@xzzpig/pi-subagents 0.11.0 → 0.13.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.
@@ -0,0 +1,42 @@
1
+ /** Shared wire contract for selecting a pi-permission-system profile in a child Pi process. */
2
+ export const SUBAGENT_PERMISSION_PROFILE_ENV = "PI_SUBAGENT_PERMISSION_PROFILE";
3
+
4
+ /**
5
+ * Marks a child process whose profile selection was pinned by its launcher.
6
+ *
7
+ * The selection key alone cannot express "this child was launched with no
8
+ * profile": clearing it looks exactly like a host session that never selected
9
+ * one. pi-permission-system therefore freezes the launcher's selection only when
10
+ * this marker is present, which keeps a host session reading the value live so a
11
+ * mid-session role change still applies.
12
+ */
13
+ export const SUBAGENT_PERMISSION_PROFILE_PINNED_ENV =
14
+ "PI_SUBAGENT_PERMISSION_PROFILE_PINNED";
15
+
16
+ const MAX_PERMISSION_PROFILE_NAME_LENGTH = 128;
17
+ const PERMISSION_PROFILE_NAME_PATTERN = /^[A-Za-z0-9][A-Za-z0-9_-]*$/;
18
+
19
+ /**
20
+ * Validate a raw `permission-profile` selection value into a normalized name.
21
+ * Only a bare identifier is accepted — objects (agent files must never carry
22
+ * inline policy), the literal `false`, path components, whitespace, and
23
+ * over-long values are all rejected at agent-load time.
24
+ */
25
+ export function validatePermissionProfileName(
26
+ value: unknown,
27
+ label = "permission profile",
28
+ ): string {
29
+ if (typeof value !== "string" || value.length === 0 || value.trim() !== value) {
30
+ throw new Error(`${label} must be a non-empty profile name without surrounding whitespace.`);
31
+ }
32
+ if (value === "false") {
33
+ throw new Error(`${label} must select a named profile; the literal false is not supported.`);
34
+ }
35
+ if (value.length > MAX_PERMISSION_PROFILE_NAME_LENGTH) {
36
+ throw new Error(`${label} must be at most ${MAX_PERMISSION_PROFILE_NAME_LENGTH} characters.`);
37
+ }
38
+ if (!PERMISSION_PROFILE_NAME_PATTERN.test(value)) {
39
+ throw new Error(`${label} must contain only letters, digits, underscores, or hyphens and start with a letter or digit.`);
40
+ }
41
+ return value;
42
+ }
@@ -787,6 +787,7 @@ export interface SteeringRecoveryDescriptor {
787
787
  agentContract?: AgentContract;
788
788
  agent: string;
789
789
  sandbox?: string;
790
+ permissionProfile?: string;
790
791
  sessionFile?: string;
791
792
  /** Git ref used to allocate managed worktrees for this run. */
792
793
  baseRef?: string;
@@ -1242,6 +1243,7 @@ export interface SingleResult {
1242
1243
  toolBudget?: ToolBudgetState;
1243
1244
  toolBudgetBlocked?: boolean;
1244
1245
  sandbox?: string;
1246
+ permissionProfile?: string;
1245
1247
  messages?: Message[];
1246
1248
  usage: Usage;
1247
1249
  model?: string;
@@ -1575,6 +1577,7 @@ export interface NestedStepSummary {
1575
1577
  toolBudget?: ToolBudgetState;
1576
1578
  toolBudgetBlocked?: boolean;
1577
1579
  sandbox?: string;
1580
+ permissionProfile?: string;
1578
1581
  processTerminal?: ProcessTerminalV1;
1579
1582
  launchResolvedExtensions?: LaunchResolvedChildExtensionsV1;
1580
1583
  runtimeAcknowledgedExtensions?: RuntimeAcknowledgedChildExtensionsV1;
@@ -1605,6 +1608,7 @@ export interface NestedRunSummary extends NestedRunAddress {
1605
1608
  /** Human-readable display name for the child session, when derived at launch. */
1606
1609
  sessionName?: string;
1607
1610
  sandbox?: string;
1611
+ permissionProfile?: string;
1608
1612
  agents?: string[];
1609
1613
  model?: string;
1610
1614
  thinking?: string;
@@ -1669,6 +1673,7 @@ export interface AsyncStartedEvent {
1669
1673
  preflight?: WorkflowPreflightV1;
1670
1674
  launchContractDigest?: string;
1671
1675
  sandbox?: string;
1676
+ permissionProfile?: string;
1672
1677
  launchResolvedExtensions?: LaunchResolvedChildExtensionsV1;
1673
1678
  runtimeAcknowledgedExtensions?: RuntimeAcknowledgedChildExtensionsV1;
1674
1679
  usageBudget?: UsageBudgetState;
@@ -1841,6 +1846,7 @@ export interface AsyncStatus {
1841
1846
  runFanoutBudgetDescriptor?: RunFanoutBudgetDescriptor;
1842
1847
  launchContractDigest?: string;
1843
1848
  sandbox?: string;
1849
+ permissionProfile?: string;
1844
1850
  launchResolvedExtensions?: LaunchResolvedChildExtensionsV1;
1845
1851
  runtimeAcknowledgedExtensions?: RuntimeAcknowledgedChildExtensionsV1;
1846
1852
  capabilityCeiling?: ResolvedSubagentCapabilityCeiling;
@@ -1933,6 +1939,7 @@ export interface AsyncStatus {
1933
1939
  agentContract?: AgentContract;
1934
1940
  launchContractDigest?: string;
1935
1941
  sandbox?: string;
1942
+ permissionProfile?: string;
1936
1943
  launchResolvedExtensions?: LaunchResolvedChildExtensionsV1;
1937
1944
  runtimeAcknowledgedExtensions?: RuntimeAcknowledgedChildExtensionsV1;
1938
1945
  execution?: ExecutionProjection;
@@ -2069,6 +2076,7 @@ export interface ForegroundResumeChild {
2069
2076
  };
2070
2077
  launchContractDigest?: string;
2071
2078
  sandbox?: string;
2079
+ permissionProfile?: string;
2072
2080
  /** Private retained launch authority. Never project into status or result output. */
2073
2081
  extensionBindings?: ExtensionBindings;
2074
2082
  launchResolvedExtensions?: LaunchResolvedChildExtensionsV1;
@@ -2377,6 +2385,8 @@ export interface RunSyncOptions {
2377
2385
  toolBudget?: ResolvedToolBudget;
2378
2386
  /** Selected global sandbox profile, when this child requested one. */
2379
2387
  sandbox?: string;
2388
+ /** Selected global pi-permission-system profile, when this child requested one. */
2389
+ permissionProfile?: string;
2380
2390
  allowZeroToolBudget?: boolean;
2381
2391
  allowIntercomDetach?: boolean;
2382
2392
  intercomEvents?: IntercomEventBus;