dsh-pentester 0.1.0-alpha.2 → 2.0.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.
- package/README.md +43 -44
- package/agents/impact/profile.yml +19 -0
- package/agents/recon/profile.yml +23 -0
- package/agents/reporting/REPORT_TEMPLATE.md +333 -0
- package/agents/reporting/profile.yml +45 -0
- package/agents/threat-model/profile.yml +19 -0
- package/agents/validation/profile.yml +20 -0
- package/agents/vulnerability/profile.yml +19 -0
- package/agents/web/profile.yml +19 -0
- package/docker/README.md +60 -0
- package/docker/kali/Dockerfile +881 -0
- package/docker/kali/README.md +104 -0
- package/docker/kali/REPORT_TEMPLATE.md +333 -0
- package/docker/kali/TOOL_PROMPT.md +361 -0
- package/docker/kali/bin/clone-kb +39 -0
- package/docker/kali/bin/entrypoint.sh +9 -0
- package/docker/kali/bin/gen-tools-json.sh +246 -0
- package/docker/kali/bin/record-traffic.sh +32 -0
- package/docker/kali/bin/tool-info +31 -0
- package/docker/kali/bin/tool-list +17 -0
- package/lib/build-id.json +1 -0
- package/lib/catalog-BmeOyr6n.js +231 -0
- package/lib/catalog-BmeOyr6n.js.map +1 -0
- package/lib/catalog-DhE_r18k.js +231 -0
- package/lib/catalog-DhE_r18k.js.map +1 -0
- package/lib/client.js +4916 -12596
- package/lib/client.js.map +4 -4
- package/lib/container-listing-BI6Xj8l2.js +56 -0
- package/lib/container-listing-BI6Xj8l2.js.map +1 -0
- package/lib/container-listing-BWZoBnN_.js +56 -0
- package/lib/container-listing-BWZoBnN_.js.map +1 -0
- package/lib/engagement-container-store-Cf-h0B4F.js +641 -0
- package/lib/engagement-container-store-Cf-h0B4F.js.map +1 -0
- package/lib/engagement-container-store-L_Gms-zi.js +632 -0
- package/lib/engagement-container-store-L_Gms-zi.js.map +1 -0
- package/lib/index.d.ts +11 -3920
- package/lib/index.js +4491 -15959
- package/lib/index.js.map +1 -1
- package/lib/model-CZoiogVs.js +149 -0
- package/lib/model-CZoiogVs.js.map +1 -0
- package/lib/model-DKZ5Rjik.js +145 -0
- package/lib/model-DKZ5Rjik.js.map +1 -0
- package/lib/worker-events-jFvaBp9x.js +351 -0
- package/lib/worker-events-jFvaBp9x.js.map +1 -0
- package/lib/worker-events-juSf0EDW.js +347 -0
- package/lib/worker-events-juSf0EDW.js.map +1 -0
- package/package.json +23 -14
- package/presets/pentester/agent.cordis.yml +221 -0
- package/presets/pentester/preset.yml +2 -0
- package/presets/pentester/run-state.mjs +219 -0
- package/presets/pentester-mode/agent.cordis.yml +0 -60
- package/presets/pentester-mode/preset.yml +0 -3
package/lib/index.d.ts
CHANGED
|
@@ -1,3938 +1,29 @@
|
|
|
1
1
|
import Schema from "@deepseek-ai/schemastery";
|
|
2
2
|
import { Context } from "@deepseek-ai/cordis";
|
|
3
|
-
//#region src/
|
|
4
|
-
interface
|
|
5
|
-
readonly verbose: boolean;
|
|
6
|
-
readonly devSeed: boolean;
|
|
7
|
-
/** UI Preview: development-only sample read model for inspecting the Pentester interface. */
|
|
8
|
-
readonly uiPreview: boolean;
|
|
9
|
-
}
|
|
10
|
-
/** Only an explicit boolean `true` enables the DEV fixture. */
|
|
11
|
-
declare function resolvePluginConfig(input: unknown): PluginConfig;
|
|
12
|
-
//#endregion
|
|
13
|
-
//#region src/runtime/config.d.ts
|
|
14
|
-
interface RuntimeConfig {
|
|
15
|
-
readonly verbose: boolean;
|
|
16
|
-
readonly devSeed: boolean;
|
|
17
|
-
readonly storageRoot: string;
|
|
18
|
-
readonly dockerSocket: string;
|
|
19
|
-
}
|
|
20
|
-
declare function resolveRuntimeConfig(input: unknown): RuntimeConfig;
|
|
21
|
-
//#endregion
|
|
22
|
-
//#region src/domain/ids.d.ts
|
|
23
|
-
type EngagementId = string & {
|
|
24
|
-
readonly __brand: 'EngagementId';
|
|
25
|
-
};
|
|
26
|
-
type TargetId = string & {
|
|
27
|
-
readonly __brand: 'TargetId';
|
|
28
|
-
};
|
|
29
|
-
type AssetId = string & {
|
|
30
|
-
readonly __brand: 'AssetId';
|
|
31
|
-
};
|
|
32
|
-
type ScopeId = string & {
|
|
33
|
-
readonly __brand: 'ScopeId';
|
|
34
|
-
};
|
|
35
|
-
type StageId = string & {
|
|
36
|
-
readonly __brand: 'StageId';
|
|
37
|
-
};
|
|
38
|
-
type TaskId = string & {
|
|
39
|
-
readonly __brand: 'TaskId';
|
|
40
|
-
};
|
|
41
|
-
type AgentTemplateId = string & {
|
|
42
|
-
readonly __brand: 'AgentTemplateId';
|
|
43
|
-
};
|
|
44
|
-
type AgentRunId = string & {
|
|
45
|
-
readonly __brand: 'AgentRunId';
|
|
46
|
-
};
|
|
47
|
-
type SkillId = string & {
|
|
48
|
-
readonly __brand: 'SkillId';
|
|
49
|
-
};
|
|
50
|
-
type McpServerId = string & {
|
|
51
|
-
readonly __brand: 'McpServerId';
|
|
52
|
-
};
|
|
53
|
-
type ToolboxId = string & {
|
|
54
|
-
readonly __brand: 'ToolboxId';
|
|
55
|
-
};
|
|
56
|
-
type ToolId = string & {
|
|
57
|
-
readonly __brand: 'ToolId';
|
|
58
|
-
};
|
|
59
|
-
type ToolCallId = string & {
|
|
60
|
-
readonly __brand: 'ToolCallId';
|
|
61
|
-
};
|
|
62
|
-
type ArtifactId = string & {
|
|
63
|
-
readonly __brand: 'ArtifactId';
|
|
64
|
-
};
|
|
65
|
-
type EvidenceId = string & {
|
|
66
|
-
readonly __brand: 'EvidenceId';
|
|
67
|
-
};
|
|
68
|
-
type FindingId = string & {
|
|
69
|
-
readonly __brand: 'FindingId';
|
|
70
|
-
};
|
|
71
|
-
type FindingOccurrenceId = string & {
|
|
72
|
-
readonly __brand: 'FindingOccurrenceId';
|
|
73
|
-
};
|
|
74
|
-
type EventId = string & {
|
|
75
|
-
readonly __brand: 'EventId';
|
|
76
|
-
};
|
|
77
|
-
//#endregion
|
|
78
|
-
//#region src/domain/workflow/stages.d.ts
|
|
79
|
-
declare const PTES_STAGE_KINDS: readonly ["pre-engagement", "intelligence-gathering", "threat-modeling", "vulnerability-analysis", "exploitation", "post-exploitation", "reporting"];
|
|
80
|
-
type PtesStageKind = (typeof PTES_STAGE_KINDS)[number];
|
|
81
|
-
//#endregion
|
|
82
|
-
//#region src/config/types.d.ts
|
|
83
|
-
/**
|
|
84
|
-
* Global Pentester Configuration domain model (ADR-0006).
|
|
85
|
-
*
|
|
86
|
-
* Three layers:
|
|
87
|
-
* Factory Defaults — code-built, version-controlled, authoritative baseline.
|
|
88
|
-
* Global Overrides — user-edited replacements for built-in entities + custom
|
|
89
|
-
* entities + disabled built-in ids, persisted.
|
|
90
|
-
* Effective Config — Factory ⊕ Overrides ∖ Disabled, resolved at runtime.
|
|
91
|
-
*
|
|
92
|
-
* Never store the full Factory catalog in the persisted Global config; only
|
|
93
|
-
* overrides/custom/disabled survive (see PentesterGlobalConfigV1).
|
|
94
|
-
*/
|
|
95
|
-
type ConfigEntitySource = 'builtin' | 'custom';
|
|
96
|
-
interface BaseConfigEntity {
|
|
97
|
-
readonly id: string;
|
|
98
|
-
readonly name: string;
|
|
99
|
-
readonly description: string;
|
|
100
|
-
readonly enabled: boolean;
|
|
101
|
-
readonly source: ConfigEntitySource;
|
|
102
|
-
readonly revision: number;
|
|
103
|
-
}
|
|
104
|
-
/** Global-config Agent definition. Resolves to a runtime AgentTemplate. */
|
|
105
|
-
interface AgentConfigEntity extends BaseConfigEntity {
|
|
106
|
-
readonly id: AgentTemplateId;
|
|
107
|
-
readonly instructions: string;
|
|
108
|
-
readonly skillIds: readonly SkillId[];
|
|
109
|
-
readonly mcpServerIds: readonly McpServerId[];
|
|
110
|
-
readonly allowedToolboxIds: readonly ToolboxId[];
|
|
111
|
-
readonly primaryToolboxId?: ToolboxId;
|
|
112
|
-
}
|
|
113
|
-
/** A Pentester Worker knowledge / procedural instruction (no execution power). */
|
|
114
|
-
interface SkillConfigEntity extends BaseConfigEntity {
|
|
115
|
-
readonly id: SkillId;
|
|
116
|
-
readonly instructions: string;
|
|
117
|
-
}
|
|
118
|
-
type McpConfigLifecycle = 'agent_run' | 'engagement';
|
|
119
|
-
/** Environment reference (never a plaintext secret). */
|
|
120
|
-
interface McpEnvVar {
|
|
121
|
-
readonly name: string;
|
|
122
|
-
/** Host env var name to inherit (secret reference), not a literal value. */
|
|
123
|
-
readonly sourceEnv: string;
|
|
124
|
-
}
|
|
125
|
-
interface McpConfigEntity extends BaseConfigEntity {
|
|
126
|
-
readonly id: McpServerId;
|
|
127
|
-
readonly transport: 'stdio';
|
|
128
|
-
readonly command: string;
|
|
129
|
-
readonly args: readonly string[];
|
|
130
|
-
readonly env: readonly McpEnvVar[];
|
|
131
|
-
readonly lifecycle: McpConfigLifecycle;
|
|
132
|
-
}
|
|
133
|
-
type ToolboxImageSource = 'builtin' | 'pull' | 'dockerfile';
|
|
134
|
-
interface ToolboxImageDefinition {
|
|
135
|
-
readonly source: ToolboxImageSource;
|
|
136
|
-
readonly ref: string;
|
|
137
|
-
readonly dockerfilePath?: string;
|
|
138
|
-
readonly buildContext?: string;
|
|
139
|
-
}
|
|
140
|
-
interface ToolboxConfigEntity extends BaseConfigEntity {
|
|
141
|
-
readonly id: ToolboxId;
|
|
142
|
-
readonly image: ToolboxImageDefinition;
|
|
143
|
-
readonly lifecycle: McpConfigLifecycle;
|
|
144
|
-
}
|
|
145
|
-
/** Which Agents are AVAILABLE to the Orchestrator during one fixed PTES Stage. */
|
|
146
|
-
interface StageAgentPolicy {
|
|
147
|
-
readonly stageId: StageId;
|
|
148
|
-
readonly stageKind: PtesStageKind;
|
|
149
|
-
readonly allowedAgentTemplateIds: readonly AgentTemplateId[];
|
|
150
|
-
}
|
|
151
|
-
interface EntityOverrideSet<T extends BaseConfigEntity> {
|
|
152
|
-
/** id → Global replacement for a built-in entity. */
|
|
153
|
-
readonly builtinOverrides: Readonly<Record<string, T>>;
|
|
154
|
-
/** id → custom entity (id starts with a custom prefix, never collides with factory). */
|
|
155
|
-
readonly custom: Readonly<Record<string, T>>;
|
|
156
|
-
/** Built-in ids disabled in the Global layer. */
|
|
157
|
-
readonly disabledBuiltinIds: readonly string[];
|
|
158
|
-
}
|
|
159
|
-
interface PentesterGlobalConfigV1 {
|
|
160
|
-
readonly schemaVersion: 1;
|
|
161
|
-
readonly globalRevision: number;
|
|
162
|
-
readonly agents: EntityOverrideSet<AgentConfigEntity>;
|
|
163
|
-
readonly skills: EntityOverrideSet<SkillConfigEntity>;
|
|
164
|
-
readonly mcpServers: EntityOverrideSet<McpConfigEntity>;
|
|
165
|
-
readonly toolboxes: EntityOverrideSet<ToolboxConfigEntity>;
|
|
166
|
-
readonly stageOverrides: Readonly<Record<string, readonly AgentTemplateId[]>>;
|
|
167
|
-
}
|
|
168
|
-
interface EffectivePentesterConfig {
|
|
169
|
-
readonly globalRevision: number;
|
|
170
|
-
readonly agents: Readonly<Record<AgentTemplateId, AgentConfigEntity>>;
|
|
171
|
-
readonly skills: Readonly<Record<SkillId, SkillConfigEntity>>;
|
|
172
|
-
readonly mcpServers: Readonly<Record<McpServerId, McpConfigEntity>>;
|
|
173
|
-
readonly toolboxes: Readonly<Record<ToolboxId, ToolboxConfigEntity>>;
|
|
174
|
-
readonly stagePolicies: Readonly<Record<StageId, StageAgentPolicy>>;
|
|
175
|
-
}
|
|
176
|
-
//#endregion
|
|
177
|
-
//#region src/domain/agent.d.ts
|
|
178
|
-
type AgentTemplateKind = 'built-in' | 'user';
|
|
179
|
-
interface AgentTemplate {
|
|
180
|
-
readonly id: AgentTemplateId;
|
|
181
|
-
readonly kind: AgentTemplateKind;
|
|
182
|
-
readonly name: string;
|
|
183
|
-
readonly description: string;
|
|
184
|
-
readonly rolePrompt: string;
|
|
185
|
-
readonly model?: string;
|
|
186
|
-
readonly skillIds: readonly SkillId[];
|
|
187
|
-
readonly mcpServerIds: readonly McpServerId[];
|
|
188
|
-
readonly allowedToolboxIds: readonly ToolboxId[];
|
|
189
|
-
readonly attachedStages: readonly PtesStageKind[];
|
|
190
|
-
}
|
|
191
|
-
declare const AGENT_RUN_STATUSES: readonly ["created", "running", "blocked", "completed", "failed", "cancelled", "interrupted"];
|
|
192
|
-
type AgentRunStatus = (typeof AGENT_RUN_STATUSES)[number];
|
|
193
|
-
/**
|
|
194
|
-
* Immutable configuration snapshot captured when an AgentRun is created.
|
|
195
|
-
* A running Worker must never change mid-flight when Global Settings change:
|
|
196
|
-
* instructions / skills / MCP / Docker image stay exactly as snapshotted.
|
|
197
|
-
*/
|
|
198
|
-
interface AgentRunConfigSnapshot {
|
|
199
|
-
readonly agentTemplateId: AgentTemplateId;
|
|
200
|
-
readonly agentTemplateRevision: number;
|
|
201
|
-
readonly agentName: string;
|
|
202
|
-
readonly instructions: string;
|
|
203
|
-
readonly skillIds: readonly SkillId[];
|
|
204
|
-
readonly mcpServerIds: readonly McpServerId[];
|
|
205
|
-
readonly allowedToolboxIds: readonly ToolboxId[];
|
|
206
|
-
readonly primaryToolboxId?: ToolboxId;
|
|
207
|
-
}
|
|
208
|
-
interface AgentRun {
|
|
209
|
-
readonly id: AgentRunId;
|
|
210
|
-
readonly engagementId: EngagementId;
|
|
211
|
-
readonly templateId: AgentTemplateId;
|
|
212
|
-
readonly status: AgentRunStatus;
|
|
213
|
-
readonly taskIds: readonly TaskId[];
|
|
214
|
-
readonly currentTaskId?: TaskId;
|
|
215
|
-
/** Immutable Global-config snapshot captured at creation (rev-stable). */
|
|
216
|
-
readonly configSnapshot?: AgentRunConfigSnapshot;
|
|
217
|
-
}
|
|
218
|
-
//#endregion
|
|
219
|
-
//#region src/domain/artifact.d.ts
|
|
220
|
-
declare const ARTIFACT_KINDS: readonly ["asset", "service", "endpoint", "technology", "observation", "attack-surface", "attack-path", "hypothesis", "impact", "other"];
|
|
221
|
-
type ArtifactKind = (typeof ARTIFACT_KINDS)[number];
|
|
222
|
-
interface ArtifactProvenance {
|
|
223
|
-
readonly sourcePtapMessageId: string;
|
|
224
|
-
readonly createdInStageId: StageId;
|
|
225
|
-
readonly producedByTaskId: TaskId;
|
|
226
|
-
readonly producedByAgentRunId: AgentRunId;
|
|
227
|
-
readonly observedAt: string;
|
|
228
|
-
}
|
|
229
|
-
interface ArtifactIdentityFields {
|
|
230
|
-
readonly assetValue?: string;
|
|
231
|
-
readonly assetId?: string;
|
|
232
|
-
readonly protocol?: string;
|
|
233
|
-
readonly port?: number;
|
|
234
|
-
readonly serviceId?: string;
|
|
235
|
-
readonly method?: string;
|
|
236
|
-
readonly path?: string;
|
|
237
|
-
readonly ownerRef?: string;
|
|
238
|
-
readonly technologyName?: string;
|
|
239
|
-
}
|
|
240
|
-
interface Artifact {
|
|
241
|
-
readonly id: ArtifactId;
|
|
242
|
-
readonly engagementId: EngagementId;
|
|
243
|
-
readonly kind: ArtifactKind;
|
|
244
|
-
readonly createdInStageId: StageId;
|
|
245
|
-
readonly producedByTaskId: TaskId;
|
|
246
|
-
readonly producedByAgentRunId: AgentRunId;
|
|
247
|
-
readonly evidenceIds: readonly EvidenceId[];
|
|
248
|
-
readonly summary: string;
|
|
249
|
-
readonly identityKey?: string;
|
|
250
|
-
readonly identity?: ArtifactIdentityFields;
|
|
251
|
-
readonly provenance: readonly ArtifactProvenance[];
|
|
252
|
-
}
|
|
253
|
-
/** Protocol-facing draft. PTES Core assigns `ArtifactId` on persist. */
|
|
254
|
-
interface ArtifactSubmission extends ArtifactIdentityFields {
|
|
255
|
-
readonly kind: ArtifactKind;
|
|
256
|
-
readonly summary: string;
|
|
257
|
-
readonly evidenceRefs?: readonly string[];
|
|
258
|
-
}
|
|
259
|
-
//#endregion
|
|
260
|
-
//#region src/domain/capability.d.ts
|
|
261
|
-
type CapabilityReference = {
|
|
262
|
-
readonly kind: 'skill';
|
|
263
|
-
readonly skillId: SkillId;
|
|
264
|
-
} | {
|
|
265
|
-
readonly kind: 'mcp';
|
|
266
|
-
readonly mcpServerId: McpServerId;
|
|
267
|
-
} | {
|
|
268
|
-
readonly kind: 'toolbox';
|
|
269
|
-
readonly toolboxId: ToolboxId;
|
|
270
|
-
};
|
|
271
|
-
//#endregion
|
|
272
|
-
//#region src/domain/evidence.d.ts
|
|
273
|
-
declare const EVIDENCE_KINDS: readonly ["http-request", "http-response", "screenshot", "tool-output", "file", "raw-scanner-output", "other"];
|
|
274
|
-
type EvidenceKind = (typeof EVIDENCE_KINDS)[number];
|
|
275
|
-
interface Evidence {
|
|
276
|
-
readonly id: EvidenceId;
|
|
277
|
-
readonly engagementId: EngagementId;
|
|
278
|
-
readonly kind: EvidenceKind;
|
|
279
|
-
readonly producedByTaskId?: TaskId;
|
|
280
|
-
readonly producedByAgentRunId?: AgentRunId;
|
|
281
|
-
readonly ref: string;
|
|
282
|
-
readonly summary: string;
|
|
283
|
-
readonly mediaType?: string;
|
|
284
|
-
readonly sizeBytes: number;
|
|
285
|
-
readonly sha256: string;
|
|
286
|
-
readonly createdInStageId: StageId;
|
|
287
|
-
readonly sourcePtapMessageId: string;
|
|
288
|
-
readonly createdAt: string;
|
|
289
|
-
}
|
|
290
|
-
/** Protocol-facing draft. Small content may be inline; large content uses `ref`. */
|
|
291
|
-
interface EvidenceSubmission {
|
|
292
|
-
readonly kind: EvidenceKind;
|
|
293
|
-
readonly summary: string;
|
|
294
|
-
readonly content?: string;
|
|
295
|
-
readonly ref?: string;
|
|
296
|
-
readonly mediaType?: string;
|
|
297
|
-
}
|
|
298
|
-
//#endregion
|
|
299
|
-
//#region src/domain/finding.d.ts
|
|
300
|
-
declare const FINDING_STATUSES: readonly ["candidate", "validating", "confirmed", "unconfirmed", "false_positive"];
|
|
301
|
-
type FindingStatus = (typeof FINDING_STATUSES)[number];
|
|
302
|
-
declare const FINDING_SEVERITIES: readonly ["info", "low", "medium", "high", "critical"];
|
|
303
|
-
type FindingSeverity = (typeof FINDING_SEVERITIES)[number];
|
|
304
|
-
interface Finding {
|
|
305
|
-
readonly id: FindingId;
|
|
306
|
-
readonly engagementId: EngagementId;
|
|
307
|
-
readonly title: string;
|
|
308
|
-
readonly severity: FindingSeverity;
|
|
309
|
-
readonly confidence: number;
|
|
310
|
-
readonly status: FindingStatus;
|
|
311
|
-
readonly occurrenceIds: readonly FindingOccurrenceId[];
|
|
312
|
-
readonly category?: string;
|
|
313
|
-
readonly weakness?: string;
|
|
314
|
-
readonly cwe?: string;
|
|
315
|
-
readonly identityKey?: string;
|
|
316
|
-
readonly createdInStageId?: StageId;
|
|
317
|
-
readonly producedByTaskId?: TaskId;
|
|
318
|
-
readonly producedByAgentRunId?: AgentRunId;
|
|
319
|
-
}
|
|
320
|
-
interface FindingOccurrence {
|
|
321
|
-
readonly id: FindingOccurrenceId;
|
|
322
|
-
readonly findingId: FindingId;
|
|
323
|
-
readonly engagementId: EngagementId;
|
|
324
|
-
readonly assetId: AssetId;
|
|
325
|
-
readonly endpoint?: string;
|
|
326
|
-
readonly serviceId?: string;
|
|
327
|
-
readonly evidenceIds: readonly EvidenceId[];
|
|
328
|
-
readonly reproductionContext?: string;
|
|
329
|
-
readonly status: FindingStatus;
|
|
330
|
-
readonly identityKey?: string;
|
|
331
|
-
}
|
|
332
|
-
interface FindingOccurrenceSubmission {
|
|
333
|
-
readonly assetId: string;
|
|
334
|
-
readonly endpoint?: string;
|
|
335
|
-
readonly serviceId?: string;
|
|
336
|
-
readonly evidenceRefs?: readonly string[];
|
|
337
|
-
readonly reproductionContext?: string;
|
|
338
|
-
}
|
|
339
|
-
/** Protocol-facing draft. PTES Core assigns `FindingId` on persist. */
|
|
340
|
-
interface FindingSubmission {
|
|
341
|
-
readonly title: string;
|
|
342
|
-
readonly severity: FindingSeverity;
|
|
343
|
-
readonly confidence: number;
|
|
344
|
-
readonly status: FindingStatus;
|
|
345
|
-
readonly summary?: string;
|
|
346
|
-
readonly category?: string;
|
|
347
|
-
readonly weakness?: string;
|
|
348
|
-
readonly cwe?: string;
|
|
349
|
-
readonly occurrence?: FindingOccurrenceSubmission;
|
|
350
|
-
}
|
|
351
|
-
//#endregion
|
|
352
|
-
//#region src/domain/ptap.d.ts
|
|
353
|
-
declare const PTAP_PROTOCOL: "ptap";
|
|
354
|
-
declare const PTAP_VERSION: 1;
|
|
355
|
-
declare const PTAP_COMMAND_TYPES: readonly ["task.request", "steer.message", "delegate.decision", "capability.decision"];
|
|
356
|
-
declare const PTAP_EVENT_TYPES: readonly ["progress.updated", "artifact.produced", "evidence.produced", "finding.produced", "delegate.requested", "capability.requested", "task.completed", "task.failed", "task.blocked"];
|
|
357
|
-
type PtapCommandType = (typeof PTAP_COMMAND_TYPES)[number];
|
|
358
|
-
type PtapEventType = (typeof PTAP_EVENT_TYPES)[number];
|
|
359
|
-
type PtapMessageType = PtapCommandType | PtapEventType;
|
|
360
|
-
declare const AGENT_PROGRESS_STATUSES: readonly ["planning", "working", "waiting", "blocked", "finalizing"];
|
|
361
|
-
type AgentProgressStatus = (typeof AGENT_PROGRESS_STATUSES)[number];
|
|
362
|
-
declare const STEER_SOURCES: readonly ["user", "orchestrator"];
|
|
363
|
-
type SteerSource = (typeof STEER_SOURCES)[number];
|
|
364
|
-
declare const DELEGATE_DECISIONS: readonly ["accepted", "rejected"];
|
|
365
|
-
type DelegateDecision = (typeof DELEGATE_DECISIONS)[number];
|
|
366
|
-
declare const CAPABILITY_DECISIONS: readonly ["granted", "denied"];
|
|
367
|
-
type CapabilityDecision = (typeof CAPABILITY_DECISIONS)[number];
|
|
368
|
-
declare const TASK_CONSTRAINT_PRIORITIES: readonly ["low", "normal", "high"];
|
|
369
|
-
type TaskConstraintPriority = (typeof TASK_CONSTRAINT_PRIORITIES)[number];
|
|
370
|
-
type PtapMessageId = string & {
|
|
371
|
-
readonly __brand: 'PtapMessageId';
|
|
372
|
-
};
|
|
373
|
-
type PtapRequestId = string & {
|
|
374
|
-
readonly __brand: 'PtapRequestId';
|
|
375
|
-
};
|
|
376
|
-
interface PtapEnvelope<TType extends PtapMessageType, TPayload> {
|
|
377
|
-
readonly protocol: typeof PTAP_PROTOCOL;
|
|
378
|
-
readonly version: typeof PTAP_VERSION;
|
|
379
|
-
readonly messageId: PtapMessageId;
|
|
380
|
-
readonly type: TType;
|
|
381
|
-
readonly engagementId: EngagementId;
|
|
382
|
-
readonly stageId: StageId;
|
|
383
|
-
readonly taskId: TaskId;
|
|
384
|
-
readonly agentRunId: AgentRunId;
|
|
385
|
-
readonly timestamp: string;
|
|
386
|
-
readonly payload: TPayload;
|
|
387
|
-
}
|
|
388
|
-
interface PtapInputRefs {
|
|
389
|
-
readonly assets?: readonly AssetId[];
|
|
390
|
-
readonly artifacts?: readonly ArtifactId[];
|
|
391
|
-
readonly evidence?: readonly EvidenceId[];
|
|
392
|
-
readonly findings?: readonly FindingId[];
|
|
393
|
-
}
|
|
394
|
-
interface TaskRequestPayload {
|
|
395
|
-
readonly goal: string;
|
|
396
|
-
readonly instructions?: string;
|
|
397
|
-
readonly inputRefs?: PtapInputRefs;
|
|
398
|
-
readonly constraints?: {
|
|
399
|
-
readonly priority?: TaskConstraintPriority;
|
|
400
|
-
};
|
|
401
|
-
}
|
|
402
|
-
interface SteerMessagePayload {
|
|
403
|
-
readonly message: string;
|
|
404
|
-
readonly source: SteerSource;
|
|
405
|
-
}
|
|
406
|
-
interface DelegateDecisionPayload {
|
|
407
|
-
readonly requestId: PtapRequestId;
|
|
408
|
-
readonly decision: DelegateDecision;
|
|
409
|
-
readonly reason?: string;
|
|
410
|
-
readonly createdTaskId?: TaskId;
|
|
411
|
-
}
|
|
412
|
-
interface CapabilityDecisionPayload {
|
|
413
|
-
readonly requestId: PtapRequestId;
|
|
414
|
-
readonly decision: CapabilityDecision;
|
|
415
|
-
readonly reason?: string;
|
|
416
|
-
}
|
|
417
|
-
interface ProgressUpdatedPayload {
|
|
418
|
-
readonly status: AgentProgressStatus;
|
|
419
|
-
readonly summary: string;
|
|
420
|
-
readonly currentAction?: string;
|
|
421
|
-
}
|
|
422
|
-
interface ArtifactProducedPayload {
|
|
423
|
-
readonly artifact: ArtifactSubmission;
|
|
424
|
-
readonly summary?: string;
|
|
425
|
-
readonly reportWorthy?: boolean;
|
|
426
|
-
}
|
|
427
|
-
interface EvidenceProducedPayload {
|
|
428
|
-
readonly evidence: EvidenceSubmission;
|
|
429
|
-
readonly summary?: string;
|
|
430
|
-
readonly reportWorthy?: boolean;
|
|
431
|
-
}
|
|
432
|
-
interface FindingProducedPayload {
|
|
433
|
-
readonly finding: FindingSubmission;
|
|
434
|
-
readonly summary?: string;
|
|
435
|
-
readonly reportWorthy?: boolean;
|
|
436
|
-
}
|
|
437
|
-
interface DelegateRequestedPayload {
|
|
438
|
-
readonly requestId: PtapRequestId;
|
|
439
|
-
readonly goal: string;
|
|
440
|
-
readonly reason: string;
|
|
441
|
-
readonly preferredAgentTemplateId?: AgentTemplateId;
|
|
442
|
-
readonly inputRefs?: PtapInputRefs;
|
|
443
|
-
}
|
|
444
|
-
interface CapabilityRequestedPayload {
|
|
445
|
-
readonly requestId: PtapRequestId;
|
|
446
|
-
readonly capability: CapabilityReference;
|
|
447
|
-
readonly reason: string;
|
|
448
|
-
}
|
|
449
|
-
interface SuggestedTask {
|
|
450
|
-
readonly goal: string;
|
|
451
|
-
readonly reason?: string;
|
|
452
|
-
readonly preferredAgentTemplateId?: AgentTemplateId;
|
|
453
|
-
}
|
|
454
|
-
interface TaskCompletedPayload {
|
|
455
|
-
readonly summary: string;
|
|
456
|
-
readonly produced?: {
|
|
457
|
-
readonly artifacts?: readonly PtapMessageId[];
|
|
458
|
-
readonly evidence?: readonly PtapMessageId[];
|
|
459
|
-
readonly findings?: readonly PtapMessageId[];
|
|
460
|
-
};
|
|
461
|
-
readonly suggestedTasks?: readonly SuggestedTask[];
|
|
462
|
-
/** P1-5: which exit criteria this completion satisfied (typed, not prose). */
|
|
463
|
-
readonly exitCondition?: {
|
|
464
|
-
/** Stable machine code (e.g. "recon-service-inventory"). */
|
|
465
|
-
readonly code: string;
|
|
466
|
-
readonly satisfiedCriteria: readonly string[];
|
|
467
|
-
};
|
|
468
|
-
}
|
|
469
|
-
interface TaskFailedPayload {
|
|
470
|
-
readonly summary: string;
|
|
471
|
-
readonly code?: string;
|
|
472
|
-
readonly retryable: boolean;
|
|
473
|
-
readonly details?: string;
|
|
474
|
-
}
|
|
475
|
-
/**
|
|
476
|
-
* A Worker declares its Task blocked: it cannot make progress on its own and
|
|
477
|
-
* requires Orchestrator/user intervention. `reasonCode` is a stable machine
|
|
478
|
-
* code (e.g. `missing_credentials`, `user_decision_required`,
|
|
479
|
-
* `target_unreachable`); `recoverable` tells the Orchestrator whether a later
|
|
480
|
-
* continue/steer can resume the Task.
|
|
481
|
-
*/
|
|
482
|
-
interface TaskBlockedPayload {
|
|
483
|
-
readonly summary: string;
|
|
484
|
-
readonly reasonCode: string;
|
|
485
|
-
/** True when a later continue/steer may resume the Task. */
|
|
486
|
-
readonly recoverable: boolean;
|
|
487
|
-
/** Optional machine-readable diagnostics (never secrets). */
|
|
488
|
-
readonly diagnostics?: readonly string[];
|
|
489
|
-
}
|
|
490
|
-
type TaskRequestMessage = PtapEnvelope<'task.request', TaskRequestPayload>;
|
|
491
|
-
type SteerMessage = PtapEnvelope<'steer.message', SteerMessagePayload>;
|
|
492
|
-
type DelegateDecisionMessage = PtapEnvelope<'delegate.decision', DelegateDecisionPayload>;
|
|
493
|
-
type CapabilityDecisionMessage = PtapEnvelope<'capability.decision', CapabilityDecisionPayload>;
|
|
494
|
-
type ProgressUpdatedMessage = PtapEnvelope<'progress.updated', ProgressUpdatedPayload>;
|
|
495
|
-
type ArtifactProducedMessage = PtapEnvelope<'artifact.produced', ArtifactProducedPayload>;
|
|
496
|
-
type EvidenceProducedMessage = PtapEnvelope<'evidence.produced', EvidenceProducedPayload>;
|
|
497
|
-
type FindingProducedMessage = PtapEnvelope<'finding.produced', FindingProducedPayload>;
|
|
498
|
-
type DelegateRequestedMessage = PtapEnvelope<'delegate.requested', DelegateRequestedPayload>;
|
|
499
|
-
type CapabilityRequestedMessage = PtapEnvelope<'capability.requested', CapabilityRequestedPayload>;
|
|
500
|
-
type TaskCompletedMessage = PtapEnvelope<'task.completed', TaskCompletedPayload>;
|
|
501
|
-
type TaskFailedMessage = PtapEnvelope<'task.failed', TaskFailedPayload>;
|
|
502
|
-
type TaskBlockedMessage = PtapEnvelope<'task.blocked', TaskBlockedPayload>;
|
|
503
|
-
type PtapCommand = TaskRequestMessage | SteerMessage | DelegateDecisionMessage | CapabilityDecisionMessage;
|
|
504
|
-
type PtapEvent = ProgressUpdatedMessage | ArtifactProducedMessage | EvidenceProducedMessage | FindingProducedMessage | DelegateRequestedMessage | CapabilityRequestedMessage | TaskCompletedMessage | TaskFailedMessage | TaskBlockedMessage;
|
|
505
|
-
type PtapMessage = PtapCommand | PtapEvent;
|
|
506
|
-
//#endregion
|
|
507
|
-
//#region src/domain/orchestrator.d.ts
|
|
508
|
-
declare const ORCHESTRATOR_DECISION_TYPES: readonly ["create_task", "continue_agent_run", "cancel_task", "request_stage_transition", "delegate_response", "capability_response", "noop"];
|
|
509
|
-
type OrchestratorDecisionType = (typeof ORCHESTRATOR_DECISION_TYPES)[number];
|
|
510
|
-
declare const ORCHESTRATOR_WAKE_KINDS: readonly ["engagement.created", "user.message", "task.completed", "task.blocked", "task.failed", "task.cancelled", "task.interrupted", "delegate.requested", "capability.requested", "finding.produced", "artifact.important", "workflow.result", "engagement.recovered", "agent.steered"];
|
|
511
|
-
type OrchestratorWakeKind = (typeof ORCHESTRATOR_WAKE_KINDS)[number];
|
|
512
|
-
interface OrchestratorWakeEvent {
|
|
513
|
-
readonly kind: OrchestratorWakeKind;
|
|
514
|
-
readonly engagementId: EngagementId;
|
|
515
|
-
/**
|
|
516
|
-
* Task whose terminal event (completed/blocked/failed) produced this wake.
|
|
517
|
-
* Used by the Parent Wakeup Bridge to build a deterministic delta and to
|
|
518
|
-
* deduplicate wakes by (taskId, terminalEventId).
|
|
519
|
-
*/
|
|
520
|
-
readonly taskId?: TaskId;
|
|
521
|
-
/** The canonical store eventId of the terminal transition (idempotency key). */
|
|
522
|
-
readonly terminalEventId?: EventId;
|
|
523
|
-
}
|
|
524
|
-
interface OrchestratorReasoningOutput {
|
|
525
|
-
readonly summary?: string;
|
|
526
|
-
readonly decisions: readonly unknown[];
|
|
527
|
-
}
|
|
528
|
-
declare const ORCHESTRATOR_REJECTION_REASONS: readonly ["template_not_found", "agent_not_found", "agent_disabled", "stage_agent_not_allowed", "agent_configuration_invalid", "template_not_eligible", "invalid_parent_task", "invalid_continuation", "agent_run_not_found", "capability_not_allowed", "invalid_stage", "stage_mismatch", "source_not_allowed", "scope_violation", "stale_decision", "unsupported_decision", "invalid_decision", "invalid_arguments", "runtime_contract_error"];
|
|
529
|
-
type OrchestratorRejectionReason = (typeof ORCHESTRATOR_REJECTION_REASONS)[number];
|
|
530
|
-
type OrchestratorDecisionResult = {
|
|
531
|
-
readonly status: 'accepted';
|
|
532
|
-
readonly type: OrchestratorDecisionType;
|
|
533
|
-
readonly taskId?: TaskId;
|
|
534
|
-
readonly agentRunId?: AgentRunId;
|
|
535
|
-
readonly runStatus?: string;
|
|
536
|
-
} | {
|
|
537
|
-
readonly status: 'rejected';
|
|
538
|
-
readonly reason: OrchestratorRejectionReason;
|
|
539
|
-
readonly message?: string;
|
|
540
|
-
readonly currentStageKind?: string;
|
|
541
|
-
readonly requestedStageKind?: string;
|
|
542
|
-
readonly nextAction?: string;
|
|
543
|
-
readonly repeated_rejection?: boolean;
|
|
544
|
-
} | {
|
|
545
|
-
readonly status: 'failed';
|
|
546
|
-
readonly message: string;
|
|
547
|
-
};
|
|
548
|
-
/**
|
|
549
|
-
* P0-A: a Task's canonical terminal status. A Task reaches one of these ONLY
|
|
550
|
-
* through a terminal PTAP (ptap_complete_task / ptap_block_task /
|
|
551
|
-
* ptap_fail_task), the Worker Finalizer, or a user-initiated cancel
|
|
552
|
-
* (pentester_cancel_task / Stop). A plain DSH turn/end never equals
|
|
553
|
-
* completion — it is finalized as `failed` (WORKER_TERMINATED_WITHOUT_TASK_TERMINAL).
|
|
554
|
-
* P0-3/P0-5: `cancelled` is a real user-initiated terminal state — never
|
|
555
|
-
* recorded as failed.
|
|
556
|
-
*/
|
|
557
|
-
declare const TASK_TERMINAL_STATUSES: readonly ["completed", "blocked", "failed", "cancelled"];
|
|
558
|
-
type TaskTerminalStatus = (typeof TASK_TERMINAL_STATUSES)[number];
|
|
559
|
-
/**
|
|
560
|
-
* Deterministic terminal payload handed to the Parent Wakeup Bridge. The
|
|
561
|
-
* Orchestrator re-reads canonical state from these fields — never from the
|
|
562
|
-
* Worker's final prose.
|
|
563
|
-
*/
|
|
564
|
-
interface TaskTerminalInfo {
|
|
565
|
-
readonly engagementId: EngagementId;
|
|
566
|
-
readonly taskId: TaskId;
|
|
567
|
-
readonly agentRunId: AgentRunId;
|
|
568
|
-
readonly status: TaskTerminalStatus;
|
|
569
|
-
/** Canonical store eventId of the terminal transition (idempotency key). */
|
|
570
|
-
readonly terminalEventId: EventId;
|
|
571
|
-
readonly summary: string;
|
|
572
|
-
readonly reasonCode?: string;
|
|
573
|
-
readonly recoverable?: boolean;
|
|
574
|
-
readonly details?: string;
|
|
575
|
-
readonly produced?: {
|
|
576
|
-
readonly artifacts?: readonly string[];
|
|
577
|
-
readonly evidence?: readonly string[];
|
|
578
|
-
readonly findings?: readonly string[];
|
|
579
|
-
};
|
|
580
|
-
}
|
|
581
|
-
//#endregion
|
|
582
|
-
//#region src/domain/workflow.d.ts
|
|
583
|
-
declare const WORKFLOW_TRANSITION_MODES: readonly ["normal", "manual_override", "skip"];
|
|
584
|
-
type WorkflowTransitionMode = (typeof WORKFLOW_TRANSITION_MODES)[number];
|
|
585
|
-
declare const WORKFLOW_TRANSITION_SOURCES: readonly ["orchestrator", "user"];
|
|
586
|
-
type WorkflowTransitionSource = (typeof WORKFLOW_TRANSITION_SOURCES)[number];
|
|
587
|
-
declare const WORKFLOW_REJECTION_REASONS: readonly ["source_not_allowed", "no_active_stage", "from_stage_mismatch", "not_next_stage", "criteria_unsatisfied", "stale_transition", "invalid_stage_state", "workflow_complete"];
|
|
588
|
-
type WorkflowTransitionRejectionReason = (typeof WORKFLOW_REJECTION_REASONS)[number];
|
|
589
|
-
interface WorkflowTransitionRequest {
|
|
590
|
-
readonly engagementId: EngagementId;
|
|
591
|
-
readonly fromStageId: StageId;
|
|
592
|
-
readonly toStageId?: StageId;
|
|
593
|
-
readonly mode: WorkflowTransitionMode;
|
|
594
|
-
readonly source: WorkflowTransitionSource;
|
|
595
|
-
/** P1-6: human-readable skip reason (user instruction). */
|
|
596
|
-
readonly reason?: string;
|
|
597
|
-
}
|
|
598
|
-
interface StageTaskFacts {
|
|
599
|
-
readonly total: number;
|
|
600
|
-
readonly pending: number;
|
|
601
|
-
readonly running: number;
|
|
602
|
-
readonly completed: number;
|
|
603
|
-
readonly failed: number;
|
|
604
|
-
readonly cancelled: number;
|
|
605
|
-
readonly interrupted: number;
|
|
606
|
-
readonly blocked: number;
|
|
607
|
-
}
|
|
608
|
-
interface WorkflowFacts {
|
|
609
|
-
readonly targetCount: number;
|
|
610
|
-
readonly assetCount: number;
|
|
611
|
-
readonly scopeConfigured: boolean;
|
|
612
|
-
readonly stageTasks: Readonly<Record<string, StageTaskFacts>>;
|
|
613
|
-
}
|
|
614
|
-
interface ExitCriteriaCheckResult {
|
|
615
|
-
readonly id: string;
|
|
616
|
-
readonly description: string;
|
|
617
|
-
readonly satisfied: boolean;
|
|
618
|
-
}
|
|
619
|
-
interface ExitCriteriaEvaluation {
|
|
620
|
-
readonly stageId: StageId;
|
|
621
|
-
readonly satisfied: boolean;
|
|
622
|
-
readonly checks: readonly ExitCriteriaCheckResult[];
|
|
623
|
-
}
|
|
624
|
-
interface WorkflowTransitionAccepted {
|
|
625
|
-
readonly status: 'accepted';
|
|
626
|
-
readonly fromStageId: StageId;
|
|
627
|
-
readonly toStageId?: StageId;
|
|
628
|
-
readonly previousStageStatus: 'active';
|
|
629
|
-
readonly finalStageStatus: 'completed' | 'skipped';
|
|
630
|
-
readonly criteria?: ExitCriteriaEvaluation;
|
|
631
|
-
}
|
|
632
|
-
interface WorkflowTransitionAlreadyApplied {
|
|
633
|
-
readonly status: 'already_applied';
|
|
634
|
-
readonly fromStageId: StageId;
|
|
635
|
-
readonly toStageId?: StageId;
|
|
636
|
-
}
|
|
637
|
-
interface WorkflowTransitionRejected {
|
|
638
|
-
readonly status: 'rejected';
|
|
639
|
-
readonly reason: WorkflowTransitionRejectionReason;
|
|
640
|
-
readonly message?: string;
|
|
641
|
-
readonly criteria?: ExitCriteriaEvaluation;
|
|
642
|
-
}
|
|
643
|
-
type WorkflowTransitionResult = WorkflowTransitionAccepted | WorkflowTransitionAlreadyApplied | WorkflowTransitionRejected;
|
|
644
|
-
//#endregion
|
|
645
|
-
//#region src/orchestrator/runtime.d.ts
|
|
646
|
-
interface OrchestratorReasoningInput {
|
|
647
|
-
readonly engagementId: EngagementId;
|
|
648
|
-
readonly currentStageId?: StageId;
|
|
649
|
-
readonly triggers: readonly OrchestratorWakeEvent[];
|
|
650
|
-
readonly lastWorkflowTransitionResult?: WorkflowTransitionResult;
|
|
651
|
-
}
|
|
652
|
-
interface OrchestratorAgentRuntime {
|
|
653
|
-
reason(input: OrchestratorReasoningInput): Promise<OrchestratorReasoningOutput>;
|
|
654
|
-
}
|
|
655
|
-
interface SpawnAgentRunInput {
|
|
656
|
-
readonly engagementId: EngagementId;
|
|
657
|
-
readonly taskId: TaskId;
|
|
658
|
-
readonly agentRunId: AgentRunId;
|
|
659
|
-
readonly agentTemplateId: AgentTemplateId;
|
|
660
|
-
}
|
|
661
|
-
interface ContinueAgentRunInput {
|
|
662
|
-
readonly engagementId: EngagementId;
|
|
663
|
-
readonly taskId: TaskId;
|
|
664
|
-
readonly agentRunId: AgentRunId;
|
|
665
|
-
}
|
|
666
|
-
interface SteerAgentRunInput {
|
|
667
|
-
readonly agentRunId: AgentRunId;
|
|
668
|
-
readonly message: string;
|
|
669
|
-
}
|
|
670
|
-
interface AgentRunRuntime {
|
|
671
|
-
spawn(input: SpawnAgentRunInput): Promise<void>;
|
|
672
|
-
continue(input: ContinueAgentRunInput): Promise<void>;
|
|
673
|
-
steer(input: SteerAgentRunInput): Promise<void>;
|
|
674
|
-
/** P0-3/P0-5: cancel the Worker's live AgentRun (native session cancel). */
|
|
675
|
-
cancel(agentRunId: AgentRunId): Promise<void>;
|
|
676
|
-
}
|
|
677
|
-
interface AgentTemplateRegistry {
|
|
678
|
-
get(id: AgentTemplateId): AgentTemplate | undefined;
|
|
679
|
-
listEligibleForStage(stageKind: AgentTemplate['attachedStages'][number]): readonly AgentTemplate[];
|
|
680
|
-
}
|
|
681
|
-
interface ProducedDataSink {
|
|
682
|
-
handleArtifact(message: PtapMessage): void | Promise<void>;
|
|
683
|
-
handleEvidence(message: PtapMessage): void | Promise<void>;
|
|
684
|
-
handleFinding(message: PtapMessage): void | Promise<void>;
|
|
685
|
-
}
|
|
686
|
-
interface PtapOutbound {
|
|
687
|
-
emit(message: PtapMessage): void;
|
|
688
|
-
}
|
|
689
|
-
interface AuditSink {
|
|
690
|
-
record(event: string, detail?: unknown): void;
|
|
691
|
-
}
|
|
692
|
-
declare class InMemoryAgentTemplateRegistry implements AgentTemplateRegistry {
|
|
693
|
-
private readonly templates;
|
|
694
|
-
constructor(templates: readonly AgentTemplate[]);
|
|
695
|
-
get(id: AgentTemplateId): AgentTemplate | undefined;
|
|
696
|
-
entries(): IterableIterator<[AgentTemplateId, AgentTemplate]>;
|
|
697
|
-
listEligibleForStage(stageKind: AgentTemplate['attachedStages'][number]): readonly AgentTemplate[];
|
|
698
|
-
}
|
|
699
|
-
declare class InMemoryPtapOutbound implements PtapOutbound {
|
|
700
|
-
readonly messages: PtapMessage[];
|
|
701
|
-
emit(message: PtapMessage): void;
|
|
702
|
-
}
|
|
703
|
-
declare class InMemoryAuditSink implements AuditSink {
|
|
704
|
-
readonly events: Array<{
|
|
705
|
-
event: string;
|
|
706
|
-
detail?: unknown;
|
|
707
|
-
}>;
|
|
708
|
-
record(event: string, detail?: unknown): void;
|
|
709
|
-
}
|
|
710
|
-
interface RuntimeProgress {
|
|
711
|
-
readonly status: AgentProgressStatus;
|
|
712
|
-
readonly summary: string;
|
|
713
|
-
}
|
|
714
|
-
//#endregion
|
|
715
|
-
//#region src/domain/asset.d.ts
|
|
716
|
-
declare const ASSET_ORIGINS: readonly ["initial-target", "discovered", "derived"];
|
|
717
|
-
type AssetOrigin = (typeof ASSET_ORIGINS)[number];
|
|
718
|
-
interface Asset {
|
|
719
|
-
readonly id: AssetId;
|
|
720
|
-
readonly engagementId: EngagementId;
|
|
721
|
-
readonly value: string;
|
|
722
|
-
readonly origin: AssetOrigin;
|
|
723
|
-
readonly sourceTargetId?: TargetId;
|
|
724
|
-
}
|
|
725
|
-
//#endregion
|
|
726
|
-
//#region src/domain/stage.d.ts
|
|
727
|
-
declare const STAGE_STATUSES: readonly ["pending", "active", "completed", "skipped"];
|
|
728
|
-
type StageStatus = (typeof STAGE_STATUSES)[number];
|
|
729
|
-
declare const STAGE_TRANSITION_REASONS: readonly ["workflow", "manual_override", "skip"];
|
|
730
|
-
type StageTransitionReason = (typeof STAGE_TRANSITION_REASONS)[number];
|
|
731
|
-
interface Stage {
|
|
732
|
-
readonly id: StageId;
|
|
733
|
-
readonly engagementId: EngagementId;
|
|
734
|
-
readonly kind: PtesStageKind;
|
|
735
|
-
readonly status: StageStatus;
|
|
736
|
-
/** P1-6: human-readable reason when the Stage was user-skipped. */
|
|
737
|
-
readonly skippedReason?: string;
|
|
738
|
-
/** P1-6: ISO timestamp when the Stage was skipped. */
|
|
739
|
-
readonly skippedAt?: string;
|
|
740
|
-
}
|
|
741
|
-
//#endregion
|
|
742
|
-
//#region src/domain/task.d.ts
|
|
743
|
-
declare const TASK_STATUSES: readonly ["pending", "running", "blocked", "completed", "failed", "cancelled", "interrupted"];
|
|
744
|
-
type TaskStatus = (typeof TASK_STATUSES)[number];
|
|
745
|
-
interface Task {
|
|
746
|
-
readonly id: TaskId;
|
|
747
|
-
readonly engagementId: EngagementId;
|
|
748
|
-
readonly stageId: StageId;
|
|
749
|
-
readonly kind: PtesStageKind;
|
|
750
|
-
readonly goal: string;
|
|
751
|
-
readonly primaryAgentRunId: AgentRunId;
|
|
752
|
-
readonly dependsOn: readonly TaskId[];
|
|
753
|
-
readonly status: TaskStatus;
|
|
754
|
-
readonly parentTaskId?: TaskId;
|
|
755
|
-
}
|
|
756
|
-
//#endregion
|
|
757
|
-
//#region src/domain/context.d.ts
|
|
758
|
-
declare const CONTEXT_TRUST_LEVELS: readonly ["system", "user", "trusted_internal", "untrusted_external"];
|
|
759
|
-
type ContextTrustLevel = (typeof CONTEXT_TRUST_LEVELS)[number];
|
|
760
|
-
declare const CONTEXT_SOURCE_TYPES: readonly ["engagement", "task", "agent_run", "asset", "artifact", "evidence", "finding", "user"];
|
|
761
|
-
type ContextSourceType = (typeof CONTEXT_SOURCE_TYPES)[number];
|
|
762
|
-
declare const CONTEXT_ITEM_KINDS: readonly ["asset", "artifact", "finding", "evidence", "related_task", "guidance"];
|
|
763
|
-
type ContextItemKind = (typeof CONTEXT_ITEM_KINDS)[number];
|
|
764
|
-
type ContextPriority = 1 | 2 | 3 | 4 | 5 | 6;
|
|
765
|
-
interface ContextSource {
|
|
766
|
-
readonly type: ContextSourceType;
|
|
767
|
-
readonly sourceId?: string;
|
|
768
|
-
readonly producedByTaskId?: TaskId;
|
|
769
|
-
readonly producedByAgentRunId?: AgentRunId;
|
|
770
|
-
readonly createdInStageId?: StageId;
|
|
771
|
-
readonly contentKind?: string;
|
|
772
|
-
}
|
|
773
|
-
interface ContextResourceRef {
|
|
774
|
-
readonly resourceId: string;
|
|
775
|
-
readonly kind: string;
|
|
776
|
-
readonly mediaType?: string;
|
|
777
|
-
readonly sizeBytes?: number;
|
|
778
|
-
}
|
|
779
|
-
interface InlineContextContent {
|
|
780
|
-
readonly text: string;
|
|
781
|
-
readonly mediaType?: string;
|
|
782
|
-
}
|
|
783
|
-
interface ContextItemBase {
|
|
784
|
-
readonly id: string;
|
|
785
|
-
readonly kind: ContextItemKind;
|
|
786
|
-
readonly trust: ContextTrustLevel;
|
|
787
|
-
readonly source: ContextSource;
|
|
788
|
-
readonly summary?: string;
|
|
789
|
-
readonly content?: InlineContextContent;
|
|
790
|
-
readonly ref?: ContextResourceRef;
|
|
791
|
-
readonly priority: ContextPriority;
|
|
792
|
-
}
|
|
793
|
-
type AssetContextItem = ContextItemBase & {
|
|
794
|
-
readonly kind: 'asset';
|
|
795
|
-
};
|
|
796
|
-
type ArtifactContextItem = ContextItemBase & {
|
|
797
|
-
readonly kind: 'artifact';
|
|
798
|
-
};
|
|
799
|
-
type FindingContextItem = ContextItemBase & {
|
|
800
|
-
readonly kind: 'finding';
|
|
801
|
-
};
|
|
802
|
-
type EvidenceContextItem = ContextItemBase & {
|
|
803
|
-
readonly kind: 'evidence';
|
|
804
|
-
};
|
|
805
|
-
type RelatedTaskContextItem = ContextItemBase & {
|
|
806
|
-
readonly kind: 'related_task';
|
|
807
|
-
};
|
|
808
|
-
type UserGuidanceContextItem = ContextItemBase & {
|
|
809
|
-
readonly kind: 'guidance';
|
|
810
|
-
};
|
|
811
|
-
type ContextItem = AssetContextItem | ArtifactContextItem | FindingContextItem | EvidenceContextItem | RelatedTaskContextItem | UserGuidanceContextItem;
|
|
812
|
-
interface ContextConstraint {
|
|
813
|
-
readonly id: string;
|
|
814
|
-
readonly text: string;
|
|
815
|
-
}
|
|
816
|
-
interface EngagementContext {
|
|
817
|
-
readonly id: EngagementId;
|
|
818
|
-
readonly objectives: string;
|
|
819
|
-
}
|
|
820
|
-
interface ScopeContext {
|
|
3
|
+
//#region src/model.d.ts
|
|
4
|
+
interface AgentProfile {
|
|
821
5
|
readonly id: string;
|
|
822
|
-
readonly summary: string;
|
|
823
|
-
}
|
|
824
|
-
interface RoeContext {
|
|
825
|
-
readonly summary: string;
|
|
826
|
-
}
|
|
827
|
-
interface StageContext {
|
|
828
|
-
readonly id: StageId;
|
|
829
|
-
readonly kind: PtesStageKind;
|
|
830
|
-
readonly status: string;
|
|
831
|
-
}
|
|
832
|
-
interface TaskContext {
|
|
833
|
-
readonly id: TaskId;
|
|
834
|
-
readonly goal: string;
|
|
835
|
-
readonly status: string;
|
|
836
|
-
readonly stageId: StageId;
|
|
837
|
-
readonly parentTaskId?: TaskId;
|
|
838
|
-
}
|
|
839
|
-
interface AgentTemplateContext {
|
|
840
|
-
readonly id: AgentTemplateId;
|
|
841
|
-
readonly name: string;
|
|
842
|
-
readonly role: string;
|
|
843
|
-
/**
|
|
844
|
-
* POLICY METADATA ONLY — never rendered as "available tools". The actual
|
|
845
|
-
* model-facing tools come from the Worker Tool Manifest (resolveWorkerTools).
|
|
846
|
-
*/
|
|
847
|
-
readonly capabilities: readonly string[];
|
|
848
|
-
}
|
|
849
|
-
interface TaskLineageContext {
|
|
850
|
-
readonly parentTaskId?: TaskId;
|
|
851
|
-
readonly parentSummary?: string;
|
|
852
|
-
}
|
|
853
|
-
interface ContextBundleMetadata {
|
|
854
|
-
readonly builtAt: string;
|
|
855
|
-
readonly itemCount: number;
|
|
856
|
-
}
|
|
857
|
-
interface ContextDeltaMetadata {
|
|
858
|
-
readonly builtAt: string;
|
|
859
|
-
readonly addedCount: number;
|
|
860
|
-
}
|
|
861
|
-
interface TaskContextBundle {
|
|
862
|
-
readonly engagement: EngagementContext;
|
|
863
|
-
readonly scope: ScopeContext;
|
|
864
|
-
readonly roe: RoeContext;
|
|
865
|
-
readonly stage: StageContext;
|
|
866
|
-
readonly task: TaskContext;
|
|
867
|
-
readonly agentTemplate: AgentTemplateContext;
|
|
868
|
-
readonly lineage: TaskLineageContext;
|
|
869
|
-
readonly assets: readonly AssetContextItem[];
|
|
870
|
-
readonly artifacts: readonly ArtifactContextItem[];
|
|
871
|
-
readonly findings: readonly FindingContextItem[];
|
|
872
|
-
readonly evidence: readonly EvidenceContextItem[];
|
|
873
|
-
readonly relatedTasks: readonly RelatedTaskContextItem[];
|
|
874
|
-
readonly userGuidance: readonly UserGuidanceContextItem[];
|
|
875
|
-
readonly constraints: readonly ContextConstraint[];
|
|
876
|
-
readonly metadata: ContextBundleMetadata;
|
|
877
|
-
}
|
|
878
|
-
interface TaskContextDelta {
|
|
879
|
-
readonly task: TaskContext;
|
|
880
|
-
readonly addedItems: readonly ContextItem[];
|
|
881
|
-
readonly addedRefs: readonly ContextResourceRef[];
|
|
882
|
-
readonly userGuidance: readonly UserGuidanceContextItem[];
|
|
883
|
-
readonly changedConstraints: readonly ContextConstraint[];
|
|
884
|
-
readonly metadata: ContextDeltaMetadata;
|
|
885
|
-
}
|
|
886
|
-
interface ContextBudget {
|
|
887
|
-
readonly maxAssets: number;
|
|
888
|
-
readonly maxArtifacts: number;
|
|
889
|
-
readonly maxFindings: number;
|
|
890
|
-
readonly maxEvidenceRefs: number;
|
|
891
|
-
readonly maxRelatedTasks: number;
|
|
892
|
-
readonly maxUserGuidance: number;
|
|
893
|
-
readonly maxContextItems: number;
|
|
894
|
-
readonly maxEstimatedChars: number;
|
|
895
|
-
readonly maxInlineChars: number;
|
|
896
|
-
readonly maxMandatoryChars: number;
|
|
897
|
-
}
|
|
898
|
-
interface ExplicitContextRef {
|
|
899
|
-
readonly id: string;
|
|
900
|
-
readonly required?: boolean;
|
|
901
|
-
}
|
|
902
|
-
interface ContextDeliveryState {
|
|
903
|
-
readonly agentRunId: AgentRunId;
|
|
904
|
-
readonly deliveredItemIds: readonly string[];
|
|
905
|
-
readonly deliveredRefIds: readonly string[];
|
|
906
|
-
readonly revision: number;
|
|
907
|
-
readonly constraintFingerprint?: string;
|
|
908
|
-
}
|
|
909
|
-
declare const CONTEXT_BUILD_ERROR_CODES: readonly ["context_state_invalid", "task_not_found", "agent_run_not_found", "template_not_found", "scope_missing", "unresolved_required_ref", "mandatory_context_too_large", "delivery_state_invalid", "provider_failure"];
|
|
910
|
-
type ContextBuildErrorCode = (typeof CONTEXT_BUILD_ERROR_CODES)[number];
|
|
911
|
-
//#endregion
|
|
912
|
-
//#region src/domain/target.d.ts
|
|
913
|
-
interface Target {
|
|
914
|
-
readonly id: TargetId;
|
|
915
|
-
readonly engagementId: EngagementId;
|
|
916
|
-
readonly value: string;
|
|
917
|
-
readonly initialAssetId: AssetId;
|
|
918
|
-
}
|
|
919
|
-
//#endregion
|
|
920
|
-
//#region src/domain/state.d.ts
|
|
921
|
-
declare const ENGAGEMENT_SNAPSHOT_SCHEMA_VERSION: 1;
|
|
922
|
-
interface EngagementRuntimeState {
|
|
923
|
-
readonly id: EngagementId;
|
|
924
|
-
readonly objectives: string;
|
|
925
|
-
readonly scopeId: ScopeId;
|
|
926
|
-
readonly scopeSummary: string;
|
|
927
|
-
/** P0-1: true when no un-archived Root Session remains attached. Archived
|
|
928
|
-
* Engagements are excluded from bootstrap candidates but keep all history. */
|
|
929
|
-
readonly archived?: boolean;
|
|
930
|
-
/** ISO timestamp of archive (when archived). */
|
|
931
|
-
readonly archivedAt?: string;
|
|
932
|
-
}
|
|
933
|
-
interface WorkflowState {
|
|
934
|
-
readonly currentStageId?: StageId;
|
|
935
|
-
}
|
|
936
|
-
interface EngagementStateSnapshot {
|
|
937
|
-
readonly schemaVersion: typeof ENGAGEMENT_SNAPSHOT_SCHEMA_VERSION;
|
|
938
|
-
readonly lastEventSequence: number;
|
|
939
|
-
readonly engagement: EngagementRuntimeState;
|
|
940
|
-
readonly workflow: WorkflowState;
|
|
941
|
-
readonly stages: Readonly<Record<string, Stage>>;
|
|
942
|
-
readonly targets: Readonly<Record<string, Target>>;
|
|
943
|
-
readonly assets: Readonly<Record<string, Asset>>;
|
|
944
|
-
readonly tasks: Readonly<Record<string, Task>>;
|
|
945
|
-
readonly agentRuns: Readonly<Record<string, AgentRun>>;
|
|
946
|
-
}
|
|
947
|
-
//#endregion
|
|
948
|
-
//#region src/domain/ptes-core.d.ts
|
|
949
|
-
declare const PTES_CORE_INDEX_SCHEMA_VERSION: 1;
|
|
950
|
-
type ArtifactRecord = Artifact;
|
|
951
|
-
type FindingRecord = Finding;
|
|
952
|
-
type FindingOccurrenceRecord = FindingOccurrence;
|
|
953
|
-
interface EvidenceRecord extends Evidence {
|
|
954
|
-
readonly resourceRef: ContextResourceRef;
|
|
955
|
-
}
|
|
956
|
-
type ArtifactUpsertStatus = 'created' | 'merged';
|
|
957
|
-
type FindingUpsertStatus = 'created' | 'merged';
|
|
958
|
-
type OccurrenceUpsertStatus = 'created' | 'merged';
|
|
959
|
-
interface ArtifactUpsertResult {
|
|
960
|
-
readonly status: ArtifactUpsertStatus;
|
|
961
|
-
readonly artifact: ArtifactRecord;
|
|
962
|
-
}
|
|
963
|
-
interface FindingUpsertResult {
|
|
964
|
-
readonly status: FindingUpsertStatus;
|
|
965
|
-
readonly finding: FindingRecord;
|
|
966
|
-
}
|
|
967
|
-
interface FindingOccurrenceUpsertResult {
|
|
968
|
-
readonly status: OccurrenceUpsertStatus;
|
|
969
|
-
readonly occurrence: FindingOccurrenceRecord;
|
|
970
|
-
readonly finding: FindingRecord;
|
|
971
|
-
}
|
|
972
|
-
type IngestionResult = {
|
|
973
|
-
readonly type: 'artifact';
|
|
974
|
-
readonly artifactId: ArtifactId;
|
|
975
|
-
readonly status: ArtifactUpsertStatus;
|
|
976
|
-
} | {
|
|
977
|
-
readonly type: 'evidence';
|
|
978
|
-
readonly evidenceId: EvidenceId;
|
|
979
|
-
} | {
|
|
980
|
-
readonly type: 'finding';
|
|
981
|
-
readonly findingId: FindingId;
|
|
982
|
-
readonly occurrenceId?: FindingOccurrenceId;
|
|
983
|
-
readonly findingStatus: FindingUpsertStatus;
|
|
984
|
-
readonly occurrenceStatus?: OccurrenceUpsertStatus;
|
|
985
|
-
};
|
|
986
|
-
interface ArtifactQuery {
|
|
987
|
-
readonly kind?: Artifact['kind'];
|
|
988
|
-
readonly identityKey?: string;
|
|
989
|
-
}
|
|
990
|
-
interface EvidenceQuery {
|
|
991
|
-
readonly kind?: Evidence['kind'];
|
|
992
|
-
}
|
|
993
|
-
interface FindingQuery {
|
|
994
|
-
readonly status?: FindingStatus;
|
|
995
|
-
readonly identityKey?: string;
|
|
996
|
-
}
|
|
997
|
-
interface EvidenceStorageLimits {
|
|
998
|
-
readonly maxEvidenceBytes: number;
|
|
999
|
-
}
|
|
1000
|
-
interface PtesCoreState {
|
|
1001
|
-
readonly schemaVersion: typeof PTES_CORE_INDEX_SCHEMA_VERSION;
|
|
1002
|
-
readonly lastEventSequence: number;
|
|
1003
|
-
readonly engagementId: EngagementId;
|
|
1004
|
-
readonly artifacts: Readonly<Record<string, ArtifactRecord>>;
|
|
1005
|
-
readonly artifactIdsByIdentityKey: Readonly<Record<string, ArtifactId>>;
|
|
1006
|
-
readonly evidence: Readonly<Record<string, EvidenceRecord>>;
|
|
1007
|
-
readonly findings: Readonly<Record<string, FindingRecord>>;
|
|
1008
|
-
readonly occurrences: Readonly<Record<string, FindingOccurrenceRecord>>;
|
|
1009
|
-
readonly findingIdsByIdentityKey: Readonly<Record<string, FindingId>>;
|
|
1010
|
-
readonly occurrenceIdsByIdentityKey: Readonly<Record<string, FindingOccurrenceId>>;
|
|
1011
|
-
readonly ingestion: Readonly<Record<string, IngestionResult>>;
|
|
1012
|
-
}
|
|
1013
|
-
//#endregion
|
|
1014
|
-
//#region src/domain/tools.d.ts
|
|
1015
|
-
declare const TOOL_CALL_STATUSES: readonly ["requested", "pending_approval", "queued", "running", "succeeded", "failed", "timed_out", "cancelled", "interrupted", "denied", "capability_required"];
|
|
1016
|
-
type ToolCallStatus = (typeof TOOL_CALL_STATUSES)[number];
|
|
1017
|
-
declare const TOOL_RISK_DECISIONS: readonly ["AUTO", "APPROVAL", "DENY"];
|
|
1018
|
-
type ToolRiskDecision = (typeof TOOL_RISK_DECISIONS)[number];
|
|
1019
|
-
declare const TOOL_FAILURE_KINDS: readonly ["timeout", "transport", "execution", "backend_unavailable", "toolbox_image_unavailable", "cancelled", "invalid_result", "unknown"];
|
|
1020
|
-
type ToolFailureKind = (typeof TOOL_FAILURE_KINDS)[number];
|
|
1021
|
-
declare const TOOLBOX_LIFECYCLES: readonly ["agent_run", "engagement"];
|
|
1022
|
-
type ToolboxLifecycle = (typeof TOOLBOX_LIFECYCLES)[number];
|
|
1023
|
-
declare const MCP_LIFECYCLES: readonly ["agent_run", "engagement"];
|
|
1024
|
-
type McpLifecycle = (typeof MCP_LIFECYCLES)[number];
|
|
1025
|
-
declare const IMAGE_RESOLVE_SOURCES: readonly ["existing", "built", "pulled"];
|
|
1026
|
-
type ImageResolveSource = (typeof IMAGE_RESOLVE_SOURCES)[number];
|
|
1027
|
-
declare const TOOL_RETRY_HINTS: readonly ["transient", "permanent", "unknown"];
|
|
1028
|
-
type ToolRetryHint = (typeof TOOL_RETRY_HINTS)[number];
|
|
1029
|
-
declare const TOOL_TERMINATIONS: readonly ["confirmed", "requested", "unknown"];
|
|
1030
|
-
type ToolTermination = (typeof TOOL_TERMINATIONS)[number];
|
|
1031
|
-
type ToolBackendBinding = {
|
|
1032
|
-
readonly kind: 'docker';
|
|
1033
|
-
readonly executor: string;
|
|
1034
|
-
} | {
|
|
1035
|
-
readonly kind: 'mcp';
|
|
1036
|
-
readonly serverId: McpServerId;
|
|
1037
|
-
readonly remoteToolName: string;
|
|
1038
|
-
};
|
|
1039
|
-
interface ToolTimeoutSpec {
|
|
1040
|
-
readonly defaultMs: number;
|
|
1041
|
-
readonly maxMs: number;
|
|
1042
|
-
}
|
|
1043
|
-
interface ToolScopeTarget {
|
|
1044
|
-
readonly value: string;
|
|
1045
|
-
}
|
|
1046
|
-
interface ToolCallRequest {
|
|
1047
|
-
readonly engagementId: EngagementId;
|
|
1048
|
-
readonly taskId: TaskId;
|
|
1049
|
-
readonly agentRunId: AgentRunId;
|
|
1050
|
-
readonly toolId: ToolId;
|
|
1051
|
-
readonly arguments: unknown;
|
|
1052
|
-
readonly timeoutMs?: number;
|
|
1053
|
-
readonly retryOf?: ToolCallId;
|
|
1054
|
-
}
|
|
1055
|
-
interface ToolDefinition {
|
|
1056
|
-
readonly id: ToolId;
|
|
1057
|
-
readonly name: string;
|
|
1058
|
-
readonly description: string;
|
|
1059
|
-
readonly toolboxId: ToolboxId;
|
|
1060
|
-
readonly backend: ToolBackendBinding;
|
|
1061
|
-
readonly risk: ToolRiskDecision;
|
|
1062
|
-
readonly timeout: ToolTimeoutSpec;
|
|
1063
|
-
readonly requiredArgumentKeys?: readonly string[];
|
|
1064
|
-
readonly scopeTargets?: (args: Record<string, unknown>) => readonly ToolScopeTarget[];
|
|
1065
|
-
}
|
|
1066
|
-
interface ToolboxProvisioning {
|
|
1067
|
-
readonly dockerfile?: {
|
|
1068
|
-
readonly context: string;
|
|
1069
|
-
readonly dockerfile: string;
|
|
1070
|
-
};
|
|
1071
|
-
readonly pull?: {
|
|
1072
|
-
readonly image: string;
|
|
1073
|
-
};
|
|
1074
|
-
}
|
|
1075
|
-
interface ToolboxDefinition {
|
|
1076
|
-
readonly id: ToolboxId;
|
|
1077
6
|
readonly name: string;
|
|
1078
7
|
readonly description: string;
|
|
1079
|
-
readonly
|
|
1080
|
-
readonly
|
|
1081
|
-
readonly
|
|
1082
|
-
readonly provisioning?: ToolboxProvisioning;
|
|
1083
|
-
readonly env?: Readonly<Record<string, string>>;
|
|
1084
|
-
readonly secrets?: Readonly<Record<string, string>>;
|
|
1085
|
-
}
|
|
1086
|
-
interface ToolOutputLimits {
|
|
1087
|
-
readonly maxInlineOutputBytes: number;
|
|
1088
|
-
readonly maxTotalCapturedBytes: number;
|
|
1089
|
-
}
|
|
1090
|
-
interface DockerToolboxBinding {
|
|
1091
|
-
readonly engagementId: EngagementId;
|
|
1092
|
-
readonly agentRunId?: AgentRunId;
|
|
1093
|
-
readonly toolboxId: ToolboxId;
|
|
1094
|
-
readonly lifecycle: ToolboxLifecycle;
|
|
1095
|
-
readonly containerId: string;
|
|
1096
|
-
readonly image: string;
|
|
1097
|
-
readonly imageId?: string;
|
|
1098
|
-
readonly imageSource?: ImageResolveSource;
|
|
1099
|
-
}
|
|
1100
|
-
interface McpTransportDefinition {
|
|
1101
|
-
readonly kind: 'fixture' | 'stdio' | 'http';
|
|
1102
|
-
readonly command?: string;
|
|
1103
|
-
readonly args?: readonly string[];
|
|
1104
|
-
readonly url?: string;
|
|
1105
|
-
}
|
|
1106
|
-
interface McpServerConfig {
|
|
1107
|
-
readonly env?: Readonly<Record<string, string>>;
|
|
1108
|
-
readonly secrets?: Readonly<Record<string, string>>;
|
|
1109
|
-
}
|
|
1110
|
-
interface McpServerDefinition {
|
|
1111
|
-
readonly id: McpServerId;
|
|
1112
|
-
readonly name: string;
|
|
1113
|
-
readonly lifecycle: McpLifecycle;
|
|
1114
|
-
readonly transport: McpTransportDefinition;
|
|
1115
|
-
readonly config: McpServerConfig;
|
|
1116
|
-
}
|
|
1117
|
-
interface McpRuntimeBinding {
|
|
1118
|
-
readonly engagementId: EngagementId;
|
|
1119
|
-
readonly agentRunId?: AgentRunId;
|
|
1120
|
-
readonly serverId: McpServerId;
|
|
1121
|
-
readonly lifecycle: McpLifecycle;
|
|
1122
|
-
readonly runtimeId?: string;
|
|
1123
|
-
}
|
|
1124
|
-
interface ToolOutputResourceRef extends ContextResourceRef {}
|
|
1125
|
-
interface ToolCallRecord {
|
|
1126
|
-
readonly toolCallId: ToolCallId;
|
|
1127
|
-
readonly request: ToolCallRequest;
|
|
1128
|
-
readonly status: ToolCallStatus;
|
|
1129
|
-
readonly createdAt: string;
|
|
1130
|
-
readonly updatedAt: string;
|
|
1131
|
-
readonly retryOf?: ToolCallId;
|
|
1132
|
-
readonly reason?: string;
|
|
1133
|
-
readonly outputRefs?: readonly ToolOutputResourceRef[];
|
|
1134
|
-
readonly retryHint?: ToolRetryHint;
|
|
1135
|
-
readonly failureKind?: ToolFailureKind;
|
|
1136
|
-
readonly termination?: ToolTermination;
|
|
1137
|
-
readonly policySnapshot?: {
|
|
1138
|
-
readonly risk?: ToolRiskDecision;
|
|
1139
|
-
readonly scope?: 'allowed' | 'denied';
|
|
1140
|
-
};
|
|
1141
|
-
}
|
|
1142
|
-
interface PendingToolCall {
|
|
1143
|
-
readonly toolCallId: ToolCallId;
|
|
1144
|
-
readonly request: ToolCallRequest;
|
|
1145
|
-
readonly status: 'pending_approval';
|
|
1146
|
-
readonly requestedAt: string;
|
|
1147
|
-
readonly policySnapshot: {
|
|
1148
|
-
readonly risk: 'APPROVAL';
|
|
1149
|
-
readonly scope: 'allowed';
|
|
1150
|
-
readonly toolboxId: ToolboxId;
|
|
1151
|
-
};
|
|
1152
|
-
}
|
|
1153
|
-
interface ToolBrokerConcurrencyLimits {
|
|
1154
|
-
readonly maxPerEngagement: number;
|
|
1155
|
-
readonly maxPerAgentRun: number;
|
|
1156
|
-
}
|
|
1157
|
-
//#endregion
|
|
1158
|
-
//#region src/harness/session-binding.d.ts
|
|
1159
|
-
interface HarnessSessionBinding {
|
|
1160
|
-
readonly engagementId: EngagementId;
|
|
1161
|
-
readonly agentRunId: AgentRunId;
|
|
1162
|
-
readonly sessionId: string;
|
|
1163
|
-
readonly templateId: string;
|
|
1164
|
-
readonly templateRole: string;
|
|
1165
|
-
readonly model?: string;
|
|
1166
|
-
readonly skillIds: readonly string[];
|
|
1167
|
-
readonly mcpIds: readonly string[];
|
|
1168
|
-
/** Root Orchestrator Session that spawned this worker (trusted parentage). */
|
|
1169
|
-
readonly parentRootSessionId?: string;
|
|
1170
|
-
}
|
|
1171
|
-
interface HarnessSessionBindingStore {
|
|
1172
|
-
get(agentRunId: AgentRunId): Promise<HarnessSessionBinding | undefined>;
|
|
1173
|
-
bind(binding: HarnessSessionBinding): Promise<void>;
|
|
1174
|
-
remove(agentRunId: AgentRunId): Promise<void>;
|
|
1175
|
-
}
|
|
1176
|
-
//#endregion
|
|
1177
|
-
//#region src/reporting/types.d.ts
|
|
1178
|
-
declare const REPORT_STATUSES: readonly ["not_started", "drafting", "ready", "failed"];
|
|
1179
|
-
type ReportStatus = (typeof REPORT_STATUSES)[number];
|
|
1180
|
-
interface ReportState {
|
|
1181
|
-
readonly status: ReportStatus;
|
|
1182
|
-
readonly version: number;
|
|
1183
|
-
readonly generatedAt?: string;
|
|
1184
|
-
readonly reportingAgentRunId?: AgentRunId;
|
|
1185
|
-
readonly error?: string;
|
|
1186
|
-
}
|
|
1187
|
-
interface ReportBuildResult {
|
|
1188
|
-
readonly markdown: string;
|
|
1189
|
-
readonly markdownPath: string;
|
|
1190
|
-
readonly html?: string;
|
|
1191
|
-
readonly htmlPath?: string;
|
|
1192
|
-
readonly state: ReportState;
|
|
1193
|
-
readonly markdownRef: ContextResourceRef;
|
|
1194
|
-
readonly htmlRef?: ContextResourceRef;
|
|
1195
|
-
}
|
|
1196
|
-
//#endregion
|
|
1197
|
-
//#region src/projection/types.d.ts
|
|
1198
|
-
declare const PENTECSTER_PROJECTION_KEYS: readonly ["pentester", "pentester.assets", "pentester.findings", "pentester.evidence", "pentester.activity", "pentester.report"];
|
|
1199
|
-
type PentesterProjectionKey = (typeof PENTECSTER_PROJECTION_KEYS)[number];
|
|
1200
|
-
interface TargetSummary {
|
|
1201
|
-
readonly id: string;
|
|
1202
|
-
readonly value: string;
|
|
1203
|
-
}
|
|
1204
|
-
interface StageSummary {
|
|
1205
|
-
readonly id: StageId;
|
|
1206
|
-
readonly kind: PtesStageKind;
|
|
1207
|
-
readonly name: string;
|
|
1208
|
-
readonly status: StageStatus;
|
|
1209
|
-
readonly completedTasks: number;
|
|
1210
|
-
readonly runningTasks: number;
|
|
1211
|
-
readonly totalTasks: number;
|
|
1212
|
-
readonly findingCount: number;
|
|
1213
|
-
readonly exitCriteriaSatisfied: boolean;
|
|
1214
|
-
/** P1-5: the specific satisfied exit criteria (descriptions), never just
|
|
1215
|
-
* "退出条件已满足". */
|
|
1216
|
-
readonly satisfiedCriteria: readonly string[];
|
|
1217
|
-
/** P1-6: skip reason when the Stage was user-skipped (archived audit). */
|
|
1218
|
-
readonly skippedReason?: string;
|
|
1219
|
-
}
|
|
1220
|
-
interface AttentionItem {
|
|
1221
|
-
readonly kind: 'pending_approval' | 'failed_task' | 'blocked_task' | 'capability_required';
|
|
1222
|
-
readonly id: string;
|
|
1223
|
-
readonly title: string;
|
|
1224
|
-
readonly toolId?: string;
|
|
1225
|
-
readonly target?: string;
|
|
1226
|
-
readonly risk?: string;
|
|
1227
|
-
readonly agentRunId?: string;
|
|
1228
|
-
readonly taskId?: string;
|
|
1229
|
-
readonly reason?: string;
|
|
1230
|
-
}
|
|
1231
|
-
interface RunningItem {
|
|
1232
|
-
readonly agentRunId: AgentRunId;
|
|
1233
|
-
readonly taskId: TaskId;
|
|
1234
|
-
readonly taskGoal: string;
|
|
1235
|
-
/** 'starting' = launched but no Worker activity yet; else the run status. */
|
|
1236
|
-
readonly status: AgentRunStatus | 'starting';
|
|
1237
|
-
readonly stageKind: PtesStageKind;
|
|
1238
|
-
readonly templateName?: string;
|
|
1239
|
-
readonly sessionId?: string;
|
|
1240
|
-
readonly sessionAvailable: boolean;
|
|
1241
|
-
}
|
|
1242
|
-
interface ActivityItem {
|
|
1243
|
-
readonly id: string;
|
|
1244
|
-
readonly kind: 'finding' | 'asset' | 'task' | 'stage' | 'tool' | 'approval' | 'evidence' | 'engagement' | 'agent';
|
|
1245
|
-
readonly title: string;
|
|
1246
|
-
readonly createdAt?: string;
|
|
1247
|
-
}
|
|
1248
|
-
interface EnvironmentProjection {
|
|
1249
|
-
readonly status: 'checking' | 'ready' | 'blocked';
|
|
1250
|
-
readonly checkedAt?: string;
|
|
1251
|
-
readonly generation?: number;
|
|
1252
|
-
/** Short actionable reason when blocked (e.g. "Docker API unreachable"). */
|
|
1253
|
-
readonly reason?: string;
|
|
1254
|
-
readonly code?: string;
|
|
1255
|
-
readonly recoverable?: boolean;
|
|
1256
|
-
}
|
|
1257
|
-
interface PentesterProjection {
|
|
1258
|
-
readonly engagement: {
|
|
1259
|
-
readonly id: EngagementId;
|
|
1260
|
-
readonly status: string;
|
|
1261
|
-
readonly targets: readonly TargetSummary[];
|
|
1262
|
-
readonly scopeSummary: string;
|
|
1263
|
-
};
|
|
1264
|
-
/** Host-enforced Environment Readiness Gate state (UI: Checking/Ready/Blocked). */
|
|
1265
|
-
readonly environment: EnvironmentProjection;
|
|
1266
|
-
readonly workflow: {
|
|
1267
|
-
readonly currentStageId?: StageId;
|
|
1268
|
-
readonly currentStageKind?: PtesStageKind;
|
|
1269
|
-
readonly stages: readonly StageSummary[];
|
|
1270
|
-
};
|
|
1271
|
-
readonly counts: {
|
|
1272
|
-
readonly assets: number;
|
|
1273
|
-
readonly findings: number;
|
|
1274
|
-
readonly evidence: number;
|
|
1275
|
-
readonly runningTasks: number;
|
|
1276
|
-
readonly runningAgents: number;
|
|
1277
|
-
readonly pendingApprovals: number;
|
|
1278
|
-
};
|
|
1279
|
-
readonly findingSeverityCounts: {
|
|
1280
|
-
readonly critical: number;
|
|
1281
|
-
readonly high: number;
|
|
1282
|
-
readonly medium: number;
|
|
1283
|
-
readonly low: number;
|
|
1284
|
-
readonly info: number;
|
|
1285
|
-
};
|
|
1286
|
-
readonly attention: readonly AttentionItem[];
|
|
1287
|
-
readonly running: readonly RunningItem[];
|
|
1288
|
-
readonly recentActivity: readonly ActivityItem[];
|
|
1289
|
-
}
|
|
1290
|
-
interface AssetProjectionItem {
|
|
1291
|
-
readonly id: AssetId;
|
|
1292
|
-
/** P1-2: human-readable display id ("A-001") — never the raw UUID. */
|
|
1293
|
-
readonly displayId: string;
|
|
1294
|
-
readonly value: string;
|
|
1295
|
-
readonly origin: AssetOrigin;
|
|
1296
|
-
readonly parentId?: string;
|
|
1297
|
-
readonly relatedFindingCount: number;
|
|
1298
|
-
readonly serviceCount: number;
|
|
1299
|
-
readonly endpointCount: number;
|
|
1300
|
-
readonly discoveredBy?: string;
|
|
1301
|
-
}
|
|
1302
|
-
interface AssetsProjection {
|
|
1303
|
-
readonly engagementId: EngagementId;
|
|
1304
|
-
readonly assets: readonly AssetProjectionItem[];
|
|
1305
|
-
}
|
|
1306
|
-
interface FindingProjectionItem {
|
|
1307
|
-
readonly id: FindingId;
|
|
1308
|
-
/** P1-2: human-readable display id ("V-001") — never the raw UUID. */
|
|
1309
|
-
readonly displayId: string;
|
|
1310
|
-
readonly title: string;
|
|
1311
|
-
readonly status: FindingStatus;
|
|
1312
|
-
readonly severity: FindingSeverity;
|
|
1313
|
-
readonly occurrenceIds: readonly FindingOccurrenceId[];
|
|
1314
|
-
readonly createdInStageId?: StageId;
|
|
1315
|
-
readonly description?: string;
|
|
1316
|
-
readonly remediation?: string;
|
|
1317
|
-
readonly producedByTaskId?: string;
|
|
1318
|
-
readonly producedByAgentRunId?: string;
|
|
1319
|
-
}
|
|
1320
|
-
interface OccurrenceProjectionItem {
|
|
1321
|
-
readonly id: FindingOccurrenceId;
|
|
1322
|
-
readonly findingId: FindingId;
|
|
1323
|
-
readonly assetId: AssetId;
|
|
1324
|
-
readonly endpoint?: string;
|
|
1325
|
-
readonly evidenceIds: readonly EvidenceId[];
|
|
1326
|
-
readonly status: FindingStatus;
|
|
1327
|
-
}
|
|
1328
|
-
interface FindingsProjection {
|
|
1329
|
-
readonly engagementId: EngagementId;
|
|
1330
|
-
readonly findings: readonly FindingProjectionItem[];
|
|
1331
|
-
readonly occurrences: readonly OccurrenceProjectionItem[];
|
|
1332
|
-
}
|
|
1333
|
-
interface EvidenceProjectionItem {
|
|
1334
|
-
readonly id: EvidenceId;
|
|
1335
|
-
readonly kind: string;
|
|
1336
|
-
readonly mediaType?: string;
|
|
1337
|
-
readonly sizeBytes: number;
|
|
1338
|
-
readonly createdAt: string;
|
|
1339
|
-
readonly taskId?: TaskId;
|
|
1340
|
-
readonly agentRunId?: AgentRunId;
|
|
1341
|
-
readonly findingIds: readonly FindingId[];
|
|
1342
|
-
readonly occurrenceIds: readonly FindingOccurrenceId[];
|
|
1343
|
-
readonly resourceRef: ContextResourceRef;
|
|
1344
|
-
readonly previewable: boolean;
|
|
1345
|
-
/** P1-2: human-readable display id ("E-001") — never the raw UUID. */
|
|
1346
|
-
readonly displayId: string;
|
|
1347
|
-
}
|
|
1348
|
-
interface EvidenceProjection {
|
|
1349
|
-
readonly engagementId: EngagementId;
|
|
1350
|
-
readonly items: readonly EvidenceProjectionItem[];
|
|
1351
|
-
}
|
|
1352
|
-
interface ActivityProjection {
|
|
1353
|
-
readonly engagementId: EngagementId;
|
|
1354
|
-
readonly tasks: readonly {
|
|
1355
|
-
readonly id: TaskId;
|
|
1356
|
-
readonly goal: string;
|
|
1357
|
-
readonly status: TaskStatus;
|
|
1358
|
-
readonly stageKind: PtesStageKind;
|
|
1359
|
-
}[];
|
|
1360
|
-
readonly agentRuns: readonly {
|
|
1361
|
-
readonly id: AgentRunId;
|
|
1362
|
-
readonly status: AgentRunStatus;
|
|
1363
|
-
readonly sessionId?: string;
|
|
1364
|
-
}[];
|
|
1365
|
-
readonly approvals: readonly {
|
|
1366
|
-
readonly id: ToolCallId;
|
|
1367
|
-
readonly toolId: string;
|
|
1368
|
-
readonly status: 'pending_approval';
|
|
1369
|
-
readonly target?: string;
|
|
1370
|
-
readonly risk: string;
|
|
1371
|
-
readonly agentRunId: string;
|
|
1372
|
-
readonly taskId: string;
|
|
1373
|
-
readonly reason?: string;
|
|
1374
|
-
}[];
|
|
1375
|
-
readonly toolCalls: readonly {
|
|
1376
|
-
readonly id: ToolCallId;
|
|
1377
|
-
readonly toolId: string;
|
|
1378
|
-
readonly status: string;
|
|
1379
|
-
}[];
|
|
1380
|
-
}
|
|
1381
|
-
interface ReportProjection {
|
|
1382
|
-
readonly engagementId: EngagementId;
|
|
1383
|
-
readonly status: 'not_started' | 'drafting' | 'ready' | 'failed';
|
|
1384
|
-
readonly version?: number;
|
|
1385
|
-
readonly generatedAt?: string;
|
|
1386
|
-
readonly markdownRef?: ContextResourceRef;
|
|
1387
|
-
readonly htmlRef?: ContextResourceRef;
|
|
1388
|
-
readonly pdfRef?: ContextResourceRef;
|
|
1389
|
-
readonly preview?: string;
|
|
1390
|
-
}
|
|
1391
|
-
interface CanonicalReadModel {
|
|
1392
|
-
readonly engagement: EngagementStateSnapshot;
|
|
1393
|
-
readonly ptes: PtesCoreState;
|
|
1394
|
-
readonly toolCalls: readonly ToolCallRecord[];
|
|
1395
|
-
readonly pendingApprovals: readonly PendingToolCall[];
|
|
1396
|
-
readonly bindings: readonly HarnessSessionBinding[];
|
|
1397
|
-
readonly report?: ReportState;
|
|
1398
|
-
/** templateId → display name (for Running / detail UI). */
|
|
1399
|
-
readonly templateNames?: Readonly<Record<string, string>>;
|
|
1400
|
-
/** Host-enforced Environment Readiness Gate state. */
|
|
1401
|
-
readonly environment?: EnvironmentProjection;
|
|
1402
|
-
/** agentRunId → true once the Worker emitted its first runtime activity
|
|
1403
|
-
* (P1-9: UI shows "starting" before this, "running" after). */
|
|
1404
|
-
readonly workerActivity?: Readonly<Record<string, boolean>>;
|
|
1405
|
-
}
|
|
1406
|
-
//#endregion
|
|
1407
|
-
//#region src/runtime/parent-wakeup-outbox.d.ts
|
|
1408
|
-
/**
|
|
1409
|
-
* P0-A ParentWakeupOutbox — durable intent to wake the parent Orchestrator
|
|
1410
|
-
* session after a Task terminal transition.
|
|
1411
|
-
*
|
|
1412
|
-
* INVARIANT: the outbox record and the canonical Task terminal state are
|
|
1413
|
-
* written in the SAME commit window. `ptap_complete_task` returns ok:true
|
|
1414
|
-
* ONLY after both (a) the Task reached a terminal state AND (b) the outbox
|
|
1415
|
-
* record exists. There is no observable "Task completed but no wakeup intent".
|
|
1416
|
-
*
|
|
1417
|
-
* State machine:
|
|
1418
|
-
* pending — created with the terminal transition; not yet dispatched
|
|
1419
|
-
* delivering — dispatcher picked it up, parent continuation in flight
|
|
1420
|
-
* delivered — parent inbox injected AND continuation scheduled
|
|
1421
|
-
* failed_retryable — dispatch failed; startup recovery retries
|
|
1422
|
-
*
|
|
1423
|
-
* Idempotency key: (parentSessionId, terminalEventId). The store dedupes on
|
|
1424
|
-
* insert — a replayed terminal event never creates a second record.
|
|
1425
|
-
*/
|
|
1426
|
-
declare const PARENT_WAKEUP_STATES: readonly ["pending", "delivering", "delivered", "failed_retryable"];
|
|
1427
|
-
type ParentWakeupState = (typeof PARENT_WAKEUP_STATES)[number];
|
|
1428
|
-
interface ParentWakeupRecord {
|
|
1429
|
-
readonly id: string;
|
|
1430
|
-
/** Canonical store eventId of the terminal transition (idempotency half-key). */
|
|
1431
|
-
readonly terminalEventId: EventId;
|
|
1432
|
-
readonly engagementId: EngagementId;
|
|
1433
|
-
readonly taskId: TaskId;
|
|
1434
|
-
readonly agentRunId: AgentRunId;
|
|
1435
|
-
/** Worker DSH session that produced the terminal event. */
|
|
1436
|
-
readonly childSessionId: string;
|
|
1437
|
-
/** Root Orchestrator DSH session to wake. */
|
|
1438
|
-
readonly parentSessionId: string;
|
|
1439
|
-
readonly terminalStatus: 'completed' | 'blocked' | 'failed' | 'cancelled';
|
|
1440
|
-
readonly summary: string;
|
|
1441
|
-
readonly artifactRefs: readonly string[];
|
|
1442
|
-
readonly evidenceRefs: readonly string[];
|
|
1443
|
-
readonly findingRefs: readonly string[];
|
|
1444
|
-
readonly reasonCode?: string;
|
|
1445
|
-
readonly recoverable?: boolean;
|
|
1446
|
-
readonly state: ParentWakeupState;
|
|
1447
|
-
readonly createdAt: string;
|
|
1448
|
-
readonly updatedAt: string;
|
|
1449
|
-
readonly attempts: number;
|
|
1450
|
-
}
|
|
1451
|
-
interface CreateParentWakeupInput {
|
|
1452
|
-
readonly terminalEventId: EventId;
|
|
1453
|
-
readonly engagementId: EngagementId;
|
|
1454
|
-
readonly taskId: TaskId;
|
|
1455
|
-
readonly agentRunId: AgentRunId;
|
|
1456
|
-
readonly childSessionId: string;
|
|
1457
|
-
readonly parentSessionId: string;
|
|
1458
|
-
readonly terminalStatus: 'completed' | 'blocked' | 'failed' | 'cancelled';
|
|
1459
|
-
readonly summary: string;
|
|
1460
|
-
readonly artifactRefs?: readonly string[];
|
|
1461
|
-
readonly evidenceRefs?: readonly string[];
|
|
1462
|
-
readonly findingRefs?: readonly string[];
|
|
1463
|
-
readonly reasonCode?: string;
|
|
1464
|
-
readonly recoverable?: boolean;
|
|
1465
|
-
}
|
|
1466
|
-
declare class ParentWakeupOutbox {
|
|
1467
|
-
private readonly path;
|
|
1468
|
-
private records;
|
|
1469
|
-
private readonly byKey;
|
|
1470
|
-
private constructor();
|
|
1471
|
-
static open(engagementDir: string): Promise<ParentWakeupOutbox>;
|
|
1472
|
-
list(): readonly ParentWakeupRecord[];
|
|
1473
|
-
/** Records still needing delivery (pending / failed_retryable). */
|
|
1474
|
-
listPending(): readonly ParentWakeupRecord[];
|
|
1475
|
-
get(id: string): ParentWakeupRecord | undefined;
|
|
1476
|
-
/**
|
|
1477
|
-
* Idempotent insert. Returns the existing record when the same
|
|
1478
|
-
* (parentSessionId, terminalEventId) already exists — a duplicate terminal
|
|
1479
|
-
* event never creates a second record.
|
|
1480
|
-
*/
|
|
1481
|
-
insert(input: CreateParentWakeupInput): Promise<ParentWakeupRecord>;
|
|
1482
|
-
/** Mark a record delivering (dispatcher picked it up). */
|
|
1483
|
-
markDelivering(id: string): Promise<void>;
|
|
1484
|
-
/** Mark delivered (parent inbox injected + continuation scheduled). */
|
|
1485
|
-
markDelivered(id: string): Promise<void>;
|
|
1486
|
-
/** Mark failed but retryable (dispatcher error, plugin restart retries). */
|
|
1487
|
-
markFailedRetryable(id: string): Promise<void>;
|
|
1488
|
-
private update;
|
|
1489
|
-
private persist;
|
|
1490
|
-
}
|
|
1491
|
-
//#endregion
|
|
1492
|
-
//#region src/tools/audit.d.ts
|
|
1493
|
-
interface ToolAuditSink {
|
|
1494
|
-
record(event: string, detail?: unknown): void;
|
|
1495
|
-
}
|
|
1496
|
-
//#endregion
|
|
1497
|
-
//#region src/tools/backend.d.ts
|
|
1498
|
-
interface ToolBackendExecutionContext {
|
|
1499
|
-
readonly toolCallId: ToolCallId;
|
|
1500
|
-
readonly toolId: ToolId;
|
|
1501
|
-
readonly request: ToolCallRequest;
|
|
1502
|
-
}
|
|
1503
|
-
interface ToolBackendSuccess {
|
|
1504
|
-
readonly status: 'succeeded';
|
|
1505
|
-
readonly summary?: string;
|
|
1506
|
-
readonly data?: unknown;
|
|
1507
|
-
readonly outputs?: Readonly<Record<string, string>>;
|
|
1508
|
-
readonly binaryOutputs?: Readonly<Record<string, Buffer>>;
|
|
1509
|
-
}
|
|
1510
|
-
interface ToolBackendFailure {
|
|
1511
|
-
readonly status: 'failed';
|
|
1512
|
-
readonly kind: 'timeout' | 'transport' | 'execution' | 'backend_unavailable' | 'toolbox_image_unavailable' | 'cancelled' | 'invalid_result' | 'unknown';
|
|
1513
|
-
readonly message: string;
|
|
1514
|
-
readonly retryHint: ToolRetryHint;
|
|
1515
|
-
}
|
|
1516
|
-
type ToolBackendResult = ToolBackendSuccess | ToolBackendFailure;
|
|
1517
|
-
interface ToolBackendCancelResult {
|
|
1518
|
-
readonly termination: ToolTermination;
|
|
1519
|
-
}
|
|
1520
|
-
interface ToolBackend {
|
|
1521
|
-
execute(context: ToolBackendExecutionContext): Promise<ToolBackendResult>;
|
|
1522
|
-
cancel(executionId: string): Promise<ToolBackendCancelResult>;
|
|
1523
|
-
}
|
|
1524
|
-
//#endregion
|
|
1525
|
-
//#region src/tools/catalog.d.ts
|
|
1526
|
-
interface ToolCatalog {
|
|
1527
|
-
get(toolId: ToolId): ToolDefinition | undefined;
|
|
1528
|
-
listForToolbox(toolboxId: ToolboxId): readonly ToolDefinition[];
|
|
1529
|
-
list(): readonly ToolDefinition[];
|
|
1530
|
-
}
|
|
1531
|
-
//#endregion
|
|
1532
|
-
//#region src/tools/capability.d.ts
|
|
1533
|
-
interface ToolboxGrantStore {
|
|
1534
|
-
hasGrant(agentRunId: AgentRunId, toolboxId: ToolboxId): boolean;
|
|
1535
|
-
grant(agentRunId: AgentRunId, toolboxId: ToolboxId): Promise<void>;
|
|
1536
|
-
revoke(agentRunId: AgentRunId, toolboxId: ToolboxId): Promise<void>;
|
|
1537
|
-
calls: number;
|
|
1538
|
-
}
|
|
1539
|
-
declare class DurableToolboxGrantStore implements ToolboxGrantStore {
|
|
1540
|
-
calls: number;
|
|
1541
|
-
private readonly path;
|
|
1542
|
-
private grants;
|
|
1543
|
-
private constructor();
|
|
1544
|
-
static open(engagementDir: string): Promise<DurableToolboxGrantStore>;
|
|
1545
|
-
hasGrant(agentRunId: AgentRunId, toolboxId: ToolboxId): boolean;
|
|
1546
|
-
grant(agentRunId: AgentRunId, toolboxId: ToolboxId): Promise<void>;
|
|
1547
|
-
revoke(agentRunId: AgentRunId, toolboxId: ToolboxId): Promise<void>;
|
|
1548
|
-
}
|
|
1549
|
-
//#endregion
|
|
1550
|
-
//#region src/tools/mcp-auth.d.ts
|
|
1551
|
-
interface McpAuthorization {
|
|
1552
|
-
isAuthorized(agentRunId: AgentRunId, serverId: McpServerId): boolean;
|
|
1553
|
-
}
|
|
1554
|
-
//#endregion
|
|
1555
|
-
//#region src/tools/result.d.ts
|
|
1556
|
-
type ToolExecuteResult = {
|
|
1557
|
-
readonly status: 'succeeded';
|
|
1558
|
-
readonly toolCallId: ToolCallId;
|
|
1559
|
-
readonly toolId: ToolId;
|
|
1560
|
-
readonly summary?: string;
|
|
1561
|
-
readonly data?: unknown;
|
|
1562
|
-
readonly outputRefs: readonly ToolOutputResourceRef[];
|
|
1563
|
-
} | {
|
|
1564
|
-
readonly status: 'pending_approval';
|
|
1565
|
-
readonly toolCallId: ToolCallId;
|
|
1566
|
-
} | {
|
|
1567
|
-
readonly status: 'denied';
|
|
1568
|
-
readonly toolCallId: ToolCallId;
|
|
1569
|
-
readonly reason: string;
|
|
1570
|
-
} | {
|
|
1571
|
-
readonly status: 'capability_required';
|
|
1572
|
-
readonly toolCallId: ToolCallId;
|
|
1573
|
-
readonly toolboxId: ToolboxId;
|
|
1574
|
-
} | {
|
|
1575
|
-
readonly status: 'failed';
|
|
1576
|
-
readonly toolCallId: ToolCallId;
|
|
1577
|
-
readonly kind: ToolFailureKind;
|
|
1578
|
-
readonly message: string;
|
|
1579
|
-
readonly retryHint: ToolRetryHint;
|
|
1580
|
-
} | {
|
|
1581
|
-
readonly status: 'timed_out';
|
|
1582
|
-
readonly toolCallId: ToolCallId;
|
|
1583
|
-
readonly termination: ToolTermination;
|
|
1584
|
-
} | {
|
|
1585
|
-
readonly status: 'cancelled';
|
|
1586
|
-
readonly toolCallId: ToolCallId;
|
|
1587
|
-
readonly termination?: ToolTermination;
|
|
1588
|
-
} | {
|
|
1589
|
-
readonly status: 'queued';
|
|
1590
|
-
readonly toolCallId: ToolCallId;
|
|
1591
|
-
} | {
|
|
1592
|
-
readonly status: 'interrupted';
|
|
1593
|
-
readonly toolCallId: ToolCallId;
|
|
1594
|
-
};
|
|
1595
|
-
//#endregion
|
|
1596
|
-
//#region src/tools/risk-policy.d.ts
|
|
1597
|
-
interface ToolRiskContext {
|
|
1598
|
-
readonly request: ToolCallRequest;
|
|
1599
|
-
readonly tool: ToolDefinition;
|
|
1600
|
-
}
|
|
1601
|
-
interface ToolRiskPolicy {
|
|
1602
|
-
evaluate(context: ToolRiskContext): Promise<ToolRiskDecision>;
|
|
1603
|
-
calls: number;
|
|
1604
|
-
}
|
|
1605
|
-
//#endregion
|
|
1606
|
-
//#region src/tools/scope-policy.d.ts
|
|
1607
|
-
interface ToolScopeContext {
|
|
1608
|
-
readonly request: ToolCallRequest;
|
|
1609
|
-
readonly tool: ToolDefinition;
|
|
1610
|
-
readonly targets: readonly ToolScopeTarget[];
|
|
1611
|
-
}
|
|
1612
|
-
interface ToolScopeDecision {
|
|
1613
|
-
readonly decision: 'allowed' | 'denied';
|
|
1614
|
-
readonly reason?: string;
|
|
1615
|
-
}
|
|
1616
|
-
interface ToolScopePolicy {
|
|
1617
|
-
evaluate(context: ToolScopeContext): Promise<ToolScopeDecision>;
|
|
1618
|
-
calls: number;
|
|
1619
|
-
}
|
|
1620
|
-
//#endregion
|
|
1621
|
-
//#region src/tools/broker.d.ts
|
|
1622
|
-
interface EngagementView {
|
|
1623
|
-
getTask(id: TaskId): Task | undefined;
|
|
1624
|
-
getAgentRun(id: AgentRunId): AgentRun | undefined;
|
|
1625
|
-
getTemplate?(id: AgentTemplateId): AgentTemplate | undefined;
|
|
1626
|
-
}
|
|
1627
|
-
interface ToolBrokerOptions {
|
|
1628
|
-
readonly engagementDir: string;
|
|
1629
|
-
readonly engagementId: EngagementId;
|
|
1630
|
-
readonly engagement: EngagementView;
|
|
1631
|
-
readonly grants: ToolboxGrantStore;
|
|
1632
|
-
readonly docker: ToolBackend;
|
|
1633
|
-
readonly mcp: ToolBackend;
|
|
1634
|
-
readonly catalog?: ToolCatalog;
|
|
1635
|
-
readonly scopePolicy: ToolScopePolicy;
|
|
1636
|
-
readonly riskPolicy?: ToolRiskPolicy;
|
|
1637
|
-
readonly limits?: ToolBrokerConcurrencyLimits;
|
|
1638
|
-
readonly audit?: ToolAuditSink;
|
|
1639
|
-
readonly now?: () => string;
|
|
1640
|
-
readonly mcpAuth?: McpAuthorization;
|
|
1641
|
-
}
|
|
1642
|
-
declare class ToolBroker {
|
|
1643
|
-
readonly directory: string;
|
|
1644
|
-
readonly engagementId: EngagementId;
|
|
1645
|
-
private readonly engagement;
|
|
1646
|
-
private readonly grants;
|
|
1647
|
-
private readonly docker;
|
|
1648
|
-
private readonly mcp;
|
|
1649
|
-
private readonly catalog;
|
|
1650
|
-
private readonly scopePolicy;
|
|
1651
|
-
private readonly riskPolicy;
|
|
1652
|
-
private readonly limits;
|
|
1653
|
-
private readonly audit;
|
|
1654
|
-
private readonly mcpAuth;
|
|
1655
|
-
private readonly now;
|
|
1656
|
-
private readonly calls;
|
|
1657
|
-
private readonly approvals;
|
|
1658
|
-
private readonly outputs;
|
|
1659
|
-
private chain;
|
|
1660
|
-
private draining;
|
|
1661
|
-
private constructor();
|
|
1662
|
-
static open(options: ToolBrokerOptions): Promise<ToolBroker>;
|
|
1663
|
-
getCall(id: ToolCallId): ToolCallRecord | undefined;
|
|
1664
|
-
listPending(): readonly PendingToolCall[];
|
|
1665
|
-
execute(request: ToolCallRequest): Promise<ToolExecuteResult>;
|
|
1666
|
-
approve(toolCallId: ToolCallId): Promise<ToolExecuteResult>;
|
|
1667
|
-
reject(toolCallId: ToolCallId, reason?: string): Promise<ToolExecuteResult>;
|
|
1668
|
-
cancel(toolCallId: ToolCallId): Promise<ToolExecuteResult>;
|
|
1669
|
-
/**
|
|
1670
|
-
* P0-3/P0-5: cancel every in-flight tool call (requested/queued/running/
|
|
1671
|
-
* pending_approval) for one AgentRun. Best-effort per call; used when the
|
|
1672
|
-
* user stops a Subagent / cancels a Task.
|
|
1673
|
-
*/
|
|
1674
|
-
cancelAgentRunCalls(agentRunId: AgentRunId): Promise<number>;
|
|
1675
|
-
private serialized;
|
|
1676
|
-
private admit;
|
|
1677
|
-
private admitApproval;
|
|
1678
|
-
private enqueueOrDispatch;
|
|
1679
|
-
private canRun;
|
|
1680
|
-
private dispatch;
|
|
1681
|
-
private finishDispatch;
|
|
1682
|
-
private resultFromRecord;
|
|
1683
|
-
private drain;
|
|
1684
|
-
private validateIdentity;
|
|
1685
|
-
private effectiveToolbox;
|
|
1686
|
-
private backendFor;
|
|
1687
|
-
private denyMcp;
|
|
1688
|
-
private save;
|
|
1689
|
-
private finish;
|
|
1690
|
-
}
|
|
1691
|
-
//#endregion
|
|
1692
|
-
//#region src/projection/commands.d.ts
|
|
1693
|
-
type PentesterCommand = {
|
|
1694
|
-
readonly type: 'approval.approve';
|
|
1695
|
-
readonly approvalId: ToolCallId;
|
|
1696
|
-
} | {
|
|
1697
|
-
readonly type: 'approval.reject';
|
|
1698
|
-
readonly approvalId: ToolCallId;
|
|
1699
|
-
readonly reason?: string;
|
|
1700
|
-
} | {
|
|
1701
|
-
readonly type: 'conversation.open';
|
|
1702
|
-
readonly agentRunId: string;
|
|
1703
|
-
} | {
|
|
1704
|
-
/** P0-5: user stops a running Subagent / cancels a Task from the UI. */
|
|
1705
|
-
readonly type: 'task.stop';
|
|
1706
|
-
readonly taskId?: TaskId;
|
|
1707
|
-
readonly reason?: string;
|
|
1708
|
-
};
|
|
1709
|
-
type PentesterCommandResult = {
|
|
1710
|
-
readonly status: 'accepted';
|
|
1711
|
-
readonly type: PentesterCommand['type'];
|
|
1712
|
-
readonly sessionId?: string;
|
|
1713
|
-
readonly projection?: PentesterProjection;
|
|
1714
|
-
} | {
|
|
1715
|
-
readonly status: 'rejected';
|
|
1716
|
-
readonly reason: string;
|
|
1717
|
-
};
|
|
1718
|
-
//#endregion
|
|
1719
|
-
//#region src/projection/publisher.d.ts
|
|
1720
|
-
interface PublishedBundle {
|
|
1721
|
-
readonly revision: number;
|
|
1722
|
-
readonly overview: PentesterProjection;
|
|
1723
|
-
readonly assets: AssetsProjection;
|
|
1724
|
-
readonly findings: FindingsProjection;
|
|
1725
|
-
readonly evidence: EvidenceProjection;
|
|
1726
|
-
readonly activity: ActivityProjection;
|
|
1727
|
-
readonly report: ReportProjection;
|
|
1728
|
-
}
|
|
1729
|
-
/**
|
|
1730
|
-
* Binding-aware projection publisher: resolves `sessionId → engagementId →
|
|
1731
|
-
* canonical bundle`. A session with no binding reads an explicit empty/unbound
|
|
1732
|
-
* state (never a guess, never the last-published bundle, never a Workspace
|
|
1733
|
-
* merge). Updates propagate to every session bound to the same Engagement
|
|
1734
|
-
* (S1/S2 → E1 both refresh when E1 changes).
|
|
1735
|
-
*/
|
|
1736
|
-
declare class PentesterProjectionPublisher {
|
|
1737
|
-
private readonly builder;
|
|
1738
|
-
private readonly byEngagement;
|
|
1739
|
-
/** sessionId → engagementId (Root binding mirror; the durable store is authoritative). */
|
|
1740
|
-
private readonly sessionEngagement;
|
|
1741
|
-
private previewEnabled;
|
|
1742
|
-
private globalRevision;
|
|
1743
|
-
/** Enable presentation-only sample projections when no real bundle exists. */
|
|
1744
|
-
setUiPreview(enabled: boolean): void;
|
|
1745
|
-
isUiPreviewEnabled(): boolean;
|
|
1746
|
-
private previewBundle;
|
|
1747
|
-
/** Publish (or refresh) the canonical bundle for one Engagement. */
|
|
1748
|
-
publish(model: CanonicalReadModel): PublishedBundle;
|
|
1749
|
-
/** The current bundle for one Engagement (undefined when never published). */
|
|
1750
|
-
currentFor(engagementId: EngagementId): PublishedBundle | undefined;
|
|
1751
|
-
/** Legacy single-engagement view (devSeed / single-engagement tests). */
|
|
1752
|
-
current(): PublishedBundle | undefined;
|
|
1753
|
-
engagementId(): EngagementId | undefined;
|
|
1754
|
-
/** Bind a Root Session to its Engagement (projection resolution authority). */
|
|
1755
|
-
bindSession(sessionId: string, engagementId?: EngagementId): void;
|
|
1756
|
-
isBound(sessionId: string | undefined, viaEvent: boolean): boolean;
|
|
1757
|
-
/** Per-session resolution: sessionId → engagementId → canonical bundle. */
|
|
1758
|
-
viewForSession(sessionId: string, key: PentesterProjectionKey): PublishedBundle[keyof Omit<PublishedBundle, 'revision'>] | null;
|
|
1759
|
-
/** Per-engagement resolution (used by the per-session projection unit). */
|
|
1760
|
-
viewForEngagement(engagementId: EngagementId, key: PentesterProjectionKey): PublishedBundle[keyof Omit<PublishedBundle, 'revision'>] | null;
|
|
1761
|
-
/** Legacy single-bundle view (kept for existing tests / devSeed). */
|
|
1762
|
-
view(key: PentesterProjectionKey, bound: boolean): PublishedBundle[keyof Omit<PublishedBundle, 'revision'>] | null;
|
|
1763
|
-
}
|
|
1764
|
-
//#endregion
|
|
1765
|
-
//#region src/ptes-core/events.d.ts
|
|
1766
|
-
declare const PTES_CORE_EVENT_TYPES: readonly ["artifact.created", "artifact.merged", "evidence.created", "finding.created", "finding.updated", "finding.status_changed", "occurrence.created", "occurrence.merged", "occurrence.status_changed"];
|
|
1767
|
-
type PtesCoreEventType = (typeof PTES_CORE_EVENT_TYPES)[number];
|
|
1768
|
-
interface PtesCoreEventEnvelope<TType extends PtesCoreEventType, TPayload> {
|
|
1769
|
-
readonly eventId: EventId;
|
|
1770
|
-
readonly sequence: number;
|
|
1771
|
-
readonly type: TType;
|
|
1772
|
-
readonly engagementId: EngagementId;
|
|
1773
|
-
readonly timestamp: string;
|
|
1774
|
-
readonly sourcePtapMessageId?: string;
|
|
1775
|
-
readonly ingestionResult?: IngestionResult;
|
|
1776
|
-
readonly payload: TPayload;
|
|
1777
|
-
}
|
|
1778
|
-
interface ArtifactCreatedPayload {
|
|
1779
|
-
readonly artifact: ArtifactRecord;
|
|
1780
|
-
}
|
|
1781
|
-
interface ArtifactMergedPayload {
|
|
1782
|
-
readonly artifactId: ArtifactId;
|
|
1783
|
-
readonly provenance: ArtifactProvenance;
|
|
1784
|
-
readonly evidenceIds: readonly EvidenceId[];
|
|
1785
|
-
}
|
|
1786
|
-
interface EvidenceCreatedPayload {
|
|
1787
|
-
readonly evidence: EvidenceRecord;
|
|
1788
|
-
}
|
|
1789
|
-
interface FindingCreatedPayload {
|
|
1790
|
-
readonly finding: FindingRecord;
|
|
1791
|
-
}
|
|
1792
|
-
interface FindingUpdatedPayload {
|
|
1793
|
-
readonly findingId: FindingId;
|
|
1794
|
-
readonly occurrenceIds: readonly FindingOccurrenceId[];
|
|
1795
|
-
}
|
|
1796
|
-
interface FindingStatusChangedPayload {
|
|
1797
|
-
readonly findingId: FindingId;
|
|
1798
|
-
readonly from: FindingStatus;
|
|
1799
|
-
readonly to: FindingStatus;
|
|
1800
|
-
}
|
|
1801
|
-
interface OccurrenceCreatedPayload {
|
|
1802
|
-
readonly occurrence: FindingOccurrenceRecord;
|
|
1803
|
-
}
|
|
1804
|
-
interface OccurrenceMergedPayload {
|
|
1805
|
-
readonly occurrenceId: FindingOccurrenceId;
|
|
1806
|
-
readonly evidenceIds: readonly EvidenceId[];
|
|
1807
|
-
}
|
|
1808
|
-
interface OccurrenceStatusChangedPayload {
|
|
1809
|
-
readonly occurrenceId: FindingOccurrenceId;
|
|
1810
|
-
readonly from: FindingStatus;
|
|
1811
|
-
readonly to: FindingStatus;
|
|
1812
|
-
}
|
|
1813
|
-
type ArtifactCreatedEvent = PtesCoreEventEnvelope<'artifact.created', ArtifactCreatedPayload>;
|
|
1814
|
-
type ArtifactMergedEvent = PtesCoreEventEnvelope<'artifact.merged', ArtifactMergedPayload>;
|
|
1815
|
-
type EvidenceCreatedEvent = PtesCoreEventEnvelope<'evidence.created', EvidenceCreatedPayload>;
|
|
1816
|
-
type FindingCreatedEvent = PtesCoreEventEnvelope<'finding.created', FindingCreatedPayload>;
|
|
1817
|
-
type FindingUpdatedEvent = PtesCoreEventEnvelope<'finding.updated', FindingUpdatedPayload>;
|
|
1818
|
-
type FindingStatusChangedEvent = PtesCoreEventEnvelope<'finding.status_changed', FindingStatusChangedPayload>;
|
|
1819
|
-
type OccurrenceCreatedEvent = PtesCoreEventEnvelope<'occurrence.created', OccurrenceCreatedPayload>;
|
|
1820
|
-
type OccurrenceMergedEvent = PtesCoreEventEnvelope<'occurrence.merged', OccurrenceMergedPayload>;
|
|
1821
|
-
type OccurrenceStatusChangedEvent = PtesCoreEventEnvelope<'occurrence.status_changed', OccurrenceStatusChangedPayload>;
|
|
1822
|
-
type PtesCoreEvent = ArtifactCreatedEvent | ArtifactMergedEvent | EvidenceCreatedEvent | FindingCreatedEvent | FindingUpdatedEvent | FindingStatusChangedEvent | OccurrenceCreatedEvent | OccurrenceMergedEvent | OccurrenceStatusChangedEvent;
|
|
1823
|
-
//#endregion
|
|
1824
|
-
//#region src/ptes-core/repositories/artifacts.d.ts
|
|
1825
|
-
interface ArtifactUpsertInput {
|
|
1826
|
-
readonly kind: ArtifactKind;
|
|
1827
|
-
readonly summary: string;
|
|
1828
|
-
readonly identity?: ArtifactIdentityFields;
|
|
1829
|
-
readonly identityKey?: string;
|
|
1830
|
-
readonly evidenceIds: readonly EvidenceId[];
|
|
1831
|
-
readonly provenance: ArtifactProvenance;
|
|
1832
|
-
readonly createdInStageId: StageId;
|
|
1833
|
-
readonly producedByTaskId: TaskId;
|
|
1834
|
-
readonly producedByAgentRunId: AgentRunId;
|
|
1835
|
-
}
|
|
1836
|
-
interface ArtifactRepository {
|
|
1837
|
-
get(id: ArtifactId): Promise<ArtifactRecord | undefined>;
|
|
1838
|
-
list(query?: ArtifactQuery): Promise<readonly ArtifactRecord[]>;
|
|
1839
|
-
upsert(input: ArtifactUpsertInput): Promise<ArtifactUpsertResult>;
|
|
1840
|
-
}
|
|
1841
|
-
//#endregion
|
|
1842
|
-
//#region src/ptes-core/repositories/evidence.d.ts
|
|
1843
|
-
interface EvidenceCreateInput {
|
|
1844
|
-
readonly kind: EvidenceKind;
|
|
1845
|
-
readonly summary: string;
|
|
1846
|
-
readonly bytes: Uint8Array;
|
|
1847
|
-
readonly mediaType?: string;
|
|
1848
|
-
readonly createdInStageId: StageId;
|
|
1849
|
-
readonly producedByTaskId: TaskId;
|
|
1850
|
-
readonly producedByAgentRunId: AgentRunId;
|
|
1851
|
-
readonly sourcePtapMessageId: string;
|
|
1852
|
-
}
|
|
1853
|
-
interface EvidenceRepository {
|
|
1854
|
-
get(id: EvidenceId): Promise<EvidenceRecord | undefined>;
|
|
1855
|
-
list(query?: EvidenceQuery): Promise<readonly EvidenceRecord[]>;
|
|
1856
|
-
create(input: EvidenceCreateInput): Promise<EvidenceRecord>;
|
|
1857
|
-
readBytes(id: EvidenceId): Promise<Uint8Array>;
|
|
1858
|
-
}
|
|
1859
|
-
//#endregion
|
|
1860
|
-
//#region src/ptes-core/repositories/findings.d.ts
|
|
1861
|
-
interface FindingUpsertInput {
|
|
1862
|
-
readonly title: string;
|
|
1863
|
-
readonly severity: FindingSeverity;
|
|
1864
|
-
readonly confidence: number;
|
|
1865
|
-
readonly category?: string;
|
|
1866
|
-
readonly weakness?: string;
|
|
1867
|
-
readonly cwe?: string;
|
|
1868
|
-
readonly identityKey?: string;
|
|
1869
|
-
readonly createdInStageId: StageId;
|
|
1870
|
-
readonly producedByTaskId: TaskId;
|
|
1871
|
-
readonly producedByAgentRunId: AgentRunId;
|
|
1872
|
-
readonly sourcePtapMessageId?: string;
|
|
1873
|
-
readonly ingestionResult?: IngestionResult;
|
|
1874
|
-
readonly finalizeIngestion?: boolean;
|
|
1875
|
-
}
|
|
1876
|
-
interface FindingOccurrenceUpsertInput {
|
|
1877
|
-
readonly findingId: FindingId;
|
|
1878
|
-
readonly assetId: AssetId;
|
|
1879
|
-
readonly endpoint?: string;
|
|
1880
|
-
readonly serviceId?: string;
|
|
1881
|
-
readonly evidenceIds: readonly EvidenceId[];
|
|
1882
|
-
readonly reproductionContext?: string;
|
|
1883
|
-
readonly identityKey: string;
|
|
1884
|
-
readonly sourcePtapMessageId?: string;
|
|
1885
|
-
readonly ingestionResult?: IngestionResult;
|
|
1886
|
-
}
|
|
1887
|
-
interface FindingStatusUpdateInput {
|
|
1888
|
-
readonly findingId: FindingId;
|
|
1889
|
-
readonly to: FindingStatus;
|
|
1890
|
-
}
|
|
1891
|
-
interface FindingRepository {
|
|
1892
|
-
get(id: FindingId): Promise<FindingRecord | undefined>;
|
|
1893
|
-
list(query?: FindingQuery): Promise<readonly FindingRecord[]>;
|
|
1894
|
-
getOccurrence(id: FindingOccurrenceId): Promise<FindingOccurrenceRecord | undefined>;
|
|
1895
|
-
listOccurrences(findingId?: FindingId): Promise<readonly FindingOccurrenceRecord[]>;
|
|
1896
|
-
upsertFinding(input: FindingUpsertInput): Promise<FindingUpsertResult>;
|
|
1897
|
-
upsertOccurrence(input: FindingOccurrenceUpsertInput): Promise<FindingOccurrenceUpsertResult>;
|
|
1898
|
-
updateStatus(input: FindingStatusUpdateInput): Promise<FindingRecord>;
|
|
1899
|
-
}
|
|
1900
|
-
//#endregion
|
|
1901
|
-
//#region src/ptes-core/store.d.ts
|
|
1902
|
-
interface PtesCoreStoreOptions {
|
|
1903
|
-
readonly engagementDir: string;
|
|
1904
|
-
readonly engagementId: EngagementId;
|
|
1905
|
-
readonly limits?: EvidenceStorageLimits;
|
|
1906
|
-
readonly now?: () => string;
|
|
1907
|
-
}
|
|
1908
|
-
interface PtesCoreStore {
|
|
1909
|
-
readonly artifacts: ArtifactRepository;
|
|
1910
|
-
readonly evidence: EvidenceRepository;
|
|
1911
|
-
readonly findings: FindingRepository;
|
|
1912
|
-
readonly directory: string;
|
|
1913
|
-
readonly engagementId: EngagementId;
|
|
1914
|
-
getState(): PtesCoreState;
|
|
1915
|
-
getIngestion(sourcePtapMessageId: string): IngestionResult | undefined;
|
|
1916
|
-
listOrphanBlobs(): Promise<readonly string[]>;
|
|
1917
|
-
cleanOrphanBlobs(): Promise<readonly string[]>;
|
|
1918
|
-
}
|
|
1919
|
-
declare class DurablePtesCoreStore implements PtesCoreStore {
|
|
1920
|
-
readonly artifacts: ArtifactRepository;
|
|
1921
|
-
readonly evidence: EvidenceRepository;
|
|
1922
|
-
readonly findings: FindingRepository;
|
|
1923
|
-
readonly directory: string;
|
|
1924
|
-
readonly engagementId: EngagementId;
|
|
1925
|
-
private readonly blobs;
|
|
1926
|
-
private readonly limits;
|
|
1927
|
-
private readonly now;
|
|
1928
|
-
private chain;
|
|
1929
|
-
private current;
|
|
1930
|
-
private constructor();
|
|
1931
|
-
getState(): PtesCoreState;
|
|
1932
|
-
getIngestion(sourcePtapMessageId: string): IngestionResult | undefined;
|
|
1933
|
-
listOrphanBlobs(): Promise<readonly string[]>;
|
|
1934
|
-
cleanOrphanBlobs(): Promise<readonly string[]>;
|
|
1935
|
-
static open(options: PtesCoreStoreOptions): Promise<DurablePtesCoreStore>;
|
|
1936
|
-
applyPreparedEvents(events: readonly PtesCoreEvent[]): Promise<PtesCoreState>;
|
|
1937
|
-
private serialized;
|
|
1938
|
-
private readEvidenceBytes;
|
|
1939
|
-
private filterArtifacts;
|
|
1940
|
-
private filterEvidence;
|
|
1941
|
-
private filterFindings;
|
|
1942
|
-
private commitEvents;
|
|
1943
|
-
private envelope;
|
|
1944
|
-
private replayedArtifact;
|
|
1945
|
-
private replayedEvidence;
|
|
1946
|
-
private replayedFinding;
|
|
1947
|
-
private replayedOccurrence;
|
|
1948
|
-
private upsertArtifact;
|
|
1949
|
-
private createEvidence;
|
|
1950
|
-
private upsertFinding;
|
|
1951
|
-
private upsertOccurrence;
|
|
1952
|
-
private updateFindingStatus;
|
|
1953
|
-
}
|
|
1954
|
-
//#endregion
|
|
1955
|
-
//#region src/state/engagement-state-store.d.ts
|
|
1956
|
-
interface CreateEngagementInput {
|
|
1957
|
-
readonly parentDir: string;
|
|
1958
|
-
readonly objectives: string;
|
|
1959
|
-
readonly scopeSummary: string;
|
|
1960
|
-
readonly targets: readonly {
|
|
1961
|
-
readonly value: string;
|
|
1962
|
-
}[];
|
|
1963
|
-
}
|
|
1964
|
-
interface CreateTaskInput {
|
|
1965
|
-
readonly stageId: StageId;
|
|
1966
|
-
readonly goal: string;
|
|
1967
|
-
readonly templateId: AgentTemplateId;
|
|
1968
|
-
readonly continueAgentRunId?: AgentRunId;
|
|
1969
|
-
readonly dependsOn?: readonly TaskId[];
|
|
1970
|
-
readonly parentTaskId?: TaskId;
|
|
1971
|
-
/** Immutable Global-config snapshot captured at AgentRun creation. */
|
|
1972
|
-
readonly configSnapshot?: AgentRunConfigSnapshot;
|
|
1973
|
-
}
|
|
1974
|
-
interface SerializedStoreApi {
|
|
1975
|
-
snapshot(): EngagementStateSnapshot;
|
|
1976
|
-
advanceStages(steps: readonly {
|
|
1977
|
-
readonly stageId: StageId;
|
|
1978
|
-
readonly to: StageStatus;
|
|
1979
|
-
readonly reason: StageTransitionReason;
|
|
1980
|
-
readonly skippedReason?: string;
|
|
1981
|
-
}[]): Promise<void>;
|
|
1982
|
-
}
|
|
1983
|
-
declare class EngagementStateStore {
|
|
1984
|
-
private writeChain;
|
|
1985
|
-
readonly directory: string;
|
|
1986
|
-
private current;
|
|
1987
|
-
private constructor();
|
|
1988
|
-
getSnapshot(): EngagementStateSnapshot;
|
|
1989
|
-
static create(input: CreateEngagementInput): Promise<EngagementStateStore>;
|
|
1990
|
-
static load(engagementDir: string): Promise<EngagementStateStore>;
|
|
1991
|
-
static recover(engagementDir: string): Promise<EngagementStateStore>;
|
|
1992
|
-
private enqueue;
|
|
1993
|
-
private nextEvents;
|
|
1994
|
-
private commit;
|
|
1995
|
-
/**
|
|
1996
|
-
* Run `fn` on the latest in-memory snapshot inside the per-Engagement write chain.
|
|
1997
|
-
* Callers must not enqueue other store methods from `fn`.
|
|
1998
|
-
*/
|
|
1999
|
-
runSerialized<T>(fn: (api: SerializedStoreApi) => Promise<T>): Promise<T>;
|
|
2000
|
-
transitionStage(input: {
|
|
2001
|
-
readonly stageId: StageId;
|
|
2002
|
-
readonly to: StageStatus;
|
|
2003
|
-
readonly reason: StageTransitionReason;
|
|
2004
|
-
}): Promise<void>;
|
|
2005
|
-
advanceStages(steps: readonly {
|
|
2006
|
-
readonly stageId: StageId;
|
|
2007
|
-
readonly to: StageStatus;
|
|
2008
|
-
readonly reason: StageTransitionReason;
|
|
2009
|
-
readonly skippedReason?: string;
|
|
2010
|
-
}[]): Promise<void>;
|
|
2011
|
-
private advanceStagesUnlocked;
|
|
2012
|
-
createTask(input: CreateTaskInput): Promise<{
|
|
2013
|
-
taskId: TaskId;
|
|
2014
|
-
agentRunId: AgentRunId;
|
|
2015
|
-
}>;
|
|
2016
|
-
startTask(taskId: TaskId): Promise<void>;
|
|
2017
|
-
/**
|
|
2018
|
-
* P1-9: mark an AgentRun as genuinely `running` — called when the Worker
|
|
2019
|
-
* runtime emits its first activity (PTAP progress/artifact) after launch.
|
|
2020
|
-
* Prevents the UI from showing "running" before the Worker actually runs.
|
|
2021
|
-
*/
|
|
2022
|
-
markAgentRunRunning(agentRunId: AgentRunId, taskId: TaskId): Promise<void>;
|
|
2023
|
-
completeTask(taskId: TaskId): Promise<EventId>;
|
|
2024
|
-
failTask(taskId: TaskId): Promise<EventId>;
|
|
2025
|
-
cancelTask(taskId: TaskId): Promise<EventId>;
|
|
2026
|
-
blockTask(taskId: TaskId): Promise<EventId>;
|
|
2027
|
-
completeAgentRun(agentRunId: AgentRunId): Promise<void>;
|
|
2028
|
-
failAgentRun(agentRunId: AgentRunId): Promise<void>;
|
|
2029
|
-
cancelAgentRun(agentRunId: AgentRunId): Promise<void>;
|
|
2030
|
-
blockAgentRun(agentRunId: AgentRunId): Promise<void>;
|
|
2031
|
-
private transitionTask;
|
|
2032
|
-
private transitionAgentRun;
|
|
2033
|
-
/**
|
|
2034
|
-
* P0-1: mark the Engagement archived (last active Root Session detached).
|
|
2035
|
-
* History is retained; only the active association is closed. Idempotent.
|
|
2036
|
-
*/
|
|
2037
|
-
archiveEngagement(detachedSessionIds: readonly string[]): Promise<void>;
|
|
2038
|
-
recoverRunningWork(): Promise<void>;
|
|
2039
|
-
}
|
|
2040
|
-
//#endregion
|
|
2041
|
-
//#region src/tools/docker-engine.d.ts
|
|
2042
|
-
interface DockerImageInspect {
|
|
2043
|
-
readonly id: string;
|
|
2044
|
-
readonly digest?: string;
|
|
2045
|
-
}
|
|
2046
|
-
interface DockerContainerInspect {
|
|
2047
|
-
readonly id: string;
|
|
2048
|
-
readonly running: boolean;
|
|
2049
|
-
readonly image: string;
|
|
2050
|
-
}
|
|
2051
|
-
/** Minimal container row for listing (P0-B GC scans by label/name/image). */
|
|
2052
|
-
interface DockerContainerListItem {
|
|
2053
|
-
readonly id: string;
|
|
2054
|
-
readonly name: string;
|
|
2055
|
-
readonly image: string;
|
|
2056
|
-
readonly running: boolean;
|
|
2057
|
-
readonly labels?: Readonly<Record<string, string>>;
|
|
2058
|
-
}
|
|
2059
|
-
interface DockerListContainersInput {
|
|
2060
|
-
readonly all?: boolean;
|
|
2061
|
-
/** Docker label filter: `key=value`. */
|
|
2062
|
-
readonly label?: string;
|
|
2063
|
-
}
|
|
2064
|
-
interface DockerHostConfig {
|
|
2065
|
-
readonly privileged?: boolean;
|
|
2066
|
-
readonly networkMode?: string;
|
|
2067
|
-
readonly pidMode?: string;
|
|
2068
|
-
readonly ipcMode?: string;
|
|
2069
|
-
readonly capAdd?: readonly string[];
|
|
2070
|
-
readonly binds?: readonly string[];
|
|
2071
|
-
}
|
|
2072
|
-
interface DockerCreateContainerInput {
|
|
2073
|
-
readonly image: string;
|
|
2074
|
-
readonly name?: string;
|
|
2075
|
-
readonly cmd?: readonly string[];
|
|
2076
|
-
readonly env?: readonly string[];
|
|
2077
|
-
readonly labels?: Readonly<Record<string, string>>;
|
|
2078
|
-
readonly hostConfig: DockerHostConfig;
|
|
2079
|
-
}
|
|
2080
|
-
interface DockerExecInput {
|
|
2081
|
-
readonly containerId: string;
|
|
2082
|
-
readonly argv: readonly string[];
|
|
2083
|
-
readonly cwd?: string;
|
|
2084
|
-
readonly env?: readonly string[];
|
|
2085
|
-
readonly timeoutMs?: number;
|
|
2086
|
-
readonly abort?: AbortSignal;
|
|
2087
|
-
readonly maxTotalCapturedBytes?: number;
|
|
2088
|
-
readonly onExecCreated?: (execId: string) => void;
|
|
2089
|
-
}
|
|
2090
|
-
interface DockerExecResult {
|
|
2091
|
-
readonly execId: string;
|
|
2092
|
-
readonly exitCode: number;
|
|
2093
|
-
readonly stdout: Buffer;
|
|
2094
|
-
readonly stderr: Buffer;
|
|
2095
|
-
readonly truncated: boolean;
|
|
2096
|
-
readonly captureLimitReached: boolean;
|
|
2097
|
-
}
|
|
2098
|
-
interface DockerEngineClient {
|
|
2099
|
-
inspectImage(ref: string): Promise<DockerImageInspect | undefined>;
|
|
2100
|
-
buildImage(input: {
|
|
2101
|
-
contextDir: string;
|
|
2102
|
-
dockerfile: string;
|
|
2103
|
-
tag: string;
|
|
2104
|
-
}): Promise<DockerImageInspect>;
|
|
2105
|
-
pullImage(image: string): Promise<DockerImageInspect>;
|
|
2106
|
-
createContainer(input: DockerCreateContainerInput): Promise<{
|
|
2107
|
-
containerId: string;
|
|
2108
|
-
}>;
|
|
2109
|
-
inspectContainer(containerId: string): Promise<DockerContainerInspect | undefined>;
|
|
2110
|
-
startContainer(containerId: string): Promise<void>;
|
|
2111
|
-
stopContainer(containerId: string): Promise<void>;
|
|
2112
|
-
removeContainer(containerId: string): Promise<void>;
|
|
2113
|
-
/** List containers (P0-B GC). `label` filters on `dsh.pentester.*` labels. */
|
|
2114
|
-
listContainers(input?: DockerListContainersInput): Promise<readonly DockerContainerListItem[]>;
|
|
2115
|
-
exec(input: DockerExecInput): Promise<DockerExecResult>;
|
|
2116
|
-
cancelExec(execId: string): Promise<'confirmed' | 'requested' | 'unknown'>;
|
|
2117
|
-
}
|
|
2118
|
-
//#endregion
|
|
2119
|
-
//#region src/tools/engagement-container-store.d.ts
|
|
2120
|
-
interface EngagementContainerBinding {
|
|
2121
|
-
readonly engagementId: EngagementId;
|
|
2122
|
-
readonly profile: string;
|
|
2123
|
-
readonly image: string;
|
|
2124
|
-
readonly containerId: string;
|
|
2125
|
-
readonly imageId?: string;
|
|
2126
|
-
readonly imageSource?: 'existing' | 'built' | 'pulled';
|
|
2127
|
-
readonly createdAt: string;
|
|
2128
|
-
}
|
|
2129
|
-
//#endregion
|
|
2130
|
-
//#region src/tools/toolbox-registry.d.ts
|
|
2131
|
-
declare class InMemoryToolboxRegistry {
|
|
2132
|
-
private readonly boxes;
|
|
2133
|
-
constructor(boxes?: readonly ToolboxDefinition[]);
|
|
2134
|
-
get(id: ToolboxId): ToolboxDefinition | undefined;
|
|
2135
|
-
list(): readonly ToolboxDefinition[];
|
|
2136
|
-
}
|
|
2137
|
-
//#endregion
|
|
2138
|
-
//#region src/tools/docker-provisioner.d.ts
|
|
2139
|
-
interface ResolvedToolboxImage {
|
|
2140
|
-
readonly toolboxId: ToolboxId;
|
|
2141
|
-
readonly image: string;
|
|
2142
|
-
readonly inspect: DockerImageInspect;
|
|
2143
|
-
readonly source: ImageResolveSource;
|
|
2144
|
-
}
|
|
2145
|
-
declare class ToolboxProvisioner {
|
|
2146
|
-
inspectCalls: number;
|
|
2147
|
-
buildCalls: number;
|
|
2148
|
-
pullCalls: number;
|
|
2149
|
-
private readonly engine;
|
|
2150
|
-
private readonly registry;
|
|
2151
|
-
private readonly repoRoot;
|
|
2152
|
-
private readonly sources;
|
|
2153
|
-
constructor(input: {
|
|
2154
|
-
readonly engine: DockerEngineClient;
|
|
2155
|
-
readonly registry?: InMemoryToolboxRegistry;
|
|
2156
|
-
readonly repoRoot?: string;
|
|
2157
|
-
});
|
|
2158
|
-
definition(id: ToolboxId): ToolboxDefinition | undefined;
|
|
2159
|
-
inspect(id: ToolboxId): Promise<DockerImageInspect | undefined>;
|
|
2160
|
-
build(id: ToolboxId): Promise<ResolvedToolboxImage>;
|
|
2161
|
-
pull(id: ToolboxId): Promise<ResolvedToolboxImage>;
|
|
2162
|
-
resolve(id: ToolboxId): Promise<ResolvedToolboxImage | undefined>;
|
|
2163
|
-
private require;
|
|
2164
|
-
}
|
|
2165
|
-
//#endregion
|
|
2166
|
-
//#region src/tools/docker-backend.d.ts
|
|
2167
|
-
interface DockerToolBackend extends ToolBackend {
|
|
2168
|
-
readonly kind: 'docker';
|
|
2169
|
-
}
|
|
2170
|
-
interface DockerToolExecutorOptions {
|
|
2171
|
-
readonly engagementDir: string;
|
|
2172
|
-
readonly engagementId: EngagementId;
|
|
2173
|
-
readonly engine: DockerEngineClient;
|
|
2174
|
-
readonly catalog?: ToolCatalog;
|
|
2175
|
-
readonly registry?: InMemoryToolboxRegistry;
|
|
2176
|
-
readonly provisioner?: ToolboxProvisioner;
|
|
2177
|
-
readonly outputLimits?: ToolOutputLimits;
|
|
2178
|
-
/**
|
|
2179
|
-
* Host path of the DSH project working directory, bind-mounted into the
|
|
2180
|
-
* container as `/workspace` (the default exec cwd). Trusted host value —
|
|
2181
|
-
* never from the model. When absent the Engagement workspace is mounted to
|
|
2182
|
-
* `/workspace` instead (legacy fallback) and `/artifacts` is omitted.
|
|
2183
|
-
*/
|
|
2184
|
-
readonly workspacePath?: string;
|
|
2185
|
-
/**
|
|
2186
|
-
* P0-B: stable workspace identity label value (hashed, never the raw path).
|
|
2187
|
-
* Recorded on the managed container so GC can attribute it without parsing
|
|
2188
|
-
* container names.
|
|
2189
|
-
*/
|
|
2190
|
-
readonly workspaceLabel?: string;
|
|
2191
|
-
/**
|
|
2192
|
-
* P1-4: human-readable slug for the container name (e.g. "192-168-107-5").
|
|
2193
|
-
* Derived from the Engagement's targets — never a UUID.
|
|
2194
|
-
*/
|
|
2195
|
-
readonly nameSlug?: string;
|
|
2196
|
-
}
|
|
2197
|
-
declare class DockerToolExecutor implements DockerToolBackend {
|
|
2198
|
-
readonly kind: "docker";
|
|
2199
|
-
executeCalls: number;
|
|
2200
|
-
cancelCalls: number;
|
|
2201
|
-
lastContext?: ToolBackendExecutionContext;
|
|
2202
|
-
lastArgv?: readonly string[];
|
|
2203
|
-
lastContainerId?: string;
|
|
2204
|
-
lastResolvedImage?: DockerImageInspect;
|
|
2205
|
-
firewallObjectsCreated: number;
|
|
2206
|
-
private readonly engagementDir;
|
|
2207
|
-
private readonly engagementId;
|
|
2208
|
-
private readonly engine;
|
|
2209
|
-
private readonly catalog;
|
|
2210
|
-
private readonly registry;
|
|
2211
|
-
private readonly provisioner;
|
|
2212
|
-
private readonly limits;
|
|
2213
|
-
private workspacePath;
|
|
2214
|
-
private workspaceLabel;
|
|
2215
|
-
private nameSlug;
|
|
2216
|
-
/** P0-B: 1 Engagement = 1 persistent container (engagementId × profile). */
|
|
2217
|
-
private engagementContainers;
|
|
2218
|
-
private readonly inflight;
|
|
2219
|
-
private constructor();
|
|
2220
|
-
static open(options: DockerToolExecutorOptions): Promise<DockerToolExecutor>;
|
|
2221
|
-
listBindings(): readonly DockerToolboxBinding[];
|
|
2222
|
-
/** P0-B: expose the engagement container bindings (provenance + GC). */
|
|
2223
|
-
listEngagementContainers(): readonly EngagementContainerBinding[];
|
|
2224
|
-
/**
|
|
2225
|
-
* P0-B: bind the trusted DSH workspace AFTER open (recovery path). The DSH
|
|
2226
|
-
* session's header cwd — never ~/.dsh — is the /workspace mount source.
|
|
2227
|
-
* Setting it late also updates the workspace label on the container.
|
|
2228
|
-
*/
|
|
2229
|
-
setWorkspacePath(workspacePath: string | undefined): void;
|
|
2230
|
-
/** P0-B: the current /workspace mount source (trusted DSH workspace). */
|
|
2231
|
-
currentWorkspacePath(): string | undefined;
|
|
2232
|
-
inspectRuntime(binding: DockerToolboxBinding): Promise<'running' | 'stopped' | 'missing' | 'unknown'>;
|
|
2233
|
-
startRuntime(binding: DockerToolboxBinding): Promise<void>;
|
|
2234
|
-
stopRuntime(binding: DockerToolboxBinding): Promise<void>;
|
|
2235
|
-
cleanupRuntime(binding: DockerToolboxBinding): Promise<void>;
|
|
2236
|
-
execute(context: ToolBackendExecutionContext): Promise<ToolBackendResult>;
|
|
2237
|
-
cancel(executionId: string): Promise<ToolBackendCancelResult>;
|
|
2238
|
-
/**
|
|
2239
|
-
* P0-B Engagement CLOSED: stop + remove the managed container(s) for this
|
|
2240
|
-
* Engagement and forget the bindings. Returns removed container ids.
|
|
2241
|
-
*/
|
|
2242
|
-
closeEngagementContainers(): Promise<readonly string[]>;
|
|
2243
|
-
/**
|
|
2244
|
-
* P0-B explicit runtime reset: stop + remove + recreate the Engagement's
|
|
2245
|
-
* managed container (next ensure re-creates it lazily).
|
|
2246
|
-
*/
|
|
2247
|
-
resetEngagementContainer(): Promise<string | undefined>;
|
|
2248
|
-
/**
|
|
2249
|
-
* P0-B: DISPOSABLE execution smoke. Creates a transient container (no
|
|
2250
|
-
* managed label, no persistent binding), runs `argv`, and ALWAYS removes it
|
|
2251
|
-
* (PASS or FAIL). The global preflight uses this so it never leaves a
|
|
2252
|
-
* long-running `sleep infinity` container behind. Persistent containers are
|
|
2253
|
-
* created ONLY by ensureEngagementContainer (via execute).
|
|
2254
|
-
*/
|
|
2255
|
-
runDisposableSmoke(input: {
|
|
2256
|
-
readonly argv: readonly string[];
|
|
2257
|
-
readonly cwd?: string;
|
|
2258
|
-
readonly env?: Readonly<Record<string, string>>;
|
|
2259
|
-
readonly timeoutMs?: number;
|
|
2260
|
-
}): Promise<{
|
|
2261
|
-
ok: boolean;
|
|
2262
|
-
stdout: string;
|
|
2263
|
-
stderr: string;
|
|
2264
|
-
exitCode: number;
|
|
2265
|
-
message?: string;
|
|
2266
|
-
}>;
|
|
2267
|
-
private toolboxIdFor;
|
|
2268
|
-
private argvFor;
|
|
2269
|
-
}
|
|
2270
|
-
//#endregion
|
|
2271
|
-
//#region src/tools/mcp-registry.d.ts
|
|
2272
|
-
declare class InMemoryMcpServerRegistry {
|
|
2273
|
-
private readonly servers;
|
|
2274
|
-
constructor(servers?: readonly McpServerDefinition[]);
|
|
2275
|
-
get(id: McpServerId): McpServerDefinition | undefined;
|
|
2276
|
-
list(): readonly McpServerDefinition[];
|
|
2277
|
-
}
|
|
2278
|
-
//#endregion
|
|
2279
|
-
//#region src/tools/mcp-backend.d.ts
|
|
2280
|
-
interface McpToolBackend extends ToolBackend {
|
|
2281
|
-
readonly kind: 'mcp';
|
|
2282
|
-
}
|
|
2283
|
-
interface McpTransportCall {
|
|
2284
|
-
readonly serverId: McpServerId;
|
|
2285
|
-
readonly remoteToolName: string;
|
|
2286
|
-
readonly arguments: unknown;
|
|
2287
|
-
readonly replay: boolean;
|
|
2288
|
-
}
|
|
2289
|
-
interface McpTransport {
|
|
2290
|
-
call(input: McpTransportCall): Promise<{
|
|
2291
|
-
result: unknown;
|
|
2292
|
-
text?: string;
|
|
2293
|
-
}>;
|
|
2294
|
-
reconnect?(serverId: McpServerId): Promise<void>;
|
|
2295
|
-
}
|
|
2296
|
-
interface McpToolExecutorOptions {
|
|
2297
|
-
readonly engagementDir: string;
|
|
2298
|
-
readonly engagementId: EngagementId;
|
|
2299
|
-
readonly transport: McpTransport;
|
|
2300
|
-
readonly catalog?: ToolCatalog;
|
|
2301
|
-
readonly registry?: InMemoryMcpServerRegistry;
|
|
2302
|
-
}
|
|
2303
|
-
declare class McpToolExecutor implements McpToolBackend {
|
|
2304
|
-
readonly kind: "mcp";
|
|
2305
|
-
executeCalls: number;
|
|
2306
|
-
cancelCalls: number;
|
|
2307
|
-
lastContext?: ToolBackendExecutionContext;
|
|
2308
|
-
lastRuntimeId?: string;
|
|
2309
|
-
private readonly engagementId;
|
|
2310
|
-
private readonly transport;
|
|
2311
|
-
private readonly catalog;
|
|
2312
|
-
private readonly registry;
|
|
2313
|
-
private bindings;
|
|
2314
|
-
private seq;
|
|
2315
|
-
private constructor();
|
|
2316
|
-
static open(options: McpToolExecutorOptions): Promise<McpToolExecutor>;
|
|
2317
|
-
listBindings(): readonly McpRuntimeBinding[];
|
|
2318
|
-
restoreRuntime(binding: McpRuntimeBinding): Promise<void>;
|
|
2319
|
-
execute(context: ToolBackendExecutionContext): Promise<ToolBackendResult>;
|
|
2320
|
-
cancel(_executionId: string): Promise<ToolBackendCancelResult>;
|
|
2321
|
-
}
|
|
2322
|
-
//#endregion
|
|
2323
|
-
//#region src/host/seed.d.ts
|
|
2324
|
-
interface DevSeed {
|
|
2325
|
-
readonly engagement: EngagementStateStore;
|
|
2326
|
-
readonly ptes: DurablePtesCoreStore;
|
|
2327
|
-
readonly broker: ToolBroker;
|
|
2328
|
-
readonly bindings: HarnessSessionBinding[];
|
|
2329
|
-
loadModel(): CanonicalReadModel;
|
|
2330
|
-
}
|
|
2331
|
-
//#endregion
|
|
2332
|
-
//#region src/host/runtime.d.ts
|
|
2333
|
-
interface HostEngagementSource {
|
|
2334
|
-
readonly engagementId: EngagementId;
|
|
2335
|
-
loadModel(): CanonicalReadModel;
|
|
2336
|
-
readonly broker: Pick<ToolBroker, 'approve' | 'reject' | 'listPending' | 'getCall'>;
|
|
2337
|
-
readonly orchestratorSessions: Readonly<Record<string, EngagementId>>;
|
|
2338
|
-
readEvidence(evidenceId: EvidenceId): Promise<{
|
|
2339
|
-
readonly text?: string;
|
|
2340
|
-
readonly mediaType?: string;
|
|
2341
|
-
readonly error?: string;
|
|
2342
|
-
}>;
|
|
2343
|
-
}
|
|
2344
|
-
interface HostSession {
|
|
2345
|
-
readonly id: string;
|
|
2346
|
-
readonly header?: {
|
|
2347
|
-
readonly agentPreset?: string;
|
|
2348
|
-
readonly parentSession?: string;
|
|
2349
|
-
readonly cwd?: string;
|
|
2350
|
-
};
|
|
2351
|
-
append: (type: string, data: Record<string, unknown>) => unknown;
|
|
2352
|
-
}
|
|
2353
|
-
interface HostContext {
|
|
2354
|
-
readonly sessionProjections: {
|
|
2355
|
-
register: (definition: {
|
|
2356
|
-
key: string;
|
|
2357
|
-
schema: unknown;
|
|
2358
|
-
init: () => unknown;
|
|
2359
|
-
apply: (state: unknown, event: unknown) => unknown;
|
|
2360
|
-
view: (state: unknown) => unknown;
|
|
2361
|
-
stateVersion: number;
|
|
2362
|
-
}) => () => void;
|
|
2363
|
-
};
|
|
2364
|
-
commands?: {
|
|
2365
|
-
register: (definition: {
|
|
2366
|
-
name: string;
|
|
2367
|
-
description: string;
|
|
2368
|
-
handler: (invocation: {
|
|
2369
|
-
agent: {
|
|
2370
|
-
session: HostSession;
|
|
2371
|
-
};
|
|
2372
|
-
rawInput: string;
|
|
2373
|
-
}) => Promise<{
|
|
2374
|
-
kind: 'success' | 'error';
|
|
2375
|
-
text?: string;
|
|
2376
|
-
}> | {
|
|
2377
|
-
kind: 'success' | 'error';
|
|
2378
|
-
text?: string;
|
|
2379
|
-
};
|
|
2380
|
-
}) => () => void;
|
|
2381
|
-
};
|
|
2382
|
-
on?: (event: string, listener: (...args: unknown[]) => void) => () => void;
|
|
2383
|
-
/**
|
|
2384
|
-
* P0-1: durable DSH workspace registry (archivedSessionIds).
|
|
2385
|
-
*
|
|
2386
|
-
* OPTIONAL service — read it through the non-strict reflect accessor
|
|
2387
|
-
* (`ctx.get('workspaceRegistry', false)`), never as a direct property:
|
|
2388
|
-
* Cordis's context proxy throws "cannot get property ... without inject"
|
|
2389
|
-
* for any service not declared in the enclosing callback's inject list,
|
|
2390
|
-
* so even a `=== undefined` guard on a direct access crashes when the
|
|
2391
|
-
* assembly does not inject the service.
|
|
2392
|
-
*/
|
|
2393
|
-
workspaceRegistry?: {
|
|
2394
|
-
readonly archivedSessionIds: readonly string[];
|
|
2395
|
-
};
|
|
2396
|
-
}
|
|
2397
|
-
/**
|
|
2398
|
-
* P0-1: called by the host when a Root Session is archived so the plugin can
|
|
2399
|
-
* detach it from its Engagement (and archive the Engagement when empty).
|
|
2400
|
-
*/
|
|
2401
|
-
type SessionArchivedHook = (sessionId: string) => Promise<void> | void;
|
|
2402
|
-
declare class PentesterHostRuntime {
|
|
2403
|
-
readonly publisher: PentesterProjectionPublisher;
|
|
2404
|
-
readonly sessions: Map<string, HostSession>;
|
|
2405
|
-
private seed;
|
|
2406
|
-
private readonly sources;
|
|
2407
|
-
private tickSeq;
|
|
2408
|
-
/**
|
|
2409
|
-
* Host-enforced Environment Readiness Gate hook: invoked when a Pentester
|
|
2410
|
-
* session activates. The plugin registers this to run the global preflight
|
|
2411
|
-
* and emit pentester/environment-preflight-* events into the session log.
|
|
2412
|
-
*/
|
|
2413
|
-
onSessionActivated?: (session: HostSession) => Promise<void> | void;
|
|
2414
|
-
/**
|
|
2415
|
-
* P0-1: invoked when a Root Session is archived (DSH workspace registry
|
|
2416
|
-
* reports it). The plugin detaches the session from its Engagement and
|
|
2417
|
-
* archives the Engagement when no active Root remains.
|
|
2418
|
-
*/
|
|
2419
|
-
onSessionArchived?: SessionArchivedHook;
|
|
2420
|
-
/** Track the last-seen archived set (P0-1 archive detection). */
|
|
2421
|
-
private lastArchivedSessionIds;
|
|
2422
|
-
/** Next tick sequence (used by context injection command ids). */
|
|
2423
|
-
nextTickSeq(): number;
|
|
2424
|
-
bindSource(source: HostEngagementSource): void;
|
|
2425
|
-
/** Re-publish one composition's canonical bundle (after a canonical mutation). */
|
|
2426
|
-
publishComposition(composition: PentesterComposition): void;
|
|
2427
|
-
/** Append a projection-invalidation tick for one session (canonical changed). */
|
|
2428
|
-
tickSession(sessionId: string, name: 'pentester-sync' | 'pentester-attach'): void;
|
|
2429
|
-
start(options: {
|
|
2430
|
-
readonly devSeed: boolean;
|
|
2431
|
-
readonly parentDir?: string;
|
|
2432
|
-
readonly seed?: DevSeed;
|
|
2433
|
-
}): Promise<void>;
|
|
2434
|
-
registerProjections(ctx: HostContext): void;
|
|
2435
|
-
registerCommands(ctx: HostContext): void;
|
|
2436
|
-
listenSessions(ctx: HostContext): void;
|
|
2437
|
-
private ctx;
|
|
2438
|
-
/**
|
|
2439
|
-
* P0-1: diff the DSH archived-session set against the last seen one and
|
|
2440
|
-
* fire `onSessionArchived` for each newly archived session.
|
|
2441
|
-
*/
|
|
2442
|
-
checkArchivedSessions(): Promise<void>;
|
|
2443
|
-
/** Non-strict reflect read of the optional workspace registry (absent → undefined). */
|
|
2444
|
-
private workspaceRegistryOf;
|
|
2445
|
-
private reconcileArchived;
|
|
2446
|
-
private attached;
|
|
2447
|
-
private readonly engagementBySession;
|
|
2448
|
-
private isAttached;
|
|
2449
|
-
private isPentesterRootSession;
|
|
2450
|
-
/** Bind a Harness session to an Engagement. Override is for tests / multi-engagement isolation. */
|
|
2451
|
-
bindSessionEngagement(sessionId: string, engagementId: EngagementId): void;
|
|
2452
|
-
/** P0-1: unbind a session from its Engagement (Session archived). */
|
|
2453
|
-
unbindSessionEngagement(sessionId: string): void;
|
|
2454
|
-
hasSeed(): boolean;
|
|
2455
|
-
listPending(): PendingToolCall[];
|
|
2456
|
-
seedEngagementId(): EngagementId | undefined;
|
|
2457
|
-
seedPrimaryRunId(): AgentRunId | undefined;
|
|
2458
|
-
attachSession(session: HostSession): Promise<{
|
|
2459
|
-
kind: 'success';
|
|
2460
|
-
text: string;
|
|
2461
|
-
}>;
|
|
2462
|
-
dispatch(sessionId: string, command: PentesterCommand): Promise<PentesterCommandResult>;
|
|
2463
|
-
private asCommandResult;
|
|
2464
|
-
private liveSource;
|
|
2465
|
-
private isRootPentesterAttached;
|
|
2466
|
-
private dispatchFromSlash;
|
|
2467
|
-
private dispatchSeed;
|
|
2468
|
-
readEvidence(evidenceId: string): Promise<{
|
|
2469
|
-
readonly text?: string;
|
|
2470
|
-
readonly mediaType?: string;
|
|
2471
|
-
readonly error?: string;
|
|
2472
|
-
}>;
|
|
2473
|
-
openConversation(agentRunId: string): Promise<PentesterCommandResult>;
|
|
2474
|
-
private tick;
|
|
2475
|
-
}
|
|
2476
|
-
//#endregion
|
|
2477
|
-
//#region src/runtime/wakeup-bridge.d.ts
|
|
2478
|
-
/**
|
|
2479
|
-
* P0-A ParentWakeupDispatcher.
|
|
2480
|
-
*
|
|
2481
|
-
* A Worker's terminal PTAP (or the Worker Finalizer) produces a canonical
|
|
2482
|
-
* task.completed / task.blocked / task.failed store event AND a durable
|
|
2483
|
-
* ParentWakeupRecord in the same commit window. This dispatcher turns that
|
|
2484
|
-
* record into a REAL parent continuation:
|
|
2485
|
-
*
|
|
2486
|
-
* 1. inject a deterministic plugin-origin user message into the parent's
|
|
2487
|
-
* DSH inbox (source.kind='plugin', plugin='dsh-pentester') — NEVER the
|
|
2488
|
-
* Worker's prose, only the terminal delta;
|
|
2489
|
-
* 2. schedule/resume the parent Agent so a NEW turn starts (the parent is
|
|
2490
|
-
* normally idle after its own turn/end; `agent.followup` wakes it).
|
|
2491
|
-
*
|
|
2492
|
-
* State machine: pending → delivering → delivered | failed_retryable.
|
|
2493
|
-
* Idempotency: (parentSessionId, terminalEventId) is the durable key; the
|
|
2494
|
-
* outbox dedupes inserts and the dispatcher only delivers records not yet
|
|
2495
|
-
* marked delivered. Startup recovery re-scans pending/failed_retryable
|
|
2496
|
-
* records so a crash never loses a terminal notification.
|
|
2497
|
-
*/
|
|
2498
|
-
/** The DSH-native continuation seam (live agent handle). */
|
|
2499
|
-
interface ParentAgentHandle {
|
|
2500
|
-
/** Deliver one user-role message to the next-turn inbox AND wake the driver. */
|
|
2501
|
-
followup(message: {
|
|
2502
|
-
readonly id: string;
|
|
2503
|
-
readonly role: 'user';
|
|
2504
|
-
readonly content: readonly [{
|
|
2505
|
-
readonly type: 'text';
|
|
2506
|
-
readonly text: string;
|
|
2507
|
-
}];
|
|
2508
|
-
readonly source: {
|
|
2509
|
-
readonly kind: 'plugin';
|
|
2510
|
-
readonly plugin: 'dsh-pentester';
|
|
2511
|
-
};
|
|
2512
|
-
}): void;
|
|
2513
|
-
}
|
|
2514
|
-
interface ParentWakeupDispatcherDeps {
|
|
2515
|
-
/** Resolve the parent Orchestrator HostSession for a record. */
|
|
2516
|
-
resolveParentSession: (input: {
|
|
2517
|
-
readonly engagementId: EngagementId;
|
|
2518
|
-
readonly taskId: TaskId;
|
|
2519
|
-
readonly agentRunId: AgentRunId;
|
|
2520
|
-
readonly parentSessionId: string;
|
|
2521
|
-
}) => HostSession | undefined;
|
|
2522
|
-
/**
|
|
2523
|
-
* Resolve the live DSH agent handle for the parent session. `undefined`
|
|
2524
|
-
* means the parent is not currently live — the record stays pending and a
|
|
2525
|
-
* later dispatch/retry picks it up.
|
|
2526
|
-
*/
|
|
2527
|
-
resolveParentAgent: (parentSessionId: string) => ParentAgentHandle | undefined;
|
|
2528
|
-
/** Test/embedding hook: called INSTEAD of the native followup when no agent resolves. */
|
|
2529
|
-
continueParentFallback?: (session: HostSession, record: ParentWakeupRecord) => Promise<void> | void;
|
|
2530
|
-
/** Diagnostics / audit sink. */
|
|
2531
|
-
log?: (event: string, detail?: unknown) => void;
|
|
2532
|
-
}
|
|
2533
|
-
declare class ParentWakeupDispatcher {
|
|
2534
|
-
private deps;
|
|
2535
|
-
constructor(deps: ParentWakeupDispatcherDeps);
|
|
2536
|
-
/** Replace the deps (composition default → host-installed live deps). */
|
|
2537
|
-
install(deps: ParentWakeupDispatcherDeps): void;
|
|
2538
|
-
/**
|
|
2539
|
-
* Create the durable wakeup intent (called inside the terminal transition
|
|
2540
|
-
* window) and dispatch immediately. Returns the record.
|
|
2541
|
-
*/
|
|
2542
|
-
notify(outbox: ParentWakeupOutbox, info: TaskTerminalInfo, childSessionId: string, parentSessionId: string): Promise<ParentWakeupRecord>;
|
|
2543
|
-
/**
|
|
2544
|
-
* Dispatch one pending record: inject the inbox message + schedule the
|
|
2545
|
-
* parent continuation. Returns true when delivered.
|
|
2546
|
-
*/
|
|
2547
|
-
dispatch(outbox: ParentWakeupOutbox, record: ParentWakeupRecord): Promise<boolean>;
|
|
2548
|
-
/**
|
|
2549
|
-
* P0-A startup recovery: re-dispatch every pending/failed_retryable record.
|
|
2550
|
-
* Called by the plugin host after compositions + sessions are live so a
|
|
2551
|
-
* crash between terminal transition and delivery never loses the wakeup.
|
|
2552
|
-
*/
|
|
2553
|
-
recoverPending(outbox: ParentWakeupOutbox): Promise<number>;
|
|
2554
|
-
}
|
|
2555
|
-
//#endregion
|
|
2556
|
-
//#region src/runtime/docker-endpoint.d.ts
|
|
2557
|
-
/**
|
|
2558
|
-
* Docker endpoint resolution — NEVER hard-codes a single socket path.
|
|
2559
|
-
*
|
|
2560
|
-
* Priority (first hit wins):
|
|
2561
|
-
* 1. plugin config `dockerSocket` (explicit operator choice)
|
|
2562
|
-
* 2. `DOCKER_HOST` env (standard Docker override)
|
|
2563
|
-
* 3. configured Docker runtime/context (`docker context inspect` current)
|
|
2564
|
-
* 4. platform default:
|
|
2565
|
-
* macOS → OrbStack socket if present (~/.orbstack/run/docker.sock)
|
|
2566
|
-
* macOS → ~/.docker/run/docker.sock (Docker Desktop) if present
|
|
2567
|
-
* Linux → /var/run/docker.sock
|
|
2568
|
-
*
|
|
2569
|
-
* All discovery is read-only (fs stat / docker context inspect).
|
|
2570
|
-
*/
|
|
2571
|
-
type DockerEndpointSource = 'plugin_config' | 'docker_host' | 'docker_context' | 'platform_default';
|
|
2572
|
-
interface ResolvedDockerEndpoint {
|
|
2573
|
-
readonly socketPath: string;
|
|
2574
|
-
readonly source: DockerEndpointSource;
|
|
2575
|
-
}
|
|
2576
|
-
//#endregion
|
|
2577
|
-
//#region src/runtime/environment-gate.d.ts
|
|
2578
|
-
/**
|
|
2579
|
-
* Pentester Environment Readiness Gate.
|
|
2580
|
-
*
|
|
2581
|
-
* A deterministic GLOBAL preflight that must pass before a Pentester Session
|
|
2582
|
-
* enters normal workflow (bootstrap / stage transition / create_task / spawn /
|
|
2583
|
-
* execution). Every check is READ-ONLY — no target traffic, no state mutation.
|
|
2584
|
-
*
|
|
2585
|
-
* The Host enforces the gate; it is never the model's responsibility to call
|
|
2586
|
-
* a "check" tool. A failed gate blocks the corresponding action and returns
|
|
2587
|
-
* typed diagnostics with `executionRetryable` / `recoverable` semantics.
|
|
2588
|
-
*/
|
|
2589
|
-
type EnvironmentStatus = 'checking' | 'ready' | 'blocked';
|
|
2590
|
-
type EnvironmentCheckCode = 'ENVIRONMENT_NOT_READY' | 'AGENTS_SERVICE_UNAVAILABLE' | 'DOCKER_RUNTIME_UNAVAILABLE' | 'FACTORY_IMAGE_UNAVAILABLE' | 'WORKSPACE_UNAVAILABLE' | 'WORKER_TOOL_MISSING' | 'WORKER_COMMAND_MISSING';
|
|
2591
|
-
interface EnvironmentDiagnostic {
|
|
2592
|
-
readonly code: EnvironmentCheckCode;
|
|
2593
|
-
readonly message: string;
|
|
2594
|
-
/** False for deterministic contract/environment failures — do NOT let the
|
|
2595
|
-
* model retry the same call immediately. */
|
|
2596
|
-
readonly executionRetryable: false;
|
|
2597
|
-
/** True when the environment condition may resolve (daemon starts, image
|
|
2598
|
-
* gets built) — the HOST may re-run the gate later. */
|
|
2599
|
-
readonly recoverable: boolean;
|
|
2600
|
-
}
|
|
2601
|
-
interface GlobalEnvironmentState {
|
|
2602
|
-
readonly status: EnvironmentStatus;
|
|
2603
|
-
readonly checkedAt: string;
|
|
2604
|
-
readonly generation: number;
|
|
2605
|
-
readonly diagnostic?: EnvironmentDiagnostic;
|
|
2606
|
-
/** True when every check passed and the state is cached for reuse. */
|
|
2607
|
-
readonly ready: boolean;
|
|
2608
|
-
}
|
|
2609
|
-
interface GlobalEnvironmentChecks {
|
|
2610
|
-
/** DSH project workspace path resolved & existing on disk. */
|
|
2611
|
-
readonly workspacePath: string;
|
|
2612
|
-
/** Whether the agents/subagent service is available (native or injected). */
|
|
2613
|
-
readonly agentsServiceAvailable: boolean;
|
|
2614
|
-
/** Whether container_exec (and exec tools) are registered model-facing. */
|
|
2615
|
-
readonly execToolsRegistered: readonly string[];
|
|
2616
|
-
/** Docker endpoint + engine (reached via resolver; NOT hard-coded). */
|
|
2617
|
-
readonly endpoint: ResolvedDockerEndpoint;
|
|
2618
|
-
readonly engine: DockerEngineClient;
|
|
2619
|
-
/** Factory image ref to resolve (e.g. dsh-pentester/kali:latest). */
|
|
2620
|
-
readonly factoryImage: string;
|
|
2621
|
-
/** Whether the approval runtime (Tool Broker pending-approval) is available. */
|
|
2622
|
-
readonly approvalRuntimeAvailable: boolean;
|
|
2623
|
-
/** Whether the role-based tool registration is valid (templates resolve). */
|
|
2624
|
-
readonly roleToolRegistrationValid: boolean;
|
|
2625
|
-
/** Whether PTAP contracts/schemas are loaded. */
|
|
2626
|
-
readonly ptapContractsLoaded: boolean;
|
|
2627
|
-
/**
|
|
2628
|
-
* Optional execution round-trip smoke runner. When provided, the gate runs a
|
|
2629
|
-
* no-target, no-network smoke command through the SAME production chain the
|
|
2630
|
-
* Worker uses (resolver → container → binding → Broker → Executor → result
|
|
2631
|
-
* adapter → lossless JSON). Failure ⇒ ENVIRONMENT_NOT_READY.
|
|
2632
|
-
*/
|
|
2633
|
-
readonly runExecutionSmoke?: () => Promise<ExecutionSmokeResult>;
|
|
2634
|
-
}
|
|
2635
|
-
interface ExecutionSmokeResult {
|
|
2636
|
-
readonly ok: boolean;
|
|
2637
|
-
readonly code?: 'EXECUTION_RUNTIME_UNAVAILABLE' | 'EXECUTION_CONTAINER_UNAVAILABLE' | 'EXECUTION_RESULT_SERIALIZATION_FAILED' | 'EXECUTION_SMOKE_TEST_FAILED';
|
|
2638
|
-
readonly message?: string;
|
|
2639
|
-
readonly stdout?: string;
|
|
2640
|
-
}
|
|
2641
|
-
/**
|
|
2642
|
-
* Run the GLOBAL environment gate. Returns a cached READY state when the last
|
|
2643
|
-
* check passed; re-runs when the previous state is not ready or is stale.
|
|
2644
|
-
*/
|
|
2645
|
-
declare class PentesterEnvironmentGate {
|
|
2646
|
-
private state;
|
|
2647
|
-
private generation;
|
|
2648
|
-
/** Invalidate the cached READY state (Docker/runtime changed). */
|
|
2649
|
-
invalidate(): void;
|
|
2650
|
-
cached(): GlobalEnvironmentState | undefined;
|
|
2651
|
-
/** Force a full re-check (used by tests / after a runtime change). */
|
|
2652
|
-
recheck(checks: GlobalEnvironmentChecks, now?: string): Promise<GlobalEnvironmentState>;
|
|
2653
|
-
ensure(checks: GlobalEnvironmentChecks, now?: string): Promise<GlobalEnvironmentState>;
|
|
2654
|
-
}
|
|
2655
|
-
//#endregion
|
|
2656
|
-
//#region src/workflow/facts.d.ts
|
|
2657
|
-
interface WorkflowFactsProvider {
|
|
2658
|
-
getFacts(input: {
|
|
2659
|
-
engagementId: EngagementId;
|
|
2660
|
-
state: EngagementStateSnapshot;
|
|
2661
|
-
}): Promise<WorkflowFacts>;
|
|
2662
|
-
}
|
|
2663
|
-
//#endregion
|
|
2664
|
-
//#region src/workflow/engine.d.ts
|
|
2665
|
-
declare class WorkflowEngine {
|
|
2666
|
-
private readonly store;
|
|
2667
|
-
private readonly facts;
|
|
2668
|
-
constructor(store: EngagementStateStore, facts?: WorkflowFactsProvider);
|
|
2669
|
-
evaluateExitCriteria(engagementId: EngagementId, stageId: StageId): Promise<ExitCriteriaEvaluation>;
|
|
2670
|
-
requestTransition(request: WorkflowTransitionRequest): Promise<WorkflowTransitionResult>;
|
|
2671
|
-
}
|
|
2672
|
-
//#endregion
|
|
2673
|
-
//#region src/context/delivery-state.d.ts
|
|
2674
|
-
interface ContextDeliveryStateStore {
|
|
2675
|
-
get(agentRunId: AgentRunId): Promise<ContextDeliveryState | undefined>;
|
|
2676
|
-
recordDelivery(agentRunId: AgentRunId, itemIds: readonly string[], refIds: readonly string[], constraintFingerprint?: string): Promise<void>;
|
|
2677
|
-
}
|
|
2678
|
-
//#endregion
|
|
2679
|
-
//#region src/context/errors.d.ts
|
|
2680
|
-
declare class ContextBuildError extends Error {
|
|
2681
|
-
readonly code: ContextBuildErrorCode;
|
|
2682
|
-
constructor(code: ContextBuildErrorCode, message: string);
|
|
2683
|
-
}
|
|
2684
|
-
type ContextBuildResult<T> = {
|
|
2685
|
-
readonly ok: true;
|
|
2686
|
-
readonly value: T;
|
|
2687
|
-
} | {
|
|
2688
|
-
readonly ok: false;
|
|
2689
|
-
readonly error: ContextBuildError;
|
|
2690
|
-
};
|
|
2691
|
-
//#endregion
|
|
2692
|
-
//#region src/context/providers.d.ts
|
|
2693
|
-
interface ContextCandidate {
|
|
2694
|
-
readonly id: string;
|
|
2695
|
-
readonly kind: 'asset' | 'artifact' | 'finding' | 'evidence' | 'related_task' | 'guidance';
|
|
2696
|
-
readonly source: ContextSource;
|
|
2697
|
-
readonly summary?: string;
|
|
2698
|
-
readonly text?: string;
|
|
2699
|
-
readonly mediaType?: string;
|
|
2700
|
-
readonly producedByTaskId?: TaskId;
|
|
2701
|
-
readonly assetIds?: readonly string[];
|
|
2702
|
-
readonly findingIds?: readonly string[];
|
|
2703
|
-
readonly stageId?: StageId;
|
|
2704
|
-
readonly targetTaskId?: TaskId;
|
|
2705
|
-
readonly targetAgentRunId?: AgentRunId;
|
|
2706
|
-
readonly createdAt: number;
|
|
2707
|
-
readonly sizeBytes?: number;
|
|
2708
|
-
}
|
|
2709
|
-
interface ContextDataProvider {
|
|
2710
|
-
getAssets(snapshot: EngagementStateSnapshot): Promise<readonly ContextCandidate[]>;
|
|
2711
|
-
getArtifacts(snapshot: EngagementStateSnapshot): Promise<readonly ContextCandidate[]>;
|
|
2712
|
-
getFindings(snapshot: EngagementStateSnapshot): Promise<readonly ContextCandidate[]>;
|
|
2713
|
-
getEvidence(snapshot: EngagementStateSnapshot): Promise<readonly ContextCandidate[]>;
|
|
2714
|
-
getRelatedTasks(snapshot: EngagementStateSnapshot): Promise<readonly ContextCandidate[]>;
|
|
2715
|
-
getUserGuidance(snapshot: EngagementStateSnapshot): Promise<readonly ContextCandidate[]>;
|
|
2716
|
-
}
|
|
2717
|
-
//#endregion
|
|
2718
|
-
//#region src/context/builder.d.ts
|
|
2719
|
-
interface TemplateLookup {
|
|
2720
|
-
get(id: AgentTemplateId): AgentTemplate | undefined;
|
|
2721
|
-
}
|
|
2722
|
-
interface ContextBuilderDeps {
|
|
2723
|
-
readonly data: ContextDataProvider;
|
|
2724
|
-
readonly templates: TemplateLookup;
|
|
2725
|
-
readonly delivery: ContextDeliveryStateStore;
|
|
2726
|
-
readonly budget?: ContextBudget;
|
|
2727
|
-
readonly now?: () => string;
|
|
2728
|
-
}
|
|
2729
|
-
interface ContextBuildRequest {
|
|
2730
|
-
readonly snapshot: EngagementStateSnapshot;
|
|
2731
|
-
readonly taskId: TaskId;
|
|
2732
|
-
readonly agentRunId: AgentRunId;
|
|
2733
|
-
readonly agentTemplateId: AgentTemplateId;
|
|
2734
|
-
readonly explicitRefs?: readonly ExplicitContextRef[];
|
|
2735
|
-
readonly taskConstraints?: readonly ContextConstraint[];
|
|
2736
|
-
}
|
|
2737
|
-
declare class ContextBuilder {
|
|
2738
|
-
private readonly data;
|
|
2739
|
-
private readonly templates;
|
|
2740
|
-
private readonly delivery;
|
|
2741
|
-
private readonly budget;
|
|
2742
|
-
private readonly now;
|
|
2743
|
-
constructor(deps: ContextBuilderDeps);
|
|
2744
|
-
buildForSpawn(request: ContextBuildRequest): Promise<ContextBuildResult<TaskContextBundle>>;
|
|
2745
|
-
buildForContinue(request: ContextBuildRequest): Promise<ContextBuildResult<TaskContextDelta>>;
|
|
2746
|
-
recordDelivery(agentRunId: AgentRunId, items: readonly ContextItem[], constraints?: readonly ContextConstraint[]): Promise<void>;
|
|
2747
|
-
private buildBundle;
|
|
2748
|
-
private loadMandatory;
|
|
2749
|
-
private collect;
|
|
2750
|
-
}
|
|
2751
|
-
//#endregion
|
|
2752
|
-
//#region src/orchestrator/controller.d.ts
|
|
2753
|
-
interface OrchestratorControllerDeps {
|
|
2754
|
-
readonly store: EngagementStateStore;
|
|
2755
|
-
readonly engine: WorkflowEngine;
|
|
2756
|
-
readonly reasoning: OrchestratorAgentRuntime;
|
|
2757
|
-
readonly templates: AgentTemplateRegistry;
|
|
2758
|
-
readonly agentRuns: AgentRunRuntime;
|
|
2759
|
-
readonly produced: ProducedDataSink;
|
|
2760
|
-
readonly outbound: PtapOutbound;
|
|
2761
|
-
readonly audit: AuditSink;
|
|
2762
|
-
readonly toolboxGrants?: ToolboxGrantStore;
|
|
2763
|
-
/** Effective Global Config source (Stage Agent policies + Agent entities). */
|
|
2764
|
-
readonly config?: EffectiveConfigSource;
|
|
2765
|
-
/**
|
|
2766
|
-
* P0-A Parent Wakeup Bridge sink: receives the deterministic TerminalInfo
|
|
2767
|
-
* for every canonical task.completed/blocked/failed so the host can wake the
|
|
2768
|
-
* parent Orchestrator session exactly once.
|
|
2769
|
-
*/
|
|
2770
|
-
readonly terminalSink?: (info: TaskTerminalInfo) => Promise<void> | void;
|
|
2771
|
-
/** P0-3/P0-5: cancel in-flight tool calls for one AgentRun (broker). */
|
|
2772
|
-
readonly cancelAgentRunCalls?: (agentRunId: AgentRunId) => Promise<number>;
|
|
2773
|
-
}
|
|
2774
|
-
/** Async source of the Effective Pentester Config (the store is async + cached). */
|
|
2775
|
-
interface EffectiveConfigSource {
|
|
2776
|
-
resolve(): Promise<EffectivePentesterConfig>;
|
|
2777
|
-
}
|
|
2778
|
-
declare class OrchestratorController {
|
|
2779
|
-
private readonly store;
|
|
2780
|
-
private readonly engine;
|
|
2781
|
-
private readonly reasoning;
|
|
2782
|
-
private readonly templates;
|
|
2783
|
-
private readonly agentRuns;
|
|
2784
|
-
private readonly produced;
|
|
2785
|
-
private readonly outbound;
|
|
2786
|
-
private readonly audit;
|
|
2787
|
-
private readonly toolboxGrants?;
|
|
2788
|
-
private readonly config?;
|
|
2789
|
-
private readonly terminalSink?;
|
|
2790
|
-
private readonly cancelAgentRunCalls?;
|
|
2791
|
-
private chain;
|
|
2792
|
-
private draining;
|
|
2793
|
-
private readonly pending;
|
|
2794
|
-
private readonly progress;
|
|
2795
|
-
private readonly attempts;
|
|
2796
|
-
private readonly pendingDelegates;
|
|
2797
|
-
readonly pendingCapabilities: Set<string>;
|
|
2798
|
-
private readonly pendingCapabilityRecords;
|
|
2799
|
-
lastWorkflowResult?: WorkflowTransitionResult;
|
|
2800
|
-
readonly decisionResults: OrchestratorDecisionResult[];
|
|
2801
|
-
constructor(deps: OrchestratorControllerDeps);
|
|
2802
|
-
getProgress(agentRunId: AgentRunId): RuntimeProgress | undefined;
|
|
2803
|
-
notifyEngagementCreated(): Promise<void>;
|
|
2804
|
-
notifyUserMessage(): Promise<void>;
|
|
2805
|
-
notifyRecovered(): Promise<void>;
|
|
2806
|
-
steerAgentRun(agentRunId: AgentRunId, message: string): Promise<OrchestratorDecisionResult>;
|
|
2807
|
-
handlePtapEvent(input: unknown): Promise<{
|
|
2808
|
-
woke: boolean;
|
|
2809
|
-
}>;
|
|
2810
|
-
private handleValidatedPtap;
|
|
2811
|
-
private handleTaskFailed;
|
|
2812
|
-
/** Deliver the deterministic TerminalInfo to the Parent Wakeup Bridge sink. */
|
|
2813
|
-
private emitTerminal;
|
|
2814
|
-
private handleCapabilityRequested;
|
|
2815
|
-
private enqueueWake;
|
|
2816
|
-
private drain;
|
|
2817
|
-
applyDecision(raw: unknown, engagementId: EngagementId): Promise<OrchestratorDecisionResult>;
|
|
2818
|
-
private executeDecision;
|
|
2819
|
-
private applyCreateTask;
|
|
2820
|
-
/** Resolve the effective Agent entity for an immutable AgentRun snapshot. */
|
|
2821
|
-
private snapshotForAgent;
|
|
2822
|
-
private applyContinue;
|
|
2823
|
-
/**
|
|
2824
|
-
* P0-3/P0-5: user-initiated Task cancel. Resolves the target Task (explicit
|
|
2825
|
-
* taskRef, or the current running Task), cancels the Worker's live AgentRun
|
|
2826
|
-
* (native session cancel), cancels in-flight tool calls via the broker, marks
|
|
2827
|
-
* Task + AgentRun `cancelled` (reason user_requested — NEVER failed), keeps
|
|
2828
|
-
* already-produced artifacts/evidence/findings, emits the canonical
|
|
2829
|
-
* terminal event, and wakes the parent Orchestrator.
|
|
2830
|
-
*/
|
|
2831
|
-
private applyCancelTask;
|
|
2832
|
-
private applyStageTransition;
|
|
2833
|
-
private applyDelegate;
|
|
2834
|
-
private applyCapabilityResponse;
|
|
2835
|
-
private persistToolboxGrant;
|
|
2836
|
-
/**
|
|
2837
|
-
* Auto-grant every Toolbox the Template is allowed to use. Normal Workers
|
|
2838
|
-
* never negotiate capabilities for their own execution tools — the Template
|
|
2839
|
-
* decides model-facing tools (resolveWorkerTools) and the grants that back
|
|
2840
|
-
* them. ptap_request_capability stays for extra escalation only.
|
|
2841
|
-
*/
|
|
2842
|
-
private grantTemplateToolboxes;
|
|
2843
|
-
}
|
|
2844
|
-
//#endregion
|
|
2845
|
-
//#region src/harness/errors.d.ts
|
|
2846
|
-
type AgentRuntimeFailureKind = 'transport' | 'session_unavailable' | 'session_terminated' | 'configuration' | 'tool_runtime' | 'invalid_output' | 'cancelled' | 'unknown';
|
|
2847
|
-
type RuntimeRetryHint = 'transient' | 'permanent' | 'unknown';
|
|
2848
|
-
interface AgentRuntimeFailure {
|
|
2849
|
-
readonly kind: AgentRuntimeFailureKind;
|
|
2850
|
-
readonly retryHint: RuntimeRetryHint;
|
|
2851
|
-
readonly message: string;
|
|
2852
|
-
}
|
|
2853
|
-
//#endregion
|
|
2854
|
-
//#region src/harness/outcome.d.ts
|
|
2855
|
-
type HarnessSessionStatus = 'resumable' | 'running' | 'terminated' | 'unavailable' | 'unknown';
|
|
2856
|
-
type AgentRuntimeOutcome = {
|
|
2857
|
-
readonly status: 'accepted';
|
|
2858
|
-
readonly observation?: 'turn_finished_without_terminal_event' | 'turn_kicked_in_background';
|
|
2859
|
-
} | {
|
|
2860
|
-
readonly status: 'failed';
|
|
2861
|
-
readonly failure: AgentRuntimeFailure;
|
|
2862
|
-
};
|
|
2863
|
-
//#endregion
|
|
2864
|
-
//#region src/harness/client.d.ts
|
|
2865
|
-
interface CreateSessionInput {
|
|
2866
|
-
readonly instructions: string;
|
|
8
|
+
readonly systemPrompt: string;
|
|
9
|
+
readonly skills: readonly string[];
|
|
10
|
+
readonly mcpServers: readonly string[];
|
|
2867
11
|
readonly model?: string;
|
|
2868
|
-
readonly provider?: string;
|
|
2869
|
-
/** The Root Orchestrator Session this worker is a child of (official subagent parentage). */
|
|
2870
|
-
readonly parentSessionId?: string;
|
|
2871
|
-
/** Trusted workspace/cwd inherited from the Root Session. */
|
|
2872
|
-
readonly cwd?: string;
|
|
2873
|
-
/** Composition identity (pentester-mode). */
|
|
2874
|
-
readonly agentPreset?: string;
|
|
2875
|
-
/** Stable display label for the native subagent dropdown (e.g. "Recon · 192.168.107.5"). */
|
|
2876
|
-
readonly workerLabel?: string;
|
|
2877
|
-
readonly skillIds: readonly string[];
|
|
2878
|
-
readonly mcpIds: readonly string[];
|
|
2879
|
-
/** The complete worker allow-list. Host setup must not add orchestration tools. */
|
|
2880
|
-
readonly toolNames: readonly string[];
|
|
2881
|
-
readonly onToolCall?: (name: string, args: Record<string, unknown>) => Promise<void>;
|
|
2882
|
-
/**
|
|
2883
|
-
* P0-A: invoked when the Worker's DSH turn/end settles (native `whenIdle`,
|
|
2884
|
-
* fake startTurn completion). The adapter runs the Worker Finalizer from it
|
|
2885
|
-
* so a Worker that ends without a terminal PTAP never leaves the Task
|
|
2886
|
-
* running/starting forever.
|
|
2887
|
-
*/
|
|
2888
|
-
readonly onTurnSettled?: (sessionId: string) => Promise<void> | void;
|
|
2889
|
-
}
|
|
2890
|
-
interface HarnessSession {
|
|
2891
|
-
readonly sessionId: string;
|
|
2892
|
-
}
|
|
2893
|
-
interface HarnessClient {
|
|
2894
|
-
createSession(input: CreateSessionInput): Promise<HarnessSession>;
|
|
2895
|
-
/** Materialize a cold persisted session before continuation. */
|
|
2896
|
-
resumeSession?(sessionId: string, input: CreateSessionInput): Promise<HarnessSession>;
|
|
2897
|
-
appendContext(sessionId: string, text: string): Promise<void>;
|
|
2898
|
-
/** Start exactly one foreground agent turn and wait for its activity to settle. */
|
|
2899
|
-
startTurn(sessionId: string): Promise<AgentRuntimeOutcome>;
|
|
2900
|
-
/**
|
|
2901
|
-
* Kick a Worker turn without blocking until it completes (async lifecycle).
|
|
2902
|
-
* Used by spawn so `create_task` returns as soon as the Worker is started.
|
|
2903
|
-
* Completion / failure reaches the Orchestrator through PTAP events.
|
|
2904
|
-
*/
|
|
2905
|
-
kickTurn?(sessionId: string): Promise<void>;
|
|
2906
|
-
steer(sessionId: string, instruction: string): Promise<void>;
|
|
2907
|
-
cancel(sessionId: string): Promise<void>;
|
|
2908
|
-
inspect(sessionId: string): Promise<HarnessSessionStatus>;
|
|
2909
|
-
/** Deliver controller data as a trusted internal message when supported. */
|
|
2910
|
-
deliverCommand?(sessionId: string, command: PtapCommand): Promise<void>;
|
|
2911
|
-
}
|
|
2912
|
-
//#endregion
|
|
2913
|
-
//#region src/harness/launch-spec.d.ts
|
|
2914
|
-
interface HarnessTemplateSpec {
|
|
2915
|
-
readonly id: AgentTemplateId;
|
|
2916
|
-
readonly role: string;
|
|
2917
|
-
readonly model?: string;
|
|
2918
|
-
readonly provider?: string;
|
|
2919
|
-
}
|
|
2920
|
-
interface HarnessSkillRef {
|
|
2921
|
-
readonly id: string;
|
|
2922
|
-
}
|
|
2923
|
-
interface HarnessMcpServerRef {
|
|
2924
|
-
readonly id: string;
|
|
2925
|
-
}
|
|
2926
|
-
interface HarnessAgentLaunchSpec {
|
|
2927
|
-
readonly engagementId: EngagementId;
|
|
2928
|
-
readonly stageId: StageId;
|
|
2929
|
-
readonly taskId: TaskId;
|
|
2930
|
-
readonly agentRunId: AgentRunId;
|
|
2931
|
-
readonly template: HarnessTemplateSpec;
|
|
2932
|
-
readonly skills: readonly HarnessSkillRef[];
|
|
2933
|
-
readonly mcpServers: readonly HarnessMcpServerRef[];
|
|
2934
|
-
readonly context: TaskContextBundle | TaskContextDelta;
|
|
2935
|
-
/** Root Orchestrator Session this worker is a child of (official subagent parentage). */
|
|
2936
|
-
readonly parentSessionId?: string;
|
|
2937
|
-
/** Trusted workspace/cwd inherited from the Root Session. */
|
|
2938
|
-
readonly cwd?: string;
|
|
2939
|
-
/** Composition identity (pentester-mode). */
|
|
2940
|
-
readonly agentPreset?: string;
|
|
2941
|
-
/** Stable display label for the native subagent dropdown. */
|
|
2942
|
-
readonly workerLabel?: string;
|
|
2943
|
-
/**
|
|
2944
|
-
* The Worker's model-facing tool allowlist, resolved from the Template via
|
|
2945
|
-
* resolveWorkerTools. The ONLY source for request/header tool assembly —
|
|
2946
|
-
* never inferred from prompt text or capabilities.
|
|
2947
|
-
*/
|
|
2948
|
-
readonly toolNames: readonly string[];
|
|
2949
|
-
}
|
|
2950
|
-
//#endregion
|
|
2951
|
-
//#region src/harness/ptap-tool-handler.d.ts
|
|
2952
|
-
interface PtapEventSink {
|
|
2953
|
-
handle(message: PtapEvent): Promise<void>;
|
|
2954
|
-
}
|
|
2955
|
-
//#endregion
|
|
2956
|
-
//#region src/harness/contract-breaker.d.ts
|
|
2957
|
-
interface ContractFailureSignature {
|
|
2958
|
-
readonly tool: string;
|
|
2959
|
-
readonly code: string;
|
|
2960
|
-
readonly path?: string;
|
|
2961
|
-
}
|
|
2962
|
-
interface ContractBreakerState {
|
|
2963
|
-
readonly signature: ContractFailureSignature;
|
|
2964
|
-
readonly attempts: number;
|
|
2965
|
-
readonly lastPayload?: unknown;
|
|
2966
|
-
}
|
|
2967
|
-
declare class ContractBreaker {
|
|
2968
|
-
private readonly byRun;
|
|
2969
|
-
private readonly threshold;
|
|
2970
|
-
constructor(threshold?: number);
|
|
2971
|
-
/** Record a deterministic contract failure; true when the breaker trips. */
|
|
2972
|
-
record(agentRunId: AgentRunId, signature: ContractFailureSignature, lastPayload?: unknown): boolean;
|
|
2973
|
-
/** Snapshot diagnostics for one run (for the failure report). */
|
|
2974
|
-
snapshot(agentRunId: AgentRunId): readonly ContractBreakerState[];
|
|
2975
|
-
reset(agentRunId: AgentRunId): void;
|
|
2976
|
-
}
|
|
2977
|
-
//#endregion
|
|
2978
|
-
//#region src/harness/runtime-events.d.ts
|
|
2979
|
-
type HarnessRuntimeEvent = {
|
|
2980
|
-
readonly kind: 'session_terminated';
|
|
2981
|
-
readonly agentRunId: AgentRunId;
|
|
2982
|
-
readonly sessionId: string;
|
|
2983
|
-
} | {
|
|
2984
|
-
readonly kind: 'session_unavailable';
|
|
2985
|
-
readonly agentRunId: AgentRunId;
|
|
2986
|
-
readonly sessionId?: string;
|
|
2987
|
-
} | {
|
|
2988
|
-
readonly kind: 'transport_failure';
|
|
2989
|
-
readonly agentRunId: AgentRunId;
|
|
2990
|
-
readonly message: string;
|
|
2991
|
-
} | {
|
|
2992
|
-
readonly kind: 'worker_diagnostics';
|
|
2993
|
-
readonly agentRunId: AgentRunId;
|
|
2994
|
-
/** Developer-observable runtime contract snapshot (never model-visible). */
|
|
2995
|
-
readonly diagnostics: {
|
|
2996
|
-
readonly templateId: string;
|
|
2997
|
-
readonly sessionId: string;
|
|
2998
|
-
readonly engagementBindingPresent: boolean;
|
|
2999
|
-
readonly workspaceResolved: boolean;
|
|
3000
|
-
readonly resolvedTools: readonly string[];
|
|
3001
|
-
readonly executionTools: readonly string[];
|
|
3002
|
-
readonly ptapTools: readonly string[];
|
|
3003
|
-
readonly capabilities: readonly string[];
|
|
3004
|
-
readonly preflightStatus: 'ok';
|
|
3005
|
-
};
|
|
3006
|
-
};
|
|
3007
|
-
interface HarnessRuntimeEventSink {
|
|
3008
|
-
handle(event: HarnessRuntimeEvent): Promise<void>;
|
|
3009
|
-
}
|
|
3010
|
-
//#endregion
|
|
3011
|
-
//#region src/harness/adapter.d.ts
|
|
3012
|
-
interface HarnessSteerInput {
|
|
3013
|
-
readonly engagementId: EngagementId;
|
|
3014
|
-
readonly agentRunId: AgentRunId;
|
|
3015
|
-
readonly instruction: string;
|
|
3016
|
-
}
|
|
3017
|
-
interface HarnessCancelInput {
|
|
3018
|
-
readonly agentRunId: AgentRunId;
|
|
3019
|
-
}
|
|
3020
|
-
interface HarnessAgentRuntime {
|
|
3021
|
-
spawn(spec: HarnessAgentLaunchSpec): Promise<AgentRuntimeOutcome>;
|
|
3022
|
-
continue(spec: HarnessAgentLaunchSpec): Promise<AgentRuntimeOutcome>;
|
|
3023
|
-
steer(input: HarnessSteerInput): Promise<AgentRuntimeOutcome>;
|
|
3024
|
-
cancel(input: HarnessCancelInput): Promise<AgentRuntimeOutcome>;
|
|
3025
|
-
inspectSession(agentRunId: AgentRunId): Promise<HarnessSessionStatus>;
|
|
3026
|
-
deliverPtapCommand(agentRunId: AgentRunId, command: PtapCommand): Promise<AgentRuntimeOutcome>;
|
|
3027
12
|
}
|
|
3028
|
-
interface HarnessAdapterDeps {
|
|
3029
|
-
readonly client: HarnessClient;
|
|
3030
|
-
readonly bindings: HarnessSessionBindingStore;
|
|
3031
|
-
readonly delivery: ContextDeliveryStateStore;
|
|
3032
|
-
readonly sink: PtapEventSink;
|
|
3033
|
-
readonly runtimeEvents?: HarnessRuntimeEventSink;
|
|
3034
|
-
/**
|
|
3035
|
-
* P0-A Worker Finalizer: invoked when a Worker's DSH turn/end settles while
|
|
3036
|
-
* its Task is still non-terminal. The host marks the Task failed/blocked
|
|
3037
|
-
* with WORKER_TERMINATED_WITHOUT_TASK_TERMINAL — a plain turn/end never
|
|
3038
|
-
* equals completion.
|
|
3039
|
-
*/
|
|
3040
|
-
readonly onWorkerTurnSettled?: (spec: HarnessAgentLaunchSpec) => Promise<void> | void;
|
|
3041
|
-
}
|
|
3042
|
-
declare class HarnessAdapter implements HarnessAgentRuntime {
|
|
3043
|
-
private readonly client;
|
|
3044
|
-
private readonly bindings;
|
|
3045
|
-
private readonly delivery;
|
|
3046
|
-
private readonly sink;
|
|
3047
|
-
private readonly runtimeEvents;
|
|
3048
|
-
private readonly onWorkerTurnSettled?;
|
|
3049
|
-
private readonly terminalByRun;
|
|
3050
|
-
/** Runs whose turn settled and were already finalized (no double-finalize). */
|
|
3051
|
-
private readonly finalizedByRun;
|
|
3052
|
-
readonly invokedTools: string[];
|
|
3053
|
-
/** Per-Worker deterministic contract-violation breaker. */
|
|
3054
|
-
readonly contractBreaker: ContractBreaker;
|
|
3055
|
-
constructor(deps: HarnessAdapterDeps);
|
|
3056
|
-
spawn(spec: HarnessAgentLaunchSpec): Promise<AgentRuntimeOutcome>;
|
|
3057
|
-
continue(spec: HarnessAgentLaunchSpec): Promise<AgentRuntimeOutcome>;
|
|
3058
|
-
steer(input: HarnessSteerInput): Promise<AgentRuntimeOutcome>;
|
|
3059
|
-
cancel(input: HarnessCancelInput): Promise<AgentRuntimeOutcome>;
|
|
3060
|
-
inspectSession(agentRunId: AgentRunId): Promise<HarnessSessionStatus>;
|
|
3061
|
-
deliverPtapCommand(agentRunId: AgentRunId, command: PtapCommand): Promise<AgentRuntimeOutcome>;
|
|
3062
|
-
invokeWorkerTool(spec: HarnessAgentLaunchSpec, name: string, args: Record<string, unknown>): Promise<void>;
|
|
3063
|
-
/**
|
|
3064
|
-
* P0-A Worker Finalizer. A Worker's DSH turn/end is NEVER equivalent to
|
|
3065
|
-
* Task completion: only a terminal PTAP (complete/blocked/fail) settles the
|
|
3066
|
-
* Task. When a turn settles while the run has no terminal PTAP recorded,
|
|
3067
|
-
* the host is notified via `onWorkerTurnSettled` so it can mark the Task
|
|
3068
|
-
* failed/blocked deterministically (WORKER_TERMINATED_WITHOUT_TASK_TERMINAL)
|
|
3069
|
-
* and wake the parent — the Task is never left running/starting forever.
|
|
3070
|
-
*
|
|
3071
|
-
* Idempotent per run: after the first finalize, further settle callbacks are
|
|
3072
|
-
* no-ops (a continued run clears the flag on the next continue()).
|
|
3073
|
-
*/
|
|
3074
|
-
finalizeTurn(spec: HarnessAgentLaunchSpec): Promise<void>;
|
|
3075
|
-
/** Reset per-run finalize guard when a run is continued (new Task). */
|
|
3076
|
-
private resetFinalize;
|
|
3077
|
-
/**
|
|
3078
|
-
* Emit developer-observable Worker runtime diagnostics (never model-visible):
|
|
3079
|
-
* template, resolved tools, capabilities, bindings, workspace resolution.
|
|
3080
|
-
*/
|
|
3081
|
-
private emitWorkerDiagnostics;
|
|
3082
|
-
/**
|
|
3083
|
-
* On circuit breaker trip: deliver a deterministic task.failed so the Task
|
|
3084
|
-
* moves to failed with an actionable reason instead of looping.
|
|
3085
|
-
*/
|
|
3086
|
-
private emitContractTrip;
|
|
3087
|
-
/**
|
|
3088
|
-
* Spawn path: deliver the TaskContextBundle, then kick the Worker turn
|
|
3089
|
-
* WITHOUT blocking until completion (async lifecycle). The model turn runs
|
|
3090
|
-
* in the background; completion/failure arrives via PTAP events.
|
|
3091
|
-
*/
|
|
3092
|
-
private kickAndDeliver;
|
|
3093
|
-
private deliverAndRun;
|
|
3094
|
-
private sessionInput;
|
|
3095
|
-
private getBinding;
|
|
3096
|
-
private inspectBound;
|
|
3097
|
-
private missing;
|
|
3098
|
-
private failFrom;
|
|
3099
|
-
private emit;
|
|
3100
|
-
}
|
|
3101
|
-
//#endregion
|
|
3102
|
-
//#region src/harness/session-binding-store.d.ts
|
|
3103
|
-
declare class FileHarnessSessionBindingStore implements HarnessSessionBindingStore {
|
|
3104
|
-
readonly filePath: string;
|
|
3105
|
-
constructor(engagementDir: string);
|
|
3106
|
-
get(agentRunId: AgentRunId): Promise<HarnessSessionBinding | undefined>;
|
|
3107
|
-
list(): Promise<readonly HarnessSessionBinding[]>;
|
|
3108
|
-
bind(binding: HarnessSessionBinding): Promise<void>;
|
|
3109
|
-
remove(agentRunId: AgentRunId): Promise<void>;
|
|
3110
|
-
private readAll;
|
|
3111
|
-
private writeAll;
|
|
3112
|
-
}
|
|
3113
|
-
//#endregion
|
|
3114
|
-
//#region src/harness/native-client.d.ts
|
|
3115
|
-
interface NativeAgent {
|
|
3116
|
-
readonly id: string;
|
|
3117
|
-
readonly status: 'idle' | 'running';
|
|
3118
|
-
readonly options?: {
|
|
3119
|
-
readonly model?: string;
|
|
3120
|
-
readonly provider?: string;
|
|
3121
|
-
};
|
|
3122
|
-
readonly ctx: Context;
|
|
3123
|
-
followup(message: NativeUserMessage): void;
|
|
3124
|
-
inject(message: NativeUserMessage): void;
|
|
3125
|
-
steer(message: NativeUserMessage): void;
|
|
3126
|
-
cancel(cause: {
|
|
3127
|
-
kind: string;
|
|
3128
|
-
reason?: string;
|
|
3129
|
-
}): void;
|
|
3130
|
-
whenIdle(): Promise<void>;
|
|
3131
|
-
}
|
|
3132
|
-
interface NativeAgentHandle {
|
|
3133
|
-
readonly agent: NativeAgent;
|
|
3134
|
-
dispose(): Promise<void>;
|
|
3135
|
-
}
|
|
3136
|
-
interface NativeAgentRegistry {
|
|
3137
|
-
create(input: {
|
|
3138
|
-
sessionId: string;
|
|
3139
|
-
agentOptions?: {
|
|
3140
|
-
model?: string;
|
|
3141
|
-
provider?: string;
|
|
3142
|
-
};
|
|
3143
|
-
meta?: {
|
|
3144
|
-
cwd?: string;
|
|
3145
|
-
parentSession?: string;
|
|
3146
|
-
seedLength?: number;
|
|
3147
|
-
origin?: 'subagent';
|
|
3148
|
-
delegationDepth?: number;
|
|
3149
|
-
agentPreset?: string;
|
|
3150
|
-
};
|
|
3151
|
-
setup?: (agentCtx: Context) => void | Promise<void>;
|
|
3152
|
-
}): Promise<NativeAgentHandle>;
|
|
3153
|
-
resume(input: {
|
|
3154
|
-
resumeSessionId: string;
|
|
3155
|
-
agentOptions?: {
|
|
3156
|
-
model?: string;
|
|
3157
|
-
provider?: string;
|
|
3158
|
-
};
|
|
3159
|
-
setup?: (agentCtx: Context) => void | Promise<void>;
|
|
3160
|
-
}): Promise<NativeAgentHandle>;
|
|
3161
|
-
get(sessionId: string): NativeAgent | undefined;
|
|
3162
|
-
}
|
|
3163
|
-
interface NativeSessionPersistence {
|
|
3164
|
-
list(): Promise<readonly {
|
|
3165
|
-
readonly id: string;
|
|
3166
|
-
}[]>;
|
|
3167
|
-
}
|
|
3168
|
-
interface NativeHarnessContext extends Context {
|
|
3169
|
-
readonly agents: NativeAgentRegistry;
|
|
3170
|
-
readonly sessionPersistence?: NativeSessionPersistence;
|
|
3171
|
-
}
|
|
3172
|
-
interface NativeUserMessage {
|
|
3173
|
-
readonly id: string;
|
|
3174
|
-
readonly role: 'user';
|
|
3175
|
-
readonly content: readonly [{
|
|
3176
|
-
readonly type: 'text';
|
|
3177
|
-
readonly text: string;
|
|
3178
|
-
}];
|
|
3179
|
-
readonly source: {
|
|
3180
|
-
readonly kind: 'plugin';
|
|
3181
|
-
readonly plugin: 'dsh-pentester';
|
|
3182
|
-
};
|
|
3183
|
-
}
|
|
3184
|
-
//#endregion
|
|
3185
|
-
//#region src/runtime/composition.d.ts
|
|
3186
|
-
interface ComposeOptions {
|
|
3187
|
-
readonly config?: unknown;
|
|
3188
|
-
readonly engagementDir?: string;
|
|
3189
|
-
readonly create?: {
|
|
3190
|
-
readonly objectives: string;
|
|
3191
|
-
readonly scopeSummary: string;
|
|
3192
|
-
readonly targets: readonly {
|
|
3193
|
-
readonly value: string;
|
|
3194
|
-
}[];
|
|
3195
|
-
readonly parentDir?: string;
|
|
3196
|
-
};
|
|
3197
|
-
readonly harnessClient?: HarnessClient;
|
|
3198
|
-
readonly nativeCtx?: NativeHarnessContext;
|
|
3199
|
-
readonly recover?: boolean;
|
|
3200
|
-
/**
|
|
3201
|
-
* Trusted DSH project working directory, bind-mounted to `/workspace` in
|
|
3202
|
-
* every Toolbox container. Comes from the Host session header cwd — never
|
|
3203
|
-
* from the model.
|
|
3204
|
-
*/
|
|
3205
|
-
readonly workspacePath?: string;
|
|
3206
|
-
/** Async Effective Global Config source (Stage policies + Agent entities). */
|
|
3207
|
-
readonly globalConfig?: () => Promise<EffectivePentesterConfig>;
|
|
3208
|
-
}
|
|
3209
|
-
declare class PentesterComposition {
|
|
3210
|
-
readonly config: RuntimeConfig;
|
|
3211
|
-
readonly store: EngagementStateStore;
|
|
3212
|
-
readonly ptes: DurablePtesCoreStore;
|
|
3213
|
-
readonly broker: ToolBroker;
|
|
3214
|
-
readonly controller: OrchestratorController;
|
|
3215
|
-
readonly engine: WorkflowEngine;
|
|
3216
|
-
readonly builder: ContextBuilder;
|
|
3217
|
-
readonly adapter: HarnessAdapter;
|
|
3218
|
-
readonly bindings: FileHarnessSessionBindingStore;
|
|
3219
|
-
readonly grants: DurableToolboxGrantStore;
|
|
3220
|
-
readonly templates: InMemoryAgentTemplateRegistry;
|
|
3221
|
-
readonly audit: InMemoryAuditSink;
|
|
3222
|
-
readonly outbound: InMemoryPtapOutbound;
|
|
3223
|
-
orchestratorSessions: Record<string, EngagementId>;
|
|
3224
|
-
readonly docker: DockerToolExecutor;
|
|
3225
|
-
readonly mcp: McpToolExecutor;
|
|
3226
|
-
readonly clientKind: 'native' | 'unavailable' | 'injected';
|
|
3227
|
-
/** P0-A durable ParentWakeupOutbox (same commit window as terminal state). */
|
|
3228
|
-
readonly wakeupOutbox: ParentWakeupOutbox;
|
|
3229
|
-
/** P0-A ParentWakeupDispatcher (inbox injection + parent continuation). */
|
|
3230
|
-
readonly wakeupDispatcher: ParentWakeupDispatcher;
|
|
3231
|
-
private readonly client;
|
|
3232
|
-
private bindingCache;
|
|
3233
|
-
private rootSession?;
|
|
3234
|
-
private constructor();
|
|
3235
|
-
static open(options?: ComposeOptions): Promise<PentesterComposition>;
|
|
3236
|
-
bindOrchestratorSession(sessionId: string, cwd?: string): void;
|
|
3237
|
-
/**
|
|
3238
|
-
* Rebuild the runtime template registry when the Global config changes.
|
|
3239
|
-
* Running AgentRuns keep their immutable snapshot; only FUTURE create_task
|
|
3240
|
-
* decisions / context assembly see the new Effective config.
|
|
3241
|
-
*/
|
|
3242
|
-
refreshGlobalConfig(next: Promise<EffectivePentesterConfig>): void;
|
|
3243
|
-
/**
|
|
3244
|
-
* P0-1: detach an archived Root Orchestrator session from this Engagement.
|
|
3245
|
-
* Removes it from the orchestrator-sessions map; clears the root session
|
|
3246
|
-
* reference when it was the current root.
|
|
3247
|
-
*/
|
|
3248
|
-
detachOrchestratorSession(sessionId: string): void;
|
|
3249
|
-
/** The trusted Root Orchestrator session that owns this Engagement. */
|
|
3250
|
-
rootOrchestratorSession(): {
|
|
3251
|
-
readonly sessionId: string;
|
|
3252
|
-
readonly cwd?: string;
|
|
3253
|
-
} | undefined;
|
|
3254
|
-
loadModel(): CanonicalReadModel;
|
|
3255
|
-
/** agentRunId → has the Worker emitted any runtime activity yet (P1-9). */
|
|
3256
|
-
private workerActivitySnapshot;
|
|
3257
|
-
/** Host-enforced Environment Readiness Gate state (published to projection). */
|
|
3258
|
-
private environmentState;
|
|
3259
|
-
setEnvironmentState(state: EnvironmentProjection): void;
|
|
3260
|
-
refreshBindings(): Promise<void>;
|
|
3261
|
-
handleWorkerPtap(spec: HarnessAgentLaunchSpec, name: string, args: Record<string, unknown>): Promise<void>;
|
|
3262
|
-
/**
|
|
3263
|
-
* P0-A Worker Finalizer entry: a Worker's turn/end settled while its Task is
|
|
3264
|
-
* still non-terminal. Marks the Task failed deterministically
|
|
3265
|
-
* (WORKER_TERMINATED_WITHOUT_TASK_TERMINAL) and wakes the parent — a plain
|
|
3266
|
-
* DSH turn/end NEVER equals completion. Idempotent at the store level (a
|
|
3267
|
-
* Task already terminal is a no-op).
|
|
3268
|
-
*/
|
|
3269
|
-
finalizeWorkerTurn(spec: HarnessAgentLaunchSpec): Promise<void>;
|
|
3270
|
-
/**
|
|
3271
|
-
* P0-A terminal handler: every canonical task.completed/blocked/failed
|
|
3272
|
-
* creates the durable ParentWakeupRecord (same commit window as the store
|
|
3273
|
-
* transition) and dispatches it. `childSessionId` / `parentSessionId` are
|
|
3274
|
-
* resolved from the worker binding (the durable session→run mapping).
|
|
3275
|
-
*/
|
|
3276
|
-
handleTaskTerminal(info: TaskTerminalInfo): Promise<void>;
|
|
3277
|
-
/**
|
|
3278
|
-
* Install the real ParentWakeupDispatcher deps (host-owned session map +
|
|
3279
|
-
* native agent continuation). Called by the plugin host after the session
|
|
3280
|
-
* environment is live. Also re-dispatches any pending records from a crash.
|
|
3281
|
-
*/
|
|
3282
|
-
installWakeupDeps(deps: ParentWakeupDispatcherDeps): void;
|
|
3283
|
-
/** P0-A startup recovery: re-dispatch pending wakeup records. */
|
|
3284
|
-
recoverPendingWakeups(): Promise<number>;
|
|
3285
|
-
/** Durable outbox records (diagnostics / tests). */
|
|
3286
|
-
wakeupRecords(): readonly ParentWakeupRecord[];
|
|
3287
|
-
decide(raw: unknown): Promise<OrchestratorDecisionResult>;
|
|
3288
|
-
command(sessionId: string, command: PentesterCommand): Promise<PentesterCommandResult>;
|
|
3289
|
-
invokeBroker(request: Omit<ToolCallRequest, 'engagementId' | 'taskId' | 'agentRunId'> & {
|
|
3290
|
-
readonly taskId?: ToolCallRequest['taskId'];
|
|
3291
|
-
readonly agentRunId?: ToolCallRequest['agentRunId'];
|
|
3292
|
-
}): Promise<ToolExecuteResult>;
|
|
3293
|
-
brokerToolId(name: string): ToolId | undefined;
|
|
3294
|
-
buildReportDraft(draft: unknown): Promise<ReportBuildResult>;
|
|
3295
|
-
overview(): PentesterProjection;
|
|
3296
|
-
/**
|
|
3297
|
-
* P0-2/P0-B execution round-trip smoke: run `printf dsh-pentester-preflight-ok`
|
|
3298
|
-
* through the SAME production chain the Worker uses (resolver → factory
|
|
3299
|
-
* container → exec → result adapter → lossless JSON). No target traffic —
|
|
3300
|
-
* the command is inert.
|
|
3301
|
-
*
|
|
3302
|
-
* P0-B: the smoke uses DISPOSABLE execution — a transient container is
|
|
3303
|
-
* created, the smoke runs, and it is ALWAYS removed (PASS or FAIL). It never
|
|
3304
|
-
* creates a persistent engagement container. Persistent containers are
|
|
3305
|
-
* created ONLY by ensureEngagementContainer (via docker.execute).
|
|
3306
|
-
*/
|
|
3307
|
-
runExecutionSmoke(): Promise<ExecutionSmokeResult>;
|
|
3308
|
-
engagementId(): EngagementId;
|
|
3309
|
-
readEvidenceBytes(evidenceId: EvidenceId): Promise<{
|
|
3310
|
-
error: "not_found";
|
|
3311
|
-
record?: undefined;
|
|
3312
|
-
bytes?: undefined;
|
|
3313
|
-
} | {
|
|
3314
|
-
record: EvidenceRecord;
|
|
3315
|
-
bytes: Uint8Array<ArrayBufferLike>;
|
|
3316
|
-
error?: undefined;
|
|
3317
|
-
}>;
|
|
3318
|
-
workerSpec(): HarnessAgentLaunchSpec;
|
|
3319
|
-
}
|
|
3320
|
-
//#endregion
|
|
3321
|
-
//#region src/runtime/register-dsh-tools.d.ts
|
|
3322
|
-
interface DshToolsService {
|
|
3323
|
-
register(definition: {
|
|
3324
|
-
name: string;
|
|
3325
|
-
description: string;
|
|
3326
|
-
parameters?: Record<string, unknown>;
|
|
3327
|
-
output?: {
|
|
3328
|
-
schema: unknown;
|
|
3329
|
-
render?: (args: unknown, value: unknown) => unknown;
|
|
3330
|
-
};
|
|
3331
|
-
execute: (args: Record<string, unknown>, exec?: unknown) => Promise<unknown> | unknown;
|
|
3332
|
-
}): unknown;
|
|
3333
|
-
}
|
|
3334
|
-
interface RegisteredToolCall {
|
|
3335
|
-
readonly name: string;
|
|
3336
|
-
readonly args: Record<string, unknown>;
|
|
3337
|
-
readonly exec?: unknown;
|
|
3338
|
-
}
|
|
3339
|
-
//#endregion
|
|
3340
|
-
//#region src/runtime/workspace.d.ts
|
|
3341
|
-
/**
|
|
3342
|
-
* Trusted Host-side Workspace identity. The model can never override it:
|
|
3343
|
-
* it is derived from the session's durable `cwd` (Host-written SessionHeader),
|
|
3344
|
-
* canonicalized through realpath, and hashed so the raw absolute path never
|
|
3345
|
-
* leaks into model-visible output.
|
|
3346
|
-
*
|
|
3347
|
-
* `workspaceKey` is stable across Host restarts and symlink aliases (realpath
|
|
3348
|
-
* canonicalizes them). It is the discovery boundary key — NEVER an
|
|
3349
|
-
* authorization boundary for cross-Engagement data access.
|
|
3350
|
-
*/
|
|
3351
|
-
type WorkspaceKey = string;
|
|
3352
|
-
//#endregion
|
|
3353
|
-
//#region src/config/global-config-store.d.ts
|
|
3354
|
-
/**
|
|
3355
|
-
* Durable, atomic, versioned Global Pentester Configuration store.
|
|
3356
|
-
*
|
|
3357
|
-
* This is GLOBAL product configuration — never stored inside an Engagement's
|
|
3358
|
-
* state / PTES Core / session log. Path: `$DSH_HOME/pentester-config.json`
|
|
3359
|
-
* (default `~/.dsh/pentester-config.json`) via the standard DSH home.
|
|
3360
|
-
*/
|
|
3361
|
-
interface ConfigRevisionConflictError {
|
|
3362
|
-
readonly code: 'config_revision_conflict';
|
|
3363
|
-
readonly expectedRevision: number;
|
|
3364
|
-
readonly actualRevision: number;
|
|
3365
|
-
}
|
|
3366
|
-
declare function dshHome(env?: string | undefined): string;
|
|
3367
|
-
declare function globalConfigPath(home?: string): string;
|
|
3368
|
-
declare function emptyGlobalConfig(): PentesterGlobalConfigV1;
|
|
3369
|
-
declare class PentesterGlobalConfigStore {
|
|
3370
|
-
private readonly filePath;
|
|
3371
|
-
private cache;
|
|
3372
|
-
constructor(home?: string);
|
|
3373
|
-
load(): Promise<PentesterGlobalConfigV1>;
|
|
3374
|
-
save(config: PentesterGlobalConfigV1): Promise<void>;
|
|
3375
|
-
/** Optimistic-concurrency guarded mutation. */
|
|
3376
|
-
mutate(expectedRevision: number | undefined, fn: (config: PentesterGlobalConfigV1) => PentesterGlobalConfigV1): Promise<PentesterGlobalConfigV1>;
|
|
3377
|
-
}
|
|
3378
|
-
//#endregion
|
|
3379
|
-
//#region src/config/factory-defaults.d.ts
|
|
3380
|
-
/**
|
|
3381
|
-
* Factory Defaults — the version-controlled authoritative baseline for the
|
|
3382
|
-
* Global Pentester Configuration. Never edited by users; Global overrides
|
|
3383
|
-
* layer on top. Keep existing built-in IDs stable (tpl-recon etc.) so
|
|
3384
|
-
* persistence / tests / runtime bindings keep working.
|
|
3385
|
-
*/
|
|
3386
|
-
declare const FACTORY_GLOBAL_CONFIG_SCHEMA_VERSION: 1;
|
|
3387
|
-
declare const FACTORY_AGENT_TEMPLATES: readonly AgentConfigEntity[];
|
|
3388
|
-
declare const FACTORY_SKILLS: readonly SkillConfigEntity[];
|
|
3389
|
-
declare const FACTORY_MCP_SERVERS: readonly McpConfigEntity[];
|
|
3390
|
-
declare const FACTORY_TOOLBOXES: readonly ToolboxConfigEntity[];
|
|
3391
|
-
/** Default Stage → allowed Agent mappings (Factory). */
|
|
3392
|
-
declare const FACTORY_STAGE_POLICIES: readonly StageAgentPolicy[];
|
|
3393
|
-
declare const FACTORY_AGENT_IDS: readonly AgentTemplateId[];
|
|
3394
|
-
declare const FACTORY_TOOLBOX_IDS: readonly ToolboxId[];
|
|
3395
|
-
declare const FACTORY_MCP_IDS: readonly McpServerId[];
|
|
3396
|
-
declare const FACTORY_SKILL_IDS: readonly SkillId[];
|
|
3397
|
-
//#endregion
|
|
3398
|
-
//#region src/config/validation.d.ts
|
|
3399
|
-
/**
|
|
3400
|
-
* Validate the persisted Global config. Returns a list of typed problems; an
|
|
3401
|
-
* empty list means the config is structurally valid. Reporting must always
|
|
3402
|
-
* have at least one enabled, valid Agent (cannot be skipped).
|
|
3403
|
-
*/
|
|
3404
|
-
interface ConfigDiagnostic {
|
|
3405
|
-
readonly severity: 'error' | 'warning';
|
|
3406
|
-
readonly code: string;
|
|
3407
|
-
readonly message: string;
|
|
3408
|
-
readonly entityId?: string;
|
|
3409
|
-
}
|
|
3410
|
-
declare function validatePentesterGlobalConfig(config: PentesterGlobalConfigV1 | undefined, runtimeHints?: {
|
|
3411
|
-
readonly mcpAvailable?: Readonly<Record<string, boolean>>;
|
|
3412
|
-
}): readonly ConfigDiagnostic[];
|
|
3413
|
-
declare function effectiveAgentsByStage(effective: EffectivePentesterConfig, stageKind: string): readonly AgentConfigEntity[];
|
|
3414
|
-
//#endregion
|
|
3415
|
-
//#region src/config/service.d.ts
|
|
3416
|
-
/**
|
|
3417
|
-
* Typed Global Config service — the Host face the Settings UI and runtime call.
|
|
3418
|
-
* All mutations go through the store (optimistic concurrency + atomic write),
|
|
3419
|
-
* bump `revision` on the saved entity, and re-validate before persisting.
|
|
3420
|
-
*/
|
|
3421
|
-
type ConfigServiceResult<T> = {
|
|
3422
|
-
readonly ok: true;
|
|
3423
|
-
readonly value: T;
|
|
3424
|
-
} | {
|
|
3425
|
-
readonly ok: false;
|
|
3426
|
-
readonly error: string;
|
|
3427
|
-
readonly code?: string;
|
|
3428
|
-
};
|
|
3429
|
-
declare class PentesterConfigService {
|
|
3430
|
-
private readonly store;
|
|
3431
|
-
constructor(store: PentesterGlobalConfigStore);
|
|
3432
|
-
static open(home?: string): PentesterConfigService;
|
|
3433
|
-
getGlobalConfig(): Promise<PentesterGlobalConfigV1>;
|
|
3434
|
-
getEffective(): Promise<EffectivePentesterConfig>;
|
|
3435
|
-
diagnostics(): Promise<readonly ConfigDiagnostic[]>;
|
|
3436
|
-
saveAgent(entity: Omit<AgentConfigEntity, 'revision' | 'source'> & {
|
|
3437
|
-
readonly source?: 'builtin' | 'custom';
|
|
3438
|
-
readonly id: AgentTemplateId;
|
|
3439
|
-
}, expectedRevision: number | undefined): Promise<ConfigServiceResult<{
|
|
3440
|
-
revision: number;
|
|
3441
|
-
globalRevision: number;
|
|
3442
|
-
}>>;
|
|
3443
|
-
resetAgent(id: AgentTemplateId, expectedRevision: number | undefined): Promise<ConfigServiceResult<{
|
|
3444
|
-
globalRevision: number;
|
|
3445
|
-
}>>;
|
|
3446
|
-
disableAgent(id: AgentTemplateId, expectedRevision: number | undefined): Promise<ConfigServiceResult<{
|
|
3447
|
-
globalRevision: number;
|
|
3448
|
-
}>>;
|
|
3449
|
-
deleteAgent(id: AgentTemplateId, expectedRevision: number | undefined): Promise<ConfigServiceResult<{
|
|
3450
|
-
globalRevision: number;
|
|
3451
|
-
}>>;
|
|
3452
|
-
/** Clone a built-in or custom Agent into a new custom entity (revision 1). */
|
|
3453
|
-
duplicateAgent(id: AgentTemplateId, name: string, expectedRevision: number | undefined): Promise<ConfigServiceResult<{
|
|
3454
|
-
id: AgentTemplateId;
|
|
3455
|
-
revision: number;
|
|
3456
|
-
globalRevision: number;
|
|
3457
|
-
}>>;
|
|
3458
|
-
saveStagePolicy(stageKind: PtesStageKind, allowedAgentTemplateIds: readonly AgentTemplateId[], expectedRevision: number | undefined): Promise<ConfigServiceResult<{
|
|
3459
|
-
globalRevision: number;
|
|
3460
|
-
}>>;
|
|
3461
|
-
resetStagePolicy(stageKind: PtesStageKind, expectedRevision: number | undefined): Promise<ConfigServiceResult<{
|
|
3462
|
-
globalRevision: number;
|
|
3463
|
-
}>>;
|
|
3464
|
-
restoreAllStageDefaults(expectedRevision: number | undefined): Promise<ConfigServiceResult<{
|
|
3465
|
-
globalRevision: number;
|
|
3466
|
-
}>>;
|
|
3467
|
-
saveSkill(entity: Omit<SkillConfigEntity, 'revision' | 'source'> & {
|
|
3468
|
-
readonly source?: 'builtin' | 'custom';
|
|
3469
|
-
readonly id: SkillId;
|
|
3470
|
-
}, expectedRevision: number | undefined): Promise<ConfigServiceResult<{
|
|
3471
|
-
revision: number;
|
|
3472
|
-
globalRevision: number;
|
|
3473
|
-
}>>;
|
|
3474
|
-
duplicateSkill(id: SkillId, name: string, expectedRevision: number | undefined): Promise<ConfigServiceResult<{
|
|
3475
|
-
id: SkillId;
|
|
3476
|
-
revision: number;
|
|
3477
|
-
globalRevision: number;
|
|
3478
|
-
}>>;
|
|
3479
|
-
resetSkill(id: SkillId, expectedRevision: number | undefined): Promise<ConfigServiceResult<{
|
|
3480
|
-
globalRevision: number;
|
|
3481
|
-
}>>;
|
|
3482
|
-
disableSkill(id: SkillId, expectedRevision: number | undefined): Promise<ConfigServiceResult<{
|
|
3483
|
-
globalRevision: number;
|
|
3484
|
-
}>>;
|
|
3485
|
-
deleteSkill(id: SkillId, expectedRevision: number | undefined): Promise<ConfigServiceResult<{
|
|
3486
|
-
globalRevision: number;
|
|
3487
|
-
}>>;
|
|
3488
|
-
saveMcp(entity: Omit<McpConfigEntity, 'revision' | 'source'> & {
|
|
3489
|
-
readonly source?: 'builtin' | 'custom';
|
|
3490
|
-
readonly id: McpServerId;
|
|
3491
|
-
}, expectedRevision: number | undefined): Promise<ConfigServiceResult<{
|
|
3492
|
-
revision: number;
|
|
3493
|
-
globalRevision: number;
|
|
3494
|
-
}>>;
|
|
3495
|
-
duplicateMcp(id: McpServerId, name: string, expectedRevision: number | undefined): Promise<ConfigServiceResult<{
|
|
3496
|
-
id: McpServerId;
|
|
3497
|
-
revision: number;
|
|
3498
|
-
globalRevision: number;
|
|
3499
|
-
}>>;
|
|
3500
|
-
resetMcp(id: McpServerId, expectedRevision: number | undefined): Promise<ConfigServiceResult<{
|
|
3501
|
-
globalRevision: number;
|
|
3502
|
-
}>>;
|
|
3503
|
-
disableMcp(id: McpServerId, expectedRevision: number | undefined): Promise<ConfigServiceResult<{
|
|
3504
|
-
globalRevision: number;
|
|
3505
|
-
}>>;
|
|
3506
|
-
deleteMcp(id: McpServerId, expectedRevision: number | undefined): Promise<ConfigServiceResult<{
|
|
3507
|
-
globalRevision: number;
|
|
3508
|
-
}>>;
|
|
3509
|
-
saveToolbox(entity: Omit<ToolboxConfigEntity, 'revision' | 'source'> & {
|
|
3510
|
-
readonly source?: 'builtin' | 'custom';
|
|
3511
|
-
readonly id: ToolboxId;
|
|
3512
|
-
}, expectedRevision: number | undefined): Promise<ConfigServiceResult<{
|
|
3513
|
-
revision: number;
|
|
3514
|
-
globalRevision: number;
|
|
3515
|
-
}>>;
|
|
3516
|
-
duplicateToolbox(id: ToolboxId, name: string, expectedRevision: number | undefined): Promise<ConfigServiceResult<{
|
|
3517
|
-
id: ToolboxId;
|
|
3518
|
-
revision: number;
|
|
3519
|
-
globalRevision: number;
|
|
3520
|
-
}>>;
|
|
3521
|
-
resetToolbox(id: ToolboxId, expectedRevision: number | undefined): Promise<ConfigServiceResult<{
|
|
3522
|
-
globalRevision: number;
|
|
3523
|
-
}>>;
|
|
3524
|
-
deleteToolbox(id: ToolboxId, expectedRevision: number | undefined): Promise<ConfigServiceResult<{
|
|
3525
|
-
globalRevision: number;
|
|
3526
|
-
}>>;
|
|
3527
|
-
/**
|
|
3528
|
-
* Restore Factory Defaults: clear built-in overrides + stage overrides.
|
|
3529
|
-
* Custom objects are deliberately KEPT (per plan §84 — never one button
|
|
3530
|
-
* deleting user MCP/Images).
|
|
3531
|
-
*/
|
|
3532
|
-
restoreFactoryDefaults(expectedRevision: number | undefined): Promise<ConfigServiceResult<{
|
|
3533
|
-
globalRevision: number;
|
|
3534
|
-
}>>;
|
|
3535
|
-
private mutate;
|
|
3536
|
-
}
|
|
3537
|
-
//#endregion
|
|
3538
|
-
//#region src/config/docker-image-service.d.ts
|
|
3539
|
-
type ImageRuntimeStatus = 'unknown' | 'available' | 'missing' | 'building' | 'pulling' | 'error';
|
|
3540
|
-
interface ImageRuntimeState {
|
|
3541
|
-
readonly status: ImageRuntimeStatus;
|
|
3542
|
-
readonly inspect?: DockerImageInspect;
|
|
3543
|
-
readonly message?: string;
|
|
3544
|
-
}
|
|
3545
|
-
/**
|
|
3546
|
-
* Docker Image provisioning service. Derived runtime state is NEVER persisted
|
|
3547
|
-
* as canonical config (plan §67) — availability comes from live Docker engine
|
|
3548
|
-
* inspect. Pull / Build are explicit user actions; AgentRun start never
|
|
3549
|
-
* auto-pulls or auto-builds (plan §22-§23): runtime fails closed with
|
|
3550
|
-
* `image_unavailable` and points the user to Settings provisioning.
|
|
3551
|
-
*/
|
|
3552
|
-
declare class DockerImageService {
|
|
3553
|
-
private readonly engine;
|
|
3554
|
-
constructor(engine: DockerEngineClient);
|
|
3555
|
-
inspect(toolbox: ToolboxConfigEntity): Promise<ImageRuntimeState>;
|
|
3556
|
-
pull(toolbox: ToolboxConfigEntity): Promise<ImageRuntimeState>;
|
|
3557
|
-
build(toolbox: ToolboxConfigEntity): Promise<ImageRuntimeState>;
|
|
3558
|
-
}
|
|
3559
|
-
//#endregion
|
|
3560
|
-
//#region src/harness/worker-monitor.d.ts
|
|
3561
|
-
interface WorkerRuntimeStats {
|
|
3562
|
-
readonly toolCalls: number;
|
|
3563
|
-
readonly successfulExecutionCalls: number;
|
|
3564
|
-
readonly validationFailures: number;
|
|
3565
|
-
readonly deniedCalls: number;
|
|
3566
|
-
readonly availableTools: readonly string[];
|
|
3567
|
-
}
|
|
3568
|
-
declare class WorkerRuntimeMonitor {
|
|
3569
|
-
/** Keyed by the Worker Session id (stable per worker, host-side). */
|
|
3570
|
-
private readonly byWorker;
|
|
3571
|
-
recordToolCall(sessionId: string, kind: 'success' | 'contract' | 'denied', availableTools: readonly string[]): boolean;
|
|
3572
|
-
snapshot(sessionId: string): WorkerRuntimeStats | undefined;
|
|
3573
|
-
reset(sessionId: string): void;
|
|
3574
|
-
}
|
|
3575
|
-
//#endregion
|
|
3576
|
-
//#region src/runtime/plugin-host.d.ts
|
|
3577
|
-
/**
|
|
3578
|
-
* Typed Pre-engagement intake produced by the Orchestrator from user
|
|
3579
|
-
* answers. Never the raw conversation text.
|
|
3580
|
-
*/
|
|
3581
|
-
interface EngagementBootstrapInput {
|
|
3582
|
-
readonly name?: string;
|
|
3583
|
-
readonly objectives: string;
|
|
3584
|
-
readonly scopeSummary: string;
|
|
3585
|
-
readonly targets: readonly {
|
|
3586
|
-
readonly value: string;
|
|
3587
|
-
}[];
|
|
3588
|
-
readonly rulesOfEngagement?: string;
|
|
3589
|
-
readonly credentialMode?: 'none' | 'provided' | 'collected';
|
|
3590
|
-
}
|
|
3591
|
-
interface EnsureEngagementResult {
|
|
3592
|
-
readonly engagementId: EngagementId;
|
|
3593
|
-
readonly created: boolean;
|
|
3594
|
-
}
|
|
3595
|
-
/** Lightweight candidate returned to the model for user selection (never business data). */
|
|
3596
|
-
interface EngagementCandidate {
|
|
3597
|
-
readonly engagementId: string;
|
|
3598
|
-
readonly displayName: string;
|
|
3599
|
-
readonly currentStageId: string | null;
|
|
3600
|
-
readonly workflowStatus: string;
|
|
3601
|
-
readonly targetSummary: readonly string[];
|
|
3602
|
-
readonly updatedAt?: string;
|
|
3603
|
-
}
|
|
3604
|
-
declare class PentesterPluginHost {
|
|
3605
|
-
readonly compositions: Map<EngagementId, PentesterComposition>;
|
|
3606
|
-
readonly ui: PentesterHostRuntime;
|
|
3607
|
-
readonly config: RuntimeConfig;
|
|
3608
|
-
readonly globalConfig: PentesterConfigService;
|
|
3609
|
-
readonly dockerImages: DockerImageService;
|
|
3610
|
-
/** Per-Worker stalled / no-execution detection. */
|
|
3611
|
-
readonly workerMonitor: WorkerRuntimeMonitor;
|
|
3612
|
-
/** Host-enforced Environment Readiness Gate (deterministic global preflight). */
|
|
3613
|
-
readonly environmentGate: PentesterEnvironmentGate;
|
|
3614
|
-
/** P0-6: deterministic runtime-contract failures (e.g. lossless-JSON) per Worker. */
|
|
3615
|
-
private readonly runtimeContractFailures;
|
|
3616
|
-
/** Test/embedding override: inject a fake engine + workspace to simulate a
|
|
3617
|
-
* ready environment (never used in production where the resolver runs). */
|
|
3618
|
-
private testEngineOverride;
|
|
3619
|
-
private testWorkspaceOverride;
|
|
3620
|
-
private nativeCtx;
|
|
3621
|
-
private harnessClient;
|
|
3622
|
-
private rootBindings;
|
|
3623
|
-
private workspaceRegistry;
|
|
3624
|
-
constructor(ui: PentesterHostRuntime, config: RuntimeConfig);
|
|
3625
|
-
/**
|
|
3626
|
-
* Global environment preflight for an activated session. Emits real
|
|
3627
|
-
* pentester/environment-preflight-* events into the session log so
|
|
3628
|
-
* session.jsonl proves the gate ran BEFORE any workflow tool.
|
|
3629
|
-
*/
|
|
3630
|
-
private runSessionPreflight;
|
|
3631
|
-
/** Append a session-log event (writes session.jsonl via HostSession.append). */
|
|
3632
|
-
private appendSessionEvent;
|
|
3633
|
-
/** Resolve the Effective Global Config (async; cached by the store). */
|
|
3634
|
-
resolveGlobalConfig(): Promise<EffectivePentesterConfig>;
|
|
3635
|
-
/** Resolve an effective Toolbox entity by id (for image ops). */
|
|
3636
|
-
resolveToolbox(id: string): Promise<ToolboxConfigEntity | undefined>;
|
|
3637
|
-
/** Global Config event: future create_task decisions + context refresh. */
|
|
3638
|
-
notifyConfigChanged(): Promise<void>;
|
|
3639
|
-
/**
|
|
3640
|
-
* Inject the CURRENT STAGE AGENT POLICY context into attached root sessions
|
|
3641
|
-
* (plan §37, §79). Triggered on: stage transition, config change, recovery.
|
|
3642
|
-
*/
|
|
3643
|
-
injectAvailableAgentsContext(effective?: EffectivePentesterConfig): Promise<void>;
|
|
3644
|
-
/** Lazily open the durable Root binding store (created on first need). */
|
|
3645
|
-
private bindings;
|
|
3646
|
-
/** Lazily open the Workspace discovery registry (CASE B global root). */
|
|
3647
|
-
private workspaces;
|
|
3648
|
-
setNativeContext(ctx: NativeHarnessContext): void;
|
|
3649
|
-
setHarnessClient(client: HarnessClient): void;
|
|
3650
|
-
recoverExisting(): Promise<readonly PentesterComposition[]>;
|
|
3651
|
-
/**
|
|
3652
|
-
* P0-B: scan Docker for dsh.pentester.managed=true containers. Active
|
|
3653
|
-
* Engagements keep their container (the executor rebinds on open); missing
|
|
3654
|
-
* or CLOSED Engagements' containers are stopped+removed. Legacy
|
|
3655
|
-
* 1-AgentRun=1-container leftovers are only cleaned when the Engagement
|
|
3656
|
-
* directory is known; uncertain ownership is reported, never deleted.
|
|
3657
|
-
*/
|
|
3658
|
-
private runStartupContainerGc;
|
|
3659
|
-
createEngagement(input: {
|
|
3660
|
-
readonly objectives: string;
|
|
3661
|
-
readonly scopeSummary: string;
|
|
3662
|
-
readonly targets: readonly {
|
|
3663
|
-
readonly value: string;
|
|
3664
|
-
}[];
|
|
3665
|
-
readonly workspacePath?: string;
|
|
3666
|
-
}): Promise<PentesterComposition>;
|
|
3667
|
-
private readonly bootstrapChain;
|
|
3668
|
-
private readonly lastCallerBySession;
|
|
3669
|
-
/**
|
|
3670
|
-
* Idempotent bootstrap: create a canonical Engagement for the given root
|
|
3671
|
-
* Orchestrator Session, bind it durably, and return the same Engagement on
|
|
3672
|
-
* retries / double submits. Concurrent calls for one Session serialize to a
|
|
3673
|
-
* single canonical Engagement.
|
|
3674
|
-
*/
|
|
3675
|
-
ensureEngagementForSession(input: {
|
|
3676
|
-
readonly sessionId: string;
|
|
3677
|
-
readonly intake: EngagementBootstrapInput;
|
|
3678
|
-
}): Promise<EnsureEngagementResult>;
|
|
3679
|
-
private ensureEngagementForSessionInner;
|
|
3680
|
-
/** Resolve a root Orchestrator Session to an Engagement (durable Root binding store first). */
|
|
3681
|
-
resolveEngagementForSession(sessionId: string): EngagementId | undefined;
|
|
3682
|
-
/** Cache the caller for the current session so async create can bind with the trusted workspace. */
|
|
3683
|
-
private lastCallerFor;
|
|
3684
|
-
private rootBindingFor;
|
|
3685
|
-
private rootBindingCache;
|
|
3686
|
-
private loadRootBindings;
|
|
3687
|
-
/**
|
|
3688
|
-
* Discover Engagements belonging to the caller's Workspace discovery
|
|
3689
|
-
* boundary. Lightweight candidates only — never business data. Archived
|
|
3690
|
-
* Engagements (P0-1) are excluded from the default candidate list.
|
|
3691
|
-
*/
|
|
3692
|
-
discoverCandidates(workspaceKey: WorkspaceKey): Promise<readonly EngagementCandidate[]>;
|
|
3693
|
-
attach(composition: PentesterComposition): void;
|
|
3694
|
-
/** Resolve the Root Orchestrator session id from a worker binding. */
|
|
3695
|
-
private rootSessionIdFor;
|
|
3696
|
-
registerCommands(ctx: HostContext): void;
|
|
3697
|
-
registerTools(tools: DshToolsService): readonly string[];
|
|
3698
|
-
executeRegisteredTool(call: RegisteredToolCall): Promise<unknown>;
|
|
3699
|
-
/**
|
|
3700
|
-
* P0-4: resolve the Worker's unresolved approval (if any) from the Broker's
|
|
3701
|
-
* pending list. A Worker with a pending approval is suspended — no further
|
|
3702
|
-
* tool calls dispatch, so at most one pending approval can exist per Worker.
|
|
3703
|
-
*/
|
|
3704
|
-
private suspendedApprovalFor;
|
|
3705
|
-
/**
|
|
3706
|
-
* P0-6: count a deterministic runtime-contract failure for a Worker. The
|
|
3707
|
-
* same signature (tool + code) reaching 2 trips the breaker — the model
|
|
3708
|
-
* cannot fix a host serialization bug by retrying. Returns true when tripped.
|
|
3709
|
-
*/
|
|
3710
|
-
private recordRuntimeContractFailure;
|
|
3711
|
-
/** Stop a Worker after repeated runtime-contract failures (host bug, not model retry). */
|
|
3712
|
-
private emitRuntimeContractStop;
|
|
3713
|
-
/**
|
|
3714
|
-
* P0-5/P0-A: true when the Worker's AgentRun is in `blocked` state. Terminal
|
|
3715
|
-
* PTAP calls (complete/fail/block) are exempt so the Task can settle.
|
|
3716
|
-
*/
|
|
3717
|
-
private workerRunBlocked;
|
|
3718
|
-
private recordWorkerActivity;
|
|
3719
|
-
/** True when the Worker is stalled (no progress, no execution, repeated failures). */
|
|
3720
|
-
private workerStalled;
|
|
3721
|
-
/** Emit a synthetic task.failed so a stalled Worker stops deterministically. */
|
|
3722
|
-
private emitWorkerStalled;
|
|
3723
|
-
/**
|
|
3724
|
-
* Resolve Broker tool arguments with host-side identity, never model ids.
|
|
3725
|
-
* container_exec: the model sends `{ argv }`; the host injects the Toolbox
|
|
3726
|
-
* from the Worker Template AND converts to the internal broker DTO
|
|
3727
|
-
* (`mode: argv`, `command`, `args`) so the Broker/docker backend sees a
|
|
3728
|
-
* fully host-resolved request.
|
|
3729
|
-
*/
|
|
3730
|
-
private resolveBrokerArguments;
|
|
3731
|
-
/**
|
|
3732
|
-
* Assemble and run the GLOBAL environment gate (host-enforced). READ-ONLY.
|
|
3733
|
-
* Success is cached with generation/timestamp; invalidate() re-checks after
|
|
3734
|
-
* Docker/runtime changes.
|
|
3735
|
-
*/
|
|
3736
|
-
private assertEnvironmentReady;
|
|
3737
|
-
/** P0-2 smoke runner installed by the host (runs the Broker chain). */
|
|
3738
|
-
private executionSmokeRunner;
|
|
3739
|
-
/**
|
|
3740
|
-
* Install the execution round-trip smoke runner. The host composes it over
|
|
3741
|
-
* the real Broker/Executor; it must resolve a container, exec the smoke
|
|
3742
|
-
* command, and serialize the result lossless-JSON safe.
|
|
3743
|
-
*/
|
|
3744
|
-
setExecutionSmokeRunner(runner: () => Promise<ExecutionSmokeResult>): void;
|
|
3745
|
-
/**
|
|
3746
|
-
* TEST-ONLY: inject an engine + workspace to simulate a ready environment.
|
|
3747
|
-
* Production never calls this — the resolver runs against the real Docker.
|
|
3748
|
-
*/
|
|
3749
|
-
setEnvironmentOverridesForTesting(input: {
|
|
3750
|
-
readonly engine?: DockerEngineClient;
|
|
3751
|
-
readonly workspacePath?: string;
|
|
3752
|
-
}): void;
|
|
3753
|
-
/** Resolve the trusted Root workspace path (host cwd) or the storage root. */
|
|
3754
|
-
private rootWorkspacePath;
|
|
3755
|
-
private dockerEngine;
|
|
3756
|
-
/** Publish the gate state into every composition's projection (UI). */
|
|
3757
|
-
private publishEnvironment;
|
|
3758
|
-
/** Typed blocked result for a failed global gate. */
|
|
3759
|
-
private environmentBlocked;
|
|
3760
|
-
/**
|
|
3761
|
-
* Template-specific preflight BEFORE create_task spawns a Worker. Any
|
|
3762
|
-
* failure ⇒ the Worker's model invocation count stays 0 (spawn never runs).
|
|
3763
|
-
* At this point the Task/Run do not exist yet, so binding/scope are already
|
|
3764
|
-
* guaranteed by the controller; here we verify the runtime contract
|
|
3765
|
-
* (manifest / required tools / factory image / workspace / commands).
|
|
3766
|
-
*/
|
|
3767
|
-
private assertTemplateReady;
|
|
3768
|
-
/**
|
|
3769
|
-
* After any canonical mutation (decision / PTAP / Broker), re-publish the
|
|
3770
|
-
* Engagement's projection bundle so the Panel (via official session
|
|
3771
|
-
* projections) refreshes without a page reload or manual sync.
|
|
3772
|
-
*/
|
|
3773
|
-
private afterCanonicalMutation;
|
|
3774
|
-
/** A session id is a worker when it resolves through a HarnessSessionBinding. */
|
|
3775
|
-
private isWorkerSessionId;
|
|
3776
|
-
private readonly rejectionFingerprints;
|
|
3777
|
-
/**
|
|
3778
|
-
* Deterministic anti-loop guard: the same decision shape rejected against the
|
|
3779
|
-
* same canonical state must not be retried indefinitely. After 3 consecutive
|
|
3780
|
-
* identical rejections the Orchestrator gets an explicit "repeated_rejection"
|
|
3781
|
-
* hint instead of a bare reason.
|
|
3782
|
-
*/
|
|
3783
|
-
private guardRepeatedRejection;
|
|
3784
|
-
/**
|
|
3785
|
-
* Resolve a Worker Session's own trusted context (session → AgentRun →
|
|
3786
|
-
* Task → Engagement) from the durable binding store. Returns undefined when
|
|
3787
|
-
* the Worker has no binding (infrastructure failure — never a bootstrap
|
|
3788
|
-
* prompt to the model).
|
|
3789
|
-
*/
|
|
3790
|
-
private resolveWorkerContext;
|
|
3791
|
-
private templateRoleOf;
|
|
3792
|
-
private templateOf;
|
|
3793
|
-
/** Execute a Worker PTAP tool against the caller's OWN binding. */
|
|
3794
|
-
private runWorkerPtap;
|
|
3795
|
-
private runEnsureEngagement;
|
|
3796
|
-
/** Mode 2 — attach: validate existence + workspace + no conflicting binding, then bind. */
|
|
3797
|
-
private attachEngagement;
|
|
3798
|
-
/** Mode 3 — create: intake → create canonical Engagement → register in Workspace → bind. */
|
|
3799
|
-
private createAndBind;
|
|
3800
|
-
private isEngagementValid;
|
|
3801
|
-
private engagementBindingInvalid;
|
|
3802
|
-
/** Trusted Workspace key from the Host-written SessionHeader cwd. */
|
|
3803
|
-
private workspaceKeyOf;
|
|
3804
|
-
/** Establish the durable Root binding + ui association for a session. */
|
|
3805
|
-
private bindRootSession;
|
|
3806
|
-
/**
|
|
3807
|
-
* P0-1: detach one Root Session from its Engagement (DSH Session archived).
|
|
3808
|
-
* Removes the durable Root binding, the in-memory cache, the UI
|
|
3809
|
-
* session→engagement association, and the composition's orchestrator
|
|
3810
|
-
* session entry. When the Engagement has no remaining un-archived Root
|
|
3811
|
-
* Session, it is marked `archived` (history retained, excluded from
|
|
3812
|
-
* bootstrap candidates). Child worker session bindings of the same root are
|
|
3813
|
-
* detached too (their parent is gone).
|
|
3814
|
-
*/
|
|
3815
|
-
detachSessionFromEngagement(sessionId: string): Promise<void>;
|
|
3816
|
-
/** P0-1: detach every archived Root Session (host calls after DSH archive). */
|
|
3817
|
-
detachArchivedSessions(archivedSessionIds: readonly string[]): Promise<void>;
|
|
3818
|
-
private engagementRequired;
|
|
3819
|
-
private resolveComposition;
|
|
3820
|
-
/**
|
|
3821
|
-
* A caller is the Root Orchestrator iff it is a trusted pentester-preset
|
|
3822
|
-
* root session (never a subagent child). Durable `orchestratorSessions`
|
|
3823
|
-
* binding is NOT required — that is exactly the fresh-bootstrap case.
|
|
3824
|
-
*/
|
|
3825
|
-
private isRootOrchestratorCaller;
|
|
3826
|
-
}
|
|
3827
|
-
//#endregion
|
|
3828
|
-
//#region src/config/effective-config.d.ts
|
|
3829
|
-
/**
|
|
3830
|
-
* EffectiveConfigResolver — the single authoritative resolver for the Global
|
|
3831
|
-
* Pentester Configuration. Runtime never reads Factory or the persisted config
|
|
3832
|
-
* directly; it resolves through this. Factory ⊕ Overrides ∖ Disabled.
|
|
3833
|
-
*/
|
|
3834
|
-
declare class EffectiveConfigResolver {
|
|
3835
|
-
static fromGlobal(config: PentesterGlobalConfigV1 | undefined): EffectivePentesterConfig;
|
|
3836
|
-
private readonly config;
|
|
3837
|
-
constructor(config: PentesterGlobalConfigV1 | undefined);
|
|
3838
|
-
resolve(): EffectivePentesterConfig;
|
|
3839
|
-
}
|
|
3840
|
-
//#endregion
|
|
3841
|
-
//#region src/config/runtime-catalog.d.ts
|
|
3842
|
-
/**
|
|
3843
|
-
* Convert effective Global-config entities into the existing runtime types
|
|
3844
|
-
* (ToolboxDefinition / McpServerDefinition). Runtime never reads Factory or
|
|
3845
|
-
* the persisted config directly; it resolves through EffectiveConfigResolver.
|
|
3846
|
-
*
|
|
3847
|
-
* ToolboxDefinition maps the user-facing "Docker Image" to the Tool Broker's
|
|
3848
|
-
* trusted image definition (plan §15-§18): id / displayName / image ref /
|
|
3849
|
-
* lifecycle, with provisioning derived from the image source.
|
|
3850
|
-
*/
|
|
3851
|
-
declare function toolboxDefinitionsFromEffective(effective: EffectivePentesterConfig): ToolboxDefinition[];
|
|
3852
|
-
declare function toolboxDefinitionFromConfig(toolbox: ToolboxConfigEntity): ToolboxDefinition | undefined;
|
|
3853
|
-
/** Resolve the primary execution image of an Agent (decision-friendly). */
|
|
3854
|
-
declare function primaryImageOfAgent(effective: EffectivePentesterConfig, agent: AgentConfigEntity): {
|
|
3855
|
-
readonly toolboxId: ToolboxId;
|
|
3856
|
-
readonly name: string;
|
|
3857
|
-
readonly ref: string;
|
|
3858
|
-
} | undefined;
|
|
3859
|
-
declare function mcpServersFromEffective(effective: EffectivePentesterConfig): McpServerDefinition[];
|
|
3860
|
-
declare function mcpServerDefinitionFromConfig(server: McpConfigEntity): McpServerDefinition | undefined;
|
|
3861
|
-
//#endregion
|
|
3862
|
-
//#region src/config/mcp-test.d.ts
|
|
3863
|
-
interface McpTestResult {
|
|
3864
|
-
readonly ok: boolean;
|
|
3865
|
-
readonly tools?: readonly string[];
|
|
3866
|
-
readonly message?: string;
|
|
3867
|
-
}
|
|
3868
|
-
/**
|
|
3869
|
-
* MCP Test Connection (plan §64): starts the real StdioMcpTransport server,
|
|
3870
|
-
* initialize + listTools, timeout, shutdown. NEVER calls a business tool and
|
|
3871
|
-
* never shows a raw stack trace to the user.
|
|
3872
|
-
*/
|
|
3873
|
-
declare function testMcpConnection(server: McpConfigEntity): Promise<McpTestResult>;
|
|
3874
|
-
//#endregion
|
|
3875
|
-
//#region src/config/orchestrator-context.d.ts
|
|
3876
|
-
/**
|
|
3877
|
-
* Render the decision-friendly AVAILABLE AGENTS context for the Root
|
|
3878
|
-
* Orchestrator (plan §37, §79). This is trusted_internal context — the model
|
|
3879
|
-
* sees only decision-friendly summaries (name / description / skills / MCP /
|
|
3880
|
-
* primary execution image), never MCP commands, Docker internals, or secrets.
|
|
3881
|
-
*/
|
|
3882
|
-
declare function renderAvailableAgentsContext(effective: EffectivePentesterConfig, stageKind: string): string;
|
|
3883
|
-
//#endregion
|
|
3884
|
-
//#region src/config/template-registry.d.ts
|
|
3885
|
-
/**
|
|
3886
|
-
* AgentTemplateRegistry backed by the Effective Pentester Config. Runtime
|
|
3887
|
-
* never reads Factory / persisted config directly; every template lookup
|
|
3888
|
-
* resolves through EffectiveConfigResolver → this registry. This replaces the
|
|
3889
|
-
* hardcoded built-in catalog lookup at the Controller / Context Builder /
|
|
3890
|
-
* HarnessAdapter seam (plan §76).
|
|
3891
|
-
*/
|
|
3892
|
-
declare class EffectiveConfigTemplateRegistry implements AgentTemplateRegistry {
|
|
3893
|
-
private effective;
|
|
3894
|
-
private readonly cache;
|
|
3895
|
-
constructor(effective: EffectivePentesterConfig);
|
|
3896
|
-
/** Swap to a newer EffectiveConfig (Global config revision changed). */
|
|
3897
|
-
refresh(effective: EffectivePentesterConfig): void;
|
|
3898
|
-
get(id: AgentTemplateId): AgentTemplate | undefined;
|
|
3899
|
-
entries(): IterableIterator<[AgentTemplateId, AgentTemplate]>;
|
|
3900
|
-
listEligibleForStage(stageKind: AgentTemplate['attachedStages'][number]): readonly AgentTemplate[];
|
|
3901
|
-
}
|
|
3902
|
-
//#endregion
|
|
3903
|
-
//#region src/config/runtime-bridge.d.ts
|
|
3904
|
-
/**
|
|
3905
|
-
* Bridge from the Global-config domain (AgentConfigEntity / EffectiveConfig)
|
|
3906
|
-
* to the existing runtime `AgentTemplate` type. This is the ONLY mapping —
|
|
3907
|
-
* runtime never reads Factory or persisted config directly; it resolves
|
|
3908
|
-
* through EffectiveConfigResolver and converts here.
|
|
3909
|
-
*
|
|
3910
|
-
* `attachedStages` is derived from the Factory Stage Policies (which stage
|
|
3911
|
-
* kinds may use this Agent), keeping the existing `isTemplateEligibleForStage`
|
|
3912
|
-
* seam working while the Controller enforces the policy allowlist.
|
|
3913
|
-
*/
|
|
3914
|
-
declare function agentTemplateFromEffective(effective: EffectivePentesterConfig, agent: AgentConfigEntity): AgentTemplate;
|
|
3915
|
-
/** Which PTES Stage kinds allow this Agent (Factory policies + overrides). */
|
|
3916
|
-
declare function stageKindsForAgent(effective: EffectivePentesterConfig, agentId: AgentTemplateId): readonly PtesStageKind[];
|
|
3917
|
-
/** Build the immutable AgentRun config snapshot from the effective Agent. */
|
|
3918
|
-
declare function snapshotFromEffectiveAgent(agent: AgentConfigEntity): AgentRunConfigSnapshot;
|
|
3919
|
-
/** Deterministic ordered prompt assembly: Base Worker + Agent instructions + Skills. */
|
|
3920
|
-
declare function assembleWorkerPrompt(agent: AgentConfigEntity, skills: Readonly<Record<SkillId, SkillConfigEntity>>): string;
|
|
3921
13
|
//#endregion
|
|
3922
14
|
//#region src/index.d.ts
|
|
3923
15
|
declare const name = "dsh-pentester";
|
|
3924
16
|
declare const inject: string[];
|
|
3925
17
|
interface Config {
|
|
3926
18
|
verbose: boolean;
|
|
3927
|
-
|
|
3928
|
-
|
|
3929
|
-
/** UI Preview: development-only sample data for inspecting the Pentester interface. Never written to canonical stores. */
|
|
3930
|
-
uiPreview: boolean;
|
|
3931
|
-
storageRoot?: string;
|
|
3932
|
-
dockerSocket?: string;
|
|
19
|
+
dockerHost?: string;
|
|
20
|
+
toolboxImages?: Record<string, string>;
|
|
3933
21
|
}
|
|
3934
22
|
declare const Config: Schema<Config>;
|
|
3935
23
|
declare function apply(ctx: Context, config: Config): Promise<void>;
|
|
24
|
+
declare const STAGE_PROFILES_FILE = "stage-profiles.json";
|
|
25
|
+
declare function writeStageProfilesManifest(presetDir: string, profiles: ReadonlyMap<string, AgentProfile>): Promise<void>;
|
|
26
|
+
declare function publishPentesterPreset(home?: string): Promise<string | undefined>;
|
|
3936
27
|
//#endregion
|
|
3937
|
-
export {
|
|
28
|
+
export { Config, STAGE_PROFILES_FILE, apply, inject, name, publishPentesterPreset, writeStageProfilesManifest };
|
|
3938
29
|
//# sourceMappingURL=index.d.ts.map
|