specrails-core 6.3.0 → 6.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (102) hide show
  1. package/dist/agent-runtime/capabilities.js +22 -5
  2. package/dist/agent-runtime/cli-executor.js +8 -3
  3. package/dist/agent-runtime/cli.d.ts +1 -1
  4. package/dist/agent-runtime/cli.js +50 -3
  5. package/dist/agent-runtime/compact/environment.d.ts +49 -4
  6. package/dist/agent-runtime/compact/environment.js +191 -8
  7. package/dist/agent-runtime/config.js +68 -53
  8. package/dist/agent-runtime/engine/compiler.js +10 -2
  9. package/dist/agent-runtime/engine/contracts.d.ts +16 -0
  10. package/dist/agent-runtime/engine/pieces/control.js +11 -2
  11. package/dist/agent-runtime/engine/pieces/role-turn.d.ts +5 -0
  12. package/dist/agent-runtime/engine/pieces/role-turn.js +69 -3
  13. package/dist/agent-runtime/engine/pieces/verify.d.ts +10 -3
  14. package/dist/agent-runtime/engine/pieces/verify.js +105 -30
  15. package/dist/agent-runtime/executor-types.d.ts +2 -0
  16. package/dist/agent-runtime/graph/nodes.js +9 -55
  17. package/dist/agent-runtime/prompts.d.ts +1 -1
  18. package/dist/agent-runtime/prompts.js +18 -12
  19. package/dist/agent-runtime/session/application/active-session.d.ts +176 -0
  20. package/dist/agent-runtime/session/application/active-session.js +701 -0
  21. package/dist/agent-runtime/session/application/delegation.d.ts +73 -0
  22. package/dist/agent-runtime/session/application/delegation.js +171 -0
  23. package/dist/agent-runtime/session/application/output-buffer.d.ts +43 -0
  24. package/dist/agent-runtime/session/application/output-buffer.js +65 -0
  25. package/dist/agent-runtime/session/application/session-service.d.ts +121 -0
  26. package/dist/agent-runtime/session/application/session-service.js +256 -0
  27. package/dist/agent-runtime/session/application/timers.d.ts +15 -0
  28. package/dist/agent-runtime/session/application/timers.js +35 -0
  29. package/dist/agent-runtime/session/domain/descriptor.d.ts +6 -0
  30. package/dist/agent-runtime/session/domain/descriptor.js +32 -0
  31. package/dist/agent-runtime/session/domain/errors.d.ts +9 -0
  32. package/dist/agent-runtime/session/domain/errors.js +16 -0
  33. package/dist/agent-runtime/session/domain/events.d.ts +147 -0
  34. package/dist/agent-runtime/session/domain/events.js +24 -0
  35. package/dist/agent-runtime/session/domain/fingerprint.d.ts +2 -0
  36. package/dist/agent-runtime/session/domain/fingerprint.js +10 -0
  37. package/dist/agent-runtime/session/domain/interruption.d.ts +13 -0
  38. package/dist/agent-runtime/session/domain/interruption.js +39 -0
  39. package/dist/agent-runtime/session/domain/policy.d.ts +42 -0
  40. package/dist/agent-runtime/session/domain/policy.js +104 -0
  41. package/dist/agent-runtime/session/domain/snapshot.d.ts +100 -0
  42. package/dist/agent-runtime/session/domain/snapshot.js +234 -0
  43. package/dist/agent-runtime/session/domain/state-machines.d.ts +21 -0
  44. package/dist/agent-runtime/session/domain/state-machines.js +41 -0
  45. package/dist/agent-runtime/session/domain/types.d.ts +130 -0
  46. package/dist/agent-runtime/session/domain/types.js +15 -0
  47. package/dist/agent-runtime/session/domain/usage.d.ts +54 -0
  48. package/dist/agent-runtime/session/domain/usage.js +86 -0
  49. package/dist/agent-runtime/session/drivers/claude/argv.d.ts +19 -0
  50. package/dist/agent-runtime/session/drivers/claude/argv.js +67 -0
  51. package/dist/agent-runtime/session/drivers/claude/driver.d.ts +19 -0
  52. package/dist/agent-runtime/session/drivers/claude/driver.js +134 -0
  53. package/dist/agent-runtime/session/drivers/claude/translator.d.ts +40 -0
  54. package/dist/agent-runtime/session/drivers/claude/translator.js +247 -0
  55. package/dist/agent-runtime/session/drivers/codex/argv.d.ts +12 -0
  56. package/dist/agent-runtime/session/drivers/codex/argv.js +76 -0
  57. package/dist/agent-runtime/session/drivers/codex/driver.d.ts +19 -0
  58. package/dist/agent-runtime/session/drivers/codex/driver.js +193 -0
  59. package/dist/agent-runtime/session/drivers/codex/rpc.d.ts +28 -0
  60. package/dist/agent-runtime/session/drivers/codex/rpc.js +81 -0
  61. package/dist/agent-runtime/session/drivers/codex/translator.d.ts +53 -0
  62. package/dist/agent-runtime/session/drivers/codex/translator.js +267 -0
  63. package/dist/agent-runtime/session/drivers/common/process.d.ts +37 -0
  64. package/dist/agent-runtime/session/drivers/common/process.js +116 -0
  65. package/dist/agent-runtime/session/drivers/executor/driver.d.ts +22 -0
  66. package/dist/agent-runtime/session/drivers/executor/driver.js +163 -0
  67. package/dist/agent-runtime/session/drivers/registry.d.ts +32 -0
  68. package/dist/agent-runtime/session/drivers/registry.js +38 -0
  69. package/dist/agent-runtime/session/host/protocol.d.ts +18 -0
  70. package/dist/agent-runtime/session/host/protocol.js +88 -0
  71. package/dist/agent-runtime/session/host/server.d.ts +57 -0
  72. package/dist/agent-runtime/session/host/server.js +229 -0
  73. package/dist/agent-runtime/session/index.d.ts +45 -0
  74. package/dist/agent-runtime/session/index.js +74 -0
  75. package/dist/agent-runtime/session/journal/schema.d.ts +7 -0
  76. package/dist/agent-runtime/session/journal/schema.js +44 -0
  77. package/dist/agent-runtime/session/journal/sqlite-journal.d.ts +70 -0
  78. package/dist/agent-runtime/session/journal/sqlite-journal.js +279 -0
  79. package/dist/agent-runtime/session/ports.d.ts +192 -0
  80. package/dist/agent-runtime/session/ports.js +1 -0
  81. package/dist/agent-runtime/session/testing/driver-conformance.d.ts +21 -0
  82. package/dist/agent-runtime/session/testing/driver-conformance.js +97 -0
  83. package/dist/agent-runtime/session/testing/fake-clock.d.ts +20 -0
  84. package/dist/agent-runtime/session/testing/fake-clock.js +34 -0
  85. package/dist/agent-runtime/session/testing/fixture-replayer.d.ts +41 -0
  86. package/dist/agent-runtime/session/testing/fixture-replayer.js +172 -0
  87. package/dist/agent-runtime/session/testing/index.d.ts +9 -0
  88. package/dist/agent-runtime/session/testing/index.js +9 -0
  89. package/dist/agent-runtime/session/testing/memory-journal.d.ts +27 -0
  90. package/dist/agent-runtime/session/testing/memory-journal.js +70 -0
  91. package/dist/agent-runtime/session/testing/scripted-driver.d.ts +30 -0
  92. package/dist/agent-runtime/session/testing/scripted-driver.js +77 -0
  93. package/dist/agent-runtime/verification-proposals.d.ts +9 -0
  94. package/dist/agent-runtime/verification-proposals.js +69 -0
  95. package/dist/agent-runtime/verification-repair.d.ts +26 -0
  96. package/dist/agent-runtime/verification-repair.js +88 -0
  97. package/dist/installer/util/registry.js +3 -3
  98. package/dist/shared/specrails-home.d.ts +21 -0
  99. package/dist/shared/specrails-home.js +36 -0
  100. package/integration-contract.json +43 -2
  101. package/package.json +11 -1
  102. package/schemas/agent-runtime.schema.json +9 -7
@@ -0,0 +1,21 @@
1
+ /**
2
+ * The user-level Specrails home. Registry, framework store, workspaces and
3
+ * agent session journals all live under `<home>/.specrails`, never inside a
4
+ * project repository.
5
+ *
6
+ * `SPECRAILS_REGISTRY_HOME` overrides the base directory so tests (and
7
+ * isolated installs) redirect every user-level artifact together.
8
+ */
9
+ export declare function userHome(home?: string): string;
10
+ /** Absolute path to `<home>/.specrails`. */
11
+ export declare function specrailsHome(home?: string): string;
12
+ /** Scope used by session hosts that are not bound to a project. */
13
+ export declare const GLOBAL_SESSION_SCOPE = "global";
14
+ /** True when `scope` is a valid session scope key (a project slug or `global`). */
15
+ export declare function isSessionScopeKey(scope: string): boolean;
16
+ /**
17
+ * Directory that holds every agent session journal of one scope:
18
+ * `<home>/.specrails/sessions/<scope>/`. Sessions are grouped per project so a
19
+ * project's history can be inspected, backed up or removed as one unit.
20
+ */
21
+ export declare function sessionsRoot(scope: string, home?: string): string;
@@ -0,0 +1,36 @@
1
+ import os from 'node:os';
2
+ import path from 'node:path';
3
+ /**
4
+ * The user-level Specrails home. Registry, framework store, workspaces and
5
+ * agent session journals all live under `<home>/.specrails`, never inside a
6
+ * project repository.
7
+ *
8
+ * `SPECRAILS_REGISTRY_HOME` overrides the base directory so tests (and
9
+ * isolated installs) redirect every user-level artifact together.
10
+ */
11
+ export function userHome(home) {
12
+ return home ?? process.env.SPECRAILS_REGISTRY_HOME ?? os.homedir();
13
+ }
14
+ /** Absolute path to `<home>/.specrails`. */
15
+ export function specrailsHome(home) {
16
+ return path.join(userHome(home), '.specrails');
17
+ }
18
+ /** Scope used by session hosts that are not bound to a project. */
19
+ export const GLOBAL_SESSION_SCOPE = 'global';
20
+ /** Same alphabet the registry uses for project slugs, bounded for file names. */
21
+ const SCOPE_KEY = /^[a-z0-9](?:[a-z0-9-]{0,126}[a-z0-9])?$/;
22
+ /** True when `scope` is a valid session scope key (a project slug or `global`). */
23
+ export function isSessionScopeKey(scope) {
24
+ return SCOPE_KEY.test(scope);
25
+ }
26
+ /**
27
+ * Directory that holds every agent session journal of one scope:
28
+ * `<home>/.specrails/sessions/<scope>/`. Sessions are grouped per project so a
29
+ * project's history can be inspected, backed up or removed as one unit.
30
+ */
31
+ export function sessionsRoot(scope, home) {
32
+ if (!isSessionScopeKey(scope)) {
33
+ throw new Error(`Invalid session scope "${scope}": use a project slug (a-z, 0-9, "-") or "${GLOBAL_SESSION_SCOPE}"`);
34
+ }
35
+ return path.join(specrailsHome(home), 'sessions', scope);
36
+ }
@@ -241,7 +241,8 @@
241
241
  "workflows",
242
242
  "fork",
243
243
  "signal",
244
- "cancel"
244
+ "cancel",
245
+ "host"
245
246
  ],
246
247
  "cliPresentationOperations": [
247
248
  "help"
@@ -293,7 +294,7 @@
293
294
  "specificationFormat": "Architect specs contain complete main-spec replacements, including unchanged requirements; archive does not merge partial delta snippets.",
294
295
  "compatibility": "Additive to integration schema 4 and execution context schema 1. Legacy workflows and profile v1 remain supported. Hosts must check RUNTIME_API_VERSION, not infer runtime support from Core major version.",
295
296
  "documentation": "docs/agent-runtime.md",
296
- "instructionsVersion": "13",
297
+ "instructionsVersion": "14",
297
298
  "workflowVersion": "7",
298
299
  "engines": [
299
300
  1,
@@ -373,6 +374,46 @@
373
374
  "workflowAgentSteps": {
374
375
  "version": 1,
375
376
  "ownership": "Host-defined roles, schemas and gates; Core provides scoped artifact contracts and verified candidate guards"
377
+ },
378
+ "sessions": {
379
+ "version": 1,
380
+ "protocolVersions": [
381
+ 1
382
+ ],
383
+ "capability": "sessions",
384
+ "cliOperation": "host",
385
+ "cliCommand": "specrails-core runtime host --stdio --scope <projectKey|global>",
386
+ "transport": "JSON-RPC 2.0 over newline-delimited stdio; one host per scope",
387
+ "journalRoot": "~/.specrails/sessions/<scope>/sessions.sqlite",
388
+ "moduleExport": "./agent-runtime/session",
389
+ "documentation": "docs/agent-sessions/protocol.md",
390
+ "eventTypes": [
391
+ "session.opened",
392
+ "session.phase",
393
+ "session.process",
394
+ "session.provider-ref",
395
+ "session.updated",
396
+ "session.closed",
397
+ "input.accepted",
398
+ "input.state",
399
+ "turn.started",
400
+ "turn.output",
401
+ "turn.tool",
402
+ "turn.completed",
403
+ "subagent.started",
404
+ "subagent.phase",
405
+ "subagent.output",
406
+ "subagent.usage",
407
+ "subagent.result",
408
+ "subagents.settled",
409
+ "output.truncated",
410
+ "notice.interruption",
411
+ "provider.diagnostic"
412
+ ],
413
+ "capabilities": [
414
+ "sessions",
415
+ "delegation"
416
+ ]
376
417
  }
377
418
  },
378
419
  "execution": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "specrails-core",
3
- "version": "6.3.0",
3
+ "version": "6.5.0",
4
4
  "description": "Agent workflow engine for specrails-desktop: provider-independent installer and programmatic agent runtime for Claude Code and Codex",
5
5
  "type": "module",
6
6
  "exports": {
@@ -14,6 +14,16 @@
14
14
  "import": "./dist/agent-runtime/engine/index.js",
15
15
  "default": "./dist/agent-runtime/engine/index.js"
16
16
  },
17
+ "./agent-runtime/session": {
18
+ "types": "./dist/agent-runtime/session/index.d.ts",
19
+ "import": "./dist/agent-runtime/session/index.js",
20
+ "default": "./dist/agent-runtime/session/index.js"
21
+ },
22
+ "./agent-runtime/session/testing": {
23
+ "types": "./dist/agent-runtime/session/testing/index.d.ts",
24
+ "import": "./dist/agent-runtime/session/testing/index.js",
25
+ "default": "./dist/agent-runtime/session/testing/index.js"
26
+ },
17
27
  "./package.json": "./package.json",
18
28
  "./integration-contract.json": "./integration-contract.json",
19
29
  "./schemas/agent-runtime.schema.json": "./schemas/agent-runtime.schema.json",
@@ -134,13 +134,8 @@
134
134
  "maxAttempts": { "$ref": "#/definitions/positiveInteger" }, "maxTokens": { "$ref": "#/definitions/positiveInteger" },
135
135
  "maxCostUsd": { "type": "number", "exclusiveMinimum": 0 }, "timeoutMs": { "$ref": "#/definitions/positiveInteger" }
136
136
  } },
137
- "verification": { "type": "array", "items": { "type": "object", "additionalProperties": false, "required": ["repositoryId", "command", "args"], "properties": {
138
- "key": { "$ref": "#/definitions/id" }, "label": { "type": "string", "minLength": 1, "maxLength": 256, "pattern": "\\S" }, "policy": { "$ref": "#/definitions/checkPolicy" },
139
- "repositoryId": { "$ref": "#/definitions/id" }, "command": { "type": "string", "minLength": 1 },
140
- "args": { "type": "array", "items": { "type": "string" } }, "cwd": { "type": "string", "minLength": 1 },
141
- "env": { "type": "object", "propertyNames": { "pattern": "^[A-Za-z_][A-Za-z0-9_]*$" }, "additionalProperties": { "type": "string" } },
142
- "timeoutMs": { "$ref": "#/definitions/positiveInteger" }
143
- } } },
137
+ "verification": { "type": "array", "items": { "$ref": "#/definitions/checkCommand" } },
138
+ "setup": { "type": "array", "description": "Idempotent commands the verify piece runs sequentially in the admitted workspace before each verification plan; a failing setup command blocks the run instead of starting a correction round.", "items": { "$ref": "#/definitions/checkCommand" } },
144
139
  "approvalBeforeArchive": { "type": "boolean" },
145
140
  "review": { "type": "object", "additionalProperties": false, "description": "Review gate thresholds; unset fields keep Core's defaults (score 70, security 75, other aspects 60).", "properties": {
146
141
  "minScore": { "$ref": "#/definitions/score" },
@@ -154,6 +149,13 @@
154
149
  } }
155
150
  },
156
151
  "definitions": {
152
+ "checkCommand": { "type": "object", "additionalProperties": false, "required": ["repositoryId", "command", "args"], "properties": {
153
+ "key": { "$ref": "#/definitions/id" }, "label": { "type": "string", "minLength": 1, "maxLength": 256, "pattern": "\\S" }, "policy": { "$ref": "#/definitions/checkPolicy" },
154
+ "repositoryId": { "$ref": "#/definitions/id" }, "command": { "type": "string", "minLength": 1 },
155
+ "args": { "type": "array", "items": { "type": "string" } }, "cwd": { "type": "string", "minLength": 1 },
156
+ "env": { "type": "object", "propertyNames": { "pattern": "^[A-Za-z_][A-Za-z0-9_]*$" }, "additionalProperties": { "type": "string" } },
157
+ "timeoutMs": { "$ref": "#/definitions/positiveInteger" }
158
+ } },
157
159
  "effort": { "type": "string", "pattern": "^[a-z][a-z0-9_-]{0,31}$" },
158
160
  "inputList": { "type": "array", "maxItems": 256, "items": { "type": "string", "minLength": 1, "maxLength": 4096, "pattern": "\\S" } },
159
161
  "checkPolicy": { "type": "object", "additionalProperties": false, "properties": {