@phyzess/pappra 0.1.0-beta.13 → 0.1.0-beta.18
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 +134 -15
- package/assets/integrations/skills/pappra/SKILL.md +28 -7
- package/assets/integrations/skills/pappra/references/collaboration.md +633 -0
- package/assets/integrations/skills/pappra/references/environment.md +360 -0
- package/assets/integrations/skills/pappra/references/hosts.md +20 -0
- package/assets/integrations/skills/pappra/references/operations.md +36 -5
- package/dist/adapters/pi/recovery-extension.d.ts +65 -0
- package/dist/adapters/pi/recovery-extension.js +238 -0
- package/dist/adapters/pi/session-transition-extension.d.ts +30 -0
- package/dist/adapters/pi/session-transition-extension.js +265 -0
- package/dist/app/automatic-handoff-events.d.ts +26 -0
- package/dist/app/automatic-handoff-events.js +134 -0
- package/dist/app/bounded-file.d.ts +2 -0
- package/dist/app/bounded-file.js +2 -0
- package/dist/app/capability-evidence/claude.d.ts +37 -0
- package/dist/app/capability-evidence/claude.js +206 -0
- package/dist/app/capability-evidence/codex.d.ts +35 -0
- package/dist/app/capability-evidence/codex.js +193 -0
- package/dist/app/capability-evidence/index.d.ts +33 -0
- package/dist/app/capability-evidence/index.js +117 -0
- package/dist/app/capability-evidence/pi.d.ts +73 -0
- package/dist/app/capability-evidence/pi.js +669 -0
- package/dist/app/capability-evidence/shared.d.ts +69 -0
- package/dist/app/capability-evidence/shared.js +195 -0
- package/dist/app/collab-auto-handoff.d.ts +55 -0
- package/dist/app/collab-auto-handoff.js +384 -0
- package/dist/app/collab-bindings.d.ts +57 -0
- package/dist/app/collab-bindings.js +1006 -0
- package/dist/app/collab-bootstrap-transport.d.ts +163 -0
- package/dist/app/collab-bootstrap-transport.js +769 -0
- package/dist/app/collab-bootstrap.d.ts +137 -0
- package/dist/app/collab-bootstrap.js +3455 -0
- package/dist/app/collab-handoff.d.ts +12 -0
- package/dist/app/collab-handoff.js +511 -0
- package/dist/app/collab-messages.d.ts +2 -0
- package/dist/app/collab-messages.js +2 -0
- package/dist/app/collab-notify.d.ts +156 -0
- package/dist/app/collab-notify.js +1208 -0
- package/dist/app/collab-preflight.d.ts +34 -0
- package/dist/app/collab-preflight.js +96 -0
- package/dist/app/collab-recovery-executor.d.ts +161 -0
- package/dist/app/collab-recovery-executor.js +1153 -0
- package/dist/app/collab-recovery-projection.d.ts +103 -0
- package/dist/app/collab-recovery-projection.js +659 -0
- package/dist/app/collab-recovery.d.ts +25 -0
- package/dist/app/collab-recovery.js +429 -0
- package/dist/app/collab-resources.d.ts +16 -0
- package/dist/app/collab-resources.js +278 -0
- package/dist/app/collab-role-events.d.ts +22 -0
- package/dist/app/collab-role-events.js +329 -0
- package/dist/app/collab-role-orchestration.d.ts +53 -0
- package/dist/app/collab-role-orchestration.js +601 -0
- package/dist/app/collab-role-plan.d.ts +81 -0
- package/dist/app/collab-role-plan.js +504 -0
- package/dist/app/collab-role-repair.d.ts +109 -0
- package/dist/app/collab-role-repair.js +821 -0
- package/dist/app/collab-rollover.d.ts +263 -0
- package/dist/app/collab-rollover.js +1112 -0
- package/dist/app/collab-route.d.ts +64 -0
- package/dist/app/collab-route.js +240 -0
- package/dist/app/collab-session-transition.d.ts +221 -0
- package/dist/app/collab-session-transition.js +3334 -0
- package/dist/app/collab-state.d.ts +7 -0
- package/dist/app/collab-state.js +162 -0
- package/dist/app/collab-task-store.d.ts +22 -0
- package/dist/app/collab-task-store.js +204 -0
- package/dist/app/collab-work-execution.d.ts +127 -0
- package/dist/app/collab-work-execution.js +1027 -0
- package/dist/app/collab-work-plan.d.ts +87 -0
- package/dist/app/collab-work-plan.js +437 -0
- package/dist/app/collaboration.d.ts +8 -2
- package/dist/app/collaboration.js +101 -12
- package/dist/app/doctor.js +108 -5
- package/dist/app/host-mcp.js +34 -8
- package/dist/app/host-probe.js +4 -4
- package/dist/app/init.d.ts +58 -4
- package/dist/app/init.js +768 -155
- package/dist/app/managed-pi-bootstrap-admission.d.ts +14 -0
- package/dist/app/managed-pi-bootstrap-admission.js +104 -0
- package/dist/app/managed-pi-bootstrap-refresh.d.ts +10 -0
- package/dist/app/managed-pi-bootstrap-refresh.js +78 -0
- package/dist/app/managed-pi-delivery.d.ts +8 -0
- package/dist/app/managed-pi-delivery.js +110 -0
- package/dist/app/managed-pi-handoff-receiver.d.ts +15 -0
- package/dist/app/managed-pi-handoff-receiver.js +263 -0
- package/dist/app/managed-pi-handoff-reference.d.ts +3 -0
- package/dist/app/managed-pi-handoff-reference.js +60 -0
- package/dist/app/managed-pi-herdr.d.ts +21 -0
- package/dist/app/managed-pi-herdr.js +185 -0
- package/dist/app/managed-pi-initial-admission.d.ts +28 -0
- package/dist/app/managed-pi-initial-admission.js +416 -0
- package/dist/app/managed-pi-initial-launch.d.ts +5 -0
- package/dist/app/managed-pi-initial-launch.js +61 -0
- package/dist/app/managed-pi-native-observation.d.ts +36 -0
- package/dist/app/managed-pi-native-observation.js +191 -0
- package/dist/app/managed-pi-readiness.d.ts +29 -0
- package/dist/app/managed-pi-readiness.js +288 -0
- package/dist/app/managed-pi-repair-stop.d.ts +21 -0
- package/dist/app/managed-pi-repair-stop.js +371 -0
- package/dist/app/managed-pi-resume-admission.d.ts +32 -0
- package/dist/app/managed-pi-resume-admission.js +618 -0
- package/dist/app/managed-pi-retirement.d.ts +28 -0
- package/dist/app/managed-pi-retirement.js +112 -0
- package/dist/app/managed-pi-sdk-control.d.ts +7 -0
- package/dist/app/managed-pi-sdk-control.js +169 -0
- package/dist/app/managed-pi-sdk-runtime.d.ts +3 -0
- package/dist/app/managed-pi-sdk-runtime.js +483 -0
- package/dist/app/managed-pi-source-admission.d.ts +14 -0
- package/dist/app/managed-pi-source-admission.js +323 -0
- package/dist/app/managed-pi-transition-host.d.ts +36 -0
- package/dist/app/managed-pi-transition-host.js +292 -0
- package/dist/app/managed-pi.d.ts +54 -0
- package/dist/app/managed-pi.js +248 -0
- package/dist/app/shell-readiness.d.ts +66 -0
- package/dist/app/shell-readiness.js +368 -0
- package/dist/app/task-pin.d.ts +2 -23
- package/dist/app/task-pin.js +2 -113
- package/dist/cli/commands/collaboration-binding.d.ts +13 -0
- package/dist/cli/commands/collaboration-binding.js +118 -0
- package/dist/cli/commands/collaboration-bootstrap.d.ts +10 -0
- package/dist/cli/commands/collaboration-bootstrap.js +84 -0
- package/dist/cli/commands/collaboration-capabilities.d.ts +13 -0
- package/dist/cli/commands/collaboration-capabilities.js +127 -0
- package/dist/cli/commands/collaboration-handoff.d.ts +13 -0
- package/dist/cli/commands/collaboration-handoff.js +102 -0
- package/dist/cli/commands/collaboration-message.d.ts +17 -0
- package/dist/cli/commands/collaboration-message.js +177 -0
- package/dist/cli/commands/collaboration-plan.d.ts +8 -0
- package/dist/cli/commands/collaboration-plan.js +108 -0
- package/dist/cli/commands/collaboration-preflight.d.ts +10 -0
- package/dist/cli/commands/collaboration-preflight.js +167 -0
- package/dist/cli/commands/collaboration-recovery-run.d.ts +46 -0
- package/dist/cli/commands/collaboration-recovery-run.js +224 -0
- package/dist/cli/commands/collaboration-recovery.d.ts +11 -0
- package/dist/cli/commands/collaboration-recovery.js +104 -0
- package/dist/cli/commands/collaboration-resources.d.ts +11 -0
- package/dist/cli/commands/collaboration-resources.js +96 -0
- package/dist/cli/commands/collaboration-role-plan.d.ts +9 -0
- package/dist/cli/commands/collaboration-role-plan.js +69 -0
- package/dist/cli/commands/collaboration-role-run.d.ts +11 -0
- package/dist/cli/commands/collaboration-role-run.js +128 -0
- package/dist/cli/commands/collaboration-rollover.d.ts +10 -0
- package/dist/cli/commands/collaboration-rollover.js +103 -0
- package/dist/cli/commands/collaboration-state.d.ts +10 -0
- package/dist/cli/commands/collaboration-state.js +96 -0
- package/dist/cli/commands/collaboration-transition.d.ts +10 -0
- package/dist/cli/commands/collaboration-transition.js +75 -0
- package/dist/cli/commands/collaboration-work-run.d.ts +34 -0
- package/dist/cli/commands/collaboration-work-run.js +178 -0
- package/dist/cli/commands/collaboration.d.ts +4 -0
- package/dist/cli/commands/collaboration.js +39 -4
- package/dist/cli/commands/continuity.js +2 -6
- package/dist/cli/commands/docs.d.ts +2 -0
- package/dist/cli/commands/docs.js +89 -15
- package/dist/cli/commands/host.d.ts +7 -1
- package/dist/cli/commands/host.js +122 -7
- package/dist/cli/commands/init.d.ts +20 -3
- package/dist/cli/commands/init.js +897 -232
- package/dist/cli/commands/mcp.d.ts +1 -0
- package/dist/cli/commands/mcp.js +11 -5
- package/dist/cli/commands/repair.d.ts +12 -0
- package/dist/cli/commands/repair.js +41 -0
- package/dist/cli/commands/runtime.d.ts +1 -1
- package/dist/cli/commands/runtime.js +139 -38
- package/dist/cli/commands/session.d.ts +7 -0
- package/dist/cli/commands/session.js +82 -0
- package/dist/cli/commands/task.js +19 -5
- package/dist/cli/run.js +866 -24
- package/dist/code/identity.d.ts +7 -0
- package/dist/code/identity.js +7 -3
- package/dist/code/registration.js +7 -0
- package/dist/code/service.d.ts +9 -0
- package/dist/code/service.js +16 -3
- package/dist/code/text.js +19 -7
- package/dist/collab/admission.d.ts +91 -66
- package/dist/collab/admission.js +21 -6
- package/dist/collab/canonical.d.ts +1 -1
- package/dist/collab/canonical.js +44 -3
- package/dist/collab/envelope.d.ts +2 -2
- package/dist/collab/envelope.js +12 -12
- package/dist/collab/first-work.d.ts +3 -0
- package/dist/collab/first-work.js +15 -0
- package/dist/collab/handoff.d.ts +16 -0
- package/dist/collab/handoff.js +39 -5
- package/dist/collab/index.d.ts +97 -1
- package/dist/collab/index.js +9 -1
- package/dist/collab/messages.js +126 -3
- package/dist/collab/persisted-messages.d.ts +123 -0
- package/dist/collab/persisted-messages.js +496 -0
- package/dist/collab/preflight.d.ts +1 -1
- package/dist/collab/resources.d.ts +13 -3
- package/dist/collab/resources.js +37 -6
- package/dist/collab/rollover.d.ts +311 -0
- package/dist/collab/rollover.js +1024 -0
- package/dist/collab/store.d.ts +1 -0
- package/dist/collab/store.js +1 -4
- package/dist/collab/types.d.ts +2 -354
- package/dist/collab/validation.d.ts +2 -10
- package/dist/collab/validation.js +2 -303
- package/dist/collab/work-plan.d.ts +105 -0
- package/dist/collab/work-plan.js +843 -0
- package/dist/continuity/context.d.ts +11 -2
- package/dist/continuity/context.js +100 -13
- package/dist/continuity/handoff-bundle.d.ts +296 -0
- package/dist/continuity/handoff-bundle.js +477 -0
- package/dist/continuity/index.d.ts +2 -0
- package/dist/continuity/index.js +1 -0
- package/dist/continuity/paths.js +10 -2
- package/dist/continuity/service.js +91 -15
- package/dist/continuity/task-pin.d.ts +24 -0
- package/dist/continuity/task-pin.js +590 -0
- package/dist/doctor.d.ts +1 -0
- package/dist/doctor.js +6 -0
- package/dist/experimental/index.d.ts +13 -0
- package/dist/experimental/index.js +25 -0
- package/dist/experimental/pi.d.ts +4 -0
- package/dist/experimental/pi.js +12 -0
- package/dist/hosts/claude/native.js +1 -1
- package/dist/hosts/codex/native.js +1 -1
- package/dist/hosts/codex/protocol.js +1 -1
- package/dist/hosts/integration/bootstrap-config.d.ts +58 -0
- package/dist/hosts/integration/bootstrap-config.js +254 -0
- package/dist/hosts/integration/bundle-export.d.ts +44 -0
- package/dist/hosts/integration/bundle-export.js +366 -3
- package/dist/hosts/integration/bundle.js +3 -0
- package/dist/hosts/integration/hook.js +36 -9
- package/dist/hosts/integration/pappra-bootstrap-extension.mjs +80 -0
- package/dist/hosts/integration/pappra-extension-runtime.mjs +59 -24631
- package/dist/hosts/integration/pappra-hook.mjs +61 -24749
- package/dist/hosts/integration/pappra-recovery-extension.mjs +259 -0
- package/dist/hosts/integration/pappra-session-transition-extension.mjs +276 -0
- package/dist/hosts/integration/pi-bootstrap-extension.d.ts +36 -0
- package/dist/hosts/integration/pi-bootstrap-extension.js +101 -0
- package/dist/hosts/integration/pi-bootstrap-guard.d.ts +125 -0
- package/dist/hosts/integration/pi-bootstrap-guard.js +438 -0
- package/dist/hosts/integration/pi-bootstrap-runtime.d.ts +63 -0
- package/dist/hosts/integration/pi-bootstrap-runtime.js +223 -0
- package/dist/hosts/integration/pi-native-events.d.ts +112 -0
- package/dist/hosts/integration/pi-native-events.js +348 -0
- package/dist/hosts/integration/pi-rollover-extension.d.ts +166 -0
- package/dist/hosts/integration/pi-rollover-extension.js +431 -0
- package/dist/hosts/integration/recovery-config.d.ts +48 -0
- package/dist/hosts/integration/recovery-config.js +117 -0
- package/dist/hosts/integration/service.d.ts +6 -1
- package/dist/hosts/integration/service.js +485 -35
- package/dist/hosts/integration/support.d.ts +7 -0
- package/dist/hosts/integration/support.js +9 -1
- package/dist/hosts/integration/templates.d.ts +3 -0
- package/dist/hosts/integration/templates.js +26 -3
- package/dist/hosts/pi/managed-host-identity.d.ts +2 -0
- package/dist/hosts/pi/managed-host-identity.js +40 -0
- package/dist/hosts/pi/managed-provider-diagnostics.d.ts +6 -0
- package/dist/hosts/pi/managed-provider-diagnostics.js +184 -0
- package/dist/hosts/pi/managed-sdk-session.d.ts +335 -0
- package/dist/hosts/pi/managed-sdk-session.js +1639 -0
- package/dist/hosts/pi/managed-session-extension.d.ts +20 -0
- package/dist/hosts/pi/managed-session-extension.js +84 -0
- package/dist/hosts/pi/managed-session.d.ts +177 -0
- package/dist/hosts/pi/managed-session.js +1557 -0
- package/dist/hosts/pi/protocol.js +1 -1
- package/dist/hosts/pi/query-result.js +1 -1
- package/dist/hosts/pi/resume-capability.d.ts +41 -0
- package/dist/hosts/pi/resume-capability.js +33 -0
- package/dist/hosts/pi/rpc.d.ts +182 -134
- package/dist/hosts/pi/rpc.js +230 -37
- package/dist/hosts/pilot.d.ts +97 -74
- package/dist/hosts/pilot.js +5 -1
- package/dist/hosts/version.d.ts +3 -0
- package/dist/hosts/version.js +18 -0
- package/dist/index.d.ts +0 -1
- package/dist/index.js +0 -1
- package/dist/infra/bounded-file.d.ts +19 -0
- package/dist/infra/bounded-file.js +66 -0
- package/dist/infra/fs.js +10 -2
- package/dist/infra/git.d.ts +29 -0
- package/dist/infra/git.js +45 -9
- package/dist/infra/json-property.d.ts +2 -0
- package/dist/infra/json-property.js +69 -0
- package/dist/infra/json.d.ts +4 -0
- package/dist/infra/json.js +24 -0
- package/dist/infra/owned-process-group.js +1 -1
- package/dist/infra/private-lock.d.ts +16 -0
- package/dist/infra/private-lock.js +148 -0
- package/dist/infra/private-state.d.ts +7 -0
- package/dist/infra/private-state.js +146 -0
- package/dist/infra/process-identity.d.ts +12 -0
- package/dist/infra/process-identity.js +142 -0
- package/dist/infra/validation.d.ts +5 -0
- package/dist/infra/validation.js +15 -0
- package/dist/init.d.ts +1 -0
- package/dist/init.js +6 -0
- package/dist/install/apply.d.ts +9 -1
- package/dist/install/apply.js +176 -12
- package/dist/install/dependencies.d.ts +38 -0
- package/dist/install/dependencies.js +282 -0
- package/dist/install/ownership.js +30 -1
- package/dist/install/references.d.ts +31 -0
- package/dist/install/references.js +208 -0
- package/dist/install/repair.d.ts +37 -0
- package/dist/install/repair.js +798 -0
- package/dist/install/reset-local.d.ts +16 -0
- package/dist/install/reset-local.js +304 -0
- package/dist/install/rollback.d.ts +3 -0
- package/dist/install/rollback.js +9 -3
- package/dist/install/runtime.d.ts +10 -6
- package/dist/install/runtime.js +299 -59
- package/dist/install/source-fingerprint.d.ts +2 -0
- package/dist/install/source-fingerprint.js +103 -0
- package/dist/knowledge/catalog.d.ts +1 -0
- package/dist/knowledge/catalog.js +143 -10
- package/dist/knowledge/journal.js +17 -7
- package/dist/knowledge/paths.js +2 -1
- package/dist/knowledge/refs.js +4 -0
- package/dist/knowledge/register-batch.d.ts +4 -0
- package/dist/knowledge/register-batch.js +225 -0
- package/dist/knowledge/relocate.d.ts +5 -0
- package/dist/knowledge/relocate.js +92 -0
- package/dist/knowledge/scan.js +103 -47
- package/dist/knowledge/service.d.ts +3 -0
- package/dist/knowledge/service.js +33 -1
- package/dist/knowledge/write.d.ts +4 -1
- package/dist/knowledge/write.js +1 -1
- package/dist/mcp/server.d.ts +4 -2
- package/dist/mcp/server.js +87 -136
- package/dist/schemas/collaboration-state-validation.d.ts +6 -0
- package/dist/schemas/collaboration-state-validation.js +342 -0
- package/dist/schemas/collaboration-state.d.ts +436 -0
- package/dist/schemas/collaboration-state.js +1 -0
- package/dist/schemas/collaboration.d.ts +335 -0
- package/dist/schemas/collaboration.js +272 -0
- package/dist/schemas/continuity.d.ts +8 -0
- package/dist/schemas/continuity.js +13 -3
- package/dist/schemas/doctor.d.ts +1 -0
- package/dist/schemas/doctor.js +1 -0
- package/dist/schemas/document.d.ts +61 -0
- package/dist/schemas/document.js +9 -0
- package/dist/schemas/errors.d.ts +1 -0
- package/dist/schemas/errors.js +1 -0
- package/dist/schemas/host.d.ts +24 -0
- package/dist/schemas/host.js +19 -0
- package/dist/schemas/install.d.ts +8 -2
- package/dist/schemas/install.js +11 -1
- package/dist/schemas/managed-pi-execution.d.ts +16 -0
- package/dist/schemas/managed-pi-execution.js +2 -0
- package/dist/schemas/outcome.d.ts +9 -5
- package/dist/workspace/config-file.js +1 -3
- package/dist/workspace/documents.js +12 -2
- package/dist/workspace/repositories.d.ts +7 -0
- package/dist/workspace/repositories.js +14 -5
- package/package.json +35 -35
- package/skills/pappra/SKILL.md +28 -7
- package/skills/pappra/references/collaboration.md +633 -0
- package/skills/pappra/references/environment.md +360 -0
- package/skills/pappra/references/hosts.md +20 -0
- package/skills/pappra/references/operations.md +36 -5
- package/dist/app/collab-from.d.ts +0 -35
- package/dist/app/collab-from.js +0 -84
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { ExtensionAPI } from '@earendil-works/pi-coding-agent';
|
|
2
|
+
import type { PiBootstrapGuard } from './pi-bootstrap-guard.js';
|
|
3
|
+
/**
|
|
4
|
+
* Self-contained Pi extension entry for the opt-in successor bootstrap gate.
|
|
5
|
+
*
|
|
6
|
+
* This file is bundled into `pappra-bootstrap-extension.mjs` and shipped next to a validated
|
|
7
|
+
* `bootstrap.json` inside a private export directory. Loading it registers a default-deny
|
|
8
|
+
* `tool_call` handler before any configuration, reader or lifecycle work; only a fully
|
|
9
|
+
* initialized accepted guard may reach the real decision. Any failure keeps the deny handler
|
|
10
|
+
* for the process lifetime and never rethrows into an unrestricted loader fallthrough.
|
|
11
|
+
*
|
|
12
|
+
* The status command reports registration, never write permission: `registered` only means the
|
|
13
|
+
* gate and lifecycle handlers were installed, and `write_permitted` is always `not-asserted`.
|
|
14
|
+
*/
|
|
15
|
+
export declare const PI_BOOTSTRAP_STATUS_SCHEMA = "pappra/pi-bootstrap-status/1";
|
|
16
|
+
export type PiBootstrapState = 'denied' | 'registered';
|
|
17
|
+
export interface PiBootstrapStatus {
|
|
18
|
+
readonly schema: typeof PI_BOOTSTRAP_STATUS_SCHEMA;
|
|
19
|
+
/** `registered` means handlers were installed; it is not a permission signal. */
|
|
20
|
+
readonly state: PiBootstrapState;
|
|
21
|
+
readonly registered: boolean;
|
|
22
|
+
/** The gate never asserts current write permission; a tool call still decides per call. */
|
|
23
|
+
readonly write_permitted: 'not-asserted';
|
|
24
|
+
readonly mode: 'deny-until-completed-transfer' | 'default-deny';
|
|
25
|
+
readonly reason: string | null;
|
|
26
|
+
readonly taskId: string | null;
|
|
27
|
+
readonly config_digest: string | null;
|
|
28
|
+
readonly guard: ReturnType<PiBootstrapGuard['status']> | null;
|
|
29
|
+
readonly limitations: readonly string[];
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Loads the sibling config, registers the accepted runtime gate and the accepted lifecycle
|
|
33
|
+
* extension, and exposes a read-only status command. Returns the installed handler count only
|
|
34
|
+
* for tests; the host surface itself has no allow/release API.
|
|
35
|
+
*/
|
|
36
|
+
export default function bootstrapExtension(pi: ExtensionAPI): void;
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { fileURLToPath } from 'node:url';
|
|
2
|
+
import { boundedReason, readPiBootstrapConfig, runtimeConfigOf, } from './bootstrap-config.js';
|
|
3
|
+
import { registerPiBootstrapRuntime } from './pi-bootstrap-runtime.js';
|
|
4
|
+
import { createPiExtension } from './pi-extension-runtime.js';
|
|
5
|
+
/**
|
|
6
|
+
* Self-contained Pi extension entry for the opt-in successor bootstrap gate.
|
|
7
|
+
*
|
|
8
|
+
* This file is bundled into `pappra-bootstrap-extension.mjs` and shipped next to a validated
|
|
9
|
+
* `bootstrap.json` inside a private export directory. Loading it registers a default-deny
|
|
10
|
+
* `tool_call` handler before any configuration, reader or lifecycle work; only a fully
|
|
11
|
+
* initialized accepted guard may reach the real decision. Any failure keeps the deny handler
|
|
12
|
+
* for the process lifetime and never rethrows into an unrestricted loader fallthrough.
|
|
13
|
+
*
|
|
14
|
+
* The status command reports registration, never write permission: `registered` only means the
|
|
15
|
+
* gate and lifecycle handlers were installed, and `write_permitted` is always `not-asserted`.
|
|
16
|
+
*/
|
|
17
|
+
export const PI_BOOTSTRAP_STATUS_SCHEMA = 'pappra/pi-bootstrap-status/1';
|
|
18
|
+
const LIMITATIONS = Object.freeze([
|
|
19
|
+
'registered_is_not_write_permission',
|
|
20
|
+
'not_a_native_host_load_or_trust_proof',
|
|
21
|
+
'no_allow_thaw_release_or_permanent_unlock',
|
|
22
|
+
'check_use_gap_and_background_effects_are_not_fenced',
|
|
23
|
+
]);
|
|
24
|
+
function notify(context, message) {
|
|
25
|
+
if (typeof context !== 'object' || context === null)
|
|
26
|
+
return;
|
|
27
|
+
if ('ui' in context &&
|
|
28
|
+
typeof context.ui === 'object' &&
|
|
29
|
+
context.ui !== null &&
|
|
30
|
+
'notify' in context.ui &&
|
|
31
|
+
typeof context.ui.notify === 'function') {
|
|
32
|
+
context.ui.notify(message, 'info');
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
function configPath() {
|
|
36
|
+
return fileURLToPath(new URL('./bootstrap.json', import.meta.url));
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Loads the sibling config, registers the accepted runtime gate and the accepted lifecycle
|
|
40
|
+
* extension, and exposes a read-only status command. Returns the installed handler count only
|
|
41
|
+
* for tests; the host surface itself has no allow/release API.
|
|
42
|
+
*/
|
|
43
|
+
export default function bootstrapExtension(pi) {
|
|
44
|
+
const extensionHost = pi;
|
|
45
|
+
let initialized = false;
|
|
46
|
+
let deniedReason = 'bootstrap-config-not-loaded';
|
|
47
|
+
let config = null;
|
|
48
|
+
let configDigest = null;
|
|
49
|
+
let guard = null;
|
|
50
|
+
const status = () => ({
|
|
51
|
+
schema: PI_BOOTSTRAP_STATUS_SCHEMA,
|
|
52
|
+
state: initialized ? 'registered' : 'denied',
|
|
53
|
+
registered: initialized,
|
|
54
|
+
write_permitted: 'not-asserted',
|
|
55
|
+
mode: initialized ? 'deny-until-completed-transfer' : 'default-deny',
|
|
56
|
+
reason: initialized ? null : deniedReason,
|
|
57
|
+
taskId: config?.taskId ?? null,
|
|
58
|
+
config_digest: configDigest,
|
|
59
|
+
guard: guard === null ? null : guard.status(),
|
|
60
|
+
limitations: LIMITATIONS,
|
|
61
|
+
});
|
|
62
|
+
// Fail-closed first — every tool call before full initialization is blocked here.
|
|
63
|
+
// After success it returns `undefined` and the accepted guard handler makes the decision.
|
|
64
|
+
extensionHost.on('tool_call', () => {
|
|
65
|
+
if (initialized)
|
|
66
|
+
return undefined;
|
|
67
|
+
return {
|
|
68
|
+
block: true,
|
|
69
|
+
reason: `pappra-bootstrap: ${deniedReason ?? 'not-initialized'}`,
|
|
70
|
+
};
|
|
71
|
+
});
|
|
72
|
+
try {
|
|
73
|
+
extensionHost.registerCommand('bootstrap-status', {
|
|
74
|
+
description: 'Report bootstrap gate registration only (never write permission).',
|
|
75
|
+
handler: (_args, context) => {
|
|
76
|
+
notify(context, JSON.stringify(status()));
|
|
77
|
+
},
|
|
78
|
+
});
|
|
79
|
+
const loaded = readPiBootstrapConfig(configPath());
|
|
80
|
+
if (loaded.ok === false) {
|
|
81
|
+
deniedReason = `${loaded.code}: ${loaded.message}`;
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
config = loaded.config;
|
|
85
|
+
configDigest = loaded.digest;
|
|
86
|
+
const registered = registerPiBootstrapRuntime(pi, runtimeConfigOf(loaded.config));
|
|
87
|
+
// The accepted lifecycle extension is attached unchanged after the gate.
|
|
88
|
+
createPiExtension(pi);
|
|
89
|
+
guard = registered;
|
|
90
|
+
initialized = true;
|
|
91
|
+
}
|
|
92
|
+
catch (error) {
|
|
93
|
+
try {
|
|
94
|
+
deniedReason = boundedReason(error);
|
|
95
|
+
}
|
|
96
|
+
catch {
|
|
97
|
+
deniedReason = 'initialization failed';
|
|
98
|
+
}
|
|
99
|
+
initialized = false;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Opt-in successor-bootstrap managed-tool gate (one rollover prerequisite).
|
|
3
|
+
*
|
|
4
|
+
* A separately opt-in Pi `tool_call` guard for the NEW (successor) writer session during a rollover.
|
|
5
|
+
* Registered before any model work, it starts DENIED for every non-vetted-read managed tool
|
|
6
|
+
* (bash/write/edit and any unknown/custom tool); only the fixed vetted native-read set reused from the
|
|
7
|
+
* accepted freeze module is ever allowed, and only for the exact pinned native session. It permits the
|
|
8
|
+
* successor's first non-read tool ONLY after the authoritative, validated current task record proves the
|
|
9
|
+
* completed writer transfer to the pinned successor — read fresh on EVERY call. It does not require a
|
|
10
|
+
* first-work REPORT to permit the first write; that proof comes afterward.
|
|
11
|
+
*
|
|
12
|
+
* Authority is validated against the record itself for cross-record CONSISTENCY, not merely schema
|
|
13
|
+
* validity: the pinned intent in `record.rollover`, the completed WRITER `record.handoffs` entry (kind,
|
|
14
|
+
* subtask/attempt, coordinator epoch, exact from/to, resources and ownership snapshot consistent with the
|
|
15
|
+
* intent), a transfer boundary bounded by the current record and history, the latest actionable attempt
|
|
16
|
+
* owned by the successor with `ownership:'transferred'` and its full confirmed native binding, and every
|
|
17
|
+
* original claim held by the successor at `original + 1`. Duplicate or ambiguous ids anywhere block rather
|
|
18
|
+
* than letting a first-match lookup resolve contradictory records to allow. Every check is fail-closed: a
|
|
19
|
+
* malformed event, a throwing property/record accessor, or any traversal/validation failure returns an
|
|
20
|
+
* explicit block and never escapes into host default behavior.
|
|
21
|
+
*
|
|
22
|
+
* What it is NOT: it is not a transfer action, a stop/quiescence inference, an authority store, or a
|
|
23
|
+
* filesystem/cross-process write fence. It never mutates claims, epochs, handoffs, bindings, messages,
|
|
24
|
+
* the bundle or the archive; it never feeds observations into the freeze controller; it adds no timer,
|
|
25
|
+
* watcher, spawned command, transcript access, network or model call. There is no model-accessible allow/
|
|
26
|
+
* thaw/release method and no boolean authorization callback. The record comes only from an explicitly
|
|
27
|
+
* trusted, read-only host adapter supplied at registration that returns record DATA (never `allowed:true`,
|
|
28
|
+
* a self-signed token or an invented stop proof); this slice does not authenticate a filesystem/remote
|
|
29
|
+
* source, establish freshness against a dishonest adapter, or install a durable reader — a later real
|
|
30
|
+
* adapter must bind and read the actual task domain safely, and this is not complete native authorization.
|
|
31
|
+
*
|
|
32
|
+
* There is no filesystem lock covering a tool's later execution: the guard answers the call-time question
|
|
33
|
+
* only (check/use gap), and background/external processes and effects outside managed Pi tools are never
|
|
34
|
+
* fenced.
|
|
35
|
+
*
|
|
36
|
+
* Installed Pi 1.3.0 `tool_call` blocking contract and the vetted native-read set are reused from the
|
|
37
|
+
* accepted `pi-rollover-extension.ts`; the running session is read from `ctx.sessionManager.getSessionId()`
|
|
38
|
+
* (pinned API). Structural compatibility is not a shipped-declaration or live-load proof.
|
|
39
|
+
*/
|
|
40
|
+
import { type PiToolBlockDecision, type PiToolCallEvent } from './pi-rollover-extension.js';
|
|
41
|
+
export declare const PI_BOOTSTRAP_GUARD_STATUS_SCHEMA = "pappra/pi-bootstrap-guard-status/1";
|
|
42
|
+
export interface BootstrapGuardIdentity {
|
|
43
|
+
readonly agentId: string;
|
|
44
|
+
readonly sessionId: string;
|
|
45
|
+
readonly harness: string;
|
|
46
|
+
}
|
|
47
|
+
/** One pinned ORIGINAL claim: the guard requires the current claim at `originalResourceEpoch + 1`. */
|
|
48
|
+
export interface BootstrapGuardClaim {
|
|
49
|
+
readonly claimId: string;
|
|
50
|
+
readonly originalResourceEpoch: number;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* The explicitly trusted, read-only host adapter. It returns the current full task record DATA, or
|
|
54
|
+
* throws/returns a non-record on failure (treated conservatively as a block). It never returns an allow
|
|
55
|
+
* decision, a token or a stop proof. In tests this is a fixture; a later real adapter binds and reads the
|
|
56
|
+
* authoritative task domain. This slice does not authenticate or install it.
|
|
57
|
+
*/
|
|
58
|
+
export type TrustedRecordReader = () => unknown | Promise<unknown>;
|
|
59
|
+
export interface BootstrapGuardOptions {
|
|
60
|
+
readonly taskId: string;
|
|
61
|
+
readonly intentId: string;
|
|
62
|
+
readonly handoffId: string;
|
|
63
|
+
readonly generation: number;
|
|
64
|
+
readonly subtaskId: string;
|
|
65
|
+
readonly attempt: number;
|
|
66
|
+
readonly inputRevision: string;
|
|
67
|
+
readonly coordinatorEpoch: number;
|
|
68
|
+
readonly successor: BootstrapGuardIdentity;
|
|
69
|
+
readonly claims: readonly BootstrapGuardClaim[];
|
|
70
|
+
readonly readRecord: TrustedRecordReader;
|
|
71
|
+
}
|
|
72
|
+
interface PinnedConfig {
|
|
73
|
+
readonly taskId: string;
|
|
74
|
+
readonly intentId: string;
|
|
75
|
+
readonly handoffId: string;
|
|
76
|
+
readonly generation: number;
|
|
77
|
+
readonly subtaskId: string;
|
|
78
|
+
readonly attempt: number;
|
|
79
|
+
readonly inputRevision: string;
|
|
80
|
+
readonly coordinatorEpoch: number;
|
|
81
|
+
readonly successor: BootstrapGuardIdentity;
|
|
82
|
+
readonly claims: readonly BootstrapGuardClaim[];
|
|
83
|
+
}
|
|
84
|
+
export interface BootstrapDecision {
|
|
85
|
+
readonly allow: boolean;
|
|
86
|
+
readonly reason: string;
|
|
87
|
+
}
|
|
88
|
+
export interface BootstrapGuardStatus {
|
|
89
|
+
readonly schema: typeof PI_BOOTSTRAP_GUARD_STATUS_SCHEMA;
|
|
90
|
+
readonly taskId: string;
|
|
91
|
+
readonly intentId: string;
|
|
92
|
+
readonly handoffId: string;
|
|
93
|
+
readonly generation: number;
|
|
94
|
+
readonly subtaskId: string;
|
|
95
|
+
readonly attempt: number;
|
|
96
|
+
readonly coordinatorEpoch: number;
|
|
97
|
+
readonly successor: BootstrapGuardIdentity;
|
|
98
|
+
readonly pinnedClaimCount: number;
|
|
99
|
+
readonly mode: 'deny-until-completed-transfer';
|
|
100
|
+
readonly vettedReadTools: readonly string[];
|
|
101
|
+
readonly limitations: readonly string[];
|
|
102
|
+
}
|
|
103
|
+
export interface PiToolCallHandler {
|
|
104
|
+
(event: PiToolCallEvent, context: unknown): Promise<PiToolBlockDecision | undefined>;
|
|
105
|
+
}
|
|
106
|
+
/** Narrow structural host: only a `tool_call` subscription is needed (no model-accessible command). */
|
|
107
|
+
export interface PiBootstrapGuardHost {
|
|
108
|
+
on(event: 'tool_call', handler: PiToolCallHandler): void;
|
|
109
|
+
}
|
|
110
|
+
export interface PiBootstrapGuard {
|
|
111
|
+
status(): BootstrapGuardStatus;
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Pure decision over the current record. Allows a non-read tool only when the validated record proves a
|
|
115
|
+
* consistent completed WRITER transfer to the pinned successor. First-work is NOT required. Any traversal
|
|
116
|
+
* or accessor failure fails closed.
|
|
117
|
+
*/
|
|
118
|
+
export declare function decideBootstrapWrite(record: unknown, pinned: PinnedConfig, liveSessionId: string | null): BootstrapDecision;
|
|
119
|
+
/**
|
|
120
|
+
* Register the opt-in successor bootstrap gate on `pi`. It only subscribes `tool_call`; it registers no
|
|
121
|
+
* model-accessible command, removes no tools/MCP/skills/hooks, and mutates nothing. The returned handle
|
|
122
|
+
* exposes a conservative frozen status only — no allow/thaw/release.
|
|
123
|
+
*/
|
|
124
|
+
export declare function registerPiBootstrapGuard(pi: PiBootstrapGuardHost, options: BootstrapGuardOptions): PiBootstrapGuard;
|
|
125
|
+
export {};
|