@pellux/goodvibes-sdk 0.38.0 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/contracts/artifacts/operator-contract.json +4468 -916
- package/dist/daemon.d.ts +2 -0
- package/dist/daemon.d.ts.map +1 -1
- package/dist/daemon.js +4 -0
- package/dist/events/communication.d.ts +1 -1
- package/dist/events/surfaces.d.ts +25 -3
- package/dist/events/surfaces.d.ts.map +1 -1
- package/dist/events/surfaces.js +22 -1
- package/dist/events/workflows.d.ts +7 -6
- package/dist/events/workflows.d.ts.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/platform/agents/archetypes.d.ts.map +1 -1
- package/dist/platform/agents/archetypes.js +7 -0
- package/dist/platform/agents/index.d.ts +1 -0
- package/dist/platform/agents/index.d.ts.map +1 -1
- package/dist/platform/agents/index.js +1 -0
- package/dist/platform/agents/orchestrator-runner.d.ts +16 -3
- package/dist/platform/agents/orchestrator-runner.d.ts.map +1 -1
- package/dist/platform/agents/orchestrator-runner.js +20 -6
- package/dist/platform/agents/orchestrator.d.ts +42 -10
- package/dist/platform/agents/orchestrator.d.ts.map +1 -1
- package/dist/platform/agents/orchestrator.js +68 -20
- package/dist/platform/agents/planner-decomposition-runner.d.ts +38 -0
- package/dist/platform/agents/planner-decomposition-runner.d.ts.map +1 -0
- package/dist/platform/agents/planner-decomposition-runner.js +113 -0
- package/dist/platform/agents/turn-knowledge-injection.d.ts +88 -3
- package/dist/platform/agents/turn-knowledge-injection.d.ts.map +1 -1
- package/dist/platform/agents/turn-knowledge-injection.js +147 -30
- package/dist/platform/agents/worktree.d.ts +126 -8
- package/dist/platform/agents/worktree.d.ts.map +1 -1
- package/dist/platform/agents/worktree.js +240 -19
- package/dist/platform/agents/wrfc-controller.d.ts +24 -1
- package/dist/platform/agents/wrfc-controller.d.ts.map +1 -1
- package/dist/platform/agents/wrfc-controller.js +161 -35
- package/dist/platform/agents/wrfc-gate-runtime.d.ts +9 -0
- package/dist/platform/agents/wrfc-gate-runtime.d.ts.map +1 -1
- package/dist/platform/agents/wrfc-gate-runtime.js +7 -3
- package/dist/platform/agents/wrfc-gates.d.ts +1 -1
- package/dist/platform/agents/wrfc-gates.d.ts.map +1 -1
- package/dist/platform/agents/wrfc-gates.js +7 -1
- package/dist/platform/agents/wrfc-types.d.ts +23 -3
- package/dist/platform/agents/wrfc-types.d.ts.map +1 -1
- package/dist/platform/automation/types.d.ts +9 -1
- package/dist/platform/automation/types.d.ts.map +1 -1
- package/dist/platform/calendar/calendar-api-shared.d.ts +25 -0
- package/dist/platform/calendar/calendar-api-shared.d.ts.map +1 -0
- package/dist/platform/calendar/calendar-api-shared.js +100 -0
- package/dist/platform/calendar/calendar-connector.d.ts +79 -0
- package/dist/platform/calendar/calendar-connector.d.ts.map +1 -0
- package/dist/platform/calendar/calendar-connector.js +155 -0
- package/dist/platform/calendar/google-calendar-api.d.ts +25 -0
- package/dist/platform/calendar/google-calendar-api.d.ts.map +1 -0
- package/dist/platform/calendar/google-calendar-api.js +89 -0
- package/dist/platform/calendar/http-fetch-adapter.d.ts +25 -0
- package/dist/platform/calendar/http-fetch-adapter.d.ts.map +1 -0
- package/dist/platform/calendar/http-fetch-adapter.js +25 -0
- package/dist/platform/calendar/ics-parser.d.ts +35 -0
- package/dist/platform/calendar/ics-parser.d.ts.map +1 -0
- package/dist/platform/calendar/ics-parser.js +236 -0
- package/dist/platform/calendar/index.d.ts +41 -0
- package/dist/platform/calendar/index.d.ts.map +1 -0
- package/dist/platform/calendar/index.js +49 -0
- package/dist/platform/calendar/merged-calendar-model.d.ts +67 -0
- package/dist/platform/calendar/merged-calendar-model.d.ts.map +1 -0
- package/dist/platform/calendar/merged-calendar-model.js +181 -0
- package/dist/platform/calendar/microsoft-graph-api.d.ts +25 -0
- package/dist/platform/calendar/microsoft-graph-api.d.ts.map +1 -0
- package/dist/platform/calendar/microsoft-graph-api.js +95 -0
- package/dist/platform/calendar/oauth-flow.d.ts +62 -0
- package/dist/platform/calendar/oauth-flow.d.ts.map +1 -0
- package/dist/platform/calendar/oauth-flow.js +305 -0
- package/dist/platform/calendar/oauth-providers.d.ts +43 -0
- package/dist/platform/calendar/oauth-providers.d.ts.map +1 -0
- package/dist/platform/calendar/oauth-providers.js +120 -0
- package/dist/platform/calendar/oauth-token-store.d.ts +72 -0
- package/dist/platform/calendar/oauth-token-store.d.ts.map +1 -0
- package/dist/platform/calendar/oauth-token-store.js +189 -0
- package/dist/platform/calendar/oauth-types.d.ts +274 -0
- package/dist/platform/calendar/oauth-types.d.ts.map +1 -0
- package/dist/platform/calendar/oauth-types.js +22 -0
- package/dist/platform/calendar/rrule.d.ts +39 -0
- package/dist/platform/calendar/rrule.d.ts.map +1 -0
- package/dist/platform/calendar/rrule.js +261 -0
- package/dist/platform/calendar/subscription-store.d.ts +118 -0
- package/dist/platform/calendar/subscription-store.d.ts.map +1 -0
- package/dist/platform/calendar/subscription-store.js +293 -0
- package/dist/platform/calendar/types.d.ts +170 -0
- package/dist/platform/calendar/types.d.ts.map +1 -0
- package/dist/platform/calendar/types.js +21 -0
- package/dist/platform/companion/companion-chat-attachments.d.ts +29 -0
- package/dist/platform/companion/companion-chat-attachments.d.ts.map +1 -0
- package/dist/platform/companion/companion-chat-attachments.js +121 -0
- package/dist/platform/companion/companion-chat-branching.d.ts +66 -0
- package/dist/platform/companion/companion-chat-branching.d.ts.map +1 -0
- package/dist/platform/companion/companion-chat-branching.js +142 -0
- package/dist/platform/companion/companion-chat-broker-bridge.d.ts +40 -0
- package/dist/platform/companion/companion-chat-broker-bridge.d.ts.map +1 -0
- package/dist/platform/companion/companion-chat-broker-bridge.js +14 -0
- package/dist/platform/companion/companion-chat-broker-sync.d.ts +38 -0
- package/dist/platform/companion/companion-chat-broker-sync.d.ts.map +1 -0
- package/dist/platform/companion/companion-chat-broker-sync.js +80 -0
- package/dist/platform/companion/companion-chat-gc.d.ts +63 -0
- package/dist/platform/companion/companion-chat-gc.d.ts.map +1 -0
- package/dist/platform/companion/companion-chat-gc.js +38 -0
- package/dist/platform/companion/companion-chat-manager.d.ts +91 -23
- package/dist/platform/companion/companion-chat-manager.d.ts.map +1 -1
- package/dist/platform/companion/companion-chat-manager.js +195 -223
- package/dist/platform/companion/companion-chat-persistence.d.ts +9 -1
- package/dist/platform/companion/companion-chat-persistence.d.ts.map +1 -1
- package/dist/platform/companion/companion-chat-persistence.js +10 -2
- package/dist/platform/companion/companion-chat-routes.d.ts +2 -1
- package/dist/platform/companion/companion-chat-routes.d.ts.map +1 -1
- package/dist/platform/companion/companion-chat-routes.js +113 -4
- package/dist/platform/companion/companion-chat-turn-execution.d.ts +61 -0
- package/dist/platform/companion/companion-chat-turn-execution.d.ts.map +1 -0
- package/dist/platform/companion/companion-chat-turn-execution.js +107 -0
- package/dist/platform/companion/companion-chat-types.d.ts +67 -0
- package/dist/platform/companion/companion-chat-types.d.ts.map +1 -1
- package/dist/platform/config/credential-status.d.ts +28 -0
- package/dist/platform/config/credential-status.d.ts.map +1 -0
- package/dist/platform/config/credential-status.js +75 -0
- package/dist/platform/config/index.d.ts +25 -0
- package/dist/platform/config/index.d.ts.map +1 -1
- package/dist/platform/config/index.js +18 -0
- package/dist/platform/config/manager.d.ts +9 -0
- package/dist/platform/config/manager.d.ts.map +1 -1
- package/dist/platform/config/manager.js +21 -2
- package/dist/platform/config/migrations.d.ts +48 -0
- package/dist/platform/config/migrations.d.ts.map +1 -0
- package/dist/platform/config/migrations.js +54 -0
- package/dist/platform/config/schema-domain-core.d.ts +10 -1
- package/dist/platform/config/schema-domain-core.d.ts.map +1 -1
- package/dist/platform/config/schema-domain-core.js +46 -3
- package/dist/platform/config/schema-domain-runtime.d.ts +8 -0
- package/dist/platform/config/schema-domain-runtime.d.ts.map +1 -1
- package/dist/platform/config/schema-domain-runtime.js +32 -0
- package/dist/platform/config/schema-types.d.ts +21 -7
- package/dist/platform/config/schema-types.d.ts.map +1 -1
- package/dist/platform/config/schema.d.ts.map +1 -1
- package/dist/platform/config/schema.js +2 -0
- package/dist/platform/control-plane/approval-broker.d.ts +11 -0
- package/dist/platform/control-plane/approval-broker.d.ts.map +1 -1
- package/dist/platform/control-plane/approval-broker.js +17 -1
- package/dist/platform/control-plane/approval-hunk-apply.d.ts +77 -0
- package/dist/platform/control-plane/approval-hunk-apply.d.ts.map +1 -0
- package/dist/platform/control-plane/approval-hunk-apply.js +80 -0
- package/dist/platform/control-plane/gateway-disabled-response.d.ts +20 -0
- package/dist/platform/control-plane/gateway-disabled-response.d.ts.map +1 -0
- package/dist/platform/control-plane/gateway-disabled-response.js +24 -0
- package/dist/platform/control-plane/gateway-scope-enforcement.d.ts +68 -0
- package/dist/platform/control-plane/gateway-scope-enforcement.d.ts.map +1 -0
- package/dist/platform/control-plane/gateway-scope-enforcement.js +91 -0
- package/dist/platform/control-plane/gateway-utils.d.ts +17 -0
- package/dist/platform/control-plane/gateway-utils.d.ts.map +1 -1
- package/dist/platform/control-plane/gateway-utils.js +30 -0
- package/dist/platform/control-plane/gateway.d.ts +12 -2
- package/dist/platform/control-plane/gateway.d.ts.map +1 -1
- package/dist/platform/control-plane/gateway.js +27 -31
- package/dist/platform/control-plane/index.d.ts +8 -1
- package/dist/platform/control-plane/index.d.ts.map +1 -1
- package/dist/platform/control-plane/index.js +8 -0
- package/dist/platform/control-plane/invoke-input-validation.d.ts +56 -0
- package/dist/platform/control-plane/invoke-input-validation.d.ts.map +1 -0
- package/dist/platform/control-plane/invoke-input-validation.js +163 -0
- package/dist/platform/control-plane/method-catalog-admin.d.ts.map +1 -1
- package/dist/platform/control-plane/method-catalog-admin.js +12 -1
- package/dist/platform/control-plane/method-catalog-calendar.d.ts +16 -0
- package/dist/platform/control-plane/method-catalog-calendar.d.ts.map +1 -1
- package/dist/platform/control-plane/method-catalog-calendar.js +21 -0
- package/dist/platform/control-plane/method-catalog-channels.d.ts.map +1 -1
- package/dist/platform/control-plane/method-catalog-channels.js +32 -3
- package/dist/platform/control-plane/method-catalog-control-automation.d.ts.map +1 -1
- package/dist/platform/control-plane/method-catalog-control-automation.js +19 -34
- package/dist/platform/control-plane/method-catalog-control-companion.d.ts +15 -0
- package/dist/platform/control-plane/method-catalog-control-companion.d.ts.map +1 -0
- package/dist/platform/control-plane/method-catalog-control-companion.js +176 -0
- package/dist/platform/control-plane/method-catalog-control-core.d.ts.map +1 -1
- package/dist/platform/control-plane/method-catalog-control-core.js +104 -122
- package/dist/platform/control-plane/method-catalog-control.d.ts.map +1 -1
- package/dist/platform/control-plane/method-catalog-control.js +4 -0
- package/dist/platform/control-plane/method-catalog-email.d.ts +17 -0
- package/dist/platform/control-plane/method-catalog-email.d.ts.map +1 -1
- package/dist/platform/control-plane/method-catalog-email.js +21 -0
- package/dist/platform/control-plane/method-catalog-events.d.ts +28 -0
- package/dist/platform/control-plane/method-catalog-events.d.ts.map +1 -1
- package/dist/platform/control-plane/method-catalog-events.js +74 -1
- package/dist/platform/control-plane/method-catalog-fleet.d.ts +24 -0
- package/dist/platform/control-plane/method-catalog-fleet.d.ts.map +1 -0
- package/dist/platform/control-plane/method-catalog-fleet.js +65 -0
- package/dist/platform/control-plane/method-catalog-push.d.ts +30 -0
- package/dist/platform/control-plane/method-catalog-push.d.ts.map +1 -0
- package/dist/platform/control-plane/method-catalog-push.js +80 -0
- package/dist/platform/control-plane/method-catalog-route-reconcile.d.ts +84 -0
- package/dist/platform/control-plane/method-catalog-route-reconcile.d.ts.map +1 -0
- package/dist/platform/control-plane/method-catalog-route-reconcile.js +103 -0
- package/dist/platform/control-plane/method-catalog-runtime.d.ts.map +1 -1
- package/dist/platform/control-plane/method-catalog-runtime.js +83 -1
- package/dist/platform/control-plane/method-catalog-shared.d.ts +29 -0
- package/dist/platform/control-plane/method-catalog-shared.d.ts.map +1 -1
- package/dist/platform/control-plane/method-catalog.d.ts +9 -0
- package/dist/platform/control-plane/method-catalog.d.ts.map +1 -1
- package/dist/platform/control-plane/method-catalog.js +34 -3
- package/dist/platform/control-plane/operator-contract-schemas-admin.d.ts +8 -0
- package/dist/platform/control-plane/operator-contract-schemas-admin.d.ts.map +1 -1
- package/dist/platform/control-plane/operator-contract-schemas-admin.js +22 -1
- package/dist/platform/control-plane/operator-contract-schemas-fleet.d.ts +18 -0
- package/dist/platform/control-plane/operator-contract-schemas-fleet.d.ts.map +1 -0
- package/dist/platform/control-plane/operator-contract-schemas-fleet.js +182 -0
- package/dist/platform/control-plane/operator-contract-schemas-permissions.d.ts.map +1 -1
- package/dist/platform/control-plane/operator-contract-schemas-permissions.js +5 -0
- package/dist/platform/control-plane/operator-contract-schemas-runtime.d.ts +37 -0
- package/dist/platform/control-plane/operator-contract-schemas-runtime.d.ts.map +1 -1
- package/dist/platform/control-plane/operator-contract-schemas-runtime.js +100 -3
- package/dist/platform/control-plane/operator-contract-schemas.d.ts +1 -0
- package/dist/platform/control-plane/operator-contract-schemas.d.ts.map +1 -1
- package/dist/platform/control-plane/operator-contract-schemas.js +1 -0
- package/dist/platform/control-plane/operator-contract.d.ts.map +1 -1
- package/dist/platform/control-plane/operator-contract.js +8 -0
- package/dist/platform/control-plane/routes/checkpoints.d.ts +39 -0
- package/dist/platform/control-plane/routes/checkpoints.d.ts.map +1 -0
- package/dist/platform/control-plane/routes/checkpoints.js +166 -0
- package/dist/platform/control-plane/routes/fleet.d.ts +53 -0
- package/dist/platform/control-plane/routes/fleet.d.ts.map +1 -0
- package/dist/platform/control-plane/routes/fleet.js +153 -0
- package/dist/platform/control-plane/routes/gateway-verb-error.d.ts +30 -0
- package/dist/platform/control-plane/routes/gateway-verb-error.d.ts.map +1 -0
- package/dist/platform/control-plane/routes/gateway-verb-error.js +36 -0
- package/dist/platform/control-plane/routes/index.d.ts +0 -6
- package/dist/platform/control-plane/routes/index.d.ts.map +1 -1
- package/dist/platform/control-plane/routes/index.js +5 -5
- package/dist/platform/control-plane/routes/invocation-params.d.ts +23 -0
- package/dist/platform/control-plane/routes/invocation-params.d.ts.map +1 -0
- package/dist/platform/control-plane/routes/invocation-params.js +9 -0
- package/dist/platform/control-plane/routes/push.d.ts +26 -0
- package/dist/platform/control-plane/routes/push.d.ts.map +1 -0
- package/dist/platform/control-plane/routes/push.js +104 -0
- package/dist/platform/control-plane/routes/register-gateway-verb-groups.d.ts +31 -0
- package/dist/platform/control-plane/routes/register-gateway-verb-groups.d.ts.map +1 -0
- package/dist/platform/control-plane/routes/register-gateway-verb-groups.js +16 -0
- package/dist/platform/control-plane/routes/register-w3-s2.d.ts +26 -0
- package/dist/platform/control-plane/routes/register-w3-s2.d.ts.map +1 -0
- package/dist/platform/control-plane/routes/register-w3-s2.js +8 -0
- package/dist/platform/control-plane/routes/session-search.d.ts +37 -0
- package/dist/platform/control-plane/routes/session-search.d.ts.map +1 -0
- package/dist/platform/control-plane/routes/session-search.js +113 -0
- package/dist/platform/control-plane/session-broker-gc.d.ts +16 -0
- package/dist/platform/control-plane/session-broker-gc.d.ts.map +1 -1
- package/dist/platform/control-plane/session-broker-gc.js +23 -6
- package/dist/platform/control-plane/session-broker-helpers.d.ts +3 -3
- package/dist/platform/control-plane/session-broker-helpers.d.ts.map +1 -1
- package/dist/platform/control-plane/session-broker-inputs.d.ts +18 -0
- package/dist/platform/control-plane/session-broker-inputs.d.ts.map +1 -1
- package/dist/platform/control-plane/session-broker-inputs.js +34 -0
- package/dist/platform/control-plane/session-broker-sessions.d.ts +102 -3
- package/dist/platform/control-plane/session-broker-sessions.d.ts.map +1 -1
- package/dist/platform/control-plane/session-broker-sessions.js +179 -5
- package/dist/platform/control-plane/session-broker-state.d.ts +20 -1
- package/dist/platform/control-plane/session-broker-state.d.ts.map +1 -1
- package/dist/platform/control-plane/session-broker-state.js +67 -5
- package/dist/platform/control-plane/session-broker.d.ts +51 -38
- package/dist/platform/control-plane/session-broker.d.ts.map +1 -1
- package/dist/platform/control-plane/session-broker.js +183 -75
- package/dist/platform/control-plane/session-store-importer.d.ts +57 -0
- package/dist/platform/control-plane/session-store-importer.d.ts.map +1 -0
- package/dist/platform/control-plane/session-store-importer.js +227 -0
- package/dist/platform/control-plane/session-types.d.ts +142 -7
- package/dist/platform/control-plane/session-types.d.ts.map +1 -1
- package/dist/platform/core/execution-plan.d.ts +43 -1
- package/dist/platform/core/execution-plan.d.ts.map +1 -1
- package/dist/platform/core/execution-plan.js +46 -10
- package/dist/platform/core/index.d.ts +1 -0
- package/dist/platform/core/index.d.ts.map +1 -1
- package/dist/platform/core/index.js +1 -0
- package/dist/platform/core/orchestrator-runtime.d.ts +23 -3
- package/dist/platform/core/orchestrator-runtime.d.ts.map +1 -1
- package/dist/platform/core/orchestrator-tool-runtime.d.ts +7 -0
- package/dist/platform/core/orchestrator-tool-runtime.d.ts.map +1 -1
- package/dist/platform/core/orchestrator-tool-runtime.js +10 -0
- package/dist/platform/core/orchestrator-turn-loop.d.ts +13 -6
- package/dist/platform/core/orchestrator-turn-loop.d.ts.map +1 -1
- package/dist/platform/core/orchestrator-turn-loop.js +29 -22
- package/dist/platform/core/orchestrator.d.ts +16 -10
- package/dist/platform/core/orchestrator.d.ts.map +1 -1
- package/dist/platform/core/orchestrator.js +23 -8
- package/dist/platform/core/plan-decomposition.d.ts +196 -0
- package/dist/platform/core/plan-decomposition.d.ts.map +1 -0
- package/dist/platform/core/plan-decomposition.js +417 -0
- package/dist/platform/core/plan-proposal.d.ts +39 -0
- package/dist/platform/core/plan-proposal.d.ts.map +1 -1
- package/dist/platform/core/wrfc-routing.d.ts +1 -0
- package/dist/platform/core/wrfc-routing.d.ts.map +1 -1
- package/dist/platform/core/wrfc-routing.js +51 -1
- package/dist/platform/daemon/boot.d.ts +69 -0
- package/dist/platform/daemon/boot.d.ts.map +1 -0
- package/dist/platform/daemon/boot.js +61 -0
- package/dist/platform/daemon/cli.js +2 -1
- package/dist/platform/daemon/control-plane.d.ts.map +1 -1
- package/dist/platform/daemon/control-plane.js +50 -1
- package/dist/platform/daemon/facade-composition.d.ts.map +1 -1
- package/dist/platform/daemon/facade-composition.js +6 -0
- package/dist/platform/daemon/facade.d.ts +15 -6
- package/dist/platform/daemon/facade.d.ts.map +1 -1
- package/dist/platform/daemon/facade.js +48 -43
- package/dist/platform/daemon/http/router-route-contexts.d.ts +1 -0
- package/dist/platform/daemon/http/router-route-contexts.d.ts.map +1 -1
- package/dist/platform/daemon/http/router-route-contexts.js +1 -0
- package/dist/platform/daemon/http/router-session-broker-adapter.d.ts +13 -0
- package/dist/platform/daemon/http/router-session-broker-adapter.d.ts.map +1 -0
- package/dist/platform/daemon/http/router-session-broker-adapter.js +27 -0
- package/dist/platform/daemon/http/router.d.ts +2 -1
- package/dist/platform/daemon/http/router.d.ts.map +1 -1
- package/dist/platform/daemon/http/router.js +42 -40
- package/dist/platform/daemon/http/runtime-route-types.d.ts +42 -4
- package/dist/platform/daemon/http/runtime-route-types.d.ts.map +1 -1
- package/dist/platform/daemon/http/webui-serving.d.ts +68 -0
- package/dist/platform/daemon/http/webui-serving.d.ts.map +1 -0
- package/dist/platform/daemon/http/webui-serving.js +230 -0
- package/dist/platform/daemon/index.d.ts +2 -0
- package/dist/platform/daemon/index.d.ts.map +1 -1
- package/dist/platform/daemon/index.js +1 -0
- package/dist/platform/daemon/service-manager.d.ts +16 -0
- package/dist/platform/daemon/service-manager.d.ts.map +1 -1
- package/dist/platform/daemon/service-manager.js +79 -15
- package/dist/platform/intelligence/tree-sitter/service.d.ts.map +1 -1
- package/dist/platform/intelligence/tree-sitter/service.js +16 -2
- package/dist/platform/knowledge/browser-history/readers.d.ts.map +1 -1
- package/dist/platform/knowledge/browser-history/readers.js +15 -5
- package/dist/platform/knowledge/knowledge-api.d.ts +1 -1
- package/dist/platform/knowledge/project-planning/service.d.ts +14 -1
- package/dist/platform/knowledge/project-planning/service.d.ts.map +1 -1
- package/dist/platform/knowledge/project-planning/service.js +77 -0
- package/dist/platform/knowledge/project-planning/types.d.ts +32 -0
- package/dist/platform/knowledge/project-planning/types.d.ts.map +1 -1
- package/dist/platform/orchestration/bookkeeping.d.ts +12 -0
- package/dist/platform/orchestration/bookkeeping.d.ts.map +1 -0
- package/dist/platform/orchestration/bookkeeping.js +91 -0
- package/dist/platform/orchestration/budget.d.ts +2 -2
- package/dist/platform/orchestration/cancellation.d.ts +2 -2
- package/dist/platform/orchestration/controller-compat.d.ts +16 -3
- package/dist/platform/orchestration/controller-compat.d.ts.map +1 -1
- package/dist/platform/orchestration/controller-compat.js +18 -4
- package/dist/platform/orchestration/dirty-guard.js +1 -1
- package/dist/platform/orchestration/engine.d.ts +26 -1
- package/dist/platform/orchestration/engine.d.ts.map +1 -1
- package/dist/platform/orchestration/engine.js +229 -25
- package/dist/platform/orchestration/index.d.ts +6 -4
- package/dist/platform/orchestration/index.d.ts.map +1 -1
- package/dist/platform/orchestration/index.js +3 -2
- package/dist/platform/orchestration/persistence.d.ts.map +1 -1
- package/dist/platform/orchestration/persistence.js +6 -3
- package/dist/platform/orchestration/phase-runner.d.ts +33 -6
- package/dist/platform/orchestration/phase-runner.d.ts.map +1 -1
- package/dist/platform/orchestration/phase-runner.js +98 -25
- package/dist/platform/orchestration/proposal-workstream.d.ts +56 -0
- package/dist/platform/orchestration/proposal-workstream.d.ts.map +1 -0
- package/dist/platform/orchestration/proposal-workstream.js +76 -0
- package/dist/platform/orchestration/scheduler.d.ts +20 -1
- package/dist/platform/orchestration/scheduler.d.ts.map +1 -1
- package/dist/platform/orchestration/scheduler.js +16 -0
- package/dist/platform/orchestration/types.d.ts +289 -4
- package/dist/platform/orchestration/types.d.ts.map +1 -1
- package/dist/platform/orchestration/types.js +32 -0
- package/dist/platform/orchestration/worktree-isolation.d.ts +33 -0
- package/dist/platform/orchestration/worktree-isolation.d.ts.map +1 -0
- package/dist/platform/orchestration/worktree-isolation.js +248 -0
- package/dist/platform/presentation/glyphs.d.ts +91 -0
- package/dist/platform/presentation/glyphs.d.ts.map +1 -0
- package/dist/platform/presentation/glyphs.js +93 -0
- package/dist/platform/presentation/index.d.ts +28 -0
- package/dist/platform/presentation/index.d.ts.map +1 -0
- package/dist/platform/presentation/index.js +27 -0
- package/dist/platform/presentation/thinking-phrases.d.ts +12 -0
- package/dist/platform/presentation/thinking-phrases.d.ts.map +1 -0
- package/dist/platform/presentation/thinking-phrases.js +32 -0
- package/dist/platform/presentation/tones.d.ts +121 -0
- package/dist/platform/presentation/tones.d.ts.map +1 -0
- package/dist/platform/presentation/tones.js +145 -0
- package/dist/platform/presentation/waiting-wording.d.ts +54 -0
- package/dist/platform/presentation/waiting-wording.d.ts.map +1 -0
- package/dist/platform/presentation/waiting-wording.js +51 -0
- package/dist/platform/providers/runtime-snapshot.d.ts.map +1 -1
- package/dist/platform/providers/runtime-snapshot.js +12 -2
- package/dist/platform/push/delivery.d.ts +48 -0
- package/dist/platform/push/delivery.d.ts.map +1 -0
- package/dist/platform/push/delivery.js +117 -0
- package/dist/platform/push/encryption.d.ts +41 -0
- package/dist/platform/push/encryption.d.ts.map +1 -0
- package/dist/platform/push/encryption.js +82 -0
- package/dist/platform/push/index.d.ts +17 -0
- package/dist/platform/push/index.d.ts.map +1 -0
- package/dist/platform/push/index.js +10 -0
- package/dist/platform/push/service.d.ts +75 -0
- package/dist/platform/push/service.d.ts.map +1 -0
- package/dist/platform/push/service.js +95 -0
- package/dist/platform/push/subscription-store.d.ts +50 -0
- package/dist/platform/push/subscription-store.d.ts.map +1 -0
- package/dist/platform/push/subscription-store.js +123 -0
- package/dist/platform/push/types.d.ts +68 -0
- package/dist/platform/push/types.d.ts.map +1 -0
- package/dist/platform/push/types.js +13 -0
- package/dist/platform/push/vapid.d.ts +54 -0
- package/dist/platform/push/vapid.d.ts.map +1 -0
- package/dist/platform/push/vapid.js +113 -0
- package/dist/platform/runtime/bootstrap-services.d.ts +62 -2
- package/dist/platform/runtime/bootstrap-services.d.ts.map +1 -1
- package/dist/platform/runtime/bootstrap-services.js +217 -50
- package/dist/platform/runtime/daemon-version-compat.d.ts +39 -0
- package/dist/platform/runtime/daemon-version-compat.d.ts.map +1 -0
- package/dist/platform/runtime/daemon-version-compat.js +75 -0
- package/dist/platform/runtime/detached-daemon-runtime.d.ts +26 -0
- package/dist/platform/runtime/detached-daemon-runtime.d.ts.map +1 -0
- package/dist/platform/runtime/detached-daemon-runtime.js +49 -0
- package/dist/platform/runtime/emitters/workflows.d.ts +1 -1
- package/dist/platform/runtime/emitters/workflows.d.ts.map +1 -1
- package/dist/platform/runtime/events/index.d.ts +13 -0
- package/dist/platform/runtime/events/index.d.ts.map +1 -1
- package/dist/platform/runtime/events/index.js +13 -0
- package/dist/platform/runtime/feature-flags/flags.d.ts.map +1 -1
- package/dist/platform/runtime/feature-flags/flags.js +39 -1
- package/dist/platform/runtime/fleet/adapters/agent.d.ts +2 -2
- package/dist/platform/runtime/fleet/adapters/agent.d.ts.map +1 -1
- package/dist/platform/runtime/fleet/adapters/agent.js +4 -4
- package/dist/platform/runtime/fleet/adapters/automation.d.ts +1 -1
- package/dist/platform/runtime/fleet/adapters/automation.js +1 -1
- package/dist/platform/runtime/fleet/adapters/code-index.d.ts +1 -1
- package/dist/platform/runtime/fleet/adapters/code-index.js +1 -1
- package/dist/platform/runtime/fleet/adapters/orchestration.d.ts +40 -18
- package/dist/platform/runtime/fleet/adapters/orchestration.d.ts.map +1 -1
- package/dist/platform/runtime/fleet/adapters/orchestration.js +138 -34
- package/dist/platform/runtime/fleet/adapters/schedule.d.ts +4 -4
- package/dist/platform/runtime/fleet/adapters/schedule.js +4 -4
- package/dist/platform/runtime/fleet/adapters/trigger.d.ts +3 -4
- package/dist/platform/runtime/fleet/adapters/trigger.d.ts.map +1 -1
- package/dist/platform/runtime/fleet/adapters/trigger.js +3 -4
- package/dist/platform/runtime/fleet/adapters/wrfc.d.ts +13 -0
- package/dist/platform/runtime/fleet/adapters/wrfc.d.ts.map +1 -1
- package/dist/platform/runtime/fleet/adapters/wrfc.js +49 -2
- package/dist/platform/runtime/fleet/registry.d.ts +7 -7
- package/dist/platform/runtime/fleet/registry.d.ts.map +1 -1
- package/dist/platform/runtime/fleet/registry.js +41 -7
- package/dist/platform/runtime/fleet/types.d.ts +9 -9
- package/dist/platform/runtime/fleet/types.d.ts.map +1 -1
- package/dist/platform/runtime/memory-spine/client.d.ts +127 -0
- package/dist/platform/runtime/memory-spine/client.d.ts.map +1 -0
- package/dist/platform/runtime/memory-spine/client.js +113 -0
- package/dist/platform/runtime/memory-spine/index.d.ts +11 -0
- package/dist/platform/runtime/memory-spine/index.d.ts.map +1 -0
- package/dist/platform/runtime/memory-spine/index.js +10 -0
- package/dist/platform/runtime/operator-client.d.ts +20 -2
- package/dist/platform/runtime/operator-client.d.ts.map +1 -1
- package/dist/platform/runtime/operator-client.js +11 -1
- package/dist/platform/runtime/provider-accounts/registry.d.ts.map +1 -1
- package/dist/platform/runtime/provider-accounts/registry.js +11 -1
- package/dist/platform/runtime/services.d.ts +11 -9
- package/dist/platform/runtime/services.d.ts.map +1 -1
- package/dist/platform/runtime/services.js +24 -9
- package/dist/platform/runtime/session-spine/client.d.ts +234 -0
- package/dist/platform/runtime/session-spine/client.d.ts.map +1 -0
- package/dist/platform/runtime/session-spine/client.js +449 -0
- package/dist/platform/runtime/session-spine/index.d.ts +12 -0
- package/dist/platform/runtime/session-spine/index.d.ts.map +1 -0
- package/dist/platform/runtime/session-spine/index.js +11 -0
- package/dist/platform/runtime/session-spine/union-cache.d.ts +225 -0
- package/dist/platform/runtime/session-spine/union-cache.d.ts.map +1 -0
- package/dist/platform/runtime/session-spine/union-cache.js +333 -0
- package/dist/platform/runtime/shell-command-ops.d.ts +3 -1
- package/dist/platform/runtime/shell-command-ops.d.ts.map +1 -1
- package/dist/platform/runtime/transports/daemon-http-client-validators.d.ts.map +1 -1
- package/dist/platform/runtime/transports/daemon-http-client-validators.js +22 -0
- package/dist/platform/runtime/transports/daemon-http-client.d.ts.map +1 -1
- package/dist/platform/runtime/transports/daemon-http-client.js +25 -2
- package/dist/platform/runtime/transports/http-types.d.ts +9 -2
- package/dist/platform/runtime/transports/http-types.d.ts.map +1 -1
- package/dist/platform/state/canonical-memory.d.ts +95 -0
- package/dist/platform/state/canonical-memory.d.ts.map +1 -0
- package/dist/platform/state/canonical-memory.js +155 -0
- package/dist/platform/state/code-index-chunking.js +1 -1
- package/dist/platform/state/code-index-db.d.ts +1 -1
- package/dist/platform/state/code-index-reindex.d.ts +73 -0
- package/dist/platform/state/code-index-reindex.d.ts.map +1 -0
- package/dist/platform/state/code-index-reindex.js +156 -0
- package/dist/platform/state/code-index-store.d.ts.map +1 -1
- package/dist/platform/state/code-index-store.js +11 -3
- package/dist/platform/state/index.d.ts +8 -0
- package/dist/platform/state/index.d.ts.map +1 -1
- package/dist/platform/state/index.js +4 -0
- package/dist/platform/state/memory-recall-contract.d.ts +118 -0
- package/dist/platform/state/memory-recall-contract.d.ts.map +1 -0
- package/dist/platform/state/memory-recall-contract.js +170 -0
- package/dist/platform/state/memory-registry.d.ts +8 -0
- package/dist/platform/state/memory-registry.d.ts.map +1 -1
- package/dist/platform/state/memory-registry.js +10 -0
- package/dist/platform/state/memory-store.d.ts +2 -0
- package/dist/platform/state/memory-store.d.ts.map +1 -1
- package/dist/platform/state/memory-store.js +4 -0
- package/dist/platform/state/memory-vector-store.d.ts.map +1 -1
- package/dist/platform/state/memory-vector-store.js +14 -3
- package/dist/platform/state/sqlite-store.d.ts +2 -0
- package/dist/platform/state/sqlite-store.d.ts.map +1 -1
- package/dist/platform/state/sqlite-store.js +4 -0
- package/dist/platform/state/sqlite-vec-loader.d.ts +1 -1
- package/dist/platform/state/sqlite-vec-loader.js +1 -1
- package/dist/platform/state/vibe-projection.d.ts +67 -0
- package/dist/platform/state/vibe-projection.d.ts.map +1 -0
- package/dist/platform/state/vibe-projection.js +115 -0
- package/dist/platform/tools/agent/index.d.ts.map +1 -1
- package/dist/platform/tools/agent/index.js +8 -0
- package/dist/platform/tools/agent/manager.d.ts +22 -10
- package/dist/platform/tools/agent/manager.d.ts.map +1 -1
- package/dist/platform/tools/agent/manager.js +13 -7
- package/dist/platform/tools/agent/schema.d.ts +26 -0
- package/dist/platform/tools/agent/schema.d.ts.map +1 -1
- package/dist/platform/tools/agent/schema.js +2 -2
- package/dist/platform/tools/agent/wrfc-batch-policy.d.ts +13 -0
- package/dist/platform/tools/agent/wrfc-batch-policy.d.ts.map +1 -1
- package/dist/platform/tools/agent/wrfc-batch-policy.js +60 -0
- package/dist/platform/tools/exec/runtime.d.ts +10 -0
- package/dist/platform/tools/exec/runtime.d.ts.map +1 -1
- package/dist/platform/tools/exec/runtime.js +27 -10
- package/dist/platform/tools/exec/schema.d.ts +2 -2
- package/dist/platform/tools/exec/schema.d.ts.map +1 -1
- package/dist/platform/tools/exec/schema.js +2 -1
- package/dist/platform/tools/fetch/runtime.d.ts +1 -1
- package/dist/platform/tools/index.d.ts +2 -0
- package/dist/platform/tools/index.d.ts.map +1 -1
- package/dist/platform/tools/index.js +2 -0
- package/dist/platform/tools/registry.d.ts +1 -1
- package/dist/platform/tools/registry.js +1 -1
- package/dist/platform/tools/state/index.d.ts +9 -0
- package/dist/platform/tools/state/index.d.ts.map +1 -1
- package/dist/platform/tools/state/index.js +60 -3
- package/dist/platform/types/foundation-contract.d.ts +1 -1
- package/dist/platform/types/foundation-contract.d.ts.map +1 -1
- package/dist/platform/types/index.d.ts +1 -1
- package/dist/platform/types/index.d.ts.map +1 -1
- package/dist/platform/types/tools.d.ts +1 -1
- package/dist/platform/utils/request-body.d.ts.map +1 -1
- package/dist/platform/utils/request-body.js +50 -5
- package/dist/platform/version.js +1 -1
- package/package.json +25 -9
- package/dist/platform/control-plane/routes/automation.d.ts +0 -3
- package/dist/platform/control-plane/routes/automation.d.ts.map +0 -1
- package/dist/platform/control-plane/routes/automation.js +0 -63
- package/dist/platform/control-plane/routes/context.d.ts +0 -2
- package/dist/platform/control-plane/routes/context.d.ts.map +0 -1
- package/dist/platform/control-plane/routes/context.js +0 -1
- package/dist/platform/control-plane/routes/operator.d.ts +0 -8
- package/dist/platform/control-plane/routes/operator.d.ts.map +0 -1
- package/dist/platform/control-plane/routes/operator.js +0 -415
- package/dist/platform/control-plane/routes/remote.d.ts +0 -3
- package/dist/platform/control-plane/routes/remote.d.ts.map +0 -1
- package/dist/platform/control-plane/routes/remote.js +0 -35
- package/dist/platform/control-plane/routes/sessions.d.ts +0 -3
- package/dist/platform/control-plane/routes/sessions.d.ts.map +0 -1
- package/dist/platform/control-plane/routes/sessions.js +0 -43
- package/dist/platform/control-plane/routes/tasks.d.ts +0 -3
- package/dist/platform/control-plane/routes/tasks.d.ts.map +0 -1
- package/dist/platform/control-plane/routes/tasks.js +0 -22
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* calendar-api-shared.ts — the bearer-auth HTTP helper and honest degraded-state
|
|
3
|
+
* mapping shared by the Google Calendar and Microsoft Graph clients. Every failed
|
|
4
|
+
* response is turned into a NAMED ApiDegradedState (never a generic throw): a 401 is
|
|
5
|
+
* `reconnect-needed`, a 403 that names a missing scope is `insufficient-scope` naming
|
|
6
|
+
* that scope, a 429 is `rate-limited` carrying the honored Retry-After, everything
|
|
7
|
+
* else is `provider-error` with the status.
|
|
8
|
+
*/
|
|
9
|
+
/** A named, honest API failure. */
|
|
10
|
+
export class CalendarApiError extends Error {
|
|
11
|
+
degraded;
|
|
12
|
+
constructor(degraded) {
|
|
13
|
+
super(degraded.detail);
|
|
14
|
+
this.name = 'CalendarApiError';
|
|
15
|
+
this.degraded = degraded;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
function retryAfterMs(res) {
|
|
19
|
+
const header = res.header('retry-after');
|
|
20
|
+
if (!header)
|
|
21
|
+
return 1000;
|
|
22
|
+
const seconds = Number(header);
|
|
23
|
+
if (Number.isFinite(seconds))
|
|
24
|
+
return Math.max(0, seconds * 1000);
|
|
25
|
+
const when = Date.parse(header);
|
|
26
|
+
return Number.isFinite(when) ? Math.max(0, when - Date.now()) : 1000;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Best-effort extraction of the scope a 403 says is missing. Google returns it in
|
|
30
|
+
* the error message / details; Graph names it in the error message. When we cannot
|
|
31
|
+
* pin the exact scope, we say so honestly rather than invent one.
|
|
32
|
+
*/
|
|
33
|
+
function missingScopeFrom(bodyText, provider) {
|
|
34
|
+
const scopeMatch = /scope[s]?['"\s:=]+([A-Za-z0-9_.:/-]+)/i.exec(bodyText);
|
|
35
|
+
if (scopeMatch)
|
|
36
|
+
return scopeMatch[1];
|
|
37
|
+
const graphPerm = /(Calendars\.[A-Za-z]+)/.exec(bodyText);
|
|
38
|
+
if (graphPerm)
|
|
39
|
+
return graphPerm[1];
|
|
40
|
+
return provider === 'google'
|
|
41
|
+
? 'a Google Calendar scope not granted to this connection'
|
|
42
|
+
: 'a Microsoft Graph Calendars permission not granted to this connection';
|
|
43
|
+
}
|
|
44
|
+
/** Map a non-OK response to a CalendarApiError with a named degraded state. */
|
|
45
|
+
export async function errorFromResponse(res, provider) {
|
|
46
|
+
const bodyText = await res.text().catch(() => '');
|
|
47
|
+
if (res.status === 401) {
|
|
48
|
+
return new CalendarApiError({
|
|
49
|
+
kind: 'reconnect-needed',
|
|
50
|
+
detail: `${provider} rejected the access token (401). Reconnect the account.`,
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
if (res.status === 403) {
|
|
54
|
+
return new CalendarApiError({
|
|
55
|
+
kind: 'insufficient-scope',
|
|
56
|
+
missingScope: missingScopeFrom(bodyText, provider),
|
|
57
|
+
detail: `${provider} refused the request for lack of a granted scope (403).`,
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
if (res.status === 429) {
|
|
61
|
+
return new CalendarApiError({
|
|
62
|
+
kind: 'rate-limited',
|
|
63
|
+
retryAfterMs: retryAfterMs(res),
|
|
64
|
+
detail: `${provider} rate-limited the request (429).`,
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
return new CalendarApiError({
|
|
68
|
+
kind: 'provider-error',
|
|
69
|
+
status: res.status,
|
|
70
|
+
detail: `${provider} returned ${res.status}${bodyText ? `: ${bodyText.slice(0, 200)}` : ''}.`,
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
/** Issue a bearer-authorized request, throwing a CalendarApiError on failure. */
|
|
74
|
+
export async function authedRequest(fetchImpl, provider, input) {
|
|
75
|
+
const headers = {
|
|
76
|
+
Authorization: `Bearer ${input.token}`,
|
|
77
|
+
Accept: 'application/json',
|
|
78
|
+
...input.extraHeaders,
|
|
79
|
+
};
|
|
80
|
+
if (input.body !== undefined)
|
|
81
|
+
headers['Content-Type'] = 'application/json';
|
|
82
|
+
let res;
|
|
83
|
+
try {
|
|
84
|
+
res = await fetchImpl({
|
|
85
|
+
url: input.url,
|
|
86
|
+
method: input.method,
|
|
87
|
+
headers,
|
|
88
|
+
...(input.body !== undefined ? { body: JSON.stringify(input.body) } : {}),
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
catch (error) {
|
|
92
|
+
throw new CalendarApiError({
|
|
93
|
+
kind: 'network-error',
|
|
94
|
+
detail: `Reaching ${provider} failed: ${error instanceof Error ? error.message : String(error)}`,
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
if (!res.ok)
|
|
98
|
+
throw await errorFromResponse(res, provider);
|
|
99
|
+
return res.json();
|
|
100
|
+
}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* calendar-connector.ts — the high-level connector the agent drives. It ties the
|
|
3
|
+
* provider profiles, the OAuth flows, the secret-backed token store, and the two API
|
|
4
|
+
* clients into one surface: connect (auth-code or device-code), disconnect, list
|
|
5
|
+
* accounts + their honest state, list calendars, list events (normalized + source-
|
|
6
|
+
* labeled) across a window, and create an event routed to an explicitly chosen
|
|
7
|
+
* provider. The network and (for the loopback flow) the redirect listener are
|
|
8
|
+
* injected, so the whole thing runs against fakes with no real network or port.
|
|
9
|
+
*/
|
|
10
|
+
import { type Sleep } from './oauth-flow.js';
|
|
11
|
+
import type { AuthCodeFlowStart, CalendarProviderId, Clock, ConnectedAccount, ConnectionState, DeviceCodeFlowStart, HttpFetch, LoopbackListenerFactory, LoopbackWaiter, MergedCalendarEvent, NewCalendarEvent, OAuthClientOverrides, ProviderCalendar, ResolvedClientConfig, SecretStoreSlice } from './oauth-types.js';
|
|
12
|
+
export interface CalendarConnectorOptions {
|
|
13
|
+
readonly secrets: SecretStoreSlice;
|
|
14
|
+
readonly fetchImpl: HttpFetch;
|
|
15
|
+
readonly clock?: Clock;
|
|
16
|
+
/** Required only for the auth-code (loopback) flow; device-code needs no listener. */
|
|
17
|
+
readonly listenerFactory?: LoopbackListenerFactory;
|
|
18
|
+
/** Injected delay for device-code polling; defaults to a real timer. */
|
|
19
|
+
readonly sleep?: Sleep;
|
|
20
|
+
readonly refreshLeewayMs?: number;
|
|
21
|
+
}
|
|
22
|
+
/** A time window for event listing, as ISO strings. */
|
|
23
|
+
export interface EventWindow {
|
|
24
|
+
readonly timeMin: string;
|
|
25
|
+
readonly timeMax: string;
|
|
26
|
+
}
|
|
27
|
+
export declare class CalendarConnector {
|
|
28
|
+
private readonly secrets;
|
|
29
|
+
private readonly fetchImpl;
|
|
30
|
+
private readonly clock;
|
|
31
|
+
private readonly listenerFactory?;
|
|
32
|
+
private readonly sleep;
|
|
33
|
+
private readonly store;
|
|
34
|
+
constructor(options: CalendarConnectorOptions);
|
|
35
|
+
/** Resolve the client config for a provider (profile + optional user overrides). */
|
|
36
|
+
resolveConfig(provider: CalendarProviderId, overrides?: OAuthClientOverrides): ResolvedClientConfig;
|
|
37
|
+
listAccounts(): Promise<ConnectedAccount[]>;
|
|
38
|
+
connectionState(provider: CalendarProviderId): Promise<ConnectionState>;
|
|
39
|
+
/** Begin the loopback auth-code flow; returns the URL to open and the waiter. */
|
|
40
|
+
beginConnectAuthCode(config: ResolvedClientConfig): Promise<{
|
|
41
|
+
readonly start: AuthCodeFlowStart;
|
|
42
|
+
readonly waiter: LoopbackWaiter;
|
|
43
|
+
}>;
|
|
44
|
+
/** Complete the auth-code flow after the redirect delivered a code; saves tokens. */
|
|
45
|
+
completeConnectAuthCode(config: ResolvedClientConfig, input: {
|
|
46
|
+
readonly code: string;
|
|
47
|
+
readonly verifier: string;
|
|
48
|
+
readonly redirectUri: string;
|
|
49
|
+
}): Promise<ConnectedAccount>;
|
|
50
|
+
/** Begin the device-code flow; returns the user code + verification URL to show. */
|
|
51
|
+
beginConnectDeviceCode(config: ResolvedClientConfig): Promise<DeviceCodeFlowStart>;
|
|
52
|
+
/** Poll until the device code is approved, then save tokens. */
|
|
53
|
+
completeConnectDeviceCode(config: ResolvedClientConfig, start: DeviceCodeFlowStart): Promise<ConnectedAccount>;
|
|
54
|
+
disconnect(provider: CalendarProviderId, overrides?: OAuthClientOverrides): Promise<{
|
|
55
|
+
readonly revokedRemotely: boolean;
|
|
56
|
+
}>;
|
|
57
|
+
/** List the provider's calendars (refreshing the token first when due). */
|
|
58
|
+
listCalendars(config: ResolvedClientConfig): Promise<ProviderCalendar[]>;
|
|
59
|
+
/**
|
|
60
|
+
* List events across all of the provider's calendars in a window, normalized into
|
|
61
|
+
* the merged model, source-labeled, and sorted chronologically (through the ONE
|
|
62
|
+
* documented cross-zone comparator, `compareMergedCalendarEventsByStart` — see
|
|
63
|
+
* merged-calendar-model.ts for why a raw string/localeCompare sort of `start.value`
|
|
64
|
+
* is wrong once utc and tzid/floating events are mixed). Callers merge this with
|
|
65
|
+
* A9's ICS/local events into the unified /calendar view.
|
|
66
|
+
*/
|
|
67
|
+
listEvents(config: ResolvedClientConfig, window: EventWindow): Promise<MergedCalendarEvent[]>;
|
|
68
|
+
createEvent(config: ResolvedClientConfig, calendarId: string, calendarLabel: string, event: NewCalendarEvent): Promise<MergedCalendarEvent>;
|
|
69
|
+
/** Save tokens + a best-effort enriched account label, and return the account. */
|
|
70
|
+
private persistConnection;
|
|
71
|
+
/**
|
|
72
|
+
* Best-effort account label: the primary calendar id is the account email for
|
|
73
|
+
* Google, and the primary calendar's name is a reasonable Outlook label. A failure
|
|
74
|
+
* here must NOT fail the connection (the token is already valid), so it falls back
|
|
75
|
+
* to the provider display name.
|
|
76
|
+
*/
|
|
77
|
+
private deriveLabel;
|
|
78
|
+
}
|
|
79
|
+
//# sourceMappingURL=calendar-connector.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"calendar-connector.d.ts","sourceRoot":"","sources":["../../../src/platform/calendar/calendar-connector.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAKL,KAAK,KAAK,EACX,MAAM,iBAAiB,CAAC;AAczB,OAAO,KAAK,EACV,iBAAiB,EACjB,kBAAkB,EAClB,KAAK,EACL,gBAAgB,EAChB,eAAe,EACf,mBAAmB,EACnB,SAAS,EACT,uBAAuB,EACvB,cAAc,EACd,mBAAmB,EACnB,gBAAgB,EAChB,oBAAoB,EACpB,gBAAgB,EAChB,oBAAoB,EACpB,gBAAgB,EAEjB,MAAM,kBAAkB,CAAC;AAE1B,MAAM,WAAW,wBAAwB;IACvC,QAAQ,CAAC,OAAO,EAAE,gBAAgB,CAAC;IACnC,QAAQ,CAAC,SAAS,EAAE,SAAS,CAAC;IAC9B,QAAQ,CAAC,KAAK,CAAC,EAAE,KAAK,CAAC;IACvB,sFAAsF;IACtF,QAAQ,CAAC,eAAe,CAAC,EAAE,uBAAuB,CAAC;IACnD,wEAAwE;IACxE,QAAQ,CAAC,KAAK,CAAC,EAAE,KAAK,CAAC;IACvB,QAAQ,CAAC,eAAe,CAAC,EAAE,MAAM,CAAC;CACnC;AAED,uDAAuD;AACvD,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CAC1B;AAED,qBAAa,iBAAiB;IAC5B,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAmB;IAC3C,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAY;IACtC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAQ;IAC9B,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAC,CAA0B;IAC3D,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAQ;IAC9B,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAqB;gBAE/B,OAAO,EAAE,wBAAwB;IAc7C,oFAAoF;IACpF,aAAa,CAAC,QAAQ,EAAE,kBAAkB,EAAE,SAAS,CAAC,EAAE,oBAAoB,GAAG,oBAAoB;IAMnG,YAAY,IAAI,OAAO,CAAC,gBAAgB,EAAE,CAAC;IAI3C,eAAe,CAAC,QAAQ,EAAE,kBAAkB,GAAG,OAAO,CAAC,eAAe,CAAC;IAMvE,iFAAiF;IAC3E,oBAAoB,CACxB,MAAM,EAAE,oBAAoB,GAC3B,OAAO,CAAC;QAAE,QAAQ,CAAC,KAAK,EAAE,iBAAiB,CAAC;QAAC,QAAQ,CAAC,MAAM,EAAE,cAAc,CAAA;KAAE,CAAC;IAOlF,qFAAqF;IAC/E,uBAAuB,CAC3B,MAAM,EAAE,oBAAoB,EAC5B,KAAK,EAAE;QAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAA;KAAE,GACxF,OAAO,CAAC,gBAAgB,CAAC;IAO5B,oFAAoF;IACpF,sBAAsB,CAAC,MAAM,EAAE,oBAAoB,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAIlF,gEAAgE;IAC1D,yBAAyB,CAC7B,MAAM,EAAE,oBAAoB,EAC5B,KAAK,EAAE,mBAAmB,GACzB,OAAO,CAAC,gBAAgB,CAAC;IAO5B,UAAU,CACR,QAAQ,EAAE,kBAAkB,EAC5B,SAAS,CAAC,EAAE,oBAAoB,GAC/B,OAAO,CAAC;QAAE,QAAQ,CAAC,eAAe,EAAE,OAAO,CAAA;KAAE,CAAC;IAMjD,2EAA2E;IACrE,aAAa,CAAC,MAAM,EAAE,oBAAoB,GAAG,OAAO,CAAC,gBAAgB,EAAE,CAAC;IAO9E;;;;;;;OAOG;IACG,UAAU,CAAC,MAAM,EAAE,oBAAoB,EAAE,MAAM,EAAE,WAAW,GAAG,OAAO,CAAC,mBAAmB,EAAE,CAAC;IA2B7F,WAAW,CACf,MAAM,EAAE,oBAAoB,EAC5B,UAAU,EAAE,MAAM,EAClB,aAAa,EAAE,MAAM,EACrB,KAAK,EAAE,gBAAgB,GACtB,OAAO,CAAC,mBAAmB,CAAC;IAS/B,kFAAkF;YACpE,iBAAiB;IAY/B;;;;;OAKG;YACW,WAAW;CAY1B"}
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* calendar-connector.ts — the high-level connector the agent drives. It ties the
|
|
3
|
+
* provider profiles, the OAuth flows, the secret-backed token store, and the two API
|
|
4
|
+
* clients into one surface: connect (auth-code or device-code), disconnect, list
|
|
5
|
+
* accounts + their honest state, list calendars, list events (normalized + source-
|
|
6
|
+
* labeled) across a window, and create an event routed to an explicitly chosen
|
|
7
|
+
* provider. The network and (for the loopback flow) the redirect listener are
|
|
8
|
+
* injected, so the whole thing runs against fakes with no real network or port.
|
|
9
|
+
*/
|
|
10
|
+
import { beginAuthCodeFlow, beginDeviceCodeFlow, completeAuthCodeFlow, pollDeviceCodeFlow, } from './oauth-flow.js';
|
|
11
|
+
import { providerProfile, resolveClientConfig } from './oauth-providers.js';
|
|
12
|
+
import { CalendarTokenStore } from './oauth-token-store.js';
|
|
13
|
+
import { createGoogleEvent, listGoogleCalendars, listGoogleEvents, } from './google-calendar-api.js';
|
|
14
|
+
import { createGraphEvent, listGraphCalendars, listGraphEvents, } from './microsoft-graph-api.js';
|
|
15
|
+
import { compareMergedCalendarEventsByStart } from './merged-calendar-model.js';
|
|
16
|
+
export class CalendarConnector {
|
|
17
|
+
secrets;
|
|
18
|
+
fetchImpl;
|
|
19
|
+
clock;
|
|
20
|
+
listenerFactory;
|
|
21
|
+
sleep;
|
|
22
|
+
store;
|
|
23
|
+
constructor(options) {
|
|
24
|
+
this.secrets = options.secrets;
|
|
25
|
+
this.fetchImpl = options.fetchImpl;
|
|
26
|
+
this.clock = options.clock ?? (() => Date.now());
|
|
27
|
+
if (options.listenerFactory)
|
|
28
|
+
this.listenerFactory = options.listenerFactory;
|
|
29
|
+
this.sleep = options.sleep ?? ((ms) => new Promise((r) => setTimeout(r, ms)));
|
|
30
|
+
const storeOptions = {
|
|
31
|
+
secrets: options.secrets,
|
|
32
|
+
clock: this.clock,
|
|
33
|
+
...(typeof options.refreshLeewayMs === 'number' ? { refreshLeewayMs: options.refreshLeewayMs } : {}),
|
|
34
|
+
};
|
|
35
|
+
this.store = new CalendarTokenStore(storeOptions);
|
|
36
|
+
}
|
|
37
|
+
/** Resolve the client config for a provider (profile + optional user overrides). */
|
|
38
|
+
resolveConfig(provider, overrides) {
|
|
39
|
+
return resolveClientConfig(providerProfile(provider), overrides);
|
|
40
|
+
}
|
|
41
|
+
// --- Accounts / state -----------------------------------------------------
|
|
42
|
+
listAccounts() {
|
|
43
|
+
return this.store.listAccounts();
|
|
44
|
+
}
|
|
45
|
+
connectionState(provider) {
|
|
46
|
+
return this.store.connectionState(provider);
|
|
47
|
+
}
|
|
48
|
+
// --- Connect: authorization-code (loopback) flow --------------------------
|
|
49
|
+
/** Begin the loopback auth-code flow; returns the URL to open and the waiter. */
|
|
50
|
+
async beginConnectAuthCode(config) {
|
|
51
|
+
if (!this.listenerFactory) {
|
|
52
|
+
throw new Error('No loopback listener is available; use the device-code flow for headless connect.');
|
|
53
|
+
}
|
|
54
|
+
return beginAuthCodeFlow(config, this.listenerFactory);
|
|
55
|
+
}
|
|
56
|
+
/** Complete the auth-code flow after the redirect delivered a code; saves tokens. */
|
|
57
|
+
async completeConnectAuthCode(config, input) {
|
|
58
|
+
const tokens = await completeAuthCodeFlow(config, this.fetchImpl, input, this.clock());
|
|
59
|
+
return this.persistConnection(config, tokens);
|
|
60
|
+
}
|
|
61
|
+
// --- Connect: device-code (headless) flow ---------------------------------
|
|
62
|
+
/** Begin the device-code flow; returns the user code + verification URL to show. */
|
|
63
|
+
beginConnectDeviceCode(config) {
|
|
64
|
+
return beginDeviceCodeFlow(config, this.fetchImpl, this.clock());
|
|
65
|
+
}
|
|
66
|
+
/** Poll until the device code is approved, then save tokens. */
|
|
67
|
+
async completeConnectDeviceCode(config, start) {
|
|
68
|
+
const tokens = await pollDeviceCodeFlow(config, this.fetchImpl, start, this.clock, this.sleep);
|
|
69
|
+
return this.persistConnection(config, tokens);
|
|
70
|
+
}
|
|
71
|
+
// --- Disconnect -----------------------------------------------------------
|
|
72
|
+
disconnect(provider, overrides) {
|
|
73
|
+
return this.store.disconnect(provider, this.resolveConfig(provider, overrides), this.fetchImpl);
|
|
74
|
+
}
|
|
75
|
+
// --- Read: calendars + events ---------------------------------------------
|
|
76
|
+
/** List the provider's calendars (refreshing the token first when due). */
|
|
77
|
+
async listCalendars(config) {
|
|
78
|
+
const token = await this.store.getFreshAccessToken(config.provider, config, this.fetchImpl);
|
|
79
|
+
return config.provider === 'google'
|
|
80
|
+
? listGoogleCalendars(this.fetchImpl, token)
|
|
81
|
+
: listGraphCalendars(this.fetchImpl, token);
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* List events across all of the provider's calendars in a window, normalized into
|
|
85
|
+
* the merged model, source-labeled, and sorted chronologically (through the ONE
|
|
86
|
+
* documented cross-zone comparator, `compareMergedCalendarEventsByStart` — see
|
|
87
|
+
* merged-calendar-model.ts for why a raw string/localeCompare sort of `start.value`
|
|
88
|
+
* is wrong once utc and tzid/floating events are mixed). Callers merge this with
|
|
89
|
+
* A9's ICS/local events into the unified /calendar view.
|
|
90
|
+
*/
|
|
91
|
+
async listEvents(config, window) {
|
|
92
|
+
const token = await this.store.getFreshAccessToken(config.provider, config, this.fetchImpl);
|
|
93
|
+
const calendars = config.provider === 'google'
|
|
94
|
+
? await listGoogleCalendars(this.fetchImpl, token)
|
|
95
|
+
: await listGraphCalendars(this.fetchImpl, token);
|
|
96
|
+
const out = [];
|
|
97
|
+
for (const calendar of calendars) {
|
|
98
|
+
const events = config.provider === 'google'
|
|
99
|
+
? await listGoogleEvents(this.fetchImpl, token, {
|
|
100
|
+
calendarId: calendar.id,
|
|
101
|
+
calendarLabel: calendar.name,
|
|
102
|
+
timeMin: window.timeMin,
|
|
103
|
+
timeMax: window.timeMax,
|
|
104
|
+
})
|
|
105
|
+
: await listGraphEvents(this.fetchImpl, token, {
|
|
106
|
+
calendarId: calendar.id,
|
|
107
|
+
calendarLabel: calendar.name,
|
|
108
|
+
start: window.timeMin,
|
|
109
|
+
end: window.timeMax,
|
|
110
|
+
});
|
|
111
|
+
out.push(...events);
|
|
112
|
+
}
|
|
113
|
+
return [...out].sort(compareMergedCalendarEventsByStart);
|
|
114
|
+
}
|
|
115
|
+
// --- Write: create an event on an explicitly chosen provider --------------
|
|
116
|
+
async createEvent(config, calendarId, calendarLabel, event) {
|
|
117
|
+
const token = await this.store.getFreshAccessToken(config.provider, config, this.fetchImpl);
|
|
118
|
+
return config.provider === 'google'
|
|
119
|
+
? createGoogleEvent(this.fetchImpl, token, calendarId, calendarLabel, event)
|
|
120
|
+
: createGraphEvent(this.fetchImpl, token, calendarId, calendarLabel, event);
|
|
121
|
+
}
|
|
122
|
+
// --- internals ------------------------------------------------------------
|
|
123
|
+
/** Save tokens + a best-effort enriched account label, and return the account. */
|
|
124
|
+
async persistConnection(config, tokens) {
|
|
125
|
+
const account = {
|
|
126
|
+
provider: config.provider,
|
|
127
|
+
accountId: config.provider,
|
|
128
|
+
label: await this.deriveLabel(config, tokens),
|
|
129
|
+
scopes: tokens.scopes ?? config.scopes,
|
|
130
|
+
connectedAt: this.clock(),
|
|
131
|
+
};
|
|
132
|
+
await this.store.save(config.provider, tokens, account);
|
|
133
|
+
return account;
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Best-effort account label: the primary calendar id is the account email for
|
|
137
|
+
* Google, and the primary calendar's name is a reasonable Outlook label. A failure
|
|
138
|
+
* here must NOT fail the connection (the token is already valid), so it falls back
|
|
139
|
+
* to the provider display name.
|
|
140
|
+
*/
|
|
141
|
+
async deriveLabel(config, tokens) {
|
|
142
|
+
try {
|
|
143
|
+
const calendars = config.provider === 'google'
|
|
144
|
+
? await listGoogleCalendars(this.fetchImpl, tokens.accessToken)
|
|
145
|
+
: await listGraphCalendars(this.fetchImpl, tokens.accessToken);
|
|
146
|
+
const primary = calendars.find((c) => c.primary) ?? calendars[0];
|
|
147
|
+
if (primary)
|
|
148
|
+
return config.provider === 'google' ? primary.id : primary.name;
|
|
149
|
+
}
|
|
150
|
+
catch {
|
|
151
|
+
// fall through to the honest default
|
|
152
|
+
}
|
|
153
|
+
return config.provider === 'google' ? 'Google Calendar' : 'Microsoft Outlook';
|
|
154
|
+
}
|
|
155
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* google-calendar-api.ts — the Google Calendar API v3 client over an access token
|
|
3
|
+
* and the injected HttpFetch. Lists calendars (calendarList.list), lists events
|
|
4
|
+
* (events.list with timeMin/timeMax paging and singleEvents=true so instances are
|
|
5
|
+
* already expanded), and creates events (events.insert). Every event is normalized
|
|
6
|
+
* into the merged model; every failure is a named degraded state via CalendarApiError.
|
|
7
|
+
*/
|
|
8
|
+
import type { HttpFetch, MergedCalendarEvent, NewCalendarEvent, ProviderCalendar } from './oauth-types.js';
|
|
9
|
+
/** List the user's calendars. Write access is inferred from accessRole. */
|
|
10
|
+
export declare function listGoogleCalendars(fetchImpl: HttpFetch, token: string): Promise<ProviderCalendar[]>;
|
|
11
|
+
export interface GoogleEventsQuery {
|
|
12
|
+
readonly calendarId: string;
|
|
13
|
+
readonly calendarLabel: string;
|
|
14
|
+
/** RFC3339 lower bound (inclusive), e.g. '2026-07-01T00:00:00Z'. */
|
|
15
|
+
readonly timeMin: string;
|
|
16
|
+
/** RFC3339 upper bound (exclusive). */
|
|
17
|
+
readonly timeMax: string;
|
|
18
|
+
/** Page size cap per request; the client pages until exhausted. */
|
|
19
|
+
readonly pageSize?: number;
|
|
20
|
+
}
|
|
21
|
+
/** List events in a window, paging through every page. Instances are pre-expanded. */
|
|
22
|
+
export declare function listGoogleEvents(fetchImpl: HttpFetch, token: string, query: GoogleEventsQuery): Promise<MergedCalendarEvent[]>;
|
|
23
|
+
/** Insert a new event; returns it normalized into the merged model. */
|
|
24
|
+
export declare function createGoogleEvent(fetchImpl: HttpFetch, token: string, calendarId: string, calendarLabel: string, event: NewCalendarEvent): Promise<MergedCalendarEvent>;
|
|
25
|
+
//# sourceMappingURL=google-calendar-api.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"google-calendar-api.d.ts","sourceRoot":"","sources":["../../../src/platform/calendar/google-calendar-api.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAKH,OAAO,KAAK,EAAE,SAAS,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAI3G,2EAA2E;AAC3E,wBAAsB,mBAAmB,CAAC,SAAS,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,EAAE,CAAC,CA0B1G;AAED,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,oEAAoE;IACpE,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,uCAAuC;IACvC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,mEAAmE;IACnE,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;CAC5B;AAED,sFAAsF;AACtF,wBAAsB,gBAAgB,CACpC,SAAS,EAAE,SAAS,EACpB,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,iBAAiB,GACvB,OAAO,CAAC,mBAAmB,EAAE,CAAC,CAwBhC;AAED,uEAAuE;AACvE,wBAAsB,iBAAiB,CACrC,SAAS,EAAE,SAAS,EACpB,KAAK,EAAE,MAAM,EACb,UAAU,EAAE,MAAM,EAClB,aAAa,EAAE,MAAM,EACrB,KAAK,EAAE,gBAAgB,GACtB,OAAO,CAAC,mBAAmB,CAAC,CAa9B"}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* google-calendar-api.ts — the Google Calendar API v3 client over an access token
|
|
3
|
+
* and the injected HttpFetch. Lists calendars (calendarList.list), lists events
|
|
4
|
+
* (events.list with timeMin/timeMax paging and singleEvents=true so instances are
|
|
5
|
+
* already expanded), and creates events (events.insert). Every event is normalized
|
|
6
|
+
* into the merged model; every failure is a named degraded state via CalendarApiError.
|
|
7
|
+
*/
|
|
8
|
+
import { authedRequest } from './calendar-api-shared.js';
|
|
9
|
+
import { normalizeGoogleEvent } from './merged-calendar-model.js';
|
|
10
|
+
const BASE = 'https://www.googleapis.com/calendar/v3';
|
|
11
|
+
/** List the user's calendars. Write access is inferred from accessRole. */
|
|
12
|
+
export async function listGoogleCalendars(fetchImpl, token) {
|
|
13
|
+
const out = [];
|
|
14
|
+
let pageToken;
|
|
15
|
+
do {
|
|
16
|
+
const url = new URL(`${BASE}/users/me/calendarList`);
|
|
17
|
+
url.searchParams.set('maxResults', '250');
|
|
18
|
+
if (pageToken)
|
|
19
|
+
url.searchParams.set('pageToken', pageToken);
|
|
20
|
+
const body = (await authedRequest(fetchImpl, 'google', { url: url.toString(), method: 'GET', token }));
|
|
21
|
+
for (const raw of body.items ?? []) {
|
|
22
|
+
const item = (raw ?? {});
|
|
23
|
+
if (typeof item.id !== 'string')
|
|
24
|
+
continue;
|
|
25
|
+
const accessRole = typeof item.accessRole === 'string' ? item.accessRole : 'reader';
|
|
26
|
+
out.push({
|
|
27
|
+
id: item.id,
|
|
28
|
+
name: typeof item.summary === 'string' ? item.summary : item.id,
|
|
29
|
+
provider: 'google',
|
|
30
|
+
...(item.primary === true ? { primary: true } : {}),
|
|
31
|
+
canWrite: accessRole === 'owner' || accessRole === 'writer',
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
pageToken = typeof body.nextPageToken === 'string' ? body.nextPageToken : undefined;
|
|
35
|
+
} while (pageToken);
|
|
36
|
+
return out;
|
|
37
|
+
}
|
|
38
|
+
/** List events in a window, paging through every page. Instances are pre-expanded. */
|
|
39
|
+
export async function listGoogleEvents(fetchImpl, token, query) {
|
|
40
|
+
const out = [];
|
|
41
|
+
let pageToken;
|
|
42
|
+
do {
|
|
43
|
+
const url = new URL(`${BASE}/calendars/${encodeURIComponent(query.calendarId)}/events`);
|
|
44
|
+
url.searchParams.set('timeMin', query.timeMin);
|
|
45
|
+
url.searchParams.set('timeMax', query.timeMax);
|
|
46
|
+
url.searchParams.set('singleEvents', 'true');
|
|
47
|
+
url.searchParams.set('orderBy', 'startTime');
|
|
48
|
+
url.searchParams.set('maxResults', String(query.pageSize ?? 250));
|
|
49
|
+
if (pageToken)
|
|
50
|
+
url.searchParams.set('pageToken', pageToken);
|
|
51
|
+
const body = (await authedRequest(fetchImpl, 'google', { url: url.toString(), method: 'GET', token }));
|
|
52
|
+
for (const raw of body.items ?? []) {
|
|
53
|
+
const status = raw.status;
|
|
54
|
+
if (status === 'cancelled')
|
|
55
|
+
continue;
|
|
56
|
+
const event = normalizeGoogleEvent(raw, query.calendarId, query.calendarLabel);
|
|
57
|
+
if (event)
|
|
58
|
+
out.push(event);
|
|
59
|
+
}
|
|
60
|
+
pageToken = typeof body.nextPageToken === 'string' ? body.nextPageToken : undefined;
|
|
61
|
+
} while (pageToken);
|
|
62
|
+
return out;
|
|
63
|
+
}
|
|
64
|
+
/** Insert a new event; returns it normalized into the merged model. */
|
|
65
|
+
export async function createGoogleEvent(fetchImpl, token, calendarId, calendarLabel, event) {
|
|
66
|
+
const payload = {
|
|
67
|
+
summary: event.summary,
|
|
68
|
+
start: googleEventDate(event.start),
|
|
69
|
+
...(event.end ? { end: googleEventDate(event.end) } : {}),
|
|
70
|
+
...(event.location ? { location: event.location } : {}),
|
|
71
|
+
...(event.description ? { description: event.description } : {}),
|
|
72
|
+
};
|
|
73
|
+
const url = `${BASE}/calendars/${encodeURIComponent(calendarId)}/events`;
|
|
74
|
+
const created = await authedRequest(fetchImpl, 'google', { url, method: 'POST', token, body: payload });
|
|
75
|
+
const normalized = normalizeGoogleEvent(created, calendarId, calendarLabel);
|
|
76
|
+
if (!normalized)
|
|
77
|
+
throw new Error('Google accepted the event but returned an unreadable body.');
|
|
78
|
+
return normalized;
|
|
79
|
+
}
|
|
80
|
+
/** Map an EventDateTime to a Google event start/end object. */
|
|
81
|
+
function googleEventDate(dt) {
|
|
82
|
+
if (dt.kind === 'date')
|
|
83
|
+
return { date: dt.value };
|
|
84
|
+
if (dt.zone === 'tzid' && dt.tzid)
|
|
85
|
+
return { dateTime: dt.value, timeZone: dt.tzid };
|
|
86
|
+
// utc or floating: send an explicit UTC anchor so Google does not guess.
|
|
87
|
+
const iso = dt.value.endsWith('Z') ? dt.value : `${dt.value}Z`;
|
|
88
|
+
return { dateTime: iso, timeZone: 'UTC' };
|
|
89
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* http-fetch-adapter.ts — a pure adapter turning a standard WHATWG `fetch` into the
|
|
3
|
+
* connector's injected HttpFetch boundary. This module references only the global
|
|
4
|
+
* fetch/Response (no node:*), so it stays within the calendar module's purity
|
|
5
|
+
* contract; the actual `fetch` used is supplied by the caller (the agent passes the
|
|
6
|
+
* runtime fetch, tests pass a fake server's fetch).
|
|
7
|
+
*/
|
|
8
|
+
import type { HttpFetch } from './oauth-types.js';
|
|
9
|
+
type FetchLike = (url: string, init?: {
|
|
10
|
+
method?: string;
|
|
11
|
+
headers?: Record<string, string>;
|
|
12
|
+
body?: string;
|
|
13
|
+
}) => Promise<{
|
|
14
|
+
status: number;
|
|
15
|
+
ok: boolean;
|
|
16
|
+
headers: {
|
|
17
|
+
get(name: string): string | null;
|
|
18
|
+
};
|
|
19
|
+
json(): Promise<unknown>;
|
|
20
|
+
text(): Promise<string>;
|
|
21
|
+
}>;
|
|
22
|
+
/** Wrap a WHATWG-style fetch into an HttpFetch. Defaults to the global fetch. */
|
|
23
|
+
export declare function fetchAdapter(fetchImpl?: FetchLike): HttpFetch;
|
|
24
|
+
export {};
|
|
25
|
+
//# sourceMappingURL=http-fetch-adapter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http-fetch-adapter.d.ts","sourceRoot":"","sources":["../../../src/platform/calendar/http-fetch-adapter.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,SAAS,EAA6B,MAAM,kBAAkB,CAAC;AAE7E,KAAK,SAAS,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE;IACpC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,KAAK,OAAO,CAAC;IACZ,MAAM,EAAE,MAAM,CAAC;IACf,EAAE,EAAE,OAAO,CAAC;IACZ,OAAO,EAAE;QAAE,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAA;KAAE,CAAC;IAC9C,IAAI,IAAI,OAAO,CAAC,OAAO,CAAC,CAAC;IACzB,IAAI,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC;CACzB,CAAC,CAAC;AAEH,iFAAiF;AACjF,wBAAgB,YAAY,CAAC,SAAS,CAAC,EAAE,SAAS,GAAG,SAAS,CAgB7D"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* http-fetch-adapter.ts — a pure adapter turning a standard WHATWG `fetch` into the
|
|
3
|
+
* connector's injected HttpFetch boundary. This module references only the global
|
|
4
|
+
* fetch/Response (no node:*), so it stays within the calendar module's purity
|
|
5
|
+
* contract; the actual `fetch` used is supplied by the caller (the agent passes the
|
|
6
|
+
* runtime fetch, tests pass a fake server's fetch).
|
|
7
|
+
*/
|
|
8
|
+
/** Wrap a WHATWG-style fetch into an HttpFetch. Defaults to the global fetch. */
|
|
9
|
+
export function fetchAdapter(fetchImpl) {
|
|
10
|
+
const impl = fetchImpl ?? (globalThis.fetch);
|
|
11
|
+
return async (req) => {
|
|
12
|
+
const res = await impl(req.url, {
|
|
13
|
+
method: req.method,
|
|
14
|
+
...(req.headers ? { headers: { ...req.headers } } : {}),
|
|
15
|
+
...(req.body !== undefined ? { body: req.body } : {}),
|
|
16
|
+
});
|
|
17
|
+
return {
|
|
18
|
+
status: res.status,
|
|
19
|
+
ok: res.ok,
|
|
20
|
+
header: (name) => res.headers.get(name),
|
|
21
|
+
json: () => res.json(),
|
|
22
|
+
text: () => res.text(),
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ics-parser.ts — a pure, dependency-free iCalendar (RFC 5545) reader.
|
|
3
|
+
*
|
|
4
|
+
* Vendored on purpose. The SDK's `packages/sdk` ships ZERO third-party runtime
|
|
5
|
+
* dependencies (workspace packages only — see packages/sdk/package.json), and it
|
|
6
|
+
* guards that with bundle-budget / browser-compat / no-any gates. Pulling a general
|
|
7
|
+
* ICS library in for the read-focused subset we actually need would break that
|
|
8
|
+
* convention for little gain; this focused reader matches repo style and is easy to
|
|
9
|
+
* hold honest. See the decision record for the vendored-vs-dependency ruling and the
|
|
10
|
+
* exact supported subset.
|
|
11
|
+
*
|
|
12
|
+
* Scope of what this reads (documented, not faked):
|
|
13
|
+
* - VCALENDAR framing, X-WR-CALNAME for a calendar display name.
|
|
14
|
+
* - VEVENT: UID, SUMMARY, LOCATION, DESCRIPTION, DTSTART, DTEND, RRULE.
|
|
15
|
+
* - DTSTART/DTEND as VALUE=DATE ('YYYYMMDD') or date-time ('YYYYMMDDTHHMMSS'),
|
|
16
|
+
* with honest zone anchoring: trailing 'Z' => utc; TZID=... => tzid (wall time
|
|
17
|
+
* kept, NOT offset-converted, because this build has no tz database); otherwise
|
|
18
|
+
* floating. RRULE is captured raw and handed to the recurrence expander.
|
|
19
|
+
* - RFC 5545 line unfolding (a leading space/tab continues the previous line) and
|
|
20
|
+
* TEXT unescaping (\\n \\, \\; \\, \\\\).
|
|
21
|
+
*
|
|
22
|
+
* Everything unrecognised is ignored quietly EXCEPT the two things a caller must be
|
|
23
|
+
* told about: a VEVENT with no usable DTSTART is `skipped` with a reason, and an
|
|
24
|
+
* RRULE we do not fully expand is flagged on the event (in rrule.ts) — never dropped.
|
|
25
|
+
*
|
|
26
|
+
* PURE: no fs, no network, no process globals. Input is text; output is data.
|
|
27
|
+
*/
|
|
28
|
+
import type { ParsedCalendar } from './types.js';
|
|
29
|
+
/**
|
|
30
|
+
* Parse .ics text into typed events plus honest skip/diagnostic lists.
|
|
31
|
+
*
|
|
32
|
+
* @param text raw .ics content (file body or fetched feed body).
|
|
33
|
+
*/
|
|
34
|
+
export declare function parseIcs(text: string): ParsedCalendar;
|
|
35
|
+
//# sourceMappingURL=ics-parser.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ics-parser.d.ts","sourceRoot":"","sources":["../../../src/platform/calendar/ics-parser.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,OAAO,KAAK,EAIV,cAAc,EACf,MAAM,YAAY,CAAC;AA2HpB;;;;GAIG;AACH,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,cAAc,CA6ErD"}
|