@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,34 @@
|
|
|
1
|
+
import type { OnboardingState } from "../../types.js";
|
|
2
|
+
import type { Router } from "../router.js";
|
|
3
|
+
type JsonRecord = Record<string, unknown>;
|
|
4
|
+
type OnboardingControllerLike = {
|
|
5
|
+
startPairing: (input: {
|
|
6
|
+
openclawVersion?: string;
|
|
7
|
+
platform?: string;
|
|
8
|
+
deviceName?: string;
|
|
9
|
+
}) => Promise<{
|
|
10
|
+
pairingId: string;
|
|
11
|
+
connectUrl: string;
|
|
12
|
+
expiresAt: string | null;
|
|
13
|
+
pollIntervalMs: number | null;
|
|
14
|
+
state: OnboardingState;
|
|
15
|
+
}>;
|
|
16
|
+
getStatus: () => Promise<OnboardingState>;
|
|
17
|
+
submitManualKey: (input: {
|
|
18
|
+
apiKey: string;
|
|
19
|
+
userId?: string;
|
|
20
|
+
}) => Promise<OnboardingState>;
|
|
21
|
+
disconnect: () => Promise<OnboardingState>;
|
|
22
|
+
};
|
|
23
|
+
type RegisterOnboardingRoutesDeps<TReq, TRes> = {
|
|
24
|
+
onboarding: OnboardingControllerLike;
|
|
25
|
+
parseJsonRequest: (req: TReq) => Promise<JsonRecord>;
|
|
26
|
+
pickString: (input: unknown, keys: string[]) => string | null;
|
|
27
|
+
pickHeaderString: (headers: unknown, names: string[]) => string | null;
|
|
28
|
+
isUserScopedApiKey: (apiKey: string) => boolean;
|
|
29
|
+
sendJson: (res: TRes, status: number, payload: unknown) => void;
|
|
30
|
+
safeErrorMessage: (err: unknown) => string;
|
|
31
|
+
getOnboardingState: (state: OnboardingState) => OnboardingState;
|
|
32
|
+
};
|
|
33
|
+
export declare function registerOnboardingRoutes<TReq, TRes>(router: Router<Record<string, never>, TReq, TRes>, deps: RegisterOnboardingRoutesDeps<TReq, TRes>): void;
|
|
34
|
+
export {};
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
export function registerOnboardingRoutes(router, deps) {
|
|
2
|
+
router.add("GET", "onboarding/status", async ({ res }) => {
|
|
3
|
+
try {
|
|
4
|
+
const state = await deps.onboarding.getStatus();
|
|
5
|
+
deps.sendJson(res, 200, {
|
|
6
|
+
ok: true,
|
|
7
|
+
data: deps.getOnboardingState(state),
|
|
8
|
+
});
|
|
9
|
+
}
|
|
10
|
+
catch (err) {
|
|
11
|
+
deps.sendJson(res, 500, {
|
|
12
|
+
ok: false,
|
|
13
|
+
error: deps.safeErrorMessage(err),
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
}, "Read onboarding status");
|
|
17
|
+
router.add("POST", "onboarding/start", async ({ req, res }) => {
|
|
18
|
+
try {
|
|
19
|
+
const payload = await deps.parseJsonRequest(req);
|
|
20
|
+
const started = await deps.onboarding.startPairing({
|
|
21
|
+
openclawVersion: deps.pickString(payload, ["openclawVersion", "openclaw_version"]) ??
|
|
22
|
+
undefined,
|
|
23
|
+
platform: deps.pickString(payload, ["platform"]) ?? undefined,
|
|
24
|
+
deviceName: deps.pickString(payload, ["deviceName", "device_name"]) ?? undefined,
|
|
25
|
+
});
|
|
26
|
+
deps.sendJson(res, 200, {
|
|
27
|
+
ok: true,
|
|
28
|
+
data: {
|
|
29
|
+
pairingId: started.pairingId,
|
|
30
|
+
connectUrl: started.connectUrl,
|
|
31
|
+
expiresAt: started.expiresAt,
|
|
32
|
+
pollIntervalMs: started.pollIntervalMs,
|
|
33
|
+
state: deps.getOnboardingState(started.state),
|
|
34
|
+
},
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
catch (err) {
|
|
38
|
+
deps.sendJson(res, 400, {
|
|
39
|
+
ok: false,
|
|
40
|
+
error: deps.safeErrorMessage(err),
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
}, "Start onboarding pairing flow");
|
|
44
|
+
router.add("POST", "onboarding/manual-key", async ({ req, res }) => {
|
|
45
|
+
try {
|
|
46
|
+
const payload = await deps.parseJsonRequest(req);
|
|
47
|
+
const reqWithHeaders = req;
|
|
48
|
+
const authHeader = deps.pickHeaderString(reqWithHeaders.headers, ["authorization"]);
|
|
49
|
+
const bearerApiKey = authHeader && authHeader.toLowerCase().startsWith("bearer ")
|
|
50
|
+
? authHeader.slice("bearer ".length).trim()
|
|
51
|
+
: null;
|
|
52
|
+
const headerApiKey = deps.pickHeaderString(reqWithHeaders.headers, [
|
|
53
|
+
"x-orgx-api-key",
|
|
54
|
+
"x-api-key",
|
|
55
|
+
]);
|
|
56
|
+
const apiKey = deps.pickString(payload, ["apiKey", "api_key"]) ??
|
|
57
|
+
headerApiKey ??
|
|
58
|
+
bearerApiKey;
|
|
59
|
+
if (!apiKey) {
|
|
60
|
+
deps.sendJson(res, 400, {
|
|
61
|
+
ok: false,
|
|
62
|
+
error: "apiKey is required",
|
|
63
|
+
});
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
const requestedUserId = deps.pickString(payload, ["userId", "user_id"]) ??
|
|
67
|
+
deps.pickHeaderString(reqWithHeaders.headers, ["x-orgx-user-id", "x-user-id"]) ??
|
|
68
|
+
undefined;
|
|
69
|
+
const userId = deps.isUserScopedApiKey(apiKey) ? undefined : requestedUserId;
|
|
70
|
+
const state = await deps.onboarding.submitManualKey({
|
|
71
|
+
apiKey,
|
|
72
|
+
userId,
|
|
73
|
+
});
|
|
74
|
+
deps.sendJson(res, 200, {
|
|
75
|
+
ok: true,
|
|
76
|
+
data: deps.getOnboardingState(state),
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
catch (err) {
|
|
80
|
+
deps.sendJson(res, 400, {
|
|
81
|
+
ok: false,
|
|
82
|
+
error: deps.safeErrorMessage(err),
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
}, "Submit manual OrgX API key");
|
|
86
|
+
router.add("POST", "onboarding/disconnect", async ({ res }) => {
|
|
87
|
+
try {
|
|
88
|
+
const state = await deps.onboarding.disconnect();
|
|
89
|
+
deps.sendJson(res, 200, {
|
|
90
|
+
ok: true,
|
|
91
|
+
data: deps.getOnboardingState(state),
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
catch (err) {
|
|
95
|
+
deps.sendJson(res, 500, {
|
|
96
|
+
ok: false,
|
|
97
|
+
error: deps.safeErrorMessage(err),
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
}, "Disconnect onboarding session");
|
|
101
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Router } from "../router.js";
|
|
2
|
+
type JsonRecord = Record<string, unknown>;
|
|
3
|
+
type RegisterRealtimeOrchestratorRoutesDeps<TReq, TRes> = {
|
|
4
|
+
parseJsonRequest: (req: TReq) => Promise<JsonRecord>;
|
|
5
|
+
rawRequest: (method: "GET" | "POST" | "PATCH" | "PUT" | "DELETE", path: string, body?: unknown) => Promise<unknown>;
|
|
6
|
+
sendJson: (res: TRes, status: number, payload: unknown) => void;
|
|
7
|
+
safeErrorMessage: (err: unknown) => string;
|
|
8
|
+
};
|
|
9
|
+
export declare function registerRealtimeOrchestratorRoutes<TReq, TRes>(router: Router<Record<string, never>, TReq, TRes>, deps: RegisterRealtimeOrchestratorRoutesDeps<TReq, TRes>): void;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
function parseStatusCodeFromError(message) {
|
|
2
|
+
const normalized = message.trim();
|
|
3
|
+
const match = normalized.match(/^(\d{3})\b/);
|
|
4
|
+
if (!match)
|
|
5
|
+
return 500;
|
|
6
|
+
const value = Number(match[1]);
|
|
7
|
+
if (!Number.isFinite(value))
|
|
8
|
+
return 500;
|
|
9
|
+
if (value < 400 || value > 599)
|
|
10
|
+
return 500;
|
|
11
|
+
return value;
|
|
12
|
+
}
|
|
13
|
+
export function registerRealtimeOrchestratorRoutes(router, deps) {
|
|
14
|
+
router.add("POST", "realtime/session", async ({ req, res }) => {
|
|
15
|
+
try {
|
|
16
|
+
const payload = await deps.parseJsonRequest(req);
|
|
17
|
+
const upstream = await deps.rawRequest("POST", "/api/client/orchestrator/realtime/session", payload);
|
|
18
|
+
deps.sendJson(res, 200, upstream);
|
|
19
|
+
}
|
|
20
|
+
catch (err) {
|
|
21
|
+
const message = deps.safeErrorMessage(err);
|
|
22
|
+
deps.sendJson(res, parseStatusCodeFromError(message), { ok: false, error: message });
|
|
23
|
+
}
|
|
24
|
+
}, "Create an ephemeral GPT realtime session for orchestrator voice control");
|
|
25
|
+
router.add("POST", "orchestrator/commands/preview", async ({ req, res }) => {
|
|
26
|
+
try {
|
|
27
|
+
const payload = await deps.parseJsonRequest(req);
|
|
28
|
+
const upstream = await deps.rawRequest("POST", "/api/client/orchestrator/commands/preview", payload);
|
|
29
|
+
deps.sendJson(res, 200, upstream);
|
|
30
|
+
}
|
|
31
|
+
catch (err) {
|
|
32
|
+
const message = deps.safeErrorMessage(err);
|
|
33
|
+
deps.sendJson(res, parseStatusCodeFromError(message), { ok: false, error: message });
|
|
34
|
+
}
|
|
35
|
+
}, "Preview inferred orchestrator actions from natural language input");
|
|
36
|
+
router.add("POST", "orchestrator/commands/apply", async ({ req, res }) => {
|
|
37
|
+
try {
|
|
38
|
+
const payload = await deps.parseJsonRequest(req);
|
|
39
|
+
const upstream = await deps.rawRequest("POST", "/api/client/orchestrator/commands/apply", payload);
|
|
40
|
+
deps.sendJson(res, 200, upstream);
|
|
41
|
+
}
|
|
42
|
+
catch (err) {
|
|
43
|
+
const message = deps.safeErrorMessage(err);
|
|
44
|
+
deps.sendJson(res, parseStatusCodeFromError(message), { ok: false, error: message });
|
|
45
|
+
}
|
|
46
|
+
}, "Apply confirmed orchestrator actions");
|
|
47
|
+
router.add("GET", "orchestrator/commands/*", async ({ path, res }) => {
|
|
48
|
+
const match = path.match(/^orchestrator\/commands\/([^/]+)$/);
|
|
49
|
+
if (!match) {
|
|
50
|
+
deps.sendJson(res, 404, { ok: false, error: "Unknown API endpoint" });
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
let commandId = "";
|
|
54
|
+
try {
|
|
55
|
+
commandId = decodeURIComponent(match[1] ?? "").trim();
|
|
56
|
+
}
|
|
57
|
+
catch {
|
|
58
|
+
deps.sendJson(res, 400, { ok: false, error: "invalid command id encoding" });
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
if (!commandId) {
|
|
62
|
+
deps.sendJson(res, 400, { ok: false, error: "command id is required" });
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
try {
|
|
66
|
+
const upstream = await deps.rawRequest("GET", `/api/client/orchestrator/commands/${encodeURIComponent(commandId)}`);
|
|
67
|
+
deps.sendJson(res, 200, upstream);
|
|
68
|
+
}
|
|
69
|
+
catch (err) {
|
|
70
|
+
const message = deps.safeErrorMessage(err);
|
|
71
|
+
deps.sendJson(res, parseStatusCodeFromError(message), { ok: false, error: message });
|
|
72
|
+
}
|
|
73
|
+
}, "Read orchestrator command status");
|
|
74
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { Router } from "../router.js";
|
|
2
|
+
type JsonRecord = Record<string, unknown>;
|
|
3
|
+
type RunAction = "pause" | "resume" | "cancel" | "rollback" | "complete";
|
|
4
|
+
type RegisterRunControlRoutesDeps<TReq, TRes> = {
|
|
5
|
+
parseJsonRequest: (req: TReq) => Promise<JsonRecord>;
|
|
6
|
+
pickString: (input: Record<string, unknown>, keys: string[]) => string | null;
|
|
7
|
+
listRunCheckpoints: (runId: string) => Promise<unknown>;
|
|
8
|
+
createRunCheckpoint: (runId: string, input: {
|
|
9
|
+
reason?: string;
|
|
10
|
+
payload?: Record<string, unknown>;
|
|
11
|
+
}) => Promise<unknown>;
|
|
12
|
+
restoreRunCheckpoint: (runId: string, input: {
|
|
13
|
+
checkpointId: string;
|
|
14
|
+
reason?: string;
|
|
15
|
+
}) => Promise<unknown>;
|
|
16
|
+
runAction: (runId: string, action: Exclude<RunAction, "complete">, input: {
|
|
17
|
+
checkpointId?: string;
|
|
18
|
+
reason?: string;
|
|
19
|
+
}) => Promise<unknown>;
|
|
20
|
+
markRunCompleted: (runId: string, input: {
|
|
21
|
+
reason?: string;
|
|
22
|
+
}) => Promise<unknown>;
|
|
23
|
+
sendJson: (res: TRes, status: number, payload: unknown) => void;
|
|
24
|
+
safeErrorMessage: (err: unknown) => string;
|
|
25
|
+
};
|
|
26
|
+
export declare function registerRunControlRoutes<TReq, TRes>(router: Router<Record<string, never>, TReq, TRes>, deps: RegisterRunControlRoutesDeps<TReq, TRes>): void;
|
|
27
|
+
export {};
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
export function registerRunControlRoutes(router, deps) {
|
|
2
|
+
router.add("*", "runs/*", async ({ req, res, path }) => {
|
|
3
|
+
const method = (req.method ?? "GET").toUpperCase();
|
|
4
|
+
const runCheckpointsMatch = path.match(/^runs\/([^/]+)\/checkpoints$/);
|
|
5
|
+
const runCheckpointRestoreMatch = path.match(/^runs\/([^/]+)\/checkpoints\/([^/]+)\/restore$/);
|
|
6
|
+
const runActionMatch = path.match(/^runs\/([^/]+)\/actions\/([^/]+)$/);
|
|
7
|
+
if (runCheckpointsMatch) {
|
|
8
|
+
const runId = decodeURIComponent(runCheckpointsMatch[1]);
|
|
9
|
+
if (method === "POST") {
|
|
10
|
+
try {
|
|
11
|
+
const payload = await deps.parseJsonRequest(req);
|
|
12
|
+
const reason = deps.pickString(payload, ["reason"]) ?? undefined;
|
|
13
|
+
const rawPayload = payload.payload;
|
|
14
|
+
const checkpointPayload = rawPayload && typeof rawPayload === "object" && !Array.isArray(rawPayload)
|
|
15
|
+
? rawPayload
|
|
16
|
+
: undefined;
|
|
17
|
+
const data = await deps.createRunCheckpoint(runId, {
|
|
18
|
+
reason,
|
|
19
|
+
payload: checkpointPayload,
|
|
20
|
+
});
|
|
21
|
+
deps.sendJson(res, 200, data);
|
|
22
|
+
}
|
|
23
|
+
catch (err) {
|
|
24
|
+
deps.sendJson(res, 500, { error: deps.safeErrorMessage(err) });
|
|
25
|
+
}
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
if (method === "GET" || method === "HEAD") {
|
|
29
|
+
try {
|
|
30
|
+
const data = await deps.listRunCheckpoints(runId);
|
|
31
|
+
deps.sendJson(res, 200, data);
|
|
32
|
+
}
|
|
33
|
+
catch (err) {
|
|
34
|
+
deps.sendJson(res, 500, { error: deps.safeErrorMessage(err) });
|
|
35
|
+
}
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
deps.sendJson(res, 405, { error: "Method not allowed" });
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
if (runCheckpointRestoreMatch) {
|
|
42
|
+
if (method !== "POST") {
|
|
43
|
+
deps.sendJson(res, 405, { error: "Use POST for this endpoint" });
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
try {
|
|
47
|
+
const runId = decodeURIComponent(runCheckpointRestoreMatch[1]);
|
|
48
|
+
const checkpointId = decodeURIComponent(runCheckpointRestoreMatch[2]);
|
|
49
|
+
const payload = await deps.parseJsonRequest(req);
|
|
50
|
+
const reason = deps.pickString(payload, ["reason"]) ?? undefined;
|
|
51
|
+
const data = await deps.restoreRunCheckpoint(runId, {
|
|
52
|
+
checkpointId,
|
|
53
|
+
reason,
|
|
54
|
+
});
|
|
55
|
+
deps.sendJson(res, 200, data);
|
|
56
|
+
}
|
|
57
|
+
catch (err) {
|
|
58
|
+
deps.sendJson(res, 500, { error: deps.safeErrorMessage(err) });
|
|
59
|
+
}
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
if (runActionMatch) {
|
|
63
|
+
if (method !== "POST") {
|
|
64
|
+
deps.sendJson(res, 405, { error: "Use POST for this endpoint" });
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
try {
|
|
68
|
+
const runId = decodeURIComponent(runActionMatch[1]);
|
|
69
|
+
const action = decodeURIComponent(runActionMatch[2]);
|
|
70
|
+
const payload = await deps.parseJsonRequest(req);
|
|
71
|
+
const checkpointId = deps.pickString(payload, ["checkpointId", "checkpoint_id"]);
|
|
72
|
+
const reason = deps.pickString(payload, ["reason"]);
|
|
73
|
+
if (action === "complete") {
|
|
74
|
+
const data = await deps.markRunCompleted(runId, {
|
|
75
|
+
reason: reason ?? undefined,
|
|
76
|
+
});
|
|
77
|
+
deps.sendJson(res, 200, data);
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
const data = await deps.runAction(runId, action, {
|
|
81
|
+
checkpointId: checkpointId ?? undefined,
|
|
82
|
+
reason: reason ?? undefined,
|
|
83
|
+
});
|
|
84
|
+
deps.sendJson(res, 200, data);
|
|
85
|
+
}
|
|
86
|
+
catch (err) {
|
|
87
|
+
const actionLabel = runActionMatch ? runActionMatch[2] : "unknown";
|
|
88
|
+
const runLabel = runActionMatch ? runActionMatch[1] : "unknown";
|
|
89
|
+
console.error(`[run-control] ${actionLabel} failed for run ${runLabel}:`, err);
|
|
90
|
+
deps.sendJson(res, 500, { error: deps.safeErrorMessage(err) });
|
|
91
|
+
}
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
deps.sendJson(res, 404, { error: "Unknown API endpoint" });
|
|
95
|
+
}, "Run control (checkpoints/actions)");
|
|
96
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import type { RuntimeHookPayload } from "../../runtime-instance-store.js";
|
|
2
|
+
import type { Router } from "../router.js";
|
|
3
|
+
type JsonRecord = Record<string, unknown>;
|
|
4
|
+
type RuntimeStreamSubscriber = {
|
|
5
|
+
id: string;
|
|
6
|
+
write: (chunk: Buffer) => boolean;
|
|
7
|
+
end: () => void;
|
|
8
|
+
};
|
|
9
|
+
type RuntimeInstanceLike = {
|
|
10
|
+
id: string;
|
|
11
|
+
state: string;
|
|
12
|
+
event: string;
|
|
13
|
+
displayName: string;
|
|
14
|
+
lastHeartbeatAt: string | null;
|
|
15
|
+
lastEventAt: string;
|
|
16
|
+
runId: string | null;
|
|
17
|
+
correlationId: string | null;
|
|
18
|
+
initiativeId: string | null;
|
|
19
|
+
sourceClient: string;
|
|
20
|
+
taskId: string | null;
|
|
21
|
+
workstreamId: string | null;
|
|
22
|
+
progressPct: number | null;
|
|
23
|
+
metadata: Record<string, unknown> | null;
|
|
24
|
+
};
|
|
25
|
+
type RegisterRuntimeHookRoutesDeps<TReq, TRes> = {
|
|
26
|
+
parseJsonRequest: (req: TReq) => Promise<JsonRecord>;
|
|
27
|
+
pickString: (record: Record<string, unknown>, keys: string[]) => string | null;
|
|
28
|
+
pickNumber: (record: Record<string, unknown>, keys: string[]) => number | null;
|
|
29
|
+
pickHeaderString: (headers: Record<string, string | string[] | undefined>, names: string[]) => string | null;
|
|
30
|
+
resolveRuntimeHookToken: () => string;
|
|
31
|
+
maskSecret: (value: string | null) => string | null;
|
|
32
|
+
parseJsonSafe: <T>(value: string) => T | null;
|
|
33
|
+
sendJson: (res: TRes, status: number, payload: unknown) => void;
|
|
34
|
+
safeErrorMessage: (err: unknown) => string;
|
|
35
|
+
randomUUID: () => string;
|
|
36
|
+
listRuntimeInstances: (input: {
|
|
37
|
+
limit: number;
|
|
38
|
+
}) => unknown;
|
|
39
|
+
writeRuntimeSseEvent: (subscriber: RuntimeStreamSubscriber, event: string, payload: unknown) => void;
|
|
40
|
+
runtimeStreamSubscribers: Map<string, RuntimeStreamSubscriber>;
|
|
41
|
+
ensureRuntimeStreamTimers: () => void;
|
|
42
|
+
stopRuntimeStreamTimers: () => void;
|
|
43
|
+
upsertRuntimeInstanceFromHook: (payload: RuntimeHookPayload) => RuntimeInstanceLike;
|
|
44
|
+
broadcastRuntimeSse: (event: string, payload: unknown) => void;
|
|
45
|
+
clearSnapshotResponseCache: () => void;
|
|
46
|
+
normalizeHookPhase: (value: string | null) => "intent" | "execution" | "blocked" | "review" | "handoff" | "completed";
|
|
47
|
+
normalizeRuntimeSourceForReporting: (value: unknown) => string;
|
|
48
|
+
emitActivity: (input: {
|
|
49
|
+
initiative_id: string;
|
|
50
|
+
run_id?: string;
|
|
51
|
+
correlation_id?: string;
|
|
52
|
+
source_client: string;
|
|
53
|
+
message: string;
|
|
54
|
+
phase: "intent" | "execution" | "blocked" | "review" | "handoff" | "completed";
|
|
55
|
+
progress_pct?: number;
|
|
56
|
+
level: "info" | "warn" | "error";
|
|
57
|
+
metadata?: Record<string, unknown>;
|
|
58
|
+
}) => Promise<unknown>;
|
|
59
|
+
securityHeaders: Record<string, string>;
|
|
60
|
+
corsHeaders: Record<string, string>;
|
|
61
|
+
};
|
|
62
|
+
export declare function registerRuntimeHookRoutes<TReq, TRes extends {
|
|
63
|
+
write?: (chunk: string | Buffer) => boolean | void;
|
|
64
|
+
end: () => void;
|
|
65
|
+
writeHead: (statusCode: number, headers?: Record<string, string>) => unknown;
|
|
66
|
+
writableEnded?: boolean;
|
|
67
|
+
on?: (event: string, listener: () => void) => void;
|
|
68
|
+
}>(router: Router<Record<string, never>, TReq, TRes>, deps: RegisterRuntimeHookRoutesDeps<TReq, TRes>): void;
|
|
69
|
+
export {};
|