@xzzpig/pi-subagents 0.10.0 → 0.12.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/CHANGELOG.md CHANGED
@@ -1,5 +1,30 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.12.0] - 2026-09-11
4
+
5
+ ### Added
6
+
7
+ - **`permission-profile` agent frontmatter.** A custom agent can select a named `pi-permission-system` permission profile (global-only `profiles` registry) with `permission-profile: <name>` — a validated scalar selector, never an inline policy. The field is serialized, round-tripped through eject/settings overrides, and propagated through foreground/background/async/workflow launches, recovery descriptors, and status projections alongside the sandbox profile.
8
+ - **Transient profile channel.** When the field is set, the child receives the bare validated name via the transient `PI_SUBAGENT_PERMISSION_PROFILE` env var and `pi-subagents` injects the installed `pi-permission-system` extension into the child launch even under an explicit `extensions` allowlist, so the child's permission system applies the selected profile. Launch fails closed when the package is missing, a capability ceiling denies child extensions, or the runner is not a native Pi child (`external-cli`/`external-job` reject the field).
9
+
10
+ ## [0.11.0] - 2026-09-11
11
+
12
+ ### Added
13
+
14
+ - **Silent span marker for user-initiated dialogs (pi-notify protocol).**
15
+ The fleet inspector and the `/subagents admin` management dialogs emit the
16
+ literal `pi-notify:ui_span_silent` bus event (payload `{ reason: "fleet" |
17
+ "admin" }`) synchronously before opening their `ctx.ui.*` dialog, so the
18
+ pi-notify generic UI-prompt adapter produces no notification and no Herdr
19
+ wait entry for them. Emission is observational (bare try/catch) and uses the
20
+ literal event name with no dependency on the `@xzzpig/pi-notify` package, so
21
+ installs without pi-notify are unaffected. Both fleet open paths are wired
22
+ — the `/subagents-fleet` command and the fleet status widget — via the new
23
+ optional `FleetViewOptions.events` field; the subagent-executor agent-waiting
24
+ confirmations (worktree cleanup, authority confirmation) deliberately do not
25
+ emit the marker.
26
+
27
+
3
28
  ## [0.10.0] - 2026-09-10 (fork release)
4
29
 
5
30
  ### Added
package/docs/agents.md CHANGED
@@ -260,6 +260,7 @@ excludeTools: bash
260
260
  extensions:
261
261
  subagentOnlyExtensions: ./tools/child-only-search.ts
262
262
  sandbox: reviewer-strict
263
+ permission-profile: reviewer
263
264
  model: claude-haiku-4-5
264
265
  fallbackModels: openai-codex/gpt-5.6-luna:low, anthropic/claude-sonnet-4
265
266
  thinking: high
@@ -310,6 +311,7 @@ Field notes:
310
311
  | `extensions` | Omitted means a background child loads the parent's ambient extensions; empty means no ambient extensions; list values load exactly those extensions. Foreground children never load ambient extensions, so for them only listed values apply. |
311
312
  | `subagentOnlyExtensions` | Extension paths loaded only in this agent's child sessions. Tools registered there are unavailable to the main agent unless also installed through normal Pi extension configuration. |
312
313
  | `sandbox` | Optional named `pi-sandbox` profile for a native Pi child. It must be a non-empty safe name defined in the user's global `<agentDir>/sandbox.json`; it is a selector only, never an inline network or filesystem policy. |
314
+ | `permission-profile` | Optional named permission profile for a native Pi child. The name must be a non-empty safe identifier defined in the global `pi-permission-system` config's `profiles` registry; only the validated name is passed to the child. See below. |
313
315
  | `model` | Default model. Bare ids prefer the current provider when possible, then unique registry matches. |
314
316
  | `fallbackModels` | Ordered backup models for provider/model failures such as quota, auth, provider-reported timeout, or unavailable model. Expiration of the run-level `timeoutMs` / `maxRuntimeMs` deadline is terminal and does not trigger fallback. Ordinary task failures do not trigger fallback. |
315
317
  | `thinking` | Appended as a `:level` suffix at runtime unless a suffix is already present. |
@@ -377,6 +379,50 @@ or supervisor forwarding to ask the parent for an approval. See
377
379
  [`pi-sandbox`'s README](https://github.com/xzzpig/pi-extensions/tree/main/packages/pi-sandbox#named-profiles-for-subagents)
378
380
  for profile inheritance and merge rules.
379
381
 
382
+ ### Permission profiles
383
+
384
+ Use `permission-profile: <name>` to select a named policy profile from the
385
+ **global-only** `profiles` registry in `pi-permission-system`'s config
386
+ (`<agentDir>/extensions/pi-permission-system/config.json`). It is a selector
387
+ only — the actual rules (tool scalars, `bash`/`mcp`/`skill`/`external_directory`
388
+ pattern maps, `'*'` fallback) live in that registry and always resolve from the
389
+ child's own global config:
390
+
391
+ ```yaml
392
+ ---
393
+ name: reviewer
394
+ description: Review changes without write access
395
+ permission-profile: reviewer
396
+ ---
397
+ Review the requested change and report findings.
398
+ ```
399
+
400
+ `pi-subagents` validates the scalar name (same grammar as sandbox profiles),
401
+ passes only that name to the child via the transient
402
+ `PI_SUBAGENT_PERMISSION_PROFILE` environment variable, and injects the
403
+ installed `pi-permission-system` extension into the child launch even when
404
+ `extensions` is an explicit allowlist, so the child's permission system applies
405
+ the selected profile. The env channel carries a bare validated name — raw
406
+ policy is never transmitted — and the rules are always read from the child's
407
+ own global config, so the profile means the same policy regardless of which
408
+ host launches the agent. Selection precedence inside the permission system is
409
+ env > project agent file > global agent file.
410
+
411
+ The launch fails closed when a profile is declared but `pi-permission-system`
412
+ is not installed, when a capability ceiling denies child extensions, or when
413
+ the runner is not a native Pi child (the field is rejected for `external-cli`
414
+ and `external-job` runners). At runtime, selecting an unknown profile or an
415
+ empty ruleset clamps that agent's `allow` rules to `ask` with an explicit
416
+ `Permission profile '<name>' could not be resolved` diagnostic — it never
417
+ silently degrades to the unselected baseline. An agent without the field keeps
418
+ its pre-change behavior exactly.
419
+
420
+ The profile merges between the project config and the agent's own `permission:`
421
+ block: patterns the profile does not mention keep the lower scopes' rules
422
+ (global denies survive), and `permission:` overrides the profile per pattern.
423
+ A profile selected by a **project** agent file participates only when the host
424
+ marks that project trusted.
425
+
380
426
  ## Context injection
381
427
 
382
428
  By default the parent agent learns which agents exist only by calling `subagent({ action: "list" })`. Context injection pre-declares selected agents in the parent system prompt through a compact `<available_subagents>` block, so routing decisions can happen without a discovery round trip.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xzzpig/pi-subagents",
3
- "version": "0.10.0",
3
+ "version": "0.12.0",
4
4
  "description": "Pi extension for single-agent delegation and scripted multi-agent workflows",
5
5
  "author": "Nico Bailon",
6
6
  "license": "MIT",
@@ -42,6 +42,7 @@ import { capabilityCeilingAgentRestrictionSources, isAgentAllowedByCapabilityCei
42
42
  import { mergeRuntimeAgents, type RuntimeAgentOwner } from "./runtime-agent-registry.ts";
43
43
  import { listExternalJobProviders } from "../api/external-job-provider.ts";
44
44
  import { validateSandboxProfileName } from "../shared/sandbox-profile.ts";
45
+ import { validatePermissionProfileName } from "../shared/permission-profile.ts";
45
46
 
46
47
  export const AGENT_MANAGEMENT_API_VERSION = 1 as const;
47
48
 
@@ -114,7 +115,11 @@ function result(text: string, isError = false, details?: Partial<Details>): Agen
114
115
  }
115
116
 
116
117
  function jsonDetails<T>(value: T): T {
117
- return JSON.parse(JSON.stringify(value)) as T;
118
+ try {
119
+ return JSON.parse(JSON.stringify(value)) as T;
120
+ } catch (error) {
121
+ throw new Error(`Failed to serialize agent management details: ${error instanceof Error ? error.message : String(error)}`);
122
+ }
118
123
  }
119
124
 
120
125
  function presentDetails<T extends Record<string, unknown>>(value: T): T | undefined {
@@ -453,6 +458,7 @@ export function preservedAgentFrontmatterFields(agent: AgentConfig, cfg: Record<
453
458
  }
454
459
  if (hasKey(cfg, "toolBudget")) changed("toolBudget");
455
460
  if (hasKey(cfg, "sandbox")) changed("sandbox");
461
+ if (hasKey(cfg, "permissionProfile")) changed("permission-profile");
456
462
 
457
463
  return fields;
458
464
  }
@@ -692,6 +698,14 @@ function applyAgentConfig(target: AgentConfig, cfg: Record<string, unknown>): st
692
698
  return error instanceof Error ? error.message : String(error);
693
699
  }
694
700
  }
701
+ if (hasKey(cfg, "permissionProfile")) {
702
+ if (typeof cfg.permissionProfile !== "string") return "config.permissionProfile must be a non-empty permission profile name when provided.";
703
+ try {
704
+ target.permissionProfile = validatePermissionProfileName(cfg.permissionProfile, "config.permissionProfile");
705
+ } catch (error) {
706
+ return error instanceof Error ? error.message : String(error);
707
+ }
708
+ }
695
709
  if (target.runner?.type === "external-cli" || target.runner?.type === "external-job") {
696
710
  const unsupported = [
697
711
  target.tools?.length || target.mcpDirectTools?.length ? "tools" : undefined,
@@ -707,6 +721,7 @@ function applyAgentConfig(target: AgentConfig, cfg: Record<string, unknown>): st
707
721
  target.completionGuard !== undefined ? "completionGuard" : undefined,
708
722
  target.toolBudget ? "toolBudget" : undefined,
709
723
  target.sandbox ? "sandbox" : undefined,
724
+ target.permissionProfile ? "permissionProfile" : undefined,
710
725
  ].filter((field): field is string => Boolean(field));
711
726
  if (unsupported.length > 0) return `config.runner type '${target.runner.type}' does not support Pi-only fields: ${unsupported.join(", ")}.`;
712
727
  }
@@ -1008,6 +1023,7 @@ function formatAgentDetail(agent: AgentConfig): string {
1008
1023
  if (agent.completionGuard === false) lines.push("Completion guard: false");
1009
1024
  if (agent.toolBudget) lines.push(`Tool budget: ${JSON.stringify(agent.toolBudget)}`);
1010
1025
  if (agent.sandbox) lines.push(`Sandbox profile: ${agent.sandbox}`);
1026
+ if (agent.permissionProfile) lines.push(`Permission profile: ${agent.permissionProfile}`);
1011
1027
  if (agent.memory) lines.push(`Memory: ${agent.memory.scope} scope, path: ${agent.memory.path}`);
1012
1028
  if (agent.systemPrompt.trim()) lines.push("", "System Prompt:", agent.systemPrompt);
1013
1029
  return lines.join("\n");
@@ -1436,6 +1452,7 @@ function validateEjectedAgentLaunchPreflight(agent: AgentConfig, cwd: string): s
1436
1452
  requireReadTool: resolvedSkills.resolved.length > 0,
1437
1453
  agentName: agent.name,
1438
1454
  sandbox: agent.sandbox,
1455
+ permissionProfile: agent.permissionProfile,
1439
1456
  });
1440
1457
  } catch (error) {
1441
1458
  return error instanceof Error ? error.message : String(error);
@@ -41,6 +41,7 @@ export const KNOWN_FIELDS = new Set([
41
41
  "completionGuard",
42
42
  "toolBudget",
43
43
  "sandbox",
44
+ "permission-profile",
44
45
  "permission",
45
46
  "permissions",
46
47
  "memory",
@@ -147,6 +148,7 @@ export function serializeAgent(config: AgentConfig, options: SerializeAgentOptio
147
148
  lines.push(`toolBudget: ${config.toolBudget ? JSON.stringify(config.toolBudget) : ""}`);
148
149
  }
149
150
  if (config.sandbox) lines.push(`sandbox: ${config.sandbox}`);
151
+ if (config.permissionProfile || preserve("permission-profile")) lines.push(`permission-profile: ${config.permissionProfile ?? ""}`);
150
152
  if (config.permissions || preserve("permission", "permissions")) {
151
153
  const key = preserve("permission") && !preserve("permissions") ? "permission" : "permissions";
152
154
  lines.push(`${key}:`);
@@ -25,6 +25,7 @@ import { validateAcceptanceInput } from "../runs/shared/acceptance.ts";
25
25
  import { validatePermissionRules, type PermissionRules } from "../runs/shared/permissions.ts";
26
26
  import { parseThinkingLevel, type ThinkingLevel } from "../shared/thinking-ceiling.ts";
27
27
  import { validateSandboxProfileName } from "../shared/sandbox-profile.ts";
28
+ import { validatePermissionProfileName } from "../shared/permission-profile.ts";
28
29
 
29
30
  export type AgentScope = "user" | "project" | "both";
30
31
 
@@ -81,6 +82,7 @@ export interface BuiltinAgentOverrideBase {
81
82
  completionGuard?: boolean;
82
83
  toolBudget?: ToolBudgetConfig;
83
84
  sandbox?: string;
85
+ permissionProfile?: string;
84
86
  }
85
87
 
86
88
  interface BuiltinAgentOverrideConfig {
@@ -111,6 +113,7 @@ interface BuiltinAgentOverrideConfig {
111
113
  completionGuard?: boolean;
112
114
  toolBudget?: ToolBudgetConfig | false;
113
115
  sandbox?: string;
116
+ permissionProfile?: string;
114
117
  }
115
118
 
116
119
  interface BuiltinAgentOverrideInfo {
@@ -178,6 +181,7 @@ export interface AgentConfig {
178
181
  completionGuard?: boolean;
179
182
  toolBudget?: ToolBudgetConfig;
180
183
  sandbox?: string;
184
+ permissionProfile?: string;
181
185
  permissions?: PermissionRules;
182
186
  memory?: AgentMemoryConfig;
183
187
  disabled?: boolean;
@@ -793,6 +797,7 @@ function cloneOverrideBase(agent: AgentConfig): BuiltinAgentOverrideBase {
793
797
  ...(agent.completionGuard !== undefined ? { completionGuard: agent.completionGuard } : {}),
794
798
  ...(agent.toolBudget !== undefined ? { toolBudget: agent.toolBudget } : {}),
795
799
  ...(agent.sandbox !== undefined ? { sandbox: agent.sandbox } : {}),
800
+ ...(agent.permissionProfile !== undefined ? { permissionProfile: agent.permissionProfile } : {}),
796
801
  };
797
802
  }
798
803
 
@@ -827,6 +832,7 @@ function cloneOverrideValue(override: BuiltinAgentOverrideConfig): BuiltinAgentO
827
832
  ...(override.completionGuard !== undefined ? { completionGuard: override.completionGuard } : {}),
828
833
  ...(override.toolBudget !== undefined ? { toolBudget: override.toolBudget === false ? false : { ...override.toolBudget, ...(Array.isArray(override.toolBudget.block) ? { block: [...override.toolBudget.block] } : {}) } } : {}),
829
834
  ...(override.sandbox !== undefined ? { sandbox: override.sandbox } : {}),
835
+ ...(override.permissionProfile !== undefined ? { permissionProfile: override.permissionProfile } : {}),
830
836
  };
831
837
  }
832
838
 
@@ -1095,6 +1101,10 @@ function parseBuiltinOverrideEntry(
1095
1101
  override.sandbox = validateSandboxProfileName(input.sandbox, `Builtin override '${name}' in '${filePath}' sandbox`);
1096
1102
  }
1097
1103
 
1104
+ if ("permissionProfile" in input) {
1105
+ override.permissionProfile = validatePermissionProfileName(input.permissionProfile, `Builtin override '${name}' in '${filePath}' permission-profile`);
1106
+ }
1107
+
1098
1108
  if ("systemPrompt" in input) {
1099
1109
  if (typeof input.systemPrompt === "string") override.systemPrompt = input.systemPrompt;
1100
1110
  else throw new Error(`Builtin override '${name}' in '${filePath}' has invalid 'systemPrompt'; expected a string.`);
@@ -1442,6 +1452,7 @@ function applyBuiltinOverride(
1442
1452
  if (override.completionGuard !== undefined) next.completionGuard = override.completionGuard;
1443
1453
  if (override.toolBudget !== undefined) { if (override.toolBudget === false) delete next.toolBudget; else next.toolBudget = override.toolBudget; }
1444
1454
  if (override.sandbox !== undefined) next.sandbox = override.sandbox;
1455
+ if (override.permissionProfile !== undefined) next.permissionProfile = override.permissionProfile;
1445
1456
 
1446
1457
  return next;
1447
1458
  }
@@ -1543,7 +1554,7 @@ function applyCustomAgentOverrides(
1543
1554
 
1544
1555
  export function buildBuiltinOverrideConfig(
1545
1556
  base: BuiltinAgentOverrideBase,
1546
- draft: Pick<AgentConfig, "model" | "modelProvider" | "fallbackModels" | "fast" | "thinking" | "systemPromptMode" | "inheritProjectContext" | "inheritGlobalContext" | "inheritSkills" | "defaultContext" | "acceptanceRole" | "disabled" | "systemPrompt" | "skills" | "tools" | "allowNestedSubagents" | "mcpDirectTools" | "extensions" | "subagentOnlyExtensions" | "mutationTools" | "completionGuard" | "toolBudget" | "sandbox"> & Partial<Pick<AgentConfig, "description" | "output" | "outputMode" | "defaultReads" | "excludeTools">>,
1557
+ draft: Pick<AgentConfig, "model" | "modelProvider" | "fallbackModels" | "fast" | "thinking" | "systemPromptMode" | "inheritProjectContext" | "inheritGlobalContext" | "inheritSkills" | "defaultContext" | "acceptanceRole" | "disabled" | "systemPrompt" | "skills" | "tools" | "allowNestedSubagents" | "mcpDirectTools" | "extensions" | "subagentOnlyExtensions" | "mutationTools" | "completionGuard" | "toolBudget" | "sandbox" | "permissionProfile"> & Partial<Pick<AgentConfig, "description" | "output" | "outputMode" | "defaultReads" | "excludeTools">>,
1547
1558
  ): BuiltinAgentOverrideConfig | undefined {
1548
1559
  const override: BuiltinAgentOverrideConfig = {};
1549
1560
 
@@ -1584,6 +1595,7 @@ export function buildBuiltinOverrideConfig(
1584
1595
  }
1585
1596
  if (JSON.stringify(draft.toolBudget) !== JSON.stringify(base.toolBudget)) override.toolBudget = draft.toolBudget ?? false;
1586
1597
  if (draft.sandbox !== undefined && draft.sandbox !== base.sandbox) override.sandbox = draft.sandbox;
1598
+ if (draft.permissionProfile !== undefined && draft.permissionProfile !== base.permissionProfile) override.permissionProfile = draft.permissionProfile;
1587
1599
 
1588
1600
  return Object.keys(override).length > 0 ? override : undefined;
1589
1601
  }
@@ -1938,7 +1950,7 @@ function parseAgentRunnerFrontmatter(raw: string | undefined, agentName: string)
1938
1950
 
1939
1951
  function validateExternalRunnerProfile(frontmatter: Record<string, string>, agentName: string, runner: AgentRunnerConfig | undefined): void {
1940
1952
  if (runner?.type !== "external-cli" && runner?.type !== "external-job") return;
1941
- const unsupported = ["tools", "excludeTools", "allowNestedSubagents", "model", "fallbackModels", "thinking", "extensions", "subagentOnlyExtensions", "mutationTools", "maxSubagentDepth", "completionGuard", "skills", "skill", "skillPath", "toolBudget", "sandbox", "permission", "permissions"]
1953
+ const unsupported = ["tools", "excludeTools", "allowNestedSubagents", "model", "fallbackModels", "thinking", "extensions", "subagentOnlyExtensions", "mutationTools", "maxSubagentDepth", "completionGuard", "skills", "skill", "skillPath", "toolBudget", "sandbox", "permission-profile", "permission", "permissions"]
1942
1954
  .filter((field) => frontmatter[field] !== undefined);
1943
1955
  if (unsupported.length > 0) {
1944
1956
  throw new Error(`Agent '${agentName}' uses runner.type='${runner.type}' and declares unsupported Pi-only fields: ${unsupported.join(", ")}.`);
@@ -2109,6 +2121,9 @@ function loadAgentsFromDefinitionFiles(files: AgentDefinitionFile[], source: Age
2109
2121
  const sandbox = frontmatter.sandbox !== undefined
2110
2122
  ? validateSandboxProfileName(frontmatter.sandbox, `Agent '${localName}' sandbox`)
2111
2123
  : undefined;
2124
+ const permissionProfile = frontmatter["permission-profile"] !== undefined
2125
+ ? validatePermissionProfileName(frontmatter["permission-profile"], `Agent '${localName}' permission-profile`)
2126
+ : undefined;
2112
2127
  if (frontmatter.permission !== undefined && frontmatter.permissions !== undefined) {
2113
2128
  throw new Error(`Agent '${localName}' cannot declare both permission and permissions frontmatter.`);
2114
2129
  }
@@ -2181,6 +2196,7 @@ function loadAgentsFromDefinitionFiles(files: AgentDefinitionFile[], source: Age
2181
2196
  ...(completionGuard !== undefined ? { completionGuard } : {}),
2182
2197
  ...(toolBudget !== undefined ? { toolBudget } : {}),
2183
2198
  ...(sandbox !== undefined ? { sandbox } : {}),
2199
+ ...(permissionProfile !== undefined ? { permissionProfile } : {}),
2184
2200
  ...(permissions !== undefined ? { permissions } : {}),
2185
2201
  ...(memory !== undefined ? { memory } : {}),
2186
2202
  ...(Object.keys(extraFields).length > 0 ? { extraFields } : {}),
@@ -7,6 +7,7 @@ import { validateToolBudgetConfig } from "../runs/shared/tool-budget.ts";
7
7
  import { BUILTIN_AGENT_NAMES } from "./builtin-names.ts";
8
8
  import type { AgentConfig, AgentDefaultContext, AgentDiscoveryDiagnostic } from "./agents.ts";
9
9
  import { validateSandboxProfileName } from "../shared/sandbox-profile.ts";
10
+ import { validatePermissionProfileName } from "../shared/permission-profile.ts";
10
11
 
11
12
  export const RUNTIME_AGENT_REGISTRY_KEY = "pi-subagents.runtime-agents.v1";
12
13
 
@@ -53,6 +54,7 @@ export interface RuntimeAgentDefinition {
53
54
  completionGuard?: boolean;
54
55
  toolBudget?: ToolBudgetConfig;
55
56
  sandbox?: string;
57
+ permissionProfile?: string;
56
58
  permissions?: PermissionRules;
57
59
  }
58
60
 
@@ -206,7 +208,7 @@ function validateDefinition(value: unknown): RuntimeAgentDefinition {
206
208
  "systemPromptMode", "inheritProjectContext", "inheritGlobalContext", "inheritSkills", "defaultContext", "defaultAsync", "defaultTimeoutMs",
207
209
  "defaultToolTimeoutMs", "defaultAcceptance", "acceptanceRole", "runner", "skills", "skillPath",
208
210
  "extensions", "subagentOnlyExtensions", "mutationTools", "output", "outputMode", "defaultReads", "defaultProgress", "injectToContext", "interactive",
209
- "maxSubagentDepth", "completionGuard", "toolBudget", "sandbox", "permissions",
211
+ "maxSubagentDepth", "completionGuard", "toolBudget", "sandbox", "permissionProfile", "permissions",
210
212
  ]);
211
213
  const unknown = Object.keys(definition).filter((key) => !supported.has(key));
212
214
  if (unknown.length > 0) throw new Error(`Runtime agent definition has unknown fields: ${unknown.join(", ")}.`);
@@ -254,6 +256,12 @@ function validateDefinition(value: unknown): RuntimeAgentDefinition {
254
256
  if (sandbox && (runner?.type === "external-cli" || runner?.type === "external-job")) {
255
257
  throw new Error(`Runtime agent definition runner.type='${runner.type}' cannot use sandbox profiles because it does not run a native Pi child.`);
256
258
  }
259
+ const permissionProfile = definition.permissionProfile === undefined
260
+ ? undefined
261
+ : validatePermissionProfileName(definition.permissionProfile, "Runtime agent definition permissionProfile");
262
+ if (permissionProfile && (runner?.type === "external-cli" || runner?.type === "external-job")) {
263
+ throw new Error(`Runtime agent definition runner.type='${runner.type}' cannot use permission profiles because it does not run a native Pi child.`);
264
+ }
257
265
  const permissions = validatePermissionRules(definition.permissions, "Runtime agent definition permissions");
258
266
  return {
259
267
  description: validateString(definition.description, "Runtime agent definition description", MAX_DESCRIPTION_LENGTH),
@@ -292,6 +300,7 @@ function validateDefinition(value: unknown): RuntimeAgentDefinition {
292
300
  ...(completionGuard !== undefined ? { completionGuard } : {}),
293
301
  ...(toolBudget !== undefined ? { toolBudget } : {}),
294
302
  ...(sandbox !== undefined ? { sandbox } : {}),
303
+ ...(permissionProfile !== undefined ? { permissionProfile } : {}),
295
304
  ...(permissions !== undefined ? { permissions } : {}),
296
305
  };
297
306
  }
@@ -376,6 +385,7 @@ function toAgentConfig(name: string, definition: RuntimeAgentDefinition): AgentC
376
385
  ...(definition.completionGuard !== undefined ? { completionGuard: definition.completionGuard } : {}),
377
386
  ...(definition.toolBudget !== undefined ? { toolBudget: definition.toolBudget } : {}),
378
387
  ...(definition.sandbox !== undefined ? { sandbox: definition.sandbox } : {}),
388
+ ...(definition.permissionProfile !== undefined ? { permissionProfile: definition.permissionProfile } : {}),
379
389
  ...(definition.permissions !== undefined ? { permissions: definition.permissions } : {}),
380
390
  };
381
391
  assertNoIdentityCollisions([agent], `Runtime agent '${name}'`);
@@ -40,7 +40,8 @@ export type SubagentLaunchContractReasonCode =
40
40
  | "thinking_ceiling"
41
41
  | "invalid_extension_bindings"
42
42
  | "untrusted_project"
43
- | "sandbox_unavailable";
43
+ | "sandbox_unavailable"
44
+ | "permission_profile_unavailable";
44
45
 
45
46
  export type SubagentLaunchContractDiagnosticCode = SubagentLaunchContractReasonCode | "host_required" | "snapshot_warning" | "workspace_scope_authority";
46
47
 
@@ -294,14 +295,26 @@ export async function resolveSubagentLaunchContract(input: SubagentLaunchContrac
294
295
  const message = `Agent '${agent.name}' selects sandbox profile '${agent.sandbox}' from project scope, but the project is not trusted. Trust the project and retry.`;
295
296
  return { ok: false, code: "untrusted_project", message, diagnostics: [{ code: "untrusted_project", severity: "error", message }] };
296
297
  }
298
+ if (agent.permissionProfile && (agent.source === "project" || agent.override?.scope === "project") && input.projectTrusted !== true) {
299
+ const message = `Agent '${agent.name}' selects permission profile '${agent.permissionProfile}' from project scope, but the project is not trusted. Trust the project and retry.`;
300
+ return { ok: false, code: "untrusted_project", message, diagnostics: [{ code: "untrusted_project", severity: "error", message }] };
301
+ }
297
302
  if (agent.sandbox && (agent.source === "project" || agent.override?.scope === "project") && trustedProjectCwd !== effectiveCwd) {
298
303
  const message = `Agent '${agent.name}' selects sandbox profile '${agent.sandbox}' from project scope, but cwd '${effectiveCwd}' does not match trusted project cwd '${trustedProjectCwd}'. Launch from the trusted project cwd and retry.`;
299
304
  return { ok: false, code: "untrusted_project", message, diagnostics: [{ code: "untrusted_project", severity: "error", message }] };
300
305
  }
306
+ if (agent.permissionProfile && (agent.source === "project" || agent.override?.scope === "project") && trustedProjectCwd !== effectiveCwd) {
307
+ const message = `Agent '${agent.name}' selects permission profile '${agent.permissionProfile}' from project scope, but cwd '${effectiveCwd}' does not match trusted project cwd '${trustedProjectCwd}'. Launch from the trusted project cwd and retry.`;
308
+ return { ok: false, code: "untrusted_project", message, diagnostics: [{ code: "untrusted_project", severity: "error", message }] };
309
+ }
301
310
  if (agent.sandbox && (agent.runner?.type === "external-cli" || agent.runner?.type === "external-job")) {
302
311
  const message = `Agent '${agent.name}' requests sandbox profile '${agent.sandbox}', but runner.type='${agent.runner.type}' cannot load the native pi-sandbox extension.`;
303
312
  return { ok: false, code: "unsupported_mode", message, diagnostics: [{ code: "unsupported_mode", severity: "error", message }] };
304
313
  }
314
+ if (agent.permissionProfile && (agent.runner?.type === "external-cli" || agent.runner?.type === "external-job")) {
315
+ const message = `Agent '${agent.name}' requests permission profile '${agent.permissionProfile}', but runner.type='${agent.runner.type}' cannot load the native pi-permission-system extension.`;
316
+ return { ok: false, code: "unsupported_mode", message, diagnostics: [{ code: "unsupported_mode", severity: "error", message }] };
317
+ }
305
318
  let extensionBindings: ExtensionBindings | undefined;
306
319
  try {
307
320
  extensionBindings = normalizeExtensionBindings(input.extensionBindings)?.value;
@@ -397,10 +410,11 @@ export async function resolveSubagentLaunchContract(input: SubagentLaunchContrac
397
410
  agentName: agent.name,
398
411
  permissionRules,
399
412
  sandbox: agent.sandbox,
413
+ permissionProfile: agent.permissionProfile,
400
414
  });
401
415
  } catch (error) {
402
416
  const message = error instanceof Error ? error.message : String(error);
403
- const code: SubagentLaunchContractReasonCode = agent.sandbox ? "sandbox_unavailable" : "denied_required_tool";
417
+ const code: SubagentLaunchContractReasonCode = agent.sandbox ? "sandbox_unavailable" : agent.permissionProfile ? "permission_profile_unavailable" : "denied_required_tool";
404
418
  diagnostics.push({ code, severity: "error", message });
405
419
  return { ok: false, code, message, diagnostics };
406
420
  }
@@ -453,6 +467,7 @@ export async function resolveSubagentLaunchContract(input: SubagentLaunchContrac
453
467
  ...(resolveEffectiveThinking(model, effectiveThinkingConfig) ? { thinking: resolveEffectiveThinking(model, effectiveThinkingConfig) } : {}),
454
468
  ...(thinkingCeiling ? { thinkingCeiling } : {}),
455
469
  ...(agent.sandbox ? { sandbox: agent.sandbox } : {}),
470
+ ...(agent.permissionProfile ? { permissionProfile: agent.permissionProfile } : {}),
456
471
  systemPromptMode: agent.systemPromptMode,
457
472
  inheritProjectContext: agent.inheritProjectContext,
458
473
  inheritGlobalContext: agent.inheritGlobalContext,
@@ -515,6 +530,7 @@ export async function resolveSubagentLaunchContract(input: SubagentLaunchContrac
515
530
  inheritGlobalContext: agent.inheritGlobalContext,
516
531
  inheritSkills: agent.inheritSkills,
517
532
  sandbox: agent.sandbox,
533
+ permissionProfile: agent.permissionProfile,
518
534
  skills: requestedSkills,
519
535
  tools: toolPlan.effectiveToolAllowlist,
520
536
  ...(toolPlan.excludeTools.length > 0 ? { excludeTools: toolPlan.excludeTools } : {}),
@@ -31,7 +31,7 @@ import { isStaleExtensionContextError, withCachedUiContext } from "../shared/ext
31
31
  import { currentCompletionOwnerId } from "../shared/completion-owner.ts";
32
32
  import { cleanupOldChainDirs } from "../shared/settings.ts";
33
33
  import { clearLegacyResultAnimationTimer, renderSubagentResult, renderSubagentSummary } from "../tui/render.ts";
34
- import { openSubagentFleet } from "../tui/fleet.ts";
34
+ import { openSubagentFleetFromStatus } from "../tui/fleet.ts";
35
35
  import { SubagentFleetStatus, resolveFleetViewPlacement } from "../tui/fleet-status.ts";
36
36
  import { createSubagentParamsSchema } from "./schemas.ts";
37
37
  import { createSubagentExecutor, type SubagentParamsLike } from "../runs/foreground/subagent-executor.ts";
@@ -69,7 +69,7 @@ import { disposeChildSessions } from "../runs/shared/child-session.ts";
69
69
  import { resolveCurrentSubagentCapabilityCeiling } from "../runs/shared/capability-ceiling.ts";
70
70
  import { formatDuration, shortenPath } from "../shared/formatters.ts";
71
71
  import { applyModelExclusionsConfig, loadConfig, resolveAsyncByDefault, resolveScheduledStoreRoot } from "./config.ts";
72
- import { applyInjectionBlock, renderInjectionBlock, resolveInjectableAgents, SUBAGENT_INJECTION_MARKER } from "./context-injection.ts";
72
+ import { applyInjectionBlock, renderInjectionBlock, resolveInjectableAgents } from "./context-injection.ts";
73
73
  import { buildSubagentToolDescription, buildSubagentToolPromptMetadata } from "./tool-description.ts";
74
74
  import { formatWorkflowPreflightSummary, normalizeWorkflowPreflight } from "../workflows/workflow-preflight.ts";
75
75
  import { finalizeToolResult } from "./tool-result.ts";
@@ -499,7 +499,7 @@ export default function registerSubagentExtension(pi: ExtensionAPI): void {
499
499
  const ctx = withLastUiContext((current) => current);
500
500
  if (!ctx) return;
501
501
  try {
502
- await openSubagentFleet(ctx, state, { initialKey: itemKey, asyncDirRoot: DIRS.async, resultsDir: DIRS.results, fleetKeybindings: config.fleetKeybindings });
502
+ await openSubagentFleetFromStatus(ctx, state, pi, { itemKey, asyncDirRoot: DIRS.async, resultsDir: DIRS.results, fleetKeybindings: config.fleetKeybindings });
503
503
  } catch (error) {
504
504
  if (isStaleExtensionContextError(error)) {
505
505
  if (state.lastUiContext === ctx) state.lastUiContext = null;
@@ -613,6 +613,9 @@ export default function registerSubagentExtension(pi: ExtensionAPI): void {
613
613
  executorScheduled = executor.executeScheduled;
614
614
 
615
615
  pi.registerMessageRenderer<SupervisorRequestMessageDetails>(SUPERVISOR_REQUEST_MESSAGE_TYPE, renderSupervisorRequest);
616
+ // SAFETY: `registerEntryRenderer` is not part of the typed ExtensionAPI in the
617
+ // pinned dependency version; this cast pins the runtime shape of the entry
618
+ // renderer registration surface, guarded below by a typeof check.
616
619
  const registerEntryRenderer = (pi as unknown as {
617
620
  registerEntryRenderer?: (customType: string, renderer: (entry: { data?: unknown }, options: { expanded: boolean }, theme: ExtensionContext["ui"]["theme"]) => Component | undefined) => void;
618
621
  }).registerEntryRenderer;
@@ -16,6 +16,7 @@ import { normalizeWorktreeBaseRef } from "../shared/worktree.ts";
16
16
  import { intersectThinkingCeilings, parseThinkingLevel, type ThinkingLevel } from "../../shared/thinking-ceiling.ts";
17
17
  import { assertWorkflowGraphHostSteps } from "../shared/host-step-status.ts";
18
18
  import { validateSandboxProfileName } from "../../shared/sandbox-profile.ts";
19
+ import { validatePermissionProfileName } from "../../shared/permission-profile.ts";
19
20
 
20
21
  export interface AsyncResumeParams {
21
22
  id?: string;
@@ -57,6 +58,7 @@ export type AsyncResumeTarget = {
57
58
  capabilityCeiling?: ResolvedSubagentCapabilityCeiling;
58
59
  launchContractDigest?: string;
59
60
  sandbox?: string;
61
+ permissionProfile?: string;
60
62
  runner?: NonNullable<AsyncStatus["steps"]>[number]["runner"];
61
63
  externalJob?: NonNullable<AsyncStatus["steps"]>[number]["externalJob"];
62
64
  };
@@ -76,8 +78,9 @@ interface AsyncResultFile {
76
78
  thinking?: string;
77
79
  launchContractDigest?: string;
78
80
  sandbox?: string;
81
+ permissionProfile?: string;
79
82
  capabilityCeiling?: ResolvedSubagentCapabilityCeiling;
80
- results?: Array<{ agent?: string; sessionName?: string; success?: boolean; sessionFile?: string; intercomTarget?: string; model?: string; thinking?: string; launchContractDigest?: string; sandbox?: string; capabilityCeiling?: ResolvedSubagentCapabilityCeiling }>;
83
+ results?: Array<{ agent?: string; sessionName?: string; success?: boolean; sessionFile?: string; intercomTarget?: string; model?: string; thinking?: string; launchContractDigest?: string; sandbox?: string; permissionProfile?: string; capabilityCeiling?: ResolvedSubagentCapabilityCeiling }>;
81
84
  }
82
85
 
83
86
  export interface AsyncRunLocation {
@@ -122,10 +125,13 @@ function validateResultFile(value: unknown, resultPath: string): AsyncResultFile
122
125
  const sandbox = child.sandbox === undefined
123
126
  ? undefined
124
127
  : validateSandboxProfileName(child.sandbox, `async result file '${resultPath}' results[${index}].sandbox`);
128
+ const permissionProfile = child.permissionProfile === undefined
129
+ ? undefined
130
+ : validatePermissionProfileName(child.permissionProfile, `async result file '${resultPath}' results[${index}].permissionProfile`);
125
131
  const capabilityCeiling = child.capabilityCeiling === undefined ? undefined : parseSubagentCapabilityCeiling(child.capabilityCeiling, `async result file '${resultPath}' results[${index}].capabilityCeiling`);
126
132
  const success = child.success;
127
133
  if (success !== undefined && typeof success !== "boolean") throw new Error(`Invalid async result file '${resultPath}': results[${index}].success must be a boolean.`);
128
- return { agent, sessionName, sessionFile, intercomTarget, model, thinking, launchContractDigest, ...(sandbox ? { sandbox } : {}), ...(capabilityCeiling ? { capabilityCeiling } : {}), ...(typeof success === "boolean" ? { success } : {}) };
134
+ return { agent, sessionName, sessionFile, intercomTarget, model, thinking, launchContractDigest, ...(sandbox ? { sandbox } : {}), ...(permissionProfile ? { permissionProfile } : {}), ...(capabilityCeiling ? { capabilityCeiling } : {}), ...(typeof success === "boolean" ? { success } : {}) };
129
135
  });
130
136
  }
131
137
  const success = data.success;
@@ -143,6 +149,7 @@ function validateResultFile(value: unknown, resultPath: string): AsyncResultFile
143
149
  thinking: validateOptionalString(data, "thinking", resultPath),
144
150
  launchContractDigest: validateOptionalString(data, "launchContractDigest", resultPath),
145
151
  ...(data.sandbox === undefined ? {} : { sandbox: validateSandboxProfileName(data.sandbox, `async result file '${resultPath}' sandbox`) }),
152
+ ...(data.permissionProfile === undefined ? {} : { permissionProfile: validatePermissionProfileName(data.permissionProfile, `async result file '${resultPath}' permissionProfile`) }),
146
153
  ...(data.capabilityCeiling === undefined ? {} : { capabilityCeiling: parseSubagentCapabilityCeiling(data.capabilityCeiling, `async result file '${resultPath}' capabilityCeiling`) }),
147
154
  ...(typeof success === "boolean" ? { success } : {}),
148
155
  ...(results ? { results } : {}),
@@ -290,6 +297,7 @@ function validateStatusForResume(status: AsyncStatus | null, source: string): vo
290
297
  if (stepRecord.thinkingCeiling !== undefined) stepRecord.thinkingCeiling = parseThinkingLevel(stepRecord.thinkingCeiling, `async status '${source}' steps[${index}].thinkingCeiling`);
291
298
  if (stepRecord.launchContractDigest !== undefined && typeof stepRecord.launchContractDigest !== "string") throw new Error(`Invalid async status '${source}': steps[${index}].launchContractDigest must be a string.`);
292
299
  if (stepRecord.sandbox !== undefined) stepRecord.sandbox = validateSandboxProfileName(stepRecord.sandbox, `async status '${source}' steps[${index}].sandbox`);
300
+ if (stepRecord.permissionProfile !== undefined) stepRecord.permissionProfile = validatePermissionProfileName(stepRecord.permissionProfile, `async status '${source}' steps[${index}].permissionProfile`);
293
301
  if (stepRecord.capabilityCeiling !== undefined) stepRecord.capabilityCeiling = parseSubagentCapabilityCeiling(stepRecord.capabilityCeiling, `async status '${source}' steps[${index}].capabilityCeiling`);
294
302
  });
295
303
  }
@@ -325,7 +333,7 @@ export function readAsyncRecoveryDescriptor(asyncDir: string | undefined): Steer
325
333
  if (!value || typeof value !== "object" || Array.isArray(value)) throw new Error(`Invalid async recovery descriptor '${descriptorPath}': expected an object.`);
326
334
  const parsed = value as Record<string, unknown>;
327
335
  const allowedFields = new Set([
328
- "version", "launchContractDigest", "sourceRunId", "agentContract", "agent", "sandbox", "sessionFile", "cwd", "model", "modelProvider", "modelOverrideFromParent", "modelOrigin", "fallbackModels", "thinking", "thinkingCeiling", "tools", "allowNestedSubagents", "extensions",
336
+ "version", "launchContractDigest", "sourceRunId", "agentContract", "agent", "sandbox", "permissionProfile", "sessionFile", "cwd", "model", "modelProvider", "modelOverrideFromParent", "modelOrigin", "fallbackModels", "thinking", "thinkingCeiling", "tools", "allowNestedSubagents", "extensions",
329
337
  "subagentOnlyExtensions", "mcpDirectTools", "excludeTools", "mutationTools", "systemPrompt", "systemPromptMode", "inheritProjectContext", "inheritGlobalContext", "inheritSkills", "skills",
330
338
  "skillPath", "agentFilePath", "completionGuard", "memory", "outputPath", "outputMode", "structuredOutputSchema", "acceptance", "sessionDir", "artifactConfig",
331
339
  "artifactsDir", "maxOutput", "controlConfig", "context", "intercomBridge", "absoluteDeadlineAt", "initialTurnBudget", "initialToolBudget", "maxSubagentDepth", "share", "capabilityCeiling",
@@ -384,6 +392,7 @@ export function readAsyncRecoveryDescriptor(asyncDir: string | undefined): Steer
384
392
  }
385
393
  }
386
394
  if (parsed.sandbox !== undefined) parsed.sandbox = validateSandboxProfileName(parsed.sandbox, `async recovery descriptor '${descriptorPath}' sandbox`);
395
+ if (parsed.permissionProfile !== undefined) parsed.permissionProfile = validatePermissionProfileName(parsed.permissionProfile, `async recovery descriptor '${descriptorPath}' permissionProfile`);
387
396
  if (parsed.completionGuard !== undefined && typeof parsed.completionGuard !== "boolean") throw new Error(`Invalid async recovery descriptor '${descriptorPath}': completionGuard must be a boolean.`);
388
397
  if (parsed.structuredOutputSchema !== undefined && (!parsed.structuredOutputSchema || typeof parsed.structuredOutputSchema !== "object" || Array.isArray(parsed.structuredOutputSchema))) throw new Error(`Invalid async recovery descriptor '${descriptorPath}': structuredOutputSchema must be an object.`);
389
398
  if (parsed.memory !== undefined) {
@@ -517,6 +526,7 @@ export function resolveAsyncResumeTarget(params: AsyncResumeParams, deps: AsyncR
517
526
  model: selectedStep.model,
518
527
  thinking: selectedStep.thinking,
519
528
  sandbox: selectedStep.sandbox ?? result?.results?.[requestedIndex]?.sandbox ?? result?.sandbox ?? recoveryDescriptor?.sandbox,
529
+ permissionProfile: selectedStep.permissionProfile ?? result?.results?.[requestedIndex]?.permissionProfile ?? result?.permissionProfile ?? recoveryDescriptor?.permissionProfile,
520
530
  launchContractDigest: selectedStep.launchContractDigest ?? result?.results?.[requestedIndex]?.launchContractDigest ?? result?.launchContractDigest ?? recoveryDescriptor?.launchContractDigest,
521
531
  ...(selectedStep.runner ? { runner: selectedStep.runner } : {}),
522
532
  ...(selectedStep.externalJob ? { externalJob: selectedStep.externalJob } : {}),
@@ -550,6 +560,7 @@ export function resolveAsyncResumeTarget(params: AsyncResumeParams, deps: AsyncR
550
560
  model: selected.step.model,
551
561
  thinking: selected.step.thinking,
552
562
  sandbox: selected.step.sandbox ?? result?.results?.[selected.index]?.sandbox ?? result?.sandbox ?? recoveryDescriptor?.sandbox,
563
+ permissionProfile: selected.step.permissionProfile ?? result?.results?.[selected.index]?.permissionProfile ?? result?.permissionProfile ?? recoveryDescriptor?.permissionProfile,
553
564
  launchContractDigest: selected.step.launchContractDigest ?? result?.results?.[selected.index]?.launchContractDigest ?? result?.launchContractDigest ?? recoveryDescriptor?.launchContractDigest,
554
565
  ...(selected.step.runner ? { runner: selected.step.runner } : {}),
555
566
  ...(selected.step.externalJob ? { externalJob: selected.step.externalJob } : {}),
@@ -598,6 +609,7 @@ export function resolveAsyncResumeTarget(params: AsyncResumeParams, deps: AsyncR
598
609
  ...(stepModel ? { model: stepModel } : {}),
599
610
  ...(stepThinking ? { thinking: stepThinking } : {}),
600
611
  sandbox: statusSteps[index]?.sandbox ?? resultSteps[index]?.sandbox ?? result?.sandbox ?? recoveryDescriptor?.sandbox,
612
+ permissionProfile: statusSteps[index]?.permissionProfile ?? resultSteps[index]?.permissionProfile ?? result?.permissionProfile ?? recoveryDescriptor?.permissionProfile,
601
613
  launchContractDigest: statusSteps[index]?.launchContractDigest ?? resultSteps[index]?.launchContractDigest ?? result?.launchContractDigest ?? recoveryDescriptor?.launchContractDigest,
602
614
  ...(statusSteps[index]?.runner ? { runner: statusSteps[index]!.runner } : {}),
603
615
  ...(statusSteps[index]?.externalJob ? { externalJob: statusSteps[index]!.externalJob } : {}),
@@ -623,6 +635,7 @@ export function applySteeringRecoveryAgentConfig(agentConfig: AgentConfig, descr
623
635
  mcpDirectTools: descriptor.mcpDirectTools ? [...descriptor.mcpDirectTools] : undefined,
624
636
  mutationTools: descriptor.mutationTools ? [...descriptor.mutationTools] : undefined,
625
637
  sandbox: descriptor.sandbox ?? agentConfig.sandbox,
638
+ permissionProfile: descriptor.permissionProfile ?? agentConfig.permissionProfile,
626
639
  systemPrompt: descriptor.systemPrompt ?? agentConfig.systemPrompt,
627
640
  systemPromptMode: descriptor.systemPromptMode,
628
641
  inheritProjectContext: descriptor.inheritProjectContext,
@@ -26,6 +26,7 @@ import { workflowGraphStageNodes } from "../shared/workflow-graph.ts";
26
26
  import { formatTimeoutRecoveryLines, projectTimeoutRecovery } from "../shared/mutation-evidence.ts";
27
27
  import { formatWorkflowChecklistText, projectWorkflowChecklist } from "../../workflows/workflow-checklist.ts";
28
28
  import { validateSandboxProfileName } from "../../shared/sandbox-profile.ts";
29
+ import { validatePermissionProfileName } from "../../shared/permission-profile.ts";
29
30
 
30
31
  interface AsyncRunStepSummary {
31
32
  index: number;
@@ -67,6 +68,7 @@ interface AsyncRunStepSummary {
67
68
  contextLimit?: number;
68
69
  thinking?: string;
69
70
  sandbox?: string;
71
+ permissionProfile?: string;
70
72
  attemptedModels?: string[];
71
73
  sessionFile?: string;
72
74
  transcriptPath?: string;
@@ -109,6 +111,7 @@ export interface AsyncRunSummary {
109
111
  mode: SubagentRunMode;
110
112
  context?: ContextSummary;
111
113
  sandbox?: string;
114
+ permissionProfile?: string;
112
115
  cwd?: string;
113
116
  sessionRoot?: string;
114
117
  startedAt: number;
@@ -214,6 +217,14 @@ function sandboxProfileValue(value: unknown): string | undefined {
214
217
  }
215
218
  }
216
219
 
220
+ function permissionProfileValue(value: unknown): string | undefined {
221
+ try {
222
+ return validatePermissionProfileName(value);
223
+ } catch {
224
+ return undefined;
225
+ }
226
+ }
227
+
217
228
  function isNotFoundError(error: unknown): boolean {
218
229
  return typeof error === "object"
219
230
  && error !== null
@@ -339,6 +350,7 @@ function statusToSummary(asyncDir: string, status: AsyncStatus & { cwd?: string
339
350
  const stepLastActivityAt = step.lastActivityAt;
340
351
  const timeoutRecovery = projectTimeoutRecovery(step.timeoutRecovery);
341
352
  const sandbox = sandboxProfileValue(step.sandbox);
353
+ const permissionProfile = permissionProfileValue(step.permissionProfile);
342
354
  return {
343
355
  index,
344
356
  childId: asyncStatusChildIdentity(step, index),
@@ -378,6 +390,7 @@ function statusToSummary(asyncDir: string, status: AsyncStatus & { cwd?: string
378
390
  ...(step.contextLimit !== undefined ? { contextLimit: step.contextLimit } : {}),
379
391
  ...(step.thinking ? { thinking: step.thinking } : {}),
380
392
  ...(sandbox ? { sandbox } : {}),
393
+ ...(permissionProfile ? { permissionProfile } : {}),
381
394
  ...(step.thinkingCeiling ? { thinkingCeiling: step.thinkingCeiling } : {}),
382
395
  ...(step.attemptedModels ? { attemptedModels: step.attemptedModels } : {}),
383
396
  ...(step.sessionFile ? { sessionFile: step.sessionFile } : {}),
@@ -409,6 +422,7 @@ function statusToSummary(asyncDir: string, status: AsyncStatus & { cwd?: string
409
422
  });
410
423
  attachRootChildrenToSteps(status.runId || path.basename(asyncDir), summarizedSteps, nestedChildren);
411
424
  const sandbox = sandboxProfileValue(status.sandbox);
425
+ const permissionProfile = permissionProfileValue(status.permissionProfile);
412
426
  return {
413
427
  id: status.runId || path.basename(asyncDir),
414
428
  asyncDir,
@@ -427,6 +441,7 @@ function statusToSummary(asyncDir: string, status: AsyncStatus & { cwd?: string
427
441
  mode: status.mode,
428
442
  ...(summarizeContextModes(summarizedSteps.map((step) => step.context)) ? { context: summarizeContextModes(summarizedSteps.map((step) => step.context)) } : {}),
429
443
  ...(sandbox ? { sandbox } : {}),
444
+ ...(permissionProfile ? { permissionProfile } : {}),
430
445
  cwd: status.cwd,
431
446
  ...(status.sessionRoot ? { sessionRoot: status.sessionRoot } : {}),
432
447
  startedAt: status.startedAt,