@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
|
@@ -36,6 +36,13 @@ export declare const HOST_SUPPORT: {
|
|
|
36
36
|
};
|
|
37
37
|
export declare function nativeEventFor(host: HostName, event: HostLifecycleEvent): string | null;
|
|
38
38
|
export declare function isSupportedVersion(host: HostName, version: string | null): boolean;
|
|
39
|
+
/** Only versions with bounded local event/loader evidence are admitted here.
|
|
40
|
+
* The owned SDK adapter has a separate exact version/private-source contract. */
|
|
41
|
+
export declare const HOST_EVENT_VERSIONS: {
|
|
42
|
+
readonly pi: readonly ['1.3.0', '1.4.0'];
|
|
43
|
+
readonly codex: readonly ['0.163.0', '0.164.0'];
|
|
44
|
+
readonly claude: readonly ['2.1.292', '2.1.308'];
|
|
45
|
+
};
|
|
39
46
|
export declare function surfaceFor(host: HostName): (typeof HOST_SUPPORT)[HostName]['surface'];
|
|
40
47
|
/**
|
|
41
48
|
* Observed plugin-hook support. `verified` means a real host session produced a
|
|
@@ -39,8 +39,16 @@ export function nativeEventFor(host, event) {
|
|
|
39
39
|
return HOST_SUPPORT[host].events[event];
|
|
40
40
|
}
|
|
41
41
|
export function isSupportedVersion(host, version) {
|
|
42
|
-
return version
|
|
42
|
+
return (version !== null &&
|
|
43
|
+
HOST_EVENT_VERSIONS[host].some((observed) => observed === version));
|
|
43
44
|
}
|
|
45
|
+
/** Only versions with bounded local event/loader evidence are admitted here.
|
|
46
|
+
* The owned SDK adapter has a separate exact version/private-source contract. */
|
|
47
|
+
export const HOST_EVENT_VERSIONS = {
|
|
48
|
+
pi: ['1.3.0', '1.4.0'],
|
|
49
|
+
codex: ['0.163.0', '0.164.0'],
|
|
50
|
+
claude: ['2.1.292', '2.1.308'],
|
|
51
|
+
};
|
|
44
52
|
export function surfaceFor(host) {
|
|
45
53
|
return HOST_SUPPORT[host].surface;
|
|
46
54
|
}
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import type { HostName, HostLifecycleEvent } from '../../schemas/host.js';
|
|
2
2
|
export declare const PAPPRA_MANAGED_MARKER = "pappra-managed";
|
|
3
|
+
export declare const MIN_HOOK_TIMEOUT_SECONDS = 5;
|
|
3
4
|
export interface RenderedHostTemplate {
|
|
4
5
|
readonly path: string;
|
|
5
6
|
readonly bytes: Buffer;
|
|
6
7
|
readonly kind: 'extension' | 'hook';
|
|
7
8
|
}
|
|
8
9
|
export declare function renderHookCommand(host: HostName, event: HostLifecycleEvent, hookExpression: string): string;
|
|
10
|
+
/** Recognizes only our exact script/host/event/marker suffix and a Node runner. */
|
|
11
|
+
export declare function isManagedHookCommand(command: string, expectedCommands: ReadonlySet<string>): boolean;
|
|
9
12
|
interface HookEntry {
|
|
10
13
|
readonly hooks: readonly {
|
|
11
14
|
readonly type: 'command';
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import { basename } from 'node:path';
|
|
1
|
+
import { basename, isAbsolute } from 'node:path';
|
|
2
2
|
export const PAPPRA_MANAGED_MARKER = 'pappra-managed';
|
|
3
|
+
// Covers bounded stdin collection plus lifecycle work and process startup.
|
|
4
|
+
export const MIN_HOOK_TIMEOUT_SECONDS = 5;
|
|
3
5
|
function shellQuote(value) {
|
|
4
6
|
return `'${value.replaceAll("'", "'\\''")}'`;
|
|
5
7
|
}
|
|
@@ -11,7 +13,28 @@ function pathExpression(value) {
|
|
|
11
13
|
return value.includes('${') ? `"${value}"` : shellQuote(value);
|
|
12
14
|
}
|
|
13
15
|
export function renderHookCommand(host, event, hookExpression) {
|
|
14
|
-
return
|
|
16
|
+
return `node ${pathExpression(hookExpression)} ${shellQuote(host)} ${shellQuote(event)} # ${PAPPRA_MANAGED_MARKER}`;
|
|
17
|
+
}
|
|
18
|
+
/** Recognizes only our exact script/host/event/marker suffix and a Node runner. */
|
|
19
|
+
export function isManagedHookCommand(command, expectedCommands) {
|
|
20
|
+
for (const expected of expectedCommands) {
|
|
21
|
+
if (command === expected)
|
|
22
|
+
return true;
|
|
23
|
+
const suffix = expected.slice('node'.length);
|
|
24
|
+
if (!command.endsWith(suffix))
|
|
25
|
+
continue;
|
|
26
|
+
const runner = command.slice(0, -suffix.length);
|
|
27
|
+
// Previous packages single-quoted process.execPath. Recognize that one
|
|
28
|
+
// shell word without interpreting arbitrary shell syntax or user commands.
|
|
29
|
+
if (!/^'(?:[^']|'\\'')*'$/.test(runner))
|
|
30
|
+
continue;
|
|
31
|
+
const executable = runner.slice(1, -1).replaceAll("'\\''", "'");
|
|
32
|
+
if (isAbsolute(executable) &&
|
|
33
|
+
['node', 'node.exe'].includes(basename(executable))) {
|
|
34
|
+
return true;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
return false;
|
|
15
38
|
}
|
|
16
39
|
export function renderHookConfigPatch(host, hookExpression) {
|
|
17
40
|
const entry = (event) => ({
|
|
@@ -19,7 +42,7 @@ export function renderHookConfigPatch(host, hookExpression) {
|
|
|
19
42
|
{
|
|
20
43
|
type: 'command',
|
|
21
44
|
command: renderHookCommand(host, event, hookExpression),
|
|
22
|
-
timeout:
|
|
45
|
+
timeout: MIN_HOOK_TIMEOUT_SECONDS,
|
|
23
46
|
},
|
|
24
47
|
],
|
|
25
48
|
});
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import crypto from 'node:crypto';
|
|
2
|
+
import fs from 'node:fs';
|
|
3
|
+
import { spawnSync } from 'node:child_process';
|
|
4
|
+
let cached;
|
|
5
|
+
/** A PID is meaningful only within this OS boot and PID namespace. Never use hostname as proof. */
|
|
6
|
+
export function managedPiHostIdentity() {
|
|
7
|
+
if (cached !== undefined)
|
|
8
|
+
return cached;
|
|
9
|
+
try {
|
|
10
|
+
let boot;
|
|
11
|
+
let namespace = 'native';
|
|
12
|
+
if (process.platform === 'linux') {
|
|
13
|
+
boot = fs.readFileSync('/proc/sys/kernel/random/boot_id', 'utf8').trim();
|
|
14
|
+
namespace = fs.readlinkSync('/proc/self/ns/pid');
|
|
15
|
+
if (!/^pid:\[[0-9]+\]$/.test(namespace))
|
|
16
|
+
return (cached = null);
|
|
17
|
+
}
|
|
18
|
+
else if (process.platform === 'darwin') {
|
|
19
|
+
// Absolute OS utility, direct argv, no shell/config/PATH interpretation.
|
|
20
|
+
const result = spawnSync('/usr/sbin/sysctl', ['-n', 'kern.bootsessionuuid'], {
|
|
21
|
+
encoding: 'utf8',
|
|
22
|
+
timeout: 2000,
|
|
23
|
+
maxBuffer: 1024,
|
|
24
|
+
shell: false,
|
|
25
|
+
});
|
|
26
|
+
if (result.error || result.status !== 0)
|
|
27
|
+
return (cached = null);
|
|
28
|
+
boot = result.stdout.trim();
|
|
29
|
+
}
|
|
30
|
+
else
|
|
31
|
+
return (cached = null);
|
|
32
|
+
if (!/^[a-f0-9]{8}(?:-[a-f0-9]{4}){3}-[a-f0-9]{12}$/i.test(boot))
|
|
33
|
+
return (cached = null);
|
|
34
|
+
cached = `sha256:${crypto.createHash('sha256').update(`pappra/managed-host/1\0${process.platform}\0${boot.toLowerCase()}\0${namespace}`).digest('hex')}`;
|
|
35
|
+
return cached;
|
|
36
|
+
}
|
|
37
|
+
catch {
|
|
38
|
+
return (cached = null);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export type ManagedProviderDiagnosticSink = (kind: string, fields: Readonly<Record<string, unknown>>) => void;
|
|
2
|
+
/** Never serialize errors: messages, URLs, headers and arbitrary custom fields may contain secrets. */
|
|
3
|
+
export declare function managedProviderErrorCauses(error: unknown): readonly Record<string, unknown>[];
|
|
4
|
+
export declare function managedProviderResponseId(value: unknown): string | null;
|
|
5
|
+
/** Per-call observation only: preserve the caller fetch, options, signal, response and errors. */
|
|
6
|
+
export declare function withManagedProviderDiagnostics(options: unknown, model: unknown, providerCallId: string, sink: ManagedProviderDiagnosticSink): Readonly<Record<string, unknown>>;
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
import { randomUUID } from 'node:crypto';
|
|
2
|
+
const names = new Set([
|
|
3
|
+
'Error',
|
|
4
|
+
'TypeError',
|
|
5
|
+
'AggregateError',
|
|
6
|
+
'AbortError',
|
|
7
|
+
'TimeoutError',
|
|
8
|
+
'APIConnectionError',
|
|
9
|
+
'APIConnectionTimeoutError',
|
|
10
|
+
'APIError',
|
|
11
|
+
]);
|
|
12
|
+
const syscalls = new Set([
|
|
13
|
+
'getaddrinfo',
|
|
14
|
+
'connect',
|
|
15
|
+
'read',
|
|
16
|
+
'write',
|
|
17
|
+
'recv',
|
|
18
|
+
'send',
|
|
19
|
+
'SSL_connect',
|
|
20
|
+
]);
|
|
21
|
+
const codes = new Set([
|
|
22
|
+
'ENOTFOUND',
|
|
23
|
+
'EAI_AGAIN',
|
|
24
|
+
'ETIMEDOUT',
|
|
25
|
+
'ECONNREFUSED',
|
|
26
|
+
'ECONNRESET',
|
|
27
|
+
'EHOSTUNREACH',
|
|
28
|
+
'ENETUNREACH',
|
|
29
|
+
'EPIPE',
|
|
30
|
+
'EPROTO',
|
|
31
|
+
'ECANCELED',
|
|
32
|
+
'ECONNABORTED',
|
|
33
|
+
'ENOTCONN',
|
|
34
|
+
'EHOSTDOWN',
|
|
35
|
+
'ENETDOWN',
|
|
36
|
+
'ENETRESET',
|
|
37
|
+
'EADDRINUSE',
|
|
38
|
+
'EADDRNOTAVAIL',
|
|
39
|
+
'ENOMEM',
|
|
40
|
+
'EACCES',
|
|
41
|
+
'EPERM',
|
|
42
|
+
'EMFILE',
|
|
43
|
+
'ENFILE',
|
|
44
|
+
'EAGAIN',
|
|
45
|
+
'EWOULDBLOCK',
|
|
46
|
+
'ESHUTDOWN',
|
|
47
|
+
'ABORT_ERR',
|
|
48
|
+
'UND_ERR_CONNECT_TIMEOUT',
|
|
49
|
+
'UND_ERR_HEADERS_TIMEOUT',
|
|
50
|
+
'UND_ERR_BODY_TIMEOUT',
|
|
51
|
+
'UND_ERR_SOCKET',
|
|
52
|
+
'UND_ERR_ABORTED',
|
|
53
|
+
'ERR_ABORTED',
|
|
54
|
+
'ERR_TLS_CERT_ALTNAME_INVALID',
|
|
55
|
+
'ERR_TLS_HANDSHAKE_TIMEOUT',
|
|
56
|
+
'ERR_SSL_WRONG_VERSION_NUMBER',
|
|
57
|
+
'ERR_SSL_TLSV1_ALERT_INTERNAL_ERROR',
|
|
58
|
+
'CERT_HAS_EXPIRED',
|
|
59
|
+
'CERT_NOT_YET_VALID',
|
|
60
|
+
'DEPTH_ZERO_SELF_SIGNED_CERT',
|
|
61
|
+
'SELF_SIGNED_CERT_IN_CHAIN',
|
|
62
|
+
'UNABLE_TO_VERIFY_LEAF_SIGNATURE',
|
|
63
|
+
'UNABLE_TO_GET_ISSUER_CERT_LOCALLY',
|
|
64
|
+
]);
|
|
65
|
+
const object = (value) => typeof value === 'object' && value !== null;
|
|
66
|
+
/** Never serialize errors: messages, URLs, headers and arbitrary custom fields may contain secrets. */
|
|
67
|
+
export function managedProviderErrorCauses(error) {
|
|
68
|
+
const causes = [];
|
|
69
|
+
const seen = new Set();
|
|
70
|
+
const inspect = (value) => {
|
|
71
|
+
if (!object(value) || seen.has(value) || causes.length >= 4)
|
|
72
|
+
return;
|
|
73
|
+
seen.add(value);
|
|
74
|
+
try {
|
|
75
|
+
const code = typeof value.code === 'string' && codes.has(value.code)
|
|
76
|
+
? value.code
|
|
77
|
+
: null;
|
|
78
|
+
causes.push({
|
|
79
|
+
name: typeof value.name === 'string' && names.has(value.name)
|
|
80
|
+
? value.name
|
|
81
|
+
: 'Error',
|
|
82
|
+
code,
|
|
83
|
+
errno: Number.isSafeInteger(value.errno) &&
|
|
84
|
+
Math.abs(Number(value.errno)) <= 65535
|
|
85
|
+
? value.errno
|
|
86
|
+
: null,
|
|
87
|
+
syscall: typeof value.syscall === 'string' && syscalls.has(value.syscall)
|
|
88
|
+
? value.syscall
|
|
89
|
+
: null,
|
|
90
|
+
});
|
|
91
|
+
inspect(value.cause);
|
|
92
|
+
if (value instanceof AggregateError)
|
|
93
|
+
for (const nested of value.errors.slice(0, 2))
|
|
94
|
+
inspect(nested);
|
|
95
|
+
}
|
|
96
|
+
catch {
|
|
97
|
+
// An exotic error getter must not mask the original provider error.
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
inspect(error);
|
|
101
|
+
return causes;
|
|
102
|
+
}
|
|
103
|
+
export function managedProviderResponseId(value) {
|
|
104
|
+
return typeof value === 'string' &&
|
|
105
|
+
/^[A-Za-z0-9][A-Za-z0-9_.:-]{0,127}$/.test(value) &&
|
|
106
|
+
!/^(?:sk-|bearer|basic|token|(?:api[_-]?)?key)/i.test(value)
|
|
107
|
+
? value
|
|
108
|
+
: null;
|
|
109
|
+
}
|
|
110
|
+
function requestId(response) {
|
|
111
|
+
for (const header of [
|
|
112
|
+
'x-request-id',
|
|
113
|
+
'request-id',
|
|
114
|
+
'x-openrouter-request-id',
|
|
115
|
+
]) {
|
|
116
|
+
const value = managedProviderResponseId(response.headers.get(header));
|
|
117
|
+
if (value)
|
|
118
|
+
return value;
|
|
119
|
+
}
|
|
120
|
+
return null;
|
|
121
|
+
}
|
|
122
|
+
/** Per-call observation only: preserve the caller fetch, options, signal, response and errors. */
|
|
123
|
+
export function withManagedProviderDiagnostics(options, model, providerCallId, sink) {
|
|
124
|
+
const original = object(options) ? options : {};
|
|
125
|
+
if (original.fetch !== undefined && typeof original.fetch !== 'function')
|
|
126
|
+
return original;
|
|
127
|
+
const fetcher = (original.fetch ?? globalThis.fetch);
|
|
128
|
+
const observedModel = object(model) ? model : {};
|
|
129
|
+
const metadata = {
|
|
130
|
+
provider_call_id: providerCallId,
|
|
131
|
+
provider: typeof observedModel.provider === 'string' &&
|
|
132
|
+
/^[a-z][a-z0-9-]{0,63}$/.test(observedModel.provider)
|
|
133
|
+
? observedModel.provider
|
|
134
|
+
: 'unknown',
|
|
135
|
+
model: typeof observedModel.id === 'string' &&
|
|
136
|
+
/^[A-Za-z0-9][A-Za-z0-9._/-]{0,127}$/.test(observedModel.id)
|
|
137
|
+
? observedModel.id
|
|
138
|
+
: 'unknown',
|
|
139
|
+
};
|
|
140
|
+
const emit = (kind, fields) => {
|
|
141
|
+
try {
|
|
142
|
+
sink(kind, { ...metadata, ...fields });
|
|
143
|
+
}
|
|
144
|
+
catch {
|
|
145
|
+
/* Diagnostic failure never masks an admitted effect. */
|
|
146
|
+
}
|
|
147
|
+
};
|
|
148
|
+
const observedFetch = async (input, init) => {
|
|
149
|
+
const fetchId = randomUUID();
|
|
150
|
+
const started = performance.now();
|
|
151
|
+
const elapsed = () => Math.round(Math.max(0, performance.now() - started) * 1000) / 1000;
|
|
152
|
+
emit('sdk_provider_fetch_started', { fetch_id: fetchId });
|
|
153
|
+
try {
|
|
154
|
+
const response = await fetcher(input, init);
|
|
155
|
+
try {
|
|
156
|
+
emit('sdk_provider_fetch_response', {
|
|
157
|
+
fetch_id: fetchId,
|
|
158
|
+
status: response.status,
|
|
159
|
+
request_id: requestId(response),
|
|
160
|
+
headers_elapsed_ms: elapsed(),
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
catch {
|
|
164
|
+
/* An unreadable diagnostic header must not change the response. */
|
|
165
|
+
}
|
|
166
|
+
return response;
|
|
167
|
+
}
|
|
168
|
+
catch (error) {
|
|
169
|
+
try {
|
|
170
|
+
emit('sdk_provider_fetch_failed', {
|
|
171
|
+
fetch_id: fetchId,
|
|
172
|
+
elapsed_ms: elapsed(),
|
|
173
|
+
signal_aborted: init?.signal?.aborted ?? false,
|
|
174
|
+
causes: managedProviderErrorCauses(error),
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
catch {
|
|
178
|
+
/* An exotic signal getter must not replace the original error. */
|
|
179
|
+
}
|
|
180
|
+
throw error;
|
|
181
|
+
}
|
|
182
|
+
};
|
|
183
|
+
return { ...original, fetch: observedFetch };
|
|
184
|
+
}
|
|
@@ -0,0 +1,335 @@
|
|
|
1
|
+
import type { ManagedPiExecutionScope } from '../../schemas/managed-pi-execution.js';
|
|
2
|
+
import { type ManagedPiSdkResumeAuthorization } from './resume-capability.js';
|
|
3
|
+
import { type ManagedPiJournal } from './managed-session.js';
|
|
4
|
+
export declare const MANAGED_PI_SDK_PRIVATE_SOURCE_HASHES: {
|
|
5
|
+
readonly 'dist/core/compaction/compaction.js': 'f51e78ef1da66b5803fc91e185f07b968f8f989ab9326b7744958416aad3f6f6';
|
|
6
|
+
readonly 'dist/core/agent-session.js': '436e8be3bbab2db475ce30bb5d0bb30f0046b19a3476f8cd57b8133e68891162';
|
|
7
|
+
readonly 'dist/modes/interactive/interactive-mode.js': '633000038a8a9c60111fc9b32481c4015285fe530685277068bc5ed74f77dafa';
|
|
8
|
+
};
|
|
9
|
+
declare const SDK_SESSION_SCHEMA = "harness-collab/pi-managed-sdk-session/1";
|
|
10
|
+
export interface ManagedPiSdkInputEvent {
|
|
11
|
+
readonly text: string;
|
|
12
|
+
readonly images?: readonly unknown[];
|
|
13
|
+
readonly source?: string;
|
|
14
|
+
readonly streamingBehavior?: string;
|
|
15
|
+
}
|
|
16
|
+
export interface ManagedPiSdkFence {
|
|
17
|
+
readonly fenced: boolean;
|
|
18
|
+
fence(reason: string): void;
|
|
19
|
+
invalidateResumeCheckpoint(reason: string): void;
|
|
20
|
+
}
|
|
21
|
+
/** Shared fence used by the SDK extension and the lifecycle controller. */
|
|
22
|
+
export declare class ManagedPiSdkIngressFence implements ManagedPiSdkFence {
|
|
23
|
+
private readonly journal;
|
|
24
|
+
private isFenced;
|
|
25
|
+
constructor(journal: ManagedPiJournal);
|
|
26
|
+
private checkpointRevisionValue;
|
|
27
|
+
get checkpointRevision(): number;
|
|
28
|
+
invalidateResumeCheckpoint(reason: string): void;
|
|
29
|
+
get fenced(): boolean;
|
|
30
|
+
fence(reason: string): void;
|
|
31
|
+
}
|
|
32
|
+
/** Inline Pi extension factory: journals semantic ingress and blocks new tools after fencing. */
|
|
33
|
+
export declare function createManagedPiSdkLifecycleExtension(fence: ManagedPiSdkFence, journal: ManagedPiJournal, metadataPath: string, canExecute?: () => boolean): (pi: unknown) => void;
|
|
34
|
+
export interface ManagedPiSdkContextUsage {
|
|
35
|
+
readonly tokens: number | null;
|
|
36
|
+
readonly contextWindow: number;
|
|
37
|
+
readonly percent: number | null;
|
|
38
|
+
}
|
|
39
|
+
export interface ManagedPiSdkAgentState {
|
|
40
|
+
readonly pendingToolCalls?: ReadonlySet<string>;
|
|
41
|
+
readonly isStreaming?: boolean;
|
|
42
|
+
}
|
|
43
|
+
export interface ManagedPiSdkAgent {
|
|
44
|
+
state: ManagedPiSdkAgentState;
|
|
45
|
+
streamFunction: (...args: never[]) => unknown;
|
|
46
|
+
}
|
|
47
|
+
/** Structural view of public Pi 1.4 AgentSession APIs used by the lifecycle controller. */
|
|
48
|
+
export interface ManagedPiSdkSessionPort {
|
|
49
|
+
readonly agent: ManagedPiSdkAgent;
|
|
50
|
+
readonly sessionId: string;
|
|
51
|
+
readonly model: {
|
|
52
|
+
readonly id: string;
|
|
53
|
+
readonly provider: string;
|
|
54
|
+
} | undefined;
|
|
55
|
+
readonly thinkingLevel?: string;
|
|
56
|
+
readonly sessionFile: string | undefined;
|
|
57
|
+
readonly isStreaming: boolean;
|
|
58
|
+
readonly isCompacting: boolean;
|
|
59
|
+
readonly isIdle: boolean;
|
|
60
|
+
readonly isBashRunning?: boolean;
|
|
61
|
+
readonly hasPendingBashMessages?: boolean;
|
|
62
|
+
readonly pendingMessageCount: number;
|
|
63
|
+
readonly state: ManagedPiSdkAgentState;
|
|
64
|
+
getSteeringMessages(): readonly string[];
|
|
65
|
+
getFollowUpMessages(): readonly string[];
|
|
66
|
+
getContextUsage(): ManagedPiSdkContextUsage | undefined;
|
|
67
|
+
compact(customInstructions?: string): Promise<unknown>;
|
|
68
|
+
subscribe(listener: (event: unknown) => void): () => void;
|
|
69
|
+
abort(): Promise<void>;
|
|
70
|
+
waitForIdle(): Promise<void>;
|
|
71
|
+
}
|
|
72
|
+
export interface ManagedPiSdkInteractiveModePort {
|
|
73
|
+
init(): Promise<void>;
|
|
74
|
+
run(): Promise<void>;
|
|
75
|
+
stop(): void;
|
|
76
|
+
}
|
|
77
|
+
export interface ManagedPiSdkRuntimePort {
|
|
78
|
+
readonly session: ManagedPiSdkSessionPort;
|
|
79
|
+
readonly cwd: string;
|
|
80
|
+
setRebindSession(callback?: (session: ManagedPiSdkSessionPort) => Promise<void>): void;
|
|
81
|
+
dispose(): Promise<void>;
|
|
82
|
+
}
|
|
83
|
+
export interface ManagedPiSdkPendingDialog {
|
|
84
|
+
readonly id: string;
|
|
85
|
+
readonly kind: 'confirm' | 'select' | 'input' | 'unclassified';
|
|
86
|
+
readonly startedAt: string;
|
|
87
|
+
}
|
|
88
|
+
export interface ManagedPiSdkSessionSnapshot {
|
|
89
|
+
readonly schema: typeof SDK_SESSION_SCHEMA;
|
|
90
|
+
readonly process: {
|
|
91
|
+
readonly pid: number;
|
|
92
|
+
readonly exit: 'not_owned';
|
|
93
|
+
};
|
|
94
|
+
readonly session: {
|
|
95
|
+
readonly sessionId: string;
|
|
96
|
+
readonly sessionFile: string | null;
|
|
97
|
+
};
|
|
98
|
+
readonly contextUsage: ManagedPiSdkContextUsage | null;
|
|
99
|
+
readonly ingress: {
|
|
100
|
+
readonly state: 'open' | 'fenced';
|
|
101
|
+
readonly journalPath: string;
|
|
102
|
+
readonly sequence: number;
|
|
103
|
+
readonly headDigest: string;
|
|
104
|
+
readonly healthy: boolean;
|
|
105
|
+
};
|
|
106
|
+
readonly ownedRuntime: {
|
|
107
|
+
readonly scope: 'pi_agent_session';
|
|
108
|
+
readonly queues: {
|
|
109
|
+
readonly observedScope: 'pinned_pi_1_4_owned_runtime';
|
|
110
|
+
readonly completeness: 'complete' | 'unknown';
|
|
111
|
+
readonly steering: readonly string[];
|
|
112
|
+
readonly followUp: readonly string[];
|
|
113
|
+
readonly pendingMessageCount: number;
|
|
114
|
+
readonly internal: {
|
|
115
|
+
readonly pendingNextTurn: readonly unknown[] | null;
|
|
116
|
+
readonly pendingCustom: readonly unknown[] | null;
|
|
117
|
+
readonly pendingBash: readonly unknown[] | null;
|
|
118
|
+
readonly deferredSettledActionCount: number | null;
|
|
119
|
+
readonly pendingUserInputs: readonly string[] | null;
|
|
120
|
+
readonly compactionMessages: readonly unknown[] | null;
|
|
121
|
+
readonly extensionDialogCount: number | null;
|
|
122
|
+
readonly activeSelector: boolean | null;
|
|
123
|
+
};
|
|
124
|
+
};
|
|
125
|
+
readonly work: {
|
|
126
|
+
readonly observation: 'complete' | 'unknown';
|
|
127
|
+
readonly isIdle: boolean;
|
|
128
|
+
readonly isStreaming: boolean;
|
|
129
|
+
readonly isCompacting: boolean;
|
|
130
|
+
readonly isBashRunning: boolean | null;
|
|
131
|
+
readonly hasPendingBashMessages: boolean | null;
|
|
132
|
+
readonly pendingToolCalls: number | null;
|
|
133
|
+
};
|
|
134
|
+
readonly extensionDialogs: {
|
|
135
|
+
readonly observedScope: 'InteractiveMode_extension_confirm_select_input';
|
|
136
|
+
readonly completeness: 'complete' | 'unknown';
|
|
137
|
+
readonly pending: readonly ManagedPiSdkPendingDialog[];
|
|
138
|
+
};
|
|
139
|
+
readonly builtInUiApprovals: {
|
|
140
|
+
readonly observation: 'complete' | 'unknown';
|
|
141
|
+
readonly uncoveredPaths: readonly string[];
|
|
142
|
+
};
|
|
143
|
+
};
|
|
144
|
+
readonly externalWriters: 'outside_runtime_scope';
|
|
145
|
+
readonly descendants: 'not_owned_by_sdk_runtime';
|
|
146
|
+
readonly scopedQuiescent: boolean;
|
|
147
|
+
readonly blockers: readonly string[];
|
|
148
|
+
}
|
|
149
|
+
export interface ManagedPiSdkStopReceipt {
|
|
150
|
+
readonly status: 'runtime_disposed';
|
|
151
|
+
readonly process: {
|
|
152
|
+
readonly pid: number;
|
|
153
|
+
readonly exit: 'not_owned';
|
|
154
|
+
};
|
|
155
|
+
readonly sessionId: string;
|
|
156
|
+
readonly finalSnapshot: ManagedPiSdkSessionSnapshot;
|
|
157
|
+
}
|
|
158
|
+
export interface ManagedPiSdkSummaryCapture {
|
|
159
|
+
/** The unmodified native CompactionResult returned by AgentSession.compact(). */
|
|
160
|
+
readonly result: unknown;
|
|
161
|
+
readonly sessionId: string;
|
|
162
|
+
readonly sessionFile: string | null;
|
|
163
|
+
readonly contextUsage: ManagedPiSdkContextUsage | null;
|
|
164
|
+
}
|
|
165
|
+
export interface ManagedPiSdkRolloverInventory {
|
|
166
|
+
readonly scope: 'pinned_pi_1_4_owned_runtime';
|
|
167
|
+
readonly completeness: 'complete' | 'partial' | 'unknown';
|
|
168
|
+
readonly inflight: readonly unknown[];
|
|
169
|
+
readonly pending_approvals: readonly unknown[];
|
|
170
|
+
readonly pending_messages?: readonly unknown[];
|
|
171
|
+
readonly partial_outputs?: readonly unknown[];
|
|
172
|
+
readonly outside_scope: readonly string[];
|
|
173
|
+
}
|
|
174
|
+
export interface ManagedPiSdkNativeIdentity {
|
|
175
|
+
readonly agentId: string | null;
|
|
176
|
+
readonly paneId: string | null;
|
|
177
|
+
readonly surface: string | null;
|
|
178
|
+
readonly configurationId: string | null;
|
|
179
|
+
}
|
|
180
|
+
export interface ManagedPiSdkSessionOptions {
|
|
181
|
+
readonly cwd: string;
|
|
182
|
+
/** Model ID within OpenRouter, for example `openai/gpt-6-luna`. */
|
|
183
|
+
readonly model: string;
|
|
184
|
+
readonly journalPath: string;
|
|
185
|
+
/** Fresh UUID for new sessions; resume requires the root-issued authorization below. */
|
|
186
|
+
readonly sessionId?: string;
|
|
187
|
+
readonly quiesceTimeoutMs?: number;
|
|
188
|
+
/** Exact immediate task binding, required when reopening a transcript. */
|
|
189
|
+
readonly executionScope?: ManagedPiExecutionScope;
|
|
190
|
+
/** Opaque, root-issued admission; never accepted from serialized launch config. */
|
|
191
|
+
readonly resumeAuthorization?: ManagedPiSdkResumeAuthorization;
|
|
192
|
+
/** Absolute path to the exact SDK module entrypoint; no ambient or global fallback is used. */
|
|
193
|
+
readonly sdkModulePath: string;
|
|
194
|
+
readonly nativeIdentity?: ManagedPiSdkNativeIdentity;
|
|
195
|
+
/** Explicit default-deny successor extension; normal daily resources are retained. */
|
|
196
|
+
readonly bootstrapExtensionPath?: string;
|
|
197
|
+
readonly thinkingLevel?: 'off' | 'minimal' | 'low' | 'medium' | 'high' | 'xhigh' | 'max';
|
|
198
|
+
/** Trusted application binding before the TUI can admit task input. Never read from JSON. */
|
|
199
|
+
readonly beforeInteractiveStart?: (controller: ManagedPiSdkSessionController) => Promise<void>;
|
|
200
|
+
/** Trusted application gate, rechecked for semantic input, provider runs and tools. */
|
|
201
|
+
readonly canExecute?: () => boolean;
|
|
202
|
+
}
|
|
203
|
+
interface ManagedPiSdkServices {
|
|
204
|
+
readonly modelRuntime: {
|
|
205
|
+
getModel(provider: string, model: string): unknown;
|
|
206
|
+
};
|
|
207
|
+
readonly diagnostics: readonly unknown[];
|
|
208
|
+
readonly settingsManager?: {
|
|
209
|
+
isProjectTrusted(): boolean;
|
|
210
|
+
getCompactionSettings?(model: unknown): unknown;
|
|
211
|
+
};
|
|
212
|
+
readonly resourceLoader?: {
|
|
213
|
+
getSkills(): {
|
|
214
|
+
readonly skills: readonly unknown[];
|
|
215
|
+
readonly diagnostics: readonly unknown[];
|
|
216
|
+
};
|
|
217
|
+
getExtensions(): {
|
|
218
|
+
readonly extensions: readonly {
|
|
219
|
+
readonly path: string;
|
|
220
|
+
}[];
|
|
221
|
+
readonly errors: readonly unknown[];
|
|
222
|
+
};
|
|
223
|
+
};
|
|
224
|
+
}
|
|
225
|
+
/** Read-only compatibility gate: never create a session or freeze a source. */
|
|
226
|
+
export declare function verifyManagedPiSdkInstallation(sdkModulePath: string): void;
|
|
227
|
+
/**
|
|
228
|
+
* Lifecycle wrapper around the controller-owned SDK AgentSession and native InteractiveMode.
|
|
229
|
+
* The public start function builds both from the explicitly selected SDK module.
|
|
230
|
+
*/
|
|
231
|
+
export declare class ManagedPiSdkSessionController {
|
|
232
|
+
private readonly input;
|
|
233
|
+
private disposed;
|
|
234
|
+
private readonly summaryProviderRun;
|
|
235
|
+
private readonly originalStreams;
|
|
236
|
+
private readonly unsubscribers;
|
|
237
|
+
private readonly pendingDialogs;
|
|
238
|
+
private readonly lifecycleListeners;
|
|
239
|
+
private terminalStopped;
|
|
240
|
+
private readonly originalSessionMethods;
|
|
241
|
+
private readonly activeBashPromises;
|
|
242
|
+
private interactiveRun;
|
|
243
|
+
private session;
|
|
244
|
+
private nativeIdentity;
|
|
245
|
+
private initialized;
|
|
246
|
+
private resourceFingerprint;
|
|
247
|
+
private resourceUpdatePending;
|
|
248
|
+
private readonly submittedInputs;
|
|
249
|
+
private resumeCheckpointScope;
|
|
250
|
+
private lastAgentEndCheckpointSafe;
|
|
251
|
+
private readonly providerCalls;
|
|
252
|
+
constructor(input: {
|
|
253
|
+
readonly runtime: ManagedPiSdkRuntimePort;
|
|
254
|
+
readonly interactiveMode: ManagedPiSdkInteractiveModePort;
|
|
255
|
+
readonly fence: ManagedPiSdkIngressFence;
|
|
256
|
+
readonly journal: ManagedPiJournal;
|
|
257
|
+
readonly model: string;
|
|
258
|
+
readonly executionScope?: ManagedPiExecutionScope;
|
|
259
|
+
readonly nativeIdentity: ManagedPiSdkNativeIdentity | undefined;
|
|
260
|
+
readonly quiesceTimeoutMs: number;
|
|
261
|
+
readonly metadataPath?: string;
|
|
262
|
+
readonly resources?: () => ManagedPiSdkServices | undefined;
|
|
263
|
+
readonly canCompact?: () => boolean;
|
|
264
|
+
readonly canExecute?: () => boolean;
|
|
265
|
+
readonly resumeAuthorization?: ManagedPiSdkResumeAuthorization;
|
|
266
|
+
});
|
|
267
|
+
private onDialogStart;
|
|
268
|
+
private onDialogEnd;
|
|
269
|
+
private wrapSessionExtensionBindings;
|
|
270
|
+
private bindSession;
|
|
271
|
+
private scheduleResourceObservation;
|
|
272
|
+
private wrapSessionOperations;
|
|
273
|
+
subscribe(listener: (event: unknown, snapshot: ManagedPiSdkSessionSnapshot) => void): () => void;
|
|
274
|
+
private notifyLifecycleListeners;
|
|
275
|
+
private observeSessionEvent;
|
|
276
|
+
/** Called by AgentSessionRuntime's native replacement callback wrapper. */
|
|
277
|
+
replaceSession(session: ManagedPiSdkSessionPort): void;
|
|
278
|
+
fenceIngress(reason?: string): void;
|
|
279
|
+
snapshot(): ManagedPiSdkSessionSnapshot;
|
|
280
|
+
getContextUsage(): ManagedPiSdkContextUsage | null;
|
|
281
|
+
observe(): {
|
|
282
|
+
native: {
|
|
283
|
+
harness: 'pi';
|
|
284
|
+
sessionId: string;
|
|
285
|
+
agentId: string | null;
|
|
286
|
+
paneId: string | null;
|
|
287
|
+
surface: string;
|
|
288
|
+
configurationId: string | null;
|
|
289
|
+
modelObservation: {
|
|
290
|
+
model: string;
|
|
291
|
+
provider: string;
|
|
292
|
+
reasoning: string | null;
|
|
293
|
+
};
|
|
294
|
+
};
|
|
295
|
+
cwd: string;
|
|
296
|
+
contextPercent: number | null;
|
|
297
|
+
};
|
|
298
|
+
inventory(): Promise<ManagedPiSdkRolloverInventory>;
|
|
299
|
+
canCaptureSummary(): boolean;
|
|
300
|
+
captureSummary(causeId: string): Promise<{
|
|
301
|
+
summary: string;
|
|
302
|
+
complete: false;
|
|
303
|
+
sessionFile: string;
|
|
304
|
+
}>;
|
|
305
|
+
private stopTerminalIngress;
|
|
306
|
+
quiesce(reason?: string): Promise<ManagedPiSdkSessionSnapshot>;
|
|
307
|
+
stopOwnedRuntime(): Promise<ManagedPiSdkStopReceipt>;
|
|
308
|
+
get isDisposed(): boolean;
|
|
309
|
+
cleanupAfterStartupFailure(): Promise<boolean>;
|
|
310
|
+
private closeObservers;
|
|
311
|
+
bindResumeCheckpointScope(scope: ManagedPiExecutionScope): void;
|
|
312
|
+
recordInitialResumeCheckpoint(): boolean;
|
|
313
|
+
private appendResumeCheckpoint;
|
|
314
|
+
initializeInteractiveMode(): Promise<void>;
|
|
315
|
+
get runPromise(): Promise<void> | undefined;
|
|
316
|
+
/** Admits one durable semantic input, without waiting for or claiming model success. */
|
|
317
|
+
submitInput(requestId: string, text: string): {
|
|
318
|
+
status: string;
|
|
319
|
+
request_id: string;
|
|
320
|
+
duplicate: boolean;
|
|
321
|
+
session_id: string;
|
|
322
|
+
};
|
|
323
|
+
importHandoffContext(content: string): Promise<void>;
|
|
324
|
+
/** The app binds logical assignment identity; native UUID/cwd/model remain SDK observations. */
|
|
325
|
+
bindNativeIdentity(identity: ManagedPiSdkNativeIdentity): void;
|
|
326
|
+
/** Resource availability after real initialization, without a fabricated model turn. */
|
|
327
|
+
get metadataFile(): string | null;
|
|
328
|
+
publishResourcesReady(force?: boolean): boolean;
|
|
329
|
+
}
|
|
330
|
+
/**
|
|
331
|
+
* Start Pi 1.4.0's controller-owned SDK runtime and the native interactive TUI.
|
|
332
|
+
* The module path is explicit; this function never falls back to a global/installed SDK.
|
|
333
|
+
*/
|
|
334
|
+
export declare function startManagedPiSdkSession(options: ManagedPiSdkSessionOptions): Promise<ManagedPiSdkSessionController>;
|
|
335
|
+
export {};
|