@piagent/platform 1.3.1 → 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 +39 -0
- 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 +1 -0
- 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 +7 -6
- 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/runtime-integrity.js +143 -0
- package/packages/piagent-core/extensions/piagent-guard.ts +62 -37
- package/packages/piagent-core/extensions/redaction-core.d.ts +2 -0
- 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,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.
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
|
|
1
4
|
export const CORE_RUNTIME_INTEGRITY_FILES = Object.freeze([
|
|
2
5
|
"packages/piagent-core/runtime/context/adaptive-planner.ts",
|
|
3
6
|
"packages/piagent-core/runtime/context/retrieval-route-policy.ts",
|
|
@@ -31,7 +34,53 @@ export const CORE_RUNTIME_INTEGRITY_FILES = Object.freeze([
|
|
|
31
34
|
"packages/piagent-core/runtime/hooks/session-start-hook.ts",
|
|
32
35
|
"packages/piagent-core/runtime/hooks/tool-call-hook.ts",
|
|
33
36
|
"packages/piagent-core/runtime/hooks/tool-result-hook.ts",
|
|
37
|
+
"packages/piagent-core/runtime/hooks/tool-result-metadata.ts",
|
|
34
38
|
"packages/piagent-core/runtime/input/chat-images.ts",
|
|
39
|
+
"packages/piagent-core/runtime/inspection/activity-event-adapter.ts",
|
|
40
|
+
"packages/piagent-core/runtime/inspection/approval-broker.ts",
|
|
41
|
+
"packages/piagent-core/runtime/inspection/criteria-links.ts",
|
|
42
|
+
"packages/piagent-core/runtime/inspection/commit-summary-projection.ts",
|
|
43
|
+
"packages/piagent-core/runtime/inspection/diff-projection.ts",
|
|
44
|
+
"packages/piagent-core/runtime/inspection/git-numstat-adapter.ts",
|
|
45
|
+
"packages/piagent-core/runtime/inspection/git-filter-safety.ts",
|
|
46
|
+
"packages/piagent-core/runtime/inspection/git-status-adapter.ts",
|
|
47
|
+
"packages/piagent-core/runtime/inspection/git-tree-adapter.ts",
|
|
48
|
+
"packages/piagent-core/runtime/inspection/mcp-control.ts",
|
|
49
|
+
"packages/piagent-core/runtime/inspection/mutation-provenance-contract.ts",
|
|
50
|
+
"packages/piagent-core/runtime/inspection/mutation-provenance-recorder.ts",
|
|
51
|
+
"packages/piagent-core/runtime/inspection/mutation-provenance-store.ts",
|
|
52
|
+
"packages/piagent-core/runtime/inspection/project-runtime-inspection.ts",
|
|
53
|
+
"packages/piagent-core/runtime/inspection/review-state-contract.ts",
|
|
54
|
+
"packages/piagent-core/runtime/inspection/review-state-projection.ts",
|
|
55
|
+
"packages/piagent-core/runtime/inspection/review-state-store.ts",
|
|
56
|
+
"packages/piagent-core/runtime/inspection/runtime-event-store.ts",
|
|
57
|
+
"packages/piagent-core/runtime/inspection/same-process-bridge-proof.ts",
|
|
58
|
+
"packages/piagent-core/runtime/inspection/zero-turn-conformance.ts",
|
|
59
|
+
"packages/piagent-core/runtime/inspection/source-evidence-contract.ts",
|
|
60
|
+
"packages/piagent-core/runtime/inspection/source-evidence-store.ts",
|
|
61
|
+
"packages/piagent-core/runtime/inspection/source-inspection-plan.ts",
|
|
62
|
+
"packages/piagent-core/runtime/inspection/source-mutation-projection.ts",
|
|
63
|
+
"packages/piagent-core/runtime/inspection/source-mutation-store.ts",
|
|
64
|
+
"packages/piagent-core/runtime/inspection/source-revert-projection.ts",
|
|
65
|
+
"packages/piagent-core/runtime/inspection/source-handoff-store.ts",
|
|
66
|
+
"packages/piagent-core/runtime/inspection/source-open-target.ts",
|
|
67
|
+
"packages/piagent-core/runtime/inspection/task-run-index.ts",
|
|
68
|
+
"packages/piagent-core/runtime/inspection/task-recovery-timeline.ts",
|
|
69
|
+
"packages/piagent-core/runtime/inspection/task-compaction-history.ts",
|
|
70
|
+
"packages/piagent-core/runtime/inspection/context-telemetry-inspection.ts",
|
|
71
|
+
"packages/piagent-core/runtime/inspection/task-handoff-history.ts",
|
|
72
|
+
"packages/piagent-core/runtime/inspection/task-subagent-tree.ts",
|
|
73
|
+
"packages/piagent-core/runtime/inspection/task-baseline-start-capture.ts",
|
|
74
|
+
"packages/piagent-core/runtime/inspection/task-control-journal.ts",
|
|
75
|
+
"packages/piagent-core/runtime/inspection/task-source-projection.ts",
|
|
76
|
+
"packages/piagent-core/runtime/inspection/task-provenance-projection.ts",
|
|
77
|
+
"packages/piagent-core/runtime/inspection/verifier-snapshot-contract.ts",
|
|
78
|
+
"packages/piagent-core/runtime/inspection/verifier-snapshot-store.ts",
|
|
79
|
+
"packages/piagent-core/runtime/inspection/webui-snapshot.ts",
|
|
80
|
+
"packages/piagent-core/runtime/inspection/text-diff.ts",
|
|
81
|
+
"packages/piagent-core/runtime/inspection/source-change-projection.ts",
|
|
82
|
+
"packages/piagent-core/runtime/inspection/workspace-file-reader.ts",
|
|
83
|
+
"packages/piagent-core/runtime/inspection/workspace-source-projection.ts",
|
|
35
84
|
"packages/piagent-core/runtime/model/capabilities.ts",
|
|
36
85
|
"packages/piagent-core/runtime/model/authenticated-catalog.ts",
|
|
37
86
|
"packages/piagent-core/runtime/model/model-route-policy.ts",
|
|
@@ -42,6 +91,10 @@ export const CORE_RUNTIME_INTEGRITY_FILES = Object.freeze([
|
|
|
42
91
|
"packages/piagent-core/runtime/model/snapshot-telemetry.ts",
|
|
43
92
|
"packages/piagent-core/runtime/policy/authority-manifest.ts",
|
|
44
93
|
"packages/piagent-core/runtime/policy/authority-resume-policy.ts",
|
|
94
|
+
"packages/piagent-core/runtime/policy/source-index-transaction.ts",
|
|
95
|
+
"packages/piagent-core/runtime/policy/source-mutation-guard-binding.ts",
|
|
96
|
+
"packages/piagent-core/runtime/policy/source-mutation-guard.ts",
|
|
97
|
+
"packages/piagent-core/runtime/policy/source-worktree-transaction.ts",
|
|
45
98
|
"packages/piagent-core/runtime/policy/task-authority-runtime.ts",
|
|
46
99
|
"packages/piagent-core/runtime/orchestration/role-policy.ts",
|
|
47
100
|
"packages/piagent-core/runtime/orchestration/role-binder.ts",
|
|
@@ -106,3 +159,93 @@ export const CORE_RUNTIME_INTEGRITY_FILES = Object.freeze([
|
|
|
106
159
|
"scripts/register-typescript-loader.mjs",
|
|
107
160
|
"scripts/typescript-loader.mjs"
|
|
108
161
|
]);
|
|
162
|
+
|
|
163
|
+
const EXECUTABLE_SOURCE = /\.(?:[cm]?js|ts|json|sh)$/;
|
|
164
|
+
const IMPORT_SPECIFIER = /(?:\bimport\s*(?:type\s+)?(?:[^"'`]*?\s+from\s*)?|\bexport\s+(?:type\s+)?[^"'`]*?\s+from\s*)["']([^"']+)["']/g;
|
|
165
|
+
const DYNAMIC_IMPORT = /\bimport\(\s*["']([^"']+)["']\s*\)/g;
|
|
166
|
+
const RUNTIME_LITERAL = /["']((?:packages|scripts)\/[A-Za-z0-9_./-]+\.(?:[cm]?js|ts|json|sh))["']/g;
|
|
167
|
+
const MAX_INTEGRITY_FILES = 5_000;
|
|
168
|
+
|
|
169
|
+
function normalizedRelative(root, absolute) {
|
|
170
|
+
const relative = path.relative(root, absolute);
|
|
171
|
+
if (!relative || relative.startsWith("..") || path.isAbsolute(relative)) return undefined;
|
|
172
|
+
return relative.split(path.sep).join("/");
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
function executableFilesBelow(root, relativeDirectory) {
|
|
176
|
+
const directory = path.join(root, relativeDirectory);
|
|
177
|
+
if (!fs.existsSync(directory)) return [];
|
|
178
|
+
const files = [];
|
|
179
|
+
const visit = (absolute) => {
|
|
180
|
+
const entries = fs.readdirSync(absolute, { withFileTypes: true });
|
|
181
|
+
for (const entry of entries) {
|
|
182
|
+
const target = path.join(absolute, entry.name), stat = fs.lstatSync(target);
|
|
183
|
+
if (stat.isSymbolicLink()) throw new Error(`runtime-integrity-symlink:${normalizedRelative(root, target) ?? "outside-root"}`);
|
|
184
|
+
if (stat.isDirectory()) visit(target);
|
|
185
|
+
else if (stat.isFile() && EXECUTABLE_SOURCE.test(entry.name)) files.push(normalizedRelative(root, target));
|
|
186
|
+
}
|
|
187
|
+
};
|
|
188
|
+
visit(directory);
|
|
189
|
+
return files.filter(Boolean);
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
function localImportTarget(root, importer, specifier) {
|
|
193
|
+
if (!specifier.startsWith(".")) return undefined;
|
|
194
|
+
const base = path.resolve(path.dirname(path.join(root, importer)), specifier);
|
|
195
|
+
const candidates = [base, `${base}.ts`, `${base}.js`, `${base}.mjs`, path.join(base, "index.ts"), path.join(base, "index.js")];
|
|
196
|
+
for (const candidate of candidates) {
|
|
197
|
+
const relative = normalizedRelative(root, candidate);
|
|
198
|
+
if (!relative || !fs.existsSync(candidate)) continue;
|
|
199
|
+
const stat = fs.lstatSync(candidate);
|
|
200
|
+
if (stat.isSymbolicLink()) throw new Error(`runtime-integrity-symlink:${relative}`);
|
|
201
|
+
if (stat.isFile() && EXECUTABLE_SOURCE.test(candidate)) return relative;
|
|
202
|
+
}
|
|
203
|
+
return undefined;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
function sourceReferences(root, relativeFile) {
|
|
207
|
+
if (!/\.(?:[cm]?js|ts)$/.test(relativeFile)) return [];
|
|
208
|
+
const source = fs.readFileSync(path.join(root, relativeFile), "utf8"), references = new Set();
|
|
209
|
+
for (const pattern of [IMPORT_SPECIFIER, DYNAMIC_IMPORT]) {
|
|
210
|
+
pattern.lastIndex = 0;
|
|
211
|
+
for (let match = pattern.exec(source); match; match = pattern.exec(source)) {
|
|
212
|
+
const target = localImportTarget(root, relativeFile, match[1]);
|
|
213
|
+
if (target) references.add(target);
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
RUNTIME_LITERAL.lastIndex = 0;
|
|
217
|
+
for (let match = RUNTIME_LITERAL.exec(source); match; match = RUNTIME_LITERAL.exec(source)) {
|
|
218
|
+
const target = path.join(root, match[1]), relative = normalizedRelative(root, target);
|
|
219
|
+
if (relative && fs.existsSync(target) && fs.lstatSync(target).isFile()) references.add(relative);
|
|
220
|
+
}
|
|
221
|
+
return [...references];
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
export function discoverRuntimeIntegrityFiles(root) {
|
|
225
|
+
const packageDocument = JSON.parse(fs.readFileSync(path.join(root, "package.json"), "utf8"));
|
|
226
|
+
const declaredExtensions = Array.isArray(packageDocument.pi?.extensions) ? packageDocument.pi.extensions : [];
|
|
227
|
+
const declaredBins = packageDocument.bin && typeof packageDocument.bin === "object" ? Object.values(packageDocument.bin) : [];
|
|
228
|
+
const declaredEntrypoints = Array.isArray(packageDocument.piagent?.runtimeIntegrityEntrypoints)
|
|
229
|
+
? packageDocument.piagent.runtimeIntegrityEntrypoints : [];
|
|
230
|
+
const seeds = new Set([
|
|
231
|
+
...CORE_RUNTIME_INTEGRITY_FILES,
|
|
232
|
+
"packages/piagent-core/extensions/piagent-guard.ts",
|
|
233
|
+
...executableFilesBelow(root, "packages/piagent-core/runtime"),
|
|
234
|
+
...declaredExtensions,
|
|
235
|
+
...declaredBins,
|
|
236
|
+
...declaredEntrypoints
|
|
237
|
+
].filter((entry) => typeof entry === "string" && !path.isAbsolute(entry)));
|
|
238
|
+
const files = new Set(), pending = [...seeds];
|
|
239
|
+
while (pending.length) {
|
|
240
|
+
if (files.size >= MAX_INTEGRITY_FILES) throw new Error("runtime-integrity-file-limit");
|
|
241
|
+
const relative = pending.pop();
|
|
242
|
+
if (files.has(relative)) continue;
|
|
243
|
+
const absolute = path.join(root, relative), contained = normalizedRelative(root, absolute);
|
|
244
|
+
if (!contained || !fs.existsSync(absolute)) continue;
|
|
245
|
+
const stat = fs.lstatSync(absolute);
|
|
246
|
+
if (stat.isSymbolicLink() || !stat.isFile()) throw new Error(`runtime-integrity-file-unsafe:${relative}`);
|
|
247
|
+
files.add(contained);
|
|
248
|
+
for (const reference of sourceReferences(root, contained)) if (!files.has(reference)) pending.push(reference);
|
|
249
|
+
}
|
|
250
|
+
return [...files].sort((left, right) => left.localeCompare(right, "en"));
|
|
251
|
+
}
|