openmeld 0.3.231 → 0.3.233
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/dist/{add-me-membership-0KyMk1wi.js → add-me-membership-_O3IzRLn.js} +2 -2
- package/dist/{add-me-membership-0KyMk1wi.js.map → add-me-membership-_O3IzRLn.js.map} +1 -1
- package/dist/{agents-Bkx6ldpV.js → agents-B5E7c7sQ.js} +11 -11
- package/dist/{agents-Bkx6ldpV.js.map → agents-B5E7c7sQ.js.map} +1 -1
- package/dist/{api-client-foundation-d4E5XWdJ.js → api-client-foundation-1p1VVFJ_.js} +1 -1
- package/dist/{api-client-foundation-DgTXf3Gb.js → api-client-foundation-C-RPnq_p.js} +3 -3
- package/dist/{api-client-foundation-DgTXf3Gb.js.map → api-client-foundation-C-RPnq_p.js.map} +1 -1
- package/dist/auth-session-CmjjkLiB.js +4 -0
- package/dist/{auth-session-pLaN5cnC.js → auth-session-iXCJO5oB.js} +6 -6
- package/dist/{auth-session-pLaN5cnC.js.map → auth-session-iXCJO5oB.js.map} +1 -1
- package/dist/auth-url-6Bb6YdNm.js +24 -0
- package/dist/auth-url-6Bb6YdNm.js.map +1 -0
- package/dist/{base-url-eck31vC8.js → base-url-0AoeTi3w.js} +3 -3
- package/dist/{base-url-eck31vC8.js.map → base-url-0AoeTi3w.js.map} +1 -1
- package/dist/{base-url-B8eWb2md.js → base-url-Bdjp-5vy.js} +1 -1
- package/dist/{channel-DppbHxHw.js → channel-BciBrA3Y.js} +25 -5
- package/dist/channel-BciBrA3Y.js.map +1 -0
- package/dist/{cli-binary-manifest-Bjf6T7Ef.js → cli-binary-manifest-ETxqCzfS.js} +8 -1
- package/dist/cli-binary-manifest-ETxqCzfS.js.map +1 -0
- package/dist/{command-CBWv24uj.js → command-D0pcAIoE.js} +19 -19
- package/dist/{command-CBWv24uj.js.map → command-D0pcAIoE.js.map} +1 -1
- package/dist/{computer-connection-DMkamVpB.js → computer-connection-CHP1-0rK.js} +2 -2
- package/dist/{computer-connection-DMkamVpB.js.map → computer-connection-CHP1-0rK.js.map} +1 -1
- package/dist/{computer-connection-review-BSPMGVhN.js → computer-connection-review-dHotFqmD.js} +6 -6
- package/dist/{computer-connection-review-BSPMGVhN.js.map → computer-connection-review-dHotFqmD.js.map} +1 -1
- package/dist/{computer-disconnect-BQ_MDeeA.js → computer-disconnect-B2DLDxWx.js} +9 -9
- package/dist/{computer-disconnect-BQ_MDeeA.js.map → computer-disconnect-B2DLDxWx.js.map} +1 -1
- package/dist/{computer-setup-continuation-Cd293Yzi.js → computer-setup-continuation-Cv_c1B-7.js} +3 -3
- package/dist/{computer-setup-continuation-Cd293Yzi.js.map → computer-setup-continuation-Cv_c1B-7.js.map} +1 -1
- package/dist/{context-qbQXVLF5.js → context-BnhlFS8m.js} +5 -5
- package/dist/{context-qbQXVLF5.js.map → context-BnhlFS8m.js.map} +1 -1
- package/dist/{control-plane-rTE2rHZ5.js → control-plane-QqGL-jtT.js} +2 -2
- package/dist/{control-plane-rTE2rHZ5.js.map → control-plane-QqGL-jtT.js.map} +1 -1
- package/dist/{daemon-device-id-B6iDyQEs.js → daemon-device-id-DbSIqHoZ.js} +8 -8
- package/dist/{daemon-device-id-B6iDyQEs.js.map → daemon-device-id-DbSIqHoZ.js.map} +1 -1
- package/dist/{daemon-lifecycle-journal-DrwEygzu.js → daemon-lifecycle-journal-DsVVvKJe.js} +10 -10
- package/dist/{daemon-lifecycle-journal-DrwEygzu.js.map → daemon-lifecycle-journal-DsVVvKJe.js.map} +1 -1
- package/dist/{daemon-runtime-lease-C1wkT4Bi.js → daemon-runtime-lease-Bv6vhqOe.js} +2 -2
- package/dist/{daemon-runtime-lease-C1wkT4Bi.js.map → daemon-runtime-lease-Bv6vhqOe.js.map} +1 -1
- package/dist/{daemon-runtime-lease-DAQyRUc5.js → daemon-runtime-lease-ZjP0urJt.js} +1 -1
- package/dist/{daemon-service-contract-DhEfbzHt.js → daemon-service-contract-COPKbCy_.js} +4 -4
- package/dist/{daemon-service-contract-DhEfbzHt.js.map → daemon-service-contract-COPKbCy_.js.map} +1 -1
- package/dist/{daemon-service-manager-CRnFxPKA.js → daemon-service-manager-BXAp21GH.js} +6 -6
- package/dist/{daemon-service-manager-CRnFxPKA.js.map → daemon-service-manager-BXAp21GH.js.map} +1 -1
- package/dist/{daemon-service-manager-l0unaDGa.js → daemon-service-manager-C_ny0JhB.js} +1 -1
- package/dist/{daemon-service-runtime-B4nWB2Qx.js → daemon-service-runtime-DZI6Ke3_.js} +16 -15
- package/dist/{daemon-service-runtime-B4nWB2Qx.js.map → daemon-service-runtime-DZI6Ke3_.js.map} +1 -1
- package/dist/{daemon-service-update-coordinator-C8cW7Vn_.js → daemon-service-update-coordinator-BgVBlJ4d.js} +29 -24
- package/dist/daemon-service-update-coordinator-BgVBlJ4d.js.map +1 -0
- package/dist/{daemon-state-B6G5xe7f.js → daemon-state-Dte9re5V.js} +4 -4
- package/dist/{daemon-state-B6G5xe7f.js.map → daemon-state-Dte9re5V.js.map} +1 -1
- package/dist/{daemon-frame-transport-xQnNyg6E.js → dispatch-owned-runtime-BeIQetEt.js} +550 -53
- package/dist/dispatch-owned-runtime-BeIQetEt.js.map +1 -0
- package/dist/{dist-CAypwFRu.js → dist-BgYBvEBB.js} +206 -190
- package/dist/dist-BgYBvEBB.js.map +1 -0
- package/dist/{dist-DFhd6JmQ.js → dist-DQS0XYkb.js} +3 -3
- package/dist/{dist-DFhd6JmQ.js.map → dist-DQS0XYkb.js.map} +1 -1
- package/dist/{dist-olOaAWkl.js → dist-z72xYz5Z.js} +1 -1
- package/dist/{elapsed-time-COv3bjEl.js → elapsed-time-C7S-6bWV.js} +6 -6
- package/dist/{elapsed-time-COv3bjEl.js.map → elapsed-time-C7S-6bWV.js.map} +1 -1
- package/dist/{entry-DIjUKIep.js → entry-CX24qHnm.js} +81 -17
- package/dist/entry-CX24qHnm.js.map +1 -0
- package/dist/{installation-inventory-DllgoKT1.js → installation-inventory-B3mwQFEA.js} +5 -5
- package/dist/{installation-inventory-DllgoKT1.js.map → installation-inventory-B3mwQFEA.js.map} +1 -1
- package/dist/{installer-Sc79LhuA.js → installer-DnIJ4y3l.js} +2 -2
- package/dist/{installer-Sc79LhuA.js.map → installer-DnIJ4y3l.js.map} +1 -1
- package/dist/{local-components-DleLEzSU.js → local-components-DJiMS67S.js} +36 -3
- package/dist/local-components-DJiMS67S.js.map +1 -0
- package/dist/{lock-CMH9eoS7.js → lock-BMI00i2F.js} +2 -2
- package/dist/{lock-CMH9eoS7.js.map → lock-BMI00i2F.js.map} +1 -1
- package/dist/meta-api-DgHkiIdr.js +371 -0
- package/dist/meta-api-DgHkiIdr.js.map +1 -0
- package/dist/openmeld-dev.js +17 -9
- package/dist/openmeld-dev.js.map +1 -1
- package/dist/{openmeld-environment-target-Cw3V0WnE.js → openmeld-environment-target-BgYR6ozy.js} +8 -25
- package/dist/openmeld-environment-target-BgYR6ozy.js.map +1 -0
- package/dist/{openmeld-BUYFXSyY.js → openmeld-kYp99hOl.js} +41 -39
- package/dist/{openmeld-BUYFXSyY.js.map → openmeld-kYp99hOl.js.map} +1 -1
- package/dist/{openmeld-maintenance-worker-Br6WIhhe.js → openmeld-maintenance-worker-BqU1Asrm.js} +14 -14
- package/dist/{openmeld-maintenance-worker-Br6WIhhe.js.map → openmeld-maintenance-worker-BqU1Asrm.js.map} +1 -1
- package/dist/{openmeld-tools-update-join-B1l6RER6.js → openmeld-tools-update-join-BKJnGR5h.js} +4 -4
- package/dist/{openmeld-tools-update-join-B1l6RER6.js.map → openmeld-tools-update-join-BKJnGR5h.js.map} +1 -1
- package/dist/{openmeld-tools-update-process-frame-DbEZ3fEh.js → openmeld-tools-update-process-frame-Csy2XKUf.js} +1 -1
- package/dist/{openmeld-tools-update-process-frame-BtFKp70p.js → openmeld-tools-update-process-frame-YLOS82E3.js} +2 -2
- package/dist/{openmeld-tools-update-process-frame-BtFKp70p.js.map → openmeld-tools-update-process-frame-YLOS82E3.js.map} +1 -1
- package/dist/openmeld.js +6 -6
- package/dist/{paths-DSkUuEu3.js → paths-De9xdA2h.js} +11 -6
- package/dist/paths-De9xdA2h.js.map +1 -0
- package/dist/{prepare-provider-runtime-DfsSj_N_.js → prepare-provider-runtime-CD6XRt7X.js} +385 -181
- package/dist/prepare-provider-runtime-CD6XRt7X.js.map +1 -0
- package/dist/{prepare-session-executor-CrYpWljb.js → prepare-session-executor-DY2s4FuY.js} +26 -26
- package/dist/{prepare-session-executor-CrYpWljb.js.map → prepare-session-executor-DY2s4FuY.js.map} +1 -1
- package/dist/{process-channel-DmTb_kO4.js → process-channel-CzgOWiuh.js} +2 -2
- package/dist/{process-channel-DmTb_kO4.js.map → process-channel-CzgOWiuh.js.map} +1 -1
- package/dist/{published-production-safety-CgXxtdMK.js → published-production-safety-zANGAGDI.js} +5 -6
- package/dist/published-production-safety-zANGAGDI.js.map +1 -0
- package/dist/{runtime-ZLBVtFFY.js → runtime-Br4Ga0rJ.js} +77 -23
- package/dist/runtime-Br4Ga0rJ.js.map +1 -0
- package/dist/{runtime-agent-controller-reporting-submission-CbaUsNTF.js → runtime-agent-controller-reporting-submission-CQjbBiHh.js} +146 -37
- package/dist/runtime-agent-controller-reporting-submission-CQjbBiHh.js.map +1 -0
- package/dist/{runtime-reporting-health-state-DOg9iwwO.js → runtime-reporting-health-state-a1FUE1S-.js} +120 -25
- package/dist/runtime-reporting-health-state-a1FUE1S-.js.map +1 -0
- package/dist/{runtime-transport-D4x8_AmR.js → runtime-transport-D4CVffnp.js} +88 -8
- package/dist/runtime-transport-D4CVffnp.js.map +1 -0
- package/dist/{service-B9y1SQlB.js → service-D9QVc4_y.js} +99 -30
- package/dist/service-D9QVc4_y.js.map +1 -0
- package/dist/{service-account-authorization-Di59Cjth.js → service-account-authorization-DLhUgGDb.js} +6 -6
- package/dist/{service-account-authorization-Di59Cjth.js.map → service-account-authorization-DLhUgGDb.js.map} +1 -1
- package/dist/{service-account-control-DALO1USM.js → service-account-control-DIdQILmo.js} +13 -13
- package/dist/{service-account-control-DALO1USM.js.map → service-account-control-DIdQILmo.js.map} +1 -1
- package/dist/{service-control-capabilities-B9ZxDPOJ.js → service-control-capabilities-BvHU_NcX.js} +1 -1
- package/dist/{service-control-capabilities-CKwU9Er5.js → service-control-capabilities-CGv5Cuxo.js} +5 -5
- package/dist/{service-control-capabilities-CKwU9Er5.js.map → service-control-capabilities-CGv5Cuxo.js.map} +1 -1
- package/dist/{state-CdSbKM0J.js → state-AWe5DSV8.js} +3 -3
- package/dist/{state-CdSbKM0J.js.map → state-AWe5DSV8.js.map} +1 -1
- package/dist/upgrade-CLnZ4WBF.js +4 -0
- package/dist/{upgrade-DLJJlkbf.js → upgrade-CcnlL7FH.js} +9 -9
- package/dist/{upgrade-DLJJlkbf.js.map → upgrade-CcnlL7FH.js.map} +1 -1
- package/dist/{windows-preview-channel-DPrYuLyY.js → windows-preview-channel-BPhfSwji.js} +2 -2
- package/dist/{windows-preview-channel-DPrYuLyY.js.map → windows-preview-channel-BPhfSwji.js.map} +1 -1
- package/dist/{windows-user-task-BR-WB7hr.js → windows-user-task-CTsMnmD4.js} +3 -3
- package/dist/{windows-user-task-BR-WB7hr.js.map → windows-user-task-CTsMnmD4.js.map} +1 -1
- package/dist/{windows-user-task-m9eMEUEq.js → windows-user-task-DnxKO3oB.js} +1 -1
- package/package.json +10 -10
- package/dist/auth-session-DExyUwLo.js +0 -4
- package/dist/channel-DppbHxHw.js.map +0 -1
- package/dist/cli-binary-manifest-Bjf6T7Ef.js.map +0 -1
- package/dist/daemon-frame-transport-xQnNyg6E.js.map +0 -1
- package/dist/daemon-service-update-coordinator-C8cW7Vn_.js.map +0 -1
- package/dist/dist-CAypwFRu.js.map +0 -1
- package/dist/entry-DIjUKIep.js.map +0 -1
- package/dist/local-components-DleLEzSU.js.map +0 -1
- package/dist/meta-api-CEw8eOeN.js +0 -845
- package/dist/meta-api-CEw8eOeN.js.map +0 -1
- package/dist/openmeld-environment-target-Cw3V0WnE.js.map +0 -1
- package/dist/paths-DSkUuEu3.js.map +0 -1
- package/dist/prepare-provider-runtime-DfsSj_N_.js.map +0 -1
- package/dist/published-production-safety-CgXxtdMK.js.map +0 -1
- package/dist/runtime-ZLBVtFFY.js.map +0 -1
- package/dist/runtime-agent-controller-reporting-submission-CbaUsNTF.js.map +0 -1
- package/dist/runtime-reporting-health-state-DOg9iwwO.js.map +0 -1
- package/dist/runtime-transport-D4x8_AmR.js.map +0 -1
- package/dist/service-B9y1SQlB.js.map +0 -1
- package/dist/upgrade-BFWUxFpJ.js +0 -4
|
@@ -1,845 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
import { f as toSpaceMetaUrl } from "./urls-CY2uzH2-.js";
|
|
4
|
-
import { F as resolveOpenMeldEnvPreset, w as openMeldManagedBinaryPath } from "./paths-DSkUuEu3.js";
|
|
5
|
-
import { Bn as toStructuredApiClientFailure, ei as spaceMemberDirectoryEntrySchema, gi as spaceMetaSchema, mn as createSpaceApi, nr as OPENMELD_HEADER_REQUEST_ID, t as OpenMeldApiClientHttpError, yr as gatewayErrorEnvelopeSchema } from "./dist-CAypwFRu.js";
|
|
6
|
-
import { Jt as SPACE_FILE_MAX_SIZE_BYTES, Q as openMeldSpaceEgressActionSchema, _n as spaceFileNameSchema, in as resolveSpaceFileMimeType, rr as executionContextAssignmentSchema } from "./runtime-transport-D4x8_AmR.js";
|
|
7
|
-
import { _n as OPENMELD_DISPATCH_RUNTIME_TARGET_PROFILE_ID_ENV, gn as OPENMELD_DISPATCH_RUNTIME_MODE_ENV, hn as OPENMELD_DISPATCH_RUNTIME_DISPATCH_ID_ENV, pn as DISPATCH_OWNED_RUNTIME_MODE, vn as OPENMELD_SPACE_ACTION_TOOL_COMMAND_PATH_ENV, yn as OPENMELD_USER_FACING_CLI_COMMAND_ENV } from "./daemon-frame-transport-xQnNyg6E.js";
|
|
8
|
-
import { h as isSelfWakeSpaceAction } from "./dist-DFhd6JmQ.js";
|
|
9
|
-
import { n as resolveOpenMeldDistribution } from "./distribution-BDQT2ilb.js";
|
|
10
|
-
import { h as daemonRuntimeRootPath } from "./daemon-state-B6G5xe7f.js";
|
|
11
|
-
import { n as fetchSpaceRequestWithTimeout, s as buildOpenMeldRequestContextHeadersWithAuth, t as createCliApiClientFoundation } from "./api-client-foundation-DgTXf3Gb.js";
|
|
12
|
-
import { randomUUID } from "node:crypto";
|
|
13
|
-
import { basename, delimiter, dirname, isAbsolute, join, resolve } from "node:path";
|
|
14
|
-
import { access } from "node:fs/promises";
|
|
15
|
-
import { chmodSync, existsSync, mkdirSync, openAsBlob, readFileSync, renameSync, writeFileSync } from "node:fs";
|
|
16
|
-
import { isDeepStrictEqual } from "node:util";
|
|
17
|
-
//#region src/runtime/dispatch-space-action-context.ts
|
|
18
|
-
const OPENMELD_SPACE_ACTION_CONTEXT_PATH_ENV = "OPENMELD_SPACE_ACTION_CONTEXT_PATH";
|
|
19
|
-
/** The local action context is known expired/closed/mismatched: a new ordinary action must be rejected, never recorded. */
|
|
20
|
-
var DispatchSpaceActionClosedError = class extends Error {
|
|
21
|
-
receipt = "rejected_closed";
|
|
22
|
-
reasonCode;
|
|
23
|
-
constructor(reasonCode, message) {
|
|
24
|
-
super(message);
|
|
25
|
-
this.name = "DispatchSpaceActionClosedError";
|
|
26
|
-
this.reasonCode = reasonCode;
|
|
27
|
-
}
|
|
28
|
-
};
|
|
29
|
-
/** Use only at a boundary that has positively rejected this call before recording. */
|
|
30
|
-
var DispatchSpaceActionRejectedError = class extends Error {
|
|
31
|
-
reasonCode;
|
|
32
|
-
constructor(reasonCode, message) {
|
|
33
|
-
super(message);
|
|
34
|
-
this.name = "DispatchSpaceActionRejectedError";
|
|
35
|
-
this.reasonCode = reasonCode;
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
const DISPATCH_SPACE_ACTION_CONTEXT_VERSION = 1;
|
|
39
|
-
const DISPATCH_SPACE_ACTION_RECORD_VERSION = 1;
|
|
40
|
-
const DEFAULT_CONTEXT_TTL_MS = 720 * 60 * 1e3;
|
|
41
|
-
function createDispatchSpaceActionContext(input) {
|
|
42
|
-
const contextId = randomUUID();
|
|
43
|
-
const nonce = randomUUID();
|
|
44
|
-
const contextDir = join(daemonRuntimeRootPath(input.pathInput ?? { env: input.env }), "dispatch-space-actions", `${Date.now().toString(36)}-${contextId}`);
|
|
45
|
-
mkdirSync(contextDir, {
|
|
46
|
-
recursive: true,
|
|
47
|
-
mode: 448
|
|
48
|
-
});
|
|
49
|
-
chmodSync(contextDir, 448);
|
|
50
|
-
const contextPath = join(contextDir, "context.json");
|
|
51
|
-
const actionRecordPath = join(contextDir, "action.json");
|
|
52
|
-
const context = {
|
|
53
|
-
...input.projectShell ? { projectShell: input.projectShell } : {},
|
|
54
|
-
...input.workingCopyId ? { workingCopyId: input.workingCopyId } : {},
|
|
55
|
-
version: DISPATCH_SPACE_ACTION_CONTEXT_VERSION,
|
|
56
|
-
actionRecordPath,
|
|
57
|
-
attemptId: input.attemptId,
|
|
58
|
-
contextId,
|
|
59
|
-
dispatchId: input.dispatchId,
|
|
60
|
-
expiresAtMs: Date.now() + (input.ttlMs ?? DEFAULT_CONTEXT_TTL_MS),
|
|
61
|
-
nonce,
|
|
62
|
-
replyToSignalId: normalizeOptionalText$2(input.replyToSignalId),
|
|
63
|
-
sendTargetReference: input.sendTargetReference,
|
|
64
|
-
sourceEventId: input.sourceEventId,
|
|
65
|
-
spaceContractSnapshot: input.spaceContractSnapshot ? {
|
|
66
|
-
allowedActions: input.spaceContractSnapshot.allowedActions,
|
|
67
|
-
publicationMode: input.spaceContractSnapshot.publicationMode
|
|
68
|
-
} : null,
|
|
69
|
-
spaceId: input.spaceId,
|
|
70
|
-
targetProfileId: input.targetProfileId,
|
|
71
|
-
taskId: input.taskId
|
|
72
|
-
};
|
|
73
|
-
writeJsonFileExclusive(contextPath, context);
|
|
74
|
-
return {
|
|
75
|
-
context,
|
|
76
|
-
contextPath
|
|
77
|
-
};
|
|
78
|
-
}
|
|
79
|
-
function readDispatchSpaceActionContextFromEnv(env = process.env) {
|
|
80
|
-
const context = readDispatchSpaceActionContextForReceiptFromEnv(env);
|
|
81
|
-
assertContextActive(context, Date.now());
|
|
82
|
-
return context;
|
|
83
|
-
}
|
|
84
|
-
function readDispatchSpaceActionContextForReceiptFromEnv(env = process.env) {
|
|
85
|
-
const contextPath = normalizeOptionalText$2(env[OPENMELD_SPACE_ACTION_CONTEXT_PATH_ENV]);
|
|
86
|
-
if (!contextPath) throw new Error("No active OpenMeld Space Action dispatch context was found. Use this command inside an OpenMeld Space Wake dispatch.");
|
|
87
|
-
const context = readDispatchSpaceActionContext(contextPath);
|
|
88
|
-
assertDispatchRuntimeEnvMatchesContext({
|
|
89
|
-
context,
|
|
90
|
-
env
|
|
91
|
-
});
|
|
92
|
-
return context;
|
|
93
|
-
}
|
|
94
|
-
function readDispatchSpaceActionContext(contextPath) {
|
|
95
|
-
return parseDispatchSpaceActionContext(readJsonFile(contextPath));
|
|
96
|
-
}
|
|
97
|
-
function writeDispatchSpaceActionRecord(input) {
|
|
98
|
-
const parsedAction = openMeldSpaceEgressActionSchema.safeParse(input.action);
|
|
99
|
-
if (!parsedAction.success) throw new DispatchSpaceActionRejectedError("space_action.invalid_input", parsedAction.error.message);
|
|
100
|
-
if (isSelfWakeSpaceAction(parsedAction.data, input.context.targetProfileId)) throw new DispatchSpaceActionRejectedError("space_action.invalid_input", "An Agent cannot Wake itself. To reply to the current message, omit wakeTargets (CLI: --wake) and submit the reply again. No action was recorded.");
|
|
101
|
-
const existing = readDispatchSpaceActionRecord({ context: input.context });
|
|
102
|
-
if (existing.status === "invalid") throw new Error(existing.errorMessage);
|
|
103
|
-
if (existing.status === "loaded" && isDeepStrictEqual(existing.record.action, parsedAction.data)) return existing.record;
|
|
104
|
-
assertContextActive(input.context, input.nowMs ?? Date.now());
|
|
105
|
-
const record = {
|
|
106
|
-
version: DISPATCH_SPACE_ACTION_RECORD_VERSION,
|
|
107
|
-
action: parsedAction.data,
|
|
108
|
-
command: input.command,
|
|
109
|
-
contextId: input.context.contextId,
|
|
110
|
-
createdAtMs: input.nowMs ?? Date.now(),
|
|
111
|
-
nonce: input.context.nonce
|
|
112
|
-
};
|
|
113
|
-
try {
|
|
114
|
-
writeJsonFileExclusive(input.context.actionRecordPath, record);
|
|
115
|
-
} catch (error) {
|
|
116
|
-
if (isNodeErrorCode(error, "EEXIST")) {
|
|
117
|
-
const existing = readDispatchSpaceActionRecord({ context: input.context });
|
|
118
|
-
if (existing.status === "loaded" && isDeepStrictEqual(existing.record.action, parsedAction.data)) return existing.record;
|
|
119
|
-
throw new DispatchSpaceActionRejectedError("space_action.already_recorded", "An OpenMeld Space Action has already been recorded for this dispatch. A Wake can only have one final Space action. Recover its receipt with the exact original arguments; do not replace it with a different action.");
|
|
120
|
-
}
|
|
121
|
-
throw error;
|
|
122
|
-
}
|
|
123
|
-
return record;
|
|
124
|
-
}
|
|
125
|
-
function readDispatchSpaceActionRecord(input) {
|
|
126
|
-
if (!existsSync(input.context.actionRecordPath)) return { status: "missing" };
|
|
127
|
-
try {
|
|
128
|
-
const record = parseDispatchSpaceActionRecord(readJsonFile(input.context.actionRecordPath));
|
|
129
|
-
if (record.contextId !== input.context.contextId || record.nonce !== input.context.nonce) return {
|
|
130
|
-
status: "invalid",
|
|
131
|
-
errorMessage: "OpenMeld Space Action record does not match the active dispatch context."
|
|
132
|
-
};
|
|
133
|
-
if (record.createdAtMs > input.context.expiresAtMs) return {
|
|
134
|
-
status: "invalid",
|
|
135
|
-
errorMessage: "OpenMeld Space Action record was created after the active dispatch context expired."
|
|
136
|
-
};
|
|
137
|
-
return {
|
|
138
|
-
status: "loaded",
|
|
139
|
-
record
|
|
140
|
-
};
|
|
141
|
-
} catch (error) {
|
|
142
|
-
return {
|
|
143
|
-
status: "invalid",
|
|
144
|
-
errorMessage: error instanceof Error ? error.message : String(error)
|
|
145
|
-
};
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
function supersedeDispatchSpaceActionRecordForReconsideration(input) {
|
|
149
|
-
const readResult = readDispatchSpaceActionRecord(input);
|
|
150
|
-
if (readResult.status === "missing") return null;
|
|
151
|
-
if (readResult.status === "invalid") throw new Error(readResult.errorMessage);
|
|
152
|
-
const archivedPath = `${input.context.actionRecordPath}.superseded-${String(input.nowMs ?? Date.now())}-${randomUUID()}`;
|
|
153
|
-
renameSync(input.context.actionRecordPath, archivedPath);
|
|
154
|
-
return {
|
|
155
|
-
archivedPath,
|
|
156
|
-
record: readResult.record
|
|
157
|
-
};
|
|
158
|
-
}
|
|
159
|
-
function parseDispatchSpaceActionContext(value) {
|
|
160
|
-
const record = toRecord(value, "OpenMeld Space Action context");
|
|
161
|
-
const version = record.version;
|
|
162
|
-
if (version !== DISPATCH_SPACE_ACTION_CONTEXT_VERSION) throw new Error("Unsupported OpenMeld Space Action context version.");
|
|
163
|
-
const sendTargetReference = parseSendTargetReference(record.sendTargetReference);
|
|
164
|
-
return {
|
|
165
|
-
...record.projectShell ? { projectShell: parseProjectShell(record.projectShell) } : {},
|
|
166
|
-
version,
|
|
167
|
-
actionRecordPath: requiredString(record.actionRecordPath, "actionRecordPath"),
|
|
168
|
-
attemptId: requiredString(record.attemptId, "attemptId"),
|
|
169
|
-
contextId: requiredString(record.contextId, "contextId"),
|
|
170
|
-
dispatchId: requiredString(record.dispatchId, "dispatchId"),
|
|
171
|
-
expiresAtMs: requiredFiniteNumber(record.expiresAtMs, "expiresAtMs"),
|
|
172
|
-
nonce: requiredString(record.nonce, "nonce"),
|
|
173
|
-
replyToSignalId: optionalString(record.replyToSignalId),
|
|
174
|
-
sendTargetReference,
|
|
175
|
-
sourceEventId: requiredString(record.sourceEventId, "sourceEventId"),
|
|
176
|
-
spaceContractSnapshot: parseSpaceContractSnapshot(record.spaceContractSnapshot),
|
|
177
|
-
spaceId: requiredString(record.spaceId, "spaceId"),
|
|
178
|
-
targetProfileId: requiredString(record.targetProfileId, "targetProfileId"),
|
|
179
|
-
taskId: requiredString(record.taskId, "taskId"),
|
|
180
|
-
...record.workingCopyId ? { workingCopyId: requiredString(record.workingCopyId, "workingCopyId") } : {}
|
|
181
|
-
};
|
|
182
|
-
}
|
|
183
|
-
function parseProjectShell(value) {
|
|
184
|
-
const record = toRecord(value, "OpenMeld project shell context");
|
|
185
|
-
const runtime = toRecord(record.runtime, "OpenMeld project shell runtime");
|
|
186
|
-
const kind = runtime.kind;
|
|
187
|
-
if (kind !== "docker" && kind !== "podman") throw new Error("OpenMeld project shell runtime is invalid.");
|
|
188
|
-
const executionContextId = requiredString(record.executionContextId, "executionContextId");
|
|
189
|
-
const workspacePath = requiredString(record.workspacePath, "workspacePath");
|
|
190
|
-
const boundaryRoot = requiredString(record.boundaryRoot, "boundaryRoot");
|
|
191
|
-
const ledgerRootPath = requiredString(record.ledgerRootPath, "ledgerRootPath");
|
|
192
|
-
const binary = requiredString(runtime.binary, "binary");
|
|
193
|
-
const validContextId = executionContextAssignmentSchema.shape.id.safeParse(executionContextId).success;
|
|
194
|
-
const validPaths = [
|
|
195
|
-
workspacePath,
|
|
196
|
-
boundaryRoot,
|
|
197
|
-
ledgerRootPath,
|
|
198
|
-
binary
|
|
199
|
-
].every(isAbsolute);
|
|
200
|
-
if (!(validContextId && validPaths)) throw new Error("OpenMeld project shell context is invalid.");
|
|
201
|
-
return {
|
|
202
|
-
boundaryRoot,
|
|
203
|
-
executionContextId,
|
|
204
|
-
ledgerRootPath,
|
|
205
|
-
workspacePath,
|
|
206
|
-
runtime: {
|
|
207
|
-
binary,
|
|
208
|
-
engineIdentity: requiredString(runtime.engineIdentity, "engineIdentity"),
|
|
209
|
-
kind
|
|
210
|
-
}
|
|
211
|
-
};
|
|
212
|
-
}
|
|
213
|
-
function assertDispatchRuntimeEnvMatchesContext(input) {
|
|
214
|
-
if (normalizeOptionalText$2(input.env["OPENMELD_DISPATCH_RUNTIME_MODE"]) !== "dispatch-owned-runtime") return;
|
|
215
|
-
const envDispatchId = normalizeOptionalText$2(input.env[OPENMELD_DISPATCH_RUNTIME_DISPATCH_ID_ENV]);
|
|
216
|
-
if (!envDispatchId) throw new Error("OpenMeld Space Action dispatch runtime is missing the active dispatch ID.");
|
|
217
|
-
if (envDispatchId !== input.context.dispatchId) throw new DispatchSpaceActionClosedError("space_action.context_mismatch", "OpenMeld Space Action dispatch context does not match the active dispatch runtime.");
|
|
218
|
-
const envTargetProfileId = normalizeOptionalText$2(input.env[OPENMELD_DISPATCH_RUNTIME_TARGET_PROFILE_ID_ENV]);
|
|
219
|
-
if (!envTargetProfileId) throw new Error("OpenMeld Space Action dispatch runtime is missing the active target profile ID.");
|
|
220
|
-
if (envTargetProfileId !== input.context.targetProfileId) throw new DispatchSpaceActionClosedError("space_action.context_mismatch", "OpenMeld Space Action target profile does not match the active dispatch runtime.");
|
|
221
|
-
}
|
|
222
|
-
function parseDispatchSpaceActionRecord(value) {
|
|
223
|
-
const record = toRecord(value, "OpenMeld Space Action record");
|
|
224
|
-
const version = record.version;
|
|
225
|
-
if (version !== DISPATCH_SPACE_ACTION_RECORD_VERSION) throw new Error("Unsupported OpenMeld Space Action record version.");
|
|
226
|
-
const parsedAction = openMeldSpaceEgressActionSchema.safeParse(record.action);
|
|
227
|
-
if (!parsedAction.success) throw parsedAction.error;
|
|
228
|
-
return {
|
|
229
|
-
version,
|
|
230
|
-
action: parsedAction.data,
|
|
231
|
-
command: requiredString(record.command, "command"),
|
|
232
|
-
contextId: requiredString(record.contextId, "contextId"),
|
|
233
|
-
createdAtMs: requiredFiniteNumber(record.createdAtMs, "createdAtMs"),
|
|
234
|
-
nonce: requiredString(record.nonce, "nonce")
|
|
235
|
-
};
|
|
236
|
-
}
|
|
237
|
-
function parseSendTargetReference(value) {
|
|
238
|
-
const record = toRecord(value, "sendTargetReference");
|
|
239
|
-
if (record.status === "loaded") {
|
|
240
|
-
if (!Array.isArray(record.projection)) throw new Error("OpenMeld Space Action send target projection must be an array.");
|
|
241
|
-
return {
|
|
242
|
-
status: "loaded",
|
|
243
|
-
projection: record.projection.map(parseSendTargetProjectionEntry),
|
|
244
|
-
referenceLines: parseStringArray(record.referenceLines)
|
|
245
|
-
};
|
|
246
|
-
}
|
|
247
|
-
if (record.status === "failed") return {
|
|
248
|
-
status: "failed",
|
|
249
|
-
errorMessage: requiredString(record.errorMessage, "errorMessage"),
|
|
250
|
-
projection: null,
|
|
251
|
-
referenceLines: []
|
|
252
|
-
};
|
|
253
|
-
throw new Error("Invalid OpenMeld Space Action send target reference status.");
|
|
254
|
-
}
|
|
255
|
-
function parseSendTargetProjectionEntry(value, index) {
|
|
256
|
-
const parsed = spaceMemberDirectoryEntrySchema.safeParse(value);
|
|
257
|
-
if (!parsed.success) throw new Error(`OpenMeld Space Action target projection entry ${index} is not a valid Space member directory entry.`);
|
|
258
|
-
return parsed.data;
|
|
259
|
-
}
|
|
260
|
-
function parseSpaceContractSnapshot(value) {
|
|
261
|
-
if (value === null || value === void 0) return null;
|
|
262
|
-
const record = toRecord(value, "spaceContractSnapshot");
|
|
263
|
-
return {
|
|
264
|
-
allowedActions: Array.isArray(record.allowedActions) ? record.allowedActions : [],
|
|
265
|
-
publicationMode: record.publicationMode === "raw_context_sharing" ? "raw_context_sharing" : "collaboration"
|
|
266
|
-
};
|
|
267
|
-
}
|
|
268
|
-
function assertContextActive(context, nowMs) {
|
|
269
|
-
if (nowMs > context.expiresAtMs) throw new DispatchSpaceActionClosedError("space_action.context_expired", "The OpenMeld Space Action dispatch context has expired.");
|
|
270
|
-
}
|
|
271
|
-
function readJsonFile(path) {
|
|
272
|
-
return JSON.parse(readFileSync(path, "utf8"));
|
|
273
|
-
}
|
|
274
|
-
function writeJsonFileExclusive(path, value) {
|
|
275
|
-
writeFileSync(path, `${JSON.stringify(value, null, 2)}\n`, {
|
|
276
|
-
encoding: "utf8",
|
|
277
|
-
flag: "wx",
|
|
278
|
-
mode: 384
|
|
279
|
-
});
|
|
280
|
-
chmodSync(path, 384);
|
|
281
|
-
}
|
|
282
|
-
function toRecord(value, label) {
|
|
283
|
-
if (!value || typeof value !== "object" || Array.isArray(value)) throw new Error(`${label} must be a JSON object.`);
|
|
284
|
-
return value;
|
|
285
|
-
}
|
|
286
|
-
function requiredString(value, fieldName) {
|
|
287
|
-
const normalized = normalizeOptionalText$2(value);
|
|
288
|
-
if (!normalized) throw new Error(`${fieldName} must be a non-empty string.`);
|
|
289
|
-
return normalized;
|
|
290
|
-
}
|
|
291
|
-
function requiredFiniteNumber(value, fieldName) {
|
|
292
|
-
if (typeof value !== "number" || !Number.isFinite(value)) throw new Error(`${fieldName} must be a finite number.`);
|
|
293
|
-
return value;
|
|
294
|
-
}
|
|
295
|
-
function optionalString(value) {
|
|
296
|
-
if (value === null || value === void 0) return null;
|
|
297
|
-
return normalizeOptionalText$2(value);
|
|
298
|
-
}
|
|
299
|
-
function parseStringArray(value) {
|
|
300
|
-
if (!Array.isArray(value)) return [];
|
|
301
|
-
return value.map((item) => normalizeOptionalText$2(item)).filter((item) => Boolean(item));
|
|
302
|
-
}
|
|
303
|
-
function normalizeOptionalText$2(value) {
|
|
304
|
-
const normalized = String(value ?? "").trim();
|
|
305
|
-
return normalized.length > 0 ? normalized : null;
|
|
306
|
-
}
|
|
307
|
-
function isNodeErrorCode(error, code) {
|
|
308
|
-
return typeof error === "object" && error !== null && "code" in error && error.code === code;
|
|
309
|
-
}
|
|
310
|
-
//#endregion
|
|
311
|
-
//#region src/runtime/dispatch-owned-runtime.ts
|
|
312
|
-
const DISPATCH_OWNED_RUNTIME_CLI_SHIM_DIRNAME = "dispatch-owned-cli";
|
|
313
|
-
const DISPATCH_SPACE_ACTION_CLI_SHIM_DIRNAME = "bin";
|
|
314
|
-
const OPENMELD_ENV_PRESET_ENV = "OPENMELD_ENV_PRESET";
|
|
315
|
-
const DISPATCH_OWNED_RUNTIME_CLI_COMMAND_NAMES = [
|
|
316
|
-
"openmeld",
|
|
317
|
-
"openmeld-dev",
|
|
318
|
-
"openmeld-canary"
|
|
319
|
-
];
|
|
320
|
-
function buildDispatchOwnedRuntimeEnv(input) {
|
|
321
|
-
const env = {
|
|
322
|
-
OPENMELD_HOME: process.env.OPENMELD_HOME,
|
|
323
|
-
OPENMELD_ENV_PRESET: process.env.OPENMELD_ENV_PRESET,
|
|
324
|
-
...input.env ?? {}
|
|
325
|
-
};
|
|
326
|
-
const currentPath = normalizeOptionalText$1(input.env?.PATH ?? process.env.PATH);
|
|
327
|
-
const actionCommand = resolveDispatchOwnedRuntimeActionCliEntryCommand({ env });
|
|
328
|
-
const actionCommandPath = (input.platform ?? process.platform) === "win32" && (input.distribution ?? resolveOpenMeldDistribution()) === "binary" ? resolveDispatchOwnedRuntimeBinaryCliEntryPath({
|
|
329
|
-
cliEntryPath: input.cliEntryPath,
|
|
330
|
-
env
|
|
331
|
-
}) : join(ensureDispatchOwnedRuntimeCliShims({
|
|
332
|
-
cliEntryPath: input.cliEntryPath,
|
|
333
|
-
dispatchId: input.dispatchId,
|
|
334
|
-
distribution: input.distribution,
|
|
335
|
-
env,
|
|
336
|
-
spaceActionContextPath: input.spaceActionContextPath,
|
|
337
|
-
targetProfileId: input.targetProfileId
|
|
338
|
-
}), actionCommand);
|
|
339
|
-
return {
|
|
340
|
-
...env,
|
|
341
|
-
PATH: prependPathEntry({
|
|
342
|
-
currentPath,
|
|
343
|
-
nextEntry: dirname(actionCommandPath)
|
|
344
|
-
}),
|
|
345
|
-
[OPENMELD_DISPATCH_RUNTIME_MODE_ENV]: DISPATCH_OWNED_RUNTIME_MODE,
|
|
346
|
-
[OPENMELD_DISPATCH_RUNTIME_DISPATCH_ID_ENV]: input.dispatchId,
|
|
347
|
-
[OPENMELD_DISPATCH_RUNTIME_TARGET_PROFILE_ID_ENV]: input.targetProfileId,
|
|
348
|
-
[OPENMELD_USER_FACING_CLI_COMMAND_ENV]: actionCommand,
|
|
349
|
-
[OPENMELD_SPACE_ACTION_TOOL_COMMAND_PATH_ENV]: actionCommandPath,
|
|
350
|
-
[OPENMELD_ENV_PRESET_ENV]: resolveDispatchOwnedRuntimeEnvPreset({ env }),
|
|
351
|
-
...input.spaceActionContextPath ? { [OPENMELD_SPACE_ACTION_CONTEXT_PATH_ENV]: input.spaceActionContextPath } : {}
|
|
352
|
-
};
|
|
353
|
-
}
|
|
354
|
-
function resolveDispatchOwnedRuntimeActionCliEntryCommand(input = {}) {
|
|
355
|
-
const preset = resolveOpenMeldEnvPreset(input);
|
|
356
|
-
if (preset === "dev-local") return "openmeld-dev";
|
|
357
|
-
if (preset === "canary") return "openmeld-canary";
|
|
358
|
-
return "openmeld";
|
|
359
|
-
}
|
|
360
|
-
function resolveDispatchOwnedRuntimeCliShimDir(input = {}) {
|
|
361
|
-
const spaceActionContextPath = normalizeOptionalText$1(input.spaceActionContextPath);
|
|
362
|
-
if (spaceActionContextPath) return join(dirname(spaceActionContextPath), DISPATCH_SPACE_ACTION_CLI_SHIM_DIRNAME);
|
|
363
|
-
return join(daemonRuntimeRootPath(input), "bin", DISPATCH_OWNED_RUNTIME_CLI_SHIM_DIRNAME);
|
|
364
|
-
}
|
|
365
|
-
function ensureDispatchOwnedRuntimeCliShims(input) {
|
|
366
|
-
const distribution = input?.distribution ?? resolveOpenMeldDistribution();
|
|
367
|
-
const cliEntryPath = distribution === "binary" ? resolveDispatchOwnedRuntimeBinaryCliEntryPath({
|
|
368
|
-
cliEntryPath: input?.cliEntryPath,
|
|
369
|
-
env: input?.env
|
|
370
|
-
}) : resolveDispatchOwnedRuntimeCliEntryPath(input?.cliEntryPath);
|
|
371
|
-
const shimDir = resolveDispatchOwnedRuntimeCliShimDir({
|
|
372
|
-
env: input?.env,
|
|
373
|
-
spaceActionContextPath: input?.spaceActionContextPath
|
|
374
|
-
});
|
|
375
|
-
mkdirSync(shimDir, { recursive: true });
|
|
376
|
-
for (const commandName of DISPATCH_OWNED_RUNTIME_CLI_COMMAND_NAMES) {
|
|
377
|
-
const shimPath = join(shimDir, commandName);
|
|
378
|
-
const shimSource = buildDispatchOwnedRuntimeCliShimSource({
|
|
379
|
-
cliEntryPath,
|
|
380
|
-
commandName,
|
|
381
|
-
dispatchId: input?.dispatchId,
|
|
382
|
-
distribution,
|
|
383
|
-
nodePath: process.execPath,
|
|
384
|
-
spaceActionContextPath: input?.spaceActionContextPath,
|
|
385
|
-
targetProfileId: input?.targetProfileId
|
|
386
|
-
});
|
|
387
|
-
if (existsSync(shimPath)) {
|
|
388
|
-
if (safeReadTextFile(shimPath) === shimSource) {
|
|
389
|
-
chmodSync(shimPath, 493);
|
|
390
|
-
continue;
|
|
391
|
-
}
|
|
392
|
-
}
|
|
393
|
-
writeFileSync(shimPath, shimSource, {
|
|
394
|
-
encoding: "utf8",
|
|
395
|
-
mode: 493
|
|
396
|
-
});
|
|
397
|
-
chmodSync(shimPath, 493);
|
|
398
|
-
}
|
|
399
|
-
return shimDir;
|
|
400
|
-
}
|
|
401
|
-
function readDispatchOwnedRuntimeGuard(env = process.env) {
|
|
402
|
-
if (normalizeOptionalText$1(env["OPENMELD_DISPATCH_RUNTIME_MODE"]) !== "dispatch-owned-runtime") return {
|
|
403
|
-
active: false,
|
|
404
|
-
dispatchId: null,
|
|
405
|
-
targetProfileId: null
|
|
406
|
-
};
|
|
407
|
-
return {
|
|
408
|
-
active: true,
|
|
409
|
-
dispatchId: normalizeOptionalText$1(env[OPENMELD_DISPATCH_RUNTIME_DISPATCH_ID_ENV]),
|
|
410
|
-
targetProfileId: normalizeOptionalText$1(env[OPENMELD_DISPATCH_RUNTIME_TARGET_PROFILE_ID_ENV])
|
|
411
|
-
};
|
|
412
|
-
}
|
|
413
|
-
function assertDispatchOwnedRuntimePublicWriteAllowed(input) {
|
|
414
|
-
const guard = readDispatchOwnedRuntimeGuard(input.env);
|
|
415
|
-
if (!guard.active) return;
|
|
416
|
-
const dispatchIdSuffix = guard.dispatchId ? ` (dispatch ${guard.dispatchId})` : "";
|
|
417
|
-
throw new Error(`${input.commandLabel} is blocked inside a dispatch-owned runtime${dispatchIdSuffix}. Public space writes must be returned through OpenMeld Space structured actions: post_message, post_status, or stay_silent.`);
|
|
418
|
-
}
|
|
419
|
-
function normalizeOptionalText$1(value) {
|
|
420
|
-
const normalized = String(value ?? "").trim();
|
|
421
|
-
return normalized.length > 0 ? normalized : null;
|
|
422
|
-
}
|
|
423
|
-
function resolveDispatchOwnedRuntimeCliEntryPath(cliEntryPath) {
|
|
424
|
-
const normalizedCliEntryPath = normalizeOptionalText$1(cliEntryPath) ?? normalizeOptionalText$1(process.argv[1]) ?? null;
|
|
425
|
-
if (!normalizedCliEntryPath) throw new Error("dispatch-owned runtime CLI shim requires a current CLI entry path");
|
|
426
|
-
return resolve(normalizedCliEntryPath);
|
|
427
|
-
}
|
|
428
|
-
function resolveDispatchOwnedRuntimeBinaryCliEntryPath(input) {
|
|
429
|
-
const normalizedCliEntryPath = normalizeOptionalText$1(input.cliEntryPath) ?? normalizeOptionalText$1(openMeldManagedBinaryPath({ env: input.env })) ?? null;
|
|
430
|
-
if (!normalizedCliEntryPath) throw new Error("dispatch-owned runtime CLI shim requires a current binary CLI path");
|
|
431
|
-
return resolve(normalizedCliEntryPath);
|
|
432
|
-
}
|
|
433
|
-
function buildDispatchOwnedRuntimeCliShimSource(input) {
|
|
434
|
-
const embeddedEnv = {
|
|
435
|
-
[OPENMELD_DISPATCH_RUNTIME_MODE_ENV]: DISPATCH_OWNED_RUNTIME_MODE,
|
|
436
|
-
[OPENMELD_ENV_PRESET_ENV]: resolveEnvPresetForCommandName(input.commandName),
|
|
437
|
-
[OPENMELD_USER_FACING_CLI_COMMAND_ENV]: input.commandName,
|
|
438
|
-
...normalizeOptionalText$1(input.dispatchId) ? { [OPENMELD_DISPATCH_RUNTIME_DISPATCH_ID_ENV]: normalizeOptionalText$1(input.dispatchId) } : {},
|
|
439
|
-
...normalizeOptionalText$1(input.targetProfileId) ? { [OPENMELD_DISPATCH_RUNTIME_TARGET_PROFILE_ID_ENV]: normalizeOptionalText$1(input.targetProfileId) } : {},
|
|
440
|
-
...normalizeOptionalText$1(input.spaceActionContextPath) ? { [OPENMELD_SPACE_ACTION_CONTEXT_PATH_ENV]: normalizeOptionalText$1(input.spaceActionContextPath) } : {}
|
|
441
|
-
};
|
|
442
|
-
if (input.distribution === "binary") return `#!/bin/sh
|
|
443
|
-
${Object.entries(embeddedEnv).map(([key, value]) => `export ${key}=${quoteShellValue(value)}`).join("\n")}
|
|
444
|
-
exec ${quoteShellValue(input.cliEntryPath)} "$@"
|
|
445
|
-
`;
|
|
446
|
-
return `#!/usr/bin/env node
|
|
447
|
-
import { spawnSync } from "node:child_process";
|
|
448
|
-
|
|
449
|
-
const result = spawnSync(${JSON.stringify(input.nodePath)}, [${JSON.stringify(input.cliEntryPath)}, ...process.argv.slice(2)], {
|
|
450
|
-
env: { ...process.env, ...${JSON.stringify(embeddedEnv)} },
|
|
451
|
-
stdio: "inherit",
|
|
452
|
-
});
|
|
453
|
-
|
|
454
|
-
if (result.error) {
|
|
455
|
-
throw result.error;
|
|
456
|
-
}
|
|
457
|
-
|
|
458
|
-
process.exit(result.status ?? 1);
|
|
459
|
-
`;
|
|
460
|
-
}
|
|
461
|
-
function resolveDispatchOwnedRuntimeEnvPreset(input) {
|
|
462
|
-
return resolveEnvPresetForCommandName(resolveDispatchOwnedRuntimeActionCliEntryCommand({ env: input.env }));
|
|
463
|
-
}
|
|
464
|
-
function resolveEnvPresetForCommandName(commandName) {
|
|
465
|
-
if (commandName === "openmeld-dev") return "dev-local";
|
|
466
|
-
if (commandName === "openmeld-canary") return "canary";
|
|
467
|
-
return "prod";
|
|
468
|
-
}
|
|
469
|
-
function quoteShellValue(value) {
|
|
470
|
-
return `'${value.replaceAll("'", "'\\''")}'`;
|
|
471
|
-
}
|
|
472
|
-
function safeReadTextFile(path) {
|
|
473
|
-
try {
|
|
474
|
-
return readFileSync(path, "utf8");
|
|
475
|
-
} catch {
|
|
476
|
-
return null;
|
|
477
|
-
}
|
|
478
|
-
}
|
|
479
|
-
function prependPathEntry(input) {
|
|
480
|
-
const dedupedEntries = (input.currentPath ?? "").split(delimiter).map((entry) => entry.trim()).filter((entry) => entry.length > 0).filter((entry) => entry !== input.nextEntry);
|
|
481
|
-
return [input.nextEntry, ...dedupedEntries].join(delimiter);
|
|
482
|
-
}
|
|
483
|
-
//#endregion
|
|
484
|
-
//#region src/space/cli-space-api.ts
|
|
485
|
-
function createCliSpaceApi(baseUrl, options = {}) {
|
|
486
|
-
return createSpaceApi(createCliApiClientFoundation(baseUrl, options));
|
|
487
|
-
}
|
|
488
|
-
//#endregion
|
|
489
|
-
//#region src/space/send-files.ts
|
|
490
|
-
var SpaceSendFileError = class extends Error {
|
|
491
|
-
code;
|
|
492
|
-
requestId;
|
|
493
|
-
status;
|
|
494
|
-
upstreamCode;
|
|
495
|
-
constructor(input) {
|
|
496
|
-
super(input.message, { cause: input.cause });
|
|
497
|
-
this.name = "SpaceSendFileError";
|
|
498
|
-
this.code = input.code;
|
|
499
|
-
if (input.requestId) this.requestId = input.requestId;
|
|
500
|
-
if (input.status !== null && input.status !== void 0) this.status = input.status;
|
|
501
|
-
if (input.upstreamCode) this.upstreamCode = input.upstreamCode;
|
|
502
|
-
}
|
|
503
|
-
};
|
|
504
|
-
async function prepareRequestedSpaceSendFiles(input) {
|
|
505
|
-
if (input.filePaths.length > 10) throw new SpaceSendFileError({
|
|
506
|
-
code: "space.file.too_many",
|
|
507
|
-
message: `A Space message can include at most 10 files. The message was not sent.`
|
|
508
|
-
});
|
|
509
|
-
const prepared = [];
|
|
510
|
-
for (const rawPath of input.filePaths) {
|
|
511
|
-
if (!rawPath.trim()) throw new SpaceSendFileError({
|
|
512
|
-
code: "space.file.invalid_path",
|
|
513
|
-
message: "File paths cannot be empty. The message was not sent."
|
|
514
|
-
});
|
|
515
|
-
prepared.push(await prepareSpaceSendFile(rawPath));
|
|
516
|
-
}
|
|
517
|
-
return prepared;
|
|
518
|
-
}
|
|
519
|
-
async function uploadPreparedSpaceFiles(input) {
|
|
520
|
-
const uploaded = [];
|
|
521
|
-
for (const file of input.files) try {
|
|
522
|
-
const descriptor = await input.spaceApi.uploadFile({
|
|
523
|
-
bytes: file.bytes,
|
|
524
|
-
clientMutationId: crypto.randomUUID(),
|
|
525
|
-
mimeType: file.mimeType,
|
|
526
|
-
name: file.name,
|
|
527
|
-
origin: "chat_upload",
|
|
528
|
-
parentId: null,
|
|
529
|
-
requestContext: input.requestContext,
|
|
530
|
-
spaceId: input.spaceId,
|
|
531
|
-
...input.password === void 0 ? {} : { spacePassword: input.password }
|
|
532
|
-
});
|
|
533
|
-
uploaded.push({
|
|
534
|
-
fileId: descriptor.id,
|
|
535
|
-
revision: descriptor.latestRevision.revision,
|
|
536
|
-
name: descriptor.name,
|
|
537
|
-
mimeType: descriptor.latestRevision.mimeType,
|
|
538
|
-
sizeBytes: descriptor.latestRevision.sizeBytes
|
|
539
|
-
});
|
|
540
|
-
} catch (error) {
|
|
541
|
-
const failure = toStructuredApiClientFailure(error);
|
|
542
|
-
const cleanupFailures = await moveUploadedFilesToTrash({
|
|
543
|
-
files: uploaded,
|
|
544
|
-
password: input.password,
|
|
545
|
-
requestContext: input.requestContext,
|
|
546
|
-
spaceApi: input.spaceApi,
|
|
547
|
-
spaceId: input.spaceId
|
|
548
|
-
});
|
|
549
|
-
let cleanupMessage = "";
|
|
550
|
-
if (uploaded.length > 0) cleanupMessage = cleanupFailures.length === 0 ? " Files added earlier in this send were moved to Trash." : ` ${formatCleanupFailures({
|
|
551
|
-
failures: cleanupFailures,
|
|
552
|
-
passwordProtected: input.password !== void 0,
|
|
553
|
-
profileId: input.requestContext.actorContext.openMeldProfileId,
|
|
554
|
-
spaceId: input.spaceId
|
|
555
|
-
})}`;
|
|
556
|
-
throw new SpaceSendFileError({
|
|
557
|
-
code: failure.code ?? "space.file.upload_failed",
|
|
558
|
-
message: `Could not add file "${file.name}" to this Space. The message was not sent. ${failure.message}${cleanupMessage}`,
|
|
559
|
-
cause: error,
|
|
560
|
-
requestId: failure.requestId,
|
|
561
|
-
status: failure.status,
|
|
562
|
-
upstreamCode: failure.upstreamCode
|
|
563
|
-
});
|
|
564
|
-
}
|
|
565
|
-
return uploaded;
|
|
566
|
-
}
|
|
567
|
-
async function moveUploadedFilesToTrash(input) {
|
|
568
|
-
const failures = [];
|
|
569
|
-
for (const file of input.files) try {
|
|
570
|
-
await input.spaceApi.trashFileEntry({
|
|
571
|
-
clientMutationId: crypto.randomUUID(),
|
|
572
|
-
entryId: file.fileId,
|
|
573
|
-
requestContext: input.requestContext,
|
|
574
|
-
spaceId: input.spaceId,
|
|
575
|
-
...input.password === void 0 ? {} : { spacePassword: input.password }
|
|
576
|
-
});
|
|
577
|
-
} catch (error) {
|
|
578
|
-
failures.push({
|
|
579
|
-
failure: toStructuredApiClientFailure(error),
|
|
580
|
-
fileId: file.fileId
|
|
581
|
-
});
|
|
582
|
-
}
|
|
583
|
-
return failures;
|
|
584
|
-
}
|
|
585
|
-
function formatCleanupFailures(input) {
|
|
586
|
-
return `${input.failures.map(({ failure, fileId }) => {
|
|
587
|
-
const evidence = [failure.code ? `code ${failure.code}` : null, failure.requestId ? `request ${failure.requestId}` : null].filter((value) => value !== null).join(", ");
|
|
588
|
-
return `Could not move file ${fileId} to Trash${evidence ? ` (${evidence})` : ""}: ${failure.message} Run \`openmeld space files trash ${input.spaceId} ${fileId} --profile ${input.profileId}\` to finish cleanup.`;
|
|
589
|
-
}).join(" ")}${input.passwordProtected ? " This Space is password protected. Add `--password` with the same Space password you used for this send; OpenMeld does not include the password in this message." : ""}`;
|
|
590
|
-
}
|
|
591
|
-
async function prepareSpaceSendFile(sourcePath) {
|
|
592
|
-
let bytes;
|
|
593
|
-
try {
|
|
594
|
-
await access(sourcePath);
|
|
595
|
-
bytes = await openAsBlob(sourcePath);
|
|
596
|
-
} catch (error) {
|
|
597
|
-
if (readNodeErrorCode(error) === "ENOENT") throw new SpaceSendFileError({
|
|
598
|
-
code: "space.file.file_not_found",
|
|
599
|
-
message: `File not found: ${sourcePath}. The message was not sent.`,
|
|
600
|
-
cause: error
|
|
601
|
-
});
|
|
602
|
-
throw new SpaceSendFileError({
|
|
603
|
-
code: "space.file.file_unreadable",
|
|
604
|
-
message: `Could not read file: ${sourcePath}. The message was not sent.`,
|
|
605
|
-
cause: error
|
|
606
|
-
});
|
|
607
|
-
}
|
|
608
|
-
if (bytes.size > 1073741824) throw new SpaceSendFileError({
|
|
609
|
-
code: "space.file.too_large",
|
|
610
|
-
message: `File exceeds the ${formatFileSizeLimit()} limit: ${sourcePath}. The message was not sent.`
|
|
611
|
-
});
|
|
612
|
-
const parsedName = spaceFileNameSchema.safeParse(basename(sourcePath));
|
|
613
|
-
if (!parsedName.success) throw new SpaceSendFileError({
|
|
614
|
-
code: "space.file.invalid_file_name",
|
|
615
|
-
message: `File name is invalid: ${sourcePath}. The message was not sent.`
|
|
616
|
-
});
|
|
617
|
-
return {
|
|
618
|
-
bytes,
|
|
619
|
-
name: parsedName.data,
|
|
620
|
-
mimeType: resolveSpaceFileMimeType({ fileName: parsedName.data })
|
|
621
|
-
};
|
|
622
|
-
}
|
|
623
|
-
function readNodeErrorCode(error) {
|
|
624
|
-
if (!(error && typeof error === "object" && "code" in error)) return null;
|
|
625
|
-
return typeof error.code === "string" ? error.code : null;
|
|
626
|
-
}
|
|
627
|
-
function formatFileSizeLimit() {
|
|
628
|
-
return `${SPACE_FILE_MAX_SIZE_BYTES / (1024 * 1024)} MiB`;
|
|
629
|
-
}
|
|
630
|
-
//#endregion
|
|
631
|
-
//#region src/space/api-json.ts
|
|
632
|
-
function parseJsonResponse(raw) {
|
|
633
|
-
if (!raw.trim()) return null;
|
|
634
|
-
try {
|
|
635
|
-
return JSON.parse(raw);
|
|
636
|
-
} catch {
|
|
637
|
-
return null;
|
|
638
|
-
}
|
|
639
|
-
}
|
|
640
|
-
//#endregion
|
|
641
|
-
//#region src/space/gateway-response.ts
|
|
642
|
-
const FALLBACK_GATEWAY_HTTP_ERROR_CODE = "gateway.http_error";
|
|
643
|
-
var GatewayHttpError = class extends Error {
|
|
644
|
-
code;
|
|
645
|
-
requestId;
|
|
646
|
-
status;
|
|
647
|
-
rawBody;
|
|
648
|
-
upstreamCode;
|
|
649
|
-
constructor(input) {
|
|
650
|
-
super(input.message);
|
|
651
|
-
this.name = "GatewayHttpError";
|
|
652
|
-
this.code = input.code;
|
|
653
|
-
this.requestId = normalizeOptionalText(input.requestId);
|
|
654
|
-
this.status = input.status;
|
|
655
|
-
this.rawBody = input.rawBody;
|
|
656
|
-
this.upstreamCode = normalizeOptionalText(input.upstreamCode);
|
|
657
|
-
}
|
|
658
|
-
};
|
|
659
|
-
async function readGatewayJsonResponse(input) {
|
|
660
|
-
const raw = await input.response.text();
|
|
661
|
-
assertGatewayResponseOk({
|
|
662
|
-
response: input.response,
|
|
663
|
-
raw
|
|
664
|
-
});
|
|
665
|
-
const parsed = input.schema.safeParse(parseJsonResponse(raw));
|
|
666
|
-
if (!parsed.success) throw new Error(input.invalidMessage);
|
|
667
|
-
return parsed.data;
|
|
668
|
-
}
|
|
669
|
-
async function readGatewayTextResponse(input) {
|
|
670
|
-
const raw = await input.response.text();
|
|
671
|
-
assertGatewayResponseOk({
|
|
672
|
-
response: input.response,
|
|
673
|
-
raw
|
|
674
|
-
});
|
|
675
|
-
return raw;
|
|
676
|
-
}
|
|
677
|
-
function assertGatewayResponseOk(input) {
|
|
678
|
-
if (input.response.ok) return;
|
|
679
|
-
throw parseGatewayErrorResponse(input);
|
|
680
|
-
}
|
|
681
|
-
function parseGatewayErrorResponse(input) {
|
|
682
|
-
const payload = parseJsonResponse(input.raw);
|
|
683
|
-
const parsed = gatewayErrorEnvelopeSchema.safeParse(payload);
|
|
684
|
-
const headerRequestId = normalizeOptionalText(input.response.headers.get(OPENMELD_HEADER_REQUEST_ID));
|
|
685
|
-
if (parsed.success) return new GatewayHttpError({
|
|
686
|
-
code: parsed.data.error.code,
|
|
687
|
-
message: parsed.data.error.message,
|
|
688
|
-
requestId: parsed.data.error.requestId || headerRequestId,
|
|
689
|
-
status: input.response.status,
|
|
690
|
-
rawBody: input.raw,
|
|
691
|
-
upstreamCode: parsed.data.error.upstreamCode ?? null
|
|
692
|
-
});
|
|
693
|
-
const looseEnvelope = readLooseGatewayErrorEnvelope(payload);
|
|
694
|
-
if (looseEnvelope) return new GatewayHttpError({
|
|
695
|
-
code: looseEnvelope.code ?? FALLBACK_GATEWAY_HTTP_ERROR_CODE,
|
|
696
|
-
message: looseEnvelope.message ?? `Gateway request failed with HTTP ${input.response.status}.`,
|
|
697
|
-
requestId: looseEnvelope.requestId ?? headerRequestId,
|
|
698
|
-
status: input.response.status,
|
|
699
|
-
rawBody: input.raw,
|
|
700
|
-
upstreamCode: looseEnvelope.upstreamCode
|
|
701
|
-
});
|
|
702
|
-
return new GatewayHttpError({
|
|
703
|
-
code: FALLBACK_GATEWAY_HTTP_ERROR_CODE,
|
|
704
|
-
message: normalizeOptionalText(input.raw) ?? `Gateway request failed with HTTP ${input.response.status}.`,
|
|
705
|
-
requestId: headerRequestId,
|
|
706
|
-
status: input.response.status,
|
|
707
|
-
rawBody: input.raw,
|
|
708
|
-
upstreamCode: null
|
|
709
|
-
});
|
|
710
|
-
}
|
|
711
|
-
function toStructuredGatewayFailure(error) {
|
|
712
|
-
if (error instanceof OpenMeldApiClientHttpError) return {
|
|
713
|
-
code: error.code,
|
|
714
|
-
message: normalizeFailureMessage(error.message),
|
|
715
|
-
requestId: error.requestId,
|
|
716
|
-
status: error.status,
|
|
717
|
-
upstreamCode: error.upstreamCode
|
|
718
|
-
};
|
|
719
|
-
if (error instanceof GatewayHttpError) return {
|
|
720
|
-
code: error.code,
|
|
721
|
-
message: normalizeFailureMessage(error.message),
|
|
722
|
-
requestId: error.requestId,
|
|
723
|
-
status: error.status,
|
|
724
|
-
upstreamCode: error.upstreamCode
|
|
725
|
-
};
|
|
726
|
-
const genericErrorCode = readGenericErrorCode(error);
|
|
727
|
-
if (genericErrorCode) return {
|
|
728
|
-
code: genericErrorCode,
|
|
729
|
-
message: normalizeFailureMessage(error instanceof Error ? error.message : String(error)),
|
|
730
|
-
requestId: null,
|
|
731
|
-
status: null,
|
|
732
|
-
upstreamCode: null
|
|
733
|
-
};
|
|
734
|
-
return {
|
|
735
|
-
code: null,
|
|
736
|
-
message: normalizeFailureMessage(error instanceof Error ? error.message : String(error)),
|
|
737
|
-
requestId: null,
|
|
738
|
-
status: null,
|
|
739
|
-
upstreamCode: null
|
|
740
|
-
};
|
|
741
|
-
}
|
|
742
|
-
function normalizeOptionalText(value) {
|
|
743
|
-
const normalized = String(value ?? "").trim();
|
|
744
|
-
return normalized.length > 0 ? normalized : null;
|
|
745
|
-
}
|
|
746
|
-
function normalizeFailureMessage(value) {
|
|
747
|
-
return normalizeOptionalText(value) ?? "Unknown error.";
|
|
748
|
-
}
|
|
749
|
-
function readGenericErrorCode(value) {
|
|
750
|
-
if (!value || typeof value !== "object" || !("code" in value)) return null;
|
|
751
|
-
return normalizeOptionalText(value.code ?? null);
|
|
752
|
-
}
|
|
753
|
-
function readLooseGatewayErrorEnvelope(value) {
|
|
754
|
-
if (!value || typeof value !== "object") return null;
|
|
755
|
-
const error = value.error;
|
|
756
|
-
if (!error || typeof error !== "object") return null;
|
|
757
|
-
const code = normalizeOptionalText(error.code);
|
|
758
|
-
const message = normalizeOptionalText(error.message);
|
|
759
|
-
const requestId = normalizeOptionalText(error.requestId);
|
|
760
|
-
const upstreamCode = normalizeOptionalText(error.upstreamCode);
|
|
761
|
-
if (!(code || message || requestId || upstreamCode)) return null;
|
|
762
|
-
return {
|
|
763
|
-
code,
|
|
764
|
-
message,
|
|
765
|
-
requestId,
|
|
766
|
-
upstreamCode
|
|
767
|
-
};
|
|
768
|
-
}
|
|
769
|
-
//#endregion
|
|
770
|
-
//#region src/space/space-meta-response.ts
|
|
771
|
-
function parseSpaceMetaPayload(input) {
|
|
772
|
-
try {
|
|
773
|
-
const validation = spaceMetaSchema.safeParse(input.data);
|
|
774
|
-
if (!validation.success) {
|
|
775
|
-
const reason = validation.error.issues[0]?.message ?? "space meta payload does not match schema";
|
|
776
|
-
throw new Error(reason);
|
|
777
|
-
}
|
|
778
|
-
return validation.data;
|
|
779
|
-
} catch (error) {
|
|
780
|
-
const reason = error instanceof Error ? error.message : String(error);
|
|
781
|
-
throw new Error(`${input.operation} received invalid response payload from ${input.endpoint}: ${reason}; raw=${JSON.stringify(input.data)}`);
|
|
782
|
-
}
|
|
783
|
-
}
|
|
784
|
-
function parseSpaceMetaResponse(input) {
|
|
785
|
-
try {
|
|
786
|
-
return parseSpaceMetaPayload({
|
|
787
|
-
data: JSON.parse(input.raw),
|
|
788
|
-
endpoint: input.endpoint,
|
|
789
|
-
operation: input.operation
|
|
790
|
-
});
|
|
791
|
-
} catch (error) {
|
|
792
|
-
const reason = error instanceof Error ? error.message : String(error);
|
|
793
|
-
throw new Error(`${input.operation} received invalid response payload from ${input.endpoint}: ${reason}; raw=${input.raw}`);
|
|
794
|
-
}
|
|
795
|
-
}
|
|
796
|
-
//#endregion
|
|
797
|
-
//#region src/space/meta-api.ts
|
|
798
|
-
async function fetchSpaceMeta(input) {
|
|
799
|
-
const endpoint = toSpaceMetaUrl(input.baseUrl, input.space);
|
|
800
|
-
return parseSpaceMetaResponse({
|
|
801
|
-
raw: await readGatewayTextResponse({ response: await fetchSpaceRequestWithTimeout({
|
|
802
|
-
url: endpoint,
|
|
803
|
-
operation: "space.fetch_meta",
|
|
804
|
-
init: {
|
|
805
|
-
method: "GET",
|
|
806
|
-
headers: await buildOpenMeldRequestContextHeadersWithAuth({
|
|
807
|
-
requestUrl: endpoint,
|
|
808
|
-
requestContext: input.requestContext,
|
|
809
|
-
spacePassword: input.password
|
|
810
|
-
})
|
|
811
|
-
}
|
|
812
|
-
}) }),
|
|
813
|
-
endpoint,
|
|
814
|
-
operation: "fetchSpaceMeta"
|
|
815
|
-
});
|
|
816
|
-
}
|
|
817
|
-
async function updateSpaceMeta(input) {
|
|
818
|
-
const endpoint = toSpaceMetaUrl(input.baseUrl, input.space);
|
|
819
|
-
const headers = await buildOpenMeldRequestContextHeadersWithAuth({
|
|
820
|
-
requestUrl: endpoint,
|
|
821
|
-
requestContext: input.requestContext,
|
|
822
|
-
spacePassword: input.password
|
|
823
|
-
});
|
|
824
|
-
headers["content-type"] = "application/json";
|
|
825
|
-
return parseSpaceMetaResponse({
|
|
826
|
-
raw: await readGatewayTextResponse({ response: await fetchSpaceRequestWithTimeout({
|
|
827
|
-
url: endpoint,
|
|
828
|
-
operation: "space.update_meta",
|
|
829
|
-
init: {
|
|
830
|
-
method: "PATCH",
|
|
831
|
-
headers,
|
|
832
|
-
body: JSON.stringify({
|
|
833
|
-
...input.purpose === void 0 ? {} : { purpose: input.purpose },
|
|
834
|
-
...input.guide === void 0 ? {} : { guide: input.guide }
|
|
835
|
-
})
|
|
836
|
-
}
|
|
837
|
-
}) }),
|
|
838
|
-
endpoint,
|
|
839
|
-
operation: "updateSpaceMeta"
|
|
840
|
-
});
|
|
841
|
-
}
|
|
842
|
-
//#endregion
|
|
843
|
-
export { supersedeDispatchSpaceActionRecordForReconsideration as C, readDispatchSpaceActionRecord as S, DispatchSpaceActionRejectedError as _, GatewayHttpError as a, readDispatchSpaceActionContextForReceiptFromEnv as b, toStructuredGatewayFailure as c, uploadPreparedSpaceFiles as d, createCliSpaceApi as f, DispatchSpaceActionClosedError as g, readDispatchOwnedRuntimeGuard as h, parseSpaceMetaResponse as i, parseJsonResponse as l, buildDispatchOwnedRuntimeEnv as m, updateSpaceMeta as n, readGatewayJsonResponse as o, assertDispatchOwnedRuntimePublicWriteAllowed as p, parseSpaceMetaPayload as r, readGatewayTextResponse as s, fetchSpaceMeta as t, prepareRequestedSpaceSendFiles as u, OPENMELD_SPACE_ACTION_CONTEXT_PATH_ENV as v, writeDispatchSpaceActionRecord as w, readDispatchSpaceActionContextFromEnv as x, createDispatchSpaceActionContext as y };
|
|
844
|
-
|
|
845
|
-
//# sourceMappingURL=meta-api-CEw8eOeN.js.map
|