spexcode 0.6.7 → 0.6.8

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 (205) hide show
  1. package/README.md +12 -7
  2. package/node_modules/@spexcode/session-application/dist/index.d.ts +17 -0
  3. package/node_modules/@spexcode/session-application/dist/index.js +35 -0
  4. package/node_modules/@spexcode/session-application/dist/migration.d.ts +51 -0
  5. package/node_modules/@spexcode/session-application/dist/migration.js +694 -0
  6. package/node_modules/@spexcode/session-application/dist/production.d.ts +109 -0
  7. package/node_modules/@spexcode/session-application/dist/production.js +438 -0
  8. package/node_modules/@spexcode/session-application/dist/schema.d.ts +2 -0
  9. package/node_modules/@spexcode/session-application/dist/schema.js +39 -0
  10. package/node_modules/@spexcode/session-application/package.json +29 -0
  11. package/node_modules/@spexcode/session-events/dist/errors.d.ts +6 -0
  12. package/node_modules/@spexcode/session-events/dist/errors.js +11 -0
  13. package/node_modules/@spexcode/session-events/dist/index.d.ts +46 -0
  14. package/node_modules/@spexcode/session-events/dist/index.js +245 -0
  15. package/node_modules/@spexcode/session-events/dist/schema.d.ts +3 -0
  16. package/node_modules/@spexcode/session-events/dist/schema.js +44 -0
  17. package/node_modules/@spexcode/session-events/package.json +24 -0
  18. package/node_modules/@spexcode/session-protocol/dist/canonical.d.ts +36 -0
  19. package/node_modules/@spexcode/session-protocol/dist/canonical.js +139 -0
  20. package/node_modules/@spexcode/session-protocol/dist/engine.d.ts +22 -0
  21. package/node_modules/@spexcode/session-protocol/dist/engine.js +478 -0
  22. package/node_modules/@spexcode/session-protocol/dist/errors.d.ts +8 -0
  23. package/node_modules/@spexcode/session-protocol/dist/errors.js +39 -0
  24. package/node_modules/@spexcode/session-protocol/dist/index.d.ts +60 -0
  25. package/node_modules/@spexcode/session-protocol/dist/index.js +4 -0
  26. package/node_modules/@spexcode/session-protocol/dist/schema.d.ts +36 -0
  27. package/node_modules/@spexcode/session-protocol/dist/schema.js +192 -0
  28. package/node_modules/@spexcode/{session-core → session-protocol}/package.json +4 -8
  29. package/node_modules/@spexcode/session-runtime/dist/errors.d.ts +6 -0
  30. package/node_modules/@spexcode/session-runtime/dist/errors.js +11 -0
  31. package/node_modules/@spexcode/session-runtime/dist/index.d.ts +33 -0
  32. package/node_modules/@spexcode/session-runtime/dist/index.js +193 -0
  33. package/node_modules/@spexcode/session-runtime/dist/schema.d.ts +2 -0
  34. package/node_modules/@spexcode/session-runtime/dist/schema.js +37 -0
  35. package/node_modules/@spexcode/session-runtime/package.json +24 -0
  36. package/node_modules/@spexcode/session-selflaunch/bin/spex-session.mjs +4 -0
  37. package/node_modules/@spexcode/session-selflaunch/dist/cli.d.ts +25 -0
  38. package/node_modules/@spexcode/session-selflaunch/dist/cli.js +156 -0
  39. package/node_modules/@spexcode/session-selflaunch/dist/index.d.ts +28 -0
  40. package/node_modules/@spexcode/session-selflaunch/dist/index.js +25 -0
  41. package/node_modules/@spexcode/session-selflaunch/dist/locality.d.ts +20 -0
  42. package/node_modules/@spexcode/session-selflaunch/dist/locality.js +83 -0
  43. package/node_modules/@spexcode/session-selflaunch/dist/path.d.ts +13 -0
  44. package/node_modules/@spexcode/session-selflaunch/dist/path.js +45 -0
  45. package/node_modules/@spexcode/session-selflaunch/package.json +35 -0
  46. package/node_modules/@spexcode/session-topology/dist/errors.d.ts +6 -0
  47. package/node_modules/@spexcode/session-topology/dist/errors.js +11 -0
  48. package/node_modules/@spexcode/session-topology/dist/index.d.ts +24 -0
  49. package/node_modules/@spexcode/session-topology/dist/index.js +173 -0
  50. package/node_modules/@spexcode/session-topology/dist/schema.d.ts +3 -0
  51. package/node_modules/@spexcode/session-topology/dist/schema.js +27 -0
  52. package/node_modules/@spexcode/session-topology/package.json +24 -0
  53. package/node_modules/@spexcode/spec-cli/bin/spex.mjs +56 -19
  54. package/node_modules/@spexcode/spec-cli/dist/cli.js +102 -59
  55. package/node_modules/@spexcode/spec-cli/dist/client.d.ts +1 -3
  56. package/node_modules/@spexcode/spec-cli/dist/client.js +49 -30
  57. package/node_modules/@spexcode/spec-cli/dist/codex-runtime-generations.d.ts +11 -0
  58. package/node_modules/@spexcode/spec-cli/dist/codex-runtime-generations.js +46 -9
  59. package/node_modules/@spexcode/spec-cli/dist/delivery-lock.d.ts +2 -0
  60. package/node_modules/@spexcode/spec-cli/dist/delivery-lock.js +58 -0
  61. package/node_modules/@spexcode/spec-cli/dist/doctor.js +53 -11
  62. package/node_modules/@spexcode/spec-cli/dist/execution-trace.d.ts +1 -0
  63. package/node_modules/@spexcode/spec-cli/dist/execution-trace.js +2 -2
  64. package/node_modules/@spexcode/spec-cli/dist/gateway-hub.js +2 -1
  65. package/node_modules/@spexcode/spec-cli/dist/gateway.js +6 -3
  66. package/node_modules/@spexcode/spec-cli/dist/graphCache.js +32 -2
  67. package/node_modules/@spexcode/spec-cli/dist/graphSnapshot.js +57 -2
  68. package/node_modules/@spexcode/spec-cli/dist/graphStream.d.ts +2 -0
  69. package/node_modules/@spexcode/spec-cli/dist/graphStream.js +83 -3
  70. package/node_modules/@spexcode/spec-cli/dist/guide.js +20 -7
  71. package/node_modules/@spexcode/spec-cli/dist/harness-select.js +16 -3
  72. package/node_modules/@spexcode/spec-cli/dist/harness.d.ts +15 -3
  73. package/node_modules/@spexcode/spec-cli/dist/harness.js +331 -50
  74. package/node_modules/@spexcode/spec-cli/dist/help.js +11 -8
  75. package/node_modules/@spexcode/spec-cli/dist/hook-prompts.js +8 -0
  76. package/node_modules/@spexcode/spec-cli/dist/host-resources.js +29 -8
  77. package/node_modules/@spexcode/spec-cli/dist/host.d.ts +7 -0
  78. package/node_modules/@spexcode/spec-cli/dist/host.js +93 -0
  79. package/node_modules/@spexcode/spec-cli/dist/index.js +324 -22
  80. package/node_modules/@spexcode/spec-cli/dist/init.js +1 -1
  81. package/node_modules/@spexcode/spec-cli/dist/lint.js +70 -35
  82. package/node_modules/@spexcode/spec-cli/dist/listen.d.ts +3 -2
  83. package/node_modules/@spexcode/spec-cli/dist/listen.js +14 -2
  84. package/node_modules/@spexcode/spec-cli/dist/machine-peer.js +1 -1
  85. package/node_modules/@spexcode/spec-cli/dist/materialize.d.ts +2 -2
  86. package/node_modules/@spexcode/spec-cli/dist/materialize.js +176 -35
  87. package/node_modules/@spexcode/spec-cli/dist/pty-bridge.js +14 -14
  88. package/node_modules/@spexcode/spec-cli/dist/reviews.js +12 -7
  89. package/node_modules/@spexcode/spec-cli/dist/runtime-ownership.d.ts +11 -0
  90. package/node_modules/@spexcode/spec-cli/dist/runtime-ownership.js +79 -1
  91. package/node_modules/@spexcode/spec-cli/dist/session-application.d.ts +23 -0
  92. package/node_modules/@spexcode/spec-cli/dist/session-application.js +189 -0
  93. package/node_modules/@spexcode/spec-cli/dist/session-declarations.js +13 -1
  94. package/node_modules/@spexcode/spec-cli/dist/session-files.d.ts +6 -0
  95. package/node_modules/@spexcode/spec-cli/dist/session-files.js +13 -1
  96. package/node_modules/@spexcode/spec-cli/dist/session-follow.js +39 -22
  97. package/node_modules/@spexcode/{session-core/dist/record-lock.d.ts → spec-cli/dist/session-record-lock.d.ts} +0 -4
  98. package/node_modules/@spexcode/spec-cli/dist/session-record-lock.js +94 -0
  99. package/node_modules/@spexcode/spec-cli/dist/session-runtime-adapter.d.ts +44 -0
  100. package/node_modules/@spexcode/spec-cli/dist/session-runtime-adapter.js +37 -0
  101. package/node_modules/@spexcode/spec-cli/dist/session-timeline.d.ts +25 -2
  102. package/node_modules/@spexcode/spec-cli/dist/session-timeline.js +68 -11
  103. package/node_modules/@spexcode/spec-cli/dist/session-web.js +4 -4
  104. package/node_modules/@spexcode/spec-cli/dist/sessions.d.ts +108 -15
  105. package/node_modules/@spexcode/spec-cli/dist/sessions.js +1465 -744
  106. package/node_modules/@spexcode/spec-cli/dist/source-list.d.ts +13 -0
  107. package/node_modules/@spexcode/spec-cli/dist/source-list.js +99 -0
  108. package/node_modules/@spexcode/spec-cli/dist/source-read.d.ts +16 -0
  109. package/node_modules/@spexcode/spec-cli/dist/source-read.js +84 -0
  110. package/node_modules/@spexcode/spec-cli/dist/spec-attachments.d.ts +7 -0
  111. package/node_modules/@spexcode/spec-cli/dist/spec-attachments.js +89 -0
  112. package/node_modules/@spexcode/spec-cli/dist/spec-body-edit.d.ts +23 -0
  113. package/node_modules/@spexcode/spec-cli/dist/spec-body-edit.js +138 -0
  114. package/node_modules/@spexcode/spec-cli/dist/supervise.js +15 -6
  115. package/node_modules/@spexcode/spec-cli/dist/transcript-reader.d.ts +36 -0
  116. package/node_modules/@spexcode/spec-cli/dist/transcript-reader.js +251 -0
  117. package/node_modules/@spexcode/spec-cli/hooks/dispatch.sh +19 -31
  118. package/node_modules/@spexcode/spec-cli/hooks/harness.sh +6 -6
  119. package/node_modules/@spexcode/spec-cli/package.json +6 -6
  120. package/node_modules/@spexcode/spec-cli/templates/hooks/post-checkout +4 -2
  121. package/node_modules/@spexcode/spec-cli/templates/hooks/post-merge +2 -1
  122. package/node_modules/@spexcode/spec-cli/templates/hooks/pre-commit +5 -3
  123. package/node_modules/@spexcode/spec-cli/templates/hooks/reference-transaction +5 -3
  124. package/node_modules/@spexcode/spec-cli/templates/spec/project/.plugins/commands/spec.md +2 -7
  125. package/node_modules/@spexcode/spec-cli/templates/spec/project/.plugins/core/idle/idle.sh +4 -10
  126. package/node_modules/@spexcode/spec-cli/templates/spec/project/.plugins/core/idle/spec.md +1 -1
  127. package/node_modules/@spexcode/spec-cli/templates/spec/project/.plugins/core/mark-active/mark-active.sh +22 -24
  128. package/node_modules/@spexcode/spec-cli/templates/spec/project/.plugins/core/mark-active/spec.md +10 -2
  129. package/node_modules/@spexcode/spec-cli/templates/spec/project/.plugins/core/session-fail/fail.sh +8 -7
  130. package/node_modules/@spexcode/spec-cli/templates/spec/project/.plugins/core/session-fail/spec.md +3 -1
  131. package/node_modules/@spexcode/spec-cli/templates/spec/project/.plugins/core/session-listen/session-listen.sh +133 -0
  132. package/node_modules/@spexcode/spec-cli/templates/spec/project/.plugins/core/session-listen/spec.md +36 -0
  133. package/node_modules/@spexcode/spec-cli/templates/spec/project/.plugins/core/spec.md +2 -0
  134. package/node_modules/@spexcode/spec-cli/templates/spec/project/.plugins/core/stop-gate/spec.md +1 -1
  135. package/node_modules/@spexcode/spec-cli/templates/spec/project/.plugins/core/stop-gate/stop-gate.sh +17 -20
  136. package/node_modules/@spexcode/spec-cli/templates/spec/project/.plugins/skills/merge/spec.md +33 -0
  137. package/node_modules/@spexcode/spec-cli/templates/spec/project/.plugins/skills/spec.md +2 -6
  138. package/node_modules/@spexcode/spec-cli/templates/spec/project/.plugins/spec.md +7 -0
  139. package/node_modules/@spexcode/spec-core/dist/anchors.d.ts +13 -2
  140. package/node_modules/@spexcode/spec-core/dist/anchors.js +311 -15
  141. package/node_modules/@spexcode/spec-core/dist/git.d.ts +4 -0
  142. package/node_modules/@spexcode/spec-core/dist/git.js +9 -9
  143. package/node_modules/@spexcode/spec-core/dist/layout.d.ts +12 -0
  144. package/node_modules/@spexcode/spec-core/dist/layout.js +4 -2
  145. package/node_modules/@spexcode/spec-core/dist/resilience.d.ts +1 -0
  146. package/node_modules/@spexcode/spec-core/dist/resilience.js +8 -0
  147. package/node_modules/@spexcode/spec-core/dist/review/reviewFilters.d.ts +1 -0
  148. package/node_modules/@spexcode/spec-core/dist/review/reviewFilters.js +7 -3
  149. package/node_modules/@spexcode/spec-core/dist/review/reviewQuery.d.ts +1 -0
  150. package/node_modules/@spexcode/spec-core/dist/review/reviewQuery.js +4 -0
  151. package/node_modules/@spexcode/spec-core/dist/specs.d.ts +2 -0
  152. package/node_modules/@spexcode/spec-core/dist/specs.js +30 -0
  153. package/node_modules/@spexcode/spec-core/package.json +4 -1
  154. package/node_modules/@spexcode/spec-eval/dist/cli.js +1 -1
  155. package/node_modules/@spexcode/spec-eval/dist/evaltab.d.ts +1 -0
  156. package/node_modules/@spexcode/spec-eval/dist/evaltab.js +6 -1
  157. package/node_modules/@spexcode/spec-eval/dist/freshness.d.ts +1 -1
  158. package/node_modules/@spexcode/spec-eval/dist/freshness.js +12 -12
  159. package/node_modules/@spexcode/spec-eval/dist/host.d.ts +2 -1
  160. package/node_modules/@spexcode/spec-eval/dist/sessioneval.d.ts +2 -1
  161. package/node_modules/@spexcode/spec-eval/dist/sessioneval.js +20 -3
  162. package/node_modules/@spexcode/spec-eval/package.json +2 -2
  163. package/node_modules/@spexcode/spec-forge/package.json +2 -2
  164. package/node_modules/@vscode/tree-sitter-wasm/LICENSE +21 -0
  165. package/node_modules/@vscode/tree-sitter-wasm/README.md +36 -0
  166. package/node_modules/@vscode/tree-sitter-wasm/SECURITY.md +41 -0
  167. package/node_modules/@vscode/tree-sitter-wasm/cgmanifest.json +16 -0
  168. package/node_modules/@vscode/tree-sitter-wasm/package.json +42 -0
  169. package/node_modules/@vscode/tree-sitter-wasm/wasm/tree-sitter-bash.wasm +0 -0
  170. package/node_modules/@vscode/tree-sitter-wasm/wasm/tree-sitter-c-sharp.wasm +0 -0
  171. package/node_modules/@vscode/tree-sitter-wasm/wasm/tree-sitter-cpp.wasm +0 -0
  172. package/node_modules/@vscode/tree-sitter-wasm/wasm/tree-sitter-css.wasm +0 -0
  173. package/node_modules/@vscode/tree-sitter-wasm/wasm/tree-sitter-go.wasm +0 -0
  174. package/node_modules/@vscode/tree-sitter-wasm/wasm/tree-sitter-ini.wasm +0 -0
  175. package/node_modules/@vscode/tree-sitter-wasm/wasm/tree-sitter-java.wasm +0 -0
  176. package/node_modules/@vscode/tree-sitter-wasm/wasm/tree-sitter-javascript.wasm +0 -0
  177. package/node_modules/@vscode/tree-sitter-wasm/wasm/tree-sitter-php.wasm +0 -0
  178. package/node_modules/@vscode/tree-sitter-wasm/wasm/tree-sitter-powershell.wasm +0 -0
  179. package/node_modules/@vscode/tree-sitter-wasm/wasm/tree-sitter-python.wasm +0 -0
  180. package/node_modules/@vscode/tree-sitter-wasm/wasm/tree-sitter-regex.wasm +0 -0
  181. package/node_modules/@vscode/tree-sitter-wasm/wasm/tree-sitter-ruby.wasm +0 -0
  182. package/node_modules/@vscode/tree-sitter-wasm/wasm/tree-sitter-rust.wasm +0 -0
  183. package/node_modules/@vscode/tree-sitter-wasm/wasm/tree-sitter-tsx.wasm +0 -0
  184. package/node_modules/@vscode/tree-sitter-wasm/wasm/tree-sitter-typescript.wasm +0 -0
  185. package/node_modules/@vscode/tree-sitter-wasm/wasm/tree-sitter.js +4075 -0
  186. package/node_modules/@vscode/tree-sitter-wasm/wasm/tree-sitter.wasm +0 -0
  187. package/node_modules/@vscode/tree-sitter-wasm/wasm/web-tree-sitter.d.ts +1027 -0
  188. package/package.json +9 -3
  189. package/node_modules/@spexcode/session-core/dist/delivery-queue.d.ts +0 -24
  190. package/node_modules/@spexcode/session-core/dist/delivery-queue.js +0 -206
  191. package/node_modules/@spexcode/session-core/dist/index.d.ts +0 -5
  192. package/node_modules/@spexcode/session-core/dist/index.js +0 -5
  193. package/node_modules/@spexcode/session-core/dist/internal.d.ts +0 -3
  194. package/node_modules/@spexcode/session-core/dist/internal.js +0 -3
  195. package/node_modules/@spexcode/session-core/dist/message.d.ts +0 -22
  196. package/node_modules/@spexcode/session-core/dist/message.js +0 -53
  197. package/node_modules/@spexcode/session-core/dist/record-lock.js +0 -152
  198. package/node_modules/@spexcode/session-core/dist/runtime-session.d.ts +0 -62
  199. package/node_modules/@spexcode/session-core/dist/runtime-session.js +0 -326
  200. package/node_modules/@spexcode/session-core/dist/session-cursors.d.ts +0 -14
  201. package/node_modules/@spexcode/session-core/dist/session-cursors.js +0 -82
  202. package/node_modules/@spexcode/session-core/dist/session-timeline.d.ts +0 -47
  203. package/node_modules/@spexcode/session-core/dist/session-timeline.js +0 -216
  204. package/node_modules/@spexcode/spec-cli/hooks/compat/mark-active-0.5.2-eef1.fixture +0 -53
  205. package/node_modules/@spexcode/spec-cli/hooks/compat/mark-active-sed-v0.fixture +0 -46
@@ -0,0 +1,44 @@
1
+ export interface GovernedRuntimeIdentity {
2
+ protocolSessionId: string;
3
+ harnessId: string;
4
+ harnessSessionId: string;
5
+ nativeStartToken: string;
6
+ metadata?: Record<string, unknown>;
7
+ }
8
+ export interface GovernedRuntimeBindingOptions {
9
+ expectedGeneration?: number;
10
+ now?: number;
11
+ }
12
+ export interface GovernedRuntimeBinding {
13
+ namespace: string;
14
+ protocolSessionId: string;
15
+ runtimeKind: string;
16
+ nativeSessionId: string;
17
+ nativeStartToken: string;
18
+ bindingGeneration: number;
19
+ status: 'bound' | 'unbound';
20
+ boundAtMs: number;
21
+ unboundAtMs: number | null;
22
+ metadata: Record<string, unknown>;
23
+ }
24
+ export interface GovernedProtocolTransactionHost<Transaction = unknown> {
25
+ withTransaction<T>(body: (transaction: Transaction) => T): T;
26
+ }
27
+ export interface GovernedRuntimeBindingStore<Transaction = unknown> {
28
+ bind(transaction: Transaction, protocolSessionId: string, identity: {
29
+ namespace: string;
30
+ runtimeKind: string;
31
+ nativeSessionId: string;
32
+ nativeStartToken: string;
33
+ metadata?: Record<string, unknown>;
34
+ }, options?: GovernedRuntimeBindingOptions): GovernedRuntimeBinding;
35
+ resolve(namespace: string, protocolSessionId: string, transaction?: Transaction): GovernedRuntimeBinding | null;
36
+ unbind(transaction: Transaction, namespace: string, protocolSessionId: string, options?: GovernedRuntimeBindingOptions): GovernedRuntimeBinding;
37
+ }
38
+ /**
39
+ * Bind an identity whose storage and native start token were already established by Spex composition.
40
+ * Database placement, locality, launch, and legacy record publication deliberately remain outside this seam.
41
+ */
42
+ export declare function bindSpexGovernedRuntime<Transaction>(protocol: GovernedProtocolTransactionHost<Transaction>, bindings: GovernedRuntimeBindingStore<Transaction>, identity: GovernedRuntimeIdentity, options?: GovernedRuntimeBindingOptions): GovernedRuntimeBinding;
43
+ export declare function resolveSpexGovernedRuntime<Transaction>(bindings: GovernedRuntimeBindingStore<Transaction>, protocolSessionId: string, transaction?: Transaction): GovernedRuntimeBinding | null;
44
+ export declare function unbindSpexGovernedRuntime<Transaction>(protocol: GovernedProtocolTransactionHost<Transaction>, bindings: GovernedRuntimeBindingStore<Transaction>, protocolSessionId: string, options?: GovernedRuntimeBindingOptions): GovernedRuntimeBinding;
@@ -0,0 +1,37 @@
1
+ const SPEX_GOVERNED_NAMESPACE = 'spex-governed';
2
+ function requireNonempty(value, field) {
3
+ if (typeof value !== 'string' || !value.trim()) {
4
+ throw new TypeError(`Spex governed runtime binding requires ${field}`);
5
+ }
6
+ }
7
+ /**
8
+ * Bind an identity whose storage and native start token were already established by Spex composition.
9
+ * Database placement, locality, launch, and legacy record publication deliberately remain outside this seam.
10
+ */
11
+ export function bindSpexGovernedRuntime(protocol, bindings, identity, options = {}) {
12
+ requireNonempty(identity.protocolSessionId, 'protocolSessionId');
13
+ requireNonempty(identity.harnessId, 'harnessId');
14
+ requireNonempty(identity.harnessSessionId, 'harnessSessionId');
15
+ requireNonempty(identity.nativeStartToken, 'nativeStartToken');
16
+ if (!protocol || typeof protocol.withTransaction !== 'function') {
17
+ throw new TypeError('Spex governed runtime binding requires an open protocol transaction host');
18
+ }
19
+ if (!bindings || typeof bindings.bind !== 'function') {
20
+ throw new TypeError('Spex governed runtime binding requires an open runtime binding store');
21
+ }
22
+ return protocol.withTransaction(transaction => bindings.bind(transaction, identity.protocolSessionId, {
23
+ namespace: SPEX_GOVERNED_NAMESPACE,
24
+ runtimeKind: identity.harnessId,
25
+ nativeSessionId: identity.harnessSessionId,
26
+ nativeStartToken: identity.nativeStartToken,
27
+ metadata: identity.metadata,
28
+ }, options));
29
+ }
30
+ export function resolveSpexGovernedRuntime(bindings, protocolSessionId, transaction) {
31
+ requireNonempty(protocolSessionId, 'protocolSessionId');
32
+ return bindings.resolve(SPEX_GOVERNED_NAMESPACE, protocolSessionId, transaction);
33
+ }
34
+ export function unbindSpexGovernedRuntime(protocol, bindings, protocolSessionId, options = {}) {
35
+ requireNonempty(protocolSessionId, 'protocolSessionId');
36
+ return protocol.withTransaction(transaction => bindings.unbind(transaction, SPEX_GOVERNED_NAMESPACE, protocolSessionId, options));
37
+ }
@@ -1,6 +1,28 @@
1
1
  import { type SessionLifecycle, type SessionProposal } from '@spexcode/spec-core';
2
- import { type TimelineEvent } from '@spexcode/session-core';
3
- export * from '@spexcode/session-core';
2
+ export type TimelineEvent = {
3
+ ts: string;
4
+ kind: 'status';
5
+ status: SessionLifecycle;
6
+ proposal: SessionProposal | null;
7
+ note: string | null;
8
+ display?: string;
9
+ } | {
10
+ ts: string;
11
+ kind: 'sent';
12
+ mid: string;
13
+ text: string;
14
+ from: string | null;
15
+ replyVia?: 'note';
16
+ };
17
+ export declare const timelineEvents: (id: string) => TimelineEvent[];
18
+ export declare const timelineStamp: (id: string) => string | null;
19
+ export declare const timelineTail: (id: string, limit?: number) => TimelineEvent[];
20
+ export declare const lastHumanSendVia: (id: string) => "note" | null;
21
+ export declare const currentHumanTurn: (id: string) => {
22
+ token: string;
23
+ acceptedAt: string;
24
+ } | null;
25
+ export declare const recordStatus: (id: string, status: SessionLifecycle, proposal: SessionProposal | null, note: string | null) => void;
4
26
  type DisplayWord = 'working' | 'idle' | 'review' | 'done' | 'close-pending' | 'parked' | 'error' | 'asking' | 'queued';
5
27
  export declare const timelineDisplay: (event: {
6
28
  status: SessionLifecycle;
@@ -9,3 +31,4 @@ export declare const timelineDisplay: (event: {
9
31
  export declare function readTimeline(id: string, limit?: number): {
10
32
  events: TimelineEvent[];
11
33
  } | null;
34
+ export {};
@@ -1,20 +1,77 @@
1
1
  import { readAliasedRawRecord } from '@spexcode/spec-core';
2
- import { timelineTail } from '@spexcode/session-core';
3
- export * from '@spexcode/session-core';
2
+ import { decodeEventJson } from '@spexcode/session-events';
3
+ import { MIGRATED_MESSAGE_EVENT, MIGRATED_STATE_EVENT } from '@spexcode/session-application';
4
+ import { configuredSessionApplicationIfCutover } from './session-application.js';
5
+ // The timeline is a history: events read in occurrence order (sequence breaks ties). Migrated legacy history
6
+ // lands after the live events in sequence but before them in time, and it is shown where it happened.
7
+ const canonicalSessionId = (id) => readAliasedRawRecord(id)?.session_id ?? id;
8
+ const canonicalTimelineEvents = (id) => {
9
+ const canonicalId = canonicalSessionId(id);
10
+ const application = configuredSessionApplicationIfCutover();
11
+ if (!application || !application.readState(canonicalId))
12
+ return null;
13
+ const ordered = [...application.readEvents(canonicalId)].sort((a, b) => a.occurredAtMs - b.occurredAtMs || a.eventSeq - b.eventSeq);
14
+ return ordered.flatMap((event) => {
15
+ const decoded = decodeEventJson(event.payload);
16
+ if (!decoded || typeof decoded !== 'object' || Array.isArray(decoded))
17
+ return [];
18
+ const payload = decoded;
19
+ if (event.type === 'session.state.changed.v1' || event.type === MIGRATED_STATE_EVENT)
20
+ return [{
21
+ ts: new Date(event.occurredAtMs).toISOString(),
22
+ kind: 'status',
23
+ status: String(payload.status),
24
+ proposal: payload.proposal === null || payload.proposal === undefined ? null : String(payload.proposal),
25
+ note: payload.note === null || payload.note === undefined ? null : String(payload.note),
26
+ }];
27
+ if (event.type === 'session.message.sent.v1' || event.type === MIGRATED_MESSAGE_EVENT)
28
+ return [{
29
+ ts: new Date(event.occurredAtMs).toISOString(),
30
+ kind: 'sent',
31
+ mid: String(payload.messageId),
32
+ text: String(payload.text),
33
+ from: payload.from === null || payload.from === undefined ? null : String(payload.from),
34
+ ...(payload.replyVia === 'note' ? { replyVia: 'note' } : {}),
35
+ }];
36
+ return [];
37
+ });
38
+ };
39
+ export const timelineEvents = (id) => canonicalTimelineEvents(id) ?? [];
40
+ export const timelineStamp = (id) => {
41
+ const canonicalId = canonicalSessionId(id);
42
+ const application = configuredSessionApplicationIfCutover();
43
+ if (application?.readState(canonicalId)) {
44
+ const events = application.readEvents(canonicalId);
45
+ return events.length === 0 ? null : String(events.at(-1).eventSeq);
46
+ }
47
+ return null;
48
+ };
49
+ export const timelineTail = (id, limit = 500) => timelineEvents(id).slice(-Math.max(1, limit));
50
+ export const lastHumanSendVia = (id) => {
51
+ const events = timelineEvents(id);
52
+ const sent = [...events].reverse().find((event) => event.kind === 'sent' && event.from === null);
53
+ return sent?.replyVia ?? null;
54
+ };
55
+ export const currentHumanTurn = (id) => {
56
+ const sent = [...timelineEvents(id)].reverse().find((event) => event.kind === 'sent' && event.from === null);
57
+ return sent ? { token: sent.mid, acceptedAt: sent.ts } : null;
58
+ };
59
+ export const recordStatus = (id, status, proposal, note) => {
60
+ const application = configuredSessionApplicationIfCutover();
61
+ if (!application?.readState(id))
62
+ throw new Error(`cannot record status for unknown canonical session ${id}`);
63
+ application.transitionSession(id, { status, proposal, note, reason: 'cli-status' });
64
+ };
4
65
  const PROPOSAL_DISPLAY = { merge: 'review', nothing: 'done', close: 'close-pending' };
5
66
  export const timelineDisplay = (event) => event.status === 'awaiting' ? (PROPOSAL_DISPLAY[event.proposal ?? 'nothing'] ?? 'done')
6
67
  : event.status === 'active' ? 'working' : event.status;
7
68
  // The HTTP projection remains a SpexCode concern: it resolves aliases, hides unmanaged records, and adds the
8
69
  // board's display vocabulary. The package beneath it only reads the durable file protocol.
9
70
  export function readTimeline(id, limit = 500) {
10
- let raw;
11
- try {
12
- raw = readAliasedRawRecord(id);
71
+ const application = configuredSessionApplicationIfCutover();
72
+ const canonicalId = canonicalSessionId(id);
73
+ if (application && application.readState(canonicalId)) {
74
+ return { events: canonicalTimelineEvents(id).slice(-Math.max(1, limit)).map((event) => event.kind === 'status' ? { ...event, display: timelineDisplay(event) } : event) };
13
75
  }
14
- catch {
15
- return null;
16
- }
17
- if (!raw || !raw.governed)
18
- return null;
19
- return { events: timelineTail(raw.session_id, limit).map((event) => event.kind === 'status' ? { ...event, display: timelineDisplay(event) } : event) };
76
+ return null;
20
77
  }
@@ -1,7 +1,7 @@
1
1
  import { createHash } from 'node:crypto';
2
2
  import { readFileSync, renameSync, unlinkSync, writeFileSync } from 'node:fs';
3
3
  import { join } from 'node:path';
4
- import { readRecordEntry, sessionArtifactPath, sessionStoreDir } from '@spexcode/spec-core';
4
+ import { readRecordEntry, sessionArtifactPath, sessionRecordPath } from '@spexcode/spec-core';
5
5
  import { projectRuntimeRoot } from '@spexcode/spec-core';
6
6
  export class SessionWebError extends Error {
7
7
  status;
@@ -15,8 +15,8 @@ const webPath = (id, projectRoot) => projectRoot
15
15
  ? join(projectRuntimeRoot(join(projectRoot, '.git')), 'sessions', id, 'web.json')
16
16
  : sessionArtifactPath(id, 'web.json');
17
17
  const recordPath = (id, projectRoot) => projectRoot
18
- ? join(projectRuntimeRoot(join(projectRoot, '.git')), 'sessions', id, 'session.json')
19
- : join(sessionStoreDir(id), 'session.json');
18
+ ? join(projectRuntimeRoot(join(projectRoot, '.git')), 'sessions', id, 'runtime.json')
19
+ : sessionRecordPath(id);
20
20
  function validSessionId(id) {
21
21
  return /^[A-Za-z0-9][A-Za-z0-9._-]*$/.test(id);
22
22
  }
@@ -104,7 +104,7 @@ export function listSessionWebs(id, projectRoot) {
104
104
  requireSession(id, projectRoot);
105
105
  return readSessionWebs(id, projectRoot);
106
106
  }
107
- // Session projections already hold a parsed record; re-checking session.json here would make an in-memory
107
+ // Session projections already hold a parsed runtime envelope; re-checking it here would make an in-memory
108
108
  // projection depend on the public route's existence guard. The route-facing list keeps that guard above.
109
109
  export function readSessionWebs(id, projectRoot) {
110
110
  return readWebs(id, projectRoot).map(toWeb);
@@ -1,15 +1,18 @@
1
1
  import { type ReviewDiffFile } from '@spexcode/spec-core';
2
2
  import { type ConfigPreset, type SpecLite } from '@spexcode/spec-core';
3
- import { type Harness, type TurnFailure, type DispatchResult, type PaneProbe, type ProcTable } from './harness.js';
3
+ import { type AdapterLoadedReferenceState, type Harness, type TurnFailure, type DispatchResult, type PaneProbe, type ProcTable } from './harness.js';
4
4
  import { envSessionId, type RawRecord, type SessionLifecycle, type SessionProposal } from '@spexcode/spec-core';
5
5
  import { type SessionWeb } from './session-web.js';
6
- import { type MessageIdempotency } from '@spexcode/session-core';
6
+ import { type ProductionSessionApplication } from '@spexcode/session-application';
7
7
  export declare const TMUX_SOCK: string;
8
+ /** Start the one process-local serial reaper and resume any crash leftovers. */
9
+ export declare function startWorktreeTrashReaper(): void;
8
10
  export type { DispatchResult };
9
11
  export type Lifecycle = SessionLifecycle;
10
12
  export type Proposal = SessionProposal;
11
13
  export type DisplayStatus = 'working' | 'idle' | 'offline' | 'starting' | 'review' | 'done' | 'close-pending' | 'parked' | 'error' | 'asking' | 'queued' | 'unknown' | 'corrupt' | 'retired';
12
14
  export type Liveness = 'online' | 'starting' | 'offline' | 'unknown';
15
+ export declare function displayStatusForProposal(proposal: Proposal | null | undefined): DisplayStatus;
13
16
  export type Session = {
14
17
  id: string;
15
18
  node: string | null;
@@ -34,6 +37,7 @@ export type Session = {
34
37
  liveness: Liveness;
35
38
  note: string | null;
36
39
  archived: boolean;
40
+ closedAt: string | null;
37
41
  archiveHazard?: string | null;
38
42
  prompt: string | null;
39
43
  promptPreview: string | null;
@@ -50,11 +54,6 @@ export type CloseSource = {
50
54
  } | {
51
55
  kind: 'user';
52
56
  };
53
- export type SessionClosure = {
54
- id: string;
55
- closedAt: string;
56
- };
57
- export declare function findSessionClosure(selector: string): SessionClosure | null;
58
57
  export declare const HEADLINE_PREVIEW_COLUMNS = 60;
59
58
  export declare const deriveLabel: (r: {
60
59
  name?: string | null;
@@ -104,20 +103,34 @@ export type SessRec = {
104
103
  createdAt: number;
105
104
  harness: string;
106
105
  harnessSessionId: string | null;
106
+ runtimeStartToken: string | null;
107
107
  stopped: boolean;
108
108
  archived: boolean;
109
+ closedAt: string | null;
109
110
  coldProof?: string | null;
110
111
  adapterRecovery?: string | null;
111
112
  launcher: string | null;
112
113
  launchCmd: string | null;
113
114
  launchOwner: string | null;
115
+ launchReadinessStartedAt?: number | null;
114
116
  createRequestId?: string | null;
115
117
  createPayloadHash?: string | null;
116
118
  zcodeChildSessionIds?: string[];
117
119
  base?: string | null;
120
+ forkCommit?: string | null;
121
+ diffComments?: DiffComment[];
118
122
  launchReadinessPending?: LaunchReadinessPending | null;
119
123
  };
120
- type LaunchReadinessOriginal = Pick<SessRec, 'status' | 'proposal' | 'note' | 'stopped' | 'archived' | 'coldProof' | 'adapterRecovery'>;
124
+ export type DiffComment = {
125
+ id: string;
126
+ filePath: string;
127
+ lineStart: number;
128
+ lineEnd: number;
129
+ body: string;
130
+ diffIdentity: string;
131
+ sentAt: string | null;
132
+ };
133
+ type LaunchReadinessOriginal = Pick<SessRec, 'status' | 'proposal' | 'note' | 'stopped' | 'archived' | 'closedAt' | 'coldProof' | 'adapterRecovery'>;
121
134
  type LaunchReadinessPending = {
122
135
  version: 1;
123
136
  startedAt: number;
@@ -136,7 +149,6 @@ export declare class SessionRecordUnusable extends Error {
136
149
  constructor(code: 'corrupt' | 'retired', session: string, message: string);
137
150
  }
138
151
  export declare function withSessionRecordLockSync<T>(id: string, body: () => T): T;
139
- export declare function withSessionInputLock<T>(id: string, body: () => T): T | null;
140
152
  export declare function fromRaw(raw: RawRecord & {
141
153
  launch_owner?: string;
142
154
  }): SessRec;
@@ -185,6 +197,13 @@ export type ReviewIdentity = {
185
197
  label: string;
186
198
  };
187
199
  export declare function reviewIdentity(id: string): ReviewIdentity | null;
200
+ export type SessionHookState = {
201
+ governed: boolean;
202
+ status: Lifecycle;
203
+ proposal: Proposal | null;
204
+ note: string | null;
205
+ };
206
+ export declare function sessionHookState(id: string): SessionHookState | null;
188
207
  export declare function toSession(rec: SessRec, status: DisplayStatus, lv: Liveness, activity?: string | null): Session;
189
208
  export type ZCodeChildSessionLink = {
190
209
  sessionId: string;
@@ -195,6 +214,17 @@ export declare function linkZCodeChildSession(sessionId: string, childSessionId:
195
214
  export declare function renameSession(id: string, name: string): Promise<boolean>;
196
215
  export declare function setSessionSort(id: string, key: number | null): Promise<boolean>;
197
216
  export declare function sessionPrompt(id: string): Promise<string | null>;
217
+ export type ArchiveSessionIndexRow = {
218
+ id: string;
219
+ title: string;
220
+ label: string;
221
+ closedAt: string | null;
222
+ node: string | null;
223
+ };
224
+ export type ArchiveSessionIndexProbe = {
225
+ promptReads?: number;
226
+ };
227
+ export declare function listArchivedSessionIndex(probe?: ArchiveSessionIndexProbe): Promise<ArchiveSessionIndexRow[]>;
198
228
  export declare function listSessions(includeArchived?: boolean): Promise<Session[]>;
199
229
  export type ApiBaseSource = 'flag' | 'worker-env' | 'record' | 'env-fallback' | 'default';
200
230
  export type ApiBaseInfo = {
@@ -238,7 +268,22 @@ export type LaunchBlock = {
238
268
  message: string;
239
269
  };
240
270
  export declare function launchPreflight(rec: SessRec): LaunchBlock | null;
271
+ export declare function launchShellCommand(file: string): string;
241
272
  export declare function launchScript(id: string, tail: string, harness?: Harness, cmd?: string): string;
273
+ export declare function canonicalWatchRecipients(application: Pick<ProductionSessionApplication, 'topology'>, sessionId: string, status: string): string[];
274
+ export declare function sessionHasPendingDelivery(id: string, application?: Pick<ProductionSessionApplication, 'readPendingMessages'> & Partial<Pick<ProductionSessionApplication, 'resolveRuntime'>> | null): boolean;
275
+ export declare function canonicalRecordProjection<T extends Pick<SessRec, 'status' | 'stopped' | 'archived'>>(rec: T, canonical: {
276
+ status: string;
277
+ proposal: string | null;
278
+ note: string | null;
279
+ parentSessionId: string | null;
280
+ } | null | undefined): T & {
281
+ status: Lifecycle;
282
+ proposal: Proposal | null;
283
+ note: string | null;
284
+ parent: string | null;
285
+ };
286
+ export declare function adapterResidentLiveness(rec: SessRec, resident: AdapterLoadedReferenceState | undefined): Liveness;
242
287
  export declare const drainQueue: () => Promise<void>;
243
288
  export declare function superviseQueue(intervalMs?: number): void;
244
289
  export declare function superviseDelivery(intervalMs?: number): void;
@@ -260,6 +305,7 @@ type SessionCreateRequestOptions = {
260
305
  requestKey?: string;
261
306
  signal?: AbortSignal;
262
307
  timeoutMs?: number;
308
+ onPublished?: (session: Session) => void | Promise<void>;
263
309
  };
264
310
  export type SessionCreateRequestResult = {
265
311
  status: 201;
@@ -274,6 +320,7 @@ export declare function sessionCreateTimeoutMs(env?: NodeJS.ProcessEnv): number;
274
320
  export declare function sessionIdForCreateKey(key: string): string;
275
321
  export declare function sessionCreateRequest(body: unknown, options?: SessionCreateRequestOptions): Promise<SessionCreateRequestResult>;
276
322
  export declare function createSession(prompt: string, launcher?: string, name?: string, base?: string): Promise<Session>;
323
+ export declare function projectCreatedSession(session: Session): void;
277
324
  export declare function spawnerClause(p: SessRec | null): string;
278
325
  export declare function pendingSessionCreateWorktreePaths(): Set<string>;
279
326
  export declare function bootstrapMaterialize(rec: SessRec, doMaterialize?: (proj: string) => unknown): void;
@@ -292,10 +339,11 @@ export declare function markState(status: Lifecycle, opts?: {
292
339
  note?: string;
293
340
  sessionId?: string;
294
341
  }): boolean;
342
+ export declare function markHumanPromptActive(sessionId: string): boolean;
295
343
  export declare const markDone: (proposal?: Proposal, sessionId?: string, note?: string) => boolean;
296
- export declare const markError: (sessionId?: string) => boolean;
297
344
  export declare function markTurnFailure(sessionId: string | undefined, note: string): boolean;
298
345
  export declare function markHeadlessTurnFailure(sessionId: string, harness: string, exitCode: string): boolean;
346
+ export declare function existingHarnessLaunchTarget(id: string): string | null;
299
347
  export declare function stageHarnessLaunchProof(sessionId: string | undefined, harnessSessionId: string | undefined, launchPayload: string): boolean;
300
348
  export declare function markHarnessSessionId(sessionId: string | undefined, harnessSessionId: string | undefined): boolean;
301
349
  export declare function markIdle(sessionId?: string): boolean;
@@ -312,7 +360,7 @@ export type ReviewEvalFacts = {
312
360
  export type ReviewEvalGate = ({
313
361
  phase: 'ready';
314
362
  } & ReviewEvalFacts) | {
315
- phase: 'unavailable' | 'loading' | 'updating' | 'error';
363
+ phase: 'unavailable' | 'loading' | 'updating' | 'error' | 'dormant';
316
364
  };
317
365
  export type ReviewGates = {
318
366
  conflictsWithMain: boolean;
@@ -335,14 +383,47 @@ export type ReviewPayload = {
335
383
  note: string | null;
336
384
  };
337
385
  };
386
+ export type SessionDiffFile = ReviewDiffFile & {
387
+ patch: string;
388
+ diffIdentity: string;
389
+ };
390
+ export type DiffScope = 'branch' | 'working';
391
+ export type BranchState = 'no-commits' | 'merged' | 'open';
392
+ export type SessionDiffPayload = {
393
+ id: string;
394
+ scope: 'branch';
395
+ branch: string;
396
+ baseRef: string;
397
+ base: string;
398
+ head: string;
399
+ mergeBase: string;
400
+ branchState: BranchState;
401
+ commitUrl: string | null;
402
+ files: SessionDiffFile[];
403
+ working: {
404
+ readable: boolean;
405
+ files: SessionDiffFile[];
406
+ };
407
+ comments: DiffComment[];
408
+ };
409
+ export declare function commitUrlForRemote(remote: string, commit: string): string | null;
410
+ export declare function sessionDiff(id: string, filePath?: string, offset?: number, limit?: number, scope?: DiffScope): Promise<SessionDiffPayload | null>;
411
+ export declare function saveDiffComment(id: string, input: Omit<DiffComment, 'id' | 'sentAt'> & {
412
+ id?: string;
413
+ }): Promise<DiffComment | null>;
414
+ export declare function retractDiffComment(id: string, commentId: string): Promise<DiffComment | null>;
415
+ export declare function sendDiffComments(id: string, ids?: string[]): Promise<{
416
+ ok: boolean;
417
+ sentAt?: string;
418
+ count?: number;
419
+ error?: string;
420
+ }>;
338
421
  export declare function reviewPayload(id: string): Promise<ReviewPayload | null>;
339
422
  export type MergeSessionResult = {
340
423
  dispatched: true;
341
424
  } | {
342
425
  dispatched: false;
343
426
  reason: string;
344
- code?: 'session_merge_not_proposed';
345
- status?: 409;
346
427
  };
347
428
  export declare function mergeSession(id: string): Promise<MergeSessionResult>;
348
429
  export type SessionLeafReceipt = {
@@ -366,7 +447,6 @@ export type SessionLeafProcessProbe = Readonly<{
366
447
  }>;
367
448
  export declare function installSessionLeafProcessProbeForTest(probe: SessionLeafProcessProbe): () => void;
368
449
  export declare const stopSession: (id: string) => Promise<boolean>;
369
- export declare const archiveSession: (id: string, on?: boolean) => Promise<boolean>;
370
450
  export declare const closeSession: (id: string, rawSource?: unknown) => Promise<boolean>;
371
451
  export type CorruptRecordQuarantineWitness = {
372
452
  adapter: string;
@@ -415,19 +495,32 @@ export type SessionTableScope = {
415
495
  parent: string;
416
496
  };
417
497
  export declare function formatTable(sessions: Session[], color?: boolean, scope?: SessionTableScope): string;
498
+ type MessageIdempotency = {
499
+ operation: string;
500
+ requestDigest: string;
501
+ payloadHash: string;
502
+ };
418
503
  type DispatchIdempotency = MessageIdempotency;
419
- type DispatchAcceptCode = 'dispatch_key_reused' | 'session_merge_not_proposed';
504
+ type DispatchAcceptCode = 'dispatch_key_reused';
505
+ export declare const EMPTY_PROMPT_ERROR = "empty prompt \u2014 nothing to dispatch";
420
506
  type AcceptedDispatch = DispatchResult & {
421
507
  replayed?: boolean;
422
508
  code?: DispatchAcceptCode;
509
+ delivery?: 'accepted' | 'queued' | 'deferred';
423
510
  };
424
511
  type SendTextOptions = {
425
512
  replyVia?: 'note';
426
513
  idempotency?: DispatchIdempotency;
514
+ deliveryKey?: string;
427
515
  acceptGuard?: (record: SessRec) => Promise<void>;
428
516
  deferDrain?: boolean;
517
+ allowStranded?: boolean;
429
518
  };
430
519
  export declare function sendText(id: string, text: string, from?: string, opts?: SendTextOptions): Promise<AcceptedDispatch>;
431
520
  export declare function drainSession(id: string): Promise<void>;
521
+ export declare function canonicalMessageText(message: {
522
+ kind: string;
523
+ body: Uint8Array;
524
+ }, recipient: SessRec): string;
432
525
  export declare function interruptSession(id: string): Promise<DispatchResult>;
433
526
  export declare function rawKey(id: string, key: string | string[]): Promise<boolean>;