@zaalipro/dsh-workflows 0.1.0-rc.12

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.
Files changed (229) hide show
  1. package/LICENSE +21 -0
  2. package/NOTICE.md +224 -0
  3. package/README.i18n.yaml +4 -0
  4. package/README.md +111 -0
  5. package/README.zh.md +111 -0
  6. package/cordis.patch.yml +10 -0
  7. package/docs/architecture.i18n.yaml +4 -0
  8. package/docs/architecture.md +177 -0
  9. package/docs/architecture.zh.md +177 -0
  10. package/docs/testing.i18n.yaml +4 -0
  11. package/docs/testing.md +125 -0
  12. package/docs/testing.zh.md +125 -0
  13. package/docs/user-guide.i18n.yaml +4 -0
  14. package/docs/user-guide.md +351 -0
  15. package/docs/user-guide.zh.md +351 -0
  16. package/lib/client-types/WorkflowMemberInspector.d.ts +28 -0
  17. package/lib/client-types/WorkflowMemberInspector.d.ts.map +1 -0
  18. package/lib/client-types/WorkflowMemberInspector.js +181 -0
  19. package/lib/client-types/WorkflowMemberInspector.js.map +1 -0
  20. package/lib/client-types/WorkflowRunPanel.d.ts +43 -0
  21. package/lib/client-types/WorkflowRunPanel.d.ts.map +1 -0
  22. package/lib/client-types/WorkflowRunPanel.js +130 -0
  23. package/lib/client-types/WorkflowRunPanel.js.map +1 -0
  24. package/lib/client-types/WorkflowsDashboard.d.ts +49 -0
  25. package/lib/client-types/WorkflowsDashboard.d.ts.map +1 -0
  26. package/lib/client-types/WorkflowsDashboard.js +942 -0
  27. package/lib/client-types/WorkflowsDashboard.js.map +1 -0
  28. package/lib/client-types/adapter.d.ts +60 -0
  29. package/lib/client-types/adapter.d.ts.map +1 -0
  30. package/lib/client-types/adapter.js +117 -0
  31. package/lib/client-types/adapter.js.map +1 -0
  32. package/lib/client-types/chat-renderer.d.ts +10 -0
  33. package/lib/client-types/chat-renderer.d.ts.map +1 -0
  34. package/lib/client-types/chat-renderer.js +11 -0
  35. package/lib/client-types/chat-renderer.js.map +1 -0
  36. package/lib/client-types/contract.d.ts +210 -0
  37. package/lib/client-types/contract.d.ts.map +1 -0
  38. package/lib/client-types/contract.js +37 -0
  39. package/lib/client-types/contract.js.map +1 -0
  40. package/lib/client-types/controller.d.ts +83 -0
  41. package/lib/client-types/controller.d.ts.map +1 -0
  42. package/lib/client-types/controller.js +705 -0
  43. package/lib/client-types/controller.js.map +1 -0
  44. package/lib/client-types/index.d.ts +19 -0
  45. package/lib/client-types/index.d.ts.map +1 -0
  46. package/lib/client-types/index.js +731 -0
  47. package/lib/client-types/index.js.map +1 -0
  48. package/lib/client-types/locales.d.ts +257 -0
  49. package/lib/client-types/locales.d.ts.map +1 -0
  50. package/lib/client-types/locales.js +270 -0
  51. package/lib/client-types/locales.js.map +1 -0
  52. package/lib/client-types/slot-components.d.ts +38 -0
  53. package/lib/client-types/slot-components.d.ts.map +1 -0
  54. package/lib/client-types/slot-components.js +22 -0
  55. package/lib/client-types/slot-components.js.map +1 -0
  56. package/lib/client-types/store.d.ts +69 -0
  57. package/lib/client-types/store.d.ts.map +1 -0
  58. package/lib/client-types/store.js +135 -0
  59. package/lib/client-types/store.js.map +1 -0
  60. package/lib/client-types/workflow-definition.d.ts +52 -0
  61. package/lib/client-types/workflow-definition.d.ts.map +1 -0
  62. package/lib/client-types/workflow-definition.js +135 -0
  63. package/lib/client-types/workflow-definition.js.map +1 -0
  64. package/lib/client.js +11065 -0
  65. package/lib/client.js.map +1 -0
  66. package/lib/compat-engine/index.js +1926 -0
  67. package/lib/compat-engine/index.js.map +1 -0
  68. package/lib/compat-engine/worker.cjs +1500 -0
  69. package/lib/compat-engine/worker.cjs.map +1 -0
  70. package/lib/typert.host.d.ts +3 -0
  71. package/lib/typert.host.js +1709 -0
  72. package/lib/typert.remote-client.d.ts +57 -0
  73. package/lib/typert.remote-client.js +1662 -0
  74. package/lib/types/commands/aliases.d.ts +4 -0
  75. package/lib/types/commands/aliases.d.ts.map +1 -0
  76. package/lib/types/commands/aliases.js +25 -0
  77. package/lib/types/commands/aliases.js.map +1 -0
  78. package/lib/types/commands/index.d.ts +66 -0
  79. package/lib/types/commands/index.d.ts.map +1 -0
  80. package/lib/types/commands/index.js +550 -0
  81. package/lib/types/commands/index.js.map +1 -0
  82. package/lib/types/commands/parser.d.ts +17 -0
  83. package/lib/types/commands/parser.d.ts.map +1 -0
  84. package/lib/types/commands/parser.js +45 -0
  85. package/lib/types/commands/parser.js.map +1 -0
  86. package/lib/types/config.d.ts +71 -0
  87. package/lib/types/config.d.ts.map +1 -0
  88. package/lib/types/config.js +109 -0
  89. package/lib/types/config.js.map +1 -0
  90. package/lib/types/index.d.ts +41 -0
  91. package/lib/types/index.d.ts.map +1 -0
  92. package/lib/types/index.js +483 -0
  93. package/lib/types/index.js.map +1 -0
  94. package/lib/types/invariant.d.ts +21 -0
  95. package/lib/types/invariant.d.ts.map +1 -0
  96. package/lib/types/invariant.js +85 -0
  97. package/lib/types/invariant.js.map +1 -0
  98. package/lib/types/registry/definition.d.ts +24 -0
  99. package/lib/types/registry/definition.d.ts.map +1 -0
  100. package/lib/types/registry/definition.js +189 -0
  101. package/lib/types/registry/definition.js.map +1 -0
  102. package/lib/types/registry/index.d.ts +100 -0
  103. package/lib/types/registry/index.d.ts.map +1 -0
  104. package/lib/types/registry/index.js +899 -0
  105. package/lib/types/registry/index.js.map +1 -0
  106. package/lib/types/registry/names.d.ts +19 -0
  107. package/lib/types/registry/names.d.ts.map +1 -0
  108. package/lib/types/registry/names.js +69 -0
  109. package/lib/types/registry/names.js.map +1 -0
  110. package/lib/types/registry/remote.d.ts +15 -0
  111. package/lib/types/registry/remote.d.ts.map +1 -0
  112. package/lib/types/registry/remote.js +128 -0
  113. package/lib/types/registry/remote.js.map +1 -0
  114. package/lib/types/registry/roots.d.ts +44 -0
  115. package/lib/types/registry/roots.d.ts.map +1 -0
  116. package/lib/types/registry/roots.js +118 -0
  117. package/lib/types/registry/roots.js.map +1 -0
  118. package/lib/types/registry/types.d.ts +62 -0
  119. package/lib/types/registry/types.d.ts.map +1 -0
  120. package/lib/types/registry/types.js +2 -0
  121. package/lib/types/registry/types.js.map +1 -0
  122. package/lib/types/registry/watchers.d.ts +70 -0
  123. package/lib/types/registry/watchers.d.ts.map +1 -0
  124. package/lib/types/registry/watchers.js +152 -0
  125. package/lib/types/registry/watchers.js.map +1 -0
  126. package/lib/types/remote-events.d.ts +42 -0
  127. package/lib/types/remote-events.d.ts.map +1 -0
  128. package/lib/types/remote-events.js +21 -0
  129. package/lib/types/remote-events.js.map +1 -0
  130. package/lib/types/run-recorder.d.ts +44 -0
  131. package/lib/types/run-recorder.d.ts.map +1 -0
  132. package/lib/types/run-recorder.js +356 -0
  133. package/lib/types/run-recorder.js.map +1 -0
  134. package/lib/types/supervisor/canned-validate.d.ts +25 -0
  135. package/lib/types/supervisor/canned-validate.d.ts.map +1 -0
  136. package/lib/types/supervisor/canned-validate.js +122 -0
  137. package/lib/types/supervisor/canned-validate.js.map +1 -0
  138. package/lib/types/supervisor/completion-notice.d.ts +49 -0
  139. package/lib/types/supervisor/completion-notice.d.ts.map +1 -0
  140. package/lib/types/supervisor/completion-notice.js +281 -0
  141. package/lib/types/supervisor/completion-notice.js.map +1 -0
  142. package/lib/types/supervisor/cursors.d.ts +68 -0
  143. package/lib/types/supervisor/cursors.d.ts.map +1 -0
  144. package/lib/types/supervisor/cursors.js +158 -0
  145. package/lib/types/supervisor/cursors.js.map +1 -0
  146. package/lib/types/supervisor/engine-compat.d.ts +48 -0
  147. package/lib/types/supervisor/engine-compat.d.ts.map +1 -0
  148. package/lib/types/supervisor/engine-compat.js +116 -0
  149. package/lib/types/supervisor/engine-compat.js.map +1 -0
  150. package/lib/types/supervisor/index.d.ts +183 -0
  151. package/lib/types/supervisor/index.d.ts.map +1 -0
  152. package/lib/types/supervisor/index.js +2040 -0
  153. package/lib/types/supervisor/index.js.map +1 -0
  154. package/lib/types/supervisor/parallel-compat.d.ts +36 -0
  155. package/lib/types/supervisor/parallel-compat.d.ts.map +1 -0
  156. package/lib/types/supervisor/parallel-compat.js +180 -0
  157. package/lib/types/supervisor/parallel-compat.js.map +1 -0
  158. package/lib/types/supervisor/remote.d.ts +25 -0
  159. package/lib/types/supervisor/remote.d.ts.map +1 -0
  160. package/lib/types/supervisor/remote.js +478 -0
  161. package/lib/types/supervisor/remote.js.map +1 -0
  162. package/lib/types/supervisor/storage/bounded-file.d.ts +41 -0
  163. package/lib/types/supervisor/storage/bounded-file.d.ts.map +1 -0
  164. package/lib/types/supervisor/storage/bounded-file.js +186 -0
  165. package/lib/types/supervisor/storage/bounded-file.js.map +1 -0
  166. package/lib/types/supervisor/storage/details-codec.d.ts +14 -0
  167. package/lib/types/supervisor/storage/details-codec.d.ts.map +1 -0
  168. package/lib/types/supervisor/storage/details-codec.js +359 -0
  169. package/lib/types/supervisor/storage/details-codec.js.map +1 -0
  170. package/lib/types/supervisor/storage/index.d.ts +26 -0
  171. package/lib/types/supervisor/storage/index.d.ts.map +1 -0
  172. package/lib/types/supervisor/storage/index.js +100 -0
  173. package/lib/types/supervisor/storage/index.js.map +1 -0
  174. package/lib/types/supervisor/storage/lease.d.ts +34 -0
  175. package/lib/types/supervisor/storage/lease.d.ts.map +1 -0
  176. package/lib/types/supervisor/storage/lease.js +289 -0
  177. package/lib/types/supervisor/storage/lease.js.map +1 -0
  178. package/lib/types/supervisor/storage/manifest-codec.d.ts +10 -0
  179. package/lib/types/supervisor/storage/manifest-codec.d.ts.map +1 -0
  180. package/lib/types/supervisor/storage/manifest-codec.js +335 -0
  181. package/lib/types/supervisor/storage/manifest-codec.js.map +1 -0
  182. package/lib/types/supervisor/storage/manifest-store.d.ts +99 -0
  183. package/lib/types/supervisor/storage/manifest-store.d.ts.map +1 -0
  184. package/lib/types/supervisor/storage/manifest-store.js +1606 -0
  185. package/lib/types/supervisor/storage/manifest-store.js.map +1 -0
  186. package/lib/types/supervisor/storage/manifest-types.d.ts +269 -0
  187. package/lib/types/supervisor/storage/manifest-types.d.ts.map +1 -0
  188. package/lib/types/supervisor/storage/manifest-types.js +2 -0
  189. package/lib/types/supervisor/storage/manifest-types.js.map +1 -0
  190. package/lib/types/supervisor/storage/private-root.d.ts +143 -0
  191. package/lib/types/supervisor/storage/private-root.d.ts.map +1 -0
  192. package/lib/types/supervisor/storage/private-root.js +860 -0
  193. package/lib/types/supervisor/storage/private-root.js.map +1 -0
  194. package/lib/types/supervisor/storage/recovery.d.ts +14 -0
  195. package/lib/types/supervisor/storage/recovery.d.ts.map +1 -0
  196. package/lib/types/supervisor/storage/recovery.js +126 -0
  197. package/lib/types/supervisor/storage/recovery.js.map +1 -0
  198. package/lib/types/supervisor/storage/run-files.d.ts +67 -0
  199. package/lib/types/supervisor/storage/run-files.d.ts.map +1 -0
  200. package/lib/types/supervisor/storage/run-files.js +346 -0
  201. package/lib/types/supervisor/storage/run-files.js.map +1 -0
  202. package/lib/types/supervisor/types.d.ts +295 -0
  203. package/lib/types/supervisor/types.d.ts.map +1 -0
  204. package/lib/types/supervisor/types.js +3 -0
  205. package/lib/types/supervisor/types.js.map +1 -0
  206. package/lib/types/supervisor/value-view.d.ts +19 -0
  207. package/lib/types/supervisor/value-view.d.ts.map +1 -0
  208. package/lib/types/supervisor/value-view.js +183 -0
  209. package/lib/types/supervisor/value-view.js.map +1 -0
  210. package/lib/types/tool/index.d.ts +86 -0
  211. package/lib/types/tool/index.d.ts.map +1 -0
  212. package/lib/types/tool/index.js +810 -0
  213. package/lib/types/tool/index.js.map +1 -0
  214. package/lib/types/tool/schema.d.ts +158 -0
  215. package/lib/types/tool/schema.d.ts.map +1 -0
  216. package/lib/types/tool/schema.js +137 -0
  217. package/lib/types/tool/schema.js.map +1 -0
  218. package/lib/types/types.d.ts +9 -0
  219. package/lib/types/types.d.ts.map +1 -0
  220. package/lib/types/types.js +3 -0
  221. package/lib/types/types.js.map +1 -0
  222. package/lib/types/user-questions.d.ts +9 -0
  223. package/lib/types/user-questions.d.ts.map +1 -0
  224. package/lib/types/user-questions.js +91 -0
  225. package/lib/types/user-questions.js.map +1 -0
  226. package/package.json +291 -0
  227. package/skills/create-workflow/SKILL.md +166 -0
  228. package/vendor/workflow-engine/LICENSE +21 -0
  229. package/vendor/workflow-engine/README.md +1 -0
@@ -0,0 +1,100 @@
1
+ import { openWorkflowStorageAnchor, acquireWorkflowStorageLease } from './lease.js';
2
+ import { closeWorkflowStorageLayout, initializePrivateLayout } from './private-root.js';
3
+ import { FileWorkflowRunStore } from './manifest-store.js';
4
+ import { recoverWorkflowStorage } from './recovery.js';
5
+ export * from './lease.js';
6
+ export * from './private-root.js';
7
+ export * from './bounded-file.js';
8
+ export * from './manifest-types.js';
9
+ export * from './manifest-codec.js';
10
+ export * from './details-codec.js';
11
+ export * from './manifest-store.js';
12
+ export * from './run-files.js';
13
+ export * from './recovery.js';
14
+ /** Bootstrap the leased storage root and eagerly recover retained state. */
15
+ export async function openWorkflowStorage(config, hostFileSystem) {
16
+ const anchor = await openWorkflowStorageAnchor({ runsRoot: config.runsRoot });
17
+ let lease;
18
+ let layout;
19
+ let store;
20
+ try {
21
+ lease = await acquireWorkflowStorageLease(anchor);
22
+ layout = await initializePrivateLayout(anchor, lease, hostFileSystem);
23
+ store = new FileWorkflowRunStore({
24
+ // The anchor canonicalizes harmless OS alias components (notably
25
+ // macOS /var and /tmp). Every later store operation must use that same
26
+ // pinned spelling rather than returning to the caller's lexical path.
27
+ runsRoot: anchor.root,
28
+ maxManifestBytes: config.maxManifestBytes,
29
+ maxRunDetailsBytes: config.maxRunDetailsBytes,
30
+ maxRunStoreBytes: config.maxRunStoreBytes,
31
+ maxRetainedRunsPerSession: config.maxRetainedRunsPerSession,
32
+ maxWorkflowNamesPerSession: config.maxWorkflowNamesPerSession,
33
+ maxMembersPerRun: config.maxMembersPerRun,
34
+ maxRecoveryEntries: config.maxRecoveryEntries,
35
+ maxTerminalResultBytes: config.maxTerminalResultBytes,
36
+ memberOutcomeMaxBytes: config.memberOutcomeMaxBytes,
37
+ maxLogLines: config.maxLogLines,
38
+ maxLogLineBytes: config.maxLogLineBytes,
39
+ }, lease, layout);
40
+ // Recovery receives the retained descriptor layout, not the lexical root
41
+ // string. In Host mode this is the security boundary: inventory and all
42
+ // subsequent reconciliation stay relative to the capabilities opened
43
+ // after the lifetime lease was acquired. The recovered Interrupted
44
+ // heads must remain available to the supervisor: a later store.initialize()
45
+ // is idempotent and must not report an empty rewrite.
46
+ const recovered = await recoverWorkflowStorage(layout, store, { maxRecoveryEntries: config.maxRecoveryEntries });
47
+ let disposed = false;
48
+ let disposePromise;
49
+ return {
50
+ anchor,
51
+ lease,
52
+ layout,
53
+ store,
54
+ recovered: recovered.runs,
55
+ dispose() {
56
+ disposePromise ??= (async () => {
57
+ if (disposed)
58
+ return;
59
+ disposed = true;
60
+ let first;
61
+ try {
62
+ await store.dispose();
63
+ }
64
+ catch (error) {
65
+ first = error;
66
+ }
67
+ try {
68
+ await closeWorkflowStorageLayout(layout);
69
+ }
70
+ catch (error) {
71
+ first ??= error;
72
+ }
73
+ try {
74
+ await lease.release();
75
+ }
76
+ catch (error) {
77
+ first ??= error;
78
+ }
79
+ if (first !== undefined)
80
+ throw first;
81
+ })();
82
+ return disposePromise;
83
+ },
84
+ };
85
+ }
86
+ catch (error) {
87
+ // Bootstrap can fail after any of the four layout descriptors or the
88
+ // store has been created. Close each layer before releasing the lease;
89
+ // never leave a partial layout holding descriptors into the next boot.
90
+ await store?.dispose().catch(() => undefined);
91
+ if (layout !== undefined)
92
+ await closeWorkflowStorageLayout(layout).catch(() => undefined);
93
+ if (lease !== undefined)
94
+ await lease.release().catch(() => undefined);
95
+ else
96
+ await anchor.close().catch(() => undefined);
97
+ throw error;
98
+ }
99
+ }
100
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/supervisor/storage/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,yBAAyB,EAAE,2BAA2B,EAAyD,MAAM,YAAY,CAAA;AAC1I,OAAO,EAAE,0BAA0B,EAA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A;gBACJ,OAAO,cAAc,CAAA;YACvB,CAAC;SACF,CAAA;IACH,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,qEAAqE;QACrE,wEAAwE;QACxE,uEAAuE;QACvE,MAAM,KAAK,EAAE,OAAO,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAA;QAC7C,IAAI,MAAM,KAAK,SAAS;YAAE,MAAM,0BAA0B,CAAC,MAAM,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAA;QACzF,IAAI,KAAK,KAAK,SAAS;YAAE,MAAM,KAAK,CAAC,OAAO,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAA;;YAChE,MAAM,MAAM,CAAC,KAAK,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAA;QAChD,MAAM,KAAK,CAAA;IACb,CAAC;AACH,CAAC"}
@@ -0,0 +1,34 @@
1
+ import type { FileHandle } from 'node:fs/promises';
2
+ export interface WorkflowStorageAnchor {
3
+ readonly root: string;
4
+ readonly anchorPath: string;
5
+ readonly file: FileHandle;
6
+ readonly rootFile: FileHandle;
7
+ readonly rootIdentity: {
8
+ readonly dev: number;
9
+ readonly ino: number;
10
+ };
11
+ readonly identity: {
12
+ readonly dev: number;
13
+ readonly ino: number;
14
+ };
15
+ assertCurrent(signal?: AbortSignal): Promise<void>;
16
+ close(): Promise<void>;
17
+ }
18
+ export interface WorkflowStorageLease {
19
+ readonly anchor: WorkflowStorageAnchor;
20
+ assertCurrent(signal?: AbortSignal): Promise<void>;
21
+ release(): Promise<void>;
22
+ }
23
+ export interface WorkflowStorageLockAdapter {
24
+ readonly tryLock: (fd: number) => boolean;
25
+ readonly unlock: (fd: number) => void;
26
+ }
27
+ /** Open and identity-pin the owner-only runs root and permanent lock anchor. */
28
+ export declare function openWorkflowStorageAnchor(options: {
29
+ readonly runsRoot: string;
30
+ readonly signal?: AbortSignal;
31
+ }): Promise<WorkflowStorageAnchor>;
32
+ /** Acquire the native cooperating-process lifetime lease. */
33
+ export declare function acquireWorkflowStorageLease(anchor: WorkflowStorageAnchor, signal?: AbortSignal, adapter?: WorkflowStorageLockAdapter): Promise<WorkflowStorageLease>;
34
+ //# sourceMappingURL=lease.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lease.d.ts","sourceRoot":"","sources":["../../../../src/supervisor/storage/lease.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAIlD,MAAM,WAAW,qBAAqB;IACpC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAA;IAC3B,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAA;IACzB,QAAQ,CAAC,QAAQ,EAAE,UAAU,CAAA;IAC7B,QAAQ,CAAC,YAAY,EAAE;QAAE,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAA;KAAE,CAAA;IACrE,QAAQ,CAAC,QAAQ,EAAE;QAAE,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAA;KAAE,CAAA;IACjE,aAAa,CAAC,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IAClD,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAA;CACvB;AAED,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,MAAM,EAAE,qBAAqB,CAAA;IACtC,aAAa,CAAC,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IAClD,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,CAAA;CACzB;AAwBD,MAAM,WAAW,0BAA0B;IACzC,QAAQ,CAAC,OAAO,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,OAAO,CAAA;IACzC,QAAQ,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAA;CACtC;AAmED,gFAAgF;AAChF,wBAAsB,yBAAyB,CAAC,OAAO,EAAE;IAAE,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,CAAA;CAAE,GAAG,OAAO,CAAC,qBAAqB,CAAC,CA0FrJ;AAgBD,6DAA6D;AAC7D,wBAAsB,2BAA2B,CAC/C,MAAM,EAAE,qBAAqB,EAC7B,MAAM,CAAC,EAAE,WAAW,EACpB,OAAO,CAAC,EAAE,0BAA0B,GACnC,OAAO,CAAC,oBAAoB,CAAC,CAoD/B"}
@@ -0,0 +1,289 @@
1
+ import { constants } from 'node:fs';
2
+ import { lstat, mkdir, open, realpath } from 'node:fs/promises';
3
+ import { dirname, isAbsolute, join, parse, sep } from 'node:path';
4
+ import { BoundedFileError } from './bounded-file.js';
5
+ const O_DIRECTORY = constants.O_DIRECTORY ?? 0;
6
+ const O_NOFOLLOW = constants.O_NOFOLLOW;
7
+ function unsupported() {
8
+ return new BoundedFileError(`safe workflow storage is unavailable on ${process.platform}`, 'WORKFLOW_STORAGE_UNSUPPORTED');
9
+ }
10
+ const UNSUPPORTED_LOCK_ERRNOS = new Set(['ENOSYS', 'ENOTSUP', 'EOPNOTSUPP', 'ENOLCK']);
11
+ function errorErrno(error) {
12
+ if (typeof error !== 'object' || error === null || !('code' in error))
13
+ return undefined;
14
+ const code = error.code;
15
+ return typeof code === 'string' ? code : undefined;
16
+ }
17
+ /** Missing addon/platform lock primitives stay UNSUPPORTED. Unexpected I/O
18
+ * during tryLock is a compromised root, not another live owner. */
19
+ function isUnsupportedLockError(error) {
20
+ const code = errorErrno(error);
21
+ return code !== undefined && UNSUPPORTED_LOCK_ERRNOS.has(code);
22
+ }
23
+ function unsafe(root, detail, cause) {
24
+ return new BoundedFileError(`workflow storage path "${root}" is unsafe: ${detail}`, 'WORKFLOW_STORAGE_UNSAFE', cause === undefined ? undefined : { cause });
25
+ }
26
+ function sameIdentity(a, b) {
27
+ return Number(a.dev) === Number(b.dev) && Number(a.ino) === Number(b.ino);
28
+ }
29
+ function ownerOk(info) {
30
+ return typeof process.getuid !== 'function' || info.uid === process.getuid();
31
+ }
32
+ function assertRootInfo(info, root) {
33
+ if (!info.isDirectory() || !ownerOk(info) || (info.mode & 0o777) !== 0o700)
34
+ throw unsafe(root, 'runs root must be an owner-only 0700 directory');
35
+ }
36
+ function assertAnchorInfo(info, root) {
37
+ if (!info.isFile() || info.nlink !== 1 || !ownerOk(info) || (info.mode & 0o777) !== 0o600)
38
+ throw unsafe(root, 'lock anchor must be an owner-only 0600 regular file');
39
+ }
40
+ /** Resolve ordinary system alias links (for example macOS /var ->
41
+ * /private/var) while rejecting a link at the runs-root component itself.
42
+ * The returned path is the spelling whose ancestors can be opened one
43
+ * component at a time and identity-pinned. */
44
+ async function canonicalStoragePath(path, root) {
45
+ if (!isAbsolute(path))
46
+ throw unsafe(root, 'runs root must be absolute');
47
+ const parsed = parse(path);
48
+ // macOS exposes a small set of documented system aliases. They are not a
49
+ // caller-controlled workspace boundary; arbitrary symlink ancestors remain
50
+ // unsafe and are rejected before realpath is allowed to follow them.
51
+ const allowedAliases = process.platform === 'darwin' ? new Set(['/var', '/tmp', '/etc']) : new Set();
52
+ let lexical = parsed.root;
53
+ for (const part of path.slice(parsed.root.length).split(sep).filter(Boolean)) {
54
+ lexical = join(lexical, part);
55
+ try {
56
+ const entry = await lstat(lexical);
57
+ if (entry.isSymbolicLink() && !allowedAliases.has(lexical))
58
+ throw unsafe(root, `ancestor "${lexical}" is a symbolic link`);
59
+ }
60
+ catch (error) {
61
+ if (error.code === 'ENOENT')
62
+ break;
63
+ throw error;
64
+ }
65
+ }
66
+ let current = path;
67
+ const missing = [];
68
+ while (true) {
69
+ try {
70
+ const info = await lstat(current);
71
+ if (info.isSymbolicLink() && missing.length === 0)
72
+ throw unsafe(root, 'runs root is a symbolic link');
73
+ if (!info.isDirectory() && !info.isSymbolicLink() && missing.length > 0)
74
+ throw unsafe(root, `ancestor "${current}" is not a directory`);
75
+ const resolved = await realpath(current);
76
+ return missing.length === 0 ? resolved : [resolved, ...missing].join(sep);
77
+ }
78
+ catch (error) {
79
+ if (error.code !== 'ENOENT')
80
+ throw error;
81
+ const parent = dirname(current);
82
+ if (parent === current || current === parsed.root)
83
+ throw unsafe(root, 'runs root has no accessible ancestor', error);
84
+ missing.unshift(current.slice(parent.length + (parent.endsWith(sep) ? 0 : 1)));
85
+ current = parent;
86
+ }
87
+ }
88
+ }
89
+ /** Open and identity-pin the owner-only runs root and permanent lock anchor. */
90
+ export async function openWorkflowStorageAnchor(options) {
91
+ const requestedRoot = options.runsRoot;
92
+ options.signal?.throwIfAborted();
93
+ if (process.platform === 'win32' || O_NOFOLLOW === undefined || O_NOFOLLOW === 0 || O_DIRECTORY === 0)
94
+ throw unsupported();
95
+ let rootFile;
96
+ let anchorFile;
97
+ try {
98
+ const root = await canonicalStoragePath(requestedRoot, requestedRoot);
99
+ let rootInfo;
100
+ try {
101
+ rootInfo = await lstat(root);
102
+ if (rootInfo.isSymbolicLink())
103
+ throw unsafe(root, 'runs root is a symbolic link');
104
+ assertRootInfo(rootInfo, root);
105
+ }
106
+ catch (error) {
107
+ if (error.code !== 'ENOENT')
108
+ throw error;
109
+ // The caller resolves/creates dshHome before storage bootstrap. Creating
110
+ // only this final component avoids an implicit path walk through missing
111
+ // ancestors after they were checked above.
112
+ try {
113
+ await mkdir(root, { mode: 0o700 });
114
+ }
115
+ catch (mkdirError) {
116
+ if (mkdirError.code !== 'EEXIST')
117
+ throw mkdirError;
118
+ }
119
+ rootInfo = await lstat(root);
120
+ assertRootInfo(rootInfo, root);
121
+ }
122
+ rootFile = await open(root, constants.O_RDONLY | O_DIRECTORY | O_NOFOLLOW);
123
+ const retainedRoot = await rootFile.stat();
124
+ assertRootInfo(retainedRoot, root);
125
+ if (!sameIdentity(retainedRoot, rootInfo))
126
+ throw unsafe(root, 'runs root identity changed while opening');
127
+ options.signal?.throwIfAborted();
128
+ const anchorPath = `${root}${root.endsWith(sep) ? '' : sep}.workflow-storage.lock`;
129
+ anchorFile = await open(anchorPath, constants.O_CREAT | constants.O_RDWR | O_NOFOLLOW, 0o600);
130
+ const anchorInfo = await anchorFile.stat();
131
+ assertAnchorInfo(anchorInfo, root);
132
+ const currentAnchor = await lstat(anchorPath);
133
+ if (!sameIdentity(anchorInfo, currentAnchor))
134
+ throw unsafe(root, 'lock anchor identity changed while opening');
135
+ const rootIdentity = { dev: Number(retainedRoot.dev), ino: Number(retainedRoot.ino) };
136
+ const anchorIdentity = { dev: Number(anchorInfo.dev), ino: Number(anchorInfo.ino) };
137
+ const assertCurrent = async (signal) => {
138
+ signal?.throwIfAborted();
139
+ try {
140
+ const [retained, currentRoot, retainedAnchor, currentAnchorNow] = await Promise.all([
141
+ rootFile.stat(),
142
+ lstat(root),
143
+ anchorFile.stat(),
144
+ lstat(anchorPath),
145
+ ]);
146
+ signal?.throwIfAborted();
147
+ assertRootInfo(retained, root);
148
+ assertRootInfo(currentRoot, root);
149
+ assertAnchorInfo(retainedAnchor, root);
150
+ assertAnchorInfo(currentAnchorNow, root);
151
+ if (!sameIdentity(retained, currentRoot)
152
+ || Number(retained.dev) !== rootIdentity.dev
153
+ || Number(retained.ino) !== rootIdentity.ino
154
+ || !sameIdentity(retainedAnchor, currentAnchorNow)
155
+ || Number(retainedAnchor.dev) !== anchorIdentity.dev
156
+ || Number(retainedAnchor.ino) !== anchorIdentity.ino) {
157
+ throw unsafe(root, 'root or lock anchor identity changed');
158
+ }
159
+ }
160
+ catch (error) {
161
+ if (error instanceof BoundedFileError || signal?.aborted)
162
+ throw error;
163
+ throw unsafe(root, 'root or lock anchor could not be revalidated', error);
164
+ }
165
+ };
166
+ let closePromise;
167
+ return {
168
+ root,
169
+ anchorPath,
170
+ file: anchorFile,
171
+ rootFile,
172
+ rootIdentity,
173
+ identity: anchorIdentity,
174
+ assertCurrent,
175
+ close() {
176
+ closePromise ??= (async () => {
177
+ let first;
178
+ try {
179
+ await rootFile.close();
180
+ }
181
+ catch (error) {
182
+ first = error;
183
+ }
184
+ try {
185
+ await anchorFile.close();
186
+ }
187
+ catch (error) {
188
+ first ??= error;
189
+ }
190
+ if (first !== undefined)
191
+ throw first;
192
+ })();
193
+ return closePromise;
194
+ },
195
+ };
196
+ }
197
+ catch (error) {
198
+ await anchorFile?.close().catch(() => undefined);
199
+ await rootFile?.close().catch(() => undefined);
200
+ if (error instanceof BoundedFileError)
201
+ throw error;
202
+ throw unsafe(requestedRoot, error instanceof Error ? error.message : String(error), error);
203
+ }
204
+ }
205
+ async function lockFunctions() {
206
+ try {
207
+ const module = await import('fs-native-extensions');
208
+ // The addon exposes named exports and a CommonJS-compatible default object.
209
+ const candidate = module;
210
+ return {
211
+ tryLock: module.tryLock ?? candidate.default?.tryLock,
212
+ unlock: module.unlock ?? candidate.default?.unlock,
213
+ };
214
+ }
215
+ catch {
216
+ return {};
217
+ }
218
+ }
219
+ /** Acquire the native cooperating-process lifetime lease. */
220
+ export async function acquireWorkflowStorageLease(anchor, signal, adapter) {
221
+ signal?.throwIfAborted();
222
+ await anchor.assertCurrent(signal);
223
+ const locks = adapter ?? await lockFunctions();
224
+ const tryLock = locks.tryLock;
225
+ const unlock = locks.unlock;
226
+ if (tryLock === undefined || unlock === undefined) {
227
+ await anchor.close().catch(() => undefined);
228
+ throw unsupported();
229
+ }
230
+ let locked = false;
231
+ try {
232
+ locked = tryLock(anchor.file.fd);
233
+ }
234
+ catch (error) {
235
+ await anchor.close().catch(() => undefined);
236
+ if (isUnsupportedLockError(error)) {
237
+ throw new BoundedFileError(`safe workflow storage is unavailable on ${process.platform}`, 'WORKFLOW_STORAGE_UNSUPPORTED', { cause: error });
238
+ }
239
+ throw unsafe(anchor.root, error instanceof Error ? error.message : String(error), error);
240
+ }
241
+ if (!locked) {
242
+ await anchor.close().catch(() => undefined);
243
+ throw new BoundedFileError('workflow storage root is already owned by another live process', 'WORKFLOW_STORAGE_OWNED');
244
+ }
245
+ try {
246
+ signal?.throwIfAborted();
247
+ }
248
+ catch (error) {
249
+ try {
250
+ unlock(anchor.file.fd);
251
+ }
252
+ catch { /* closing the handle also drops the lock */ }
253
+ await anchor.close().catch(() => undefined);
254
+ throw error;
255
+ }
256
+ let releaseStarted = false;
257
+ let releasePromise;
258
+ return {
259
+ anchor,
260
+ assertCurrent(signal) {
261
+ if (releaseStarted) {
262
+ return Promise.reject(new BoundedFileError('workflow storage lease is released', 'WORKFLOW_STORAGE_UNSAFE'));
263
+ }
264
+ return anchor.assertCurrent(signal);
265
+ },
266
+ release() {
267
+ releasePromise ??= (async () => {
268
+ releaseStarted = true;
269
+ let first;
270
+ try {
271
+ unlock(anchor.file.fd);
272
+ }
273
+ catch (error) {
274
+ first = error;
275
+ }
276
+ try {
277
+ await anchor.close();
278
+ }
279
+ catch (error) {
280
+ first ??= error;
281
+ }
282
+ if (first !== undefined)
283
+ throw first;
284
+ })();
285
+ return releasePromise;
286
+ },
287
+ };
288
+ }
289
+ //# sourceMappingURL=lease.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lease.js","sourceRoot":"","sources":["../../../../src/supervisor/storage/lease.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA;AAEnC,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AAE/D,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,WAAW,CAAA;AACjE,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAA;AAmBpD,MAAM,WAAW,GAAI,SAAoC,CAAC,WAAW,IAAI,CAAC,CAAA;AAC1E,MAAM,UAAU,GAAI,SAAoC,CAAC,UAAU,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QAAC,MAAM,CAAC,CAAC,4CAA4C,CAAC,CAAC;QACrF,MAAM,MAAM,CAAC,KAAK,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAA;QAC3C,MAAM,KAAK,CAAA;IACb,CAAC;IACD,IAAI,cAAc,GAAG,KAAK,CAAA;IAC1B,IAAI,cAAyC,CAAA;IAC7C,OAAO;QACL,MAAM;QACN,aAAa,CAAC,MAAoB;YAChC,IAAI,cAAc,EAAE,CAAC;gBACnB,OAAO,OAAO,CAAC,MAAM,CAAC,IAAI,gBAAgB,CAAC,oCAAoC,EAAE,yBAAyB,CAAC,CAAC,CAAA;YAC9G,CAAC;YACD,OAAO,MAAM,CAAC,aAAa,CAAC,MAAM,CAAC,CAAA;QACrC,CAAC;QACD,OAAO;YACL,cAAc,KAAK,CAAC,KAAK,IAAI,EAAE;gBAC7B,cAAc,GAAG,IAAI,CAAA;gBACrB,IAAI,KAAc,CAAA;gBAClB,IAAI,CAAC;oBAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;gBAAC,CAAC;gBAAC,OAAO,KAAK,EAAE,CAAC;oBAAC,KAAK,GAAG,KAAK,CAAA;gBAAC,CAAC;gBAC9D,IAAI,CAAC;oBAAC,MAAM,MAAM,CAAC,KAAK,EAAE,CAAA;gBAAC,CAAC;gBAAC,OAAO,KAAK,EAAE,CAAC;oBAAC,KAAK,KAAK,KAAK,CAAA;gBAAC,CAAC;gBAC9D,IAAI,KAAK,KAAK,SAAS;oBAAE,MAAM,KAAK,CAAA;YACtC,CAAC,CAAC,EAAE,CAAA;YACJ,OAAO,cAAc,CAAA;QACvB,CAAC;KACF,CAAA;AACH,CAAC"}
@@ -0,0 +1,10 @@
1
+ import type { WorkflowSessionManifest } from './manifest-types.js';
2
+ /** Parse a display handle back to its session-local launch ordinal.
3
+ * The unnumbered first handle is `name` itself (ordinal 1), including kebab
4
+ * names that already end in digits such as `gpt-4` or `review-2`. */
5
+ export declare function displayOrdinal(name: string, displayName: string): number;
6
+ /** Decode a bounded canonical version-2 Session manifest. */
7
+ export declare function decodeWorkflowSessionManifest(input: Uint8Array | string, file: string, maxBytes: number): WorkflowSessionManifest;
8
+ /** Encode a canonical version-2 Session manifest. */
9
+ export declare function encodeWorkflowSessionManifest(value: WorkflowSessionManifest, maxBytes: number): Uint8Array;
10
+ //# sourceMappingURL=manifest-codec.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"manifest-codec.d.ts","sourceRoot":"","sources":["../../../../src/supervisor/storage/manifest-codec.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAIV,uBAAuB,EACxB,MAAM,qBAAqB,CAAA;AAsB5B;;qEAEqE;AACrE,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,MAAM,CAexE;AAwND,6DAA6D;AAC7D,wBAAgB,6BAA6B,CAAC,KAAK,EAAE,UAAU,GAAG,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,uBAAuB,CAYjI;AAQD,qDAAqD;AACrD,wBAAgB,6BAA6B,CAAC,KAAK,EAAE,uBAAuB,EAAE,QAAQ,EAAE,MAAM,GAAG,UAAU,CAM1G"}