cyrus-edge-worker 0.0.37 → 0.0.39

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 (45) hide show
  1. package/dist/AgentSessionManager.d.ts +26 -1
  2. package/dist/AgentSessionManager.d.ts.map +1 -1
  3. package/dist/AgentSessionManager.js +227 -30
  4. package/dist/AgentSessionManager.js.map +1 -1
  5. package/dist/EdgeWorker.d.ts +4 -3
  6. package/dist/EdgeWorker.d.ts.map +1 -1
  7. package/dist/EdgeWorker.js +191 -25
  8. package/dist/EdgeWorker.js.map +1 -1
  9. package/dist/SharedApplicationServer.d.ts +29 -4
  10. package/dist/SharedApplicationServer.d.ts.map +1 -1
  11. package/dist/SharedApplicationServer.js +262 -0
  12. package/dist/SharedApplicationServer.js.map +1 -1
  13. package/dist/index.d.ts +2 -3
  14. package/dist/index.d.ts.map +1 -1
  15. package/dist/index.js.map +1 -1
  16. package/dist/procedures/ProcedureRouter.d.ts +60 -0
  17. package/dist/procedures/ProcedureRouter.d.ts.map +1 -0
  18. package/dist/procedures/ProcedureRouter.js +201 -0
  19. package/dist/procedures/ProcedureRouter.js.map +1 -0
  20. package/dist/procedures/index.d.ts +7 -0
  21. package/dist/procedures/index.d.ts.map +1 -0
  22. package/dist/procedures/index.js +7 -0
  23. package/dist/procedures/index.js.map +1 -0
  24. package/dist/procedures/registry.d.ts +76 -0
  25. package/dist/procedures/registry.d.ts.map +1 -0
  26. package/dist/procedures/registry.js +130 -0
  27. package/dist/procedures/registry.js.map +1 -0
  28. package/dist/procedures/types.d.ts +64 -0
  29. package/dist/procedures/types.d.ts.map +1 -0
  30. package/dist/procedures/types.js +5 -0
  31. package/dist/procedures/types.js.map +1 -0
  32. package/dist/prompts/subroutines/concise-summary.md +53 -0
  33. package/dist/prompts/subroutines/debugger-fix.md +108 -0
  34. package/dist/prompts/subroutines/debugger-reproduction.md +106 -0
  35. package/dist/prompts/subroutines/get-approval.md +175 -0
  36. package/dist/prompts/subroutines/git-gh.md +52 -0
  37. package/dist/prompts/subroutines/verbose-summary.md +46 -0
  38. package/dist/prompts/subroutines/verifications.md +46 -0
  39. package/dist/types.d.ts +0 -97
  40. package/dist/types.d.ts.map +1 -1
  41. package/package.json +8 -6
  42. package/prompt-template-v2.md +3 -19
  43. package/prompts/builder.md +1 -23
  44. package/prompts/debugger.md +11 -174
  45. package/prompts/orchestrator.md +41 -64
@@ -0,0 +1,201 @@
1
+ /**
2
+ * ProcedureRouter - Intelligent routing of agent sessions through procedures
3
+ *
4
+ * Uses SimpleClaudeRunner to analyze requests and determine which procedure
5
+ * (sequence of subroutines) should be executed.
6
+ */
7
+ import { SimpleClaudeRunner } from "cyrus-simple-agent-runner";
8
+ import { getProcedureForClassification, PROCEDURES } from "./registry.js";
9
+ export class ProcedureRouter {
10
+ routingRunner;
11
+ procedures = new Map();
12
+ constructor(config) {
13
+ // Initialize SimpleClaudeRunner for routing decisions
14
+ this.routingRunner = new SimpleClaudeRunner({
15
+ validResponses: [
16
+ "question",
17
+ "documentation",
18
+ "transient",
19
+ "code",
20
+ "debugger",
21
+ "orchestrator",
22
+ ],
23
+ cyrusHome: config.cyrusHome,
24
+ model: config.model || "haiku",
25
+ fallbackModel: "sonnet",
26
+ systemPrompt: this.buildRoutingSystemPrompt(),
27
+ maxTurns: 1,
28
+ timeoutMs: config.timeoutMs || 10000,
29
+ });
30
+ // Load all predefined procedures from registry
31
+ this.loadPredefinedProcedures();
32
+ }
33
+ /**
34
+ * Build the system prompt for routing classification
35
+ */
36
+ buildRoutingSystemPrompt() {
37
+ return `You are a request classifier for a software agent system.
38
+
39
+ Analyze the Linear issue request and classify it into ONE of these categories:
40
+
41
+ **question**: User is asking a question, seeking information, or requesting explanation.
42
+ - Examples: "How does X work?", "What is the purpose of Y?", "Explain the architecture"
43
+
44
+ **documentation**: User wants documentation, markdown, or comments edited (no code changes).
45
+ - Examples: "Update the README", "Add docstrings to functions", "Fix typos in docs"
46
+
47
+ **transient**: Request involves MCP tools, temporary files, or no codebase interaction.
48
+ - Examples: "Search the web for X", "Generate a diagram", "Use Linear MCP to check issues"
49
+
50
+ **debugger**: User EXPLICITLY requests the full debugging workflow with reproduction and approval.
51
+ - ONLY use this if the user specifically asks for: "debug this with approval workflow", "reproduce the bug first", "show me the root cause before fixing"
52
+ - DO NOT use for regular bug reports - those should use "code"
53
+ - Examples: "Debug this issue and get my approval before fixing", "Reproduce the authentication bug with approval checkpoint"
54
+
55
+ **orchestrator**: User EXPLICITLY requests decomposition into sub-issues with specialized agent delegation.
56
+ - ONLY use this if the user specifically asks for: "break this into sub-issues", "orchestrate this work", "use sub-agents", "delegate to specialized agents"
57
+ - DO NOT use for regular complex work - those should use "code"
58
+ - Examples: "Orchestrate this feature with sub-issues", "Break this down and delegate to specialized agents", "Create sub-tasks for this epic"
59
+
60
+ **code**: Request involves code changes, features, bugs, or refactoring (DEFAULT for most work).
61
+ - Examples: "Fix bug in X", "Add feature Y", "Refactor module Z", "Implement new API endpoint", "Fix the login issue"
62
+ - Use this for ALL standard bug fixes and features
63
+
64
+ IMPORTANT: Respond with ONLY the classification word, nothing else.`;
65
+ }
66
+ /**
67
+ * Load predefined procedures from registry
68
+ */
69
+ loadPredefinedProcedures() {
70
+ for (const [name, procedure] of Object.entries(PROCEDURES)) {
71
+ this.procedures.set(name, procedure);
72
+ }
73
+ }
74
+ /**
75
+ * Determine which procedure to use for a given request
76
+ */
77
+ async determineRoutine(requestText) {
78
+ try {
79
+ // Classify the request using SimpleClaudeRunner
80
+ const result = await this.routingRunner.query(`Classify this Linear issue request:\n\n${requestText}`);
81
+ const classification = result.response;
82
+ // Get procedure name for this classification
83
+ const procedureName = getProcedureForClassification(classification);
84
+ // Get procedure definition
85
+ const procedure = this.procedures.get(procedureName);
86
+ if (!procedure) {
87
+ throw new Error(`Procedure "${procedureName}" not found in registry`);
88
+ }
89
+ return {
90
+ classification,
91
+ procedure,
92
+ reasoning: `Classified as "${classification}" → using procedure "${procedureName}"`,
93
+ };
94
+ }
95
+ catch (error) {
96
+ // Fallback to full-development on error
97
+ console.error("[ProcedureRouter] Error during routing decision:", error);
98
+ const fallbackProcedure = this.procedures.get("full-development");
99
+ if (!fallbackProcedure) {
100
+ throw new Error("Fallback procedure 'full-development' not found");
101
+ }
102
+ return {
103
+ classification: "code",
104
+ procedure: fallbackProcedure,
105
+ reasoning: `Fallback to full-development due to error: ${error}`,
106
+ };
107
+ }
108
+ }
109
+ /**
110
+ * Get the next subroutine for a session
111
+ * Returns null if procedure is complete
112
+ */
113
+ getNextSubroutine(session) {
114
+ const procedureMetadata = session.metadata?.procedure;
115
+ if (!procedureMetadata) {
116
+ // No procedure metadata - session doesn't use procedure routing
117
+ return null;
118
+ }
119
+ const procedure = this.procedures.get(procedureMetadata.procedureName);
120
+ if (!procedure) {
121
+ console.error(`[ProcedureRouter] Procedure "${procedureMetadata.procedureName}" not found`);
122
+ return null;
123
+ }
124
+ const nextIndex = procedureMetadata.currentSubroutineIndex + 1;
125
+ if (nextIndex >= procedure.subroutines.length) {
126
+ // Procedure complete
127
+ return null;
128
+ }
129
+ return procedure.subroutines[nextIndex] ?? null;
130
+ }
131
+ /**
132
+ * Get the current subroutine for a session
133
+ */
134
+ getCurrentSubroutine(session) {
135
+ const procedureMetadata = session.metadata?.procedure;
136
+ if (!procedureMetadata) {
137
+ return null;
138
+ }
139
+ const procedure = this.procedures.get(procedureMetadata.procedureName);
140
+ if (!procedure) {
141
+ return null;
142
+ }
143
+ const currentIndex = procedureMetadata.currentSubroutineIndex;
144
+ if (currentIndex < 0 || currentIndex >= procedure.subroutines.length) {
145
+ return null;
146
+ }
147
+ return procedure.subroutines[currentIndex] ?? null;
148
+ }
149
+ /**
150
+ * Initialize procedure metadata for a new session
151
+ */
152
+ initializeProcedureMetadata(session, procedure) {
153
+ if (!session.metadata) {
154
+ session.metadata = {};
155
+ }
156
+ session.metadata.procedure = {
157
+ procedureName: procedure.name,
158
+ currentSubroutineIndex: 0,
159
+ subroutineHistory: [],
160
+ };
161
+ }
162
+ /**
163
+ * Record subroutine completion and advance to next
164
+ */
165
+ advanceToNextSubroutine(session, claudeSessionId) {
166
+ const procedureMetadata = session.metadata?.procedure;
167
+ if (!procedureMetadata) {
168
+ throw new Error("Cannot advance: session has no procedure metadata");
169
+ }
170
+ const currentSubroutine = this.getCurrentSubroutine(session);
171
+ if (currentSubroutine) {
172
+ // Record completion
173
+ procedureMetadata.subroutineHistory.push({
174
+ subroutine: currentSubroutine.name,
175
+ completedAt: Date.now(),
176
+ claudeSessionId,
177
+ });
178
+ }
179
+ // Advance index
180
+ procedureMetadata.currentSubroutineIndex++;
181
+ }
182
+ /**
183
+ * Check if procedure is complete
184
+ */
185
+ isProcedureComplete(session) {
186
+ return this.getNextSubroutine(session) === null;
187
+ }
188
+ /**
189
+ * Register a custom procedure
190
+ */
191
+ registerProcedure(procedure) {
192
+ this.procedures.set(procedure.name, procedure);
193
+ }
194
+ /**
195
+ * Get procedure by name
196
+ */
197
+ getProcedure(name) {
198
+ return this.procedures.get(name);
199
+ }
200
+ }
201
+ //# sourceMappingURL=ProcedureRouter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ProcedureRouter.js","sourceRoot":"","sources":["../../src/procedures/ProcedureRouter.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,EAAE,6BAA6B,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAe1E,MAAM,OAAO,eAAe;IACnB,aAAa,CAA4C;IACzD,UAAU,GAAqC,IAAI,GAAG,EAAE,CAAC;IAEjE,YAAY,MAA6B;QACxC,sDAAsD;QACtD,IAAI,CAAC,aAAa,GAAG,IAAI,kBAAkB,CAAC;YAC3C,cAAc,EAAE;gBACf,UAAU;gBACV,eAAe;gBACf,WAAW;gBACX,MAAM;gBACN,UAAU;gBACV,cAAc;aACd;YACD,SAAS,EAAE,MAAM,CAAC,SAAS;YAC3B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E,IAAI,CAAC,GAAG,EAAE;gBACvB,eAAe;aACf,CAAC,CAAC;QACJ,CAAC;QAED,gBAAgB;QAChB,iBAAiB,CAAC,sBAAsB,EAAE,CAAC;IAC5C,CAAC;IAED;;OAEG;IACH,mBAAmB,CAAC,OAA0B;QAC7C,OAAO,IAAI,CAAC,iBAAiB,CAAC,OAAO,CAAC,KAAK,IAAI,CAAC;IACjD,CAAC;IAED;;OAEG;IACH,iBAAiB,CAAC,SAA8B;QAC/C,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,SAAS,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;IAChD,CAAC;IAED;;OAEG;IACH,YAAY,CAAC,IAAY;QACxB,OAAO,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IAClC,CAAC;CACD"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Procedure routing system for intelligent workflow selection
3
+ */
4
+ export * from "./ProcedureRouter.js";
5
+ export * from "./registry.js";
6
+ export * from "./types.js";
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/procedures/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,cAAc,sBAAsB,CAAC;AACrC,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Procedure routing system for intelligent workflow selection
3
+ */
4
+ export * from "./ProcedureRouter.js";
5
+ export * from "./registry.js";
6
+ export * from "./types.js";
7
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/procedures/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,cAAc,sBAAsB,CAAC;AACrC,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC"}
@@ -0,0 +1,76 @@
1
+ /**
2
+ * Registry of predefined procedures and routing rules
3
+ */
4
+ import type { ProcedureDefinition, RequestClassification } from "./types.js";
5
+ /**
6
+ * Predefined subroutine definitions
7
+ */
8
+ export declare const SUBROUTINES: {
9
+ readonly primary: {
10
+ readonly name: "primary";
11
+ readonly promptPath: "primary";
12
+ readonly description: "Main work execution phase";
13
+ };
14
+ readonly debuggerReproduction: {
15
+ readonly name: "debugger-reproduction";
16
+ readonly promptPath: "subroutines/debugger-reproduction.md";
17
+ readonly description: "Reproduce bug and perform root cause analysis";
18
+ };
19
+ readonly getApproval: {
20
+ readonly name: "get-approval";
21
+ readonly promptPath: "subroutines/get-approval.md";
22
+ readonly description: "Request user approval before proceeding";
23
+ readonly maxTurns: 1;
24
+ readonly requiresApproval: true;
25
+ };
26
+ readonly debuggerFix: {
27
+ readonly name: "debugger-fix";
28
+ readonly promptPath: "subroutines/debugger-fix.md";
29
+ readonly description: "Implement minimal fix based on approved reproduction";
30
+ };
31
+ readonly verifications: {
32
+ readonly name: "verifications";
33
+ readonly promptPath: "subroutines/verifications.md";
34
+ readonly description: "Run tests, linting, and type checking";
35
+ };
36
+ readonly gitGh: {
37
+ readonly name: "git-gh";
38
+ readonly promptPath: "subroutines/git-gh.md";
39
+ readonly description: "Commit changes and create/update PR";
40
+ };
41
+ readonly conciseSummary: {
42
+ readonly name: "concise-summary";
43
+ readonly promptPath: "subroutines/concise-summary.md";
44
+ readonly maxTurns: 1;
45
+ readonly description: "Brief summary for simple requests";
46
+ readonly suppressThoughtPosting: true;
47
+ };
48
+ readonly verboseSummary: {
49
+ readonly name: "verbose-summary";
50
+ readonly promptPath: "subroutines/verbose-summary.md";
51
+ readonly maxTurns: 1;
52
+ readonly description: "Detailed summary with implementation details";
53
+ readonly suppressThoughtPosting: true;
54
+ };
55
+ };
56
+ /**
57
+ * Predefined procedure definitions
58
+ */
59
+ export declare const PROCEDURES: Record<string, ProcedureDefinition>;
60
+ /**
61
+ * Mapping from request classification to procedure name
62
+ */
63
+ export declare const CLASSIFICATION_TO_PROCEDURE: Record<RequestClassification, string>;
64
+ /**
65
+ * Get a procedure definition by name
66
+ */
67
+ export declare function getProcedure(name: string): ProcedureDefinition | undefined;
68
+ /**
69
+ * Get procedure name for a given classification
70
+ */
71
+ export declare function getProcedureForClassification(classification: RequestClassification): string;
72
+ /**
73
+ * Get all available procedure names
74
+ */
75
+ export declare function getAllProcedureNames(): string[];
76
+ //# sourceMappingURL=registry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../src/procedures/registry.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,mBAAmB,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAE7E;;GAEG;AACH,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA+Cd,CAAC;AAEX;;GAEG;AACH,eAAO,MAAM,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,mBAAmB,CAiD1D,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,2BAA2B,EAAE,MAAM,CAC/C,qBAAqB,EACrB,MAAM,CAQN,CAAC;AAEF;;GAEG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,mBAAmB,GAAG,SAAS,CAE1E;AAED;;GAEG;AACH,wBAAgB,6BAA6B,CAC5C,cAAc,EAAE,qBAAqB,GACnC,MAAM,CAER;AAED;;GAEG;AACH,wBAAgB,oBAAoB,IAAI,MAAM,EAAE,CAE/C"}
@@ -0,0 +1,130 @@
1
+ /**
2
+ * Registry of predefined procedures and routing rules
3
+ */
4
+ /**
5
+ * Predefined subroutine definitions
6
+ */
7
+ export const SUBROUTINES = {
8
+ primary: {
9
+ name: "primary",
10
+ promptPath: "primary", // Special: resolved via label (debugger/builder/scoper/orchestrator)
11
+ description: "Main work execution phase",
12
+ },
13
+ debuggerReproduction: {
14
+ name: "debugger-reproduction",
15
+ promptPath: "subroutines/debugger-reproduction.md",
16
+ description: "Reproduce bug and perform root cause analysis",
17
+ },
18
+ getApproval: {
19
+ name: "get-approval",
20
+ promptPath: "subroutines/get-approval.md",
21
+ description: "Request user approval before proceeding",
22
+ maxTurns: 1,
23
+ requiresApproval: true, // Flag to trigger approval workflow
24
+ },
25
+ debuggerFix: {
26
+ name: "debugger-fix",
27
+ promptPath: "subroutines/debugger-fix.md",
28
+ description: "Implement minimal fix based on approved reproduction",
29
+ },
30
+ verifications: {
31
+ name: "verifications",
32
+ promptPath: "subroutines/verifications.md",
33
+ description: "Run tests, linting, and type checking",
34
+ },
35
+ gitGh: {
36
+ name: "git-gh",
37
+ promptPath: "subroutines/git-gh.md",
38
+ description: "Commit changes and create/update PR",
39
+ },
40
+ conciseSummary: {
41
+ name: "concise-summary",
42
+ promptPath: "subroutines/concise-summary.md",
43
+ maxTurns: 1,
44
+ description: "Brief summary for simple requests",
45
+ suppressThoughtPosting: true,
46
+ },
47
+ verboseSummary: {
48
+ name: "verbose-summary",
49
+ promptPath: "subroutines/verbose-summary.md",
50
+ maxTurns: 1,
51
+ description: "Detailed summary with implementation details",
52
+ suppressThoughtPosting: true,
53
+ },
54
+ };
55
+ /**
56
+ * Predefined procedure definitions
57
+ */
58
+ export const PROCEDURES = {
59
+ "simple-question": {
60
+ name: "simple-question",
61
+ description: "For questions or requests that don't modify the codebase",
62
+ subroutines: [SUBROUTINES.primary, SUBROUTINES.conciseSummary],
63
+ },
64
+ "documentation-edit": {
65
+ name: "documentation-edit",
66
+ description: "For documentation/markdown edits that don't require verification",
67
+ subroutines: [
68
+ SUBROUTINES.primary,
69
+ SUBROUTINES.gitGh,
70
+ SUBROUTINES.conciseSummary,
71
+ ],
72
+ },
73
+ "full-development": {
74
+ name: "full-development",
75
+ description: "For code changes requiring full verification and PR creation",
76
+ subroutines: [
77
+ SUBROUTINES.primary,
78
+ SUBROUTINES.verifications,
79
+ SUBROUTINES.gitGh,
80
+ SUBROUTINES.verboseSummary,
81
+ ],
82
+ },
83
+ "debugger-full": {
84
+ name: "debugger-full",
85
+ description: "Full debugging workflow with reproduction, approval, fix, and verification",
86
+ subroutines: [
87
+ SUBROUTINES.debuggerReproduction,
88
+ SUBROUTINES.getApproval,
89
+ SUBROUTINES.debuggerFix,
90
+ SUBROUTINES.verifications,
91
+ SUBROUTINES.gitGh,
92
+ SUBROUTINES.verboseSummary,
93
+ ],
94
+ },
95
+ "orchestrator-full": {
96
+ name: "orchestrator-full",
97
+ description: "Full orchestration workflow with decomposition and delegation to sub-agents",
98
+ subroutines: [SUBROUTINES.primary, SUBROUTINES.verboseSummary],
99
+ },
100
+ };
101
+ /**
102
+ * Mapping from request classification to procedure name
103
+ */
104
+ export const CLASSIFICATION_TO_PROCEDURE = {
105
+ question: "simple-question",
106
+ documentation: "documentation-edit",
107
+ transient: "simple-question",
108
+ code: "full-development",
109
+ debugger: "debugger-full",
110
+ orchestrator: "orchestrator-full",
111
+ };
112
+ /**
113
+ * Get a procedure definition by name
114
+ */
115
+ export function getProcedure(name) {
116
+ return PROCEDURES[name];
117
+ }
118
+ /**
119
+ * Get procedure name for a given classification
120
+ */
121
+ export function getProcedureForClassification(classification) {
122
+ return CLASSIFICATION_TO_PROCEDURE[classification];
123
+ }
124
+ /**
125
+ * Get all available procedure names
126
+ */
127
+ export function getAllProcedureNames() {
128
+ return Object.keys(PROCEDURES);
129
+ }
130
+ //# sourceMappingURL=registry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"registry.js","sourceRoot":"","sources":["../../src/procedures/registry.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH;;GAEG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG;IAC1B,OAAO,EAAE;QACR,IAAI,EAAE,SAAS;QACf,UAAU,EAAE,SAAS,EAAE,qEAAqE;QAC5F,WAAW,EAAE,2BAA2B;KACxC;IACD,oBAAoB,EAAE;QACrB,IAAI,EAAE,uBAAuB;QAC7B,UAAU,EAAE,sCAAsC;QAClD,WAAW,EAAE,+CAA+C;KAC5D;IACD,WAAW,E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AAW,EAAE;YACZ,WAAW,CAAC,OAAO;YACnB,WAAW,CAAC,aAAa;YACzB,WAAW,CAAC,KAAK;YACjB,WAAW,CAAC,cAAc;SAC1B;KACD;IAED,eAAe,EAAE;QAChB,IAAI,EAAE,eAAe;QACrB,WAAW,EACV,4EAA4E;QAC7E,WAAW,EAAE;YACZ,WAAW,CAAC,oBAAoB;YAChC,WAAW,CAAC,WAAW;YACvB,WAAW,CAAC,WAAW;YACvB,WAAW,CAAC,aAAa;YACzB,WAAW,CAAC,KAAK;YACjB,WAAW,CAAC,cAAc;SAC1B;KACD;IAED,mBAAmB,EAAE;QACpB,IAAI,EAAE,mBAAmB;QACzB,WAAW,EACV,6EAA6E;QAC9E,WAAW,EAAE,CAAC,WAAW,CAAC,OAAO,EAAE,WAAW,CAAC,cAAc,CAAC;KAC9D;CACD,CAAC;AAEF;;GAEG;AACH,MAAM,CAAC,MAAM,2BAA2B,GAGpC;IACH,QAAQ,EAAE,iBAAiB;IAC3B,aAAa,EAAE,oBAAoB;IACnC,SAAS,EAAE,iBAAiB;IAC5B,IAAI,EAAE,kBAAkB;IACxB,QAAQ,EAAE,eAAe;IACzB,YAAY,EAAE,mBAAmB;CACjC,CAAC;AAEF;;GAEG;AACH,MAAM,UAAU,YAAY,CAAC,IAAY;IACxC,OAAO,UAAU,CAAC,IAAI,CAAC,CAAC;AACzB,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,6BAA6B,CAC5C,cAAqC;IAErC,OAAO,2BAA2B,CAAC,cAAc,CAAC,CAAC;AACpD,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,oBAAoB;IACnC,OAAO,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;AAChC,CAAC"}
@@ -0,0 +1,64 @@
1
+ /**
2
+ * Type definitions for the procedure routing system
3
+ */
4
+ /**
5
+ * Definition of a single subroutine in a procedure
6
+ */
7
+ export interface SubroutineDefinition {
8
+ /** Unique identifier for the subroutine */
9
+ name: string;
10
+ /** Path to the prompt file (relative to edge-worker/src/prompts/) */
11
+ promptPath: string;
12
+ /** Optional maximum number of turns (undefined = unlimited) */
13
+ maxTurns?: number;
14
+ /** Human-readable description of what this subroutine does */
15
+ description: string;
16
+ /** Whether this subroutine should skip posting to Linear activity stream */
17
+ skipLinearPost?: boolean;
18
+ /** Whether to suppress posting thoughts/actions (still posts final summary) */
19
+ suppressThoughtPosting?: boolean;
20
+ /** Whether this subroutine requires user approval before advancing to next step */
21
+ requiresApproval?: boolean;
22
+ }
23
+ /**
24
+ * Complete definition of a procedure (sequence of subroutines)
25
+ */
26
+ export interface ProcedureDefinition {
27
+ /** Unique identifier for the procedure */
28
+ name: string;
29
+ /** Human-readable description of when to use this procedure */
30
+ description: string;
31
+ /** Ordered list of subroutines to execute */
32
+ subroutines: SubroutineDefinition[];
33
+ }
34
+ /**
35
+ * Procedure metadata stored in session.metadata.procedure
36
+ */
37
+ export interface ProcedureMetadata {
38
+ /** Name of the active procedure */
39
+ procedureName: string;
40
+ /** Current position in the subroutine sequence (0-indexed) */
41
+ currentSubroutineIndex: number;
42
+ /** History of completed subroutines */
43
+ subroutineHistory: Array<{
44
+ subroutine: string;
45
+ completedAt: number;
46
+ claudeSessionId: string | null;
47
+ }>;
48
+ }
49
+ /**
50
+ * Request classification types for routing decisions
51
+ */
52
+ export type RequestClassification = "question" | "documentation" | "transient" | "code" | "debugger" | "orchestrator";
53
+ /**
54
+ * Result of procedure routing decision
55
+ */
56
+ export interface RoutingDecision {
57
+ /** Classification of the request */
58
+ classification: RequestClassification;
59
+ /** Selected procedure to execute */
60
+ procedure: ProcedureDefinition;
61
+ /** Reasoning for the classification (for debugging) */
62
+ reasoning?: string;
63
+ }
64
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/procedures/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACpC,2CAA2C;IAC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
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/procedures/types.ts"],"names":[],"mappings":"AAAA;;GAEG"}
@@ -0,0 +1,53 @@
1
+ # Summary - Brief Response for Linear
2
+
3
+ Generate a concise summary of the work completed for posting to Linear.
4
+
5
+ ## Your Task
6
+
7
+ Create a clear, brief summary that covers:
8
+
9
+ ### 1. Work Completed
10
+ - What was accomplished (1-2 sentences)
11
+ - Key outcome or result
12
+
13
+ ### 2. Key Details (if applicable)
14
+ - Files modified or created (brief list)
15
+ - Important changes made
16
+ - PR link if created
17
+
18
+ ### 3. Status
19
+ - Completion status
20
+ - Any follow-up needed
21
+
22
+ ## Format Requirements
23
+
24
+ - **Be concise** - aim for 3-5 paragraphs maximum
25
+ - Use clear, professional language suitable for Linear
26
+ - Use markdown formatting for readability
27
+ - Focus on what matters to stakeholders
28
+ - **To mention someone**: Use `https://linear.app/linear/profiles/username` syntax where `username` is the Linear username (e.g., `https://linear.app/linear/profiles/alice` to mention @alice)
29
+
30
+ ## Constraints
31
+
32
+ - **You have exactly 1 turn** - generate the summary in a single response
33
+ - This is the final output that will be posted to Linear
34
+ - Make it informative but brief
35
+
36
+ ## Example Format
37
+
38
+ ```
39
+ ## Summary
40
+
41
+ [Brief description of what was done]
42
+
43
+ ## Changes
44
+
45
+ - [Key change 1]
46
+ - [Key change 2]
47
+
48
+ ## Status
49
+
50
+ [Current status and any next steps]
51
+
52
+ [PR link if applicable]
53
+ ```