pi-harness-runtime 1.1.397 → 1.1.402
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/AGENTS.md +44 -2
- package/CHANGELOG.md +21 -0
- package/RULES.md +28 -0
- package/harness/agent-handoff.ts +2 -3
- package/harness/autonomous-review.ts +1 -1
- package/harness/blackboard.ts +2 -3
- package/harness/context-compact-orchestrator.ts +1 -1
- package/harness/context-window-manager.ts +2 -2
- package/harness/e2e/playwright-runner.ts +6 -4
- package/harness/herdr-agents.ts +1 -1
- package/harness/job-state-machine.ts +1 -1
- package/harness/langchain/daemon.ts +3 -3
- package/harness/langchain/graph.ts +2 -2
- package/harness/langchain/ping-pong-middleware.ts +2 -2
- package/harness/loop-code-agent.ts +6 -4
- package/harness/loop-controller.ts +1 -1
- package/harness/loop-review-agent.ts +1 -1
- package/harness/loop-types.ts +1 -1
- package/harness/master-planner.ts +1 -1
- package/harness/notification-events.ts +6 -6
- package/harness/project-detector/detector.ts +1 -2
- package/harness/repair-engine.ts +2 -4
- package/harness/service-diagnostics.ts +1 -1
- package/harness/skill-sync.ts +3 -3
- package/index.ts +276 -55
- package/mirror.ts +1 -1
- package/package.json +5 -3
- package/packages/a2a-adapter/dist/discovery.d.ts.map +1 -1
- package/packages/a2a-adapter/dist/discovery.js +0 -1
- package/packages/a2a-adapter/dist/discovery.js.map +1 -1
- package/packages/a2a-adapter/package.json +1 -1
- package/packages/a2a-adapter/src/discovery.ts +0 -1
- package/packages/agent-policy/package.json +1 -1
- package/packages/architecture-generator/package.json +1 -1
- package/packages/auth/dist/index.d.ts +9 -0
- package/packages/auth/dist/index.d.ts.map +1 -0
- package/packages/auth/dist/index.js +9 -0
- package/packages/auth/dist/index.js.map +1 -0
- package/packages/auth/package.json +1 -1
- package/packages/auth/src/index.ts +9 -0
- package/packages/autonomous-refactor/package.json +1 -1
- package/packages/autonomous-runtime/package.json +1 -1
- package/packages/cache-strategy/package.json +1 -1
- package/packages/capability-registry/package.json +1 -1
- package/packages/checkpoint/package.json +1 -1
- package/packages/cli-plugin-sdk/package.json +1 -1
- package/packages/clipboard/package.json +1 -1
- package/packages/clipboard-plugin/package.json +1 -1
- package/packages/code-generation/package.json +1 -1
- package/packages/code-review/package.json +1 -1
- package/packages/codex-adapter/package.json +1 -1
- package/packages/codex-watcher/package.json +1 -1
- package/packages/config-capture/dist/index.d.ts +52 -0
- package/packages/config-capture/dist/index.d.ts.map +1 -0
- package/packages/config-capture/dist/index.js +261 -0
- package/packages/config-capture/dist/index.js.map +1 -0
- package/packages/config-capture/package.json +1 -1
- package/packages/connection-runtime/package.json +1 -1
- package/packages/context-compiler/package.json +1 -1
- package/packages/context-discovery/package.json +1 -1
- package/packages/context-manager/package.json +1 -1
- package/packages/contracts/package.json +1 -1
- package/packages/cookie-sanitizer/package.json +1 -1
- package/packages/cost-optimizer/package.json +1 -1
- package/packages/dependency-analyzer/package.json +1 -1
- package/packages/django-plugin/package.json +1 -1
- package/packages/doc-generator/package.json +1 -1
- package/packages/durable-review/package.json +1 -1
- package/packages/e2e-tester/package.json +1 -1
- package/packages/evaluation-engine/package.json +1 -1
- package/packages/evaluation-runner/package.json +1 -1
- package/packages/event-bus/package.json +1 -1
- package/packages/event-sink/package.json +1 -1
- package/packages/event-store/package.json +1 -1
- package/packages/experience-replay/package.json +1 -1
- package/packages/feedback-collector/package.json +1 -1
- package/packages/file-copy-helper/dist/extension.d.ts +15 -0
- package/packages/file-copy-helper/dist/extension.d.ts.map +1 -0
- package/packages/file-copy-helper/dist/extension.debug.d.ts +15 -0
- package/packages/file-copy-helper/dist/extension.debug.d.ts.map +1 -0
- package/packages/file-copy-helper/dist/extension.debug.js +215 -0
- package/packages/file-copy-helper/dist/extension.debug.js.map +1 -0
- package/packages/file-copy-helper/dist/extension.js +222 -0
- package/packages/file-copy-helper/dist/extension.js.map +1 -0
- package/packages/file-copy-helper/dist/index.d.ts +3 -0
- package/packages/file-copy-helper/dist/index.d.ts.map +1 -0
- package/packages/file-copy-helper/dist/index.js +3 -0
- package/packages/file-copy-helper/dist/index.js.map +1 -0
- package/packages/file-copy-helper/dist/intent-detector.d.ts +21 -0
- package/packages/file-copy-helper/dist/intent-detector.d.ts.map +1 -0
- package/packages/file-copy-helper/dist/intent-detector.js +348 -0
- package/packages/file-copy-helper/dist/intent-detector.js.map +1 -0
- package/packages/file-copy-helper/package.json +1 -1
- package/packages/framework-detector/package.json +1 -1
- package/packages/framework-plugin-sdk/package.json +1 -1
- package/packages/frappe-plugin/package.json +1 -1
- package/packages/generic-web-plugin/package.json +1 -1
- package/packages/health-monitor/package.json +1 -1
- package/packages/intent-analyzer/package.json +1 -1
- package/packages/jev-judge/dist/auto-continue.d.ts +161 -2
- package/packages/jev-judge/dist/auto-continue.d.ts.map +1 -1
- package/packages/jev-judge/dist/auto-continue.js +267 -22
- package/packages/jev-judge/dist/auto-continue.js.map +1 -1
- package/packages/jev-judge/dist/index.d.ts +2 -0
- package/packages/jev-judge/dist/index.d.ts.map +1 -1
- package/packages/jev-judge/dist/index.js +2 -0
- package/packages/jev-judge/dist/index.js.map +1 -1
- package/packages/jev-judge/dist/question-risk.d.ts +50 -0
- package/packages/jev-judge/dist/question-risk.d.ts.map +1 -0
- package/packages/jev-judge/dist/question-risk.js +100 -0
- package/packages/jev-judge/dist/question-risk.js.map +1 -0
- package/packages/jev-judge/package.json +1 -1
- package/packages/jev-judge/src/auto-continue.ts +426 -29
- package/packages/jev-judge/src/index.ts +4 -0
- package/packages/jev-judge/src/question-risk.ts +151 -0
- package/packages/jev-judge/tests/auto-continue-context.test.ts +221 -0
- package/packages/jev-judge/tests/outcome-application.test.ts +132 -0
- package/packages/jev-judge/tests/question-risk.test.ts +116 -0
- package/packages/knowledge-graph/package.json +1 -1
- package/packages/knowledge-retrieval/package.json +1 -1
- package/packages/laravel-plugin/package.json +1 -1
- package/packages/learning-engine/package.json +1 -1
- package/packages/logging/README.md +36 -3
- package/packages/logging/dist/config.d.ts +7 -0
- package/packages/logging/dist/config.d.ts.map +1 -1
- package/packages/logging/dist/config.js +14 -0
- package/packages/logging/dist/config.js.map +1 -1
- package/packages/logging/dist/incidents/schema.d.ts +111 -0
- package/packages/logging/dist/incidents/schema.d.ts.map +1 -0
- package/packages/logging/dist/incidents/schema.js +0 -0
- package/packages/logging/dist/incidents/schema.js.map +1 -0
- package/packages/logging/dist/index.d.ts +2 -0
- package/packages/logging/dist/index.d.ts.map +1 -1
- package/packages/logging/dist/index.js +2 -0
- package/packages/logging/dist/index.js.map +1 -1
- package/packages/logging/dist/server/http.d.ts +4 -3
- package/packages/logging/dist/server/http.d.ts.map +1 -1
- package/packages/logging/dist/server/http.js +35 -3
- package/packages/logging/dist/server/http.js.map +1 -1
- package/packages/logging/dist/server/incident-qdrant.d.ts +83 -0
- package/packages/logging/dist/server/incident-qdrant.d.ts.map +1 -0
- package/packages/logging/dist/server/incident-qdrant.js +129 -0
- package/packages/logging/dist/server/incident-qdrant.js.map +1 -0
- package/packages/logging/dist/server/incident-store.d.ts +76 -0
- package/packages/logging/dist/server/incident-store.d.ts.map +1 -0
- package/packages/logging/dist/server/incident-store.js +157 -0
- package/packages/logging/dist/server/incident-store.js.map +1 -0
- package/packages/logging/dist/server/index.d.ts +4 -0
- package/packages/logging/dist/server/index.d.ts.map +1 -1
- package/packages/logging/dist/server/index.js +2 -0
- package/packages/logging/dist/server/index.js.map +1 -1
- package/packages/logging/dist/server/service.d.ts +33 -0
- package/packages/logging/dist/server/service.d.ts.map +1 -1
- package/packages/logging/dist/server/service.js +63 -0
- package/packages/logging/dist/server/service.js.map +1 -1
- package/packages/logging/dist/shipper.d.ts +74 -3
- package/packages/logging/dist/shipper.d.ts.map +1 -1
- package/packages/logging/dist/shipper.js +88 -5
- package/packages/logging/dist/shipper.js.map +1 -1
- package/packages/logging/dist/singleton.d.ts.map +1 -1
- package/packages/logging/dist/singleton.js +1 -0
- package/packages/logging/dist/singleton.js.map +1 -1
- package/packages/logging/package.json +1 -1
- package/packages/logging/src/config.ts +22 -0
- package/packages/logging/src/incidents/schema.ts +0 -0
- package/packages/logging/src/index.ts +17 -0
- package/packages/logging/src/server/http.ts +42 -3
- package/packages/logging/src/server/incident-qdrant.ts +177 -0
- package/packages/logging/src/server/incident-store.ts +192 -0
- package/packages/logging/src/server/index.ts +21 -0
- package/packages/logging/src/server/service.ts +79 -0
- package/packages/logging/src/shipper.ts +120 -5
- package/packages/logging/src/singleton.ts +1 -0
- package/packages/logging/test/fanout.test.ts +186 -0
- package/packages/logging/test/incidents.test.ts +404 -0
- package/packages/mcp-adapter/package.json +1 -1
- package/packages/memory-engine/package.json +1 -1
- package/packages/milestone-manager/package.json +1 -1
- package/packages/model-registry/package.json +1 -1
- package/packages/nextjs-plugin/package.json +1 -1
- package/packages/notification/dist/adapters/detail-format.d.ts +42 -0
- package/packages/notification/dist/adapters/detail-format.d.ts.map +1 -0
- package/packages/notification/dist/adapters/detail-format.js +94 -0
- package/packages/notification/dist/adapters/detail-format.js.map +1 -0
- package/packages/notification/dist/adapters/email-adapter.d.ts.map +1 -1
- package/packages/notification/dist/adapters/email-adapter.js +3 -2
- package/packages/notification/dist/adapters/email-adapter.js.map +1 -1
- package/packages/notification/dist/adapters/line-adapter.d.ts +33 -0
- package/packages/notification/dist/adapters/line-adapter.d.ts.map +1 -1
- package/packages/notification/dist/adapters/line-adapter.js +87 -9
- package/packages/notification/dist/adapters/line-adapter.js.map +1 -1
- package/packages/notification/dist/adapters/ntfy-adapter.d.ts.map +1 -1
- package/packages/notification/dist/adapters/ntfy-adapter.js +3 -2
- package/packages/notification/dist/adapters/ntfy-adapter.js.map +1 -1
- package/packages/notification/dist/adapters/telegram-adapter.d.ts +14 -0
- package/packages/notification/dist/adapters/telegram-adapter.d.ts.map +1 -1
- package/packages/notification/dist/adapters/telegram-adapter.js +89 -69
- package/packages/notification/dist/adapters/telegram-adapter.js.map +1 -1
- package/packages/notification/dist/notification-center.d.ts.map +1 -1
- package/packages/notification/dist/notification-center.js +60 -7
- package/packages/notification/dist/notification-center.js.map +1 -1
- package/packages/notification/dist/pending-question.d.ts +69 -2
- package/packages/notification/dist/pending-question.d.ts.map +1 -1
- package/packages/notification/dist/pending-question.js +88 -2
- package/packages/notification/dist/pending-question.js.map +1 -1
- package/packages/notification/dist/types.d.ts +21 -0
- package/packages/notification/dist/types.d.ts.map +1 -1
- package/packages/notification/package.json +1 -1
- package/packages/notification/src/adapters/detail-format.ts +114 -0
- package/packages/notification/src/adapters/email-adapter.ts +3 -2
- package/packages/notification/src/adapters/line-adapter.ts +97 -9
- package/packages/notification/src/adapters/ntfy-adapter.ts +3 -2
- package/packages/notification/src/adapters/telegram-adapter.ts +98 -76
- package/packages/notification/src/notification-center.ts +66 -8
- package/packages/notification/src/pending-question.ts +160 -8
- package/packages/notification/src/types.ts +21 -0
- package/packages/notification/test/approval-payload.test.ts +269 -0
- package/packages/notification/test/detail-format.test.ts +106 -0
- package/packages/notification/test/pending-question-lifecycle.test.ts +195 -0
- package/packages/observability/package.json +1 -1
- package/packages/okf-indexer/dist/index.d.ts +9 -0
- package/packages/okf-indexer/dist/index.d.ts.map +1 -0
- package/packages/okf-indexer/dist/index.js +9 -0
- package/packages/okf-indexer/dist/index.js.map +1 -0
- package/packages/okf-indexer/package.json +1 -1
- package/packages/okf-indexer/src/index.ts +9 -0
- package/packages/paperclip-integration/package.json +1 -1
- package/packages/performance-optimizer/package.json +1 -1
- package/packages/permission-mode/package.json +1 -1
- package/packages/privilege-broker/package.json +1 -1
- package/packages/project-analyzer/package.json +1 -1
- package/packages/project-bootstrap/package.json +1 -1
- package/packages/projection-engine/package.json +1 -1
- package/packages/prompt-compiler/package.json +1 -1
- package/packages/prompt-versioning/package.json +1 -1
- package/packages/provider-adapter-sdk/package.json +1 -1
- package/packages/provider-router/dist/provider-router.d.ts.map +1 -1
- package/packages/provider-router/dist/types.d.ts +2 -2
- package/packages/provider-router/dist/types.d.ts.map +1 -1
- package/packages/provider-router/dist/types.js +1 -1
- package/packages/provider-router/package.json +1 -1
- package/packages/provider-router/src/types.ts +2 -2
- package/packages/provider-selector/package.json +1 -1
- package/packages/providers/package.json +1 -1
- package/packages/qdrant-skills/package.json +1 -1
- package/packages/quota-manager/package.json +1 -1
- package/packages/rate-limiter/package.json +1 -1
- package/packages/react-vite-plugin/package.json +1 -1
- package/packages/relay/package.json +1 -1
- package/packages/release-manager/package.json +1 -1
- package/packages/requirement-compiler/package.json +1 -1
- package/packages/runtime/package.json +1 -1
- package/packages/scheduler/dist/index.d.ts +9 -0
- package/packages/scheduler/dist/index.d.ts.map +1 -0
- package/packages/scheduler/dist/index.js +9 -0
- package/packages/scheduler/dist/index.js.map +1 -0
- package/packages/scheduler/dist/scheduler.d.ts +17 -0
- package/packages/scheduler/dist/scheduler.d.ts.map +1 -0
- package/packages/scheduler/dist/scheduler.js +41 -0
- package/packages/scheduler/dist/scheduler.js.map +1 -0
- package/packages/scheduler/package.json +1 -1
- package/packages/scheduler/src/index.ts +9 -0
- package/packages/scheduler-adapter/package.json +1 -1
- package/packages/session/package.json +1 -1
- package/packages/session-api/package.json +1 -1
- package/packages/session-export/package.json +1 -1
- package/packages/shared-context/dist/index.d.ts +7 -0
- package/packages/shared-context/dist/index.d.ts.map +1 -0
- package/packages/shared-context/dist/index.js +7 -0
- package/packages/shared-context/dist/index.js.map +1 -0
- package/packages/shared-context/dist/shared-context.d.ts +12 -0
- package/packages/shared-context/dist/shared-context.d.ts.map +1 -0
- package/packages/shared-context/dist/shared-context.js +39 -0
- package/packages/shared-context/dist/shared-context.js.map +1 -0
- package/packages/shared-context/package.json +1 -1
- package/packages/skill-mcp-client/dist/client.d.ts +56 -0
- package/packages/skill-mcp-client/dist/client.d.ts.map +1 -0
- package/packages/skill-mcp-client/dist/client.js +101 -0
- package/packages/skill-mcp-client/dist/client.js.map +1 -0
- package/packages/skill-mcp-client/dist/errors.d.ts +44 -0
- package/packages/skill-mcp-client/dist/errors.d.ts.map +1 -0
- package/packages/skill-mcp-client/dist/errors.js +68 -0
- package/packages/skill-mcp-client/dist/errors.js.map +1 -0
- package/packages/skill-mcp-client/dist/index.d.ts +9 -0
- package/packages/skill-mcp-client/dist/index.d.ts.map +1 -0
- package/packages/skill-mcp-client/dist/index.js +9 -0
- package/packages/skill-mcp-client/dist/index.js.map +1 -0
- package/packages/skill-mcp-client/dist/types.d.ts +106 -0
- package/packages/skill-mcp-client/dist/types.d.ts.map +1 -0
- package/packages/skill-mcp-client/dist/types.js +14 -0
- package/packages/skill-mcp-client/dist/types.js.map +1 -0
- package/packages/skill-mcp-client/package.json +1 -1
- package/packages/skill-registry/package.json +1 -1
- package/packages/skills/package.json +1 -5
- package/packages/sprint-planner/package.json +1 -1
- package/packages/subscription-engine/package.json +1 -1
- package/packages/task-compiler/package.json +1 -1
- package/packages/telegram/package.json +1 -1
- package/packages/telegram/src/agent-messages.d.ts +28 -0
- package/packages/telegram/src/agent-messages.js +90 -0
- package/packages/telegram/src/bindings.d.ts +296 -0
- package/packages/telegram/src/bindings.js +1086 -0
- package/packages/telegram/src/bus.d.ts +759 -0
- package/packages/telegram/src/bus.js +2732 -0
- package/packages/telegram/src/commands.d.ts +761 -0
- package/packages/telegram/src/commands.js +2622 -0
- package/packages/telegram/src/config.d.ts +222 -0
- package/packages/telegram/src/config.js +844 -0
- package/packages/telegram/src/delivery.d.ts +161 -0
- package/packages/telegram/src/delivery.js +550 -0
- package/packages/telegram/src/extension.d.ts +7 -0
- package/packages/telegram/src/extension.js +2444 -0
- package/packages/telegram/src/inbound.d.ts +94 -0
- package/packages/telegram/src/inbound.js +478 -0
- package/packages/telegram/src/index.d.ts +6 -0
- package/packages/telegram/src/index.js +6 -0
- package/packages/telegram/src/keyboard.d.ts +21 -0
- package/packages/telegram/src/keyboard.js +37 -0
- package/packages/telegram/src/lifecycle.d.ts +210 -0
- package/packages/telegram/src/lifecycle.js +538 -0
- package/packages/telegram/src/pi.d.ts +76 -0
- package/packages/telegram/src/pi.js +130 -0
- package/packages/telegram/src/polling.d.ts +332 -0
- package/packages/telegram/src/polling.js +1219 -0
- package/packages/telegram/src/replies.d.ts +210 -0
- package/packages/telegram/src/replies.js +752 -0
- package/packages/telegram/src/routing.d.ts +388 -0
- package/packages/telegram/src/routing.js +7886 -0
- package/packages/telegram/src/runtime.d.ts +159 -0
- package/packages/telegram/src/runtime.js +351 -0
- package/packages/telegram/src/telegram-api.d.ts +564 -0
- package/packages/telegram/src/telegram-api.js +1332 -0
- package/packages/telegram/src/turns.d.ts +108 -0
- package/packages/telegram/src/turns.js +482 -0
- package/packages/telegram/src/updates.d.ts +1545 -0
- package/packages/telegram/src/updates.js +6420 -0
- package/packages/tencentdb-memory/package.json +1 -1
- package/packages/tencentdb-sync/package.json +1 -1
- package/packages/test-data-generator/package.json +1 -1
- package/packages/test-generator/package.json +1 -1
- package/packages/todo-bd-sync/dist/detector.d.ts +54 -0
- package/packages/todo-bd-sync/dist/detector.d.ts.map +1 -0
- package/packages/todo-bd-sync/dist/detector.js +132 -0
- package/packages/todo-bd-sync/dist/detector.js.map +1 -0
- package/packages/todo-bd-sync/dist/extension.d.ts +30 -0
- package/packages/todo-bd-sync/dist/extension.d.ts.map +1 -0
- package/packages/todo-bd-sync/dist/extension.js +35 -0
- package/packages/todo-bd-sync/dist/extension.js.map +1 -0
- package/packages/todo-bd-sync/dist/index.d.ts +87 -0
- package/packages/todo-bd-sync/dist/index.d.ts.map +1 -0
- package/packages/todo-bd-sync/dist/index.js +296 -0
- package/packages/todo-bd-sync/dist/index.js.map +1 -0
- package/packages/todo-bd-sync/dist/sync.d.ts +72 -0
- package/packages/todo-bd-sync/dist/sync.d.ts.map +1 -0
- package/packages/todo-bd-sync/dist/sync.js +290 -0
- package/packages/todo-bd-sync/dist/sync.js.map +1 -0
- package/packages/todo-bd-sync/dist/task-analyzer.d.ts +49 -0
- package/packages/todo-bd-sync/dist/task-analyzer.d.ts.map +1 -0
- package/packages/todo-bd-sync/dist/task-analyzer.js +240 -0
- package/packages/todo-bd-sync/dist/task-analyzer.js.map +1 -0
- package/packages/todo-bd-sync/dist/todo-reminder.d.ts +126 -0
- package/packages/todo-bd-sync/dist/todo-reminder.d.ts.map +1 -0
- package/packages/todo-bd-sync/dist/todo-reminder.js +329 -0
- package/packages/todo-bd-sync/dist/todo-reminder.js.map +1 -0
- package/packages/todo-bd-sync/dist/types.d.ts +65 -0
- package/packages/todo-bd-sync/dist/types.d.ts.map +1 -0
- package/packages/todo-bd-sync/dist/types.js +67 -0
- package/packages/todo-bd-sync/dist/types.js.map +1 -0
- package/packages/todo-bd-sync/package.json +1 -1
- package/packages/token-estimation/dist/index.d.ts +94 -0
- package/packages/token-estimation/dist/index.d.ts.map +1 -0
- package/packages/token-estimation/dist/index.js +115 -0
- package/packages/token-estimation/dist/index.js.map +1 -0
- package/packages/token-estimation/package.json +1 -1
- package/packages/token-optimizer/package.json +1 -1
- package/packages/trajectory/package.json +1 -1
- package/packages/tui/package.json +1 -1
- package/packages/types/dist/ai-providers.d.ts +36 -0
- package/packages/types/dist/ai-providers.d.ts.map +1 -0
- package/packages/types/dist/ai-providers.js +66 -0
- package/packages/types/dist/ai-providers.js.map +1 -0
- package/packages/types/dist/index.d.ts +12 -0
- package/packages/types/dist/index.d.ts.map +1 -0
- package/packages/types/dist/index.js +12 -0
- package/packages/types/dist/index.js.map +1 -0
- package/packages/types/package.json +5 -5
- package/packages/types/src/index.ts +12 -0
- package/packages/voice-api/package.json +1 -1
- package/packages/webmcp-tester/package.json +1 -1
- package/packages/wiki/package.json +1 -1
- package/packages/workflow-events/package.json +1 -1
- package/packages/workspace-scanner/package.json +1 -1
- package/packages/worktree/package.json +1 -1
- package/packages/worktree/worktree.ts +1 -1
- package/packages/write-review/package.json +1 -1
- package/renderer.ts +1 -1
- package/scripts/build-packages.ts +162 -0
- package/scripts/relay-client.ts +2 -2
- package/scripts/typecheck-packages.mjs +3 -3
- package/scripts/unified-webhook-server.ts +22 -10
- package/scripts/verify-package-contents.ts +345 -0
- package/scripts/ws-server.ts +1 -1
- package/tracker.ts +1 -1
- package/harness/browser-scrapers/base-browser-scraper.d.ts +0 -91
- package/harness/browser-scrapers/chrome-profile-manager.d.ts +0 -80
- package/harness/browser-scrapers/codex-browser-scraper.d.ts +0 -60
- package/harness/browser-scrapers/index.d.ts +0 -29
- package/harness/browser-scrapers/zai-browser-scraper.d.ts +0 -79
- package/harness/e2e/browser-scrapers/base-browser-scraper.d.ts +0 -92
- package/harness/e2e/browser-scrapers/chrome-profile-manager.d.ts +0 -81
- package/harness/e2e/browser-scrapers/codex-browser-scraper.d.ts +0 -61
- package/harness/e2e/browser-scrapers/index.d.ts +0 -30
- package/harness/e2e/browser-scrapers/zai-browser-scraper.d.ts +0 -80
- package/harness/langchain/agents.d.ts +0 -143
- package/harness/langchain/agents.test.d.ts +0 -2
- package/harness/langchain/checkpointer.d.ts +0 -48
- package/harness/langchain/checkpointer.test.d.ts +0 -8
- package/harness/langchain/cron-cli.d.ts +0 -12
- package/harness/langchain/daemon.d.ts +0 -161
- package/harness/langchain/daemon.test.d.ts +0 -11
- package/harness/langchain/file-tools.d.ts +0 -97
- package/harness/langchain/graph.d.ts +0 -706
- package/harness/langchain/model-router.d.ts +0 -63
- package/harness/langchain/model-router.test.d.ts +0 -2
- package/harness/langchain/models.d.ts +0 -72
- package/harness/langchain/ping-pong-middleware.d.ts +0 -28
- package/harness/langchain/ping-pong-middleware.test.d.ts +0 -2
- package/harness/langchain/run.d.ts +0 -15
- package/harness/langchain/scoreboard.test.d.ts +0 -13
- package/harness/langchain/status-line.d.ts +0 -91
- package/harness/langchain/status-line.test.d.ts +0 -8
- package/harness/langchain/surge.d.ts +0 -111
- package/harness/langchain/surge.test.d.ts +0 -10
- package/harness/langchain/widget.d.ts +0 -105
- package/harness/langchain/widget.test.d.ts +0 -8
- package/packages/autonomous-runtime/dist/worker.d.ts +0 -63
- package/packages/autonomous-runtime/dist/worker.js +0 -133
- package/packages/capability-registry/src/types.d.ts +0 -47
- package/packages/clipboard/dist/clipboard.d.ts +0 -11
- package/packages/clipboard/dist/clipboard.js +0 -40
- package/packages/clipboard/dist/index.d.ts +0 -2
- package/packages/clipboard/dist/index.js +0 -2
- package/packages/clipboard/dist/types.d.ts +0 -13
- package/packages/clipboard/dist/types.js +0 -5
- package/packages/context-discovery/dist/discover.d.ts +0 -3
- package/packages/context-discovery/dist/discover.js +0 -42
- package/packages/context-discovery/dist/discovery.d.ts +0 -28
- package/packages/context-discovery/dist/discovery.js +0 -21
- package/packages/context-discovery/dist/index.d.ts +0 -3
- package/packages/context-discovery/dist/index.js +0 -2
- package/packages/context-discovery/dist/types.d.ts +0 -16
- package/packages/context-discovery/dist/types.js +0 -2
- package/packages/event-bus/dist/bus.d.ts +0 -15
- package/packages/event-bus/dist/bus.js +0 -90
- package/packages/event-bus/dist/index.d.ts +0 -4
- package/packages/event-bus/dist/index.js +0 -3
- package/packages/event-bus/dist/test/bus.test.js +0 -52
- package/packages/event-bus/dist/types.d.ts +0 -27
- package/packages/event-bus/dist/types.js +0 -10
- package/packages/event-store/dist/index.d.ts +0 -3
- package/packages/event-store/dist/index.js +0 -2
- package/packages/event-store/dist/store.d.ts +0 -15
- package/packages/event-store/dist/store.js +0 -131
- package/packages/event-store/dist/test/store.test.js +0 -57
- package/packages/event-store/dist/types.d.ts +0 -48
- package/packages/event-store/dist/types.js +0 -5
- package/packages/event-store/src/types.d.ts +0 -48
- package/packages/file-copy-helper/dist/src/extension.js +0 -186
- package/packages/model-registry/src/types.d.ts +0 -63
- package/packages/notification/dist/src/adapters/email-adapter.d.ts +0 -17
- package/packages/notification/dist/src/adapters/email-adapter.d.ts.map +0 -1
- package/packages/notification/dist/src/adapters/email-adapter.js +0 -89
- package/packages/notification/dist/src/adapters/email-adapter.js.map +0 -1
- package/packages/notification/dist/src/adapters/line-adapter.d.ts +0 -17
- package/packages/notification/dist/src/adapters/line-adapter.d.ts.map +0 -1
- package/packages/notification/dist/src/adapters/line-adapter.js +0 -99
- package/packages/notification/dist/src/adapters/line-adapter.js.map +0 -1
- package/packages/notification/dist/src/adapters/ntfy-adapter.d.ts +0 -17
- package/packages/notification/dist/src/adapters/ntfy-adapter.d.ts.map +0 -1
- package/packages/notification/dist/src/adapters/ntfy-adapter.js +0 -84
- package/packages/notification/dist/src/adapters/ntfy-adapter.js.map +0 -1
- package/packages/notification/dist/src/adapters/telegram-adapter.d.ts +0 -56
- package/packages/notification/dist/src/adapters/telegram-adapter.d.ts.map +0 -1
- package/packages/notification/dist/src/adapters/telegram-adapter.js +0 -251
- package/packages/notification/dist/src/adapters/telegram-adapter.js.map +0 -1
- package/packages/notification/dist/src/adapters/webhook-adapter.d.ts +0 -15
- package/packages/notification/dist/src/adapters/webhook-adapter.d.ts.map +0 -1
- package/packages/notification/dist/src/adapters/webhook-adapter.js +0 -64
- package/packages/notification/dist/src/adapters/webhook-adapter.js.map +0 -1
- package/packages/notification/dist/src/base-adapter.d.ts +0 -36
- package/packages/notification/dist/src/base-adapter.d.ts.map +0 -1
- package/packages/notification/dist/src/base-adapter.js +0 -39
- package/packages/notification/dist/src/base-adapter.js.map +0 -1
- package/packages/notification/dist/src/index.d.ts +0 -12
- package/packages/notification/dist/src/index.d.ts.map +0 -1
- package/packages/notification/dist/src/index.js +0 -12
- package/packages/notification/dist/src/index.js.map +0 -1
- package/packages/notification/dist/src/notification-center.d.ts +0 -89
- package/packages/notification/dist/src/notification-center.d.ts.map +0 -1
- package/packages/notification/dist/src/notification-center.js +0 -356
- package/packages/notification/dist/src/notification-center.js.map +0 -1
- package/packages/notification/dist/src/notification-policy.d.ts +0 -66
- package/packages/notification/dist/src/notification-policy.d.ts.map +0 -1
- package/packages/notification/dist/src/notification-policy.js +0 -153
- package/packages/notification/dist/src/notification-policy.js.map +0 -1
- package/packages/notification/dist/src/telegram-webhook-handler.d.ts +0 -86
- package/packages/notification/dist/src/telegram-webhook-handler.d.ts.map +0 -1
- package/packages/notification/dist/src/telegram-webhook-handler.js +0 -149
- package/packages/notification/dist/src/telegram-webhook-handler.js.map +0 -1
- package/packages/notification/dist/src/types.d.ts +0 -106
- package/packages/notification/dist/src/types.d.ts.map +0 -1
- package/packages/notification/dist/src/types.js +0 -7
- package/packages/notification/dist/src/types.js.map +0 -1
- package/packages/projection-engine/dist/engine.d.ts +0 -61
- package/packages/projection-engine/dist/engine.js +0 -76
- package/packages/projection-engine/dist/index.d.ts +0 -2
- package/packages/projection-engine/dist/index.js +0 -2
- package/packages/projection-engine/dist/project.d.ts +0 -3
- package/packages/projection-engine/dist/project.js +0 -24
- package/packages/projection-engine/dist/types.d.ts +0 -55
- package/packages/projection-engine/dist/types.js +0 -5
- package/packages/projection-engine/src/types.d.ts +0 -55
- package/packages/provider-adapter-sdk/dist/src/builder.d.ts +0 -140
- package/packages/provider-adapter-sdk/dist/src/builder.d.ts.map +0 -1
- package/packages/provider-adapter-sdk/dist/src/builder.js +0 -332
- package/packages/provider-adapter-sdk/dist/src/builder.js.map +0 -1
- package/packages/provider-adapter-sdk/dist/src/errors.d.ts +0 -71
- package/packages/provider-adapter-sdk/dist/src/errors.d.ts.map +0 -1
- package/packages/provider-adapter-sdk/dist/src/errors.js +0 -111
- package/packages/provider-adapter-sdk/dist/src/errors.js.map +0 -1
- package/packages/provider-adapter-sdk/dist/src/index.d.ts +0 -15
- package/packages/provider-adapter-sdk/dist/src/index.d.ts.map +0 -1
- package/packages/provider-adapter-sdk/dist/src/index.js +0 -19
- package/packages/provider-adapter-sdk/dist/src/index.js.map +0 -1
- package/packages/provider-adapter-sdk/dist/src/registry.d.ts +0 -108
- package/packages/provider-adapter-sdk/dist/src/registry.d.ts.map +0 -1
- package/packages/provider-adapter-sdk/dist/src/registry.js +0 -301
- package/packages/provider-adapter-sdk/dist/src/registry.js.map +0 -1
- package/packages/provider-adapter-sdk/dist/src/tester.d.ts +0 -71
- package/packages/provider-adapter-sdk/dist/src/tester.d.ts.map +0 -1
- package/packages/provider-adapter-sdk/dist/src/tester.js +0 -392
- package/packages/provider-adapter-sdk/dist/src/tester.js.map +0 -1
- package/packages/provider-adapter-sdk/dist/src/types.d.ts +0 -182
- package/packages/provider-adapter-sdk/dist/src/types.d.ts.map +0 -1
- package/packages/provider-adapter-sdk/dist/src/types.js +0 -11
- package/packages/provider-adapter-sdk/dist/src/types.js.map +0 -1
- package/packages/provider-router/dist/capability-registry/src/types.d.ts +0 -47
- package/packages/provider-router/dist/capability-registry/src/types.d.ts.map +0 -1
- package/packages/provider-router/dist/capability-registry/src/types.js +0 -10
- package/packages/provider-router/dist/capability-registry/src/types.js.map +0 -1
- package/packages/provider-router/dist/provider-router/src/index.d.ts +0 -23
- package/packages/provider-router/dist/provider-router/src/index.d.ts.map +0 -1
- package/packages/provider-router/dist/provider-router/src/index.js +0 -25
- package/packages/provider-router/dist/provider-router/src/index.js.map +0 -1
- package/packages/provider-router/dist/provider-router/src/policy.d.ts +0 -10
- package/packages/provider-router/dist/provider-router/src/policy.d.ts.map +0 -1
- package/packages/provider-router/dist/provider-router/src/policy.js +0 -45
- package/packages/provider-router/dist/provider-router/src/policy.js.map +0 -1
- package/packages/provider-router/dist/provider-router/src/provider-router.d.ts +0 -56
- package/packages/provider-router/dist/provider-router/src/provider-router.d.ts.map +0 -1
- package/packages/provider-router/dist/provider-router/src/provider-router.js +0 -222
- package/packages/provider-router/dist/provider-router/src/provider-router.js.map +0 -1
- package/packages/provider-router/dist/provider-router/src/strategies.d.ts +0 -19
- package/packages/provider-router/dist/provider-router/src/strategies.d.ts.map +0 -1
- package/packages/provider-router/dist/provider-router/src/strategies.js +0 -110
- package/packages/provider-router/dist/provider-router/src/strategies.js.map +0 -1
- package/packages/provider-router/dist/provider-router/src/types.d.ts +0 -91
- package/packages/provider-router/dist/provider-router/src/types.d.ts.map +0 -1
- package/packages/provider-router/dist/provider-router/src/types.js +0 -10
- package/packages/provider-router/dist/provider-router/src/types.js.map +0 -1
- package/packages/provider-router/dist/src/index.d.ts +0 -23
- package/packages/provider-router/dist/src/index.d.ts.map +0 -1
- package/packages/provider-router/dist/src/index.js +0 -25
- package/packages/provider-router/dist/src/index.js.map +0 -1
- package/packages/provider-router/dist/src/policy.d.ts +0 -10
- package/packages/provider-router/dist/src/policy.d.ts.map +0 -1
- package/packages/provider-router/dist/src/policy.js +0 -45
- package/packages/provider-router/dist/src/policy.js.map +0 -1
- package/packages/provider-router/dist/src/provider-router.d.ts +0 -56
- package/packages/provider-router/dist/src/provider-router.d.ts.map +0 -1
- package/packages/provider-router/dist/src/provider-router.js +0 -222
- package/packages/provider-router/dist/src/provider-router.js.map +0 -1
- package/packages/provider-router/dist/src/strategies.d.ts +0 -19
- package/packages/provider-router/dist/src/strategies.d.ts.map +0 -1
- package/packages/provider-router/dist/src/strategies.js +0 -110
- package/packages/provider-router/dist/src/strategies.js.map +0 -1
- package/packages/provider-router/dist/src/types.d.ts +0 -91
- package/packages/provider-router/dist/src/types.d.ts.map +0 -1
- package/packages/provider-router/dist/src/types.js +0 -10
- package/packages/provider-router/dist/src/types.js.map +0 -1
- package/packages/provider-router/dist/types/src/runtime-types.d.ts +0 -412
- package/packages/provider-router/dist/types/src/runtime-types.d.ts.map +0 -1
- package/packages/provider-router/dist/types/src/runtime-types.js +0 -2
- package/packages/provider-router/dist/types/src/runtime-types.js.map +0 -1
- package/packages/session-api/dist/api.d.ts +0 -83
- package/packages/session-api/dist/api.js +0 -35
- package/packages/session-api/dist/index.d.ts +0 -2
- package/packages/session-api/dist/index.js +0 -2
- package/packages/session-api/dist/types.d.ts +0 -22
- package/packages/session-api/dist/types.js +0 -5
- package/packages/session-export/dist/exporter.d.ts +0 -28
- package/packages/session-export/dist/exporter.js +0 -38
- package/packages/session-export/dist/index.d.ts +0 -2
- package/packages/session-export/dist/index.js +0 -2
- package/packages/session-export/dist/types.d.ts +0 -20
- package/packages/session-export/dist/types.js +0 -5
- package/packages/subscription-engine/dist/engine.d.ts +0 -13
- package/packages/subscription-engine/dist/engine.js +0 -40
- package/packages/subscription-engine/dist/index.d.ts +0 -2
- package/packages/subscription-engine/dist/index.js +0 -2
- package/packages/subscription-engine/dist/subscriptions.d.ts +0 -19
- package/packages/subscription-engine/dist/subscriptions.js +0 -32
- package/packages/subscription-engine/dist/types.d.ts +0 -24
- package/packages/subscription-engine/dist/types.js +0 -5
- package/packages/trajectory/test/store.test.d.ts +0 -2
- package/packages/workflow-events/dist/events.d.ts +0 -38
- package/packages/workflow-events/dist/events.js +0 -46
- package/packages/workflow-events/dist/index.d.ts +0 -2
- package/packages/workflow-events/dist/index.js +0 -2
- package/packages/workflow-events/dist/pipeline.d.ts +0 -21
- package/packages/workflow-events/dist/pipeline.js +0 -27
- package/packages/workflow-events/dist/types.d.ts +0 -110
- package/packages/workflow-events/dist/types.js +0 -5
- package/packages/workflow-events/src/types.d.ts +0 -110
|
@@ -0,0 +1,538 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Telegram session lifecycle coordination and hook registration
|
|
3
|
+
* Zones: pi agent lifecycle, telegram session
|
|
4
|
+
* Owns context generations, bounded connect intent across resume, and session sequencing.
|
|
5
|
+
* Transport authority, durable bindings, and queue custody remain with their owners.
|
|
6
|
+
*/
|
|
7
|
+
import { randomUUID } from "node:crypto";
|
|
8
|
+
import * as BusFollower from "./bus-follower.js";
|
|
9
|
+
import * as Queue from "./queue.js";
|
|
10
|
+
import { formatTelegramConnectionFailure } from "./status.js";
|
|
11
|
+
import * as TextGroups from "./text-groups.js";
|
|
12
|
+
export function createAgentStartDedupHook(inner, resetReplyDedup, schedulePublication) {
|
|
13
|
+
return async (event, ctx) => {
|
|
14
|
+
// A new turn must not erase the anchor of a final still ahead in the FIFO.
|
|
15
|
+
if (schedulePublication)
|
|
16
|
+
schedulePublication(async () => {
|
|
17
|
+
resetReplyDedup();
|
|
18
|
+
});
|
|
19
|
+
else
|
|
20
|
+
resetReplyDedup();
|
|
21
|
+
return inner(event, ctx);
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
const HANDOFF_KEY = Symbol.for("pi-telegram.connection-resume.v1");
|
|
25
|
+
function processHandoffStore() {
|
|
26
|
+
const globals = globalThis;
|
|
27
|
+
return (globals[HANDOFF_KEY] ??= {});
|
|
28
|
+
}
|
|
29
|
+
export function createTelegramConnectionLifecycle(deps) {
|
|
30
|
+
return {
|
|
31
|
+
onSessionShutdown(event, ctx) {
|
|
32
|
+
deps.intent.suspend({
|
|
33
|
+
reason: event.reason,
|
|
34
|
+
cwd: ctx.cwd,
|
|
35
|
+
targetSessionFile: event.targetSessionFile,
|
|
36
|
+
connected: deps.isConnected(),
|
|
37
|
+
profileName: deps.getProfileName(),
|
|
38
|
+
});
|
|
39
|
+
},
|
|
40
|
+
prepare(event, ctx) {
|
|
41
|
+
const intent = deps.intent.resume({
|
|
42
|
+
reason: event.reason,
|
|
43
|
+
cwd: ctx.cwd,
|
|
44
|
+
sessionFile: event.reason === "resume"
|
|
45
|
+
? ctx.sessionManager.getSessionFile()
|
|
46
|
+
: undefined,
|
|
47
|
+
});
|
|
48
|
+
if (!intent)
|
|
49
|
+
return undefined;
|
|
50
|
+
const generation = deps.getGeneration();
|
|
51
|
+
const isCurrent = () => deps.intent.isActive(intent.id) &&
|
|
52
|
+
generation === deps.getGeneration() &&
|
|
53
|
+
deps.isCurrent(ctx);
|
|
54
|
+
return () => {
|
|
55
|
+
// Startup remains extension-owned background work; no captured command ctx crosses resume.
|
|
56
|
+
void (async () => {
|
|
57
|
+
if (!isCurrent())
|
|
58
|
+
return;
|
|
59
|
+
if (!(await deps.activateProfile(intent.profileName, isCurrent))) {
|
|
60
|
+
if (isCurrent())
|
|
61
|
+
ctx.ui.notify("Telegram profile unavailable. Run /telegram-setup.", "warning");
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
if (!isCurrent())
|
|
65
|
+
return;
|
|
66
|
+
const result = await deps.start(ctx);
|
|
67
|
+
if (!isCurrent())
|
|
68
|
+
return;
|
|
69
|
+
if (!result.ok) {
|
|
70
|
+
deps.recordError(new Error(result.message ?? "Telegram resume connection failed."));
|
|
71
|
+
ctx.ui.notify(formatTelegramConnectionFailure(result.message), "warning");
|
|
72
|
+
}
|
|
73
|
+
})()
|
|
74
|
+
.catch((error) => {
|
|
75
|
+
deps.recordError(error);
|
|
76
|
+
if (isCurrent())
|
|
77
|
+
ctx.ui.notify(formatTelegramConnectionFailure(error), "warning");
|
|
78
|
+
})
|
|
79
|
+
.finally(() => deps.intent.finish(intent.id));
|
|
80
|
+
};
|
|
81
|
+
},
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
export function createTelegramConnectionIntentRuntime(options = {}) {
|
|
85
|
+
const store = options.store ?? processHandoffStore();
|
|
86
|
+
const now = options.now ?? Date.now;
|
|
87
|
+
const pid = options.pid ?? process.pid;
|
|
88
|
+
let active;
|
|
89
|
+
return {
|
|
90
|
+
begin(cwd, profileName) {
|
|
91
|
+
store.pending = undefined;
|
|
92
|
+
active = { id: randomUUID(), cwd, profileName };
|
|
93
|
+
return active.id;
|
|
94
|
+
},
|
|
95
|
+
isActive(id) {
|
|
96
|
+
return active?.id === id;
|
|
97
|
+
},
|
|
98
|
+
finish(id) {
|
|
99
|
+
if (active?.id === id)
|
|
100
|
+
active = undefined;
|
|
101
|
+
},
|
|
102
|
+
cancel() {
|
|
103
|
+
active = undefined;
|
|
104
|
+
store.pending = undefined;
|
|
105
|
+
},
|
|
106
|
+
suspend(input) {
|
|
107
|
+
const intent = active ??
|
|
108
|
+
(input.connected
|
|
109
|
+
? { id: randomUUID(), cwd: input.cwd, profileName: input.profileName }
|
|
110
|
+
: undefined);
|
|
111
|
+
active = undefined;
|
|
112
|
+
store.pending =
|
|
113
|
+
input.reason === "resume" &&
|
|
114
|
+
input.targetSessionFile &&
|
|
115
|
+
intent?.cwd === input.cwd
|
|
116
|
+
? {
|
|
117
|
+
...intent,
|
|
118
|
+
pid,
|
|
119
|
+
targetSessionFile: input.targetSessionFile,
|
|
120
|
+
expiresAtMs: now() + 30_000,
|
|
121
|
+
}
|
|
122
|
+
: undefined;
|
|
123
|
+
},
|
|
124
|
+
resume(input) {
|
|
125
|
+
const handoff = store.pending;
|
|
126
|
+
store.pending = undefined;
|
|
127
|
+
if (!handoff ||
|
|
128
|
+
handoff.pid !== pid ||
|
|
129
|
+
now() >= handoff.expiresAtMs ||
|
|
130
|
+
input.reason !== "resume" ||
|
|
131
|
+
input.cwd !== handoff.cwd ||
|
|
132
|
+
input.sessionFile !== handoff.targetSessionFile)
|
|
133
|
+
return undefined;
|
|
134
|
+
active = {
|
|
135
|
+
id: randomUUID(),
|
|
136
|
+
cwd: handoff.cwd,
|
|
137
|
+
profileName: handoff.profileName,
|
|
138
|
+
};
|
|
139
|
+
return { ...active };
|
|
140
|
+
},
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
export function createTelegramSessionContextStore(options = {}) {
|
|
144
|
+
let currentContext;
|
|
145
|
+
let currentIdentity;
|
|
146
|
+
let generation = 0;
|
|
147
|
+
const objectIdentityGenerations = new WeakMap();
|
|
148
|
+
const primitiveIdentityGenerations = new Map();
|
|
149
|
+
const resolveIdentity = (ctx) => options.getIdentity?.(ctx) ?? ctx;
|
|
150
|
+
const getIdentityGeneration = (identity) => (typeof identity === "object" && identity !== null) ||
|
|
151
|
+
typeof identity === "function"
|
|
152
|
+
? objectIdentityGenerations.get(identity)
|
|
153
|
+
: primitiveIdentityGenerations.get(identity);
|
|
154
|
+
const setIdentityGeneration = (identity, value) => {
|
|
155
|
+
if ((typeof identity === "object" && identity !== null) ||
|
|
156
|
+
typeof identity === "function") {
|
|
157
|
+
objectIdentityGenerations.set(identity, value);
|
|
158
|
+
}
|
|
159
|
+
else {
|
|
160
|
+
primitiveIdentityGenerations.set(identity, value);
|
|
161
|
+
}
|
|
162
|
+
};
|
|
163
|
+
return {
|
|
164
|
+
get: () => currentContext,
|
|
165
|
+
getGeneration: () => generation,
|
|
166
|
+
isCurrent: (ctx, expectedGeneration) => {
|
|
167
|
+
if (currentContext === undefined)
|
|
168
|
+
return false;
|
|
169
|
+
const identity = resolveIdentity(ctx);
|
|
170
|
+
return (identity === currentIdentity &&
|
|
171
|
+
getIdentityGeneration(identity) === generation &&
|
|
172
|
+
(expectedGeneration === undefined || generation === expectedGeneration));
|
|
173
|
+
},
|
|
174
|
+
set: (ctx) => {
|
|
175
|
+
currentContext = ctx;
|
|
176
|
+
currentIdentity = resolveIdentity(ctx);
|
|
177
|
+
generation += 1;
|
|
178
|
+
setIdentityGeneration(currentIdentity, generation);
|
|
179
|
+
return generation;
|
|
180
|
+
},
|
|
181
|
+
clear: (ctx) => {
|
|
182
|
+
if (ctx !== undefined) {
|
|
183
|
+
const identity = resolveIdentity(ctx);
|
|
184
|
+
if (identity !== currentIdentity ||
|
|
185
|
+
getIdentityGeneration(identity) !== generation) {
|
|
186
|
+
return false;
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
if (currentContext === undefined)
|
|
190
|
+
return false;
|
|
191
|
+
currentContext = undefined;
|
|
192
|
+
currentIdentity = undefined;
|
|
193
|
+
generation += 1;
|
|
194
|
+
return true;
|
|
195
|
+
},
|
|
196
|
+
};
|
|
197
|
+
}
|
|
198
|
+
export function createTelegramSessionGenerationFence(store, hooks) {
|
|
199
|
+
return {
|
|
200
|
+
async onSessionStart(event, ctx) {
|
|
201
|
+
const generation = store.set(ctx);
|
|
202
|
+
await hooks.onSessionStart(event, ctx);
|
|
203
|
+
if (!store.isCurrent(ctx, generation))
|
|
204
|
+
return;
|
|
205
|
+
},
|
|
206
|
+
async onSessionShutdown(event, ctx) {
|
|
207
|
+
const generation = store.getGeneration();
|
|
208
|
+
if (!store.isCurrent(ctx, generation))
|
|
209
|
+
return;
|
|
210
|
+
await hooks.onSessionShutdown(event, ctx);
|
|
211
|
+
if (store.isCurrent(ctx, generation))
|
|
212
|
+
store.clear(ctx);
|
|
213
|
+
},
|
|
214
|
+
};
|
|
215
|
+
}
|
|
216
|
+
export function createTelegramBridgeSessionLifecycleDeps(ports) {
|
|
217
|
+
return {
|
|
218
|
+
contextStore: ports.contextStore,
|
|
219
|
+
queue: ports.queue,
|
|
220
|
+
follower: ports.follower,
|
|
221
|
+
services: {
|
|
222
|
+
resumeGroupedInput(ctx) {
|
|
223
|
+
ports.services.mediaGroup.resume(ctx);
|
|
224
|
+
ports.services.textGroup.resume(ctx);
|
|
225
|
+
},
|
|
226
|
+
suspendGroupedInput: TextGroups.createTelegramGroupedInputClearer({
|
|
227
|
+
clearMediaGroups: ports.services.mediaGroup.suspend,
|
|
228
|
+
clearTextGroups: ports.services.textGroup.suspend,
|
|
229
|
+
}),
|
|
230
|
+
delivery: ports.services.delivery,
|
|
231
|
+
polling: ports.services.polling,
|
|
232
|
+
connection: ports.services.connection,
|
|
233
|
+
inboundWorker: ports.services.inboundWorker,
|
|
234
|
+
capabilityMonitor: ports.services.capabilityMonitor,
|
|
235
|
+
queueWatchdog: ports.services.queueWatchdog,
|
|
236
|
+
guestPlaceholder: ports.services.guestPlaceholder,
|
|
237
|
+
prepareThreadPreservationOnQuit: ports.services.prepareThreadPreservationOnQuit,
|
|
238
|
+
},
|
|
239
|
+
};
|
|
240
|
+
}
|
|
241
|
+
export function createTelegramBridgeSessionLifecycleAssembly(deps) {
|
|
242
|
+
const isSessionActive = deps.contextStore.isCurrent;
|
|
243
|
+
const suspendForReplacement = BusFollower.createTelegramBusFollowerSessionReplacementSuspender({
|
|
244
|
+
registrationState: deps.follower.registrationState,
|
|
245
|
+
instanceId: deps.follower.instanceId,
|
|
246
|
+
suspendPolling: deps.follower.suspendPolling,
|
|
247
|
+
recordRuntimeEvent: deps.follower.recordRuntimeEvent,
|
|
248
|
+
});
|
|
249
|
+
let preserveTarget = true;
|
|
250
|
+
const queueLifecycle = Queue.createTelegramSessionLifecycleRuntime({
|
|
251
|
+
...deps.queue,
|
|
252
|
+
isSessionActive,
|
|
253
|
+
stopPolling: () => suspendForReplacement(preserveTarget),
|
|
254
|
+
clearPendingMediaGroups: deps.services.suspendGroupedInput,
|
|
255
|
+
});
|
|
256
|
+
const servicesLifecycle = {
|
|
257
|
+
async onSessionStart(event, ctx) {
|
|
258
|
+
const resumeConnection = deps.services.connection?.prepare(event, ctx);
|
|
259
|
+
await queueLifecycle.onSessionStart(event, ctx);
|
|
260
|
+
if (!isSessionActive(ctx))
|
|
261
|
+
return;
|
|
262
|
+
deps.services.resumeGroupedInput(ctx);
|
|
263
|
+
await deps.services.delivery.onSessionStart();
|
|
264
|
+
if (!isSessionActive(ctx))
|
|
265
|
+
return;
|
|
266
|
+
if (resumeConnection)
|
|
267
|
+
resumeConnection();
|
|
268
|
+
else
|
|
269
|
+
await deps.services.polling.onSessionStart(event, ctx);
|
|
270
|
+
deps.services.capabilityMonitor.start(ctx);
|
|
271
|
+
deps.services.queueWatchdog.start(ctx);
|
|
272
|
+
},
|
|
273
|
+
async onSessionShutdown(event, ctx) {
|
|
274
|
+
const generation = deps.contextStore.getGeneration();
|
|
275
|
+
const isCurrent = () => deps.contextStore.isCurrent(ctx, generation);
|
|
276
|
+
if (!isCurrent())
|
|
277
|
+
return;
|
|
278
|
+
deps.services.connection?.onSessionShutdown(event, ctx);
|
|
279
|
+
preserveTarget = event.reason !== "resume";
|
|
280
|
+
let preserveThread;
|
|
281
|
+
if (event.reason === "quit") {
|
|
282
|
+
try {
|
|
283
|
+
preserveThread =
|
|
284
|
+
deps.services.prepareThreadPreservationOnQuit?.(isCurrent);
|
|
285
|
+
}
|
|
286
|
+
catch (error) {
|
|
287
|
+
deps.follower.recordRuntimeEvent("session", error, {
|
|
288
|
+
phase: "preserve-thread-on-quit",
|
|
289
|
+
});
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
deps.services.guestPlaceholder?.stopAll();
|
|
293
|
+
await deps.services.delivery.onSessionShutdown();
|
|
294
|
+
if (!isCurrent())
|
|
295
|
+
return;
|
|
296
|
+
deps.services.queueWatchdog.stop();
|
|
297
|
+
deps.services.capabilityMonitor.stop();
|
|
298
|
+
await queueLifecycle.onSessionShutdown(event, ctx);
|
|
299
|
+
if (!isCurrent())
|
|
300
|
+
return;
|
|
301
|
+
await deps.services.inboundWorker.onSessionShutdown();
|
|
302
|
+
if (!isCurrent())
|
|
303
|
+
return;
|
|
304
|
+
try {
|
|
305
|
+
await preserveThread?.();
|
|
306
|
+
}
|
|
307
|
+
catch (error) {
|
|
308
|
+
deps.follower.recordRuntimeEvent("session", error, {
|
|
309
|
+
phase: "preserve-thread-on-quit",
|
|
310
|
+
});
|
|
311
|
+
}
|
|
312
|
+
},
|
|
313
|
+
};
|
|
314
|
+
const followerLifecycle = appendTelegramLifecycleHooks(servicesLifecycle, {
|
|
315
|
+
onSessionStart: BusFollower.createTelegramBusFollowerSessionRefreshHook({
|
|
316
|
+
registrationState: deps.follower.registrationState,
|
|
317
|
+
registrationRuntime: deps.follower.registrationRuntime,
|
|
318
|
+
getLeaderState: deps.follower.getLeaderState,
|
|
319
|
+
isSessionActive,
|
|
320
|
+
updateStatus: deps.follower.updateStatus,
|
|
321
|
+
recordRuntimeEvent: deps.follower.recordRuntimeEvent,
|
|
322
|
+
}),
|
|
323
|
+
}, isSessionActive);
|
|
324
|
+
return createTelegramSessionGenerationFence(deps.contextStore, followerLifecycle);
|
|
325
|
+
}
|
|
326
|
+
function unrefTelegramLifecycleTimer(timer) {
|
|
327
|
+
if (!timer || typeof timer !== "object")
|
|
328
|
+
return;
|
|
329
|
+
if (typeof timer.unref === "function")
|
|
330
|
+
timer.unref();
|
|
331
|
+
}
|
|
332
|
+
export function createTelegramCompactionObserverRuntime(deps) {
|
|
333
|
+
const timeoutMs = deps.timeoutMs ?? 300_000;
|
|
334
|
+
const setTimer = deps.setTimer ?? setTimeout;
|
|
335
|
+
const clearTimer = deps.clearTimer ?? clearTimeout;
|
|
336
|
+
let fallbackTimer;
|
|
337
|
+
let observationGeneration = 0;
|
|
338
|
+
let typingStartedByObserver = false;
|
|
339
|
+
const clearFallbackTimer = () => {
|
|
340
|
+
observationGeneration += 1;
|
|
341
|
+
if (!fallbackTimer)
|
|
342
|
+
return;
|
|
343
|
+
clearTimer(fallbackTimer);
|
|
344
|
+
fallbackTimer = undefined;
|
|
345
|
+
};
|
|
346
|
+
// Stop only a typing loop this observer started; a pre-existing agent-owned loop is preserved.
|
|
347
|
+
const releaseCompactionPresence = (ctx) => {
|
|
348
|
+
deps.setCompactionInProgress(false);
|
|
349
|
+
if (typingStartedByObserver)
|
|
350
|
+
deps.stopTypingLoop?.();
|
|
351
|
+
typingStartedByObserver = false;
|
|
352
|
+
deps.updateStatus(ctx);
|
|
353
|
+
};
|
|
354
|
+
const requestDispatch = () => {
|
|
355
|
+
deps.requestDeferredDispatchNextQueuedTelegramTurn(deps.dispatchNextQueuedTelegramTurn);
|
|
356
|
+
};
|
|
357
|
+
return {
|
|
358
|
+
onSessionBeforeCompact: (_event, ctx) => {
|
|
359
|
+
if (deps.isContextActive && !deps.isContextActive(ctx))
|
|
360
|
+
return;
|
|
361
|
+
deps.setCompactionInProgress(true);
|
|
362
|
+
const typingStartResult = deps.startTypingLoop?.(ctx);
|
|
363
|
+
typingStartedByObserver =
|
|
364
|
+
!!deps.startTypingLoop && typingStartResult !== false;
|
|
365
|
+
deps.updateStatus(ctx);
|
|
366
|
+
clearFallbackTimer();
|
|
367
|
+
const admittedGeneration = observationGeneration;
|
|
368
|
+
fallbackTimer = setTimer(() => {
|
|
369
|
+
if (observationGeneration !== admittedGeneration)
|
|
370
|
+
return;
|
|
371
|
+
observationGeneration += 1;
|
|
372
|
+
fallbackTimer = undefined;
|
|
373
|
+
if (deps.isContextActive && !deps.isContextActive(ctx))
|
|
374
|
+
return;
|
|
375
|
+
releaseCompactionPresence(ctx);
|
|
376
|
+
deps.recordRuntimeEvent?.("compact", new Error("Compaction observer timed out"));
|
|
377
|
+
// Observer expiry releases local presence, not Pi's eventual terminal result.
|
|
378
|
+
requestDispatch();
|
|
379
|
+
}, timeoutMs);
|
|
380
|
+
unrefTelegramLifecycleTimer(fallbackTimer);
|
|
381
|
+
},
|
|
382
|
+
onSessionCompact: (_event, ctx) => {
|
|
383
|
+
if (deps.isContextActive && !deps.isContextActive(ctx))
|
|
384
|
+
return;
|
|
385
|
+
clearFallbackTimer();
|
|
386
|
+
releaseCompactionPresence(ctx);
|
|
387
|
+
requestDispatch();
|
|
388
|
+
},
|
|
389
|
+
onSessionCompactFailed: (_event, ctx) => {
|
|
390
|
+
if (deps.isContextActive && !deps.isContextActive(ctx))
|
|
391
|
+
return;
|
|
392
|
+
clearFallbackTimer();
|
|
393
|
+
releaseCompactionPresence(ctx);
|
|
394
|
+
deps.onCompactionAbandoned?.();
|
|
395
|
+
requestDispatch();
|
|
396
|
+
},
|
|
397
|
+
onSessionShutdown: () => {
|
|
398
|
+
clearFallbackTimer();
|
|
399
|
+
if (typingStartedByObserver)
|
|
400
|
+
deps.stopTypingLoop?.();
|
|
401
|
+
typingStartedByObserver = false;
|
|
402
|
+
},
|
|
403
|
+
};
|
|
404
|
+
}
|
|
405
|
+
export function createTelegramMessageActivityTypingHooks(deps) {
|
|
406
|
+
const ensureTyping = (ctx) => {
|
|
407
|
+
if (deps.hasActiveTurn())
|
|
408
|
+
deps.startTypingLoop(ctx);
|
|
409
|
+
};
|
|
410
|
+
const handleMessageActivity = async (phase, event, ctx, inner) => {
|
|
411
|
+
const typedCtx = ctx;
|
|
412
|
+
ensureTyping(typedCtx);
|
|
413
|
+
try {
|
|
414
|
+
await inner(event, ctx);
|
|
415
|
+
}
|
|
416
|
+
catch (error) {
|
|
417
|
+
deps.recordRuntimeEvent?.("message-activity", error, { phase });
|
|
418
|
+
}
|
|
419
|
+
finally {
|
|
420
|
+
ensureTyping(typedCtx);
|
|
421
|
+
}
|
|
422
|
+
};
|
|
423
|
+
return {
|
|
424
|
+
onMessageStart: (event, ctx) => handleMessageActivity("start", event, ctx, deps.onMessageStart),
|
|
425
|
+
onMessageUpdate: (event, ctx) => handleMessageActivity("update", event, ctx, deps.onMessageUpdate),
|
|
426
|
+
};
|
|
427
|
+
}
|
|
428
|
+
export function appendTelegramLifecycleHooks(base, extra, isSessionActive) {
|
|
429
|
+
return {
|
|
430
|
+
onSessionStart: async (event, ctx) => {
|
|
431
|
+
await base.onSessionStart(event, ctx);
|
|
432
|
+
if (isSessionActive?.(ctx) === false)
|
|
433
|
+
return;
|
|
434
|
+
await extra.onSessionStart?.(event, ctx);
|
|
435
|
+
},
|
|
436
|
+
onSessionShutdown: async (event, ctx) => {
|
|
437
|
+
await base.onSessionShutdown(event, ctx);
|
|
438
|
+
if (isSessionActive?.(ctx) === false)
|
|
439
|
+
return;
|
|
440
|
+
await extra.onSessionShutdown?.(event, ctx);
|
|
441
|
+
},
|
|
442
|
+
};
|
|
443
|
+
}
|
|
444
|
+
export function registerTelegramLifecycleHooks(pi, deps) {
|
|
445
|
+
const isActive = (ctx) => deps.isSessionActive?.(ctx) !== false;
|
|
446
|
+
pi.on("input", async (event, ctx) => {
|
|
447
|
+
if (!isActive(ctx))
|
|
448
|
+
return;
|
|
449
|
+
await deps.onInput?.(event, ctx);
|
|
450
|
+
});
|
|
451
|
+
pi.on("session_start", async (event, ctx) => {
|
|
452
|
+
await deps.onSessionStart(event, ctx);
|
|
453
|
+
});
|
|
454
|
+
pi.on("session_shutdown", async (event, ctx) => {
|
|
455
|
+
await deps.onSessionShutdown(event, ctx);
|
|
456
|
+
});
|
|
457
|
+
pi.on("session_before_compact", async (event, ctx) => {
|
|
458
|
+
if (!isActive(ctx))
|
|
459
|
+
return;
|
|
460
|
+
await deps.onSessionBeforeCompact?.(event, ctx);
|
|
461
|
+
});
|
|
462
|
+
pi.on("session_compact", async (event, ctx) => {
|
|
463
|
+
if (!isActive(ctx))
|
|
464
|
+
return;
|
|
465
|
+
await deps.onSessionCompact?.(event, ctx);
|
|
466
|
+
});
|
|
467
|
+
pi.on("session_compact_failed", async (event, ctx) => {
|
|
468
|
+
if (!isActive(ctx))
|
|
469
|
+
return;
|
|
470
|
+
await deps.onSessionCompactFailed?.(event, ctx);
|
|
471
|
+
});
|
|
472
|
+
// The Pi SDK still types this result as a string; compatible runtimes may
|
|
473
|
+
// preserve ordered system prompt blocks through the same public hook.
|
|
474
|
+
const registerBeforeAgentStart = pi.on.bind(pi);
|
|
475
|
+
registerBeforeAgentStart("before_agent_start", async (event, ctx) => {
|
|
476
|
+
return deps.onBeforeAgentStart(event, ctx);
|
|
477
|
+
});
|
|
478
|
+
pi.on("model_select", async (event, ctx) => {
|
|
479
|
+
if (!isActive(ctx))
|
|
480
|
+
return;
|
|
481
|
+
await deps.onModelSelect(event, ctx);
|
|
482
|
+
});
|
|
483
|
+
pi.on("agent_start", async (event, ctx) => {
|
|
484
|
+
if (!isActive(ctx))
|
|
485
|
+
return;
|
|
486
|
+
await deps.onAgentStart(event, ctx);
|
|
487
|
+
});
|
|
488
|
+
pi.on("tool_execution_start", async (event, ctx) => {
|
|
489
|
+
if (!isActive(ctx))
|
|
490
|
+
return;
|
|
491
|
+
await deps.onToolExecutionStart(event, ctx);
|
|
492
|
+
});
|
|
493
|
+
pi.on("tool_execution_update", async (event, ctx) => {
|
|
494
|
+
if (!isActive(ctx))
|
|
495
|
+
return;
|
|
496
|
+
await deps.onToolExecutionUpdate?.(event, ctx);
|
|
497
|
+
});
|
|
498
|
+
pi.on("tool_execution_end", async (event, ctx) => {
|
|
499
|
+
if (!isActive(ctx))
|
|
500
|
+
return;
|
|
501
|
+
await deps.onToolExecutionEnd(event, ctx);
|
|
502
|
+
});
|
|
503
|
+
pi.on("message_start", async (event, ctx) => {
|
|
504
|
+
if (!isActive(ctx))
|
|
505
|
+
return;
|
|
506
|
+
await deps.onMessageStart(event, ctx);
|
|
507
|
+
});
|
|
508
|
+
pi.on("message_update", async (event, ctx) => {
|
|
509
|
+
if (!isActive(ctx))
|
|
510
|
+
return;
|
|
511
|
+
await deps.onMessageUpdate(event, ctx);
|
|
512
|
+
});
|
|
513
|
+
pi.on("message_end", async (event, ctx) => {
|
|
514
|
+
if (!isActive(ctx))
|
|
515
|
+
return;
|
|
516
|
+
await deps.onMessageEnd?.(event, ctx);
|
|
517
|
+
});
|
|
518
|
+
pi.on("ui_prompt_start", async (event, ctx) => {
|
|
519
|
+
if (!isActive(ctx))
|
|
520
|
+
return;
|
|
521
|
+
await deps.onUiPromptStart?.(event, ctx);
|
|
522
|
+
});
|
|
523
|
+
pi.on("ui_prompt_end", async (event, ctx) => {
|
|
524
|
+
if (!isActive(ctx))
|
|
525
|
+
return;
|
|
526
|
+
await deps.onUiPromptEnd?.(event, ctx);
|
|
527
|
+
});
|
|
528
|
+
pi.on("agent_end", async (event, ctx) => {
|
|
529
|
+
if (!isActive(ctx))
|
|
530
|
+
return;
|
|
531
|
+
await deps.onAgentEnd(event, ctx);
|
|
532
|
+
});
|
|
533
|
+
pi.on("agent_settled", async (event, ctx) => {
|
|
534
|
+
if (!isActive(ctx))
|
|
535
|
+
return;
|
|
536
|
+
await deps.onAgentSettled?.(event, ctx);
|
|
537
|
+
});
|
|
538
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* pi SDK adapter boundary
|
|
3
|
+
* Zones: pi agent sdk boundary, shared adapters
|
|
4
|
+
* Owns direct pi SDK imports and exposes narrow bridge-facing helpers/types for the extension composition layer
|
|
5
|
+
*/
|
|
6
|
+
import type { AssistantMessageEvent } from "@earendil-works/pi-ai";
|
|
7
|
+
import { type AgentEndEvent, type AgentSettledEvent, type AgentStartEvent, type BeforeAgentStartEvent, type ExtensionAPI, type ExtensionCommandContext, type ExtensionContext, type InputEvent, type MessageEndEvent, type SessionBeforeCompactEvent, type SessionCompactEvent, type SessionShutdownEvent, type SessionStartEvent, type SlashCommandInfo, type UIPromptEndEvent, type UIPromptStartEvent } from "@earendil-works/pi-coding-agent";
|
|
8
|
+
export type { AgentEndEvent, AgentSettledEvent, AgentStartEvent, AssistantMessageEvent, BeforeAgentStartEvent, ExtensionAPI, ExtensionCommandContext, ExtensionContext, InputEvent, MessageEndEvent, SessionBeforeCompactEvent, SessionCompactEvent, SessionShutdownEvent, SessionStartEvent, SlashCommandInfo, UIPromptEndEvent, UIPromptStartEvent, };
|
|
9
|
+
export interface SessionCompactFailedEvent {
|
|
10
|
+
type: "session_compact_failed";
|
|
11
|
+
reason: "manual" | "threshold" | "overflow";
|
|
12
|
+
errorMessage?: string;
|
|
13
|
+
aborted: boolean;
|
|
14
|
+
willRetry: boolean;
|
|
15
|
+
fromExtension: boolean;
|
|
16
|
+
}
|
|
17
|
+
export interface ToolExecutionStartEvent {
|
|
18
|
+
type: "tool_execution_start";
|
|
19
|
+
toolCallId: string;
|
|
20
|
+
toolName: string;
|
|
21
|
+
args: unknown;
|
|
22
|
+
}
|
|
23
|
+
export interface ToolExecutionUpdateEvent {
|
|
24
|
+
type: "tool_execution_update";
|
|
25
|
+
toolCallId: string;
|
|
26
|
+
toolName: string;
|
|
27
|
+
args: unknown;
|
|
28
|
+
partialResult: unknown;
|
|
29
|
+
}
|
|
30
|
+
export interface ToolExecutionEndEvent {
|
|
31
|
+
type: "tool_execution_end";
|
|
32
|
+
toolCallId: string;
|
|
33
|
+
toolName: string;
|
|
34
|
+
result: unknown;
|
|
35
|
+
isError: boolean;
|
|
36
|
+
}
|
|
37
|
+
export interface PiSettingsManager {
|
|
38
|
+
reload: () => Promise<void>;
|
|
39
|
+
flush: () => Promise<void>;
|
|
40
|
+
getEnabledModels: () => string[] | undefined;
|
|
41
|
+
setEnabledModels: (patterns: string[] | undefined) => void;
|
|
42
|
+
}
|
|
43
|
+
export type PiSlashCommandInfo = SlashCommandInfo;
|
|
44
|
+
export type PiRunMode = "tui" | "rpc" | "json" | "print";
|
|
45
|
+
/** Pi rejects a context captured before session replacement with a stale-context error; this is not a domain failure. */
|
|
46
|
+
export declare function isPiStaleContextError(error: unknown): boolean;
|
|
47
|
+
export declare function getExtensionContextMode(ctx: unknown): PiRunMode | undefined;
|
|
48
|
+
export declare function isExtensionContextPassiveRunMode(ctx: unknown): boolean;
|
|
49
|
+
export declare function canStartPollingInExtensionContext(ctx: unknown): boolean;
|
|
50
|
+
export declare function formatPollingStartBlockedByRunMode(ctx: unknown): string;
|
|
51
|
+
export declare function getSessionCompactionReason(event: unknown): "manual" | "threshold" | "overflow" | "unknown";
|
|
52
|
+
export interface PiExtensionApiRuntimePorts {
|
|
53
|
+
sendUserMessage: ExtensionAPI["sendUserMessage"];
|
|
54
|
+
exec: ExtensionAPI["exec"];
|
|
55
|
+
getCommands: ExtensionAPI["getCommands"];
|
|
56
|
+
getThinkingLevel: ExtensionAPI["getThinkingLevel"];
|
|
57
|
+
setThinkingLevel: ExtensionAPI["setThinkingLevel"];
|
|
58
|
+
getActiveTools: ExtensionAPI["getActiveTools"];
|
|
59
|
+
setActiveTools: ExtensionAPI["setActiveTools"];
|
|
60
|
+
setModel: ExtensionAPI["setModel"];
|
|
61
|
+
registerCommand: ExtensionAPI["registerCommand"];
|
|
62
|
+
}
|
|
63
|
+
export declare function createExtensionApiRuntimePorts(api: Pick<ExtensionAPI, "sendUserMessage" | "exec" | "getCommands" | "getThinkingLevel" | "setThinkingLevel" | "getActiveTools" | "setActiveTools" | "setModel" | "registerCommand">): PiExtensionApiRuntimePorts;
|
|
64
|
+
export declare function normalizeSettingsManager(manager: unknown): PiSettingsManager;
|
|
65
|
+
export declare function createSettingsManager(cwd: string): Promise<PiSettingsManager>;
|
|
66
|
+
export declare function createScopedModelPatternPersister(deps: {
|
|
67
|
+
createSettingsManager: (cwd: string) => PiSettingsManager | PromiseLike<PiSettingsManager>;
|
|
68
|
+
clearCachedModelMenuInputs: () => void;
|
|
69
|
+
}): (patterns: string[], ctx: ExtensionContext) => Promise<void>;
|
|
70
|
+
export declare function getExtensionContextModel(ctx: ExtensionContext): ExtensionContext["model"];
|
|
71
|
+
export declare function getExtensionContextCwd(ctx: ExtensionContext): string;
|
|
72
|
+
export declare function getExtensionContextSessionId(ctx: ExtensionContext): string;
|
|
73
|
+
export declare function getExtensionContextSessionId(ctx: ExtensionContext | undefined): string | undefined;
|
|
74
|
+
export declare function isExtensionContextIdle(ctx: ExtensionContext): boolean;
|
|
75
|
+
export declare function hasExtensionContextPendingMessages(ctx: ExtensionContext): boolean;
|
|
76
|
+
export declare function compactExtensionContext(ctx: ExtensionContext, callbacks: Parameters<ExtensionContext["compact"]>[0]): ReturnType<ExtensionContext["compact"]>;
|