@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,103 @@
|
|
|
1
|
+
function extractIdsFromPayload(payload) {
|
|
2
|
+
const raw = payload.ids;
|
|
3
|
+
if (!Array.isArray(raw))
|
|
4
|
+
return [];
|
|
5
|
+
return raw
|
|
6
|
+
.filter((id) => typeof id === "string")
|
|
7
|
+
.map((id) => id.trim())
|
|
8
|
+
.filter(Boolean);
|
|
9
|
+
}
|
|
10
|
+
async function handleApproveRequest(req, res, deps, routeIds) {
|
|
11
|
+
const payload = await deps.parseJsonRequest(req);
|
|
12
|
+
const action = payload.action === "reject" ? "reject" : "approve";
|
|
13
|
+
const note = typeof payload.note === "string" && payload.note.trim().length > 0
|
|
14
|
+
? payload.note.trim()
|
|
15
|
+
: undefined;
|
|
16
|
+
const optionIdRaw = typeof payload.option_id === "string"
|
|
17
|
+
? payload.option_id
|
|
18
|
+
: typeof payload.optionId === "string"
|
|
19
|
+
? payload.optionId
|
|
20
|
+
: null;
|
|
21
|
+
const optionId = typeof optionIdRaw === "string" && optionIdRaw.trim().length > 0
|
|
22
|
+
? optionIdRaw.trim()
|
|
23
|
+
: undefined;
|
|
24
|
+
const ids = routeIds ?? extractIdsFromPayload(payload);
|
|
25
|
+
if (ids.length === 0) {
|
|
26
|
+
deps.sendJson(res, 400, {
|
|
27
|
+
error: "Decision IDs are required.",
|
|
28
|
+
expected: {
|
|
29
|
+
route: "/orgx/api/live/decisions/approve",
|
|
30
|
+
body: { ids: ["decision-id"], action: "approve|reject", option_id: "optional-option-id" },
|
|
31
|
+
},
|
|
32
|
+
});
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
const results = await deps.bulkDecideDecisions(ids, action, {
|
|
36
|
+
note,
|
|
37
|
+
optionId,
|
|
38
|
+
});
|
|
39
|
+
const resolvedIds = results
|
|
40
|
+
.map((result, index) => (result.ok === true ? ids[index] ?? null : null))
|
|
41
|
+
.filter((id) => typeof id === "string" && id.length > 0);
|
|
42
|
+
const updated = results.filter((result) => result.ok === true).length;
|
|
43
|
+
const failed = results.length - updated;
|
|
44
|
+
if (resolvedIds.length > 0 && typeof deps.emitDecisionResolvedActivity === "function") {
|
|
45
|
+
try {
|
|
46
|
+
await deps.emitDecisionResolvedActivity(resolvedIds, action, {
|
|
47
|
+
note,
|
|
48
|
+
optionId,
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
catch {
|
|
52
|
+
// best effort; decision mutation succeeded so do not fail the response
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
deps.sendJson(res, failed > 0 ? 207 : 200, {
|
|
56
|
+
action,
|
|
57
|
+
requested: ids.length,
|
|
58
|
+
updated,
|
|
59
|
+
failed,
|
|
60
|
+
results,
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
function decodeDecisionId(encodedDecisionId) {
|
|
64
|
+
try {
|
|
65
|
+
const decoded = decodeURIComponent(encodedDecisionId).trim();
|
|
66
|
+
return decoded.length > 0 ? decoded : null;
|
|
67
|
+
}
|
|
68
|
+
catch {
|
|
69
|
+
return null;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
export function registerDecisionActionsRoutes(router, deps) {
|
|
73
|
+
router.add("POST", "live/decisions/approve", async ({ req, res }) => {
|
|
74
|
+
try {
|
|
75
|
+
await handleApproveRequest(req, res, deps, null);
|
|
76
|
+
}
|
|
77
|
+
catch (err) {
|
|
78
|
+
deps.sendJson(res, 500, {
|
|
79
|
+
error: deps.safeErrorMessage(err),
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
}, "Bulk decision approve/reject");
|
|
83
|
+
router.add("POST", "live/decisions/*", async ({ req, res, path }) => {
|
|
84
|
+
const decisionApproveMatch = path.match(/^live\/decisions\/([^/]+)\/approve$/);
|
|
85
|
+
if (!decisionApproveMatch) {
|
|
86
|
+
deps.sendJson(res, 404, { error: "Unknown API endpoint" });
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
const decisionId = decodeDecisionId(decisionApproveMatch[1]);
|
|
90
|
+
if (!decisionId) {
|
|
91
|
+
deps.sendJson(res, 400, { error: "Invalid decision ID." });
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
try {
|
|
95
|
+
await handleApproveRequest(req, res, deps, [decisionId]);
|
|
96
|
+
}
|
|
97
|
+
catch (err) {
|
|
98
|
+
deps.sendJson(res, 500, {
|
|
99
|
+
error: deps.safeErrorMessage(err),
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
}, "Single decision approve/reject");
|
|
103
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { Router } from "../router.js";
|
|
2
|
+
type JsonRecord = Record<string, unknown>;
|
|
3
|
+
type DelegationClientLike = {
|
|
4
|
+
delegationPreflight: (input: {
|
|
5
|
+
intent: string;
|
|
6
|
+
acceptanceCriteria?: string[];
|
|
7
|
+
constraints?: string[];
|
|
8
|
+
domains?: string[];
|
|
9
|
+
}) => Promise<unknown>;
|
|
10
|
+
};
|
|
11
|
+
type RegisterDelegationRoutesDeps<TReq, TRes> = {
|
|
12
|
+
client: DelegationClientLike;
|
|
13
|
+
parseJsonRequest: (req: TReq) => Promise<JsonRecord>;
|
|
14
|
+
pickString: (input: JsonRecord, keys: string[]) => string | null;
|
|
15
|
+
sendJson: (res: TRes, status: number, payload: unknown) => void;
|
|
16
|
+
safeErrorMessage: (err: unknown) => string;
|
|
17
|
+
};
|
|
18
|
+
export declare function registerDelegationRoutes<TReq, TRes>(router: Router<Record<string, never>, TReq, TRes>, deps: RegisterDelegationRoutesDeps<TReq, TRes>): void;
|
|
19
|
+
export {};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
function toStringArray(value) {
|
|
2
|
+
return Array.isArray(value)
|
|
3
|
+
? value.filter((entry) => typeof entry === "string")
|
|
4
|
+
: undefined;
|
|
5
|
+
}
|
|
6
|
+
export function registerDelegationRoutes(router, deps) {
|
|
7
|
+
router.add("POST", "delegation/preflight", async ({ req, res }) => {
|
|
8
|
+
try {
|
|
9
|
+
const payload = await deps.parseJsonRequest(req);
|
|
10
|
+
const intent = deps.pickString(payload, ["intent"]);
|
|
11
|
+
if (!intent) {
|
|
12
|
+
deps.sendJson(res, 400, { error: "intent is required" });
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
const data = await deps.client.delegationPreflight({
|
|
16
|
+
intent,
|
|
17
|
+
acceptanceCriteria: toStringArray(payload.acceptanceCriteria),
|
|
18
|
+
constraints: toStringArray(payload.constraints),
|
|
19
|
+
domains: toStringArray(payload.domains),
|
|
20
|
+
});
|
|
21
|
+
deps.sendJson(res, 200, data);
|
|
22
|
+
}
|
|
23
|
+
catch (err) {
|
|
24
|
+
deps.sendJson(res, 500, {
|
|
25
|
+
error: deps.safeErrorMessage(err),
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
}, "Delegation preflight");
|
|
29
|
+
router.add("*", "delegation/preflight", ({ res }) => {
|
|
30
|
+
deps.sendJson(res, 405, { error: "Use POST /orgx/api/delegation/preflight" });
|
|
31
|
+
}, "Reject unsupported methods for delegation/preflight");
|
|
32
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export type DispatchGatewayEnvelopeInput = {
|
|
2
|
+
dispatchId?: string;
|
|
3
|
+
dispatchMode: string;
|
|
4
|
+
route: "mission-control.next-up.play" | "mission-control.auto-continue.start";
|
|
5
|
+
source: "manual_play" | "auto_continue_start";
|
|
6
|
+
initiativeId: string;
|
|
7
|
+
workstreamId?: string | null;
|
|
8
|
+
workstreamIds?: string[] | null;
|
|
9
|
+
taskIds?: string[] | null;
|
|
10
|
+
};
|
|
11
|
+
export declare function buildDispatchGatewayEnvelope(input: DispatchGatewayEnvelopeInput): {
|
|
12
|
+
readonly dispatchId: string;
|
|
13
|
+
readonly dispatchMode: string;
|
|
14
|
+
readonly executionPath: "orgx_orchestrator_gateway";
|
|
15
|
+
readonly dispatchGateway: "orchestrator-agent";
|
|
16
|
+
readonly dispatchLineage: {
|
|
17
|
+
readonly route: "mission-control.next-up.play" | "mission-control.auto-continue.start";
|
|
18
|
+
readonly source: "manual_play" | "auto_continue_start";
|
|
19
|
+
readonly dispatchedAt: string;
|
|
20
|
+
readonly initiativeId: string;
|
|
21
|
+
readonly workstreamId: string | null;
|
|
22
|
+
readonly workstreamIds: string[];
|
|
23
|
+
readonly taskIds: string[];
|
|
24
|
+
};
|
|
25
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { randomUUID } from "node:crypto";
|
|
2
|
+
function uniqueStringIds(values) {
|
|
3
|
+
return Array.from(new Set(values
|
|
4
|
+
.map((value) => (typeof value === "string" ? value.trim() : ""))
|
|
5
|
+
.filter((value) => value.length > 0)));
|
|
6
|
+
}
|
|
7
|
+
export function buildDispatchGatewayEnvelope(input) {
|
|
8
|
+
return {
|
|
9
|
+
dispatchId: input.dispatchId ?? randomUUID(),
|
|
10
|
+
dispatchMode: input.dispatchMode,
|
|
11
|
+
executionPath: "orgx_orchestrator_gateway",
|
|
12
|
+
dispatchGateway: "orchestrator-agent",
|
|
13
|
+
dispatchLineage: {
|
|
14
|
+
route: input.route,
|
|
15
|
+
source: input.source,
|
|
16
|
+
dispatchedAt: new Date().toISOString(),
|
|
17
|
+
initiativeId: input.initiativeId,
|
|
18
|
+
workstreamId: input.workstreamId ?? null,
|
|
19
|
+
workstreamIds: uniqueStringIds([
|
|
20
|
+
input.workstreamId,
|
|
21
|
+
...(input.workstreamIds ?? []),
|
|
22
|
+
]),
|
|
23
|
+
taskIds: uniqueStringIds(input.taskIds ?? []),
|
|
24
|
+
},
|
|
25
|
+
};
|
|
26
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import type { Entity, OrgSnapshot } from "../../types.js";
|
|
2
|
+
import type { Router } from "../router.js";
|
|
3
|
+
type JsonRecord = Record<string, unknown>;
|
|
4
|
+
type AutoAssignmentResult = {
|
|
5
|
+
ok: boolean;
|
|
6
|
+
assignment_source: "orchestrator" | "fallback" | "manual";
|
|
7
|
+
assigned_agents: unknown[];
|
|
8
|
+
warnings: string[];
|
|
9
|
+
updated_entity?: Entity;
|
|
10
|
+
};
|
|
11
|
+
type EntityClientLike = {
|
|
12
|
+
createEntity: (type: string, data: Record<string, unknown>) => Promise<Entity>;
|
|
13
|
+
updateEntity: (type: string, id: string, updates: Record<string, unknown>) => Promise<Entity>;
|
|
14
|
+
listEntities: (type: string, input: {
|
|
15
|
+
id?: string;
|
|
16
|
+
ids?: string[] | string;
|
|
17
|
+
search?: string;
|
|
18
|
+
status?: string;
|
|
19
|
+
initiative_id?: string;
|
|
20
|
+
project_id?: string;
|
|
21
|
+
workspace_id?: string;
|
|
22
|
+
command_center_id?: string;
|
|
23
|
+
limit?: number;
|
|
24
|
+
offset?: number;
|
|
25
|
+
}) => Promise<unknown>;
|
|
26
|
+
};
|
|
27
|
+
type RegisterEntitiesRoutesDeps<TReq, TRes> = {
|
|
28
|
+
client: EntityClientLike;
|
|
29
|
+
parseJsonRequest: (req: TReq) => Promise<JsonRecord>;
|
|
30
|
+
pickString: (input: Record<string, unknown>, keys: string[]) => string | null;
|
|
31
|
+
normalizeEntityMutationPayload: (input: Record<string, unknown>) => Record<string, unknown>;
|
|
32
|
+
resolveAutoAssignments: (input: {
|
|
33
|
+
entityId: string;
|
|
34
|
+
entityType: string;
|
|
35
|
+
initiativeId: string | null;
|
|
36
|
+
title: string;
|
|
37
|
+
summary: string | null;
|
|
38
|
+
}) => Promise<AutoAssignmentResult>;
|
|
39
|
+
setLocalInitiativeStatusOverride: (initiativeId: string, status: string) => void;
|
|
40
|
+
clearLocalInitiativeStatusOverride: (initiativeId: string) => void;
|
|
41
|
+
isUnauthorizedOrgxError: (err: unknown) => boolean;
|
|
42
|
+
applyLocalInitiativeOverrides: (rows: Array<Record<string, unknown>>) => Array<Record<string, unknown>>;
|
|
43
|
+
formatInitiatives: (snapshot: OrgSnapshot | null) => Array<{
|
|
44
|
+
id: string;
|
|
45
|
+
title: string;
|
|
46
|
+
status: string;
|
|
47
|
+
progress?: number | null;
|
|
48
|
+
}>;
|
|
49
|
+
getSnapshot: () => OrgSnapshot | null;
|
|
50
|
+
scheduleWorkstreamReassignment?: (input: {
|
|
51
|
+
initiativeId: string;
|
|
52
|
+
workstreamId: string;
|
|
53
|
+
status: string | null;
|
|
54
|
+
event: string;
|
|
55
|
+
}) => Promise<{
|
|
56
|
+
requestId?: string | null;
|
|
57
|
+
dueAt?: string | null;
|
|
58
|
+
} | null>;
|
|
59
|
+
sendJson: (res: TRes, status: number, payload: unknown) => void;
|
|
60
|
+
safeErrorMessage: (err: unknown) => string;
|
|
61
|
+
};
|
|
62
|
+
export declare function registerEntitiesRoutes<TReq, TRes>(router: Router<Record<string, never>, TReq, TRes>, deps: RegisterEntitiesRoutesDeps<TReq, TRes>): void;
|
|
63
|
+
export {};
|