34 lines
1.0 KiB
PHP
34 lines
1.0 KiB
PHP
<?php
|
|
/**
|
|
* ambre-list-stubs.php · listing wired-pending stubs related to capabilities
|
|
*/
|
|
header("Content-Type: application/json");
|
|
$dir = "/var/www/html/api/wired-pending";
|
|
$files = glob("$dir/intent-opus4-*.php") ?: [];
|
|
$kw = $_GET["kw"] ?? "";
|
|
$out = ["count"=>count($files), "matches"=>[]];
|
|
foreach ($files as $f) {
|
|
$name = basename($f, ".php");
|
|
$short = str_replace("intent-opus4-", "", $name);
|
|
if ($kw && stripos($short, $kw) === false) continue;
|
|
// Read metadata if array stub
|
|
ob_start();
|
|
$info = @include $f;
|
|
@ob_end_clean();
|
|
$meta = [
|
|
"name" => $short,
|
|
"size" => filesize($f),
|
|
"mtime" => gmdate("c", filemtime($f)),
|
|
];
|
|
if (is_array($info)) {
|
|
$meta["triggers"] = $info["triggers"] ?? [];
|
|
$meta["status"] = $info["status"] ?? "?";
|
|
$meta["cmd"] = $info["cmd"] ?? "?";
|
|
} else {
|
|
$meta["type"] = "direct-exec";
|
|
}
|
|
$out["matches"][] = $meta;
|
|
}
|
|
$out["matches_count"] = count($out["matches"]);
|
|
echo json_encode($out, JSON_PRETTY_PRINT|JSON_UNESCAPED_SLASHES);
|