@bermudi/pi-delegate 0.1.10 → 0.1.12
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.
- package/README.md +57 -4
- package/concurrency.ts +55 -16
- package/config.ts +584 -50
- package/delegate.ts +11 -3
- package/dispatch.ts +436 -65
- package/extension.ts +16 -4
- package/format.ts +52 -6
- package/host-cache.ts +70 -0
- package/host.ts +169 -811
- package/isolated-workspace.ts +857 -0
- package/lifecycle.ts +699 -520
- package/manual.ts +4 -7
- package/package.json +1 -1
- package/pi-package-source.ts +293 -0
- package/pool.ts +23 -1
- package/provider-extensions.ts +537 -0
- package/quiescence.ts +262 -0
- package/render-branches.ts +30 -0
- package/render-result.ts +8 -5
- package/runner.ts +35 -141
- package/schema.ts +133 -202
- package/settings.ts +202 -84
- package/shared-write-safety.ts +273 -0
- package/task-resolution.ts +121 -32
- package/telemetry.ts +135 -68
- package/ticket-format.ts +331 -0
- package/tickets.ts +101 -258
- package/tools.ts +12 -0
- package/trusted-paths.ts +71 -0
- package/types.ts +83 -16
package/types.ts
CHANGED
|
@@ -41,10 +41,8 @@ export interface AgentConfig {
|
|
|
41
41
|
|
|
42
42
|
// ── Tool parameter types — derived from the TypeBox schema ────────────────
|
|
43
43
|
// `delegateArgumentsSchema` in schema.ts is the canonical provider-visible
|
|
44
|
-
// shape
|
|
45
|
-
//
|
|
46
|
-
// models. The import is type-only, so the schema.ts ↔ types.ts cycle is erased
|
|
47
|
-
// at compile time.
|
|
44
|
+
// shape; these types are its `Static<>` projections. The import is type-only,
|
|
45
|
+
// so the schema.ts ↔ types.ts cycle is erased at compile time.
|
|
48
46
|
|
|
49
47
|
type CanonicalDelegateArguments = Static<typeof delegateArgumentsSchema>;
|
|
50
48
|
type CanonicalTaskDef = NonNullable<
|
|
@@ -60,19 +58,9 @@ export type SessionAction = NonNullable<CanonicalTaskDef["sessionAction"]>;
|
|
|
60
58
|
/** Filesystem mode: shared source tree or an ephemeral CoW scratch copy. */
|
|
61
59
|
export type WorkspaceMode = NonNullable<CanonicalTaskDef["workspace"]>;
|
|
62
60
|
|
|
63
|
-
export type TaskDef = CanonicalTaskDef
|
|
64
|
-
/** @deprecated Use `sessionAction` instead. Runtime normalization still accepts this alias. */
|
|
65
|
-
action?: SessionAction;
|
|
66
|
-
};
|
|
61
|
+
export type TaskDef = CanonicalTaskDef;
|
|
67
62
|
|
|
68
|
-
export type DelegateArguments =
|
|
69
|
-
/** @deprecated Use `ticketAction` instead. Runtime normalization still accepts this alias. */
|
|
70
|
-
action?: TicketAction;
|
|
71
|
-
tasks?: TaskDef[];
|
|
72
|
-
};
|
|
73
|
-
|
|
74
|
-
/** @deprecated Use `TicketAction` instead. */
|
|
75
|
-
export type DelegateAction = TicketAction;
|
|
63
|
+
export type DelegateArguments = CanonicalDelegateArguments;
|
|
76
64
|
|
|
77
65
|
// ── Async Ticket Types ─────────────────────────────────────────────────────
|
|
78
66
|
|
|
@@ -111,8 +99,19 @@ export interface AsyncTicket {
|
|
|
111
99
|
callRecord?: CallRecord;
|
|
112
100
|
/** Runtime generation for rejecting shutdown writes from stale tickets. */
|
|
113
101
|
telemetryGeneration?: number;
|
|
102
|
+
/** Telemetry config captured at dispatch; binds shutdown aggregate rows to the
|
|
103
|
+
* same backend the call span wrote to. */
|
|
104
|
+
telemetryConfig?: import("./config.ts").TelemetryConfig;
|
|
114
105
|
/** Resolves after every async worker has settled, including shutdown aborts. */
|
|
115
106
|
completion?: Promise<void>;
|
|
107
|
+
/** False from admission until every worker has quiesced. Unlike `status`,
|
|
108
|
+
* this remains false during shutdown's early terminal transition. */
|
|
109
|
+
workersSettled?: boolean;
|
|
110
|
+
/** Batch-level warning attached to this dispatch, not to any one task. */
|
|
111
|
+
dispatchWarning?: string;
|
|
112
|
+
/** Immutable dispatch-scoped delegate.json snapshot used by async workers and
|
|
113
|
+
* later result formatting. */
|
|
114
|
+
config?: import("./config.ts").DelegateConfig;
|
|
116
115
|
}
|
|
117
116
|
|
|
118
117
|
/** Live parent settings captured when a delegate call starts. The built-in
|
|
@@ -150,6 +149,11 @@ export interface ResolvedTask {
|
|
|
150
149
|
warnings: string[];
|
|
151
150
|
/** Explicit settings that must match a live pooled session on reuse. */
|
|
152
151
|
reuseIntent?: ReuseIntent;
|
|
152
|
+
/** Stable signature of the provider-scoped extension allowlist for this task's
|
|
153
|
+
* model provider. Pool reuse compares this to the frozen session value so a
|
|
154
|
+
* revoked or reconfigured extension cannot continue executing in a reused
|
|
155
|
+
* session. */
|
|
156
|
+
providerExtensionSources?: string;
|
|
153
157
|
}
|
|
154
158
|
|
|
155
159
|
export interface ToolActivity {
|
|
@@ -207,6 +211,8 @@ export interface DelegateDetails {
|
|
|
207
211
|
/** Global overlap warning derived from result.attributedFiles, surfaced in both
|
|
208
212
|
* the textual content and the custom TUI. */
|
|
209
213
|
overlapWarning?: string;
|
|
214
|
+
/** Warning that applies to the whole dispatch rather than an individual task. */
|
|
215
|
+
dispatchWarning?: string;
|
|
210
216
|
}
|
|
211
217
|
|
|
212
218
|
export interface TaskResult {
|
|
@@ -239,8 +245,58 @@ export interface TaskResult {
|
|
|
239
245
|
* for overlap detection so concurrent tasks in the same repo do not
|
|
240
246
|
* fabricate false conflicts from shared git snapshots. */
|
|
241
247
|
attributedFiles?: string[];
|
|
248
|
+
/** Git-native proposal/reconciliation outcome for workspace:"isolated". */
|
|
249
|
+
integration?: TaskIntegration;
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
export type TaskIntegrationStatus =
|
|
253
|
+
| "applied_unverified"
|
|
254
|
+
| "no_changes"
|
|
255
|
+
| "conflict"
|
|
256
|
+
| "discarded"
|
|
257
|
+
| "apply_failed";
|
|
258
|
+
|
|
259
|
+
interface TaskIntegrationFiles {
|
|
260
|
+
proposedFiles: string[];
|
|
261
|
+
appliedFiles: string[];
|
|
242
262
|
}
|
|
243
263
|
|
|
264
|
+
interface TaskIntegrationWithoutRecovery extends TaskIntegrationFiles {
|
|
265
|
+
conflicts?: never;
|
|
266
|
+
baselineRef?: never;
|
|
267
|
+
proposalRef?: never;
|
|
268
|
+
patchPath?: never;
|
|
269
|
+
worktreePath?: never;
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
export type TaskIntegration =
|
|
273
|
+
| (TaskIntegrationWithoutRecovery & {
|
|
274
|
+
status: "applied_unverified";
|
|
275
|
+
})
|
|
276
|
+
| (TaskIntegrationWithoutRecovery & {
|
|
277
|
+
status: "no_changes";
|
|
278
|
+
})
|
|
279
|
+
| (TaskIntegrationWithoutRecovery & {
|
|
280
|
+
status: "discarded";
|
|
281
|
+
})
|
|
282
|
+
| (TaskIntegrationFiles & {
|
|
283
|
+
status: "conflict";
|
|
284
|
+
conflicts: Array<{ path: string; reason: string }>;
|
|
285
|
+
baselineRef: string;
|
|
286
|
+
proposalRef: string;
|
|
287
|
+
patchPath: string;
|
|
288
|
+
worktreePath: string;
|
|
289
|
+
})
|
|
290
|
+
| (TaskIntegrationFiles & {
|
|
291
|
+
status: "apply_failed";
|
|
292
|
+
conflicts: Array<{ path: string; reason: string }>;
|
|
293
|
+
/** Recovery metadata exists when reconciliation reached a proposal. */
|
|
294
|
+
baselineRef?: string;
|
|
295
|
+
proposalRef?: string;
|
|
296
|
+
patchPath?: string;
|
|
297
|
+
worktreePath?: string;
|
|
298
|
+
});
|
|
299
|
+
|
|
244
300
|
/** Single source of truth for a subagent's runtime configuration.
|
|
245
301
|
* Passed to `createAgentSession` as `model` / `thinkingLevel` / `tools` / `cwd`. */
|
|
246
302
|
export interface AgentRunConfig {
|
|
@@ -277,8 +333,15 @@ export interface TaskRunEnv {
|
|
|
277
333
|
telemetryCallId?: string;
|
|
278
334
|
/** Runtime generation for rejecting writes from a stale shutdown worker. */
|
|
279
335
|
telemetryGeneration?: number;
|
|
336
|
+
/** Telemetry config captured at dispatch; binds task rows to the same backend
|
|
337
|
+
* as the call span. */
|
|
338
|
+
telemetryConfig?: import("./config.ts").TelemetryConfig;
|
|
280
339
|
/** Whether this task is part of an async ticket. */
|
|
281
340
|
async?: boolean;
|
|
341
|
+
/** Immutable dispatch-scoped delegate.json snapshot. Long-lived async workers
|
|
342
|
+
* use this instead of the live singleton so retry/stall/output/provider
|
|
343
|
+
* settings stay stable for the ticket's lifetime. */
|
|
344
|
+
config?: import("./config.ts").DelegateConfig;
|
|
282
345
|
}
|
|
283
346
|
|
|
284
347
|
/** Structural subset of Pi's `ExtensionContext` used by delegate's
|
|
@@ -300,6 +363,10 @@ export interface DelegateToolCtx {
|
|
|
300
363
|
| undefined;
|
|
301
364
|
/** Optional hook Pi exposes for extensions to read the live system prompt. */
|
|
302
365
|
getSystemPrompt?: () => string | undefined;
|
|
366
|
+
/** Optional TUI notice boundary used for migration warnings. */
|
|
367
|
+
ui?: {
|
|
368
|
+
notify(message: string, level?: "info" | "warning" | "error"): void;
|
|
369
|
+
};
|
|
303
370
|
}
|
|
304
371
|
|
|
305
372
|
/** Shape returned by the delegate tool's `execute`. Mirrors Pi's
|