@piagent/platform 1.3.0 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +56 -3
- package/README.md +3 -3
- package/architecture/layers.json +96 -1
- package/docs/README.md +1 -0
- package/docs/architecture.md +1 -0
- package/docs/authority-manifest.md +1 -0
- package/docs/auto-delegation-policy.md +1 -0
- package/docs/capability-packs.md +10 -2
- package/docs/command-reference-vietnamese.md +5 -4
- package/docs/context-engine.md +1 -0
- package/docs/context-window-policy.md +1 -0
- package/docs/distribution-standard.md +8 -7
- package/docs/herdr-workflow.md +1 -0
- package/docs/mcp-and-tools.md +14 -9
- package/docs/memory-policy.md +1 -0
- package/docs/model-options.md +1 -0
- package/docs/oauth-providers.md +1 -0
- package/docs/operator-manual-vietnamese.md +15 -12
- package/docs/package-architecture-notes.md +1 -0
- package/docs/project-adapters.md +1 -0
- package/docs/project-onboarding.md +1 -0
- package/docs/publishing-for-teams.md +1 -0
- package/docs/quality-benchmark.md +1 -0
- package/docs/quickstart-vietnamese.md +3 -2
- package/docs/release-install-policy.md +11 -7
- package/docs/runtime-harness-standard.md +1 -0
- package/docs/runtime-policy-design.md +1 -0
- package/docs/runtime-quality-baseline.md +1 -0
- package/docs/security-redaction-benchmark.md +1 -0
- package/docs/security-threat-model.md +2 -1
- package/docs/subagent-orchestration-capabilities.md +1 -0
- package/docs/subagents-and-multiagent.md +1 -0
- package/docs/task-implementation-contract.md +1 -0
- package/docs/task-lifecycle-vietnamese.md +1 -0
- package/docs/team-onboarding.md +3 -2
- package/docs/third-party-neutrality.md +26 -0
- package/docs/usage-observability.md +1 -0
- package/docs/vercel-docs-site.md +1 -0
- package/docs/workflow-recipes.md +1 -0
- package/docs-site/architecture.html +1 -1
- package/docs-site/benchmark.html +1 -1
- package/docs-site/commands.html +1 -1
- package/docs-site/context-engine.html +1 -1
- package/docs-site/en/architecture.html +1 -1
- package/docs-site/en/benchmark.html +1 -1
- package/docs-site/en/commands.html +1 -1
- package/docs-site/en/context-engine.html +1 -1
- package/docs-site/en/index.html +1 -1
- package/docs-site/en/mcp-approval.html +1 -1
- package/docs-site/en/mcp-auth.html +1 -1
- package/docs-site/en/mcp-servers.html +1 -1
- package/docs-site/en/mcp.html +1 -1
- package/docs-site/en/permissions.html +1 -1
- package/docs-site/en/profiles.html +1 -1
- package/docs-site/en/quickstart.html +1 -1
- package/docs-site/en/runtime.html +1 -1
- package/docs-site/en/scope.html +1 -1
- package/docs-site/en/security.html +1 -1
- package/docs-site/en/team.html +1 -1
- package/docs-site/en/whats-new.html +1 -1
- package/docs-site/en/workflows.html +1 -1
- package/docs-site/index.html +1 -1
- package/docs-site/mcp-approval.html +1 -1
- package/docs-site/mcp-auth.html +1 -1
- package/docs-site/mcp-servers.html +1 -1
- package/docs-site/mcp.html +1 -1
- package/docs-site/permissions.html +1 -1
- package/docs-site/profiles.html +1 -1
- package/docs-site/quickstart.html +1 -1
- package/docs-site/runtime.html +1 -1
- package/docs-site/scope.html +1 -1
- package/docs-site/security.html +1 -1
- package/docs-site/team.html +1 -1
- package/docs-site/whats-new.html +1 -1
- package/docs-site/workflows.html +1 -1
- package/evals/fixtures/mutation-provenance-record.invalid.json +17 -0
- package/evals/fixtures/mutation-provenance-record.valid.json +27 -0
- package/evals/fixtures/piagent-webui/approval-v1.invalid.json +54 -0
- package/evals/fixtures/piagent-webui/approval-v1.valid.json +58 -0
- package/evals/fixtures/piagent-webui/attachment-v1.invalid.json +25 -0
- package/evals/fixtures/piagent-webui/attachment-v1.valid.json +25 -0
- package/evals/fixtures/piagent-webui/capabilities-v1.invalid.json +51 -0
- package/evals/fixtures/piagent-webui/capabilities-v1.valid.json +122 -0
- package/evals/fixtures/piagent-webui/commit-summary-v1.invalid.json +10 -0
- package/evals/fixtures/piagent-webui/commit-summary-v1.valid.json +25 -0
- package/evals/fixtures/piagent-webui/control-command-v1.invalid.json +37 -0
- package/evals/fixtures/piagent-webui/control-command-v1.valid.json +35 -0
- package/evals/fixtures/piagent-webui/diff-v1.invalid.json +13 -0
- package/evals/fixtures/piagent-webui/diff-v1.valid.json +141 -0
- package/evals/fixtures/piagent-webui/gateway-capabilities-v1.invalid.json +35 -0
- package/evals/fixtures/piagent-webui/gateway-capabilities-v1.valid.json +35 -0
- package/evals/fixtures/piagent-webui/gateway-protocol-v1.invalid.json +14 -0
- package/evals/fixtures/piagent-webui/gateway-protocol-v1.valid.json +14 -0
- package/evals/fixtures/piagent-webui/handoff-history-v1.invalid.json +16 -0
- package/evals/fixtures/piagent-webui/handoff-history-v1.valid.json +16 -0
- package/evals/fixtures/piagent-webui/model-catalog-v1.invalid.json +31 -0
- package/evals/fixtures/piagent-webui/model-catalog-v1.valid.json +43 -0
- package/evals/fixtures/piagent-webui/queue-v1.invalid.json +29 -0
- package/evals/fixtures/piagent-webui/queue-v1.valid.json +44 -0
- package/evals/fixtures/piagent-webui/recovery-history-v1.invalid.json +17 -0
- package/evals/fixtures/piagent-webui/recovery-history-v1.valid.json +20 -0
- package/evals/fixtures/piagent-webui/release-monitor-v1.invalid.json +12 -0
- package/evals/fixtures/piagent-webui/release-monitor-v1.valid.json +29 -0
- package/evals/fixtures/piagent-webui/review-state-v1.invalid.json +25 -0
- package/evals/fixtures/piagent-webui/review-state-v1.valid.json +38 -0
- package/evals/fixtures/piagent-webui/runtime-event-v2.invalid.json +49 -0
- package/evals/fixtures/piagent-webui/runtime-event-v2.valid.json +49 -0
- package/evals/fixtures/piagent-webui/session-catalog-v1.invalid.json +17 -0
- package/evals/fixtures/piagent-webui/session-catalog-v1.valid.json +58 -0
- package/evals/fixtures/piagent-webui/session-command-v1.invalid.json +19 -0
- package/evals/fixtures/piagent-webui/session-command-v1.valid.json +19 -0
- package/evals/fixtures/piagent-webui/snapshot-v1.invalid.json +5 -0
- package/evals/fixtures/piagent-webui/snapshot-v1.valid.json +191 -0
- package/evals/fixtures/piagent-webui/source-change-v1.invalid.json +57 -0
- package/evals/fixtures/piagent-webui/source-change-v1.valid.json +98 -0
- package/evals/fixtures/piagent-webui/source-mutation-v1.invalid.json +19 -0
- package/evals/fixtures/piagent-webui/source-mutation-v1.valid.json +38 -0
- package/evals/fixtures/piagent-webui/source-revert-v1.invalid.json +20 -0
- package/evals/fixtures/piagent-webui/source-revert-v1.valid.json +62 -0
- package/evals/fixtures/piagent-webui/subagent-tree-v1.invalid.json +26 -0
- package/evals/fixtures/piagent-webui/subagent-tree-v1.valid.json +39 -0
- package/evals/fixtures/piagent-webui/task-index-v1.invalid.json +15 -0
- package/evals/fixtures/piagent-webui/task-index-v1.valid.json +15 -0
- package/evals/fixtures/piagent-webui/task-timeline-v1.invalid.json +14 -0
- package/evals/fixtures/piagent-webui/task-timeline-v1.valid.json +16 -0
- package/evals/fixtures/piagent-webui/transcript-v1.invalid.json +35 -0
- package/evals/fixtures/piagent-webui/transcript-v1.valid.json +55 -0
- package/evals/fixtures/task-baseline-manifest.invalid.json +16 -0
- package/evals/fixtures/task-baseline-manifest.valid.json +41 -0
- package/evals/fixtures/verifier-file-snapshot.invalid.json +21 -0
- package/evals/fixtures/verifier-file-snapshot.valid.json +21 -0
- package/package.json +30 -3
- package/packages/piagent-core/benchmark/benchmark-candidate.d.ts +1 -0
- package/packages/piagent-core/benchmark/benchmark-forensics.d.ts +1 -0
- package/packages/piagent-core/benchmark/benchmark-ledger.d.ts +4 -0
- package/packages/piagent-core/benchmark/benchmark-record-validation.d.ts +1 -0
- package/packages/piagent-core/benchmark/benchmark-runtime.d.ts +1 -0
- package/packages/piagent-core/capabilities/capability-core.js +2 -2
- package/packages/piagent-core/capabilities/capability-verification-cache.js +280 -0
- package/packages/piagent-core/capabilities/runtime-integrity.js +153 -1
- package/packages/piagent-core/extensions/document-intake.ts +24 -10
- package/packages/piagent-core/extensions/piagent-guard.ts +90 -73
- package/packages/piagent-core/extensions/redaction-core.d.ts +2 -0
- package/packages/piagent-core/extensions/state-retention.js +77 -44
- package/packages/piagent-core/extensions/task-journal.js +30 -1
- package/packages/piagent-core/extensions/task-state.js +33 -36
- package/packages/piagent-core/mcp/mcp-server-catalog.js +5 -5
- package/packages/piagent-core/package.json +1 -1
- package/packages/piagent-core/runtime/hooks/session-start-hook.ts +2 -2
- package/packages/piagent-core/runtime/hooks/tool-call-hook.ts +5 -2
- package/packages/piagent-core/runtime/hooks/tool-result-hook.ts +20 -19
- package/packages/piagent-core/runtime/hooks/tool-result-metadata.ts +13 -0
- package/packages/piagent-core/runtime/input/chat-images.ts +2 -2
- package/packages/piagent-core/runtime/inspection/activity-event-adapter.ts +94 -0
- package/packages/piagent-core/runtime/inspection/approval-broker.ts +318 -0
- package/packages/piagent-core/runtime/inspection/commit-summary-projection.ts +59 -0
- package/packages/piagent-core/runtime/inspection/context-telemetry-inspection.ts +37 -0
- package/packages/piagent-core/runtime/inspection/criteria-links.ts +295 -0
- package/packages/piagent-core/runtime/inspection/diff-projection.ts +499 -0
- package/packages/piagent-core/runtime/inspection/git-filter-safety.ts +38 -0
- package/packages/piagent-core/runtime/inspection/git-numstat-adapter.ts +71 -0
- package/packages/piagent-core/runtime/inspection/git-status-adapter.ts +493 -0
- package/packages/piagent-core/runtime/inspection/git-tree-adapter.ts +108 -0
- package/packages/piagent-core/runtime/inspection/mcp-control.ts +10 -0
- package/packages/piagent-core/runtime/inspection/mutation-provenance-contract.ts +131 -0
- package/packages/piagent-core/runtime/inspection/mutation-provenance-recorder.ts +48 -0
- package/packages/piagent-core/runtime/inspection/mutation-provenance-store.ts +161 -0
- package/packages/piagent-core/runtime/inspection/project-runtime-inspection.ts +36 -0
- package/packages/piagent-core/runtime/inspection/review-state-contract.ts +108 -0
- package/packages/piagent-core/runtime/inspection/review-state-projection.ts +93 -0
- package/packages/piagent-core/runtime/inspection/review-state-store.ts +112 -0
- package/packages/piagent-core/runtime/inspection/runtime-event-store.ts +262 -0
- package/packages/piagent-core/runtime/inspection/same-process-bridge-proof.ts +103 -0
- package/packages/piagent-core/runtime/inspection/source-change-projection.ts +471 -0
- package/packages/piagent-core/runtime/inspection/source-evidence-contract.ts +139 -0
- package/packages/piagent-core/runtime/inspection/source-evidence-store.ts +315 -0
- package/packages/piagent-core/runtime/inspection/source-handoff-store.ts +70 -0
- package/packages/piagent-core/runtime/inspection/source-inspection-plan.ts +34 -0
- package/packages/piagent-core/runtime/inspection/source-mutation-projection.ts +164 -0
- package/packages/piagent-core/runtime/inspection/source-mutation-store.ts +168 -0
- package/packages/piagent-core/runtime/inspection/source-open-target.ts +38 -0
- package/packages/piagent-core/runtime/inspection/source-revert-projection.ts +147 -0
- package/packages/piagent-core/runtime/inspection/task-baseline-start-capture.ts +22 -0
- package/packages/piagent-core/runtime/inspection/task-compaction-history.ts +160 -0
- package/packages/piagent-core/runtime/inspection/task-control-journal.ts +131 -0
- package/packages/piagent-core/runtime/inspection/task-handoff-history.ts +95 -0
- package/packages/piagent-core/runtime/inspection/task-provenance-projection.ts +60 -0
- package/packages/piagent-core/runtime/inspection/task-recovery-timeline.ts +88 -0
- package/packages/piagent-core/runtime/inspection/task-run-index.ts +87 -0
- package/packages/piagent-core/runtime/inspection/task-source-projection.ts +401 -0
- package/packages/piagent-core/runtime/inspection/task-subagent-tree.ts +101 -0
- package/packages/piagent-core/runtime/inspection/text-diff.ts +60 -0
- package/packages/piagent-core/runtime/inspection/verifier-snapshot-contract.ts +114 -0
- package/packages/piagent-core/runtime/inspection/verifier-snapshot-store.ts +189 -0
- package/packages/piagent-core/runtime/inspection/webui-snapshot.ts +320 -0
- package/packages/piagent-core/runtime/inspection/workspace-file-reader.ts +132 -0
- package/packages/piagent-core/runtime/inspection/workspace-source-projection.ts +96 -0
- package/packages/piagent-core/runtime/inspection/zero-turn-conformance.ts +175 -0
- package/packages/piagent-core/runtime/orchestration/owned-work-budget.ts +68 -4
- package/packages/piagent-core/runtime/policy/source-index-transaction.ts +173 -0
- package/packages/piagent-core/runtime/policy/source-mutation-guard-binding.ts +42 -0
- package/packages/piagent-core/runtime/policy/source-mutation-guard.ts +184 -0
- package/packages/piagent-core/runtime/policy/source-worktree-transaction.ts +105 -0
- package/packages/piagent-core/runtime/product/activity-inspector-footer.ts +5 -3
- package/packages/piagent-core/runtime/product/activity-inspector.ts +85 -343
- package/packages/piagent-core/runtime/recovery/resume-state.ts +38 -1
- package/packages/piagent-core/runtime/registration/activity-inspector-command.ts +68 -14
- package/packages/piagent-core/runtime/registration/task-start-tool.ts +13 -14
- package/packages/piagent-core/runtime/session/model-authorship-state.ts +31 -3
- package/packages/piagent-core/runtime/session/runtime-state.ts +11 -1
- package/packages/piagent-webui/dist/client/assets/index-DjMntaK5.js +172 -0
- package/packages/piagent-webui/dist/client/assets/index-DwKCWbwd.css +1 -0
- package/packages/piagent-webui/dist/client/index.html +16 -0
- package/packages/piagent-webui/extension/attachment-store.ts +323 -0
- package/packages/piagent-webui/extension/held-message-queue.ts +311 -0
- package/packages/piagent-webui/extension/lifecycle-controller.ts +408 -0
- package/packages/piagent-webui/extension/lifecycle-event-adapter.ts +23 -0
- package/packages/piagent-webui/extension/piagent-webui.ts +470 -0
- package/packages/piagent-webui/extension/review-controller.ts +160 -0
- package/packages/piagent-webui/extension/same-session-bridge.ts +500 -0
- package/packages/piagent-webui/extension/session-options-controller.ts +281 -0
- package/packages/piagent-webui/extension/session-stream-adapter.ts +249 -0
- package/packages/piagent-webui/extension/source-mutation-controller.ts +215 -0
- package/packages/piagent-webui/extension/source-open-controller.ts +136 -0
- package/packages/piagent-webui/extension/source-revert-controller.ts +189 -0
- package/packages/piagent-webui/extension/terminal-session-adapter.ts +73 -0
- package/packages/piagent-webui/extension/vscode-handoff.ts +51 -0
- package/packages/piagent-webui/gateway/control-socket.ts +92 -0
- package/packages/piagent-webui/gateway/gateway-events.ts +60 -0
- package/packages/piagent-webui/gateway/gateway-protocol-service.ts +64 -0
- package/packages/piagent-webui/gateway/gateway-service.ts +215 -0
- package/packages/piagent-webui/gateway/gateway-session-stream.ts +110 -0
- package/packages/piagent-webui/gateway/mcp-auth-broker.ts +158 -0
- package/packages/piagent-webui/gateway/native-project-picker.ts +29 -0
- package/packages/piagent-webui/gateway/pi-host.ts +41 -0
- package/packages/piagent-webui/gateway/profile-state.ts +1 -0
- package/packages/piagent-webui/gateway/project-registry.ts +108 -0
- package/packages/piagent-webui/gateway/provider-auth-broker.ts +172 -0
- package/packages/piagent-webui/gateway/session-catalog.ts +128 -0
- package/packages/piagent-webui/gateway/session-command-controller.ts +237 -0
- package/packages/piagent-webui/gateway/session-command-store.ts +224 -0
- package/packages/piagent-webui/gateway/session-inspection-registry.ts +204 -0
- package/packages/piagent-webui/gateway/session-lease-store.ts +1 -0
- package/packages/piagent-webui/gateway/session-metadata-store.ts +152 -0
- package/packages/piagent-webui/gateway/session-runtime-supervisor.ts +485 -0
- package/packages/piagent-webui/ownership/gateway-runtime-context.ts +8 -0
- package/packages/piagent-webui/ownership/profile-state.ts +117 -0
- package/packages/piagent-webui/ownership/session-lease-store.ts +329 -0
- package/packages/piagent-webui/ownership/session-refs.ts +8 -0
- package/packages/piagent-webui/package.json +33 -0
- package/packages/piagent-webui/server/README.md +4 -0
- package/packages/piagent-webui/server/benchmark-release-monitor.ts +230 -0
- package/packages/piagent-webui/server/core-inspection-provider.ts +403 -0
- package/packages/piagent-webui/server/gateway-websocket.ts +143 -0
- package/packages/piagent-webui/server/http-security.ts +27 -0
- package/packages/piagent-webui/server/ipc-read-model-client.ts +89 -0
- package/packages/piagent-webui/server/loopback-server.ts +368 -0
- package/packages/piagent-webui/server/read-model-provider.ts +37 -0
- package/packages/piagent-webui/server/read-only-router.ts +105 -0
- package/packages/piagent-webui/server/session-auth.ts +88 -0
- package/packages/piagent-webui/server/sidecar-main.ts +86 -0
- package/packages/piagent-webui/server/sse-hub.ts +76 -0
- package/packages/piagent-webui/server/static-bundle.ts +40 -0
- package/packages/piagent-webui/server/transcript-projection.ts +110 -0
- package/schemas/mutation-provenance-record.schema.json +100 -0
- package/schemas/piagent-webui/approval-v1.schema.json +654 -0
- package/schemas/piagent-webui/attachment-v1.schema.json +267 -0
- package/schemas/piagent-webui/capabilities-v1.schema.json +729 -0
- package/schemas/piagent-webui/catalog-v1.json +240 -0
- package/schemas/piagent-webui/commit-summary-v1.schema.json +63 -0
- package/schemas/piagent-webui/common-v1.schema.json +479 -0
- package/schemas/piagent-webui/control-command-v1.schema.json +1780 -0
- package/schemas/piagent-webui/diff-v1.schema.json +826 -0
- package/schemas/piagent-webui/gateway-capabilities-v1.schema.json +136 -0
- package/schemas/piagent-webui/gateway-protocol-v1.schema.json +456 -0
- package/schemas/piagent-webui/handoff-history-v1.schema.json +92 -0
- package/schemas/piagent-webui/model-catalog-v1.schema.json +95 -0
- package/schemas/piagent-webui/queue-v1.schema.json +99 -0
- package/schemas/piagent-webui/recovery-history-v1.schema.json +144 -0
- package/schemas/piagent-webui/release-monitor-v1.schema.json +173 -0
- package/schemas/piagent-webui/review-state-v1.schema.json +206 -0
- package/schemas/piagent-webui/runtime-event-v2.schema.json +5206 -0
- package/schemas/piagent-webui/session-catalog-v1.schema.json +222 -0
- package/schemas/piagent-webui/session-command-v1.schema.json +390 -0
- package/schemas/piagent-webui/snapshot-v1.schema.json +2622 -0
- package/schemas/piagent-webui/source-change-v1.schema.json +763 -0
- package/schemas/piagent-webui/source-mutation-v1.schema.json +96 -0
- package/schemas/piagent-webui/source-revert-v1.schema.json +130 -0
- package/schemas/piagent-webui/subagent-tree-v1.schema.json +88 -0
- package/schemas/piagent-webui/task-index-v1.schema.json +74 -0
- package/schemas/piagent-webui/task-timeline-v1.schema.json +49 -0
- package/schemas/piagent-webui/transcript-v1.schema.json +243 -0
- package/schemas/task-baseline-manifest.schema.json +122 -0
- package/schemas/verifier-file-snapshot.schema.json +81 -0
- package/scripts/check-architecture.mjs +1 -0
- package/scripts/check-doc-languages.mjs +19 -2
- package/scripts/check-third-party-neutrality.mjs +43 -0
- package/scripts/install-global.sh +1 -1
- package/scripts/piagent-cli.mjs +17 -3
- package/scripts/piagent-dashboard.mjs +208 -0
- package/scripts/piagent-webui-launcher.mjs +121 -0
- package/scripts/typescript-loader.mjs +26 -1
- package/scripts/verify-local.sh +253 -0
- package/scripts/verify-release-identity.mjs +4 -1
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"schemaVersion": 1,
|
|
3
|
+
"version": "piagent-webui-task-timeline-v1",
|
|
4
|
+
"generatedAt": "2026-08-14T11:00:00.000Z",
|
|
5
|
+
"identity": { "projectRef": "project.fixture", "runtimeInstanceId": "runtime.fixture", "sessionRef": "session.fixture", "taskId": "task-active", "taskRunId": "task-active-run", "agentOperationId": null, "toolCallId": null },
|
|
6
|
+
"runRef": "run.fixture",
|
|
7
|
+
"state": "ready",
|
|
8
|
+
"timelineRevision": "timeline.fixture",
|
|
9
|
+
"continuity": { "crashEvidence": "unknown", "recoveryDecision": "paused", "latestCheckpointRef": "checkpoint.fixture", "reasonCode": "no-explicit-crash-evidence" },
|
|
10
|
+
"events": [
|
|
11
|
+
{ "eventRef": "event.fixture", "evidenceRef": "journal.fixture", "sequence": 1, "recordedAt": "2026-08-14T10:00:00.000Z", "kind": "checkpoint", "state": "observed", "title": "Checkpoint paused", "detail": "verify · paused", "checkpointRef": "checkpoint.fixture" }
|
|
12
|
+
],
|
|
13
|
+
"page": { "total": 1, "returned": 1, "truncated": false },
|
|
14
|
+
"warnings": [{ "code": "crash-not-observed", "count": 1, "message": "No explicit crash fact was recorded." }],
|
|
15
|
+
"health": { "state": "degraded", "reasonCode": "timeline-warning", "message": "Some continuity facts remain unknown." }
|
|
16
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
{
|
|
2
|
+
"schemaVersion": 1,
|
|
3
|
+
"version": "piagent-webui-transcript-v1",
|
|
4
|
+
"generatedAt": "2026-08-13T14:00:00.000Z",
|
|
5
|
+
"identity": {
|
|
6
|
+
"projectRef": "project_01",
|
|
7
|
+
"runtimeInstanceId": "runtime_01",
|
|
8
|
+
"sessionRef": "session_01",
|
|
9
|
+
"taskId": null,
|
|
10
|
+
"taskRunId": null,
|
|
11
|
+
"agentOperationId": "operation_smuggled",
|
|
12
|
+
"toolCallId": null
|
|
13
|
+
},
|
|
14
|
+
"revision": {
|
|
15
|
+
"runtimeRevision": "runtime_rev_01",
|
|
16
|
+
"taskRevision": null,
|
|
17
|
+
"controlRevision": null,
|
|
18
|
+
"workspaceRevision": null,
|
|
19
|
+
"indexRevision": null,
|
|
20
|
+
"approvalRevision": null,
|
|
21
|
+
"sessionOptionRevision": null,
|
|
22
|
+
"queueRevision": null
|
|
23
|
+
},
|
|
24
|
+
"eventCursor": "cursor_01",
|
|
25
|
+
"state": "unavailable",
|
|
26
|
+
"items": [{ "rawSessionMessage": "secret" }],
|
|
27
|
+
"page": {
|
|
28
|
+
"beforeCursor": null,
|
|
29
|
+
"nextBeforeCursor": "cursor_invented",
|
|
30
|
+
"hasOlder": false,
|
|
31
|
+
"limit": 50,
|
|
32
|
+
"truncated": false
|
|
33
|
+
},
|
|
34
|
+
"reasonCode": null
|
|
35
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
{
|
|
2
|
+
"schemaVersion": 1,
|
|
3
|
+
"version": "piagent-webui-transcript-v1",
|
|
4
|
+
"generatedAt": "2026-08-13T14:00:00.000Z",
|
|
5
|
+
"identity": {
|
|
6
|
+
"projectRef": "project_01",
|
|
7
|
+
"runtimeInstanceId": "runtime_01",
|
|
8
|
+
"sessionRef": "session_01",
|
|
9
|
+
"taskId": null,
|
|
10
|
+
"taskRunId": null,
|
|
11
|
+
"agentOperationId": null,
|
|
12
|
+
"toolCallId": null
|
|
13
|
+
},
|
|
14
|
+
"revision": {
|
|
15
|
+
"runtimeRevision": "runtime_rev_01",
|
|
16
|
+
"taskRevision": null,
|
|
17
|
+
"controlRevision": null,
|
|
18
|
+
"workspaceRevision": null,
|
|
19
|
+
"indexRevision": null,
|
|
20
|
+
"approvalRevision": null,
|
|
21
|
+
"sessionOptionRevision": null,
|
|
22
|
+
"queueRevision": "queue_rev_01"
|
|
23
|
+
},
|
|
24
|
+
"eventCursor": "cursor_01",
|
|
25
|
+
"state": "ready",
|
|
26
|
+
"items": [
|
|
27
|
+
{
|
|
28
|
+
"messageRef": "message_01",
|
|
29
|
+
"parentMessageRef": null,
|
|
30
|
+
"role": "user",
|
|
31
|
+
"recordedAt": "2026-08-13T13:59:59.000Z",
|
|
32
|
+
"agentOperationId": "operation_01",
|
|
33
|
+
"turnIndex": 0,
|
|
34
|
+
"content": {
|
|
35
|
+
"state": "available",
|
|
36
|
+
"text": "Continue the current task.",
|
|
37
|
+
"textChars": 26,
|
|
38
|
+
"digest": "sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
|
|
39
|
+
"truncated": false,
|
|
40
|
+
"redacted": false,
|
|
41
|
+
"imageCount": 0,
|
|
42
|
+
"reasonCode": null
|
|
43
|
+
},
|
|
44
|
+
"toolCalls": []
|
|
45
|
+
}
|
|
46
|
+
],
|
|
47
|
+
"page": {
|
|
48
|
+
"beforeCursor": null,
|
|
49
|
+
"nextBeforeCursor": null,
|
|
50
|
+
"hasOlder": false,
|
|
51
|
+
"limit": 50,
|
|
52
|
+
"truncated": false
|
|
53
|
+
},
|
|
54
|
+
"reasonCode": null
|
|
55
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"schemaVersion": 1,
|
|
3
|
+
"version": "piagent-task-baseline-manifest-v1",
|
|
4
|
+
"taskId": "task-01",
|
|
5
|
+
"taskRunId": "task-01-run-1",
|
|
6
|
+
"sessionIdentityHash": "raw-session-id",
|
|
7
|
+
"capturedAt": "2026-08-13",
|
|
8
|
+
"retentionUntil": "2026-09-12",
|
|
9
|
+
"baselineDigestAlgorithm": "sha1",
|
|
10
|
+
"baselineTreeDigest": "unknown",
|
|
11
|
+
"captureState": "current",
|
|
12
|
+
"reasonCode": "invented-current-error",
|
|
13
|
+
"limits": { "maxEntries": 3000, "maxFileBytes": 0, "maxTotalBytes": 0, "capturedBytes": -1 },
|
|
14
|
+
"roots": [],
|
|
15
|
+
"integrityDigest": "not-a-digest"
|
|
16
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
{
|
|
2
|
+
"schemaVersion": 1,
|
|
3
|
+
"version": "piagent-task-baseline-manifest-v1",
|
|
4
|
+
"taskId": "task-01",
|
|
5
|
+
"taskRunId": "task-01-run-1",
|
|
6
|
+
"sessionIdentityHash": "sha256:1111111111111111111111111111111111111111111111111111111111111111",
|
|
7
|
+
"capturedAt": "2026-08-13T12:00:00.000Z",
|
|
8
|
+
"retentionUntil": "2026-09-12T12:00:00.000Z",
|
|
9
|
+
"baselineDigestAlgorithm": "wt-content-v2",
|
|
10
|
+
"baselineTreeDigest": "wt-content-v2:2222222222222222222222222222222222222222222222222222222222222222",
|
|
11
|
+
"captureState": "current",
|
|
12
|
+
"reasonCode": null,
|
|
13
|
+
"limits": { "maxEntries": 2000, "maxFileBytes": 4194304, "maxTotalBytes": 67108864, "capturedBytes": 5 },
|
|
14
|
+
"roots": [
|
|
15
|
+
{
|
|
16
|
+
"repoRef": "repo.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
|
|
17
|
+
"projectPath": ".",
|
|
18
|
+
"headState": "head",
|
|
19
|
+
"headOid": "3333333333333333333333333333333333333333",
|
|
20
|
+
"workspaceRevision": "workspace.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
|
|
21
|
+
"indexRevision": "index.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
|
|
22
|
+
"state": "current",
|
|
23
|
+
"reasonCode": null,
|
|
24
|
+
"entries": [
|
|
25
|
+
{
|
|
26
|
+
"pathRef": "path.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
|
|
27
|
+
"pathDigest": "sha256:4444444444444444444444444444444444444444444444444444444444444444",
|
|
28
|
+
"repoPathBase64": "YS50eHQ",
|
|
29
|
+
"state": "blob",
|
|
30
|
+
"reasonCode": null,
|
|
31
|
+
"contentRef": "sha256:5555555555555555555555555555555555555555555555555555555555555555",
|
|
32
|
+
"byteLength": 5,
|
|
33
|
+
"mode": "100644",
|
|
34
|
+
"headObject": "6666666666666666666666666666666666666666",
|
|
35
|
+
"indexObject": "7777777777777777777777777777777777777777"
|
|
36
|
+
}
|
|
37
|
+
]
|
|
38
|
+
}
|
|
39
|
+
],
|
|
40
|
+
"integrityDigest": "sha256:19a3c69ef5e5abeeb505725d52b481744c60d3fec4bd8c46ec19a4800f64e59d"
|
|
41
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
{
|
|
2
|
+
"schemaVersion": 1,
|
|
3
|
+
"version": "piagent-verifier-file-snapshot-v1",
|
|
4
|
+
"attemptId": "verifier.invalid",
|
|
5
|
+
"attemptRef": "verifier-evidence.invalid",
|
|
6
|
+
"taskId": "task-01",
|
|
7
|
+
"taskRunId": "task-01-run-01",
|
|
8
|
+
"sessionIdentityHash": "raw-session",
|
|
9
|
+
"toolCallIdentityHash": "raw-tool",
|
|
10
|
+
"commandDigest": "raw-command",
|
|
11
|
+
"observedAt": "invalid",
|
|
12
|
+
"capturedAt": "invalid",
|
|
13
|
+
"retentionUntil": "invalid",
|
|
14
|
+
"exitCode": 1,
|
|
15
|
+
"outcome": "passed",
|
|
16
|
+
"treeDigest": "unknown",
|
|
17
|
+
"fileCount": 1,
|
|
18
|
+
"exposedPathCount": 1,
|
|
19
|
+
"files": [],
|
|
20
|
+
"integrityDigest": "sha256:0000000000000000000000000000000000000000000000000000000000000000"
|
|
21
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
{
|
|
2
|
+
"schemaVersion": 1,
|
|
3
|
+
"version": "piagent-verifier-file-snapshot-v1",
|
|
4
|
+
"attemptId": "verifier.165224a1269311b35faa7c68a3285dec225f563a761d8984b3f0e5525a3837d9",
|
|
5
|
+
"attemptRef": "verifier-evidence.165224a1269311b35faa7c68a3285dec225f563a761d8984b3f0e5525a3837d9",
|
|
6
|
+
"taskId": "task-01",
|
|
7
|
+
"taskRunId": "task-01-run-01",
|
|
8
|
+
"sessionIdentityHash": "sha256:6e165fadbb274b7254278eadb81c25aaa7fda6b62c3f2c6f8ca393b34f90834e",
|
|
9
|
+
"toolCallIdentityHash": "sha256:4dd7feedf5ee29f32ee3a58080756f540d67d815fb658d836f77d959b6c33c49",
|
|
10
|
+
"commandDigest": "sha256:328e123c63857fd8473bd4bd3581e655b08b7440d7f5d2c31cc375607582f539",
|
|
11
|
+
"observedAt": "2026-08-13T16:00:00.000Z",
|
|
12
|
+
"capturedAt": "2026-08-13T16:00:01.000Z",
|
|
13
|
+
"retentionUntil": "2026-09-12T16:00:01.000Z",
|
|
14
|
+
"exitCode": 0,
|
|
15
|
+
"outcome": "passed",
|
|
16
|
+
"treeDigest": "wt-content-v2:19d7d78c84028ca50754225c92b10733bc8a5bf2fe4dbf89042aa14352159f46",
|
|
17
|
+
"fileCount": 0,
|
|
18
|
+
"exposedPathCount": 0,
|
|
19
|
+
"files": [],
|
|
20
|
+
"integrityDigest": "sha256:afcb27f99d5ba2c52410075f4c42a3bb00209354df9edb8349ee463579e1fc66"
|
|
21
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@piagent/platform",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public",
|
|
@@ -43,12 +43,20 @@
|
|
|
43
43
|
"packs/",
|
|
44
44
|
"packages/piagent-core/",
|
|
45
45
|
"!packages/piagent-core/extensions/core-services.js",
|
|
46
|
+
"packages/piagent-webui/package.json",
|
|
47
|
+
"packages/piagent-webui/server/",
|
|
48
|
+
"packages/piagent-webui/extension/",
|
|
49
|
+
"packages/piagent-webui/gateway/",
|
|
50
|
+
"packages/piagent-webui/ownership/",
|
|
51
|
+
"packages/piagent-webui/dist/client/",
|
|
46
52
|
"schemas/",
|
|
47
53
|
"scripts/",
|
|
48
54
|
"templates/",
|
|
49
55
|
"types/"
|
|
50
56
|
],
|
|
51
57
|
"bin": {
|
|
58
|
+
"piagent": "scripts/piagent-cli.mjs",
|
|
59
|
+
"piagent-dashboard": "scripts/piagent-cli.mjs",
|
|
52
60
|
"piagent-setup": "scripts/piagent-cli.mjs",
|
|
53
61
|
"piagent-install": "scripts/piagent-cli.mjs",
|
|
54
62
|
"piagent-update": "scripts/piagent-cli.mjs",
|
|
@@ -66,11 +74,13 @@
|
|
|
66
74
|
"piagent-migrate": "scripts/piagent-cli.mjs",
|
|
67
75
|
"piagent-import-instructions": "scripts/piagent-cli.mjs",
|
|
68
76
|
"piagent-auto": "scripts/piagent-cli.mjs",
|
|
69
|
-
"piagent-context": "scripts/piagent-cli.mjs"
|
|
77
|
+
"piagent-context": "scripts/piagent-cli.mjs",
|
|
78
|
+
"piagent-webui": "scripts/piagent-cli.mjs"
|
|
70
79
|
},
|
|
71
80
|
"pi": {
|
|
72
81
|
"extensions": [
|
|
73
|
-
"packages/piagent-core/extensions/piagent-guard.ts"
|
|
82
|
+
"packages/piagent-core/extensions/piagent-guard.ts",
|
|
83
|
+
"packages/piagent-webui/extension/piagent-webui.ts"
|
|
74
84
|
],
|
|
75
85
|
"skills": [
|
|
76
86
|
"packages/piagent-core/skills"
|
|
@@ -84,6 +94,13 @@
|
|
|
84
94
|
]
|
|
85
95
|
}
|
|
86
96
|
},
|
|
97
|
+
"piagent": {
|
|
98
|
+
"runtimeIntegrityEntrypoints": [
|
|
99
|
+
"packages/piagent-webui/server/sidecar-main.ts",
|
|
100
|
+
"scripts/register-typescript-loader.mjs",
|
|
101
|
+
"scripts/typescript-loader.mjs"
|
|
102
|
+
]
|
|
103
|
+
},
|
|
87
104
|
"peerDependencies": {
|
|
88
105
|
"@earendil-works/pi-ai": "0.84.1",
|
|
89
106
|
"@earendil-works/pi-coding-agent": "0.84.1",
|
|
@@ -100,8 +117,16 @@
|
|
|
100
117
|
"optional": true
|
|
101
118
|
}
|
|
102
119
|
},
|
|
120
|
+
"dependencies": {
|
|
121
|
+
"ws": "8.21.3"
|
|
122
|
+
},
|
|
103
123
|
"devDependencies": {
|
|
124
|
+
"@axe-core/playwright": "4.13.0",
|
|
125
|
+
"@playwright/test": "1.62.1",
|
|
104
126
|
"@types/node": "^26.1.1",
|
|
127
|
+
"@types/ws": "8.18.1",
|
|
128
|
+
"ajv": "^8.20.0",
|
|
129
|
+
"ajv-formats": "^3.0.1",
|
|
105
130
|
"typescript": "^7.0.2"
|
|
106
131
|
},
|
|
107
132
|
"workspaces": [
|
|
@@ -110,6 +135,7 @@
|
|
|
110
135
|
"scripts": {
|
|
111
136
|
"verify": "bash scripts/verify-local.sh",
|
|
112
137
|
"test": "PIAGENT_NO_UPDATE_CHECK=1 node --test tests/*.test.mjs",
|
|
138
|
+
"test:webui:e2e": "playwright test --config playwright.webui.config.mjs",
|
|
113
139
|
"test:policy": "node --test tests/policy-core.test.mjs",
|
|
114
140
|
"test:golden": "node --test tests/golden-enforcement.test.mjs",
|
|
115
141
|
"typecheck": "tsc --noEmit",
|
|
@@ -129,6 +155,7 @@
|
|
|
129
155
|
"site:check": "node scripts/check-published-site.mjs",
|
|
130
156
|
"architecture:check": "node scripts/check-architecture.mjs",
|
|
131
157
|
"docs:check": "node scripts/check-doc-languages.mjs",
|
|
158
|
+
"docs:neutrality": "node scripts/check-third-party-neutrality.mjs",
|
|
132
159
|
"smoke": "bash scripts/runtime-policy-smoke.sh",
|
|
133
160
|
"usage": "bash scripts/pi-session-stats.sh",
|
|
134
161
|
"auto": "bash scripts/pi-auto.sh",
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export function validBenchmarkCandidateProvenance(value: unknown): boolean;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export function benchmarkCandidateProvenance(root: string): Record<string, unknown>;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export type BenchmarkLedgerBinding = { schemaVersion: 1; algorithm: string; digest: string; records: number; bytes: number };
|
|
2
|
+
export function inspectBenchmarkLedger(file: string): { binding: BenchmarkLedgerBinding; records: unknown[]; raw: Buffer };
|
|
3
|
+
export function assertBenchmarkLedgerBinding(expected: unknown, observed: unknown, label?: string): BenchmarkLedgerBinding;
|
|
4
|
+
export function validateBenchmarkLedgerPrefix(records: unknown[], order: unknown[], completedRecord: (record: unknown) => boolean): Set<string>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export function completedBenchmarkRecord(record: unknown): boolean;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export function benchmarkGitEnvironment(): NodeJS.ProcessEnv;
|
|
@@ -3,7 +3,7 @@ import fs from "node:fs";
|
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
import { containsSensitiveText } from "../security/sensitive-data.js";
|
|
5
5
|
import { resolveProjectProfileDocument } from "./project-profile.js";
|
|
6
|
-
import {
|
|
6
|
+
import { discoverRuntimeIntegrityFiles } from "./runtime-integrity.js";
|
|
7
7
|
|
|
8
8
|
const API_VERSION = "piagent/v1";
|
|
9
9
|
const CORE_API_VERSION = 1;
|
|
@@ -798,7 +798,7 @@ function buildCoreIntegrity(root) {
|
|
|
798
798
|
"packages/piagent-core/capabilities/project-profile.js",
|
|
799
799
|
"packages/piagent-core/security/sensitive-data.js",
|
|
800
800
|
"packages/piagent-core/extensions/piagent-guard.ts",
|
|
801
|
-
...
|
|
801
|
+
...discoverRuntimeIntegrityFiles(root),
|
|
802
802
|
// context-engine.js decides which repository content enters the model
|
|
803
803
|
// context and records the resulting telemetry, so it is part of the
|
|
804
804
|
// runtime trust boundary enforced by the profile lock.
|
|
@@ -0,0 +1,280 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
|
|
4
|
+
import { sha256, stableJson, verifyCapabilityLock } from "./capability-core.js";
|
|
5
|
+
import { resolveProjectProfileDocument } from "./project-profile.js";
|
|
6
|
+
|
|
7
|
+
const compare = (left, right) => String(left).localeCompare(String(right), "en");
|
|
8
|
+
const MAX_PACK_ENTRIES = 256;
|
|
9
|
+
const MAX_ARTIFACTS_PER_KIND = 128;
|
|
10
|
+
const MAX_JSON_BYTES = 256 * 1024;
|
|
11
|
+
|
|
12
|
+
// Full capability resolution deliberately hashes every executable runtime file.
|
|
13
|
+
// That is the right cold-path check, but not useful per-call work. This cache
|
|
14
|
+
// remembers only a `current` full verification. Reuse still walks strong
|
|
15
|
+
// metadata for every input that produced it; any change or error falls back to
|
|
16
|
+
// the cryptographic verifier.
|
|
17
|
+
export function createCapabilityVerificationCache() {
|
|
18
|
+
return new Map();
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function cacheRootForPack(rootReal, pack, extraRoots) {
|
|
22
|
+
return pack.origin === "workspace"
|
|
23
|
+
? rootReal
|
|
24
|
+
: extraRoots.find((entry) => entry.origin === pack.origin)?.root;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function addTarget(targets, target, kind, optional = false) {
|
|
28
|
+
const absolute = path.resolve(target);
|
|
29
|
+
const previous = targets.get(absolute);
|
|
30
|
+
if (!previous || previous.kind !== "directory") targets.set(absolute, { path: absolute, kind, optional });
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function containedTarget(root, relativePath) {
|
|
34
|
+
if (typeof relativePath !== "string" || path.isAbsolute(relativePath)) return undefined;
|
|
35
|
+
const absolute = path.resolve(root, relativePath);
|
|
36
|
+
const relative = path.relative(root, absolute);
|
|
37
|
+
return relative.startsWith("..") || path.isAbsolute(relative) ? undefined : absolute;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function readBoundedJson(file) {
|
|
41
|
+
const stat = fs.lstatSync(file);
|
|
42
|
+
if (stat.isSymbolicLink() || !stat.isFile() || stat.size > MAX_JSON_BYTES) return undefined;
|
|
43
|
+
try {
|
|
44
|
+
return JSON.parse(fs.readFileSync(file, "utf8"));
|
|
45
|
+
} catch {
|
|
46
|
+
return undefined;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function addEvalInputs(targets, packRoot, artifactPath) {
|
|
51
|
+
const artifact = readBoundedJson(artifactPath);
|
|
52
|
+
const profile = containedTarget(packRoot, artifact?.spec?.profile);
|
|
53
|
+
const fixture = containedTarget(packRoot, artifact?.spec?.fixture?.path);
|
|
54
|
+
if (!profile || !fixture) return false;
|
|
55
|
+
addTarget(targets, profile, "file");
|
|
56
|
+
addTarget(targets, fixture, "file");
|
|
57
|
+
return true;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
function addCatalogTargets(targets, packRoot) {
|
|
61
|
+
const packsDirectory = path.join(packRoot, "packs");
|
|
62
|
+
addTarget(targets, packsDirectory, "directory");
|
|
63
|
+
const entries = fs.readdirSync(packsDirectory, { withFileTypes: true })
|
|
64
|
+
.filter((entry) => !entry.name.startsWith("."));
|
|
65
|
+
if (entries.length > MAX_PACK_ENTRIES) return false;
|
|
66
|
+
for (const entry of entries) {
|
|
67
|
+
if (!entry.isDirectory() || entry.isSymbolicLink?.()) return false;
|
|
68
|
+
const packDirectory = path.join(packsDirectory, entry.name);
|
|
69
|
+
addTarget(targets, packDirectory, "directory");
|
|
70
|
+
const manifestPath = path.join(packDirectory, "pack.json");
|
|
71
|
+
addTarget(targets, manifestPath, "file");
|
|
72
|
+
const manifest = readBoundedJson(manifestPath);
|
|
73
|
+
const provides = manifest?.spec?.provides;
|
|
74
|
+
if (!provides || typeof provides !== "object" || Array.isArray(provides)) return false;
|
|
75
|
+
for (const [kind, artifacts] of Object.entries(provides)) {
|
|
76
|
+
if (!Array.isArray(artifacts) || artifacts.length > MAX_ARTIFACTS_PER_KIND) return false;
|
|
77
|
+
for (const artifact of artifacts) {
|
|
78
|
+
const target = containedTarget(packRoot, artifact?.path);
|
|
79
|
+
if (!target) return false;
|
|
80
|
+
addTarget(targets, target, "file");
|
|
81
|
+
if (kind === "evals" && !addEvalInputs(targets, packRoot, target)) return false;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
return true;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
function verificationTargets(root, profilePath, lockPath, document, options = {}) {
|
|
89
|
+
const rootReal = fs.realpathSync(root);
|
|
90
|
+
const targets = new Map();
|
|
91
|
+
addTarget(targets, profilePath, "file");
|
|
92
|
+
addTarget(targets, lockPath, "file");
|
|
93
|
+
for (const target of options.identityFiles ?? []) addTarget(targets, target, "file", true);
|
|
94
|
+
|
|
95
|
+
const extraRoots = options.extraRoots ?? [];
|
|
96
|
+
const packRoots = new Map();
|
|
97
|
+
for (const pack of document?.packs ?? []) {
|
|
98
|
+
const packRoot = cacheRootForPack(rootReal, pack, extraRoots);
|
|
99
|
+
if (!packRoot) continue;
|
|
100
|
+
packRoots.set(`${pack.name}@${pack.version}`, packRoot);
|
|
101
|
+
addTarget(targets, path.join(packRoot, "packs"), "directory");
|
|
102
|
+
addTarget(targets, path.join(packRoot, "packs", pack.name), "directory");
|
|
103
|
+
addTarget(targets, path.join(packRoot, "packs", pack.name, "pack.json"), "file");
|
|
104
|
+
}
|
|
105
|
+
for (const entry of extraRoots) {
|
|
106
|
+
addTarget(targets, entry.root, "directory");
|
|
107
|
+
addTarget(targets, path.join(entry.root, "packs"), "directory");
|
|
108
|
+
}
|
|
109
|
+
for (const packRoot of [rootReal, ...extraRoots.map((entry) => entry.root)]) {
|
|
110
|
+
if (!addCatalogTargets(targets, packRoot)) return undefined;
|
|
111
|
+
}
|
|
112
|
+
for (const entry of document?.core?.runtimeFiles ?? []) {
|
|
113
|
+
const target = containedTarget(rootReal, entry.path);
|
|
114
|
+
if (!target) return undefined;
|
|
115
|
+
addTarget(targets, target, "file");
|
|
116
|
+
}
|
|
117
|
+
for (const artifact of document?.artifacts ?? []) {
|
|
118
|
+
const artifactRoot = packRoots.get(artifact.pack);
|
|
119
|
+
if (!artifactRoot) continue;
|
|
120
|
+
const target = containedTarget(artifactRoot, artifact.path);
|
|
121
|
+
if (!target) return undefined;
|
|
122
|
+
addTarget(targets, target, "file");
|
|
123
|
+
}
|
|
124
|
+
return [...targets.values()].sort((left, right) => compare(left.path, right.path));
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
function statIdentity(stat, includeTimes) {
|
|
128
|
+
const values = [stat.dev, stat.ino, stat.mode, stat.nlink, stat.uid, stat.gid, stat.rdev, stat.size];
|
|
129
|
+
if (includeTimes) values.push(stat.mtimeNs, stat.ctimeNs);
|
|
130
|
+
return values.map(String).join(":");
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
function ancestorIdentity(stat) {
|
|
134
|
+
return [stat.dev, stat.ino, stat.mode, stat.uid, stat.gid, stat.rdev]
|
|
135
|
+
.map(String)
|
|
136
|
+
.join(":");
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
function lexicalAncestors(target) {
|
|
140
|
+
const parsed = path.parse(target);
|
|
141
|
+
const segments = target.slice(parsed.root.length).split(path.sep).filter(Boolean);
|
|
142
|
+
const ancestors = [];
|
|
143
|
+
let current = parsed.root;
|
|
144
|
+
for (const segment of segments.slice(0, -1)) {
|
|
145
|
+
current = path.join(current, segment);
|
|
146
|
+
ancestors.push(current);
|
|
147
|
+
}
|
|
148
|
+
return ancestors;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
function metadataSignature(targets) {
|
|
152
|
+
if (!targets) return undefined;
|
|
153
|
+
const records = [];
|
|
154
|
+
const ancestors = new Set(targets.flatMap((target) => lexicalAncestors(target.path)));
|
|
155
|
+
try {
|
|
156
|
+
for (const ancestor of [...ancestors].sort(compare)) {
|
|
157
|
+
const stat = fs.lstatSync(ancestor, { bigint: true });
|
|
158
|
+
const symbolic = stat.isSymbolicLink();
|
|
159
|
+
const identity = symbolic ? statIdentity(stat, true) : ancestorIdentity(stat);
|
|
160
|
+
records.push(`a:${ancestor}:${identity}:${symbolic ? fs.readlinkSync(ancestor) : "directory"}`);
|
|
161
|
+
}
|
|
162
|
+
for (const target of targets) {
|
|
163
|
+
let lexical;
|
|
164
|
+
try {
|
|
165
|
+
lexical = fs.lstatSync(target.path, { bigint: true });
|
|
166
|
+
} catch (error) {
|
|
167
|
+
if (target.optional && error?.code === "ENOENT") {
|
|
168
|
+
records.push(`t:${target.path}:absent`);
|
|
169
|
+
continue;
|
|
170
|
+
}
|
|
171
|
+
return undefined;
|
|
172
|
+
}
|
|
173
|
+
const expectedType = target.kind === "directory" ? lexical.isDirectory() : lexical.isFile();
|
|
174
|
+
if (!expectedType || lexical.isSymbolicLink()) return undefined;
|
|
175
|
+
records.push(`t:${target.path}:${statIdentity(lexical, true)}`);
|
|
176
|
+
}
|
|
177
|
+
} catch {
|
|
178
|
+
return undefined;
|
|
179
|
+
}
|
|
180
|
+
return sha256(records.join("\n"));
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
const cacheKey = (root, profilePath, lockPath) => (
|
|
184
|
+
`${path.resolve(root)}\0${path.resolve(profilePath)}\0${path.resolve(lockPath)}`
|
|
185
|
+
);
|
|
186
|
+
|
|
187
|
+
function cacheIdentity(lockDocument, options = {}) {
|
|
188
|
+
return sha256(stableJson({
|
|
189
|
+
lockDocument,
|
|
190
|
+
packageSource: options.packageSource,
|
|
191
|
+
extraRoots: (options.extraRoots ?? []).map((entry) => ({ origin: entry.origin, root: entry.root, source: entry.source })),
|
|
192
|
+
identityFiles: (options.identityFiles ?? []).map((entry) => path.resolve(entry)).sort(compare)
|
|
193
|
+
}));
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
function snapshotTargets(targets) {
|
|
197
|
+
const signature = metadataSignature(targets);
|
|
198
|
+
return signature ? { signature, targets } : undefined;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
function stableSnapshot(snapshot) {
|
|
202
|
+
if (!snapshot) return false;
|
|
203
|
+
const current = metadataSignature(snapshot.targets);
|
|
204
|
+
return Boolean(current && current === snapshot.signature);
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
export function verifyCapabilityLockCached(cache, root, profilePath, lockPath, lockDocument, options = {}) {
|
|
208
|
+
const key = cacheKey(root, profilePath, lockPath);
|
|
209
|
+
const identity = cacheIdentity(lockDocument, options);
|
|
210
|
+
const cached = options.forceFull === true ? undefined : cache?.get(key);
|
|
211
|
+
if (cached?.identity === identity) {
|
|
212
|
+
const signature = metadataSignature(cached.targets);
|
|
213
|
+
if (signature && signature === cached.signature) return { ...cached.verification, cacheStatus: "hit" };
|
|
214
|
+
}
|
|
215
|
+
cache?.delete(key);
|
|
216
|
+
|
|
217
|
+
const initialTargets = verificationTargets(root, profilePath, lockPath, lockDocument, options);
|
|
218
|
+
const before = snapshotTargets(initialTargets);
|
|
219
|
+
const verification = verifyCapabilityLock(root, profilePath, lockDocument, options);
|
|
220
|
+
options.afterFullVerify?.();
|
|
221
|
+
if (verification.status === "current" && before) {
|
|
222
|
+
const after = snapshotTargets(verificationTargets(root, profilePath, lockPath, verification.expected, options));
|
|
223
|
+
if (after && before.signature === after.signature && stableSnapshot(after)) {
|
|
224
|
+
cache?.set(key, { identity, ...after, verification });
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
return { ...verification, cacheStatus: "verified" };
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
export function verifyProjectCapabilityStateCached(input) {
|
|
231
|
+
const { cache, cwd, platformRoot, profilePath, lockPath, lockDocument, storedProfile } = input;
|
|
232
|
+
const profile = resolveProjectProfileDocument(platformRoot, storedProfile).profile;
|
|
233
|
+
if (!Array.isArray(profile.capabilityPacks)) return { ok: true };
|
|
234
|
+
const packageSource = input.packageSource(cwd);
|
|
235
|
+
const extraRoots = input.extraRoots(cwd, profile);
|
|
236
|
+
const identityFiles = [path.join(cwd, ".pi", "settings.json")];
|
|
237
|
+
if (typeof storedProfile.extends === "string" && /^[a-z0-9][a-z0-9-]{0,63}$/.test(storedProfile.extends)) {
|
|
238
|
+
identityFiles.push(path.join(platformRoot, "adapters", storedProfile.extends, "profile.json"));
|
|
239
|
+
}
|
|
240
|
+
const verificationOptions = { packageSource, extraRoots, identityFiles, forceFull: input.forceFull === true };
|
|
241
|
+
const verification = verifyCapabilityLockCached(cache, platformRoot, profilePath, lockPath, lockDocument, verificationOptions);
|
|
242
|
+
const runtimeDigest = verification.expected?.core?.packageDigest;
|
|
243
|
+
if (input.allowRepin !== true && input.sessionDigest && runtimeDigest !== input.sessionDigest) {
|
|
244
|
+
return { ok: false, reason: "Installed Piagent runtime changed during this session. Restart the session to verify and re-pin the capability lock before using tools." };
|
|
245
|
+
}
|
|
246
|
+
if (verification.status === "repin" && input.allowRepin !== true) {
|
|
247
|
+
return { ok: false, reason: "Installed Piagent runtime changed during this session. Restart the session to verify and re-pin the capability lock before using tools." };
|
|
248
|
+
}
|
|
249
|
+
if (verification.status === "blocked") {
|
|
250
|
+
return { ok: false, reason: `Capability lock does not match what this project agreed to: ${verification.reasons.join("; ")}. Reapply the project profile.` };
|
|
251
|
+
}
|
|
252
|
+
const granted = {
|
|
253
|
+
filesystemRead: verification.expected.permissions.filesystemRead,
|
|
254
|
+
filesystemWrite: verification.expected.permissions.filesystemWrite
|
|
255
|
+
};
|
|
256
|
+
if (verification.status !== "repin") {
|
|
257
|
+
if (input.allowRepin === true) input.rememberSessionDigest?.(runtimeDigest);
|
|
258
|
+
return { ok: true, ...granted };
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
try {
|
|
262
|
+
input.writeLock(lockPath, verification.expected);
|
|
263
|
+
} catch (error) {
|
|
264
|
+
return { ok: false, reason: `Capability lock is behind the installed platform and could not be rewritten: ${error instanceof Error ? error.message : String(error)}` };
|
|
265
|
+
}
|
|
266
|
+
input.afterRepinWrite?.();
|
|
267
|
+
const confirmed = verifyCapabilityLockCached(
|
|
268
|
+
cache,
|
|
269
|
+
platformRoot,
|
|
270
|
+
profilePath,
|
|
271
|
+
lockPath,
|
|
272
|
+
verification.expected,
|
|
273
|
+
{ ...verificationOptions, forceFull: true }
|
|
274
|
+
);
|
|
275
|
+
if (confirmed.status !== "current") {
|
|
276
|
+
return { ok: false, reason: "Installed Piagent runtime changed while the capability lock was being re-pinned. Restart the session and try again." };
|
|
277
|
+
}
|
|
278
|
+
input.rememberSessionDigest?.(runtimeDigest);
|
|
279
|
+
return { ok: true, repinned: verification.reasons.join("; "), ...granted };
|
|
280
|
+
}
|