@exaudeus/workrail 3.11.2 → 3.13.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 (77) hide show
  1. package/dist/console/assets/index-DW78t31j.css +1 -0
  2. package/dist/console/assets/index-EsSXrC_a.js +28 -0
  3. package/dist/console/index.html +2 -2
  4. package/dist/di/container.js +8 -0
  5. package/dist/di/tokens.d.ts +1 -0
  6. package/dist/di/tokens.js +1 -0
  7. package/dist/infrastructure/session/HttpServer.js +2 -14
  8. package/dist/manifest.json +139 -91
  9. package/dist/mcp/boundary-coercion.d.ts +2 -0
  10. package/dist/mcp/boundary-coercion.js +73 -0
  11. package/dist/mcp/handler-factory.d.ts +1 -1
  12. package/dist/mcp/handler-factory.js +13 -6
  13. package/dist/mcp/handlers/shared/request-workflow-reader.d.ts +10 -2
  14. package/dist/mcp/handlers/shared/request-workflow-reader.js +27 -10
  15. package/dist/mcp/handlers/shared/workflow-source-visibility.d.ts +3 -1
  16. package/dist/mcp/handlers/shared/workflow-source-visibility.js +7 -3
  17. package/dist/mcp/handlers/v2-execution/replay.js +25 -1
  18. package/dist/mcp/handlers/v2-execution/start.js +23 -17
  19. package/dist/mcp/handlers/v2-manage-workflow-source.d.ts +7 -0
  20. package/dist/mcp/handlers/v2-manage-workflow-source.js +50 -0
  21. package/dist/mcp/handlers/v2-workflow.js +123 -8
  22. package/dist/mcp/output-schemas.d.ts +393 -0
  23. package/dist/mcp/output-schemas.js +49 -1
  24. package/dist/mcp/server.js +2 -0
  25. package/dist/mcp/tool-descriptions.js +20 -0
  26. package/dist/mcp/tools.js +6 -0
  27. package/dist/mcp/types/tool-description-types.d.ts +1 -1
  28. package/dist/mcp/types/tool-description-types.js +1 -0
  29. package/dist/mcp/types/workflow-tool-edition.d.ts +1 -1
  30. package/dist/mcp/types.d.ts +2 -0
  31. package/dist/mcp/v2/tool-registry.js +8 -0
  32. package/dist/mcp/v2/tools.d.ts +15 -0
  33. package/dist/mcp/v2/tools.js +8 -1
  34. package/dist/v2/durable-core/constants.d.ts +1 -0
  35. package/dist/v2/durable-core/constants.js +2 -1
  36. package/dist/v2/durable-core/domain/observation-builder.d.ts +4 -1
  37. package/dist/v2/durable-core/domain/observation-builder.js +9 -0
  38. package/dist/v2/durable-core/schemas/export-bundle/index.d.ts +76 -16
  39. package/dist/v2/durable-core/schemas/session/events.d.ts +26 -5
  40. package/dist/v2/durable-core/schemas/session/events.js +2 -1
  41. package/dist/v2/infra/in-memory/managed-source-store/index.d.ts +8 -0
  42. package/dist/v2/infra/in-memory/managed-source-store/index.js +33 -0
  43. package/dist/v2/infra/local/data-dir/index.d.ts +2 -0
  44. package/dist/v2/infra/local/data-dir/index.js +6 -0
  45. package/dist/v2/infra/local/managed-source-store/index.d.ts +15 -0
  46. package/dist/v2/infra/local/managed-source-store/index.js +164 -0
  47. package/dist/v2/infra/local/session-summary-provider/index.js +2 -0
  48. package/dist/v2/infra/local/workspace-anchor/index.js +1 -0
  49. package/dist/v2/ports/data-dir.port.d.ts +2 -0
  50. package/dist/v2/ports/managed-source-store.port.d.ts +25 -0
  51. package/dist/v2/ports/managed-source-store.port.js +2 -0
  52. package/dist/v2/ports/workspace-anchor.port.d.ts +3 -0
  53. package/dist/v2/projections/resume-ranking.d.ts +1 -0
  54. package/dist/v2/usecases/console-routes.js +26 -0
  55. package/dist/v2/usecases/console-service.js +25 -6
  56. package/dist/v2/usecases/console-types.d.ts +22 -1
  57. package/dist/v2/usecases/worktree-service.d.ts +10 -0
  58. package/dist/v2/usecases/worktree-service.js +136 -0
  59. package/package.json +1 -1
  60. package/workflows/adaptive-ticket-creation.json +276 -282
  61. package/workflows/architecture-scalability-audit.json +317 -0
  62. package/workflows/document-creation-workflow.json +70 -191
  63. package/workflows/documentation-update-workflow.json +59 -309
  64. package/workflows/intelligent-test-case-generation.json +37 -212
  65. package/workflows/personal-learning-materials-creation-branched.json +1 -21
  66. package/workflows/presentation-creation.json +143 -308
  67. package/workflows/relocation-workflow-us.json +161 -535
  68. package/workflows/routines/tension-driven-design.json +5 -5
  69. package/workflows/scoped-documentation-workflow.json +110 -181
  70. package/workflows/workflow-for-workflows.v2.json +21 -5
  71. package/dist/console/assets/index-C5C4nDs4.css +0 -1
  72. package/dist/console/assets/index-CSUqsoQl.js +0 -28
  73. package/workflows/CHANGELOG-bug-investigation.md +0 -298
  74. package/workflows/bug-investigation.agentic.json +0 -212
  75. package/workflows/bug-investigation.json +0 -112
  76. package/workflows/mr-review-workflow.agentic.json +0 -538
  77. package/workflows/mr-review-workflow.json +0 -277
@@ -1,6 +1,6 @@
1
1
  export declare const DESCRIPTION_MODES: readonly ["standard", "authoritative"];
2
2
  export type DescriptionMode = typeof DESCRIPTION_MODES[number];
3
- export declare const WORKFLOW_TOOL_NAMES: readonly ["discover_workflows", "preview_workflow", "advance_workflow", "validate_workflow", "get_workflow_schema", "list_workflows", "inspect_workflow", "start_workflow", "continue_workflow", "checkpoint_workflow", "resume_session"];
3
+ export declare const WORKFLOW_TOOL_NAMES: readonly ["discover_workflows", "preview_workflow", "advance_workflow", "validate_workflow", "get_workflow_schema", "list_workflows", "inspect_workflow", "start_workflow", "continue_workflow", "checkpoint_workflow", "resume_session", "manage_workflow_source"];
4
4
  export type WorkflowToolName = typeof WORKFLOW_TOOL_NAMES[number];
5
5
  export type ToolDescriptionMap = Readonly<Record<WorkflowToolName, string>>;
6
6
  export type DescriptionsByMode = Readonly<Record<DescriptionMode, ToolDescriptionMap>>;
@@ -19,6 +19,7 @@ exports.WORKFLOW_TOOL_NAMES = [
19
19
  'continue_workflow',
20
20
  'checkpoint_workflow',
21
21
  'resume_session',
22
+ 'manage_workflow_source',
22
23
  ];
23
24
  function isDescriptionMode(value) {
24
25
  return exports.DESCRIPTION_MODES.includes(value);
@@ -2,7 +2,7 @@ import type { z } from 'zod';
2
2
  import type { ToolDefinition } from '../tool-factory.js';
3
3
  import type { ToolContext } from '../types.js';
4
4
  export type V1WorkflowToolName = 'discover_workflows' | 'preview_workflow' | 'advance_workflow' | 'validate_workflow' | 'get_workflow_schema';
5
- export type V2WorkflowToolName = 'list_workflows' | 'inspect_workflow' | 'start_workflow' | 'continue_workflow' | 'checkpoint_workflow' | 'resume_session';
5
+ export type V2WorkflowToolName = 'list_workflows' | 'inspect_workflow' | 'start_workflow' | 'continue_workflow' | 'checkpoint_workflow' | 'resume_session' | 'manage_workflow_source';
6
6
  export type McpCallToolResult = {
7
7
  readonly content: ReadonlyArray<{
8
8
  readonly type: 'text';
@@ -20,6 +20,7 @@ import type { ValidationPipelineDepsPhase1a } from '../application/services/work
20
20
  import type { TokenAliasStorePortV2 } from '../v2/ports/token-alias-store.port.js';
21
21
  import type { RandomEntropyPortV2 } from '../v2/ports/random-entropy.port.js';
22
22
  import type { RememberedRootsStorePortV2 } from '../v2/ports/remembered-roots-store.port.js';
23
+ import type { ManagedSourceStorePortV2 } from '../v2/ports/managed-source-store.port.js';
23
24
  export interface SessionHealthDetails {
24
25
  readonly health: SessionHealthV2;
25
26
  }
@@ -61,6 +62,7 @@ export interface V2Dependencies {
61
62
  readonly tokenCodecPorts: TokenCodecPorts;
62
63
  readonly tokenAliasStore: TokenAliasStorePortV2;
63
64
  readonly rememberedRootsStore?: RememberedRootsStorePortV2;
65
+ readonly managedSourceStore?: ManagedSourceStorePortV2;
64
66
  readonly entropy: RandomEntropyPortV2;
65
67
  readonly validationPipelineDeps: ValidationPipelineDepsPhase1a;
66
68
  readonly resolvedRootUris?: readonly string[];
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.buildV2ToolRegistry = buildV2ToolRegistry;
4
4
  const handler_factory_js_1 = require("../handler-factory.js");
5
5
  const tools_js_1 = require("./tools.js");
6
+ const v2_manage_workflow_source_js_1 = require("../handlers/v2-manage-workflow-source.js");
6
7
  const v2_execution_js_1 = require("../handlers/v2-execution.js");
7
8
  const v2_workflow_js_1 = require("../handlers/v2-workflow.js");
8
9
  const v2_checkpoint_js_1 = require("../handlers/v2-checkpoint.js");
@@ -46,6 +47,12 @@ function buildV2ToolRegistry(buildTool) {
46
47
  inputSchema: tools_js_1.V2ResumeSessionInput,
47
48
  annotations: tools_js_1.V2_TOOL_ANNOTATIONS.resume_session,
48
49
  }),
50
+ buildTool({
51
+ name: 'manage_workflow_source',
52
+ title: tools_js_1.V2_TOOL_TITLES.manage_workflow_source,
53
+ inputSchema: tools_js_1.V2ManageWorkflowSourceInput,
54
+ annotations: tools_js_1.V2_TOOL_ANNOTATIONS.manage_workflow_source,
55
+ }),
49
56
  ];
50
57
  const handlers = {
51
58
  list_workflows: (0, handler_factory_js_1.createHandler)(tools_js_1.V2ListWorkflowsInput, v2_workflow_js_1.handleV2ListWorkflows),
@@ -54,6 +61,7 @@ function buildV2ToolRegistry(buildTool) {
54
61
  continue_workflow: (0, handler_factory_js_1.createHandler)(tools_js_1.V2ContinueWorkflowInput, v2_execution_js_1.handleV2ContinueWorkflow, tools_js_1.V2ContinueWorkflowInputShape, workflow_protocol_contracts_js_1.CONTINUE_WORKFLOW_PROTOCOL.aliasMap),
55
62
  checkpoint_workflow: (0, handler_factory_js_1.createHandler)(tools_js_1.V2CheckpointWorkflowInput, v2_checkpoint_js_1.handleV2CheckpointWorkflow),
56
63
  resume_session: (0, handler_factory_js_1.createHandler)(tools_js_1.V2ResumeSessionInput, v2_resume_js_1.handleV2ResumeSession),
64
+ manage_workflow_source: (0, handler_factory_js_1.createHandler)(tools_js_1.V2ManageWorkflowSourceInput, v2_manage_workflow_source_js_1.handleV2ManageWorkflowSource),
57
65
  };
58
66
  return { tools, handlers };
59
67
  }
@@ -2,10 +2,13 @@ import { z } from 'zod';
2
2
  import type { ToolAnnotations } from '../tool-factory.js';
3
3
  export declare const V2ListWorkflowsInput: z.ZodObject<{
4
4
  workspacePath: z.ZodEffects<z.ZodString, string, string>;
5
+ includeSources: z.ZodOptional<z.ZodBoolean>;
5
6
  }, "strip", z.ZodTypeAny, {
6
7
  workspacePath: string;
8
+ includeSources?: boolean | undefined;
7
9
  }, {
8
10
  workspacePath: string;
11
+ includeSources?: boolean | undefined;
9
12
  }>;
10
13
  export type V2ListWorkflowsInput = z.infer<typeof V2ListWorkflowsInput>;
11
14
  export declare const V2InspectWorkflowInput: z.ZodObject<{
@@ -171,6 +174,17 @@ export declare const V2ResumeSessionInput: z.ZodObject<{
171
174
  sameWorkspaceOnly?: boolean | undefined;
172
175
  }>;
173
176
  export type V2ResumeSessionInput = z.infer<typeof V2ResumeSessionInput>;
177
+ export declare const V2ManageWorkflowSourceInput: z.ZodObject<{
178
+ action: z.ZodEnum<["attach", "detach"]>;
179
+ path: z.ZodEffects<z.ZodString, string, string>;
180
+ }, "strict", z.ZodTypeAny, {
181
+ path: string;
182
+ action: "attach" | "detach";
183
+ }, {
184
+ path: string;
185
+ action: "attach" | "detach";
186
+ }>;
187
+ export type V2ManageWorkflowSourceInput = z.infer<typeof V2ManageWorkflowSourceInput>;
174
188
  export declare const V2CheckpointWorkflowInput: z.ZodObject<{
175
189
  checkpointToken: z.ZodString;
176
190
  }, "strict", z.ZodTypeAny, {
@@ -186,5 +200,6 @@ export declare const V2_TOOL_TITLES: {
186
200
  readonly continue_workflow: "Continue Workflow (v2)";
187
201
  readonly checkpoint_workflow: "Checkpoint Workflow (v2)";
188
202
  readonly resume_session: "Resume Session (v2)";
203
+ readonly manage_workflow_source: "Manage Workflow Source (v2)";
189
204
  };
190
205
  export declare const V2_TOOL_ANNOTATIONS: Readonly<Record<keyof typeof V2_TOOL_TITLES, ToolAnnotations>>;
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.V2_TOOL_ANNOTATIONS = exports.V2_TOOL_TITLES = exports.V2CheckpointWorkflowInput = exports.V2ResumeSessionInput = exports.V2ContinueWorkflowInput = exports.V2ContinueWorkflowInputShape = exports.V2StartWorkflowInput = exports.V2InspectWorkflowInput = exports.V2ListWorkflowsInput = void 0;
6
+ exports.V2_TOOL_ANNOTATIONS = exports.V2_TOOL_TITLES = exports.V2CheckpointWorkflowInput = exports.V2ManageWorkflowSourceInput = exports.V2ResumeSessionInput = exports.V2ContinueWorkflowInput = exports.V2ContinueWorkflowInputShape = exports.V2StartWorkflowInput = exports.V2InspectWorkflowInput = exports.V2ListWorkflowsInput = void 0;
7
7
  const path_1 = __importDefault(require("path"));
8
8
  const zod_1 = require("zod");
9
9
  const workflow_protocol_contracts_js_1 = require("../workflow-protocol-contracts.js");
@@ -16,6 +16,7 @@ const workspacePathField = zod_1.z.string()
16
16
  const optionalWorkspacePathField = workspacePathField.optional();
17
17
  exports.V2ListWorkflowsInput = zod_1.z.object({
18
18
  workspacePath: workspacePathField.describe('Required. Absolute path to your current workspace directory (e.g. the "Workspace:" value from your system parameters). WorkRail uses this to resolve project-scoped workflow variants against the correct workspace for discovery-sensitive workflow listing. Shared MCP servers cannot infer this safely.'),
19
+ includeSources: zod_1.z.boolean().optional().describe('When true, includes a source catalog in the response showing where workflows come from (built-in, project-scoped, rooted-sharing, external), with effective and shadowed workflow counts per source. Omit or set false for the default workflow-list-only response.'),
19
20
  });
20
21
  exports.V2InspectWorkflowInput = zod_1.z.object({
21
22
  workflowId: zod_1.z.string().min(1).regex(/^([a-z0-9_-]+|[a-z][a-z0-9_-]+\.[a-z][a-z0-9_-]+)$/, 'Workflow ID must be a valid legacy ID (e.g. my-workflow) or namespaced ID (e.g. wr.discovery)').describe('The workflow ID to inspect'),
@@ -111,6 +112,10 @@ exports.V2ResumeSessionInput = zod_1.z.object({
111
112
  sameWorkspaceOnly: zod_1.z.boolean().optional().describe('If true, only sessions from the same repo/workspace are considered when repo_root_hash is available. ' +
112
113
  'Use this when the user clearly means "resume work from this repo only".'),
113
114
  }).strict();
115
+ exports.V2ManageWorkflowSourceInput = zod_1.z.object({
116
+ action: zod_1.z.enum(['attach', 'detach']).describe('The operation to perform. "attach" registers the directory as a managed workflow source; "detach" removes it. Both operations are idempotent.'),
117
+ path: zod_1.z.string().min(1).refine((p) => path_1.default.isAbsolute(p), 'path must be an absolute path').describe('Absolute filesystem path to the workflow directory to attach or detach. Must be an absolute path. The path is normalized (resolved) before storage.'),
118
+ }).strict();
114
119
  exports.V2CheckpointWorkflowInput = zod_1.z.object({
115
120
  checkpointToken: zod_1.z.string().min(1).describe('The checkpoint token from the most recent start_workflow or continue_workflow response. ' +
116
121
  'Creates a checkpoint on the current step without advancing. Idempotent — calling with the same token is safe.'),
@@ -122,6 +127,7 @@ exports.V2_TOOL_TITLES = {
122
127
  continue_workflow: 'Continue Workflow (v2)',
123
128
  checkpoint_workflow: 'Checkpoint Workflow (v2)',
124
129
  resume_session: 'Resume Session (v2)',
130
+ manage_workflow_source: 'Manage Workflow Source (v2)',
125
131
  };
126
132
  exports.V2_TOOL_ANNOTATIONS = {
127
133
  list_workflows: { readOnlyHint: true, destructiveHint: false, idempotentHint: true },
@@ -130,4 +136,5 @@ exports.V2_TOOL_ANNOTATIONS = {
130
136
  continue_workflow: { readOnlyHint: false, destructiveHint: false, idempotentHint: true },
131
137
  checkpoint_workflow: { readOnlyHint: false, destructiveHint: false, idempotentHint: true },
132
138
  resume_session: { readOnlyHint: true, destructiveHint: false, idempotentHint: true },
139
+ manage_workflow_source: { readOnlyHint: false, destructiveHint: false, idempotentHint: true },
133
140
  };
@@ -12,6 +12,7 @@ export declare const MAX_VALIDATION_SUGGESTIONS_BYTES = 4096;
12
12
  export declare const MAX_CONTEXT_BYTES: number;
13
13
  export declare const MAX_CONTEXT_DEPTH = 64;
14
14
  export declare const MAX_OBSERVATION_SHORT_STRING_LENGTH = 80;
15
+ export declare const MAX_OBSERVATION_PATH_LENGTH = 512;
15
16
  export declare const SESSION_LOCK_RETRY_AFTER_MS = 1000;
16
17
  export declare const DEFAULT_RETRY_AFTER_MS = 1000;
17
18
  export declare const TRUNCATION_MARKER = "\n\n[TRUNCATED]";
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.AUTONOMY_MODE = exports.ADVANCE_INTENT = exports.MANIFEST_KIND = exports.EDGE_CAUSE = exports.ADVANCE_OUTCOME = exports.ENGINE_STATE = exports.EDGE_KIND = exports.PAYLOAD_KIND = exports.OUTPUT_CHANNEL = exports.EVENT_KIND = exports.DELIMITER_SAFE_ID_PATTERN = exports.SHA256_DIGEST_PATTERN = exports.MAX_RESUME_PREVIEW_BYTES = exports.RECOVERY_BUDGET_BYTES = exports.TRUNCATION_MARKER = exports.DEFAULT_RETRY_AFTER_MS = exports.SESSION_LOCK_RETRY_AFTER_MS = exports.MAX_OBSERVATION_SHORT_STRING_LENGTH = exports.MAX_CONTEXT_DEPTH = exports.MAX_CONTEXT_BYTES = exports.MAX_VALIDATION_SUGGESTIONS_BYTES = exports.MAX_VALIDATION_ISSUES_BYTES = exports.MAX_VALIDATION_SUGGESTION_ITEM_BYTES = exports.MAX_VALIDATION_ISSUE_ITEM_BYTES = exports.MAX_OUTPUT_NOTES_MARKDOWN_BYTES = exports.MAX_DECISION_TRACE_TOTAL_BYTES = exports.MAX_DECISION_TRACE_ENTRY_SUMMARY_BYTES = exports.MAX_DECISION_TRACE_ENTRIES = exports.MAX_BLOCKER_SUGGESTED_FIX_BYTES = exports.MAX_BLOCKER_MESSAGE_BYTES = exports.MAX_BLOCKERS = void 0;
3
+ exports.AUTONOMY_MODE = exports.ADVANCE_INTENT = exports.MANIFEST_KIND = exports.EDGE_CAUSE = exports.ADVANCE_OUTCOME = exports.ENGINE_STATE = exports.EDGE_KIND = exports.PAYLOAD_KIND = exports.OUTPUT_CHANNEL = exports.EVENT_KIND = exports.DELIMITER_SAFE_ID_PATTERN = exports.SHA256_DIGEST_PATTERN = exports.MAX_RESUME_PREVIEW_BYTES = exports.RECOVERY_BUDGET_BYTES = exports.TRUNCATION_MARKER = exports.DEFAULT_RETRY_AFTER_MS = exports.SESSION_LOCK_RETRY_AFTER_MS = exports.MAX_OBSERVATION_PATH_LENGTH = exports.MAX_OBSERVATION_SHORT_STRING_LENGTH = exports.MAX_CONTEXT_DEPTH = exports.MAX_CONTEXT_BYTES = exports.MAX_VALIDATION_SUGGESTIONS_BYTES = exports.MAX_VALIDATION_ISSUES_BYTES = exports.MAX_VALIDATION_SUGGESTION_ITEM_BYTES = exports.MAX_VALIDATION_ISSUE_ITEM_BYTES = exports.MAX_OUTPUT_NOTES_MARKDOWN_BYTES = exports.MAX_DECISION_TRACE_TOTAL_BYTES = exports.MAX_DECISION_TRACE_ENTRY_SUMMARY_BYTES = exports.MAX_DECISION_TRACE_ENTRIES = exports.MAX_BLOCKER_SUGGESTED_FIX_BYTES = exports.MAX_BLOCKER_MESSAGE_BYTES = exports.MAX_BLOCKERS = void 0;
4
4
  exports.MAX_BLOCKERS = 10;
5
5
  exports.MAX_BLOCKER_MESSAGE_BYTES = 512;
6
6
  exports.MAX_BLOCKER_SUGGESTED_FIX_BYTES = 1024;
@@ -15,6 +15,7 @@ exports.MAX_VALIDATION_SUGGESTIONS_BYTES = 4096;
15
15
  exports.MAX_CONTEXT_BYTES = 256 * 1024;
16
16
  exports.MAX_CONTEXT_DEPTH = 64;
17
17
  exports.MAX_OBSERVATION_SHORT_STRING_LENGTH = 80;
18
+ exports.MAX_OBSERVATION_PATH_LENGTH = 512;
18
19
  exports.SESSION_LOCK_RETRY_AFTER_MS = 1000;
19
20
  exports.DEFAULT_RETRY_AFTER_MS = 1000;
20
21
  exports.TRUNCATION_MARKER = '\n\n[TRUNCATED]';
@@ -1,6 +1,6 @@
1
1
  import type { WorkspaceAnchor } from '../../ports/workspace-anchor.port.js';
2
2
  export interface ObservationEventData {
3
- readonly key: 'git_branch' | 'git_head_sha' | 'repo_root_hash';
3
+ readonly key: 'git_branch' | 'git_head_sha' | 'repo_root_hash' | 'repo_root';
4
4
  readonly value: {
5
5
  readonly type: 'short_string';
6
6
  readonly value: string;
@@ -10,6 +10,9 @@ export interface ObservationEventData {
10
10
  } | {
11
11
  readonly type: 'sha256';
12
12
  readonly value: string;
13
+ } | {
14
+ readonly type: 'path';
15
+ readonly value: string;
13
16
  };
14
17
  readonly confidence: 'low' | 'med' | 'high';
15
18
  }
@@ -33,6 +33,15 @@ function anchorsToObservations(anchors) {
33
33
  confidence: 'high',
34
34
  });
35
35
  break;
36
+ case 'repo_root':
37
+ if (anchor.value.length > constants_js_1.MAX_OBSERVATION_PATH_LENGTH)
38
+ break;
39
+ observations.push({
40
+ key: 'repo_root',
41
+ value: { type: 'path', value: anchor.value },
42
+ confidence: 'high',
43
+ });
44
+ break;
36
45
  default: {
37
46
  const _exhaustive = anchor;
38
47
  return _exhaustive;
@@ -110,7 +110,7 @@ export declare const SessionContentsV1Schema: z.ZodObject<{
110
110
  kind: z.ZodLiteral<"observation_recorded">;
111
111
  scope: z.ZodUndefined;
112
112
  data: z.ZodObject<{
113
- key: z.ZodEnum<["git_branch", "git_head_sha", "repo_root_hash"]>;
113
+ key: z.ZodEnum<["git_branch", "git_head_sha", "repo_root_hash", "repo_root"]>;
114
114
  value: z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
115
115
  type: z.ZodLiteral<"short_string">;
116
116
  value: z.ZodString;
@@ -138,6 +138,15 @@ export declare const SessionContentsV1Schema: z.ZodObject<{
138
138
  }, {
139
139
  value: string;
140
140
  type: "sha256";
141
+ }>, z.ZodObject<{
142
+ type: z.ZodLiteral<"path">;
143
+ value: z.ZodString;
144
+ }, "strip", z.ZodTypeAny, {
145
+ value: string;
146
+ type: "path";
147
+ }, {
148
+ value: string;
149
+ type: "path";
141
150
  }>]>;
142
151
  confidence: z.ZodEnum<["low", "med", "high"]>;
143
152
  }, "strip", z.ZodTypeAny, {
@@ -150,8 +159,11 @@ export declare const SessionContentsV1Schema: z.ZodObject<{
150
159
  } | {
151
160
  value: string;
152
161
  type: "sha256";
162
+ } | {
163
+ value: string;
164
+ type: "path";
153
165
  };
154
- key: "git_branch" | "git_head_sha" | "repo_root_hash";
166
+ key: "git_branch" | "git_head_sha" | "repo_root_hash" | "repo_root";
155
167
  confidence: "high" | "low" | "med";
156
168
  }, {
157
169
  value: {
@@ -163,8 +175,11 @@ export declare const SessionContentsV1Schema: z.ZodObject<{
163
175
  } | {
164
176
  value: string;
165
177
  type: "sha256";
178
+ } | {
179
+ value: string;
180
+ type: "path";
166
181
  };
167
- key: "git_branch" | "git_head_sha" | "repo_root_hash";
182
+ key: "git_branch" | "git_head_sha" | "repo_root_hash" | "repo_root";
168
183
  confidence: "high" | "low" | "med";
169
184
  }>;
170
185
  }, "strip", z.ZodTypeAny, {
@@ -180,8 +195,11 @@ export declare const SessionContentsV1Schema: z.ZodObject<{
180
195
  } | {
181
196
  value: string;
182
197
  type: "sha256";
198
+ } | {
199
+ value: string;
200
+ type: "path";
183
201
  };
184
- key: "git_branch" | "git_head_sha" | "repo_root_hash";
202
+ key: "git_branch" | "git_head_sha" | "repo_root_hash" | "repo_root";
185
203
  confidence: "high" | "low" | "med";
186
204
  };
187
205
  v: 1;
@@ -202,8 +220,11 @@ export declare const SessionContentsV1Schema: z.ZodObject<{
202
220
  } | {
203
221
  value: string;
204
222
  type: "sha256";
223
+ } | {
224
+ value: string;
225
+ type: "path";
205
226
  };
206
- key: "git_branch" | "git_head_sha" | "repo_root_hash";
227
+ key: "git_branch" | "git_head_sha" | "repo_root_hash" | "repo_root";
207
228
  confidence: "high" | "low" | "med";
208
229
  };
209
230
  v: 1;
@@ -4727,8 +4748,11 @@ export declare const SessionContentsV1Schema: z.ZodObject<{
4727
4748
  } | {
4728
4749
  value: string;
4729
4750
  type: "sha256";
4751
+ } | {
4752
+ value: string;
4753
+ type: "path";
4730
4754
  };
4731
- key: "git_branch" | "git_head_sha" | "repo_root_hash";
4755
+ key: "git_branch" | "git_head_sha" | "repo_root_hash" | "repo_root";
4732
4756
  confidence: "high" | "low" | "med";
4733
4757
  };
4734
4758
  v: 1;
@@ -5300,8 +5324,11 @@ export declare const SessionContentsV1Schema: z.ZodObject<{
5300
5324
  } | {
5301
5325
  value: string;
5302
5326
  type: "sha256";
5327
+ } | {
5328
+ value: string;
5329
+ type: "path";
5303
5330
  };
5304
- key: "git_branch" | "git_head_sha" | "repo_root_hash";
5331
+ key: "git_branch" | "git_head_sha" | "repo_root_hash" | "repo_root";
5305
5332
  confidence: "high" | "low" | "med";
5306
5333
  };
5307
5334
  v: 1;
@@ -5791,7 +5818,7 @@ export declare const ExportBundleV1Schema: z.ZodObject<{
5791
5818
  kind: z.ZodLiteral<"observation_recorded">;
5792
5819
  scope: z.ZodUndefined;
5793
5820
  data: z.ZodObject<{
5794
- key: z.ZodEnum<["git_branch", "git_head_sha", "repo_root_hash"]>;
5821
+ key: z.ZodEnum<["git_branch", "git_head_sha", "repo_root_hash", "repo_root"]>;
5795
5822
  value: z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
5796
5823
  type: z.ZodLiteral<"short_string">;
5797
5824
  value: z.ZodString;
@@ -5819,6 +5846,15 @@ export declare const ExportBundleV1Schema: z.ZodObject<{
5819
5846
  }, {
5820
5847
  value: string;
5821
5848
  type: "sha256";
5849
+ }>, z.ZodObject<{
5850
+ type: z.ZodLiteral<"path">;
5851
+ value: z.ZodString;
5852
+ }, "strip", z.ZodTypeAny, {
5853
+ value: string;
5854
+ type: "path";
5855
+ }, {
5856
+ value: string;
5857
+ type: "path";
5822
5858
  }>]>;
5823
5859
  confidence: z.ZodEnum<["low", "med", "high"]>;
5824
5860
  }, "strip", z.ZodTypeAny, {
@@ -5831,8 +5867,11 @@ export declare const ExportBundleV1Schema: z.ZodObject<{
5831
5867
  } | {
5832
5868
  value: string;
5833
5869
  type: "sha256";
5870
+ } | {
5871
+ value: string;
5872
+ type: "path";
5834
5873
  };
5835
- key: "git_branch" | "git_head_sha" | "repo_root_hash";
5874
+ key: "git_branch" | "git_head_sha" | "repo_root_hash" | "repo_root";
5836
5875
  confidence: "high" | "low" | "med";
5837
5876
  }, {
5838
5877
  value: {
@@ -5844,8 +5883,11 @@ export declare const ExportBundleV1Schema: z.ZodObject<{
5844
5883
  } | {
5845
5884
  value: string;
5846
5885
  type: "sha256";
5886
+ } | {
5887
+ value: string;
5888
+ type: "path";
5847
5889
  };
5848
- key: "git_branch" | "git_head_sha" | "repo_root_hash";
5890
+ key: "git_branch" | "git_head_sha" | "repo_root_hash" | "repo_root";
5849
5891
  confidence: "high" | "low" | "med";
5850
5892
  }>;
5851
5893
  }, "strip", z.ZodTypeAny, {
@@ -5861,8 +5903,11 @@ export declare const ExportBundleV1Schema: z.ZodObject<{
5861
5903
  } | {
5862
5904
  value: string;
5863
5905
  type: "sha256";
5906
+ } | {
5907
+ value: string;
5908
+ type: "path";
5864
5909
  };
5865
- key: "git_branch" | "git_head_sha" | "repo_root_hash";
5910
+ key: "git_branch" | "git_head_sha" | "repo_root_hash" | "repo_root";
5866
5911
  confidence: "high" | "low" | "med";
5867
5912
  };
5868
5913
  v: 1;
@@ -5883,8 +5928,11 @@ export declare const ExportBundleV1Schema: z.ZodObject<{
5883
5928
  } | {
5884
5929
  value: string;
5885
5930
  type: "sha256";
5931
+ } | {
5932
+ value: string;
5933
+ type: "path";
5886
5934
  };
5887
- key: "git_branch" | "git_head_sha" | "repo_root_hash";
5935
+ key: "git_branch" | "git_head_sha" | "repo_root_hash" | "repo_root";
5888
5936
  confidence: "high" | "low" | "med";
5889
5937
  };
5890
5938
  v: 1;
@@ -10408,8 +10456,11 @@ export declare const ExportBundleV1Schema: z.ZodObject<{
10408
10456
  } | {
10409
10457
  value: string;
10410
10458
  type: "sha256";
10459
+ } | {
10460
+ value: string;
10461
+ type: "path";
10411
10462
  };
10412
- key: "git_branch" | "git_head_sha" | "repo_root_hash";
10463
+ key: "git_branch" | "git_head_sha" | "repo_root_hash" | "repo_root";
10413
10464
  confidence: "high" | "low" | "med";
10414
10465
  };
10415
10466
  v: 1;
@@ -10981,8 +11032,11 @@ export declare const ExportBundleV1Schema: z.ZodObject<{
10981
11032
  } | {
10982
11033
  value: string;
10983
11034
  type: "sha256";
11035
+ } | {
11036
+ value: string;
11037
+ type: "path";
10984
11038
  };
10985
- key: "git_branch" | "git_head_sha" | "repo_root_hash";
11039
+ key: "git_branch" | "git_head_sha" | "repo_root_hash" | "repo_root";
10986
11040
  confidence: "high" | "low" | "med";
10987
11041
  };
10988
11042
  v: 1;
@@ -11583,8 +11637,11 @@ export declare const ExportBundleV1Schema: z.ZodObject<{
11583
11637
  } | {
11584
11638
  value: string;
11585
11639
  type: "sha256";
11640
+ } | {
11641
+ value: string;
11642
+ type: "path";
11586
11643
  };
11587
- key: "git_branch" | "git_head_sha" | "repo_root_hash";
11644
+ key: "git_branch" | "git_head_sha" | "repo_root_hash" | "repo_root";
11588
11645
  confidence: "high" | "low" | "med";
11589
11646
  };
11590
11647
  v: 1;
@@ -12173,8 +12230,11 @@ export declare const ExportBundleV1Schema: z.ZodObject<{
12173
12230
  } | {
12174
12231
  value: string;
12175
12232
  type: "sha256";
12233
+ } | {
12234
+ value: string;
12235
+ type: "path";
12176
12236
  };
12177
- key: "git_branch" | "git_head_sha" | "repo_root_hash";
12237
+ key: "git_branch" | "git_head_sha" | "repo_root_hash" | "repo_root";
12178
12238
  confidence: "high" | "low" | "med";
12179
12239
  };
12180
12240
  v: 1;
@@ -95,7 +95,7 @@ export declare const DomainEventV1Schema: z.ZodDiscriminatedUnion<"kind", [z.Zod
95
95
  kind: z.ZodLiteral<"observation_recorded">;
96
96
  scope: z.ZodUndefined;
97
97
  data: z.ZodObject<{
98
- key: z.ZodEnum<["git_branch", "git_head_sha", "repo_root_hash"]>;
98
+ key: z.ZodEnum<["git_branch", "git_head_sha", "repo_root_hash", "repo_root"]>;
99
99
  value: z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
100
100
  type: z.ZodLiteral<"short_string">;
101
101
  value: z.ZodString;
@@ -123,6 +123,15 @@ export declare const DomainEventV1Schema: z.ZodDiscriminatedUnion<"kind", [z.Zod
123
123
  }, {
124
124
  value: string;
125
125
  type: "sha256";
126
+ }>, z.ZodObject<{
127
+ type: z.ZodLiteral<"path">;
128
+ value: z.ZodString;
129
+ }, "strip", z.ZodTypeAny, {
130
+ value: string;
131
+ type: "path";
132
+ }, {
133
+ value: string;
134
+ type: "path";
126
135
  }>]>;
127
136
  confidence: z.ZodEnum<["low", "med", "high"]>;
128
137
  }, "strip", z.ZodTypeAny, {
@@ -135,8 +144,11 @@ export declare const DomainEventV1Schema: z.ZodDiscriminatedUnion<"kind", [z.Zod
135
144
  } | {
136
145
  value: string;
137
146
  type: "sha256";
147
+ } | {
148
+ value: string;
149
+ type: "path";
138
150
  };
139
- key: "git_branch" | "git_head_sha" | "repo_root_hash";
151
+ key: "git_branch" | "git_head_sha" | "repo_root_hash" | "repo_root";
140
152
  confidence: "high" | "low" | "med";
141
153
  }, {
142
154
  value: {
@@ -148,8 +160,11 @@ export declare const DomainEventV1Schema: z.ZodDiscriminatedUnion<"kind", [z.Zod
148
160
  } | {
149
161
  value: string;
150
162
  type: "sha256";
163
+ } | {
164
+ value: string;
165
+ type: "path";
151
166
  };
152
- key: "git_branch" | "git_head_sha" | "repo_root_hash";
167
+ key: "git_branch" | "git_head_sha" | "repo_root_hash" | "repo_root";
153
168
  confidence: "high" | "low" | "med";
154
169
  }>;
155
170
  }, "strip", z.ZodTypeAny, {
@@ -165,8 +180,11 @@ export declare const DomainEventV1Schema: z.ZodDiscriminatedUnion<"kind", [z.Zod
165
180
  } | {
166
181
  value: string;
167
182
  type: "sha256";
183
+ } | {
184
+ value: string;
185
+ type: "path";
168
186
  };
169
- key: "git_branch" | "git_head_sha" | "repo_root_hash";
187
+ key: "git_branch" | "git_head_sha" | "repo_root_hash" | "repo_root";
170
188
  confidence: "high" | "low" | "med";
171
189
  };
172
190
  v: 1;
@@ -187,8 +205,11 @@ export declare const DomainEventV1Schema: z.ZodDiscriminatedUnion<"kind", [z.Zod
187
205
  } | {
188
206
  value: string;
189
207
  type: "sha256";
208
+ } | {
209
+ value: string;
210
+ type: "path";
190
211
  };
191
- key: "git_branch" | "git_head_sha" | "repo_root_hash";
212
+ key: "git_branch" | "git_head_sha" | "repo_root_hash" | "repo_root";
192
213
  confidence: "high" | "low" | "med";
193
214
  };
194
215
  v: 1;
@@ -107,11 +107,12 @@ exports.DomainEventV1Schema = zod_1.z.discriminatedUnion('kind', [
107
107
  kind: zod_1.z.literal('observation_recorded'),
108
108
  scope: zod_1.z.undefined(),
109
109
  data: zod_1.z.object({
110
- key: zod_1.z.enum(['git_branch', 'git_head_sha', 'repo_root_hash']),
110
+ key: zod_1.z.enum(['git_branch', 'git_head_sha', 'repo_root_hash', 'repo_root']),
111
111
  value: zod_1.z.discriminatedUnion('type', [
112
112
  zod_1.z.object({ type: zod_1.z.literal('short_string'), value: zod_1.z.string().min(1).max(constants_js_1.MAX_OBSERVATION_SHORT_STRING_LENGTH) }),
113
113
  zod_1.z.object({ type: zod_1.z.literal('git_sha1'), value: zod_1.z.string().regex(/^[0-9a-f]{40}$/) }),
114
114
  zod_1.z.object({ type: zod_1.z.literal('sha256'), value: sha256DigestSchema }),
115
+ zod_1.z.object({ type: zod_1.z.literal('path'), value: zod_1.z.string().min(1).max(constants_js_1.MAX_OBSERVATION_PATH_LENGTH) }),
115
116
  ]),
116
117
  confidence: zod_1.z.enum(['low', 'med', 'high']),
117
118
  }),
@@ -0,0 +1,8 @@
1
+ import type { ResultAsync } from 'neverthrow';
2
+ import type { ManagedSourceRecordV2, ManagedSourceStoreError, ManagedSourceStorePortV2 } from '../../../ports/managed-source-store.port.js';
3
+ export declare class InMemoryManagedSourceStoreV2 implements ManagedSourceStorePortV2 {
4
+ private readonly sources;
5
+ list(): ResultAsync<readonly ManagedSourceRecordV2[], ManagedSourceStoreError>;
6
+ attach(sourcePath: string): ResultAsync<void, ManagedSourceStoreError>;
7
+ detach(sourcePath: string): ResultAsync<void, ManagedSourceStoreError>;
8
+ }
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.InMemoryManagedSourceStoreV2 = void 0;
7
+ const path_1 = __importDefault(require("path"));
8
+ const neverthrow_1 = require("neverthrow");
9
+ class InMemoryManagedSourceStoreV2 {
10
+ constructor() {
11
+ this.sources = [];
12
+ }
13
+ list() {
14
+ return (0, neverthrow_1.okAsync)([...this.sources]);
15
+ }
16
+ attach(sourcePath) {
17
+ const normalizedPath = path_1.default.resolve(sourcePath);
18
+ const alreadyPresent = this.sources.some((s) => s.path === normalizedPath);
19
+ if (!alreadyPresent) {
20
+ this.sources.push({ path: normalizedPath, addedAtMs: Date.now() });
21
+ }
22
+ return (0, neverthrow_1.okAsync)(undefined);
23
+ }
24
+ detach(sourcePath) {
25
+ const normalizedPath = path_1.default.resolve(sourcePath);
26
+ const index = this.sources.findIndex((s) => s.path === normalizedPath);
27
+ if (index !== -1) {
28
+ this.sources.splice(index, 1);
29
+ }
30
+ return (0, neverthrow_1.okAsync)(undefined);
31
+ }
32
+ }
33
+ exports.InMemoryManagedSourceStoreV2 = InMemoryManagedSourceStoreV2;
@@ -19,4 +19,6 @@ export declare class LocalDataDirV2 implements DataDirPortV2 {
19
19
  sessionManifestPath(sessionId: SessionId): string;
20
20
  sessionLockPath(sessionId: SessionId): string;
21
21
  tokenIndexPath(): string;
22
+ managedSourcesPath(): string;
23
+ managedSourcesLockPath(): string;
22
24
  }
@@ -89,5 +89,11 @@ class LocalDataDirV2 {
89
89
  tokenIndexPath() {
90
90
  return path.join(this.keysDir(), 'token-index.jsonl');
91
91
  }
92
+ managedSourcesPath() {
93
+ return path.join(this.root(), 'managed-sources', 'managed-sources.json');
94
+ }
95
+ managedSourcesLockPath() {
96
+ return path.join(this.root(), 'managed-sources', 'managed-sources.lock');
97
+ }
92
98
  }
93
99
  exports.LocalDataDirV2 = LocalDataDirV2;
@@ -0,0 +1,15 @@
1
+ import type { ResultAsync } from 'neverthrow';
2
+ import type { DataDirPortV2 } from '../../../ports/data-dir.port.js';
3
+ import type { FileSystemPortV2 } from '../../../ports/fs.port.js';
4
+ import type { ManagedSourceRecordV2, ManagedSourceStoreError, ManagedSourceStorePortV2 } from '../../../ports/managed-source-store.port.js';
5
+ export declare class LocalManagedSourceStoreV2 implements ManagedSourceStorePortV2 {
6
+ private readonly dataDir;
7
+ private readonly fs;
8
+ constructor(dataDir: DataDirPortV2, fs: FileSystemPortV2);
9
+ list(): ResultAsync<readonly ManagedSourceRecordV2[], ManagedSourceStoreError>;
10
+ attach(sourcePath: string): ResultAsync<void, ManagedSourceStoreError>;
11
+ detach(sourcePath: string): ResultAsync<void, ManagedSourceStoreError>;
12
+ private readSources;
13
+ private persist;
14
+ private withLock;
15
+ }