@caupulican/pi-adaptative 0.85.4 → 0.86.1
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 +65 -0
- package/dist/bun/cli.d.ts +1 -1
- package/dist/bun/cli.d.ts.map +1 -1
- package/dist/bun/cli.js +1 -0
- package/dist/bun/cli.js.map +1 -1
- package/dist/core/agent-paths.d.ts +3 -3
- package/dist/core/agent-paths.d.ts.map +1 -1
- package/dist/core/agent-paths.js +3 -3
- package/dist/core/agent-paths.js.map +1 -1
- package/dist/core/agent-session-runtime.d.ts +1 -1
- package/dist/core/agent-session-runtime.d.ts.map +1 -1
- package/dist/core/agent-session-runtime.js +1 -1
- package/dist/core/agent-session-runtime.js.map +1 -1
- package/dist/core/agent-session.d.ts +11 -5
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +14 -3
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/auth-storage.d.ts +2 -2
- package/dist/core/auth-storage.d.ts.map +1 -1
- package/dist/core/auth-storage.js +2 -2
- package/dist/core/auth-storage.js.map +1 -1
- package/dist/core/autonomy/bounded-completion.d.ts.map +1 -1
- package/dist/core/autonomy/bounded-completion.js +19 -8
- package/dist/core/autonomy/bounded-completion.js.map +1 -1
- package/dist/core/autonomy/lane-tool-surface.d.ts +11 -5
- package/dist/core/autonomy/lane-tool-surface.d.ts.map +1 -1
- package/dist/core/autonomy/lane-tool-surface.js +34 -8
- package/dist/core/autonomy/lane-tool-surface.js.map +1 -1
- package/dist/core/autonomy/subagent-prompt.d.ts +3 -3
- package/dist/core/autonomy/subagent-prompt.js +9 -9
- package/dist/core/autonomy/subagent-prompt.js.map +1 -1
- package/dist/core/background-lane-controller.d.ts +10 -8
- package/dist/core/background-lane-controller.d.ts.map +1 -1
- package/dist/core/background-lane-controller.js +23 -13
- package/dist/core/background-lane-controller.js.map +1 -1
- package/dist/core/bash-execution-controller.d.ts +4 -0
- package/dist/core/bash-execution-controller.d.ts.map +1 -1
- package/dist/core/bash-execution-controller.js +11 -4
- package/dist/core/bash-execution-controller.js.map +1 -1
- package/dist/core/bash-executor.d.ts +2 -0
- package/dist/core/bash-executor.d.ts.map +1 -1
- package/dist/core/bash-executor.js +4 -3
- package/dist/core/bash-executor.js.map +1 -1
- package/dist/core/billing-failover-controller.d.ts +2 -2
- package/dist/core/billing-failover-controller.d.ts.map +1 -1
- package/dist/core/billing-failover-controller.js +1 -1
- package/dist/core/billing-failover-controller.js.map +1 -1
- package/dist/core/capability-contract.d.ts +1 -1
- package/dist/core/capability-contract.d.ts.map +1 -1
- package/dist/core/capability-contract.js +0 -1
- package/dist/core/capability-contract.js.map +1 -1
- package/dist/core/compaction-controller.d.ts +8 -2
- package/dist/core/compaction-controller.d.ts.map +1 -1
- package/dist/core/compaction-controller.js +73 -3
- package/dist/core/compaction-controller.js.map +1 -1
- package/dist/core/compaction-support.d.ts +2 -2
- package/dist/core/compaction-support.d.ts.map +1 -1
- package/dist/core/compaction-support.js +9 -1
- package/dist/core/compaction-support.js.map +1 -1
- package/dist/core/context/artifact-retrieval.d.ts +1 -1
- package/dist/core/context/artifact-retrieval.d.ts.map +1 -1
- package/dist/core/context/artifact-retrieval.js +1 -1
- package/dist/core/context/artifact-retrieval.js.map +1 -1
- package/dist/core/context/context-artifacts.d.ts +6 -6
- package/dist/core/context/context-artifacts.d.ts.map +1 -1
- package/dist/core/context/context-artifacts.js +151 -63
- package/dist/core/context/context-artifacts.js.map +1 -1
- package/dist/core/context/context-composition.js +1 -1
- package/dist/core/context/context-composition.js.map +1 -1
- package/dist/core/context/context-store-retention.d.ts.map +1 -1
- package/dist/core/context/context-store-retention.js +5 -2
- package/dist/core/context/context-store-retention.js.map +1 -1
- package/dist/core/context/file-store-memory-provider.js +1 -1
- package/dist/core/context/file-store-memory-provider.js.map +1 -1
- package/dist/core/context/tool-output-packer.d.ts +1 -1
- package/dist/core/context/tool-output-packer.d.ts.map +1 -1
- package/dist/core/context/tool-output-packer.js +1 -1
- package/dist/core/context/tool-output-packer.js.map +1 -1
- package/dist/core/context-gc.d.ts.map +1 -1
- package/dist/core/context-gc.js +7 -5
- package/dist/core/context-gc.js.map +1 -1
- package/dist/core/context-pipeline.d.ts +2 -2
- package/dist/core/context-pipeline.d.ts.map +1 -1
- package/dist/core/context-pipeline.js +8 -4
- package/dist/core/context-pipeline.js.map +1 -1
- package/dist/core/cost/cost-summary.d.ts +1 -1
- package/dist/core/cost/cost-summary.d.ts.map +1 -1
- package/dist/core/cost/cost-summary.js +1 -1
- package/dist/core/cost/cost-summary.js.map +1 -1
- package/dist/core/cost/daily-usage.d.ts +1 -1
- package/dist/core/cost/daily-usage.d.ts.map +1 -1
- package/dist/core/cost/daily-usage.js +2 -2
- package/dist/core/cost/daily-usage.js.map +1 -1
- package/dist/core/cost/session-usage.d.ts +1 -1
- package/dist/core/cost/session-usage.d.ts.map +1 -1
- package/dist/core/cost/session-usage.js +1 -1
- package/dist/core/cost/session-usage.js.map +1 -1
- package/dist/core/default-tool-surface.d.ts +1 -0
- package/dist/core/default-tool-surface.d.ts.map +1 -1
- package/dist/core/default-tool-surface.js +3 -2
- package/dist/core/default-tool-surface.js.map +1 -1
- package/dist/core/delegation/worker-actions.js +1 -1
- package/dist/core/delegation/worker-actions.js.map +1 -1
- package/dist/core/delegation/worker-agent-control-coordinator.d.ts +27 -8
- package/dist/core/delegation/worker-agent-control-coordinator.d.ts.map +1 -1
- package/dist/core/delegation/worker-agent-control-coordinator.js +191 -33
- package/dist/core/delegation/worker-agent-control-coordinator.js.map +1 -1
- package/dist/core/delegation/worker-agent-control.d.ts +45 -6
- package/dist/core/delegation/worker-agent-control.d.ts.map +1 -1
- package/dist/core/delegation/worker-agent-control.js +110 -13
- package/dist/core/delegation/worker-agent-control.js.map +1 -1
- package/dist/core/delegation/worker-attempt-executor.d.ts +1 -1
- package/dist/core/delegation/worker-attempt-executor.d.ts.map +1 -1
- package/dist/core/delegation/worker-attempt-executor.js +180 -160
- package/dist/core/delegation/worker-attempt-executor.js.map +1 -1
- package/dist/core/delegation/worker-authority-resolver.d.ts +23 -0
- package/dist/core/delegation/worker-authority-resolver.d.ts.map +1 -0
- package/dist/core/delegation/worker-authority-resolver.js +128 -0
- package/dist/core/delegation/worker-authority-resolver.js.map +1 -0
- package/dist/core/delegation/worker-conversation-store.d.ts +2 -1
- package/dist/core/delegation/worker-conversation-store.d.ts.map +1 -1
- package/dist/core/delegation/worker-conversation-store.js +4 -3
- package/dist/core/delegation/worker-conversation-store.js.map +1 -1
- package/dist/core/delegation/worker-delegation-controller.d.ts +7 -1
- package/dist/core/delegation/worker-delegation-controller.d.ts.map +1 -1
- package/dist/core/delegation/worker-delegation-controller.js +260 -87
- package/dist/core/delegation/worker-delegation-controller.js.map +1 -1
- package/dist/core/delegation/worker-delegation-request.d.ts +25 -4
- package/dist/core/delegation/worker-delegation-request.d.ts.map +1 -1
- package/dist/core/delegation/worker-delegation-request.js +90 -1
- package/dist/core/delegation/worker-delegation-request.js.map +1 -1
- package/dist/core/delegation/worker-execution-policy.d.ts +2 -0
- package/dist/core/delegation/worker-execution-policy.d.ts.map +1 -1
- package/dist/core/delegation/worker-execution-policy.js +22 -12
- package/dist/core/delegation/worker-execution-policy.js.map +1 -1
- package/dist/core/delegation/worker-lifecycle.d.ts +1 -0
- package/dist/core/delegation/worker-lifecycle.d.ts.map +1 -1
- package/dist/core/delegation/worker-lifecycle.js +4 -2
- package/dist/core/delegation/worker-lifecycle.js.map +1 -1
- package/dist/core/delegation/worker-profile-resolver.d.ts +0 -2
- package/dist/core/delegation/worker-profile-resolver.d.ts.map +1 -1
- package/dist/core/delegation/worker-profile-resolver.js +8 -35
- package/dist/core/delegation/worker-profile-resolver.js.map +1 -1
- package/dist/core/delegation/worker-recovery-coordinator.d.ts.map +1 -1
- package/dist/core/delegation/worker-recovery-coordinator.js +1 -0
- package/dist/core/delegation/worker-recovery-coordinator.js.map +1 -1
- package/dist/core/delegation/worker-runner.d.ts +6 -1
- package/dist/core/delegation/worker-runner.d.ts.map +1 -1
- package/dist/core/delegation/worker-runner.js +20 -6
- package/dist/core/delegation/worker-runner.js.map +1 -1
- package/dist/core/delegation/worker-tree-budget-coordinator.d.ts +47 -0
- package/dist/core/delegation/worker-tree-budget-coordinator.d.ts.map +1 -0
- package/dist/core/delegation/worker-tree-budget-coordinator.js +210 -0
- package/dist/core/delegation/worker-tree-budget-coordinator.js.map +1 -0
- package/dist/core/extensions/builtin.d.ts +2 -2
- package/dist/core/extensions/builtin.d.ts.map +1 -1
- package/dist/core/extensions/builtin.js +2 -2
- package/dist/core/extensions/builtin.js.map +1 -1
- package/dist/core/extensions/bundled-virtual-modules.d.ts +2 -0
- package/dist/core/extensions/bundled-virtual-modules.d.ts.map +1 -0
- package/dist/core/extensions/bundled-virtual-modules.js +129 -0
- package/dist/core/extensions/bundled-virtual-modules.js.map +1 -0
- package/dist/core/extensions/factory-runtime.d.ts +22 -0
- package/dist/core/extensions/factory-runtime.d.ts.map +1 -0
- package/dist/core/extensions/factory-runtime.js +334 -0
- package/dist/core/extensions/factory-runtime.js.map +1 -0
- package/dist/core/extensions/index.d.ts +1 -1
- package/dist/core/extensions/index.d.ts.map +1 -1
- package/dist/core/extensions/index.js +1 -1
- package/dist/core/extensions/index.js.map +1 -1
- package/dist/core/extensions/lifecycle.d.ts +13 -0
- package/dist/core/extensions/lifecycle.d.ts.map +1 -0
- package/dist/core/extensions/lifecycle.js +52 -0
- package/dist/core/extensions/lifecycle.js.map +1 -0
- package/dist/core/extensions/loader.d.ts +3 -24
- package/dist/core/extensions/loader.d.ts.map +1 -1
- package/dist/core/extensions/loader.js +21 -531
- package/dist/core/extensions/loader.js.map +1 -1
- package/dist/core/extensions/virtual-modules.d.ts +51 -0
- package/dist/core/extensions/virtual-modules.d.ts.map +1 -0
- package/dist/core/extensions/virtual-modules.js +59 -0
- package/dist/core/extensions/virtual-modules.js.map +1 -0
- package/dist/core/foreground-recovery-controller.d.ts +2 -1
- package/dist/core/foreground-recovery-controller.d.ts.map +1 -1
- package/dist/core/foreground-recovery-controller.js +3 -3
- package/dist/core/foreground-recovery-controller.js.map +1 -1
- package/dist/core/goal-loop-controller.js +1 -1
- package/dist/core/goal-loop-controller.js.map +1 -1
- package/dist/core/goals/compact-goal-context.d.ts +1 -1
- package/dist/core/goals/compact-goal-context.d.ts.map +1 -1
- package/dist/core/goals/compact-goal-context.js +1 -1
- package/dist/core/goals/compact-goal-context.js.map +1 -1
- package/dist/core/goals/goal-auto-continue-controller.js +1 -1
- package/dist/core/goals/goal-auto-continue-controller.js.map +1 -1
- package/dist/core/goals/goal-session-controller.d.ts +1 -1
- package/dist/core/goals/goal-session-controller.d.ts.map +1 -1
- package/dist/core/goals/goal-session-controller.js +1 -1
- package/dist/core/goals/goal-session-controller.js.map +1 -1
- package/dist/core/http-dispatcher.d.ts +1 -1
- package/dist/core/http-dispatcher.d.ts.map +1 -1
- package/dist/core/http-dispatcher.js +1 -1
- package/dist/core/http-dispatcher.js.map +1 -1
- package/dist/core/index.d.ts +3 -2
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +2 -1
- package/dist/core/index.js.map +1 -1
- package/dist/core/memory/providers/file-store.d.ts.map +1 -1
- package/dist/core/memory/providers/file-store.js +1 -1
- package/dist/core/memory/providers/file-store.js.map +1 -1
- package/dist/core/memory/providers/user-memory-archive.js +1 -1
- package/dist/core/memory/providers/user-memory-archive.js.map +1 -1
- package/dist/core/model-registry.d.ts +2 -1
- package/dist/core/model-registry.d.ts.map +1 -1
- package/dist/core/model-registry.js +4 -1
- package/dist/core/model-registry.js.map +1 -1
- package/dist/core/model-resolver.d.ts +1 -1
- package/dist/core/model-resolver.d.ts.map +1 -1
- package/dist/core/model-resolver.js +1 -1
- package/dist/core/model-resolver.js.map +1 -1
- package/dist/core/model-router-controller.js +1 -1
- package/dist/core/model-router-controller.js.map +1 -1
- package/dist/core/model-selection-controller.js +1 -1
- package/dist/core/model-selection-controller.js.map +1 -1
- package/dist/core/model-tool-protocol.d.ts +1 -1
- package/dist/core/model-tool-protocol.d.ts.map +1 -1
- package/dist/core/model-tool-protocol.js +1 -1
- package/dist/core/model-tool-protocol.js.map +1 -1
- package/dist/core/models/llamacpp-runtime.d.ts +7 -0
- package/dist/core/models/llamacpp-runtime.d.ts.map +1 -1
- package/dist/core/models/llamacpp-runtime.js +8 -3
- package/dist/core/models/llamacpp-runtime.js.map +1 -1
- package/dist/core/models/local-runtime.js +1 -1
- package/dist/core/models/local-runtime.js.map +1 -1
- package/dist/core/models/runtime-process.d.ts.map +1 -1
- package/dist/core/models/runtime-process.js +5 -18
- package/dist/core/models/runtime-process.js.map +1 -1
- package/dist/core/orchestration/bounded-string-array.d.ts +11 -0
- package/dist/core/orchestration/bounded-string-array.d.ts.map +1 -0
- package/dist/core/orchestration/bounded-string-array.js +17 -0
- package/dist/core/orchestration/bounded-string-array.js.map +1 -0
- package/dist/core/orchestration/capability-gateway.d.ts +16 -0
- package/dist/core/orchestration/capability-gateway.d.ts.map +1 -1
- package/dist/core/orchestration/capability-gateway.js +38 -0
- package/dist/core/orchestration/capability-gateway.js.map +1 -1
- package/dist/core/orchestration/contracts.d.ts +11 -3
- package/dist/core/orchestration/contracts.d.ts.map +1 -1
- package/dist/core/orchestration/contracts.js +0 -1
- package/dist/core/orchestration/contracts.js.map +1 -1
- package/dist/core/orchestration/delegation-ledger.d.ts +1 -0
- package/dist/core/orchestration/delegation-ledger.d.ts.map +1 -1
- package/dist/core/orchestration/delegation-ledger.js +3 -0
- package/dist/core/orchestration/delegation-ledger.js.map +1 -1
- package/dist/core/orchestration/event-store.d.ts +12 -10
- package/dist/core/orchestration/event-store.d.ts.map +1 -1
- package/dist/core/orchestration/event-store.js +94 -104
- package/dist/core/orchestration/event-store.js.map +1 -1
- package/dist/core/orchestration/lane-tool-manifests.d.ts +2 -2
- package/dist/core/orchestration/lane-tool-manifests.d.ts.map +1 -1
- package/dist/core/orchestration/lane-tool-manifests.js +4 -1
- package/dist/core/orchestration/lane-tool-manifests.js.map +1 -1
- package/dist/core/orchestration/model-binding.d.ts +1 -1
- package/dist/core/orchestration/model-binding.d.ts.map +1 -1
- package/dist/core/orchestration/model-binding.js +1 -1
- package/dist/core/orchestration/model-binding.js.map +1 -1
- package/dist/core/orchestration/policy-compiler.d.ts.map +1 -1
- package/dist/core/orchestration/policy-compiler.js +8 -9
- package/dist/core/orchestration/policy-compiler.js.map +1 -1
- package/dist/core/orchestration/profile-registry.d.ts.map +1 -1
- package/dist/core/orchestration/profile-registry.js +4 -10
- package/dist/core/orchestration/profile-registry.js.map +1 -1
- package/dist/core/orchestration/task-profile-writer.js +1 -1
- package/dist/core/orchestration/task-profile-writer.js.map +1 -1
- package/dist/core/orchestration/task-runtime.d.ts +1 -0
- package/dist/core/orchestration/task-runtime.d.ts.map +1 -1
- package/dist/core/orchestration/task-runtime.js +58 -3
- package/dist/core/orchestration/task-runtime.js.map +1 -1
- package/dist/core/orchestration/worker-execution-contract.d.ts.map +1 -1
- package/dist/core/orchestration/worker-execution-contract.js +10 -17
- package/dist/core/orchestration/worker-execution-contract.js.map +1 -1
- package/dist/core/process-matrix/runtime.d.ts +15 -1
- package/dist/core/process-matrix/runtime.d.ts.map +1 -1
- package/dist/core/process-matrix/runtime.js +55 -34
- package/dist/core/process-matrix/runtime.js.map +1 -1
- package/dist/core/reflection-controller.d.ts +4 -3
- package/dist/core/reflection-controller.d.ts.map +1 -1
- package/dist/core/reflection-controller.js +2 -2
- package/dist/core/reflection-controller.js.map +1 -1
- package/dist/core/research/model-fitness-controller.js +1 -1
- package/dist/core/research/model-fitness-controller.js.map +1 -1
- package/dist/core/research/research-lane-controller.d.ts +2 -2
- package/dist/core/research/research-lane-controller.d.ts.map +1 -1
- package/dist/core/research/research-lane-controller.js +1 -1
- package/dist/core/research/research-lane-controller.js.map +1 -1
- package/dist/core/resource-loader.d.ts +10 -19
- package/dist/core/resource-loader.d.ts.map +1 -1
- package/dist/core/resource-loader.js +8 -70
- package/dist/core/resource-loader.js.map +1 -1
- package/dist/core/risk-classifier.js +3 -3
- package/dist/core/risk-classifier.js.map +1 -1
- package/dist/core/runtime-builder.d.ts +4 -1
- package/dist/core/runtime-builder.d.ts.map +1 -1
- package/dist/core/runtime-builder.js +47 -18
- package/dist/core/runtime-builder.js.map +1 -1
- package/dist/core/scout-controller.d.ts +1 -1
- package/dist/core/scout-controller.d.ts.map +1 -1
- package/dist/core/scout-controller.js +1 -1
- package/dist/core/scout-controller.js.map +1 -1
- package/dist/core/sdk.d.ts +2 -2
- package/dist/core/sdk.d.ts.map +1 -1
- package/dist/core/sdk.js +3 -3
- package/dist/core/sdk.js.map +1 -1
- package/dist/core/secrets/bitwarden-credential-storage.d.ts +51 -0
- package/dist/core/secrets/bitwarden-credential-storage.d.ts.map +1 -0
- package/dist/core/secrets/bitwarden-credential-storage.js +345 -0
- package/dist/core/secrets/bitwarden-credential-storage.js.map +1 -0
- package/dist/core/secrets/credential-exposure-guard.d.ts +8 -4
- package/dist/core/secrets/credential-exposure-guard.d.ts.map +1 -1
- package/dist/core/secrets/credential-exposure-guard.js +31 -29
- package/dist/core/secrets/credential-exposure-guard.js.map +1 -1
- package/dist/core/secrets/credential-manager.d.ts +109 -0
- package/dist/core/secrets/credential-manager.d.ts.map +1 -0
- package/dist/core/secrets/credential-manager.js +384 -0
- package/dist/core/secrets/credential-manager.js.map +1 -0
- package/dist/core/secrets/credential-project.d.ts +4 -0
- package/dist/core/secrets/credential-project.d.ts.map +1 -0
- package/dist/core/secrets/credential-project.js +145 -0
- package/dist/core/secrets/credential-project.js.map +1 -0
- package/dist/core/secrets/secret-dotenv.d.ts +1 -1
- package/dist/core/secrets/secret-dotenv.js +1 -1
- package/dist/core/secrets/secret-dotenv.js.map +1 -1
- package/dist/core/security/context-threat-scanner.d.ts +14 -0
- package/dist/core/security/context-threat-scanner.d.ts.map +1 -0
- package/dist/core/security/context-threat-scanner.js +71 -0
- package/dist/core/security/context-threat-scanner.js.map +1 -0
- package/dist/core/session-supervision-runtime.d.ts +4 -1
- package/dist/core/session-supervision-runtime.d.ts.map +1 -1
- package/dist/core/session-supervision-runtime.js +49 -11
- package/dist/core/session-supervision-runtime.js.map +1 -1
- package/dist/core/settings-manager.d.ts +4 -2
- package/dist/core/settings-manager.d.ts.map +1 -1
- package/dist/core/settings-manager.js +10 -6
- package/dist/core/settings-manager.js.map +1 -1
- package/dist/core/slash-commands.d.ts.map +1 -1
- package/dist/core/slash-commands.js +1 -0
- package/dist/core/slash-commands.js.map +1 -1
- package/dist/core/system-prompt.js +1 -1
- package/dist/core/system-prompt.js.map +1 -1
- package/dist/core/tool-capability-policy.js +2 -2
- package/dist/core/tool-capability-policy.js.map +1 -1
- package/dist/core/tool-recovery-logger.js +1 -1
- package/dist/core/tool-recovery-logger.js.map +1 -1
- package/dist/core/tools/artifact-retrieve.js +1 -1
- package/dist/core/tools/artifact-retrieve.js.map +1 -1
- package/dist/core/tools/bash.d.ts +2 -2
- package/dist/core/tools/bash.d.ts.map +1 -1
- package/dist/core/tools/bash.js +16 -4
- package/dist/core/tools/bash.js.map +1 -1
- package/dist/core/tools/delegate.d.ts +29 -1
- package/dist/core/tools/delegate.d.ts.map +1 -1
- package/dist/core/tools/delegate.js +179 -28
- package/dist/core/tools/delegate.js.map +1 -1
- package/dist/core/tools/extensionify-runtime.d.ts +44 -0
- package/dist/core/tools/extensionify-runtime.d.ts.map +1 -0
- package/dist/core/tools/extensionify-runtime.js +115 -0
- package/dist/core/tools/extensionify-runtime.js.map +1 -0
- package/dist/core/tools/extensionify.d.ts +9 -30
- package/dist/core/tools/extensionify.d.ts.map +1 -1
- package/dist/core/tools/extensionify.js +10 -140
- package/dist/core/tools/extensionify.js.map +1 -1
- package/dist/core/tools/find.d.ts +1 -1
- package/dist/core/tools/find.d.ts.map +1 -1
- package/dist/core/tools/find.js +1 -1
- package/dist/core/tools/find.js.map +1 -1
- package/dist/core/tools/git-filter.d.ts +1 -0
- package/dist/core/tools/git-filter.d.ts.map +1 -1
- package/dist/core/tools/git-filter.js +1 -1
- package/dist/core/tools/git-filter.js.map +1 -1
- package/dist/core/tools/index.d.ts +2 -4
- package/dist/core/tools/index.d.ts.map +1 -1
- package/dist/core/tools/index.js +7 -43
- package/dist/core/tools/index.js.map +1 -1
- package/dist/core/tools/ls.d.ts +1 -1
- package/dist/core/tools/ls.d.ts.map +1 -1
- package/dist/core/tools/ls.js +1 -1
- package/dist/core/tools/ls.js.map +1 -1
- package/dist/core/tools/output-accumulator.d.ts +1 -1
- package/dist/core/tools/output-accumulator.d.ts.map +1 -1
- package/dist/core/tools/output-accumulator.js +1 -1
- package/dist/core/tools/output-accumulator.js.map +1 -1
- package/dist/core/tools/profile-writer.js +3 -3
- package/dist/core/tools/profile-writer.js.map +1 -1
- package/dist/core/tools/python.d.ts +2 -0
- package/dist/core/tools/python.d.ts.map +1 -1
- package/dist/core/tools/python.js +17 -12
- package/dist/core/tools/python.js.map +1 -1
- package/dist/core/tools/render-utils.js +1 -1
- package/dist/core/tools/render-utils.js.map +1 -1
- package/dist/core/tools/run-process.d.ts +2 -0
- package/dist/core/tools/run-process.d.ts.map +1 -1
- package/dist/core/tools/run-process.js +7 -3
- package/dist/core/tools/run-process.js.map +1 -1
- package/dist/core/tools/search-command-guard.d.ts +8 -0
- package/dist/core/tools/search-command-guard.d.ts.map +1 -1
- package/dist/core/tools/search-command-guard.js +54 -0
- package/dist/core/tools/search-command-guard.js.map +1 -1
- package/dist/core/tools/secret-store.d.ts +8 -18
- package/dist/core/tools/secret-store.d.ts.map +1 -1
- package/dist/core/tools/secret-store.js +83 -348
- package/dist/core/tools/secret-store.js.map +1 -1
- package/dist/core/tools/shell-contract-router.d.ts.map +1 -1
- package/dist/core/tools/shell-contract-router.js +9 -4
- package/dist/core/tools/shell-contract-router.js.map +1 -1
- package/dist/core/tools/shell-session.d.ts.map +1 -1
- package/dist/core/tools/shell-session.js +6 -4
- package/dist/core/tools/shell-session.js.map +1 -1
- package/dist/core/tools/tool-definition-factory.d.ts +32 -0
- package/dist/core/tools/tool-definition-factory.d.ts.map +1 -0
- package/dist/core/tools/tool-definition-factory.js +55 -0
- package/dist/core/tools/tool-definition-factory.js.map +1 -0
- package/dist/core/util/atomic-file.d.ts.map +1 -1
- package/dist/core/util/atomic-file.js +79 -32
- package/dist/core/util/atomic-file.js.map +1 -1
- package/dist/index.d.ts +5 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -2
- package/dist/index.js.map +1 -1
- package/dist/main.d.ts +2 -0
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +24 -18
- package/dist/main.js.map +1 -1
- package/dist/modes/interactive/auto-learn-controller.js +1 -1
- package/dist/modes/interactive/auto-learn-controller.js.map +1 -1
- package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/settings-selector.js +35 -14
- package/dist/modes/interactive/components/settings-selector.js.map +1 -1
- package/dist/modes/interactive/components/tool-execution.js +1 -1
- package/dist/modes/interactive/components/tool-execution.js.map +1 -1
- package/dist/modes/interactive/interactive-event-controller.js +1 -1
- package/dist/modes/interactive/interactive-event-controller.js.map +1 -1
- package/dist/modes/interactive/interactive-mode.d.ts +1 -0
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +27 -4
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/dist/modes/interactive/secret-menu-controller.d.ts +21 -0
- package/dist/modes/interactive/secret-menu-controller.d.ts.map +1 -0
- package/dist/modes/interactive/secret-menu-controller.js +276 -0
- package/dist/modes/interactive/secret-menu-controller.js.map +1 -0
- package/dist/utils/child-process.js +1 -1
- package/dist/utils/child-process.js.map +1 -1
- package/dist/utils/tools-manager.d.ts +2 -1
- package/dist/utils/tools-manager.d.ts.map +1 -1
- package/dist/utils/tools-manager.js +43 -48
- package/dist/utils/tools-manager.js.map +1 -1
- package/dist/utils/zip-extractor.d.ts +8 -0
- package/dist/utils/zip-extractor.d.ts.map +1 -0
- package/dist/utils/zip-extractor.js +275 -0
- package/dist/utils/zip-extractor.js.map +1 -0
- package/docs/harness-architecture.md +34 -22
- package/docs/index.md +1 -1
- package/docs/resources.md +1 -1
- package/docs/settings.md +39 -103
- package/docs/usage.md +7 -5
- package/docs/worker-profiles.md +9 -7
- package/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
- package/examples/extensions/custom-provider-anthropic/package.json +1 -1
- package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
- package/examples/extensions/sandbox/package-lock.json +2 -2
- package/examples/extensions/sandbox/package.json +1 -1
- package/examples/extensions/with-deps/package-lock.json +2 -2
- package/examples/extensions/with-deps/package.json +1 -1
- package/npm-shrinkwrap.json +12 -12
- package/package.json +7 -5
- package/dist/core/secrets/secret-vault-format.d.ts +0 -112
- package/dist/core/secrets/secret-vault-format.d.ts.map +0 -1
- package/dist/core/secrets/secret-vault-format.js +0 -396
- package/dist/core/secrets/secret-vault-format.js.map +0 -1
- package/dist/core/secrets/secret-vault.d.ts +0 -72
- package/dist/core/secrets/secret-vault.d.ts.map +0 -1
- package/dist/core/secrets/secret-vault.js +0 -663
- package/dist/core/secrets/secret-vault.js.map +0 -1
|
@@ -3,22 +3,9 @@
|
|
|
3
3
|
*
|
|
4
4
|
*/
|
|
5
5
|
import { type EventBus } from "../event-bus.ts";
|
|
6
|
-
import type { Extension,
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
* Runner.bindCore() replaces these with real implementations.
|
|
10
|
-
*/
|
|
11
|
-
export declare function createExtensionRuntime(): ExtensionRuntime;
|
|
12
|
-
/**
|
|
13
|
-
* Unsubscribe a replaced extension generation's pi.events handlers from the shared
|
|
14
|
-
* event bus and invoke cleanup callbacks. Without this, every hot reload leaves the
|
|
15
|
-
* previous generation's handlers subscribed, pinning the old module graph in memory
|
|
16
|
-
* and double-processing events.
|
|
17
|
-
*/
|
|
18
|
-
export declare function disposeExtensionEventSubscriptions(extensions: Extension[], options?: {
|
|
19
|
-
deactivate?: boolean;
|
|
20
|
-
timeoutMs?: number;
|
|
21
|
-
}): Promise<void>;
|
|
6
|
+
import type { Extension, ExtensionRuntime, LoadExtensionsResult } from "./types.ts";
|
|
7
|
+
export { createExtensionRuntime, loadExtensionFromFactory } from "./factory-runtime.ts";
|
|
8
|
+
export { disposeExtensionEventSubscriptions } from "./lifecycle.ts";
|
|
22
9
|
export declare function loadExtension(extensionPath: string, cwd: string, eventBus: EventBus, runtime: ExtensionRuntime, opts?: {
|
|
23
10
|
fresh?: boolean;
|
|
24
11
|
factoryTimeoutMs?: number;
|
|
@@ -28,13 +15,6 @@ export declare function loadExtension(extensionPath: string, cwd: string, eventB
|
|
|
28
15
|
extension: Extension | null;
|
|
29
16
|
error: string | null;
|
|
30
17
|
}>;
|
|
31
|
-
/**
|
|
32
|
-
* Create an Extension from an inline factory function.
|
|
33
|
-
*/
|
|
34
|
-
export declare function loadExtensionFromFactory(factory: ExtensionFactory, cwd: string, eventBus: EventBus, runtime: ExtensionRuntime, extensionPath?: string, options?: {
|
|
35
|
-
factoryTimeoutMs?: number;
|
|
36
|
-
agentDir?: string;
|
|
37
|
-
}): Promise<Extension>;
|
|
38
18
|
/**
|
|
39
19
|
* Load extensions from paths.
|
|
40
20
|
*/
|
|
@@ -61,5 +41,4 @@ interface ExtensionLoadSpec {
|
|
|
61
41
|
* Discover and load extensions from standard locations.
|
|
62
42
|
*/
|
|
63
43
|
export declare function discoverAndLoadExtensions(configuredPaths: string[], cwd: string, agentDir?: string, eventBus?: EventBus): Promise<LoadExtensionsResult>;
|
|
64
|
-
export {};
|
|
65
44
|
//# sourceMappingURL=loader.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loader.d.ts","sourceRoot":"","sources":["../../../src/core/extensions/loader.ts"],"names":[],"mappings":"AAAA;;;GAGG;
|
|
1
|
+
{"version":3,"file":"loader.d.ts","sourceRoot":"","sources":["../../../src/core/extensions/loader.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAUH,OAAO,EAAkB,KAAK,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAahE,OAAO,KAAK,EAAE,SAAS,EAAoB,gBAAgB,EAAE,oBAAoB,EAAkB,MAAM,YAAY,CAAC;AAOtH,OAAO,EAAE,sBAAsB,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAC;AACxF,OAAO,EAAE,kCAAkC,EAAE,MAAM,gBAAgB,CAAC;AA0KpE,wBAAsB,aAAa,CAClC,aAAa,EAAE,MAAM,EACrB,GAAG,EAAE,MAAM,EACX,QAAQ,EAAE,QAAQ,EAClB,OAAO,EAAE,gBAAgB,EACzB,IAAI,CAAC,EAAE;IAAE,KAAK,CAAC,EAAE,OAAO,CAAC;IAAC,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAAC,eAAe,CAAC,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;CAAE,GAChG,OAAO,CAAC;IAAE,SAAS,EAAE,SAAS,GAAG,IAAI,CAAC;IAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,CAAC,CA2BhE;AA6GD;;GAEG;AACH,wBAAsB,cAAc,CACnC,KAAK,EAAE,KAAK,CAAC,MAAM,GAAG,iBAAiB,CAAC,EACxC,GAAG,EAAE,MAAM,EACX,QAAQ,CAAC,EAAE,QAAQ,EACnB,OAAO,GAAE;IAAE,QAAQ,CAAC,EAAE,MAAM,CAAA;CAAO,GACjC,OAAO,CAAC,oBAAoB,CAAC,CA6D/B;AAED,UAAU,gBAAgB;IACzB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,8FAA8F;IAC9F,SAAS,CAAC,EAAE,OAAO,CAAC;CACpB;AAaD,UAAU,iBAAiB;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,CAAC,EAAE,gBAAgB,EAAE,CAAC;CAC/B;AA0ID;;GAEG;AACH,wBAAsB,yBAAyB,CAC9C,eAAe,EAAE,MAAM,EAAE,EACzB,GAAG,EAAE,MAAM,EACX,QAAQ,GAAE,MAAsB,EAChC,QAAQ,CAAC,EAAE,QAAQ,GACjB,OAAO,CAAC,oBAAoB,CAAC,CA4C/B"}
|
|
@@ -6,115 +6,17 @@ import * as fs from "node:fs";
|
|
|
6
6
|
import { createRequire } from "node:module";
|
|
7
7
|
import * as path from "node:path";
|
|
8
8
|
import { fileURLToPath } from "node:url";
|
|
9
|
-
import * as _bundledPiAgentCore from "@caupulican/pi-agent-core";
|
|
10
|
-
import * as _bundledPiAi from "@caupulican/pi-ai";
|
|
11
|
-
import * as _bundledPiAiAbortSignals from "@caupulican/pi-ai/abort-signals";
|
|
12
|
-
import * as _bundledPiAiBedrockProvider from "@caupulican/pi-ai/bedrock-provider";
|
|
13
|
-
import * as _bundledPiAiEventStream from "@caupulican/pi-ai/event-stream";
|
|
14
|
-
import * as _bundledPiAiJsonParse from "@caupulican/pi-ai/json-parse";
|
|
15
|
-
import * as _bundledPiAiOauth from "@caupulican/pi-ai/oauth";
|
|
16
|
-
import * as _bundledPiAiOverflow from "@caupulican/pi-ai/overflow";
|
|
17
|
-
import * as _bundledPiAiProviderRetry from "@caupulican/pi-ai/provider-retry";
|
|
18
|
-
import * as _bundledPiAiStream from "@caupulican/pi-ai/stream";
|
|
19
|
-
import * as _bundledPiAiStreamingLines from "@caupulican/pi-ai/streaming-lines";
|
|
20
|
-
import * as _bundledPiAiTextToolProtocol from "@caupulican/pi-ai/text-tool-protocol";
|
|
21
|
-
import * as _bundledPiAiToolRepairRegistry from "@caupulican/pi-ai/tool-repair-registry";
|
|
22
|
-
import * as _bundledPiAiTypeboxHelpers from "@caupulican/pi-ai/typebox-helpers";
|
|
23
|
-
import * as _bundledPiAiTypes from "@caupulican/pi-ai/types";
|
|
24
|
-
import * as _bundledPiAiUsage from "@caupulican/pi-ai/usage";
|
|
25
|
-
import * as _bundledPiAiUuid from "@caupulican/pi-ai/uuid";
|
|
26
|
-
import * as _bundledPiAiValidation from "@caupulican/pi-ai/validation";
|
|
27
|
-
import * as _bundledPiAiValidationPath from "@caupulican/pi-ai/validation-path";
|
|
28
|
-
import * as _bundledPiTui from "@caupulican/pi-tui";
|
|
29
9
|
import { createJiti } from "jiti/static";
|
|
30
|
-
// Static imports of packages that extensions may use.
|
|
31
|
-
// These MUST be static so Bun bundles them into the compiled binary.
|
|
32
|
-
// The virtualModules option then makes them available to extensions.
|
|
33
|
-
import * as _bundledTypebox from "typebox";
|
|
34
|
-
import * as _bundledTypeboxCompile from "typebox/compile";
|
|
35
|
-
import * as _bundledTypeboxValue from "typebox/value";
|
|
36
10
|
import { CONFIG_DIR_NAME, getAgentDir, isBunBinary } from "../../config.js";
|
|
37
|
-
// NOTE: This import works because loader.ts exports are NOT re-exported from index.ts,
|
|
38
|
-
// avoiding a circular dependency. Extensions can import from @caupulican/pi-adaptative.
|
|
39
|
-
import * as _bundledPiCodingAgent from "../../index.js";
|
|
40
11
|
import { resolvePath } from "../../utils/paths.js";
|
|
41
12
|
import { cacheFile } from "../agent-paths.js";
|
|
42
13
|
import { createEventBus } from "../event-bus.js";
|
|
43
|
-
import { execCommand } from "../exec.js";
|
|
44
|
-
import { createSyntheticSourceInfo } from "../source-info.js";
|
|
45
14
|
import { resolveExtensionIndexEntry } from "./entry-resolution.js";
|
|
46
|
-
import {
|
|
47
|
-
import {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
class ExtensionFactoryTimeoutError extends Error {
|
|
52
|
-
}
|
|
53
|
-
const PI_AI_WORKSPACE_SUBPATHS = {
|
|
54
|
-
"abort-signals": "ai/src/utils/abort-signals.ts",
|
|
55
|
-
"bedrock-provider": "ai/src/bedrock-provider.ts",
|
|
56
|
-
"event-stream": "ai/src/utils/event-stream.ts",
|
|
57
|
-
"json-parse": "ai/src/utils/json-parse.ts",
|
|
58
|
-
oauth: "ai/src/oauth.ts",
|
|
59
|
-
overflow: "ai/src/utils/overflow.ts",
|
|
60
|
-
"provider-retry": "ai/src/utils/provider-retry.ts",
|
|
61
|
-
stream: "ai/src/stream.ts",
|
|
62
|
-
"streaming-lines": "ai/src/utils/streaming-lines.ts",
|
|
63
|
-
"text-tool-protocol": "ai/src/utils/tool-repair/text-protocol.ts",
|
|
64
|
-
"tool-repair-registry": "ai/src/utils/tool-repair/registry.ts",
|
|
65
|
-
"typebox-helpers": "ai/src/utils/typebox-helpers.ts",
|
|
66
|
-
types: "ai/src/types.ts",
|
|
67
|
-
usage: "ai/src/usage.ts",
|
|
68
|
-
uuid: "ai/src/utils/uuid.ts",
|
|
69
|
-
validation: "ai/src/utils/validation.ts",
|
|
70
|
-
"validation-path": "ai/src/utils/validation-path.ts",
|
|
71
|
-
};
|
|
72
|
-
const PI_AI_VIRTUAL_SUBPATHS = {
|
|
73
|
-
"abort-signals": _bundledPiAiAbortSignals,
|
|
74
|
-
"bedrock-provider": _bundledPiAiBedrockProvider,
|
|
75
|
-
"event-stream": _bundledPiAiEventStream,
|
|
76
|
-
"json-parse": _bundledPiAiJsonParse,
|
|
77
|
-
oauth: _bundledPiAiOauth,
|
|
78
|
-
overflow: _bundledPiAiOverflow,
|
|
79
|
-
"provider-retry": _bundledPiAiProviderRetry,
|
|
80
|
-
stream: _bundledPiAiStream,
|
|
81
|
-
"streaming-lines": _bundledPiAiStreamingLines,
|
|
82
|
-
"text-tool-protocol": _bundledPiAiTextToolProtocol,
|
|
83
|
-
"tool-repair-registry": _bundledPiAiToolRepairRegistry,
|
|
84
|
-
"typebox-helpers": _bundledPiAiTypeboxHelpers,
|
|
85
|
-
types: _bundledPiAiTypes,
|
|
86
|
-
usage: _bundledPiAiUsage,
|
|
87
|
-
uuid: _bundledPiAiUuid,
|
|
88
|
-
validation: _bundledPiAiValidation,
|
|
89
|
-
"validation-path": _bundledPiAiValidationPath,
|
|
90
|
-
};
|
|
91
|
-
function piAiVirtualModules(packageName) {
|
|
92
|
-
return Object.fromEntries([
|
|
93
|
-
[packageName, _bundledPiAi],
|
|
94
|
-
...Object.entries(PI_AI_VIRTUAL_SUBPATHS).map(([subpath, module]) => [`${packageName}/${subpath}`, module]),
|
|
95
|
-
]);
|
|
96
|
-
}
|
|
97
|
-
/** Modules available to extensions via virtualModules (for compiled Bun binary) */
|
|
98
|
-
const VIRTUAL_MODULES = {
|
|
99
|
-
typebox: _bundledTypebox,
|
|
100
|
-
"typebox/compile": _bundledTypeboxCompile,
|
|
101
|
-
"typebox/value": _bundledTypeboxValue,
|
|
102
|
-
"@sinclair/typebox": _bundledTypebox,
|
|
103
|
-
"@sinclair/typebox/compile": _bundledTypeboxCompile,
|
|
104
|
-
"@sinclair/typebox/value": _bundledTypeboxValue,
|
|
105
|
-
"@caupulican/pi-agent-core": _bundledPiAgentCore,
|
|
106
|
-
"@caupulican/pi-tui": _bundledPiTui,
|
|
107
|
-
...piAiVirtualModules("@caupulican/pi-ai"),
|
|
108
|
-
"@caupulican/pi-adaptative": _bundledPiCodingAgent,
|
|
109
|
-
"@earendil-works/pi-agent-core": _bundledPiAgentCore,
|
|
110
|
-
"@earendil-works/pi-tui": _bundledPiTui,
|
|
111
|
-
...piAiVirtualModules("@earendil-works/pi-ai"),
|
|
112
|
-
"@earendil-works/pi-coding-agent": _bundledPiCodingAgent,
|
|
113
|
-
"@mariozechner/pi-agent-core": _bundledPiAgentCore,
|
|
114
|
-
"@mariozechner/pi-tui": _bundledPiTui,
|
|
115
|
-
...piAiVirtualModules("@mariozechner/pi-ai"),
|
|
116
|
-
"@mariozechner/pi-coding-agent": _bundledPiCodingAgent,
|
|
117
|
-
};
|
|
15
|
+
import { createExtension, createExtensionAPI, createExtensionRuntime, EXTENSION_FACTORY_TIMEOUT_MS, ExtensionFactoryTimeoutError, restoreExtensionLoadRuntime, runExtensionFactory, snapshotExtensionLoadRuntime, } from "./factory-runtime.js";
|
|
16
|
+
import { disposeExtensionEventSubscriptions, isExtensionGenerationInactive } from "./lifecycle.js";
|
|
17
|
+
import { getBundledExtensionVirtualModules, PI_AGENT_CORE_EXTENSION_SUBPATHS, PI_AI_EXTENSION_SUBPATHS, } from "./virtual-modules.js";
|
|
18
|
+
export { createExtensionRuntime, loadExtensionFromFactory } from "./factory-runtime.js";
|
|
19
|
+
export { disposeExtensionEventSubscriptions } from "./lifecycle.js";
|
|
118
20
|
function uniquePaths(paths) {
|
|
119
21
|
return [...new Set(paths)];
|
|
120
22
|
}
|
|
@@ -176,11 +78,13 @@ function getAliases() {
|
|
|
176
78
|
};
|
|
177
79
|
const piCodingAgentEntry = packageIndex;
|
|
178
80
|
const piAgentCoreEntry = resolveWorkspaceOrImport("agent/src/index.ts", "@caupulican/pi-agent-core");
|
|
179
|
-
const
|
|
180
|
-
|
|
81
|
+
const piAgentCoreSubpathEntries = Object.fromEntries(Object.entries(PI_AGENT_CORE_EXTENSION_SUBPATHS).map(([subpath, workspacePath]) => [
|
|
82
|
+
subpath,
|
|
83
|
+
resolveWorkspaceOrImport(workspacePath, `@caupulican/pi-agent-core/${subpath}`),
|
|
84
|
+
]));
|
|
181
85
|
const piTuiEntry = resolveWorkspaceOrImport("tui/src/index.ts", "@caupulican/pi-tui");
|
|
182
86
|
const piAiEntry = resolveWorkspaceOrImport("ai/src/index.ts", "@caupulican/pi-ai");
|
|
183
|
-
const piAiSubpathEntries = Object.fromEntries(Object.entries(
|
|
87
|
+
const piAiSubpathEntries = Object.fromEntries(Object.entries(PI_AI_EXTENSION_SUBPATHS).map(([subpath, workspacePath]) => [
|
|
184
88
|
subpath,
|
|
185
89
|
resolveWorkspaceOrImport(workspacePath, `@caupulican/pi-ai/${subpath}`),
|
|
186
90
|
]));
|
|
@@ -188,24 +92,22 @@ function getAliases() {
|
|
|
188
92
|
...Object.entries(piAiSubpathEntries).map(([subpath, entry]) => [`${packageName}/${subpath}`, entry]),
|
|
189
93
|
[packageName, piAiEntry],
|
|
190
94
|
]);
|
|
95
|
+
const piAgentCoreAliases = (packageName) => Object.fromEntries([
|
|
96
|
+
...Object.entries(piAgentCoreSubpathEntries).map(([subpath, entry]) => [`${packageName}/${subpath}`, entry]),
|
|
97
|
+
[packageName, piAgentCoreEntry],
|
|
98
|
+
]);
|
|
191
99
|
_aliases = {
|
|
192
|
-
"@caupulican/pi-agent-core
|
|
193
|
-
"@caupulican/pi-agent-core/paths": piAgentCorePathsEntry,
|
|
100
|
+
...piAgentCoreAliases("@caupulican/pi-agent-core"),
|
|
194
101
|
...piAiAliases("@caupulican/pi-ai"),
|
|
195
102
|
"@caupulican/pi-adaptative": piCodingAgentEntry,
|
|
196
|
-
"@caupulican/pi-agent-core": piAgentCoreEntry,
|
|
197
103
|
"@caupulican/pi-tui": piTuiEntry,
|
|
198
|
-
"@earendil-works/pi-agent-core
|
|
199
|
-
"@earendil-works/pi-agent-core/paths": piAgentCorePathsEntry,
|
|
104
|
+
...piAgentCoreAliases("@earendil-works/pi-agent-core"),
|
|
200
105
|
...piAiAliases("@earendil-works/pi-ai"),
|
|
201
106
|
"@earendil-works/pi-coding-agent": piCodingAgentEntry,
|
|
202
|
-
"@earendil-works/pi-agent-core": piAgentCoreEntry,
|
|
203
107
|
"@earendil-works/pi-tui": piTuiEntry,
|
|
204
|
-
"@mariozechner/pi-agent-core
|
|
205
|
-
"@mariozechner/pi-agent-core/paths": piAgentCorePathsEntry,
|
|
108
|
+
...piAgentCoreAliases("@mariozechner/pi-agent-core"),
|
|
206
109
|
...piAiAliases("@mariozechner/pi-ai"),
|
|
207
110
|
"@mariozechner/pi-coding-agent": piCodingAgentEntry,
|
|
208
|
-
"@mariozechner/pi-agent-core": piAgentCoreEntry,
|
|
209
111
|
"@mariozechner/pi-tui": piTuiEntry,
|
|
210
112
|
typebox: typeboxEntry,
|
|
211
113
|
"typebox/compile": typeboxCompileEntry,
|
|
@@ -219,294 +121,6 @@ function getAliases() {
|
|
|
219
121
|
function yieldToEventLoop() {
|
|
220
122
|
return new Promise((resolve) => setImmediate(resolve));
|
|
221
123
|
}
|
|
222
|
-
/**
|
|
223
|
-
* Create a runtime with throwing stubs for action methods.
|
|
224
|
-
* Runner.bindCore() replaces these with real implementations.
|
|
225
|
-
*/
|
|
226
|
-
export function createExtensionRuntime() {
|
|
227
|
-
const notInitialized = () => {
|
|
228
|
-
throw new Error("Extension runtime not initialized. Action methods cannot be called during extension loading.");
|
|
229
|
-
};
|
|
230
|
-
const state = {};
|
|
231
|
-
const assertActive = () => {
|
|
232
|
-
if (state.staleMessage) {
|
|
233
|
-
throw new Error(state.staleMessage);
|
|
234
|
-
}
|
|
235
|
-
};
|
|
236
|
-
const providersByExtension = new Map();
|
|
237
|
-
const providerRegistrations = new Map();
|
|
238
|
-
const memoryProvidersByExtension = new Map();
|
|
239
|
-
const contextMemoryProvidersByExtension = new Map();
|
|
240
|
-
const extensionStorageOwners = new Map();
|
|
241
|
-
const runtime = {
|
|
242
|
-
sendMessage: notInitialized,
|
|
243
|
-
sendUserMessage: notInitialized,
|
|
244
|
-
appendEntry: notInitialized,
|
|
245
|
-
setSessionName: notInitialized,
|
|
246
|
-
getSessionName: notInitialized,
|
|
247
|
-
setLabel: notInitialized,
|
|
248
|
-
getActiveTools: notInitialized,
|
|
249
|
-
getAllTools: notInitialized,
|
|
250
|
-
setActiveTools: notInitialized,
|
|
251
|
-
// registerTool() is valid during extension load; refresh is only needed post-bind.
|
|
252
|
-
refreshTools: () => { },
|
|
253
|
-
getCommands: notInitialized,
|
|
254
|
-
setModel: notInitialized,
|
|
255
|
-
getThinkingLevel: notInitialized,
|
|
256
|
-
setThinkingLevel: notInitialized,
|
|
257
|
-
getExternalResourceRoots: notInitialized,
|
|
258
|
-
registerMemoryProvider: notInitialized,
|
|
259
|
-
registerContextMemoryProvider: notInitialized,
|
|
260
|
-
reportSpawnedUsage: notInitialized,
|
|
261
|
-
reportManagedLane: notInitialized,
|
|
262
|
-
flagValues: new Map(),
|
|
263
|
-
pendingProviderRegistrations: [],
|
|
264
|
-
assertActive,
|
|
265
|
-
invalidate: (message) => {
|
|
266
|
-
state.staleMessage ??= message ?? DEFAULT_STALE_EXTENSION_CONTEXT_MESSAGE;
|
|
267
|
-
},
|
|
268
|
-
// Pre-bind: queue registrations so bindCore() can flush them once the
|
|
269
|
-
// model registry is available. bindCore() replaces both with direct calls.
|
|
270
|
-
registerProvider: (name, config, extensionPath = "<unknown>") => {
|
|
271
|
-
runtime.pendingProviderRegistrations.push({ name, config, extensionPath });
|
|
272
|
-
},
|
|
273
|
-
unregisterProvider: (name) => {
|
|
274
|
-
runtime.pendingProviderRegistrations = runtime.pendingProviderRegistrations.filter((r) => r.name !== name);
|
|
275
|
-
},
|
|
276
|
-
providersByExtension,
|
|
277
|
-
providerRegistrations,
|
|
278
|
-
getProvidersForExtension: (extensionPath) => {
|
|
279
|
-
return [...(providersByExtension.get(extensionPath) ?? [])];
|
|
280
|
-
},
|
|
281
|
-
memoryProvidersByExtension,
|
|
282
|
-
contextMemoryProvidersByExtension,
|
|
283
|
-
extensionStorageOwners,
|
|
284
|
-
};
|
|
285
|
-
return runtime;
|
|
286
|
-
}
|
|
287
|
-
/**
|
|
288
|
-
* Create the ExtensionAPI for an extension.
|
|
289
|
-
* Registration methods write to the extension object.
|
|
290
|
-
* Action methods delegate to the shared runtime.
|
|
291
|
-
*/
|
|
292
|
-
function createExtensionAPI(extension, runtime, cwd, eventBus, agentDir) {
|
|
293
|
-
// A factory can time out while its promise continues running. Route every later API call through
|
|
294
|
-
// an extension-generation guard so stale async work cannot register tools, handlers, or providers.
|
|
295
|
-
const sharedRuntime = runtime;
|
|
296
|
-
runtime = new Proxy(sharedRuntime, {
|
|
297
|
-
get(target, property, receiver) {
|
|
298
|
-
if (property === "assertActive") {
|
|
299
|
-
return () => {
|
|
300
|
-
target.assertActive();
|
|
301
|
-
if (inactiveExtensions.has(extension)) {
|
|
302
|
-
throw new Error(`Extension generation is no longer active: ${extension.path}`);
|
|
303
|
-
}
|
|
304
|
-
};
|
|
305
|
-
}
|
|
306
|
-
return Reflect.get(target, property, receiver);
|
|
307
|
-
},
|
|
308
|
-
});
|
|
309
|
-
const api = {
|
|
310
|
-
getStorage(namespace) {
|
|
311
|
-
runtime.assertActive();
|
|
312
|
-
if (extension.storage) {
|
|
313
|
-
if (extension.storage.namespace !== namespace) {
|
|
314
|
-
throw new Error(`Extension ${extension.path} already owns storage namespace ${extension.storage.namespace}; cannot also use ${namespace}`);
|
|
315
|
-
}
|
|
316
|
-
return extension.storage;
|
|
317
|
-
}
|
|
318
|
-
const storage = createExtensionStorage(agentDir, namespace, runtime.assertActive, (disposer) => extension.disposers.push(disposer));
|
|
319
|
-
const previousOwner = runtime.extensionStorageOwners.get(namespace);
|
|
320
|
-
if (previousOwner && previousOwner.path !== extension.path) {
|
|
321
|
-
throw new Error(`Extension storage namespace ${namespace} is already owned by ${previousOwner.path}; ${extension.path} cannot also use it`);
|
|
322
|
-
}
|
|
323
|
-
runtime.extensionStorageOwners.set(namespace, extension);
|
|
324
|
-
extension.disposers.push(() => {
|
|
325
|
-
if (runtime.extensionStorageOwners.get(namespace) !== extension)
|
|
326
|
-
return;
|
|
327
|
-
if (previousOwner && !inactiveExtensions.has(previousOwner)) {
|
|
328
|
-
runtime.extensionStorageOwners.set(namespace, previousOwner);
|
|
329
|
-
}
|
|
330
|
-
else {
|
|
331
|
-
runtime.extensionStorageOwners.delete(namespace);
|
|
332
|
-
}
|
|
333
|
-
});
|
|
334
|
-
extension.storage = storage;
|
|
335
|
-
return storage;
|
|
336
|
-
},
|
|
337
|
-
// Registration methods - write to extension
|
|
338
|
-
on(event, handler) {
|
|
339
|
-
runtime.assertActive();
|
|
340
|
-
const list = extension.handlers.get(event) ?? [];
|
|
341
|
-
list.push(handler);
|
|
342
|
-
extension.handlers.set(event, list);
|
|
343
|
-
},
|
|
344
|
-
registerTool(tool) {
|
|
345
|
-
runtime.assertActive();
|
|
346
|
-
extension.tools.set(tool.name, {
|
|
347
|
-
definition: tool,
|
|
348
|
-
sourceInfo: extension.sourceInfo,
|
|
349
|
-
});
|
|
350
|
-
runtime.refreshTools();
|
|
351
|
-
},
|
|
352
|
-
registerCommand(name, options) {
|
|
353
|
-
runtime.assertActive();
|
|
354
|
-
extension.commands.set(name, {
|
|
355
|
-
name,
|
|
356
|
-
sourceInfo: extension.sourceInfo,
|
|
357
|
-
...options,
|
|
358
|
-
});
|
|
359
|
-
},
|
|
360
|
-
registerShortcut(shortcut, options) {
|
|
361
|
-
runtime.assertActive();
|
|
362
|
-
extension.shortcuts.set(shortcut, { shortcut, extensionPath: extension.path, ...options });
|
|
363
|
-
},
|
|
364
|
-
registerFlag(name, options) {
|
|
365
|
-
runtime.assertActive();
|
|
366
|
-
extension.flags.set(name, { name, extensionPath: extension.path, ...options });
|
|
367
|
-
if (options.default !== undefined && !runtime.flagValues.has(name)) {
|
|
368
|
-
runtime.flagValues.set(name, options.default);
|
|
369
|
-
}
|
|
370
|
-
},
|
|
371
|
-
registerMessageRenderer(customType, renderer) {
|
|
372
|
-
runtime.assertActive();
|
|
373
|
-
extension.messageRenderers.set(customType, renderer);
|
|
374
|
-
},
|
|
375
|
-
// Flag access - checks extension registered it, reads from runtime
|
|
376
|
-
getFlag(name) {
|
|
377
|
-
runtime.assertActive();
|
|
378
|
-
if (!extension.flags.has(name))
|
|
379
|
-
return undefined;
|
|
380
|
-
return runtime.flagValues.get(name);
|
|
381
|
-
},
|
|
382
|
-
// Action methods - delegate to shared runtime
|
|
383
|
-
sendMessage(message, options) {
|
|
384
|
-
runtime.assertActive();
|
|
385
|
-
runtime.sendMessage(message, options);
|
|
386
|
-
},
|
|
387
|
-
sendUserMessage(content, options) {
|
|
388
|
-
runtime.assertActive();
|
|
389
|
-
runtime.sendUserMessage(content, options);
|
|
390
|
-
},
|
|
391
|
-
appendEntry(customType, data) {
|
|
392
|
-
runtime.assertActive();
|
|
393
|
-
runtime.appendEntry(customType, data);
|
|
394
|
-
},
|
|
395
|
-
setSessionName(name) {
|
|
396
|
-
runtime.assertActive();
|
|
397
|
-
runtime.setSessionName(name);
|
|
398
|
-
},
|
|
399
|
-
getSessionName() {
|
|
400
|
-
runtime.assertActive();
|
|
401
|
-
return runtime.getSessionName();
|
|
402
|
-
},
|
|
403
|
-
setLabel(entryId, label) {
|
|
404
|
-
runtime.assertActive();
|
|
405
|
-
runtime.setLabel(entryId, label);
|
|
406
|
-
},
|
|
407
|
-
exec(command, args, options) {
|
|
408
|
-
runtime.assertActive();
|
|
409
|
-
return execCommand(command, args, options?.cwd ?? cwd, options);
|
|
410
|
-
},
|
|
411
|
-
getActiveTools() {
|
|
412
|
-
runtime.assertActive();
|
|
413
|
-
return runtime.getActiveTools();
|
|
414
|
-
},
|
|
415
|
-
getAllTools() {
|
|
416
|
-
runtime.assertActive();
|
|
417
|
-
return runtime.getAllTools();
|
|
418
|
-
},
|
|
419
|
-
setActiveTools(toolNames) {
|
|
420
|
-
runtime.assertActive();
|
|
421
|
-
runtime.setActiveTools(toolNames);
|
|
422
|
-
},
|
|
423
|
-
getCommands() {
|
|
424
|
-
runtime.assertActive();
|
|
425
|
-
return runtime.getCommands();
|
|
426
|
-
},
|
|
427
|
-
getExternalResourceRoots() {
|
|
428
|
-
runtime.assertActive();
|
|
429
|
-
return runtime.getExternalResourceRoots();
|
|
430
|
-
},
|
|
431
|
-
registerMemoryProvider(provider) {
|
|
432
|
-
runtime.assertActive();
|
|
433
|
-
runtime.registerMemoryProvider(provider);
|
|
434
|
-
const providers = runtime.memoryProvidersByExtension.get(extension.path) ?? new Set();
|
|
435
|
-
providers.add(provider);
|
|
436
|
-
runtime.memoryProvidersByExtension.set(extension.path, providers);
|
|
437
|
-
},
|
|
438
|
-
registerContextMemoryProvider(provider) {
|
|
439
|
-
runtime.assertActive();
|
|
440
|
-
runtime.registerContextMemoryProvider(provider);
|
|
441
|
-
const providers = runtime.contextMemoryProvidersByExtension.get(extension.path) ?? new Set();
|
|
442
|
-
providers.add(provider);
|
|
443
|
-
runtime.contextMemoryProvidersByExtension.set(extension.path, providers);
|
|
444
|
-
},
|
|
445
|
-
reportSpawnedUsage(usage, opts) {
|
|
446
|
-
runtime.assertActive();
|
|
447
|
-
runtime.reportSpawnedUsage(usage, opts);
|
|
448
|
-
},
|
|
449
|
-
reportManagedLane(event) {
|
|
450
|
-
runtime.assertActive();
|
|
451
|
-
runtime.reportManagedLane(event);
|
|
452
|
-
},
|
|
453
|
-
setModel(model) {
|
|
454
|
-
runtime.assertActive();
|
|
455
|
-
return runtime.setModel(model);
|
|
456
|
-
},
|
|
457
|
-
getThinkingLevel() {
|
|
458
|
-
runtime.assertActive();
|
|
459
|
-
return runtime.getThinkingLevel();
|
|
460
|
-
},
|
|
461
|
-
setThinkingLevel(level) {
|
|
462
|
-
runtime.assertActive();
|
|
463
|
-
runtime.setThinkingLevel(level);
|
|
464
|
-
},
|
|
465
|
-
registerProvider(name, config) {
|
|
466
|
-
runtime.assertActive();
|
|
467
|
-
runtime.registerProvider(name, config, extension.path);
|
|
468
|
-
},
|
|
469
|
-
unregisterProvider(name) {
|
|
470
|
-
runtime.assertActive();
|
|
471
|
-
runtime.unregisterProvider(name, extension.path);
|
|
472
|
-
},
|
|
473
|
-
onDispose(fn) {
|
|
474
|
-
runtime.assertActive();
|
|
475
|
-
extension.disposers.push(fn);
|
|
476
|
-
},
|
|
477
|
-
// Track bus subscriptions per extension generation so hot reloads can
|
|
478
|
-
// unsubscribe replaced generations (see disposeExtensionEventSubscriptions).
|
|
479
|
-
events: {
|
|
480
|
-
emit: (channel, data) => {
|
|
481
|
-
runtime.assertActive();
|
|
482
|
-
eventBus.emit(channel, data);
|
|
483
|
-
},
|
|
484
|
-
on: (channel, handler) => {
|
|
485
|
-
runtime.assertActive();
|
|
486
|
-
const unsubscribe = eventBus.on(channel, handler);
|
|
487
|
-
extension.eventUnsubscribes.push(unsubscribe);
|
|
488
|
-
return unsubscribe;
|
|
489
|
-
},
|
|
490
|
-
},
|
|
491
|
-
};
|
|
492
|
-
return api;
|
|
493
|
-
}
|
|
494
|
-
async function runExtensionFactory(factory, api, timeoutMs = EXTENSION_FACTORY_TIMEOUT_MS) {
|
|
495
|
-
let timeout;
|
|
496
|
-
const completion = Promise.resolve().then(() => factory(api));
|
|
497
|
-
try {
|
|
498
|
-
await Promise.race([
|
|
499
|
-
completion,
|
|
500
|
-
new Promise((_resolve, reject) => {
|
|
501
|
-
timeout = setTimeout(() => reject(new ExtensionFactoryTimeoutError(`Extension factory timed out after ${timeoutMs}ms`)), Math.max(0, timeoutMs));
|
|
502
|
-
}),
|
|
503
|
-
]);
|
|
504
|
-
}
|
|
505
|
-
finally {
|
|
506
|
-
if (timeout)
|
|
507
|
-
clearTimeout(timeout);
|
|
508
|
-
}
|
|
509
|
-
}
|
|
510
124
|
async function loadExtensionModule(extensionPath, transformCacheAgentDir, opts) {
|
|
511
125
|
const jiti = createJiti(import.meta.url, {
|
|
512
126
|
// A fresh jiti instance is created on every call and moduleCache is disabled so each load
|
|
@@ -527,7 +141,9 @@ async function loadExtensionModule(extensionPath, transformCacheAgentDir, opts)
|
|
|
527
141
|
fsCache: transformCacheAgentDir ? cacheFile(transformCacheAgentDir, "jiti-transforms") : false,
|
|
528
142
|
// In Bun binary: use virtualModules for bundled packages (no filesystem resolution)
|
|
529
143
|
// In Node.js/dev: use aliases to resolve to node_modules paths
|
|
530
|
-
...(isBunBinary
|
|
144
|
+
...(isBunBinary
|
|
145
|
+
? { virtualModules: getBundledExtensionVirtualModules(), tryNative: false }
|
|
146
|
+
: { alias: getAliases() }),
|
|
531
147
|
});
|
|
532
148
|
// Every call gets a fresh jiti instance with moduleCache disabled. Do not append a query string:
|
|
533
149
|
// jiti's Windows path resolver treats it as part of the .ts filename.
|
|
@@ -548,113 +164,6 @@ async function loadExtensionModule(extensionPath, transformCacheAgentDir, opts)
|
|
|
548
164
|
clearTimeout(timeout);
|
|
549
165
|
}
|
|
550
166
|
}
|
|
551
|
-
/**
|
|
552
|
-
* Create an Extension object with empty collections.
|
|
553
|
-
*/
|
|
554
|
-
function createExtension(extensionPath, resolvedPath) {
|
|
555
|
-
const source = extensionPath.startsWith("<") && extensionPath.endsWith(">")
|
|
556
|
-
? extensionPath.slice(1, -1).split(":")[0] || "temporary"
|
|
557
|
-
: "local";
|
|
558
|
-
const baseDir = extensionPath.startsWith("<") ? undefined : path.dirname(resolvedPath);
|
|
559
|
-
return {
|
|
560
|
-
path: extensionPath,
|
|
561
|
-
resolvedPath,
|
|
562
|
-
sourceInfo: createSyntheticSourceInfo(extensionPath, { source, baseDir }),
|
|
563
|
-
handlers: new Map(),
|
|
564
|
-
tools: new Map(),
|
|
565
|
-
messageRenderers: new Map(),
|
|
566
|
-
commands: new Map(),
|
|
567
|
-
flags: new Map(),
|
|
568
|
-
shortcuts: new Map(),
|
|
569
|
-
eventUnsubscribes: [],
|
|
570
|
-
disposers: [],
|
|
571
|
-
};
|
|
572
|
-
}
|
|
573
|
-
/**
|
|
574
|
-
* Unsubscribe a replaced extension generation's pi.events handlers from the shared
|
|
575
|
-
* event bus and invoke cleanup callbacks. Without this, every hot reload leaves the
|
|
576
|
-
* previous generation's handlers subscribed, pinning the old module graph in memory
|
|
577
|
-
* and double-processing events.
|
|
578
|
-
*/
|
|
579
|
-
export async function disposeExtensionEventSubscriptions(extensions, options = {}) {
|
|
580
|
-
const deadline = Date.now() + (options.timeoutMs ?? EXTENSION_DISPOSAL_TIMEOUT_MS);
|
|
581
|
-
for (const extension of extensions) {
|
|
582
|
-
if (options.deactivate ?? true)
|
|
583
|
-
inactiveExtensions.add(extension);
|
|
584
|
-
// Unsubscribe event listeners
|
|
585
|
-
for (const unsubscribe of extension.eventUnsubscribes) {
|
|
586
|
-
try {
|
|
587
|
-
unsubscribe();
|
|
588
|
-
}
|
|
589
|
-
catch {
|
|
590
|
-
// Disposal must never break a reload.
|
|
591
|
-
}
|
|
592
|
-
}
|
|
593
|
-
extension.eventUnsubscribes.length = 0;
|
|
594
|
-
// Invoke every cleanup callback, but never let one unresolved async disposer block reload or
|
|
595
|
-
// shutdown indefinitely. Late continuations retain rejection handlers and the inactive API guard.
|
|
596
|
-
for (const disposer of extension.disposers) {
|
|
597
|
-
try {
|
|
598
|
-
const result = disposer();
|
|
599
|
-
if (result !== undefined) {
|
|
600
|
-
const completion = Promise.resolve(result).catch(() => undefined);
|
|
601
|
-
const remainingMs = Math.max(0, deadline - Date.now());
|
|
602
|
-
if (remainingMs > 0) {
|
|
603
|
-
let timeout;
|
|
604
|
-
await Promise.race([
|
|
605
|
-
completion,
|
|
606
|
-
new Promise((resolve) => {
|
|
607
|
-
timeout = setTimeout(resolve, remainingMs);
|
|
608
|
-
}),
|
|
609
|
-
]);
|
|
610
|
-
if (timeout)
|
|
611
|
-
clearTimeout(timeout);
|
|
612
|
-
}
|
|
613
|
-
}
|
|
614
|
-
}
|
|
615
|
-
catch {
|
|
616
|
-
// Disposal must never break a reload.
|
|
617
|
-
}
|
|
618
|
-
}
|
|
619
|
-
extension.disposers.length = 0;
|
|
620
|
-
}
|
|
621
|
-
}
|
|
622
|
-
function snapshotExtensionLoadRuntime(runtime) {
|
|
623
|
-
return {
|
|
624
|
-
pendingProviderRegistrations: [...runtime.pendingProviderRegistrations],
|
|
625
|
-
flagValues: new Map(runtime.flagValues),
|
|
626
|
-
providerRegistrations: new Map(runtime.providerRegistrations),
|
|
627
|
-
};
|
|
628
|
-
}
|
|
629
|
-
function restoreExtensionLoadRuntime(runtime, snapshot) {
|
|
630
|
-
for (const [name, current] of runtime.providerRegistrations) {
|
|
631
|
-
const previous = snapshot.providerRegistrations.get(name);
|
|
632
|
-
if (!previous || previous.config !== current.config || previous.extensionPath !== current.extensionPath) {
|
|
633
|
-
try {
|
|
634
|
-
runtime.unregisterProvider(name, current.extensionPath);
|
|
635
|
-
}
|
|
636
|
-
catch {
|
|
637
|
-
// Preserve the original factory failure; reload rollback remains the outer safety net.
|
|
638
|
-
}
|
|
639
|
-
}
|
|
640
|
-
}
|
|
641
|
-
for (const [name, previous] of snapshot.providerRegistrations) {
|
|
642
|
-
const current = runtime.providerRegistrations.get(name);
|
|
643
|
-
if (current?.config === previous.config && current.extensionPath === previous.extensionPath)
|
|
644
|
-
continue;
|
|
645
|
-
try {
|
|
646
|
-
runtime.registerProvider(name, previous.config, previous.extensionPath);
|
|
647
|
-
}
|
|
648
|
-
catch {
|
|
649
|
-
// Preserve the original factory failure; reload rollback remains the outer safety net.
|
|
650
|
-
}
|
|
651
|
-
}
|
|
652
|
-
runtime.pendingProviderRegistrations = snapshot.pendingProviderRegistrations;
|
|
653
|
-
runtime.flagValues.clear();
|
|
654
|
-
for (const [name, value] of snapshot.flagValues) {
|
|
655
|
-
runtime.flagValues.set(name, value);
|
|
656
|
-
}
|
|
657
|
-
}
|
|
658
167
|
export async function loadExtension(extensionPath, cwd, eventBus, runtime, opts) {
|
|
659
168
|
const resolvedPath = resolvePath(extensionPath, cwd, { normalizeUnicodeSpaces: true });
|
|
660
169
|
const resolvedAgentDir = resolvePath(opts?.agentDir ?? getAgentDir());
|
|
@@ -714,7 +223,7 @@ function createLazyExtension(extensionPath, resolvedPath, cwd, eventBus, runtime
|
|
|
714
223
|
const extension = createExtension(extensionPath, resolvedPath);
|
|
715
224
|
let restoreLazyToolPlaceholders = () => { };
|
|
716
225
|
const load = async () => {
|
|
717
|
-
if (
|
|
226
|
+
if (isExtensionGenerationInactive(extension)) {
|
|
718
227
|
throw new Error(`Lazy extension generation is no longer active: ${extension.path}`);
|
|
719
228
|
}
|
|
720
229
|
if (extension.lazy?.loaded)
|
|
@@ -775,25 +284,6 @@ function createLazyExtension(extensionPath, resolvedPath, cwd, eventBus, runtime
|
|
|
775
284
|
restoreLazyToolPlaceholders();
|
|
776
285
|
return extension;
|
|
777
286
|
}
|
|
778
|
-
/**
|
|
779
|
-
* Create an Extension from an inline factory function.
|
|
780
|
-
*/
|
|
781
|
-
export async function loadExtensionFromFactory(factory, cwd, eventBus, runtime, extensionPath = "<inline>", options = {}) {
|
|
782
|
-
const extension = createExtension(extensionPath, extensionPath);
|
|
783
|
-
const resolvedCwd = resolvePath(cwd);
|
|
784
|
-
const resolvedAgentDir = resolvePath(options.agentDir ?? getAgentDir());
|
|
785
|
-
const api = createExtensionAPI(extension, runtime, resolvedCwd, eventBus, resolvedAgentDir);
|
|
786
|
-
const runtimeSnapshot = snapshotExtensionLoadRuntime(runtime);
|
|
787
|
-
try {
|
|
788
|
-
await runExtensionFactory(factory, api, options.factoryTimeoutMs);
|
|
789
|
-
}
|
|
790
|
-
catch (err) {
|
|
791
|
-
await disposeExtensionEventSubscriptions([extension]);
|
|
792
|
-
restoreExtensionLoadRuntime(runtime, runtimeSnapshot);
|
|
793
|
-
throw err;
|
|
794
|
-
}
|
|
795
|
-
return extension;
|
|
796
|
-
}
|
|
797
287
|
/**
|
|
798
288
|
* Load extensions from paths.
|
|
799
289
|
*/
|