@dyyz1993/pi-coding-agent 0.74.27 → 0.74.29

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 (36) hide show
  1. package/dist/core/agent-session.d.ts +4 -0
  2. package/dist/core/agent-session.d.ts.map +1 -1
  3. package/dist/core/agent-session.js +58 -0
  4. package/dist/core/agent-session.js.map +1 -1
  5. package/dist/core/extensions/channel-registry.d.ts +2 -0
  6. package/dist/core/extensions/channel-registry.d.ts.map +1 -1
  7. package/dist/core/extensions/channel-registry.js.map +1 -1
  8. package/dist/core/extensions/types.d.ts +17 -1
  9. package/dist/core/extensions/types.d.ts.map +1 -1
  10. package/dist/core/extensions/types.js.map +1 -1
  11. package/dist/core/session-manager.d.ts +5 -0
  12. package/dist/core/session-manager.d.ts.map +1 -1
  13. package/dist/core/session-manager.js +44 -1
  14. package/dist/core/session-manager.js.map +1 -1
  15. package/dist/extensions/bash-ext/index.ts +86 -62
  16. package/dist/extensions/file-snapshot/index.ts +4 -1
  17. package/dist/extensions/hooks-engine/index.ts +104 -16
  18. package/dist/extensions/lsp/lsp/index.ts +21 -3
  19. package/dist/extensions/lsp/lsp/utils/project-scanner.ts +102 -0
  20. package/dist/extensions/rules-engine/index.js +64 -22
  21. package/dist/extensions/rules-engine/index.ts +86 -16
  22. package/dist/extensions/rules-engine/types.d.ts +12 -2
  23. package/dist/extensions/rules-engine/types.d.ts.map +1 -1
  24. package/dist/extensions/rules-engine/types.js.map +1 -1
  25. package/dist/extensions/rules-engine/types.ts +13 -2
  26. package/dist/extensions/session-supervisor/config.ts +3 -1
  27. package/dist/extensions/session-supervisor/index.ts +90 -63
  28. package/dist/extensions/session-supervisor/types.d.ts +321 -0
  29. package/dist/extensions/session-supervisor/types.d.ts.map +1 -0
  30. package/dist/extensions/session-supervisor/types.js +92 -0
  31. package/dist/extensions/session-supervisor/types.js.map +1 -0
  32. package/dist/extensions/session-supervisor/types.ts +8 -8
  33. package/dist/modes/rpc/rpc-mode.d.ts.map +1 -1
  34. package/dist/modes/rpc/rpc-mode.js +1 -1
  35. package/dist/modes/rpc/rpc-mode.js.map +1 -1
  36. package/package.json +1 -1
@@ -0,0 +1,321 @@
1
+ import type { ChannelContract } from "@dyyz1993/pi-coding-agent";
2
+ import { type Static } from "@sinclair/typebox";
3
+ export declare const BaseGuardConfigSchema: import("@sinclair/typebox").TObject<{
4
+ /** Guard unique identifier */
5
+ name: import("@sinclair/typebox").TString;
6
+ /** Enable/disable this specific guard */
7
+ enable: import("@sinclair/typebox").TBoolean;
8
+ }>;
9
+ export declare const TodoGuardConfigSchema: import("@sinclair/typebox").TIntersect<[import("@sinclair/typebox").TObject<{
10
+ /** Guard unique identifier */
11
+ name: import("@sinclair/typebox").TString;
12
+ /** Enable/disable this specific guard */
13
+ enable: import("@sinclair/typebox").TBoolean;
14
+ }>, import("@sinclair/typebox").TObject<{
15
+ type: import("@sinclair/typebox").TLiteral<"todo">;
16
+ }>]>;
17
+ export declare const SpecsGuardConfigSchema: import("@sinclair/typebox").TIntersect<[import("@sinclair/typebox").TObject<{
18
+ /** Guard unique identifier */
19
+ name: import("@sinclair/typebox").TString;
20
+ /** Enable/disable this specific guard */
21
+ enable: import("@sinclair/typebox").TBoolean;
22
+ }>, import("@sinclair/typebox").TObject<{
23
+ type: import("@sinclair/typebox").TLiteral<"specs">;
24
+ /** Path to specs file, relative to project root */
25
+ specsFile: import("@sinclair/typebox").TString;
26
+ /** Max iterations for specs guard (0 = infinite) */
27
+ maxIterations: import("@sinclair/typebox").TInteger;
28
+ }>]>;
29
+ export declare const CiGuardConfigSchema: import("@sinclair/typebox").TIntersect<[import("@sinclair/typebox").TObject<{
30
+ /** Guard unique identifier */
31
+ name: import("@sinclair/typebox").TString;
32
+ /** Enable/disable this specific guard */
33
+ enable: import("@sinclair/typebox").TBoolean;
34
+ }>, import("@sinclair/typebox").TObject<{
35
+ type: import("@sinclair/typebox").TLiteral<"ci">;
36
+ /** Command to check CI status */
37
+ checkCommand: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
38
+ /** Polling interval in ms */
39
+ pollIntervalMs: import("@sinclair/typebox").TInteger;
40
+ }>]>;
41
+ export declare const KeywordGuardConfigSchema: import("@sinclair/typebox").TIntersect<[import("@sinclair/typebox").TObject<{
42
+ /** Guard unique identifier */
43
+ name: import("@sinclair/typebox").TString;
44
+ /** Enable/disable this specific guard */
45
+ enable: import("@sinclair/typebox").TBoolean;
46
+ }>, import("@sinclair/typebox").TObject<{
47
+ type: import("@sinclair/typebox").TLiteral<"keyword">;
48
+ /** Keywords that indicate incomplete work */
49
+ keywords: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TString>;
50
+ }>]>;
51
+ export declare const CustomGuardConfigSchema: import("@sinclair/typebox").TIntersect<[import("@sinclair/typebox").TObject<{
52
+ /** Guard unique identifier */
53
+ name: import("@sinclair/typebox").TString;
54
+ /** Enable/disable this specific guard */
55
+ enable: import("@sinclair/typebox").TBoolean;
56
+ }>, import("@sinclair/typebox").TObject<{
57
+ type: import("@sinclair/typebox").TLiteral<"custom">;
58
+ /** System prompt for the guard model */
59
+ checkPrompt: import("@sinclair/typebox").TString;
60
+ /** Prompt template for generating continue message */
61
+ continuePromptTemplate: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
62
+ }>]>;
63
+ export declare const GuardConfigSchema: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TIntersect<[import("@sinclair/typebox").TObject<{
64
+ /** Guard unique identifier */
65
+ name: import("@sinclair/typebox").TString;
66
+ /** Enable/disable this specific guard */
67
+ enable: import("@sinclair/typebox").TBoolean;
68
+ }>, import("@sinclair/typebox").TObject<{
69
+ type: import("@sinclair/typebox").TLiteral<"todo">;
70
+ }>]>, import("@sinclair/typebox").TIntersect<[import("@sinclair/typebox").TObject<{
71
+ /** Guard unique identifier */
72
+ name: import("@sinclair/typebox").TString;
73
+ /** Enable/disable this specific guard */
74
+ enable: import("@sinclair/typebox").TBoolean;
75
+ }>, import("@sinclair/typebox").TObject<{
76
+ type: import("@sinclair/typebox").TLiteral<"specs">;
77
+ /** Path to specs file, relative to project root */
78
+ specsFile: import("@sinclair/typebox").TString;
79
+ /** Max iterations for specs guard (0 = infinite) */
80
+ maxIterations: import("@sinclair/typebox").TInteger;
81
+ }>]>, import("@sinclair/typebox").TIntersect<[import("@sinclair/typebox").TObject<{
82
+ /** Guard unique identifier */
83
+ name: import("@sinclair/typebox").TString;
84
+ /** Enable/disable this specific guard */
85
+ enable: import("@sinclair/typebox").TBoolean;
86
+ }>, import("@sinclair/typebox").TObject<{
87
+ type: import("@sinclair/typebox").TLiteral<"ci">;
88
+ /** Command to check CI status */
89
+ checkCommand: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
90
+ /** Polling interval in ms */
91
+ pollIntervalMs: import("@sinclair/typebox").TInteger;
92
+ }>]>, import("@sinclair/typebox").TIntersect<[import("@sinclair/typebox").TObject<{
93
+ /** Guard unique identifier */
94
+ name: import("@sinclair/typebox").TString;
95
+ /** Enable/disable this specific guard */
96
+ enable: import("@sinclair/typebox").TBoolean;
97
+ }>, import("@sinclair/typebox").TObject<{
98
+ type: import("@sinclair/typebox").TLiteral<"keyword">;
99
+ /** Keywords that indicate incomplete work */
100
+ keywords: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TString>;
101
+ }>]>, import("@sinclair/typebox").TIntersect<[import("@sinclair/typebox").TObject<{
102
+ /** Guard unique identifier */
103
+ name: import("@sinclair/typebox").TString;
104
+ /** Enable/disable this specific guard */
105
+ enable: import("@sinclair/typebox").TBoolean;
106
+ }>, import("@sinclair/typebox").TObject<{
107
+ type: import("@sinclair/typebox").TLiteral<"custom">;
108
+ /** System prompt for the guard model */
109
+ checkPrompt: import("@sinclair/typebox").TString;
110
+ /** Prompt template for generating continue message */
111
+ continuePromptTemplate: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
112
+ }>]>]>;
113
+ export type GuardConfig = Static<typeof GuardConfigSchema>;
114
+ export declare const SupervisorConfigSchema: import("@sinclair/typebox").TObject<{
115
+ /** Master switch — default OFF */
116
+ enable: import("@sinclair/typebox").TBoolean;
117
+ /** Check when agent ends a turn */
118
+ checkOnAgentEnd: import("@sinclair/typebox").TBoolean;
119
+ /** Small model for guard checks */
120
+ smallModel: import("@sinclair/typebox").TString;
121
+ /** Max auto-continue count (0 = infinite) */
122
+ maxContinueCount: import("@sinclair/typebox").TInteger;
123
+ /** Default delay before auto-continue */
124
+ defaultDelayMs: import("@sinclair/typebox").TInteger;
125
+ /** Delay threshold for pausing (vs immediate continue) */
126
+ pauseThresholdMs: import("@sinclair/typebox").TInteger;
127
+ /** Guard plugins */
128
+ guards: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TIntersect<[import("@sinclair/typebox").TObject<{
129
+ /** Guard unique identifier */
130
+ name: import("@sinclair/typebox").TString;
131
+ /** Enable/disable this specific guard */
132
+ enable: import("@sinclair/typebox").TBoolean;
133
+ }>, import("@sinclair/typebox").TObject<{
134
+ type: import("@sinclair/typebox").TLiteral<"todo">;
135
+ }>]>, import("@sinclair/typebox").TIntersect<[import("@sinclair/typebox").TObject<{
136
+ /** Guard unique identifier */
137
+ name: import("@sinclair/typebox").TString;
138
+ /** Enable/disable this specific guard */
139
+ enable: import("@sinclair/typebox").TBoolean;
140
+ }>, import("@sinclair/typebox").TObject<{
141
+ type: import("@sinclair/typebox").TLiteral<"specs">;
142
+ /** Path to specs file, relative to project root */
143
+ specsFile: import("@sinclair/typebox").TString;
144
+ /** Max iterations for specs guard (0 = infinite) */
145
+ maxIterations: import("@sinclair/typebox").TInteger;
146
+ }>]>, import("@sinclair/typebox").TIntersect<[import("@sinclair/typebox").TObject<{
147
+ /** Guard unique identifier */
148
+ name: import("@sinclair/typebox").TString;
149
+ /** Enable/disable this specific guard */
150
+ enable: import("@sinclair/typebox").TBoolean;
151
+ }>, import("@sinclair/typebox").TObject<{
152
+ type: import("@sinclair/typebox").TLiteral<"ci">;
153
+ /** Command to check CI status */
154
+ checkCommand: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
155
+ /** Polling interval in ms */
156
+ pollIntervalMs: import("@sinclair/typebox").TInteger;
157
+ }>]>, import("@sinclair/typebox").TIntersect<[import("@sinclair/typebox").TObject<{
158
+ /** Guard unique identifier */
159
+ name: import("@sinclair/typebox").TString;
160
+ /** Enable/disable this specific guard */
161
+ enable: import("@sinclair/typebox").TBoolean;
162
+ }>, import("@sinclair/typebox").TObject<{
163
+ type: import("@sinclair/typebox").TLiteral<"keyword">;
164
+ /** Keywords that indicate incomplete work */
165
+ keywords: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TString>;
166
+ }>]>, import("@sinclair/typebox").TIntersect<[import("@sinclair/typebox").TObject<{
167
+ /** Guard unique identifier */
168
+ name: import("@sinclair/typebox").TString;
169
+ /** Enable/disable this specific guard */
170
+ enable: import("@sinclair/typebox").TBoolean;
171
+ }>, import("@sinclair/typebox").TObject<{
172
+ type: import("@sinclair/typebox").TLiteral<"custom">;
173
+ /** System prompt for the guard model */
174
+ checkPrompt: import("@sinclair/typebox").TString;
175
+ /** Prompt template for generating continue message */
176
+ continuePromptTemplate: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
177
+ }>]>]>>;
178
+ }>;
179
+ export type SupervisorConfig = Static<typeof SupervisorConfigSchema>;
180
+ export interface GuardCheckResult {
181
+ /** This guard's name */
182
+ guardName: string;
183
+ /** Whether the guard thinks work is done */
184
+ completed: boolean;
185
+ /** Confidence 0-1 */
186
+ confidence: number;
187
+ /** Remaining items if not completed */
188
+ remainingItems: string[];
189
+ /** Optional detail message */
190
+ detail?: string;
191
+ }
192
+ export interface GuardContinueMessage {
193
+ /** The message to inject as supervisor continue */
194
+ content: string;
195
+ /** Whether this guard wants to block agent completion */
196
+ blockCompletion: boolean;
197
+ }
198
+ export interface SupervisorChannelContract extends ChannelContract {
199
+ methods: {
200
+ getStatus: {
201
+ params: Record<string, never>;
202
+ return: SupervisorStatus;
203
+ };
204
+ requestPause: {
205
+ params: {
206
+ delayMs?: number;
207
+ reason?: string;
208
+ };
209
+ return: {
210
+ scheduled: boolean;
211
+ scheduledAt?: number;
212
+ };
213
+ };
214
+ cancelPause: {
215
+ params: Record<string, never>;
216
+ return: {
217
+ cancelled: boolean;
218
+ };
219
+ };
220
+ forceContinue: {
221
+ params: {
222
+ reason?: string;
223
+ };
224
+ return: {
225
+ triggered: boolean;
226
+ };
227
+ };
228
+ disable: {
229
+ params: Record<string, never>;
230
+ return: {
231
+ disabled: boolean;
232
+ };
233
+ };
234
+ enable: {
235
+ params: Record<string, never>;
236
+ return: {
237
+ enabled: boolean;
238
+ };
239
+ };
240
+ getTaskReport: {
241
+ params: Record<string, never>;
242
+ return: {
243
+ tasks: TaskReport[];
244
+ };
245
+ };
246
+ checkToolStatus: {
247
+ params: {
248
+ toolName: string;
249
+ channelName?: string;
250
+ method?: string;
251
+ };
252
+ return: {
253
+ reachable: boolean;
254
+ status?: string;
255
+ error?: string;
256
+ };
257
+ };
258
+ };
259
+ events: {
260
+ "supervisor.statusChanged": SupervisorStatus;
261
+ "supervisor.pauseRequested": {
262
+ delayMs: number;
263
+ reason?: string;
264
+ };
265
+ "supervisor.pauseCancelled": {
266
+ reason: string;
267
+ };
268
+ "supervisor.continueTriggered": {
269
+ reason: string;
270
+ delayMs: number;
271
+ };
272
+ "supervisor.taskReport": {
273
+ tasks: TaskReport[];
274
+ };
275
+ };
276
+ }
277
+ export interface SupervisorStatus {
278
+ enabled: boolean;
279
+ state: "idle" | "checking" | "paused" | "continuing" | "disabled";
280
+ continueCount: number;
281
+ maxContinueCount: number;
282
+ activeGuards: string[];
283
+ lastCheckResult?: CheckResult;
284
+ pendingPause?: {
285
+ scheduledAt: number;
286
+ delayMs: number;
287
+ reason?: string;
288
+ };
289
+ }
290
+ export interface CheckResult {
291
+ completed: boolean;
292
+ confidence: number;
293
+ incompleteTasks: IncompleteTask[];
294
+ modelResponse?: string;
295
+ guardResults?: GuardCheckResult[];
296
+ }
297
+ export interface IncompleteTask {
298
+ ruleName: string;
299
+ description: string;
300
+ severity: "high" | "medium" | "low";
301
+ }
302
+ export interface TaskReport {
303
+ guardName: string;
304
+ guardType: string;
305
+ status: "completed" | "incomplete" | "unknown" | "error";
306
+ details?: string;
307
+ error?: string;
308
+ remainingItems?: string[];
309
+ }
310
+ export declare const CompletionCheckSchema: import("@sinclair/typebox").TObject<{
311
+ completed: import("@sinclair/typebox").TBoolean;
312
+ confidence: import("@sinclair/typebox").TNumber;
313
+ incompleteTasks: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TObject<{
314
+ ruleName: import("@sinclair/typebox").TString;
315
+ description: import("@sinclair/typebox").TString;
316
+ severity: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TLiteral<"high">, import("@sinclair/typebox").TLiteral<"medium">, import("@sinclair/typebox").TLiteral<"low">]>;
317
+ }>>;
318
+ reasoning: import("@sinclair/typebox").TString;
319
+ }>;
320
+ export type CompletionCheckResult = Static<typeof CompletionCheckSchema>;
321
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AACjE,OAAO,EAAQ,KAAK,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAItD,eAAO,MAAM,qBAAqB;IAC9B,8BAA8B;;IAE9B,yCAAyC;;EAE3C,CAAC;AAEH,eAAO,MAAM,qBAAqB;IAN9B,8BAA8B;;IAE9B,yCAAyC;;;;IAS3C,CAAC;AAEH,eAAO,MAAM,sBAAsB;IAb/B,8BAA8B;;IAE9B,yCAAyC;;;;IAerC,mDAAmD;;IAEnD,oDAAoD;;IAG1D,CAAC;AAEH,eAAO,MAAM,mBAAmB;IAxB5B,8BAA8B;;IAE9B,yCAAyC;;;;IA0BrC,iCAAi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,EAAE,CAAC;IACvB,eAAe,CAAC,EAAE,WAAW,CAAC;IAC9B,YAAY,CAAC,EAAE;QAAE,WAAW,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;CAC5E;AAED,MAAM,WAAW,WAAW;IACxB,SAAS,EAAE,OAAO,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,eAAe,EAAE,cAAc,EAAE,CAAC;IAClC,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,YAAY,CAAC,EAAE,gBAAgB,EAAE,CAAC;CACrC;AAED,MAAM,WAAW,cAAc;IAC3B,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,GAAG,QAAQ,GAAG,KAAK,CAAC;CACvC;AAED,MAAM,WAAW,UAAU;IACvB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,WAAW,GAAG,YAAY,GAAG,SAAS,GAAG,OAAO,CAAC;IACzD,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;CAC7B;AAID,eAAO,MAAM,qBAAqB;;;;;;;;;EAehC,CAAC;AAEH,MAAM,MAAM,qBAAqB,GAAG,MAAM,CAAC,OAAO,qBAAqB,CAAC,CAAC","sourcesContent":["import type { ChannelContract } from \"@dyyz1993/pi-coding-agent\";\nimport { Type, type Static } from \"@sinclair/typebox\";\n\n// ── Guard Configuration ──\n\nexport const BaseGuardConfigSchema = Type.Object({\n /** Guard unique identifier */\n name: Type.String(),\n /** Enable/disable this specific guard */\n enable: Type.Boolean({ default: true }),\n});\n\nexport const TodoGuardConfigSchema = Type.Intersect([\n BaseGuardConfigSchema,\n Type.Object({\n type: Type.Literal(\"todo\"),\n }),\n]);\n\nexport const SpecsGuardConfigSchema = Type.Intersect([\n BaseGuardConfigSchema,\n Type.Object({\n type: Type.Literal(\"specs\"),\n /** Path to specs file, relative to project root */\n specsFile: Type.String({ default: \"specs.md\" }),\n /** Max iterations for specs guard (0 = infinite) */\n maxIterations: Type.Integer({ default: 100 }),\n }),\n]);\n\nexport const CiGuardConfigSchema = Type.Intersect([\n BaseGuardConfigSchema,\n Type.Object({\n type: Type.Literal(\"ci\"),\n /** Command to check CI status */\n checkCommand: Type.Optional(Type.String()),\n /** Polling interval in ms */\n pollIntervalMs: Type.Integer({ default: 30_000 }),\n }),\n]);\n\nexport const KeywordGuardConfigSchema = Type.Intersect([\n BaseGuardConfigSchema,\n Type.Object({\n type: Type.Literal(\"keyword\"),\n /** Keywords that indicate incomplete work */\n keywords: Type.Array(Type.String()),\n }),\n]);\n\nexport const CustomGuardConfigSchema = Type.Intersect([\n BaseGuardConfigSchema,\n Type.Object({\n type: Type.Literal(\"custom\"),\n /** System prompt for the guard model */\n checkPrompt: Type.String(),\n /** Prompt template for generating continue message */\n continuePromptTemplate: Type.Optional(Type.String()),\n }),\n]);\n\nexport const GuardConfigSchema = Type.Union([\n TodoGuardConfigSchema,\n SpecsGuardConfigSchema,\n CiGuardConfigSchema,\n KeywordGuardConfigSchema,\n CustomGuardConfigSchema,\n]);\n\nexport type GuardConfig = Static<typeof GuardConfigSchema>;\n\n// ── Main Supervisor Config ──\n\nexport const SupervisorConfigSchema = Type.Object({\n /** Master switch — default OFF */\n enable: Type.Boolean({ default: false }),\n /** Check when agent ends a turn */\n checkOnAgentEnd: Type.Boolean({ default: true }),\n /** Small model for guard checks */\n smallModel: Type.String({ default: \"fast\" }),\n /** Max auto-continue count (0 = infinite) */\n maxContinueCount: Type.Integer({ default: 5 }),\n /** Default delay before auto-continue */\n defaultDelayMs: Type.Integer({ default: 30_000 }),\n /** Delay threshold for pausing (vs immediate continue) */\n pauseThresholdMs: Type.Integer({ default: 300_000 }),\n /** Guard plugins */\n guards: Type.Array(GuardConfigSchema, { default: [] }),\n});\n\nexport type SupervisorConfig = Static<typeof SupervisorConfigSchema>;\n\n// ── Guard Runtime Types ──\n\nexport interface GuardCheckResult {\n /** This guard's name */\n guardName: string;\n /** Whether the guard thinks work is done */\n completed: boolean;\n /** Confidence 0-1 */\n confidence: number;\n /** Remaining items if not completed */\n remainingItems: string[];\n /** Optional detail message */\n detail?: string;\n}\n\nexport interface GuardContinueMessage {\n /** The message to inject as supervisor continue */\n content: string;\n /** Whether this guard wants to block agent completion */\n blockCompletion: boolean;\n}\n\n// ── Channel Contract ──\n\nexport interface SupervisorChannelContract extends ChannelContract {\n methods: {\n getStatus: {\n params: Record<string, never>;\n return: SupervisorStatus;\n };\n requestPause: {\n params: { delayMs?: number; reason?: string };\n return: { scheduled: boolean; scheduledAt?: number };\n };\n cancelPause: {\n params: Record<string, never>;\n return: { cancelled: boolean };\n };\n forceContinue: {\n params: { reason?: string };\n return: { triggered: boolean };\n };\n disable: {\n params: Record<string, never>;\n return: { disabled: boolean };\n };\n enable: {\n params: Record<string, never>;\n return: { enabled: boolean };\n };\n getTaskReport: {\n params: Record<string, never>;\n return: { tasks: TaskReport[] };\n };\n checkToolStatus: {\n params: { toolName: string; channelName?: string; method?: string };\n return: { reachable: boolean; status?: string; error?: string };\n };\n };\n events: {\n \"supervisor.statusChanged\": SupervisorStatus;\n \"supervisor.pauseRequested\": { delayMs: number; reason?: string };\n \"supervisor.pauseCancelled\": { reason: string };\n \"supervisor.continueTriggered\": { reason: string; delayMs: number };\n \"supervisor.taskReport\": { tasks: TaskReport[] };\n };\n}\n\n// ── Status & Reporting ──\n\nexport interface SupervisorStatus {\n enabled: boolean;\n state: \"idle\" | \"checking\" | \"paused\" | \"continuing\" | \"disabled\";\n continueCount: number;\n maxContinueCount: number;\n activeGuards: string[];\n lastCheckResult?: CheckResult;\n pendingPause?: { scheduledAt: number; delayMs: number; reason?: string };\n}\n\nexport interface CheckResult {\n completed: boolean;\n confidence: number;\n incompleteTasks: IncompleteTask[];\n modelResponse?: string;\n guardResults?: GuardCheckResult[];\n}\n\nexport interface IncompleteTask {\n ruleName: string;\n description: string;\n severity: \"high\" | \"medium\" | \"low\";\n}\n\nexport interface TaskReport {\n guardName: string;\n guardType: string;\n status: \"completed\" | \"incomplete\" | \"unknown\" | \"error\";\n details?: string;\n error?: string;\n remainingItems?: string[];\n}\n\n// ── Structured LLM output ──\n\nexport const CompletionCheckSchema = Type.Object({\n completed: Type.Boolean({ description: \"会话是否已经真正完成\" }),\n confidence: Type.Number({ description: \"置信度 0-1\", minimum: 0, maximum: 1 }),\n incompleteTasks: Type.Array(\n Type.Object({\n ruleName: Type.String(),\n description: Type.String(),\n severity: Type.Union([\n Type.Literal(\"high\"),\n Type.Literal(\"medium\"),\n Type.Literal(\"low\"),\n ]),\n }),\n ),\n reasoning: Type.String({ description: \"判断理由\" }),\n});\n\nexport type CompletionCheckResult = Static<typeof CompletionCheckSchema>;\n"]}
@@ -0,0 +1,92 @@
1
+ import { Type } from "@sinclair/typebox";
2
+ // ── Guard Configuration ──
3
+ export const BaseGuardConfigSchema = Type.Object({
4
+ /** Guard unique identifier */
5
+ name: Type.String(),
6
+ /** Enable/disable this specific guard */
7
+ enable: Type.Boolean({ default: true }),
8
+ });
9
+ export const TodoGuardConfigSchema = Type.Intersect([
10
+ BaseGuardConfigSchema,
11
+ Type.Object({
12
+ type: Type.Literal("todo"),
13
+ }),
14
+ ]);
15
+ export const SpecsGuardConfigSchema = Type.Intersect([
16
+ BaseGuardConfigSchema,
17
+ Type.Object({
18
+ type: Type.Literal("specs"),
19
+ /** Path to specs file, relative to project root */
20
+ specsFile: Type.String({ default: "specs.md" }),
21
+ /** Max iterations for specs guard (0 = infinite) */
22
+ maxIterations: Type.Integer({ default: 100 }),
23
+ }),
24
+ ]);
25
+ export const CiGuardConfigSchema = Type.Intersect([
26
+ BaseGuardConfigSchema,
27
+ Type.Object({
28
+ type: Type.Literal("ci"),
29
+ /** Command to check CI status */
30
+ checkCommand: Type.Optional(Type.String()),
31
+ /** Polling interval in ms */
32
+ pollIntervalMs: Type.Integer({ default: 30_000 }),
33
+ }),
34
+ ]);
35
+ export const KeywordGuardConfigSchema = Type.Intersect([
36
+ BaseGuardConfigSchema,
37
+ Type.Object({
38
+ type: Type.Literal("keyword"),
39
+ /** Keywords that indicate incomplete work */
40
+ keywords: Type.Array(Type.String()),
41
+ }),
42
+ ]);
43
+ export const CustomGuardConfigSchema = Type.Intersect([
44
+ BaseGuardConfigSchema,
45
+ Type.Object({
46
+ type: Type.Literal("custom"),
47
+ /** System prompt for the guard model */
48
+ checkPrompt: Type.String(),
49
+ /** Prompt template for generating continue message */
50
+ continuePromptTemplate: Type.Optional(Type.String()),
51
+ }),
52
+ ]);
53
+ export const GuardConfigSchema = Type.Union([
54
+ TodoGuardConfigSchema,
55
+ SpecsGuardConfigSchema,
56
+ CiGuardConfigSchema,
57
+ KeywordGuardConfigSchema,
58
+ CustomGuardConfigSchema,
59
+ ]);
60
+ // ── Main Supervisor Config ──
61
+ export const SupervisorConfigSchema = Type.Object({
62
+ /** Master switch — default OFF */
63
+ enable: Type.Boolean({ default: false }),
64
+ /** Check when agent ends a turn */
65
+ checkOnAgentEnd: Type.Boolean({ default: true }),
66
+ /** Small model for guard checks */
67
+ smallModel: Type.String({ default: "fast" }),
68
+ /** Max auto-continue count (0 = infinite) */
69
+ maxContinueCount: Type.Integer({ default: 5 }),
70
+ /** Default delay before auto-continue */
71
+ defaultDelayMs: Type.Integer({ default: 30_000 }),
72
+ /** Delay threshold for pausing (vs immediate continue) */
73
+ pauseThresholdMs: Type.Integer({ default: 300_000 }),
74
+ /** Guard plugins */
75
+ guards: Type.Array(GuardConfigSchema, { default: [] }),
76
+ });
77
+ // ── Structured LLM output ──
78
+ export const CompletionCheckSchema = Type.Object({
79
+ completed: Type.Boolean({ description: "会话是否已经真正完成" }),
80
+ confidence: Type.Number({ description: "置信度 0-1", minimum: 0, maximum: 1 }),
81
+ incompleteTasks: Type.Array(Type.Object({
82
+ ruleName: Type.String(),
83
+ description: Type.String(),
84
+ severity: Type.Union([
85
+ Type.Literal("high"),
86
+ Type.Literal("medium"),
87
+ Type.Literal("low"),
88
+ ]),
89
+ })),
90
+ reasoning: Type.String({ description: "判断理由" }),
91
+ });
92
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["types.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAe,MAAM,mBAAmB,CAAC;AAEtD,oCAA4B;AAE5B,MAAM,CAAC,MAAM,qBAAqB,GAAG,IAAI,CAAC,MAAM,CAAC;IAC7C,8BAA8B;IAC9B,IAAI,EAAE,IAAI,CAAC,MAAM,EAAE;IACnB,yCAAyC;IACzC,MAAM,EAAE,IAAI,CAAC,OAAO,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;CAC1C,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,qBAAqB,GAAG,IAAI,CAAC,SAAS,CAAC;IAChD,qBAAqB;IACrB,IAAI,CAAC,MAAM,CAAC;QACR,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC;KAC7B,CAAC;CACL,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,sBAAsB,GAAG,IAAI,CAAC,SAAS,CAAC;IACjD,qBAAqB;IACrB,IAAI,CAAC,MAAM,CAAC;QACR,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC;QAC3B,mDAAmD;QACnD,SAAS,EAAE,IAAI,CAAC,MAAM,CAAC,EAAE,OAAO,EAAE,UAAU,EAAE,CAAC;QAC/C,oDAAoD;QACpD,aAAa,EAAE,IAAI,CAAC,OAAO,CAAC,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC;KAChD,CAAC;CACL,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,mBAAmB,GAAG,IAAI,CAAC,SAAS,CAAC;IAC9C,qBAAqB;IACrB,IAAI,CAAC,MA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,EAAE,IAAI,CAAC,MAAM,CAAC,EAAE,WAAW,EAAE,cAAM,EAAE,CAAC;CAClD,CAAC,CAAC","sourcesContent":["import type { ChannelContract } from \"@dyyz1993/pi-coding-agent\";\nimport { Type, type Static } from \"@sinclair/typebox\";\n\n// ── Guard Configuration ──\n\nexport const BaseGuardConfigSchema = Type.Object({\n /** Guard unique identifier */\n name: Type.String(),\n /** Enable/disable this specific guard */\n enable: Type.Boolean({ default: true }),\n});\n\nexport const TodoGuardConfigSchema = Type.Intersect([\n BaseGuardConfigSchema,\n Type.Object({\n type: Type.Literal(\"todo\"),\n }),\n]);\n\nexport const SpecsGuardConfigSchema = Type.Intersect([\n BaseGuardConfigSchema,\n Type.Object({\n type: Type.Literal(\"specs\"),\n /** Path to specs file, relative to project root */\n specsFile: Type.String({ default: \"specs.md\" }),\n /** Max iterations for specs guard (0 = infinite) */\n maxIterations: Type.Integer({ default: 100 }),\n }),\n]);\n\nexport const CiGuardConfigSchema = Type.Intersect([\n BaseGuardConfigSchema,\n Type.Object({\n type: Type.Literal(\"ci\"),\n /** Command to check CI status */\n checkCommand: Type.Optional(Type.String()),\n /** Polling interval in ms */\n pollIntervalMs: Type.Integer({ default: 30_000 }),\n }),\n]);\n\nexport const KeywordGuardConfigSchema = Type.Intersect([\n BaseGuardConfigSchema,\n Type.Object({\n type: Type.Literal(\"keyword\"),\n /** Keywords that indicate incomplete work */\n keywords: Type.Array(Type.String()),\n }),\n]);\n\nexport const CustomGuardConfigSchema = Type.Intersect([\n BaseGuardConfigSchema,\n Type.Object({\n type: Type.Literal(\"custom\"),\n /** System prompt for the guard model */\n checkPrompt: Type.String(),\n /** Prompt template for generating continue message */\n continuePromptTemplate: Type.Optional(Type.String()),\n }),\n]);\n\nexport const GuardConfigSchema = Type.Union([\n TodoGuardConfigSchema,\n SpecsGuardConfigSchema,\n CiGuardConfigSchema,\n KeywordGuardConfigSchema,\n CustomGuardConfigSchema,\n]);\n\nexport type GuardConfig = Static<typeof GuardConfigSchema>;\n\n// ── Main Supervisor Config ──\n\nexport const SupervisorConfigSchema = Type.Object({\n /** Master switch — default OFF */\n enable: Type.Boolean({ default: false }),\n /** Check when agent ends a turn */\n checkOnAgentEnd: Type.Boolean({ default: true }),\n /** Small model for guard checks */\n smallModel: Type.String({ default: \"fast\" }),\n /** Max auto-continue count (0 = infinite) */\n maxContinueCount: Type.Integer({ default: 5 }),\n /** Default delay before auto-continue */\n defaultDelayMs: Type.Integer({ default: 30_000 }),\n /** Delay threshold for pausing (vs immediate continue) */\n pauseThresholdMs: Type.Integer({ default: 300_000 }),\n /** Guard plugins */\n guards: Type.Array(GuardConfigSchema, { default: [] }),\n});\n\nexport type SupervisorConfig = Static<typeof SupervisorConfigSchema>;\n\n// ── Guard Runtime Types ──\n\nexport interface GuardCheckResult {\n /** This guard's name */\n guardName: string;\n /** Whether the guard thinks work is done */\n completed: boolean;\n /** Confidence 0-1 */\n confidence: number;\n /** Remaining items if not completed */\n remainingItems: string[];\n /** Optional detail message */\n detail?: string;\n}\n\nexport interface GuardContinueMessage {\n /** The message to inject as supervisor continue */\n content: string;\n /** Whether this guard wants to block agent completion */\n blockCompletion: boolean;\n}\n\n// ── Channel Contract ──\n\nexport interface SupervisorChannelContract extends ChannelContract {\n methods: {\n getStatus: {\n params: Record<string, never>;\n return: SupervisorStatus;\n };\n requestPause: {\n params: { delayMs?: number; reason?: string };\n return: { scheduled: boolean; scheduledAt?: number };\n };\n cancelPause: {\n params: Record<string, never>;\n return: { cancelled: boolean };\n };\n forceContinue: {\n params: { reason?: string };\n return: { triggered: boolean };\n };\n disable: {\n params: Record<string, never>;\n return: { disabled: boolean };\n };\n enable: {\n params: Record<string, never>;\n return: { enabled: boolean };\n };\n getTaskReport: {\n params: Record<string, never>;\n return: { tasks: TaskReport[] };\n };\n checkToolStatus: {\n params: { toolName: string; channelName?: string; method?: string };\n return: { reachable: boolean; status?: string; error?: string };\n };\n };\n events: {\n \"supervisor.statusChanged\": SupervisorStatus;\n \"supervisor.pauseRequested\": { delayMs: number; reason?: string };\n \"supervisor.pauseCancelled\": { reason: string };\n \"supervisor.continueTriggered\": { reason: string; delayMs: number };\n \"supervisor.taskReport\": { tasks: TaskReport[] };\n };\n}\n\n// ── Status & Reporting ──\n\nexport interface SupervisorStatus {\n enabled: boolean;\n state: \"idle\" | \"checking\" | \"paused\" | \"continuing\" | \"disabled\";\n continueCount: number;\n maxContinueCount: number;\n activeGuards: string[];\n lastCheckResult?: CheckResult;\n pendingPause?: { scheduledAt: number; delayMs: number; reason?: string };\n}\n\nexport interface CheckResult {\n completed: boolean;\n confidence: number;\n incompleteTasks: IncompleteTask[];\n modelResponse?: string;\n guardResults?: GuardCheckResult[];\n}\n\nexport interface IncompleteTask {\n ruleName: string;\n description: string;\n severity: \"high\" | \"medium\" | \"low\";\n}\n\nexport interface TaskReport {\n guardName: string;\n guardType: string;\n status: \"completed\" | \"incomplete\" | \"unknown\" | \"error\";\n details?: string;\n error?: string;\n remainingItems?: string[];\n}\n\n// ── Structured LLM output ──\n\nexport const CompletionCheckSchema = Type.Object({\n completed: Type.Boolean({ description: \"会话是否已经真正完成\" }),\n confidence: Type.Number({ description: \"置信度 0-1\", minimum: 0, maximum: 1 }),\n incompleteTasks: Type.Array(\n Type.Object({\n ruleName: Type.String(),\n description: Type.String(),\n severity: Type.Union([\n Type.Literal(\"high\"),\n Type.Literal(\"medium\"),\n Type.Literal(\"low\"),\n ]),\n }),\n ),\n reasoning: Type.String({ description: \"判断理由\" }),\n});\n\nexport type CompletionCheckResult = Static<typeof CompletionCheckSchema>;\n"]}
@@ -116,35 +116,35 @@ export interface GuardContinueMessage {
116
116
 
117
117
  export interface SupervisorChannelContract extends ChannelContract {
118
118
  methods: {
119
- "supervisor.getStatus": {
119
+ getStatus: {
120
120
  params: Record<string, never>;
121
121
  return: SupervisorStatus;
122
122
  };
123
- "supervisor.requestPause": {
123
+ requestPause: {
124
124
  params: { delayMs?: number; reason?: string };
125
125
  return: { scheduled: boolean; scheduledAt?: number };
126
126
  };
127
- "supervisor.cancelPause": {
127
+ cancelPause: {
128
128
  params: Record<string, never>;
129
129
  return: { cancelled: boolean };
130
130
  };
131
- "supervisor.forceContinue": {
131
+ forceContinue: {
132
132
  params: { reason?: string };
133
133
  return: { triggered: boolean };
134
134
  };
135
- "supervisor.disable": {
135
+ disable: {
136
136
  params: Record<string, never>;
137
137
  return: { disabled: boolean };
138
138
  };
139
- "supervisor.enable": {
139
+ enable: {
140
140
  params: Record<string, never>;
141
141
  return: { enabled: boolean };
142
142
  };
143
- "supervisor.getTaskReport": {
143
+ getTaskReport: {
144
144
  params: Record<string, never>;
145
145
  return: { tasks: TaskReport[] };
146
146
  };
147
- "supervisor.checkToolStatus": {
147
+ checkToolStatus: {
148
148
  params: { toolName: string; channelName?: string; method?: string };
149
149
  return: { reachable: boolean; status?: string; error?: string };
150
150
  };