@useorgx/openclaw-plugin 0.4.9 → 0.7.2
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 +77 -11
- package/dashboard/dist/assets/6mILZQ2a.js +1 -0
- package/dashboard/dist/assets/6mILZQ2a.js.br +0 -0
- package/dashboard/dist/assets/6mILZQ2a.js.gz +0 -0
- package/dashboard/dist/assets/8dksYiq4.js +2 -0
- package/dashboard/dist/assets/8dksYiq4.js.br +0 -0
- package/dashboard/dist/assets/8dksYiq4.js.gz +0 -0
- package/dashboard/dist/assets/B5zYRHc3.js +1 -0
- package/dashboard/dist/assets/B5zYRHc3.js.br +0 -0
- package/dashboard/dist/assets/B5zYRHc3.js.gz +0 -0
- package/dashboard/dist/assets/B6wPWJ35.js +1 -0
- package/dashboard/dist/assets/B6wPWJ35.js.br +0 -0
- package/dashboard/dist/assets/B6wPWJ35.js.gz +0 -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/BWEwjt1W.js +1 -0
- package/dashboard/dist/assets/BWEwjt1W.js.br +0 -0
- package/dashboard/dist/assets/BWEwjt1W.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/BzRbDCAD.css +1 -0
- package/dashboard/dist/assets/BzRbDCAD.css.br +0 -0
- package/dashboard/dist/assets/BzRbDCAD.css.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/C8uM3AX8.js +1 -0
- package/dashboard/dist/assets/C8uM3AX8.js.br +0 -0
- package/dashboard/dist/assets/C8uM3AX8.js.gz +0 -0
- package/dashboard/dist/assets/C9jy61eu.js +212 -0
- package/dashboard/dist/assets/C9jy61eu.js.br +0 -0
- package/dashboard/dist/assets/C9jy61eu.js.gz +0 -0
- package/dashboard/dist/assets/CC63EwFD.js +1 -0
- package/dashboard/dist/assets/CC63EwFD.js.br +0 -0
- package/dashboard/dist/assets/CC63EwFD.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/CZaT3ob_.js +1 -0
- package/dashboard/dist/assets/CZaT3ob_.js.br +0 -0
- package/dashboard/dist/assets/CZaT3ob_.js.gz +0 -0
- package/dashboard/dist/assets/CgaottFX.js +1 -0
- package/dashboard/dist/assets/CgaottFX.js.br +0 -0
- package/dashboard/dist/assets/CgaottFX.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/CzCxAZlW.js +1 -0
- package/dashboard/dist/assets/CzCxAZlW.js.br +0 -0
- package/dashboard/dist/assets/CzCxAZlW.js.gz +0 -0
- package/dashboard/dist/assets/D3iMTYEj.js +1 -0
- package/dashboard/dist/assets/D3iMTYEj.js.br +0 -0
- package/dashboard/dist/assets/D3iMTYEj.js.gz +0 -0
- package/dashboard/dist/assets/D8JNX8kq.js +2 -0
- package/dashboard/dist/assets/D8JNX8kq.js.br +0 -0
- package/dashboard/dist/assets/D8JNX8kq.js.gz +0 -0
- package/dashboard/dist/assets/DnA8dpj6.js +1 -0
- package/dashboard/dist/assets/DnA8dpj6.js.br +0 -0
- package/dashboard/dist/assets/DnA8dpj6.js.gz +0 -0
- package/dashboard/dist/assets/IUexzymk.js +1 -0
- package/dashboard/dist/assets/IUexzymk.js.br +0 -0
- package/dashboard/dist/assets/IUexzymk.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/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/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/rttbDbEx.js +1 -0
- package/dashboard/dist/assets/rttbDbEx.js.br +0 -0
- package/dashboard/dist/assets/rttbDbEx.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 +34 -8
- package/dist/agent-context-store.js +79 -17
- package/dist/agent-run-store.js +44 -3
- package/dist/agent-suite.d.ts +9 -0
- package/dist/agent-suite.js +149 -9
- 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/chat-store.d.ts +157 -0
- package/dist/chat-store.js +586 -0
- package/dist/cli/orgx.js +11 -0
- package/dist/contracts/client.d.ts +43 -3
- package/dist/contracts/client.js +159 -30
- package/dist/contracts/practice-exercise-schema.d.ts +216 -0
- package/dist/contracts/practice-exercise-schema.js +314 -0
- package/dist/contracts/retro-schema.d.ts +81 -0
- package/dist/contracts/retro-schema.js +80 -0
- package/dist/contracts/shared-types.d.ts +159 -0
- package/dist/contracts/shared-types.js +199 -1
- 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 +247 -2
- package/dist/entities/auto-assignment.js +43 -17
- package/dist/event-sanitization.d.ts +11 -0
- package/dist/event-sanitization.js +113 -0
- package/dist/gateway-watchdog.d.ts +5 -0
- package/dist/gateway-watchdog.js +50 -0
- package/dist/hooks/post-reporting-event.mjs +1 -5
- package/dist/http/helpers/activity-headline.js +13 -132
- package/dist/http/helpers/auto-continue-engine.d.ts +198 -10
- package/dist/http/helpers/auto-continue-engine.js +3145 -186
- package/dist/http/helpers/autopilot-operations.d.ts +19 -0
- package/dist/http/helpers/autopilot-operations.js +182 -31
- package/dist/http/helpers/autopilot-runtime.d.ts +1 -0
- package/dist/http/helpers/autopilot-runtime.js +328 -25
- package/dist/http/helpers/autopilot-slice-utils.d.ts +18 -0
- package/dist/http/helpers/autopilot-slice-utils.js +514 -93
- package/dist/http/helpers/decision-mapper.d.ts +40 -0
- package/dist/http/helpers/decision-mapper.js +223 -7
- package/dist/http/helpers/dispatch-lifecycle.d.ts +19 -2
- package/dist/http/helpers/dispatch-lifecycle.js +242 -37
- package/dist/http/helpers/kickoff-context.js +104 -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 +102 -3
- package/dist/http/helpers/mission-control.js +498 -9
- 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 +877 -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.js +7 -2
- package/dist/http/helpers/workspace-scope.d.ts +15 -0
- package/dist/http/helpers/workspace-scope.js +170 -0
- package/dist/http/index.js +1420 -105
- package/dist/http/routes/agent-suite.d.ts +9 -0
- package/dist/http/routes/agent-suite.js +294 -8
- package/dist/http/routes/agents-catalog.js +64 -19
- package/dist/http/routes/chat.d.ts +19 -0
- package/dist/http/routes/chat.js +522 -0
- package/dist/http/routes/decision-actions.d.ts +8 -1
- package/dist/http/routes/decision-actions.js +42 -5
- 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 +16 -0
- package/dist/http/routes/entities.js +232 -6
- package/dist/http/routes/live-legacy.d.ts +5 -0
- package/dist/http/routes/live-legacy.js +23 -509
- package/dist/http/routes/live-misc.d.ts +12 -0
- package/dist/http/routes/live-misc.js +251 -31
- package/dist/http/routes/live-snapshot.d.ts +49 -2
- package/dist/http/routes/live-snapshot.js +653 -23
- package/dist/http/routes/live-terminal.d.ts +11 -0
- package/dist/http/routes/live-terminal.js +154 -0
- package/dist/http/routes/live-triage.d.ts +61 -0
- package/dist/http/routes/live-triage.js +192 -0
- package/dist/http/routes/mission-control-actions.d.ts +49 -1
- package/dist/http/routes/mission-control-actions.js +1246 -84
- package/dist/http/routes/mission-control-read.d.ts +48 -3
- package/dist/http/routes/mission-control-read.js +1658 -20
- 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 +5 -2
- package/dist/http/routes/run-control.js +10 -0
- package/dist/http/routes/sentinels-catalog.d.ts +7 -0
- package/dist/http/routes/sentinels-catalog.js +24 -0
- package/dist/http/routes/summary.js +10 -3
- package/dist/http/routes/usage.d.ts +24 -0
- package/dist/http/routes/usage.js +362 -0
- package/dist/http/routes/work-artifacts.js +28 -9
- package/dist/index.js +165 -27
- package/dist/local-openclaw.js +29 -6
- package/dist/mcp-client-setup.js +3 -3
- package/dist/mcp-http-handler.d.ts +3 -0
- package/dist/mcp-http-handler.js +34 -60
- package/dist/next-up-queue-store.d.ts +16 -1
- package/dist/next-up-queue-store.js +89 -7
- package/dist/outbox.d.ts +5 -0
- package/dist/outbox.js +113 -9
- package/dist/paths.js +36 -5
- package/dist/reporting/rollups.d.ts +41 -0
- package/dist/reporting/rollups.js +113 -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/services/background.d.ts +11 -0
- package/dist/services/background.js +22 -0
- package/dist/services/experiment-randomization.d.ts +21 -0
- package/dist/services/experiment-randomization.js +63 -0
- package/dist/skill-pack-state.d.ts +36 -5
- package/dist/skill-pack-state.js +273 -29
- package/dist/sync/local-agent-telemetry.d.ts +13 -0
- package/dist/sync/local-agent-telemetry.js +128 -0
- package/dist/sync/outbox-replay.js +131 -24
- 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 +10 -14
- package/dist/tools/core-tools.js +1289 -24
- package/dist/types.d.ts +2 -0
- package/dist/types.js +2 -0
- package/dist/worker-supervisor.js +23 -0
- package/package.json +20 -6
- package/dashboard/dist/assets/B3ziCA02.js +0 -8
- package/dashboard/dist/assets/B5NEElEI.css +0 -1
- package/dashboard/dist/assets/BhapSNAs.js +0 -215
- package/dashboard/dist/assets/iFdvE7lx.js +0 -1
- package/dashboard/dist/assets/jRJsmpYM.js +0 -1
- package/dashboard/dist/assets/sAhvFnpk.js +0 -4
|
@@ -1,8 +1,25 @@
|
|
|
1
1
|
import { randomUUID } from "node:crypto";
|
|
2
|
+
import { stableHash } from "../hash-utils.js";
|
|
3
|
+
import { validateArtifactMetadata, normalizeArtifactType, } from "./artifact-domain-schemas.js";
|
|
4
|
+
const ALLOWED_ENTITY_TYPES = new Set([
|
|
5
|
+
"initiative",
|
|
6
|
+
"workstream",
|
|
7
|
+
"milestone",
|
|
8
|
+
"task",
|
|
9
|
+
"decision",
|
|
10
|
+
"project",
|
|
11
|
+
]);
|
|
2
12
|
const MAX_PREVIEW_MARKDOWN = 25_000;
|
|
3
13
|
function normalizeText(value) {
|
|
4
14
|
return typeof value === "string" ? value.trim() : "";
|
|
5
15
|
}
|
|
16
|
+
function normalizeConfidenceScore(value) {
|
|
17
|
+
if (typeof value !== "number" || !Number.isFinite(value))
|
|
18
|
+
return null;
|
|
19
|
+
if (value < 0 || value > 1)
|
|
20
|
+
return null;
|
|
21
|
+
return value;
|
|
22
|
+
}
|
|
6
23
|
function isUuid(value) {
|
|
7
24
|
return /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(value);
|
|
8
25
|
}
|
|
@@ -28,6 +45,9 @@ export function validateRegisterArtifactInput(input) {
|
|
|
28
45
|
const entityType = normalizeText(input.entity_type);
|
|
29
46
|
if (!entityType)
|
|
30
47
|
errors.push("entity_type is required");
|
|
48
|
+
else if (!ALLOWED_ENTITY_TYPES.has(entityType)) {
|
|
49
|
+
errors.push("entity_type must be one of: initiative, workstream, milestone, task, decision, project");
|
|
50
|
+
}
|
|
31
51
|
const entityId = normalizeText(input.entity_id);
|
|
32
52
|
if (!entityId)
|
|
33
53
|
errors.push("entity_id is required");
|
|
@@ -39,6 +59,10 @@ export function validateRegisterArtifactInput(input) {
|
|
|
39
59
|
const artifactType = normalizeText(input.artifact_type);
|
|
40
60
|
if (!artifactType)
|
|
41
61
|
errors.push("artifact_type is required");
|
|
62
|
+
if (typeof input.confidence_score !== "undefined" &&
|
|
63
|
+
normalizeConfidenceScore(input.confidence_score) == null) {
|
|
64
|
+
errors.push("confidence_score must be a number between 0 and 1 when provided");
|
|
65
|
+
}
|
|
42
66
|
const createdByType = normalizeText(input.created_by_type);
|
|
43
67
|
if (createdByType && createdByType !== "human" && createdByType !== "agent") {
|
|
44
68
|
errors.push("created_by_type must be 'human' or 'agent' when provided");
|
|
@@ -60,6 +84,44 @@ function isArtifactTypeConstraintError(err) {
|
|
|
60
84
|
return (msg.includes("artifact_type") &&
|
|
61
85
|
(msg.includes("constraint") || msg.includes("foreign") || msg.includes("violat")));
|
|
62
86
|
}
|
|
87
|
+
function isRecord(value) {
|
|
88
|
+
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
89
|
+
}
|
|
90
|
+
function extractArtifactFromCreateResponse(payload) {
|
|
91
|
+
if (!isRecord(payload))
|
|
92
|
+
return null;
|
|
93
|
+
if (isRecord(payload.artifact))
|
|
94
|
+
return payload.artifact;
|
|
95
|
+
if (isRecord(payload.data) && isRecord(payload.data.artifact)) {
|
|
96
|
+
return payload.data.artifact;
|
|
97
|
+
}
|
|
98
|
+
if (isRecord(payload.data))
|
|
99
|
+
return payload.data;
|
|
100
|
+
return null;
|
|
101
|
+
}
|
|
102
|
+
function extractArtifactFromDetailResponse(payload) {
|
|
103
|
+
if (!isRecord(payload))
|
|
104
|
+
return null;
|
|
105
|
+
if (isRecord(payload.artifact))
|
|
106
|
+
return payload.artifact;
|
|
107
|
+
if (isRecord(payload.data) && isRecord(payload.data.artifact)) {
|
|
108
|
+
return payload.data.artifact;
|
|
109
|
+
}
|
|
110
|
+
if (isRecord(payload.data))
|
|
111
|
+
return payload.data;
|
|
112
|
+
return null;
|
|
113
|
+
}
|
|
114
|
+
function extractArtifactsFromListResponse(payload) {
|
|
115
|
+
if (!isRecord(payload))
|
|
116
|
+
return [];
|
|
117
|
+
const direct = payload.artifacts;
|
|
118
|
+
if (Array.isArray(direct))
|
|
119
|
+
return direct.filter(isRecord);
|
|
120
|
+
if (isRecord(payload.data) && Array.isArray(payload.data.artifacts)) {
|
|
121
|
+
return payload.data.artifacts.filter(isRecord);
|
|
122
|
+
}
|
|
123
|
+
return [];
|
|
124
|
+
}
|
|
63
125
|
function normalizeBaseUrl(baseUrl) {
|
|
64
126
|
return baseUrl.replace(/\/+$/, "");
|
|
65
127
|
}
|
|
@@ -67,18 +129,20 @@ async function sleep(ms) {
|
|
|
67
129
|
await new Promise((r) => setTimeout(r, ms));
|
|
68
130
|
}
|
|
69
131
|
async function validateArtifactPersistence(client, input) {
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
const
|
|
73
|
-
const
|
|
74
|
-
const
|
|
75
|
-
const
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
132
|
+
const detail = await client.rawRequest("GET", `/api/client/artifacts/${encodeURIComponent(input.artifactId)}`);
|
|
133
|
+
const detailArtifact = extractArtifactFromDetailResponse(detail);
|
|
134
|
+
const detailOk = Boolean(detailArtifact && typeof detailArtifact.id === "string" && detailArtifact.id === input.artifactId);
|
|
135
|
+
const list = await client.rawRequest("GET", `/api/client/artifacts/by-entity?entity_type=${encodeURIComponent(input.entity_type)}&entity_id=${encodeURIComponent(input.entity_id)}&limit=25`);
|
|
136
|
+
const artifacts = extractArtifactsFromListResponse(list);
|
|
137
|
+
const linkedArtifact = artifacts.find((artifact) => {
|
|
138
|
+
return (typeof artifact.id === "string" &&
|
|
139
|
+
artifact.id === input.artifactId &&
|
|
140
|
+
typeof artifact.entity_type === "string" &&
|
|
141
|
+
artifact.entity_type === input.entity_type &&
|
|
142
|
+
typeof artifact.entity_id === "string" &&
|
|
143
|
+
artifact.entity_id === input.entity_id);
|
|
144
|
+
});
|
|
145
|
+
return { artifact_detail_ok: detailOk, linked_ok: Boolean(linkedArtifact) };
|
|
82
146
|
}
|
|
83
147
|
export async function registerArtifact(client, baseUrl, input) {
|
|
84
148
|
const warnings = [];
|
|
@@ -111,6 +175,9 @@ export async function registerArtifact(client, baseUrl, input) {
|
|
|
111
175
|
? input.metadata
|
|
112
176
|
: {}),
|
|
113
177
|
};
|
|
178
|
+
const confidenceScore = normalizeConfidenceScore(input.confidence_score);
|
|
179
|
+
if (confidenceScore != null)
|
|
180
|
+
metadata.confidence_score = confidenceScore;
|
|
114
181
|
if (input.external_url)
|
|
115
182
|
metadata.external_url = String(input.external_url);
|
|
116
183
|
if (input.preview_markdown) {
|
|
@@ -122,20 +189,102 @@ export async function registerArtifact(client, baseUrl, input) {
|
|
|
122
189
|
if (preview.length > MAX_PREVIEW_MARKDOWN)
|
|
123
190
|
metadata.preview_truncated = true;
|
|
124
191
|
}
|
|
192
|
+
// --- Proof Ladder: atomic unit normalization + schema validation ---
|
|
193
|
+
const explicitAtomicType = typeof metadata.atomic_unit_type === "string"
|
|
194
|
+
? metadata.atomic_unit_type.trim()
|
|
195
|
+
: null;
|
|
196
|
+
const inferredAtomicType = normalizeArtifactType(input.artifact_type);
|
|
197
|
+
const atomicUnitType = explicitAtomicType || inferredAtomicType;
|
|
198
|
+
if (atomicUnitType) {
|
|
199
|
+
metadata.atomic_unit_type = atomicUnitType;
|
|
200
|
+
const validation = validateArtifactMetadata(atomicUnitType, metadata);
|
|
201
|
+
metadata.schema_validated = validation.valid;
|
|
202
|
+
if (!validation.valid) {
|
|
203
|
+
warnings.push(...validation.warnings);
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
// --- Proof Ladder: artifact content hash ---
|
|
207
|
+
const hashSource = input.preview_markdown || input.external_url || input.name;
|
|
208
|
+
if (hashSource && !metadata.artifact_hash) {
|
|
209
|
+
metadata.artifact_hash = stableHash(String(hashSource));
|
|
210
|
+
}
|
|
211
|
+
// --- Proof Ladder: queue_ref from environment / caller ---
|
|
212
|
+
if (!metadata.queue_ref) {
|
|
213
|
+
const queueRef = {};
|
|
214
|
+
const envInitId = normalizeText(process.env.ORGX_INITIATIVE_ID);
|
|
215
|
+
const envWsId = normalizeText(process.env.ORGX_WORKSTREAM_ID);
|
|
216
|
+
const envTaskId = normalizeText(process.env.ORGX_TASK_ID);
|
|
217
|
+
if (envInitId)
|
|
218
|
+
queueRef.initiative_id = envInitId;
|
|
219
|
+
if (envWsId)
|
|
220
|
+
queueRef.workstream_id = envWsId;
|
|
221
|
+
if (envTaskId)
|
|
222
|
+
queueRef.task_id = envTaskId;
|
|
223
|
+
if (Object.keys(queueRef).length > 0) {
|
|
224
|
+
metadata.queue_ref = queueRef;
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
// --- Proof Ladder: run_ref from environment / caller ---
|
|
228
|
+
if (!metadata.run_ref) {
|
|
229
|
+
const runRef = {};
|
|
230
|
+
const envRunId = normalizeText(process.env.ORGX_RUN_ID);
|
|
231
|
+
const envCorrId = normalizeText(process.env.ORGX_CORRELATION_ID);
|
|
232
|
+
const envSessionId = normalizeText(process.env.ORGX_SESSION_ID);
|
|
233
|
+
if (envRunId)
|
|
234
|
+
runRef.run_id = envRunId;
|
|
235
|
+
if (envCorrId)
|
|
236
|
+
runRef.correlation_id = envCorrId;
|
|
237
|
+
if (envSessionId)
|
|
238
|
+
runRef.session_id = envSessionId;
|
|
239
|
+
if (Object.keys(runRef).length > 0) {
|
|
240
|
+
metadata.run_ref = runRef;
|
|
241
|
+
}
|
|
242
|
+
}
|
|
125
243
|
const metadataInitiativeId = typeof metadata.initiative_id === "string" && metadata.initiative_id.trim().length > 0
|
|
126
244
|
? metadata.initiative_id.trim()
|
|
127
245
|
: null;
|
|
128
246
|
const initiativeIdHint = input.entity_type === "initiative" ? input.entity_id : metadataInitiativeId;
|
|
129
247
|
let entity = null;
|
|
130
248
|
let created = false;
|
|
131
|
-
|
|
249
|
+
let usedLegacyCreate = false;
|
|
250
|
+
// Primary path: canonical client artifact contract.
|
|
132
251
|
try {
|
|
252
|
+
const response = await client.rawRequest("POST", "/api/client/artifacts", {
|
|
253
|
+
artifact_id: desiredId,
|
|
254
|
+
entity_type: input.entity_type,
|
|
255
|
+
entity_id: input.entity_id,
|
|
256
|
+
name: input.name,
|
|
257
|
+
artifact_type: input.artifact_type,
|
|
258
|
+
description: input.description ?? undefined,
|
|
259
|
+
artifact_url: artifactUrl,
|
|
260
|
+
external_url: input.external_url ?? undefined,
|
|
261
|
+
preview_markdown: input.preview_markdown ?? undefined,
|
|
262
|
+
status,
|
|
263
|
+
metadata,
|
|
264
|
+
...(initiativeIdHint ? { initiative_id: initiativeIdHint } : {}),
|
|
265
|
+
...createdBy,
|
|
266
|
+
});
|
|
267
|
+
entity = extractArtifactFromCreateResponse(response);
|
|
268
|
+
if (!entity) {
|
|
269
|
+
warnings.push("client artifact create returned an unexpected payload shape");
|
|
270
|
+
}
|
|
271
|
+
else {
|
|
272
|
+
created = true;
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
catch (err) {
|
|
276
|
+
warnings.push(`client artifact create failed; falling back to legacy entities route: ${safeErrorMessage(err)}`);
|
|
277
|
+
}
|
|
278
|
+
// Compatibility path for older OrgX servers.
|
|
279
|
+
if (!entity) {
|
|
280
|
+
usedLegacyCreate = true;
|
|
133
281
|
try {
|
|
134
282
|
entity = await client.createEntity("artifact", {
|
|
135
283
|
id: desiredId,
|
|
136
284
|
name: input.name,
|
|
137
285
|
description: input.description ?? undefined,
|
|
138
286
|
artifact_type: input.artifact_type,
|
|
287
|
+
confidence_score: confidenceScore ?? undefined,
|
|
139
288
|
entity_type: input.entity_type,
|
|
140
289
|
entity_id: input.entity_id,
|
|
141
290
|
...(initiativeIdHint ? { initiative_id: initiativeIdHint } : {}),
|
|
@@ -150,13 +299,14 @@ export async function registerArtifact(client, baseUrl, input) {
|
|
|
150
299
|
if (!isArtifactTypeConstraintError(err)) {
|
|
151
300
|
throw err;
|
|
152
301
|
}
|
|
153
|
-
warnings.push(`artifact_type rejected; retrying with shared.project_handbook`);
|
|
302
|
+
warnings.push(`artifact_type rejected on legacy route; retrying with shared.project_handbook`);
|
|
154
303
|
metadata.requested_artifact_type = input.artifact_type;
|
|
155
304
|
entity = await client.createEntity("artifact", {
|
|
156
305
|
id: desiredId,
|
|
157
306
|
name: input.name,
|
|
158
307
|
description: input.description ?? undefined,
|
|
159
308
|
artifact_type: "shared.project_handbook",
|
|
309
|
+
confidence_score: confidenceScore ?? undefined,
|
|
160
310
|
entity_type: input.entity_type,
|
|
161
311
|
entity_id: input.entity_id,
|
|
162
312
|
...(initiativeIdHint ? { initiative_id: initiativeIdHint } : {}),
|
|
@@ -168,52 +318,15 @@ export async function registerArtifact(client, baseUrl, input) {
|
|
|
168
318
|
created = true;
|
|
169
319
|
}
|
|
170
320
|
}
|
|
171
|
-
catch (err) {
|
|
172
|
-
warnings.push(`artifact create with explicit id failed: ${safeErrorMessage(err)}`);
|
|
173
|
-
// Fallback: create without id, then patch artifact_url once we know the server id.
|
|
174
|
-
try {
|
|
175
|
-
entity = await client.createEntity("artifact", {
|
|
176
|
-
name: input.name,
|
|
177
|
-
description: input.description ?? undefined,
|
|
178
|
-
artifact_type: input.artifact_type,
|
|
179
|
-
entity_type: input.entity_type,
|
|
180
|
-
entity_id: input.entity_id,
|
|
181
|
-
...(initiativeIdHint ? { initiative_id: initiativeIdHint } : {}),
|
|
182
|
-
artifact_url: input.external_url ?? `${normalizeBaseUrl(baseUrl)}/artifacts/pending`,
|
|
183
|
-
status,
|
|
184
|
-
metadata,
|
|
185
|
-
...createdBy,
|
|
186
|
-
});
|
|
187
|
-
created = true;
|
|
188
|
-
}
|
|
189
|
-
catch (inner) {
|
|
190
|
-
if (!isArtifactTypeConstraintError(inner)) {
|
|
191
|
-
throw inner;
|
|
192
|
-
}
|
|
193
|
-
warnings.push(`artifact_type rejected; retrying with shared.project_handbook`);
|
|
194
|
-
metadata.requested_artifact_type = input.artifact_type;
|
|
195
|
-
entity = await client.createEntity("artifact", {
|
|
196
|
-
name: input.name,
|
|
197
|
-
description: input.description ?? undefined,
|
|
198
|
-
artifact_type: "shared.project_handbook",
|
|
199
|
-
entity_type: input.entity_type,
|
|
200
|
-
entity_id: input.entity_id,
|
|
201
|
-
...(initiativeIdHint ? { initiative_id: initiativeIdHint } : {}),
|
|
202
|
-
artifact_url: input.external_url ?? `${normalizeBaseUrl(baseUrl)}/artifacts/pending`,
|
|
203
|
-
status,
|
|
204
|
-
metadata,
|
|
205
|
-
...createdBy,
|
|
206
|
-
});
|
|
207
|
-
created = true;
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
321
|
const artifactId = entity && typeof entity === "object" && typeof entity.id === "string"
|
|
211
322
|
? String(entity.id)
|
|
212
323
|
: null;
|
|
213
|
-
let finalArtifactUrl =
|
|
214
|
-
?
|
|
215
|
-
:
|
|
216
|
-
|
|
324
|
+
let finalArtifactUrl = entity && typeof entity === "object" && typeof entity.artifact_url === "string"
|
|
325
|
+
? String(entity.artifact_url)
|
|
326
|
+
: artifactId
|
|
327
|
+
? `${normalizeBaseUrl(baseUrl)}/artifacts/${artifactId}`
|
|
328
|
+
: null;
|
|
329
|
+
if (artifactId && usedLegacyCreate) {
|
|
217
330
|
try {
|
|
218
331
|
await client.updateEntity("artifact", artifactId, {
|
|
219
332
|
artifact_url: finalArtifactUrl,
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
export type ChatAttachmentState = "preparing" | "indexing" | "ready" | "failed";
|
|
2
|
+
export type ChatMessageRole = "user" | "agent" | "system";
|
|
3
|
+
export type ChatLaunchStatus = "requested" | "queued" | "running" | "blocked" | "completed" | "failed";
|
|
4
|
+
export type ChatThreadStatus = "message_only" | "queued" | "running" | "blocked" | "completed" | "failed";
|
|
5
|
+
export type ChatAttachmentRecord = {
|
|
6
|
+
id: string;
|
|
7
|
+
name: string;
|
|
8
|
+
mimeType: string | null;
|
|
9
|
+
sizeBytes: number | null;
|
|
10
|
+
status: ChatAttachmentState;
|
|
11
|
+
error: string | null;
|
|
12
|
+
masked: boolean;
|
|
13
|
+
createdAt: string;
|
|
14
|
+
updatedAt: string;
|
|
15
|
+
};
|
|
16
|
+
export type ChatMessageRecord = {
|
|
17
|
+
id: string;
|
|
18
|
+
threadId: string;
|
|
19
|
+
role: ChatMessageRole;
|
|
20
|
+
body: string;
|
|
21
|
+
senderId: string | null;
|
|
22
|
+
senderName: string | null;
|
|
23
|
+
createdAt: string;
|
|
24
|
+
updatedAt: string;
|
|
25
|
+
attachments: ChatAttachmentRecord[];
|
|
26
|
+
metadata: Record<string, unknown>;
|
|
27
|
+
};
|
|
28
|
+
export type ChatLaunchAttemptRecord = {
|
|
29
|
+
id: string;
|
|
30
|
+
threadId: string;
|
|
31
|
+
messageId: string;
|
|
32
|
+
assigneeId: string | null;
|
|
33
|
+
assigneeName: string | null;
|
|
34
|
+
watcherIds: string[];
|
|
35
|
+
watcherNames: string[];
|
|
36
|
+
executionMode: "local_queue" | "cloud" | "hybrid";
|
|
37
|
+
provider: string | null;
|
|
38
|
+
runId: string | null;
|
|
39
|
+
status: ChatLaunchStatus;
|
|
40
|
+
blockedReason: string | null;
|
|
41
|
+
warnings: string[];
|
|
42
|
+
requestedAt: string;
|
|
43
|
+
updatedAt: string;
|
|
44
|
+
metadata: Record<string, unknown>;
|
|
45
|
+
};
|
|
46
|
+
export type ChatThreadRecord = {
|
|
47
|
+
id: string;
|
|
48
|
+
commandCenterId: string | null;
|
|
49
|
+
initiativeId: string | null;
|
|
50
|
+
initiativeTitle: string | null;
|
|
51
|
+
workstreamId: string | null;
|
|
52
|
+
taskId: string | null;
|
|
53
|
+
title: string;
|
|
54
|
+
summary: string | null;
|
|
55
|
+
status: ChatThreadStatus;
|
|
56
|
+
assigneeId: string | null;
|
|
57
|
+
assigneeName: string | null;
|
|
58
|
+
watcherIds: string[];
|
|
59
|
+
watcherNames: string[];
|
|
60
|
+
messageCount: number;
|
|
61
|
+
launchCount: number;
|
|
62
|
+
lastMessageAt: string | null;
|
|
63
|
+
lastLaunchAt: string | null;
|
|
64
|
+
lastActivityAt: string;
|
|
65
|
+
lastSnippet: string | null;
|
|
66
|
+
createdAt: string;
|
|
67
|
+
updatedAt: string;
|
|
68
|
+
messages: ChatMessageRecord[];
|
|
69
|
+
launches: ChatLaunchAttemptRecord[];
|
|
70
|
+
metadata: Record<string, unknown>;
|
|
71
|
+
};
|
|
72
|
+
export type ChatThreadSummary = Omit<ChatThreadRecord, "messages" | "launches"> & {
|
|
73
|
+
latestMessage: ChatMessageRecord | null;
|
|
74
|
+
latestLaunch: ChatLaunchAttemptRecord | null;
|
|
75
|
+
};
|
|
76
|
+
export declare function listChatThreads(input?: {
|
|
77
|
+
commandCenterId?: string | null;
|
|
78
|
+
initiativeId?: string | null;
|
|
79
|
+
query?: string | null;
|
|
80
|
+
status?: string | null;
|
|
81
|
+
limit?: number;
|
|
82
|
+
offset?: number;
|
|
83
|
+
}): {
|
|
84
|
+
threads: ChatThreadSummary[];
|
|
85
|
+
total: number;
|
|
86
|
+
updatedAt: string;
|
|
87
|
+
};
|
|
88
|
+
export declare function getChatThread(threadId: string): ChatThreadRecord | null;
|
|
89
|
+
export declare function sendChatMessage(input: {
|
|
90
|
+
threadId?: string | null;
|
|
91
|
+
commandCenterId?: string | null;
|
|
92
|
+
initiativeId?: string | null;
|
|
93
|
+
initiativeTitle?: string | null;
|
|
94
|
+
workstreamId?: string | null;
|
|
95
|
+
taskId?: string | null;
|
|
96
|
+
title?: string | null;
|
|
97
|
+
body: string;
|
|
98
|
+
role?: ChatMessageRole;
|
|
99
|
+
senderId?: string | null;
|
|
100
|
+
senderName?: string | null;
|
|
101
|
+
assigneeId?: string | null;
|
|
102
|
+
assigneeName?: string | null;
|
|
103
|
+
watcherIds?: string[];
|
|
104
|
+
watcherNames?: string[];
|
|
105
|
+
attachments?: Array<Partial<ChatAttachmentRecord> & {
|
|
106
|
+
name?: string | null;
|
|
107
|
+
}>;
|
|
108
|
+
metadata?: Record<string, unknown>;
|
|
109
|
+
}): {
|
|
110
|
+
thread: ChatThreadRecord;
|
|
111
|
+
message: ChatMessageRecord;
|
|
112
|
+
createdThread: boolean;
|
|
113
|
+
updatedAt: string;
|
|
114
|
+
};
|
|
115
|
+
export declare function recordChatLaunch(input: {
|
|
116
|
+
threadId: string;
|
|
117
|
+
messageId: string;
|
|
118
|
+
assigneeId?: string | null;
|
|
119
|
+
assigneeName?: string | null;
|
|
120
|
+
watcherIds?: string[];
|
|
121
|
+
watcherNames?: string[];
|
|
122
|
+
executionMode?: "local_queue" | "cloud" | "hybrid";
|
|
123
|
+
provider?: string | null;
|
|
124
|
+
runId?: string | null;
|
|
125
|
+
status?: ChatLaunchStatus;
|
|
126
|
+
blockedReason?: string | null;
|
|
127
|
+
warnings?: string[];
|
|
128
|
+
metadata?: Record<string, unknown>;
|
|
129
|
+
}): {
|
|
130
|
+
thread: ChatThreadRecord;
|
|
131
|
+
launch: ChatLaunchAttemptRecord;
|
|
132
|
+
updatedAt: string;
|
|
133
|
+
};
|
|
134
|
+
export declare function updateChatLaunchStatus(input: {
|
|
135
|
+
threadId: string;
|
|
136
|
+
launchId: string;
|
|
137
|
+
status: ChatLaunchStatus;
|
|
138
|
+
runId?: string | null;
|
|
139
|
+
blockedReason?: string | null;
|
|
140
|
+
warnings?: string[];
|
|
141
|
+
}): {
|
|
142
|
+
thread: ChatThreadRecord;
|
|
143
|
+
launch: ChatLaunchAttemptRecord;
|
|
144
|
+
updatedAt: string;
|
|
145
|
+
};
|
|
146
|
+
export declare function linkChatThreadScope(input: {
|
|
147
|
+
threadId: string;
|
|
148
|
+
commandCenterId?: string | null;
|
|
149
|
+
initiativeId?: string | null;
|
|
150
|
+
initiativeTitle?: string | null;
|
|
151
|
+
workstreamId?: string | null;
|
|
152
|
+
taskId?: string | null;
|
|
153
|
+
}): {
|
|
154
|
+
thread: ChatThreadRecord;
|
|
155
|
+
eventMessage: ChatMessageRecord;
|
|
156
|
+
updatedAt: string;
|
|
157
|
+
};
|