@useorgx/openclaw-plugin 0.4.8 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +35 -0
- package/dashboard/dist/assets/BJgZIVUQ.js +53 -0
- package/dashboard/dist/assets/BJgZIVUQ.js.br +0 -0
- package/dashboard/dist/assets/BJgZIVUQ.js.gz +0 -0
- package/dashboard/dist/assets/BXWDRGm-.js +1 -0
- package/dashboard/dist/assets/BXWDRGm-.js.br +0 -0
- package/dashboard/dist/assets/BXWDRGm-.js.gz +0 -0
- package/dashboard/dist/assets/BgOYB78t.js +4 -0
- package/dashboard/dist/assets/BgOYB78t.js.br +0 -0
- package/dashboard/dist/assets/BgOYB78t.js.gz +0 -0
- package/dashboard/dist/assets/C-KIc3Wc.js.br +0 -0
- package/dashboard/dist/assets/C-KIc3Wc.js.gz +0 -0
- package/dashboard/dist/assets/CE38zU4U.js +1 -0
- package/dashboard/dist/assets/CE38zU4U.js.br +0 -0
- package/dashboard/dist/assets/CE38zU4U.js.gz +0 -0
- package/dashboard/dist/assets/CFGKRAzG.js +1 -0
- package/dashboard/dist/assets/CFGKRAzG.js.br +0 -0
- package/dashboard/dist/assets/CFGKRAzG.js.gz +0 -0
- package/dashboard/dist/assets/CGGR2GZh.js +1 -0
- package/dashboard/dist/assets/CGGR2GZh.js.br +0 -0
- package/dashboard/dist/assets/CGGR2GZh.js.gz +0 -0
- package/dashboard/dist/assets/CL_wXqR7.js +1 -0
- package/dashboard/dist/assets/CL_wXqR7.js.br +0 -0
- package/dashboard/dist/assets/CL_wXqR7.js.gz +0 -0
- package/dashboard/dist/assets/CPFiTmlw.js +8 -0
- package/dashboard/dist/assets/CPFiTmlw.js.br +0 -0
- package/dashboard/dist/assets/CPFiTmlw.js.gz +0 -0
- package/dashboard/dist/assets/CZZTvkQZ.js +1 -0
- package/dashboard/dist/assets/CZZTvkQZ.js.br +0 -0
- package/dashboard/dist/assets/CZZTvkQZ.js.gz +0 -0
- package/dashboard/dist/assets/{CpJsfbXo.js → CxQ08qFN.js} +2 -2
- package/dashboard/dist/assets/CxQ08qFN.js.br +0 -0
- package/dashboard/dist/assets/CxQ08qFN.js.gz +0 -0
- package/dashboard/dist/assets/D-bf6hEI.js +213 -0
- package/dashboard/dist/assets/D-bf6hEI.js.br +0 -0
- package/dashboard/dist/assets/D-bf6hEI.js.gz +0 -0
- package/dashboard/dist/assets/DG6y9wJI.js +2 -0
- package/dashboard/dist/assets/DG6y9wJI.js.br +0 -0
- package/dashboard/dist/assets/DG6y9wJI.js.gz +0 -0
- package/dashboard/dist/assets/DNxKz-GV.js +1 -0
- package/dashboard/dist/assets/DNxKz-GV.js.br +0 -0
- package/dashboard/dist/assets/DNxKz-GV.js.gz +0 -0
- package/dashboard/dist/assets/DW_rKUic.js +11 -0
- package/dashboard/dist/assets/DW_rKUic.js.br +0 -0
- package/dashboard/dist/assets/DW_rKUic.js.gz +0 -0
- package/dashboard/dist/assets/DbNoijHm.js +1 -0
- package/dashboard/dist/assets/DbNoijHm.js.br +0 -0
- package/dashboard/dist/assets/DbNoijHm.js.gz +0 -0
- package/dashboard/dist/assets/DjcdE6jC.js +2 -0
- package/dashboard/dist/assets/DjcdE6jC.js.br +0 -0
- package/dashboard/dist/assets/DjcdE6jC.js.gz +0 -0
- package/dashboard/dist/assets/FZYuCDnt.js +1 -0
- package/dashboard/dist/assets/FZYuCDnt.js.br +0 -0
- package/dashboard/dist/assets/FZYuCDnt.js.gz +0 -0
- package/dashboard/dist/assets/PAUiij_z.js +1 -0
- package/dashboard/dist/assets/PAUiij_z.js.br +0 -0
- package/dashboard/dist/assets/PAUiij_z.js.gz +0 -0
- package/dashboard/dist/assets/cNrhgGc1.js +8 -0
- package/dashboard/dist/assets/cNrhgGc1.js.br +0 -0
- package/dashboard/dist/assets/cNrhgGc1.js.gz +0 -0
- package/dashboard/dist/assets/h5biQs2I.css +1 -0
- package/dashboard/dist/assets/h5biQs2I.css.br +0 -0
- package/dashboard/dist/assets/h5biQs2I.css.gz +0 -0
- package/dashboard/dist/assets/ic2FaMnh.js +1 -0
- package/dashboard/dist/assets/ic2FaMnh.js.br +0 -0
- package/dashboard/dist/assets/ic2FaMnh.js.gz +0 -0
- package/dashboard/dist/assets/nByHNHoW.js +1 -0
- package/dashboard/dist/assets/nByHNHoW.js.br +0 -0
- package/dashboard/dist/assets/nByHNHoW.js.gz +0 -0
- package/dashboard/dist/assets/qm8xLgv-.css +1 -0
- package/dashboard/dist/assets/qm8xLgv-.css.br +0 -0
- package/dashboard/dist/assets/qm8xLgv-.css.gz +0 -0
- package/dashboard/dist/assets/tS9mbYZi.js +1 -0
- package/dashboard/dist/assets/tS9mbYZi.js.br +0 -0
- package/dashboard/dist/assets/tS9mbYZi.js.gz +0 -0
- package/dashboard/dist/brand/anthropic-mark.svg.br +0 -0
- package/dashboard/dist/brand/anthropic-mark.svg.gz +0 -0
- package/dashboard/dist/brand/openai-mark.svg.br +0 -0
- package/dashboard/dist/brand/openai-mark.svg.gz +0 -0
- package/dashboard/dist/brand/openclaw-mark.svg.br +0 -0
- package/dashboard/dist/brand/openclaw-mark.svg.gz +0 -0
- package/dashboard/dist/brand/xandy-orchestrator.png +0 -0
- package/dashboard/dist/index.html +7 -5
- package/dashboard/dist/index.html.br +0 -0
- package/dashboard/dist/index.html.gz +0 -0
- package/dist/activity-actor-fields.js +26 -4
- package/dist/activity-store.js +38 -26
- package/dist/agent-context-store.js +84 -42
- package/dist/agent-run-store.js +49 -28
- package/dist/agent-suite.d.ts +9 -0
- package/dist/agent-suite.js +150 -17
- package/dist/artifacts/artifact-domain-schemas.d.ts +66 -0
- package/dist/artifacts/artifact-domain-schemas.js +357 -0
- package/dist/artifacts/register-artifact.d.ts +4 -3
- package/dist/artifacts/register-artifact.js +170 -57
- package/dist/auth/flows.d.ts +47 -0
- package/dist/auth/flows.js +169 -0
- package/dist/auth-store.js +6 -26
- package/dist/byok-store.js +5 -19
- package/dist/chat-store.d.ts +157 -0
- package/dist/chat-store.js +586 -0
- package/dist/cli/orgx.d.ts +66 -0
- package/dist/cli/orgx.js +102 -0
- package/dist/config/refresh.d.ts +32 -0
- package/dist/config/refresh.js +55 -0
- package/dist/config/resolution.d.ts +37 -0
- package/dist/config/resolution.js +178 -0
- package/dist/contracts/client.d.ts +43 -3
- package/dist/contracts/client.js +159 -30
- package/dist/contracts/retro-schema.d.ts +81 -0
- package/dist/contracts/retro-schema.js +80 -0
- package/dist/contracts/shared-types.d.ts +306 -0
- package/dist/contracts/shared-types.js +179 -0
- package/dist/contracts/skill-pack-schema.d.ts +192 -0
- package/dist/contracts/skill-pack-schema.js +180 -0
- package/dist/contracts/types.d.ts +224 -132
- package/dist/contracts/types.js +5 -0
- package/dist/entities/auto-assignment.d.ts +36 -0
- package/dist/entities/auto-assignment.js +141 -0
- package/dist/entity-comment-store.js +5 -25
- package/dist/event-sanitization.d.ts +11 -0
- package/dist/event-sanitization.js +113 -0
- package/dist/fs-utils.js +13 -1
- package/dist/gateway-watchdog.d.ts +5 -0
- package/dist/gateway-watchdog.js +50 -0
- package/dist/hash-utils.d.ts +2 -0
- package/dist/hash-utils.js +12 -0
- package/dist/hooks/post-reporting-event.mjs +1 -5
- package/dist/http/helpers/activity-headline.d.ts +10 -0
- package/dist/http/helpers/activity-headline.js +73 -0
- package/dist/http/helpers/artifact-fallback.d.ts +13 -0
- package/dist/http/helpers/artifact-fallback.js +148 -0
- package/dist/http/helpers/auto-continue-engine.d.ts +486 -0
- package/dist/http/helpers/auto-continue-engine.js +3563 -0
- package/dist/http/helpers/autopilot-operations.d.ts +176 -0
- package/dist/http/helpers/autopilot-operations.js +554 -0
- package/dist/http/helpers/autopilot-runtime.d.ts +43 -0
- package/dist/http/helpers/autopilot-runtime.js +607 -0
- package/dist/http/helpers/autopilot-slice-utils.d.ts +56 -0
- package/dist/http/helpers/autopilot-slice-utils.js +899 -0
- package/dist/http/helpers/decision-mapper.d.ts +52 -0
- package/dist/http/helpers/decision-mapper.js +260 -0
- package/dist/http/helpers/dispatch-lifecycle.d.ts +119 -0
- package/dist/http/helpers/dispatch-lifecycle.js +809 -0
- package/dist/http/helpers/hash-utils.d.ts +1 -0
- package/dist/http/helpers/hash-utils.js +1 -0
- package/dist/http/helpers/kickoff-context.d.ts +12 -0
- package/dist/http/helpers/kickoff-context.js +228 -0
- package/dist/http/helpers/llm-client.d.ts +47 -0
- package/dist/http/helpers/llm-client.js +256 -0
- package/dist/http/helpers/mission-control.d.ts +193 -0
- package/dist/http/helpers/mission-control.js +1383 -0
- package/dist/http/helpers/openclaw-cli.d.ts +37 -0
- package/dist/http/helpers/openclaw-cli.js +283 -0
- package/dist/http/helpers/runtime-sse.d.ts +20 -0
- package/dist/http/helpers/runtime-sse.js +110 -0
- package/dist/http/helpers/sentinel-catalog.d.ts +23 -0
- package/dist/http/helpers/sentinel-catalog.js +193 -0
- package/dist/http/helpers/session-classification.d.ts +9 -0
- package/dist/http/helpers/session-classification.js +564 -0
- package/dist/http/helpers/slice-experience-v2.d.ts +137 -0
- package/dist/http/helpers/slice-experience-v2.js +677 -0
- package/dist/http/helpers/slice-run-projections.d.ts +72 -0
- package/dist/http/helpers/slice-run-projections.js +860 -0
- package/dist/http/helpers/triage-mapper.d.ts +43 -0
- package/dist/http/helpers/triage-mapper.js +549 -0
- package/dist/http/helpers/value-utils.d.ts +6 -0
- package/dist/http/helpers/value-utils.js +72 -0
- package/dist/http/helpers/workspace-scope.d.ts +15 -0
- package/dist/http/helpers/workspace-scope.js +170 -0
- package/dist/http/index.d.ts +88 -0
- package/dist/http/index.js +3610 -0
- package/dist/http/router.d.ts +23 -0
- package/dist/http/router.js +23 -0
- package/dist/http/routes/agent-control.d.ts +79 -0
- package/dist/http/routes/agent-control.js +684 -0
- package/dist/http/routes/agent-suite.d.ts +38 -0
- package/dist/http/routes/agent-suite.js +397 -0
- package/dist/http/routes/agents-catalog.d.ts +40 -0
- package/dist/http/routes/agents-catalog.js +128 -0
- package/dist/http/routes/billing.d.ts +23 -0
- package/dist/http/routes/billing.js +55 -0
- package/dist/http/routes/chat.d.ts +19 -0
- package/dist/http/routes/chat.js +522 -0
- package/dist/http/routes/debug.d.ts +14 -0
- package/dist/http/routes/debug.js +21 -0
- package/dist/http/routes/decision-actions.d.ts +20 -0
- package/dist/http/routes/decision-actions.js +103 -0
- package/dist/http/routes/delegation.d.ts +19 -0
- package/dist/http/routes/delegation.js +32 -0
- package/dist/http/routes/dispatch-gateway-envelope.d.ts +25 -0
- package/dist/http/routes/dispatch-gateway-envelope.js +26 -0
- package/dist/http/routes/entities.d.ts +63 -0
- package/dist/http/routes/entities.js +440 -0
- package/dist/http/routes/entity-dynamic.d.ts +25 -0
- package/dist/http/routes/entity-dynamic.js +191 -0
- package/dist/http/routes/health.d.ts +22 -0
- package/dist/http/routes/health.js +49 -0
- package/dist/http/routes/live-legacy.d.ts +115 -0
- package/dist/http/routes/live-legacy.js +112 -0
- package/dist/http/routes/live-misc.d.ts +81 -0
- package/dist/http/routes/live-misc.js +426 -0
- package/dist/http/routes/live-snapshot.d.ts +136 -0
- package/dist/http/routes/live-snapshot.js +916 -0
- package/dist/http/routes/live-terminal.d.ts +11 -0
- package/dist/http/routes/live-terminal.js +261 -0
- package/dist/http/routes/live-triage.d.ts +61 -0
- package/dist/http/routes/live-triage.js +248 -0
- package/dist/http/routes/mission-control-actions.d.ts +131 -0
- package/dist/http/routes/mission-control-actions.js +1791 -0
- package/dist/http/routes/mission-control-read.d.ts +73 -0
- package/dist/http/routes/mission-control-read.js +1640 -0
- package/dist/http/routes/onboarding.d.ts +34 -0
- package/dist/http/routes/onboarding.js +101 -0
- package/dist/http/routes/realtime-orchestrator.d.ts +10 -0
- package/dist/http/routes/realtime-orchestrator.js +74 -0
- package/dist/http/routes/run-control.d.ts +27 -0
- package/dist/http/routes/run-control.js +96 -0
- package/dist/http/routes/runtime-hooks.d.ts +69 -0
- package/dist/http/routes/runtime-hooks.js +437 -0
- package/dist/http/routes/sentinels-catalog.d.ts +7 -0
- package/dist/http/routes/sentinels-catalog.js +24 -0
- package/dist/http/routes/settings-byok.d.ts +23 -0
- package/dist/http/routes/settings-byok.js +163 -0
- package/dist/http/routes/summary.d.ts +18 -0
- package/dist/http/routes/summary.js +49 -0
- package/dist/http/routes/usage.d.ts +24 -0
- package/dist/http/routes/usage.js +362 -0
- package/dist/http/routes/work-artifacts.d.ts +9 -0
- package/dist/http/routes/work-artifacts.js +55 -0
- package/dist/http/shared-state.d.ts +16 -0
- package/dist/http/shared-state.js +1 -0
- package/dist/http-handler.d.ts +1 -88
- package/dist/http-handler.js +1 -10605
- package/dist/index.js +287 -2284
- package/dist/json-utils.d.ts +1 -0
- package/dist/json-utils.js +8 -0
- package/dist/local-openclaw.js +29 -6
- package/dist/mcp-client-setup.js +3 -3
- package/dist/mcp-http-handler.js +33 -59
- package/dist/next-up-queue-store.d.ts +16 -1
- package/dist/next-up-queue-store.js +93 -25
- package/dist/outbox.d.ts +5 -0
- package/dist/outbox.js +113 -9
- package/dist/paths.js +24 -5
- package/dist/reporting/rollups.d.ts +53 -0
- package/dist/reporting/rollups.js +148 -0
- package/dist/retro/domain-templates.d.ts +45 -0
- package/dist/retro/domain-templates.js +297 -0
- package/dist/retro/quality-rubric.d.ts +33 -0
- package/dist/retro/quality-rubric.js +213 -0
- package/dist/runtime-cleanup.d.ts +18 -0
- package/dist/runtime-cleanup.js +87 -0
- package/dist/runtime-instance-store.js +5 -31
- package/dist/services/background.d.ts +34 -0
- package/dist/services/background.js +45 -0
- package/dist/services/experiment-randomization.d.ts +21 -0
- package/dist/services/experiment-randomization.js +63 -0
- package/dist/services/instrumentation.d.ts +29 -0
- package/dist/services/instrumentation.js +136 -0
- package/dist/skill-pack-state.d.ts +36 -5
- package/dist/skill-pack-state.js +273 -29
- package/dist/snapshot-store.js +5 -25
- package/dist/stores/json-store.d.ts +11 -0
- package/dist/stores/json-store.js +42 -0
- package/dist/sync/local-agent-telemetry.d.ts +13 -0
- package/dist/sync/local-agent-telemetry.js +128 -0
- package/dist/sync/outbox-replay.d.ts +55 -0
- package/dist/sync/outbox-replay.js +621 -0
- package/dist/team-context-store.d.ts +23 -0
- package/dist/team-context-store.js +116 -0
- package/dist/telemetry/posthog.js +4 -2
- package/dist/tools/core-tools.d.ts +72 -0
- package/dist/tools/core-tools.js +2270 -0
- package/dist/types.d.ts +2 -0
- package/dist/types.js +2 -0
- package/dist/worker-supervisor.js +23 -0
- package/package.json +14 -4
- package/dashboard/dist/assets/B3ziCA02.js +0 -8
- package/dashboard/dist/assets/BNeJ0kpF.js +0 -1
- package/dashboard/dist/assets/BzkiMPmM.js +0 -215
- package/dashboard/dist/assets/CUV9IHHi.js +0 -1
- package/dashboard/dist/assets/Ie7d9Iq2.css +0 -1
- package/dashboard/dist/assets/sAhvFnpk.js +0 -4
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
export function registerHealthRoutes(router, deps) {
|
|
2
|
+
async function handleHealth(query, res) {
|
|
3
|
+
const probeRemote = deps.parseBooleanQuery(query.get("probe") ?? query.get("probe_remote"));
|
|
4
|
+
try {
|
|
5
|
+
if (deps.diagnostics?.getHealth) {
|
|
6
|
+
const health = await deps.diagnostics.getHealth({ probeRemote });
|
|
7
|
+
deps.sendJson(res, 200, health);
|
|
8
|
+
return;
|
|
9
|
+
}
|
|
10
|
+
const outbox = await deps.readOutboxSummary();
|
|
11
|
+
deps.sendJson(res, 200, {
|
|
12
|
+
ok: true,
|
|
13
|
+
status: "ok",
|
|
14
|
+
generatedAt: new Date().toISOString(),
|
|
15
|
+
checks: [],
|
|
16
|
+
plugin: {
|
|
17
|
+
baseUrl: deps.baseUrl,
|
|
18
|
+
},
|
|
19
|
+
auth: {
|
|
20
|
+
hasApiKey: deps.hasApiKey,
|
|
21
|
+
},
|
|
22
|
+
outbox: {
|
|
23
|
+
pendingTotal: outbox.pendingTotal,
|
|
24
|
+
pendingByQueue: outbox.pendingByQueue,
|
|
25
|
+
oldestEventAt: outbox.oldestEventAt,
|
|
26
|
+
newestEventAt: outbox.newestEventAt,
|
|
27
|
+
replayStatus: "idle",
|
|
28
|
+
lastReplayAttemptAt: null,
|
|
29
|
+
lastReplaySuccessAt: null,
|
|
30
|
+
lastReplayFailureAt: null,
|
|
31
|
+
lastReplayError: null,
|
|
32
|
+
},
|
|
33
|
+
remote: {
|
|
34
|
+
enabled: false,
|
|
35
|
+
reachable: null,
|
|
36
|
+
latencyMs: null,
|
|
37
|
+
error: null,
|
|
38
|
+
},
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
catch (err) {
|
|
42
|
+
deps.sendJson(res, 500, {
|
|
43
|
+
error: deps.safeErrorMessage(err),
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
router.add("GET", "health", async ({ query, res }) => handleHealth(query, res), "Health summary");
|
|
48
|
+
router.add("HEAD", "health", async ({ query, res }) => handleHealth(query, res), "Health summary (HEAD)");
|
|
49
|
+
}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import type { LiveActivityItem, SessionTreeResponse } from "../../types.js";
|
|
2
|
+
import type { RuntimeInstanceRecord } from "../../runtime-instance-store.js";
|
|
3
|
+
import type { AgentLaunchContext, RunLaunchContext } from "../../agent-context-store.js";
|
|
4
|
+
import type { Router } from "../router.js";
|
|
5
|
+
type LocalSnapshot = Awaited<ReturnType<typeof import("../../local-openclaw.js").loadLocalOpenClawSnapshot>>;
|
|
6
|
+
type AgentContextBundle = {
|
|
7
|
+
agents: Record<string, AgentLaunchContext>;
|
|
8
|
+
runs?: Record<string, RunLaunchContext>;
|
|
9
|
+
};
|
|
10
|
+
type LocalLiveActivity = {
|
|
11
|
+
activities: LiveActivityItem[];
|
|
12
|
+
total: number;
|
|
13
|
+
};
|
|
14
|
+
type LiveActivityPage = {
|
|
15
|
+
activities: LiveActivityItem[];
|
|
16
|
+
cursor?: string | null;
|
|
17
|
+
nextCursor?: string | null;
|
|
18
|
+
prevCursor?: string | null;
|
|
19
|
+
hasMore?: boolean;
|
|
20
|
+
};
|
|
21
|
+
type LiveSessionsResponse = SessionTreeResponse;
|
|
22
|
+
type LiveActivityResponse = {
|
|
23
|
+
activities: LiveActivityItem[];
|
|
24
|
+
total?: number;
|
|
25
|
+
} & Record<string, unknown>;
|
|
26
|
+
type RouteReqLike = {
|
|
27
|
+
on?: (event: string, listener: () => void) => void;
|
|
28
|
+
};
|
|
29
|
+
type RouteResLike = {
|
|
30
|
+
write?: (chunk: string | Buffer) => boolean | void;
|
|
31
|
+
writeHead: (statusCode: number, headers?: Record<string, string>) => unknown;
|
|
32
|
+
end: (chunk?: string | Buffer) => void;
|
|
33
|
+
writableEnded?: boolean;
|
|
34
|
+
on?: (event: string, listener: () => void) => void;
|
|
35
|
+
once?: (event: string, listener: () => void) => void;
|
|
36
|
+
};
|
|
37
|
+
type RegisterLiveLegacyRoutesDeps<TRes extends RouteResLike> = {
|
|
38
|
+
getLiveSessions: (input: {
|
|
39
|
+
initiative: string | null;
|
|
40
|
+
projectId: string | null;
|
|
41
|
+
limit: number | undefined;
|
|
42
|
+
}) => Promise<LiveSessionsResponse>;
|
|
43
|
+
getLiveActivity: (input: {
|
|
44
|
+
run: string | null;
|
|
45
|
+
since: string | null;
|
|
46
|
+
projectId: string | null;
|
|
47
|
+
limit: number | undefined;
|
|
48
|
+
}) => Promise<LiveActivityResponse>;
|
|
49
|
+
listInitiativeIdsForProject: (input: {
|
|
50
|
+
projectId: string;
|
|
51
|
+
}) => Promise<string[]>;
|
|
52
|
+
listRuntimeInstances: (input: {
|
|
53
|
+
limit: number;
|
|
54
|
+
}) => RuntimeInstanceRecord[];
|
|
55
|
+
injectRuntimeInstancesAsSessions: (input: SessionTreeResponse, instances: RuntimeInstanceRecord[]) => SessionTreeResponse;
|
|
56
|
+
enrichSessionsWithRuntime: (input: SessionTreeResponse, instances: RuntimeInstanceRecord[]) => SessionTreeResponse;
|
|
57
|
+
loadLocalOpenClawSnapshot: (limit: number) => Promise<LocalSnapshot>;
|
|
58
|
+
toLocalSessionTree: (snapshot: LocalSnapshot, limit?: number) => SessionTreeResponse;
|
|
59
|
+
readAgentContexts: () => AgentContextBundle;
|
|
60
|
+
applyAgentContextsToSessionTree: (input: SessionTreeResponse, contexts: {
|
|
61
|
+
agents: Record<string, AgentLaunchContext>;
|
|
62
|
+
runs: Record<string, RunLaunchContext>;
|
|
63
|
+
}) => SessionTreeResponse;
|
|
64
|
+
listActivityPage: (input: {
|
|
65
|
+
limit: number;
|
|
66
|
+
runId: string | null;
|
|
67
|
+
since: string | null;
|
|
68
|
+
until: string | null;
|
|
69
|
+
cursor: string | null;
|
|
70
|
+
}) => LiveActivityPage;
|
|
71
|
+
applyAgentContextsToActivity: (input: LiveActivityItem[], contexts: {
|
|
72
|
+
agents: Record<string, AgentLaunchContext>;
|
|
73
|
+
runs: Record<string, RunLaunchContext>;
|
|
74
|
+
}) => LiveActivityItem[];
|
|
75
|
+
appendActivityItems: (items: LiveActivityItem[]) => void;
|
|
76
|
+
activityWarmByKey: Map<string, number>;
|
|
77
|
+
activityWarmThrottleMs: number;
|
|
78
|
+
outboxReadAllItems: () => Promise<LiveActivityItem[]>;
|
|
79
|
+
toLocalLiveActivity: (snapshot: LocalSnapshot, limit?: number) => Promise<LocalLiveActivity>;
|
|
80
|
+
loadLocalTurnDetail: (input: {
|
|
81
|
+
turnId: string;
|
|
82
|
+
sessionKey: string | null;
|
|
83
|
+
runId: string | null;
|
|
84
|
+
}) => Promise<Record<string, unknown> | null>;
|
|
85
|
+
sendJson: (res: TRes, status: number, payload: unknown) => void;
|
|
86
|
+
safeErrorMessage: (err: unknown) => string;
|
|
87
|
+
sendHtml: (res: TRes, status: number, html: string) => void;
|
|
88
|
+
resolveFilesystemOpenPath: (rawPath: string) => string;
|
|
89
|
+
escapeHtml: (value: string) => string;
|
|
90
|
+
statSync: (path: string) => {
|
|
91
|
+
isDirectory: () => boolean;
|
|
92
|
+
isFile: () => boolean;
|
|
93
|
+
size: number;
|
|
94
|
+
};
|
|
95
|
+
readdirSync: (path: string) => string[];
|
|
96
|
+
existsSync: (path: string) => boolean;
|
|
97
|
+
resolvePath: (...segments: string[]) => string;
|
|
98
|
+
readFilePreview: (path: string, totalBytes: number) => {
|
|
99
|
+
previewBuffer: Buffer;
|
|
100
|
+
truncated: boolean;
|
|
101
|
+
};
|
|
102
|
+
filePreviewMaxBytes: number;
|
|
103
|
+
filePreviewMaxDirEntries: number;
|
|
104
|
+
securityHeaders: Record<string, string>;
|
|
105
|
+
corsHeaders: Record<string, string>;
|
|
106
|
+
config: {
|
|
107
|
+
baseUrl: string;
|
|
108
|
+
apiKey: string;
|
|
109
|
+
userId: string;
|
|
110
|
+
};
|
|
111
|
+
isUserScopedApiKey: (apiKey: string) => boolean;
|
|
112
|
+
streamIdleTimeoutMs: number;
|
|
113
|
+
};
|
|
114
|
+
export declare function registerLiveLegacyRoutes<TReq extends RouteReqLike, TRes extends RouteResLike>(router: Router<Record<string, never>, TReq, TRes>, deps: RegisterLiveLegacyRoutesDeps<TRes>): void;
|
|
115
|
+
export {};
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
export function registerLiveLegacyRoutes(router, deps) {
|
|
2
|
+
const sendDeprecated = (res, endpoint, replacement) => {
|
|
3
|
+
deps.sendJson(res, 410, {
|
|
4
|
+
error: `${endpoint} is deprecated`,
|
|
5
|
+
replacement,
|
|
6
|
+
required_scope: "workspace_id",
|
|
7
|
+
});
|
|
8
|
+
};
|
|
9
|
+
async function renderLiveSessions(query, res) {
|
|
10
|
+
sendDeprecated(res, "/orgx/api/live/sessions", "/orgx/api/live/snapshot");
|
|
11
|
+
void query;
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
router.add("GET", "live/sessions", async ({ query, res }) => renderLiveSessions(query, res), "Legacy live sessions endpoint");
|
|
15
|
+
router.add("HEAD", "live/sessions", async ({ query, res }) => renderLiveSessions(query, res), "Legacy live sessions endpoint (HEAD)");
|
|
16
|
+
async function renderLiveActivityPage(query, res) {
|
|
17
|
+
sendDeprecated(res, "/orgx/api/live/activity/page", "/orgx/api/live/snapshot-v2");
|
|
18
|
+
void query;
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
router.add("GET", "live/activity/page", async ({ query, res }) => renderLiveActivityPage(query, res), "Paginated live activity");
|
|
22
|
+
router.add("HEAD", "live/activity/page", async ({ query, res }) => renderLiveActivityPage(query, res), "Paginated live activity (HEAD)");
|
|
23
|
+
async function renderLiveActivity(query, res) {
|
|
24
|
+
sendDeprecated(res, "/orgx/api/live/activity", "/orgx/api/live/snapshot");
|
|
25
|
+
void query;
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
router.add("GET", "live/activity", async ({ query, res }) => renderLiveActivity(query, res), "Legacy live activity endpoint");
|
|
29
|
+
router.add("HEAD", "live/activity", async ({ query, res }) => renderLiveActivity(query, res), "Legacy live activity endpoint (HEAD)");
|
|
30
|
+
async function renderLiveActivityDetail(query, res) {
|
|
31
|
+
sendDeprecated(res, "/orgx/api/live/activity/detail", "/orgx/api/live/snapshot-v2");
|
|
32
|
+
void query;
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
router.add("GET", "live/activity/detail", async ({ query, res }) => renderLiveActivityDetail(query, res), "Detailed activity turn view");
|
|
36
|
+
router.add("HEAD", "live/activity/detail", async ({ query, res }) => renderLiveActivityDetail(query, res), "Detailed activity turn view (HEAD)");
|
|
37
|
+
router.add("GET", "live/filesystem/open", ({ query, res }) => {
|
|
38
|
+
const rawPath = query.get("path") ?? "";
|
|
39
|
+
if (!rawPath.trim()) {
|
|
40
|
+
deps.sendJson(res, 400, { error: "path is required" });
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
const pathInput = rawPath.trim();
|
|
44
|
+
if (/^https?:\/\//i.test(pathInput)) {
|
|
45
|
+
res.writeHead(302, {
|
|
46
|
+
Location: pathInput,
|
|
47
|
+
...deps.securityHeaders,
|
|
48
|
+
...deps.corsHeaders,
|
|
49
|
+
});
|
|
50
|
+
res.end();
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
const resolvedPath = deps.resolveFilesystemOpenPath(pathInput);
|
|
54
|
+
const escapedInput = deps.escapeHtml(pathInput);
|
|
55
|
+
const escapedResolved = deps.escapeHtml(resolvedPath);
|
|
56
|
+
const shellPath = resolvedPath.replaceAll("'", "'\\''");
|
|
57
|
+
if (!deps.existsSync(resolvedPath)) {
|
|
58
|
+
deps.sendHtml(res, 404, `<!doctype html><html><head><meta charset="utf-8"/><title>Path Not Found</title><style>body{margin:0;padding:24px;background:#080808;color:#e5e7eb;font:14px/1.5 ui-sans-serif,system-ui,-apple-system,Segoe UI,sans-serif}pre{background:#0f0f0f;border:1px solid rgba(255,255,255,.08);padding:12px;border-radius:10px;white-space:pre-wrap;word-break:break-word}a{color:#BFFF00}</style></head><body><h1 style="margin:0 0 8px;font-size:18px;">Path not found</h1><p style="margin:0 0 12px;color:#9ca3af;">The evidence path no longer exists.</p><pre>${escapedInput}</pre><p style="margin:12px 0 0;color:#9ca3af;">Resolved as:</p><pre>${escapedResolved}</pre></body></html>`);
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
try {
|
|
62
|
+
const stats = deps.statSync(resolvedPath);
|
|
63
|
+
if (stats.isDirectory()) {
|
|
64
|
+
const entries = deps.readdirSync(resolvedPath);
|
|
65
|
+
const visibleEntries = entries.slice(0, deps.filePreviewMaxDirEntries);
|
|
66
|
+
const items = visibleEntries
|
|
67
|
+
.map((name) => {
|
|
68
|
+
const nextPath = deps.resolvePath(resolvedPath, name);
|
|
69
|
+
const href = `/orgx/api/live/filesystem/open?path=${encodeURIComponent(nextPath)}`;
|
|
70
|
+
return `<li style="margin:0 0 6px;"><a href="${href}" target="_blank" rel="noreferrer" style="color:#BFFF00;text-decoration:none;">${deps.escapeHtml(name)}</a></li>`;
|
|
71
|
+
})
|
|
72
|
+
.join("");
|
|
73
|
+
const overflowNote = entries.length > visibleEntries.length
|
|
74
|
+
? `<p style="margin:12px 0 0;color:#9ca3af;">Showing ${visibleEntries.length} of ${entries.length} entries.</p>`
|
|
75
|
+
: "";
|
|
76
|
+
deps.sendHtml(res, 200, `<!doctype html><html><head><meta charset="utf-8"/><title>Directory Preview</title><style>body{margin:0;padding:24px;background:#080808;color:#e5e7eb;font:14px/1.5 ui-sans-serif,system-ui,-apple-system,Segoe UI,sans-serif}pre,ul{background:#0f0f0f;border:1px solid rgba(255,255,255,.08);padding:12px;border-radius:10px}ul{list-style:none;margin:0;max-height:70vh;overflow:auto}pre{white-space:pre-wrap;word-break:break-word}code{color:#7dd3c0}</style></head><body><h1 style="margin:0 0 8px;font-size:18px;">Directory</h1><p style="margin:0 0 12px;color:#9ca3af;">${escapedResolved}</p><ul>${items || "<li style=\"color:#9ca3af;\">(empty)</li>"}</ul>${overflowNote}<p style="margin:12px 0 0;color:#9ca3af;">Tip: open in terminal with <code>ls -la '${deps.escapeHtml(shellPath)}'</code></p></body></html>`);
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
if (!stats.isFile()) {
|
|
80
|
+
deps.sendHtml(res, 200, `<!doctype html><html><head><meta charset="utf-8"/><title>Unsupported Path</title><style>body{margin:0;padding:24px;background:#080808;color:#e5e7eb;font:14px/1.5 ui-sans-serif,system-ui,-apple-system,Segoe UI,sans-serif}pre{background:#0f0f0f;border:1px solid rgba(255,255,255,.08);padding:12px;border-radius:10px;white-space:pre-wrap;word-break:break-word}</style></head><body><h1 style="margin:0 0 8px;font-size:18px;">Unsupported path type</h1><p style="margin:0 0 12px;color:#9ca3af;">Only files and directories are previewable.</p><pre>${escapedResolved}</pre></body></html>`);
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
const totalBytes = Number.isFinite(stats.size) ? Math.max(0, stats.size) : 0;
|
|
84
|
+
const { previewBuffer, truncated } = deps.readFilePreview(resolvedPath, totalBytes);
|
|
85
|
+
const isBinary = previewBuffer.includes(0);
|
|
86
|
+
const sizeLabel = `${totalBytes.toLocaleString()} bytes`;
|
|
87
|
+
if (isBinary) {
|
|
88
|
+
deps.sendHtml(res, 200, `<!doctype html><html><head><meta charset="utf-8"/><title>Binary File</title><style>body{margin:0;padding:24px;background:#080808;color:#e5e7eb;font:14px/1.5 ui-sans-serif,system-ui,-apple-system,Segoe UI,sans-serif}pre{background:#0f0f0f;border:1px solid rgba(255,255,255,.08);padding:12px;border-radius:10px;white-space:pre-wrap;word-break:break-word}code{color:#7dd3c0}</style></head><body><h1 style="margin:0 0 8px;font-size:18px;">Binary file</h1><p style="margin:0 0 12px;color:#9ca3af;">Cannot render binary content in browser preview.</p><pre>${escapedResolved}\n${deps.escapeHtml(sizeLabel)}</pre><p style="margin:12px 0 0;color:#9ca3af;">Inspect in terminal with <code>file '${deps.escapeHtml(shellPath)}'</code></p></body></html>`);
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
const previewText = previewBuffer.toString("utf8");
|
|
92
|
+
const truncationNote = truncated
|
|
93
|
+
? `<p style="margin:12px 0 0;color:#9ca3af;">Preview truncated to first ${deps.filePreviewMaxBytes.toLocaleString()} bytes.</p>`
|
|
94
|
+
: "";
|
|
95
|
+
deps.sendHtml(res, 200, `<!doctype html><html><head><meta charset="utf-8"/><title>File Preview</title><style>body{margin:0;padding:24px;background:#080808;color:#e5e7eb;font:14px/1.5 ui-sans-serif,system-ui,-apple-system,Segoe UI,sans-serif}pre{background:#0f0f0f;border:1px solid rgba(255,255,255,.08);padding:12px;border-radius:10px;white-space:pre;overflow:auto;max-height:75vh}code{color:#7dd3c0}</style></head><body><h1 style="margin:0 0 8px;font-size:18px;">File preview</h1><p style="margin:0 0 12px;color:#9ca3af;">${escapedResolved}</p><p style="margin:0 0 12px;color:#9ca3af;">${deps.escapeHtml(sizeLabel)}</p><pre>${deps.escapeHtml(previewText)}</pre>${truncationNote}<p style="margin:12px 0 0;color:#9ca3af;">Open in terminal with <code>cat '${deps.escapeHtml(shellPath)}'</code></p></body></html>`);
|
|
96
|
+
}
|
|
97
|
+
catch (err) {
|
|
98
|
+
deps.sendHtml(res, 500, `<!doctype html><html><head><meta charset="utf-8"/><title>Preview Error</title><style>body{margin:0;padding:24px;background:#080808;color:#e5e7eb;font:14px/1.5 ui-sans-serif,system-ui,-apple-system,Segoe UI,sans-serif}pre{background:#0f0f0f;border:1px solid rgba(255,255,255,.08);padding:12px;border-radius:10px;white-space:pre-wrap;word-break:break-word}</style></head><body><h1 style="margin:0 0 8px;font-size:18px;">Unable to preview path</h1><p style="margin:0 0 12px;color:#9ca3af;">${deps.escapeHtml(deps.safeErrorMessage(err))}</p><pre>${escapedResolved}</pre></body></html>`);
|
|
99
|
+
}
|
|
100
|
+
}, "Open filesystem evidence path");
|
|
101
|
+
router.add("*", "live/filesystem/open", ({ res }) => {
|
|
102
|
+
deps.sendJson(res, 405, { error: "Use GET /orgx/api/live/filesystem/open?path=..." });
|
|
103
|
+
}, "Reject unsupported methods for live/filesystem/open");
|
|
104
|
+
async function renderLiveStream(query, req, res) {
|
|
105
|
+
sendDeprecated(res, "/orgx/api/live/stream", "/orgx/api/live/snapshot-v2");
|
|
106
|
+
void query;
|
|
107
|
+
void req;
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
router.add("GET", "live/stream", async ({ query, req, res }) => renderLiveStream(query, req, res), "Proxy live SSE stream");
|
|
111
|
+
router.add("HEAD", "live/stream", async ({ query, req, res }) => renderLiveStream(query, req, res), "Proxy live SSE stream (HEAD)");
|
|
112
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import type { Router } from "../router.js";
|
|
2
|
+
import type { Entity } from "../../types.js";
|
|
3
|
+
type JsonRecord = Record<string, unknown>;
|
|
4
|
+
type LiveInitiativesResponse = {
|
|
5
|
+
initiatives: unknown[];
|
|
6
|
+
total?: number;
|
|
7
|
+
pagination?: {
|
|
8
|
+
limit?: number;
|
|
9
|
+
offset?: number;
|
|
10
|
+
has_more?: boolean;
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
type LiveDecisionsResponse = {
|
|
14
|
+
decisions: Entity[];
|
|
15
|
+
total: number;
|
|
16
|
+
};
|
|
17
|
+
type HandoffsResponse = {
|
|
18
|
+
handoffs: unknown[];
|
|
19
|
+
};
|
|
20
|
+
type LocalSnapshot = Awaited<ReturnType<typeof import("../../local-openclaw.js").loadLocalOpenClawSnapshot>>;
|
|
21
|
+
type RegisterLiveMiscRoutesDeps<TReq, TRes> = {
|
|
22
|
+
parseJsonRequest: (req: TReq) => Promise<JsonRecord>;
|
|
23
|
+
pickString: (input: Record<string, unknown>, keys: string[]) => string | null;
|
|
24
|
+
summarizeActivityHeadline: (input: {
|
|
25
|
+
text: string;
|
|
26
|
+
title: string | null;
|
|
27
|
+
type: string | null;
|
|
28
|
+
}) => Promise<{
|
|
29
|
+
headline: string;
|
|
30
|
+
source: string;
|
|
31
|
+
model: string | null;
|
|
32
|
+
}>;
|
|
33
|
+
getLiveAgents: (input: {
|
|
34
|
+
initiative: string | null;
|
|
35
|
+
projectId: string | null;
|
|
36
|
+
includeIdle: boolean | undefined;
|
|
37
|
+
}) => Promise<unknown>;
|
|
38
|
+
getLiveInitiatives: (input: {
|
|
39
|
+
id: string | null;
|
|
40
|
+
projectId: string | null;
|
|
41
|
+
limit: number | undefined;
|
|
42
|
+
offset: number | undefined;
|
|
43
|
+
}) => Promise<LiveInitiativesResponse>;
|
|
44
|
+
getLiveDecisions: (input: {
|
|
45
|
+
status: string;
|
|
46
|
+
projectId: string | null;
|
|
47
|
+
limit: number;
|
|
48
|
+
}) => Promise<LiveDecisionsResponse>;
|
|
49
|
+
getHandoffs: () => Promise<HandoffsResponse>;
|
|
50
|
+
listInitiativeIdsForProject: (input: {
|
|
51
|
+
projectId: string;
|
|
52
|
+
}) => Promise<string[]>;
|
|
53
|
+
loadLocalOpenClawSnapshot: (limit: number) => Promise<LocalSnapshot>;
|
|
54
|
+
toLocalLiveAgents: (snapshot: LocalSnapshot) => {
|
|
55
|
+
agents: Array<{
|
|
56
|
+
initiativeId: string | null;
|
|
57
|
+
status: string;
|
|
58
|
+
}>;
|
|
59
|
+
};
|
|
60
|
+
toLocalLiveInitiatives: (snapshot: LocalSnapshot) => {
|
|
61
|
+
initiatives: Array<{
|
|
62
|
+
id: string;
|
|
63
|
+
title: string;
|
|
64
|
+
status: string;
|
|
65
|
+
updatedAt: string | null;
|
|
66
|
+
sessionCount: number;
|
|
67
|
+
activeAgents: number;
|
|
68
|
+
}>;
|
|
69
|
+
};
|
|
70
|
+
localInitiativeStatusOverrides: Map<string, {
|
|
71
|
+
status: string;
|
|
72
|
+
updatedAt: string;
|
|
73
|
+
}>;
|
|
74
|
+
mapDecisionEntity: (entry: Entity) => {
|
|
75
|
+
waitingMinutes: number;
|
|
76
|
+
};
|
|
77
|
+
sendJson: (res: TRes, status: number, payload: unknown) => void;
|
|
78
|
+
safeErrorMessage: (err: unknown) => string;
|
|
79
|
+
};
|
|
80
|
+
export declare function registerLiveMiscRoutes<TReq, TRes>(router: Router<Record<string, never>, TReq, TRes>, deps: RegisterLiveMiscRoutesDeps<TReq, TRes>): void;
|
|
81
|
+
export {};
|