@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,54 @@
|
|
|
1
|
+
import type { ManagedPiReadinessConfig } from './managed-pi-readiness.js';
|
|
2
|
+
import type { ManagedPiExecutionScope } from './collab-session-transition.js';
|
|
3
|
+
import type { ManagedPiInitialAdmissionConfig } from './managed-pi-initial-admission.js';
|
|
4
|
+
import type { ManagedPiResumeConfig } from './managed-pi-resume-admission.js';
|
|
5
|
+
export declare const MANAGED_PI_REQUEST_SCHEMA = "pappra/managed-pi-session-request/1";
|
|
6
|
+
export interface ManagedPiRequest {
|
|
7
|
+
readonly schema: typeof MANAGED_PI_REQUEST_SCHEMA;
|
|
8
|
+
readonly cwd: string;
|
|
9
|
+
readonly model: string;
|
|
10
|
+
readonly journalPath: string;
|
|
11
|
+
readonly controlSocketPath?: string;
|
|
12
|
+
readonly piBin?: string;
|
|
13
|
+
readonly pythonBin?: string;
|
|
14
|
+
readonly shutdownGraceMs?: number;
|
|
15
|
+
readonly readiness?: ManagedPiReadinessConfig;
|
|
16
|
+
readonly runtime?: 'pty' | 'sdk';
|
|
17
|
+
readonly sdkModulePath?: string;
|
|
18
|
+
readonly sessionId?: string;
|
|
19
|
+
readonly automaticHandoffFile?: string;
|
|
20
|
+
readonly executionScope?: ManagedPiExecutionScope;
|
|
21
|
+
readonly initialAssignment?: ManagedPiInitialAdmissionConfig;
|
|
22
|
+
readonly resume?: ManagedPiResumeConfig;
|
|
23
|
+
readonly bootstrapExtensionPath?: string;
|
|
24
|
+
readonly handoffContextFile?: string;
|
|
25
|
+
readonly herdrAgentName?: string;
|
|
26
|
+
readonly herdrPaneId?: string;
|
|
27
|
+
readonly thinkingLevel?: 'off' | 'minimal' | 'low' | 'medium' | 'high' | 'xhigh' | 'max';
|
|
28
|
+
}
|
|
29
|
+
/** Validate a bounded launch request without creating a process, socket or file. */
|
|
30
|
+
export declare function readManagedPiRequest(file: string): ManagedPiRequest;
|
|
31
|
+
export declare function planManagedPiSession(request: ManagedPiRequest): {
|
|
32
|
+
readonly schema: 'pappra/managed-pi-session-plan/1';
|
|
33
|
+
readonly cwd: string;
|
|
34
|
+
readonly provider: 'openrouter';
|
|
35
|
+
readonly model: string;
|
|
36
|
+
readonly journal_path: string;
|
|
37
|
+
readonly control_descriptor: `${string}.control.json`;
|
|
38
|
+
readonly native_tui: true;
|
|
39
|
+
readonly runtime: "pty" | "sdk";
|
|
40
|
+
readonly launch_kind: "controlled-resume" | "fresh-session";
|
|
41
|
+
readonly resume: {
|
|
42
|
+
source_journal: string;
|
|
43
|
+
authority: string;
|
|
44
|
+
} | null;
|
|
45
|
+
readonly daily_configuration: 'preserved';
|
|
46
|
+
readonly transfer_safe_quiescence: 'unavailable';
|
|
47
|
+
readonly owned_runtime_quiescence: "pinned-version-runtime-scope" | "unavailable";
|
|
48
|
+
readonly execution_scope: "requires-live-task-binding" | null;
|
|
49
|
+
readonly effect: 'none';
|
|
50
|
+
readonly readiness: {
|
|
51
|
+
mode: string;
|
|
52
|
+
cardFile: string;
|
|
53
|
+
} | null;
|
|
54
|
+
};
|
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { readBoundedFile } from './bounded-file.js';
|
|
4
|
+
export const MANAGED_PI_REQUEST_SCHEMA = 'pappra/managed-pi-session-request/1';
|
|
5
|
+
/** Validate a bounded launch request without creating a process, socket or file. */
|
|
6
|
+
export function readManagedPiRequest(file) {
|
|
7
|
+
const loaded = readBoundedFile(file, 64 * 1024);
|
|
8
|
+
if (!loaded.ok)
|
|
9
|
+
throw new Error(`Managed Pi request refused: ${loaded.code}.`);
|
|
10
|
+
let value;
|
|
11
|
+
try {
|
|
12
|
+
value = JSON.parse(loaded.text);
|
|
13
|
+
}
|
|
14
|
+
catch {
|
|
15
|
+
throw new Error('Managed Pi request must be JSON.');
|
|
16
|
+
}
|
|
17
|
+
if (typeof value !== 'object' || value === null || Array.isArray(value))
|
|
18
|
+
throw new Error('Managed Pi request must be an object.');
|
|
19
|
+
const raw = value;
|
|
20
|
+
const keys = new Set([
|
|
21
|
+
'schema',
|
|
22
|
+
'cwd',
|
|
23
|
+
'model',
|
|
24
|
+
'journalPath',
|
|
25
|
+
'controlSocketPath',
|
|
26
|
+
'piBin',
|
|
27
|
+
'pythonBin',
|
|
28
|
+
'shutdownGraceMs',
|
|
29
|
+
'readiness',
|
|
30
|
+
'runtime',
|
|
31
|
+
'sdkModulePath',
|
|
32
|
+
'sessionId',
|
|
33
|
+
'automaticHandoffFile',
|
|
34
|
+
'executionScope',
|
|
35
|
+
'initialAssignment',
|
|
36
|
+
'resume',
|
|
37
|
+
'bootstrapExtensionPath',
|
|
38
|
+
'handoffContextFile',
|
|
39
|
+
'herdrAgentName',
|
|
40
|
+
'herdrPaneId',
|
|
41
|
+
'thinkingLevel',
|
|
42
|
+
]);
|
|
43
|
+
if (Object.keys(raw).some((key) => !keys.has(key)) ||
|
|
44
|
+
raw.schema !== MANAGED_PI_REQUEST_SCHEMA)
|
|
45
|
+
throw new Error('Managed Pi request has an unsupported schema or field.');
|
|
46
|
+
for (const key of ['cwd', 'model', 'journalPath']) {
|
|
47
|
+
if (typeof raw[key] !== 'string' ||
|
|
48
|
+
!raw[key] ||
|
|
49
|
+
raw[key].length > 4096 ||
|
|
50
|
+
raw[key].includes('\0'))
|
|
51
|
+
throw new Error(`Managed Pi request requires ${key}.`);
|
|
52
|
+
}
|
|
53
|
+
for (const key of ['piBin', 'pythonBin', 'controlSocketPath']) {
|
|
54
|
+
const field = raw[key];
|
|
55
|
+
if (field !== undefined &&
|
|
56
|
+
(typeof field !== 'string' ||
|
|
57
|
+
!field ||
|
|
58
|
+
field.length > 4096 ||
|
|
59
|
+
field.includes('\0')))
|
|
60
|
+
throw new Error(`Managed Pi request has an invalid ${key}.`);
|
|
61
|
+
}
|
|
62
|
+
for (const key of ['cwd', 'journalPath', 'controlSocketPath']) {
|
|
63
|
+
if (raw[key] !== undefined && !path.isAbsolute(raw[key]))
|
|
64
|
+
throw new Error(`${key} must be absolute.`);
|
|
65
|
+
}
|
|
66
|
+
if (!fs.statSync(raw.cwd).isDirectory())
|
|
67
|
+
throw new Error('cwd must be an existing directory.');
|
|
68
|
+
if (raw.runtime !== undefined &&
|
|
69
|
+
!['pty', 'sdk'].includes(raw.runtime))
|
|
70
|
+
throw new Error('runtime must be pty or sdk.');
|
|
71
|
+
if (raw.runtime === 'sdk') {
|
|
72
|
+
if (raw.resume !== undefined) {
|
|
73
|
+
const resume = raw.resume;
|
|
74
|
+
if (!resume ||
|
|
75
|
+
typeof resume !== 'object' ||
|
|
76
|
+
Array.isArray(resume) ||
|
|
77
|
+
Object.keys(resume).length !== 3 ||
|
|
78
|
+
!['sourceJournalPath', 'sourceSessionFile'].every((key) => typeof resume[key] === 'string' &&
|
|
79
|
+
path.isAbsolute(resume[key]) &&
|
|
80
|
+
!resume[key].includes('\0')) ||
|
|
81
|
+
typeof resume.sourceRunId !== 'string' ||
|
|
82
|
+
!/^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/.test(resume.sourceRunId) ||
|
|
83
|
+
raw.journalPath === resume.sourceJournalPath ||
|
|
84
|
+
!raw.executionScope ||
|
|
85
|
+
!raw.sessionId ||
|
|
86
|
+
raw.initialAssignment !== undefined ||
|
|
87
|
+
raw.bootstrapExtensionPath !== undefined ||
|
|
88
|
+
raw.handoffContextFile !== undefined ||
|
|
89
|
+
raw.automaticHandoffFile !== undefined)
|
|
90
|
+
throw new Error('resume requires exact source pins, a new journal and one immediate SDK task scope.');
|
|
91
|
+
}
|
|
92
|
+
if (raw.initialAssignment !== undefined) {
|
|
93
|
+
const initial = raw.initialAssignment;
|
|
94
|
+
const required = [
|
|
95
|
+
'taskRoot',
|
|
96
|
+
'assignmentFile',
|
|
97
|
+
'subtaskId',
|
|
98
|
+
'attempt',
|
|
99
|
+
'ownerEpoch',
|
|
100
|
+
'inputRevision',
|
|
101
|
+
];
|
|
102
|
+
if (!initial ||
|
|
103
|
+
typeof initial !== 'object' ||
|
|
104
|
+
Array.isArray(initial) ||
|
|
105
|
+
Object.keys(initial).length !== required.length ||
|
|
106
|
+
Object.keys(initial).some((key) => !required.includes(key)) ||
|
|
107
|
+
!['taskRoot', 'assignmentFile'].every((key) => typeof initial[key] === 'string' &&
|
|
108
|
+
path.isAbsolute(initial[key]) &&
|
|
109
|
+
!initial[key].includes('\0')) ||
|
|
110
|
+
typeof initial.subtaskId !== 'string' ||
|
|
111
|
+
!/^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/.test(initial.subtaskId) ||
|
|
112
|
+
!Number.isSafeInteger(initial.attempt) ||
|
|
113
|
+
Number(initial.attempt) < 1 ||
|
|
114
|
+
!Number.isSafeInteger(initial.ownerEpoch) ||
|
|
115
|
+
Number(initial.ownerEpoch) < 1 ||
|
|
116
|
+
typeof initial.inputRevision !== 'string' ||
|
|
117
|
+
!/^sha256:[a-f0-9]{64}$/.test(initial.inputRevision) ||
|
|
118
|
+
raw.executionScope !== undefined ||
|
|
119
|
+
raw.bootstrapExtensionPath !== undefined ||
|
|
120
|
+
raw.automaticHandoffFile !== undefined ||
|
|
121
|
+
!raw.sessionId)
|
|
122
|
+
throw new Error('initialAssignment requires a fresh SDK session and one explicit deferred task scope.');
|
|
123
|
+
}
|
|
124
|
+
if (raw.handoffContextFile !== undefined &&
|
|
125
|
+
(typeof raw.handoffContextFile !== 'string' ||
|
|
126
|
+
!path.isAbsolute(raw.handoffContextFile) ||
|
|
127
|
+
raw.handoffContextFile.includes('\0') ||
|
|
128
|
+
raw.bootstrapExtensionPath === undefined))
|
|
129
|
+
throw new Error('handoffContextFile requires an absolute bootstrap-bound SDK context reference.');
|
|
130
|
+
if (raw.thinkingLevel !== undefined &&
|
|
131
|
+
!['off', 'minimal', 'low', 'medium', 'high', 'xhigh', 'max'].includes(String(raw.thinkingLevel)))
|
|
132
|
+
throw new Error('thinkingLevel is unsupported.');
|
|
133
|
+
if (raw.bootstrapExtensionPath !== undefined &&
|
|
134
|
+
(typeof raw.bootstrapExtensionPath !== 'string' ||
|
|
135
|
+
!path.isAbsolute(raw.bootstrapExtensionPath) ||
|
|
136
|
+
raw.bootstrapExtensionPath.includes('\0')))
|
|
137
|
+
throw new Error('bootstrapExtensionPath must be absolute.');
|
|
138
|
+
if (raw.herdrAgentName !== undefined &&
|
|
139
|
+
(typeof raw.herdrAgentName !== 'string' ||
|
|
140
|
+
!/^[a-z][a-z0-9_-]{0,31}$/.test(raw.herdrAgentName)))
|
|
141
|
+
throw new Error('herdrAgentName must be a valid agent name.');
|
|
142
|
+
if (raw.herdrPaneId !== undefined &&
|
|
143
|
+
(typeof raw.herdrPaneId !== 'string' ||
|
|
144
|
+
!/^[A-Za-z0-9]+:p[A-Za-z0-9]+$/.test(raw.herdrPaneId)))
|
|
145
|
+
throw new Error('herdrPaneId must be a valid pane id.');
|
|
146
|
+
if (raw.executionScope !== undefined) {
|
|
147
|
+
const scope = raw.executionScope;
|
|
148
|
+
if (typeof scope !== 'object' ||
|
|
149
|
+
scope === null ||
|
|
150
|
+
Array.isArray(scope) ||
|
|
151
|
+
!('schema' in scope) ||
|
|
152
|
+
scope.schema !== 'pappra/managed-pi-execution-scope/1' ||
|
|
153
|
+
!('session_id' in scope) ||
|
|
154
|
+
scope.session_id !== raw.sessionId ||
|
|
155
|
+
!('cwd' in scope) ||
|
|
156
|
+
scope.cwd !== raw.cwd)
|
|
157
|
+
throw new Error('executionScope must match the SDK session and cwd.');
|
|
158
|
+
}
|
|
159
|
+
if (typeof raw.sdkModulePath !== 'string' ||
|
|
160
|
+
!path.isAbsolute(raw.sdkModulePath) ||
|
|
161
|
+
raw.sdkModulePath.includes('\0'))
|
|
162
|
+
throw new Error('SDK mode requires an absolute sdkModulePath.');
|
|
163
|
+
if (raw.sessionId !== undefined &&
|
|
164
|
+
(typeof raw.sessionId !== 'string' ||
|
|
165
|
+
!/^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(raw.sessionId)))
|
|
166
|
+
throw new Error('SDK sessionId must be a UUID.');
|
|
167
|
+
if (raw.automaticHandoffFile !== undefined &&
|
|
168
|
+
(typeof raw.automaticHandoffFile !== 'string' ||
|
|
169
|
+
!path.isAbsolute(raw.automaticHandoffFile) ||
|
|
170
|
+
raw.automaticHandoffFile.includes('\0')))
|
|
171
|
+
throw new Error('automaticHandoffFile must be absolute.');
|
|
172
|
+
if (raw.piBin !== undefined ||
|
|
173
|
+
raw.pythonBin !== undefined ||
|
|
174
|
+
raw.shutdownGraceMs !== undefined)
|
|
175
|
+
throw new Error('SDK mode does not accept PTY process options.');
|
|
176
|
+
}
|
|
177
|
+
else if (raw.sdkModulePath !== undefined ||
|
|
178
|
+
raw.sessionId !== undefined ||
|
|
179
|
+
raw.automaticHandoffFile !== undefined ||
|
|
180
|
+
raw.executionScope !== undefined ||
|
|
181
|
+
raw.initialAssignment !== undefined ||
|
|
182
|
+
raw.resume !== undefined ||
|
|
183
|
+
raw.bootstrapExtensionPath !== undefined ||
|
|
184
|
+
raw.herdrAgentName !== undefined ||
|
|
185
|
+
raw.herdrPaneId !== undefined ||
|
|
186
|
+
raw.thinkingLevel !== undefined ||
|
|
187
|
+
raw.handoffContextFile !== undefined) {
|
|
188
|
+
throw new Error('SDK options require runtime sdk.');
|
|
189
|
+
}
|
|
190
|
+
if (raw.model.startsWith('-') ||
|
|
191
|
+
/[\r\n]/.test(raw.model))
|
|
192
|
+
throw new Error('model must be a native Pi model identifier.');
|
|
193
|
+
if (raw.shutdownGraceMs !== undefined &&
|
|
194
|
+
(!Number.isSafeInteger(raw.shutdownGraceMs) ||
|
|
195
|
+
raw.shutdownGraceMs < 1 ||
|
|
196
|
+
raw.shutdownGraceMs > 30_000))
|
|
197
|
+
throw new Error('shutdownGraceMs must be between 1 and 30000.');
|
|
198
|
+
if (raw.readiness !== undefined) {
|
|
199
|
+
const readiness = raw.readiness;
|
|
200
|
+
if (typeof readiness !== 'object' ||
|
|
201
|
+
readiness === null ||
|
|
202
|
+
Array.isArray(readiness))
|
|
203
|
+
throw new Error('readiness must pin assignmentFile, templateFile and cardFile.');
|
|
204
|
+
const fields = readiness;
|
|
205
|
+
if (Object.keys(fields).sort().join('|') !==
|
|
206
|
+
'assignmentFile|cardFile|templateFile' ||
|
|
207
|
+
Object.values(fields).some((field) => typeof field !== 'string' ||
|
|
208
|
+
!path.isAbsolute(field) ||
|
|
209
|
+
field.includes('\0') ||
|
|
210
|
+
field.length > 4096))
|
|
211
|
+
throw new Error('readiness requires three absolute file paths.');
|
|
212
|
+
if (new Set(Object.values(fields).map((file) => path.resolve(file)))
|
|
213
|
+
.size !== 3)
|
|
214
|
+
throw new Error('readiness inputs and output must be separate files.');
|
|
215
|
+
}
|
|
216
|
+
return value;
|
|
217
|
+
}
|
|
218
|
+
export function planManagedPiSession(request) {
|
|
219
|
+
return {
|
|
220
|
+
schema: 'pappra/managed-pi-session-plan/1',
|
|
221
|
+
cwd: fs.realpathSync(request.cwd),
|
|
222
|
+
provider: 'openrouter',
|
|
223
|
+
model: request.model,
|
|
224
|
+
journal_path: request.journalPath,
|
|
225
|
+
control_descriptor: `${request.journalPath}.control.json`,
|
|
226
|
+
native_tui: true,
|
|
227
|
+
runtime: request.runtime ?? 'pty',
|
|
228
|
+
launch_kind: request.resume ? 'controlled-resume' : 'fresh-session',
|
|
229
|
+
resume: request.resume
|
|
230
|
+
? {
|
|
231
|
+
source_journal: request.resume.sourceJournalPath,
|
|
232
|
+
authority: 'requires-dead-source-checkpoint-and-task-reservation',
|
|
233
|
+
}
|
|
234
|
+
: null,
|
|
235
|
+
daily_configuration: 'preserved',
|
|
236
|
+
transfer_safe_quiescence: 'unavailable',
|
|
237
|
+
owned_runtime_quiescence: request.runtime === 'sdk'
|
|
238
|
+
? 'pinned-version-runtime-scope'
|
|
239
|
+
: 'unavailable',
|
|
240
|
+
execution_scope: request.executionScope
|
|
241
|
+
? 'requires-live-task-binding'
|
|
242
|
+
: null,
|
|
243
|
+
effect: 'none',
|
|
244
|
+
readiness: request.readiness
|
|
245
|
+
? { mode: 'native-resource-events', cardFile: request.readiness.cardFile }
|
|
246
|
+
: null,
|
|
247
|
+
};
|
|
248
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import type { HerdrBootstrapOps } from './collab-bootstrap-transport.js';
|
|
2
|
+
export declare const SHELL_READINESS_BUDGET_MS = 10000;
|
|
3
|
+
export declare const SHELL_READINESS_INTERVAL_MS = 100;
|
|
4
|
+
export declare const SHELL_READINESS_MAX_SAMPLES = 100;
|
|
5
|
+
export type ShellReadinessStatus = 'ready' | 'unknown' | 'timeout' | 'aborted' | 'failed';
|
|
6
|
+
export type ShellSampleState = 'ready' | 'unknown' | 'not_ready' | 'failed';
|
|
7
|
+
export interface ShellReadinessSample {
|
|
8
|
+
readonly elapsed_ms: number;
|
|
9
|
+
readonly state: ShellSampleState;
|
|
10
|
+
readonly code: string | null;
|
|
11
|
+
readonly shell_pid: number | null;
|
|
12
|
+
readonly foreground_process_group_id: number | null;
|
|
13
|
+
readonly shell_name: string | null;
|
|
14
|
+
readonly foreground_processes: readonly {
|
|
15
|
+
readonly pid: number;
|
|
16
|
+
readonly name: string;
|
|
17
|
+
}[];
|
|
18
|
+
readonly processes_truncated: number;
|
|
19
|
+
}
|
|
20
|
+
export interface ShellReadinessEvidence {
|
|
21
|
+
readonly state: ShellReadinessStatus;
|
|
22
|
+
readonly code: string | null;
|
|
23
|
+
readonly attempts: number;
|
|
24
|
+
readonly elapsed_ms: number;
|
|
25
|
+
readonly pane_id: string;
|
|
26
|
+
readonly workspace_id: string;
|
|
27
|
+
readonly terminal_id: string;
|
|
28
|
+
readonly cwd: string;
|
|
29
|
+
readonly shell_pid: number | null;
|
|
30
|
+
readonly foreground_process_group_id: number | null;
|
|
31
|
+
readonly shell_name: string | null;
|
|
32
|
+
readonly last_state: ShellSampleState | 'not_observed';
|
|
33
|
+
readonly last_code: string | null;
|
|
34
|
+
readonly limits: {
|
|
35
|
+
readonly budget_ms: number;
|
|
36
|
+
readonly interval_ms: number;
|
|
37
|
+
readonly max_samples: number;
|
|
38
|
+
readonly samples_truncated: number;
|
|
39
|
+
};
|
|
40
|
+
readonly samples: readonly ShellReadinessSample[];
|
|
41
|
+
}
|
|
42
|
+
export interface ShellReadinessResult {
|
|
43
|
+
readonly status: ShellReadinessStatus;
|
|
44
|
+
readonly code: string | null;
|
|
45
|
+
readonly evidence: ShellReadinessEvidence;
|
|
46
|
+
}
|
|
47
|
+
export interface ShellReadinessOptions {
|
|
48
|
+
readonly budgetMs?: number;
|
|
49
|
+
readonly intervalMs?: number;
|
|
50
|
+
readonly maxSamples?: number;
|
|
51
|
+
readonly clock?: () => number;
|
|
52
|
+
readonly sleeper?: (milliseconds: number) => Promise<void>;
|
|
53
|
+
readonly shouldAbort?: () => boolean;
|
|
54
|
+
}
|
|
55
|
+
export interface ShellReadinessIdentity {
|
|
56
|
+
readonly paneId: string;
|
|
57
|
+
readonly workspaceId: string;
|
|
58
|
+
readonly terminalId: string;
|
|
59
|
+
readonly cwd: string;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Verifies the installed Herdr available-shell predicate for one already owned pane.
|
|
63
|
+
* Process readiness is bounded local polling in the caller's single apply operation;
|
|
64
|
+
* it is not an event signal, a model wakeup, or an agent-completion wait.
|
|
65
|
+
*/
|
|
66
|
+
export declare function verifyAvailableShell(ops: HerdrBootstrapOps, identity: ShellReadinessIdentity, options?: ShellReadinessOptions): Promise<ShellReadinessResult>;
|