nova-personal-agent-server 0.0.0-stage → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -0
- package/README.md +30 -2
- package/bin/novapersonal-server.mjs +4 -0
- package/package.json +61 -4
- package/resources/endpointing/volcengine-v1/LICENSE.silero-vad.txt +21 -0
- package/resources/endpointing/volcengine-v1/MANIFEST.json +31 -0
- package/resources/endpointing/volcengine-v1/silence-16k-s16le.pcm +0 -0
- package/resources/endpointing/volcengine-v1/speech-16k-s16le.pcm +0 -0
- package/resources/native/codex-sandbox-probe +0 -0
- package/resources/native/project-native/nova_project_native.node +0 -0
- package/resources/native-resources-v1.json +1 -0
- package/runtime/dist/eval/demos.js +156 -0
- package/runtime/dist/eval/fixture-host.js +385 -0
- package/runtime/dist/eval/fixtures.js +319 -0
- package/runtime/dist/eval/realtime/session-fixtures.js +474 -0
- package/runtime/dist/eval/scorecard.js +285 -0
- package/runtime/dist/eval/sim.js +43 -0
- package/runtime/dist/src/cascaded-text-provider.js +31 -0
- package/runtime/dist/src/cli.js +96 -0
- package/runtime/dist/src/composition/assembly.js +352 -0
- package/runtime/dist/src/composition/cascaded-realtime-assembly.js +455 -0
- package/runtime/dist/src/composition/production-composition.js +389 -0
- package/runtime/dist/src/composition/realtime-assembly.js +1330 -0
- package/runtime/dist/src/config/capability-registry.js +315 -0
- package/runtime/dist/src/config/cascaded-realtime-config.js +146 -0
- package/runtime/dist/src/config/coding-backends.js +8 -0
- package/runtime/dist/src/config/coding-profiles.js +98 -0
- package/runtime/dist/src/config/config.js +857 -0
- package/runtime/dist/src/config/diagnostics.js +139 -0
- package/runtime/dist/src/config/environment-contract.js +202 -0
- package/runtime/dist/src/config/self-hosted.js +23 -0
- package/runtime/dist/src/connectors/composio/client.js +195 -0
- package/runtime/dist/src/connectors/composio/google.js +208 -0
- package/runtime/dist/src/connectors/composio/index.js +334 -0
- package/runtime/dist/src/connectors/feishu/cli.js +220 -0
- package/runtime/dist/src/connectors/feishu/index.js +980 -0
- package/runtime/dist/src/connectors/macos/calendar.js +35 -0
- package/runtime/dist/src/connectors/macos/mail.js +32 -0
- package/runtime/dist/src/connectors/macos/reader.js +62 -0
- package/runtime/dist/src/conversation-voice-provider.js +41 -0
- package/runtime/dist/src/core/approval-port.js +9 -0
- package/runtime/dist/src/core/approval.js +1328 -0
- package/runtime/dist/src/core/calls.js +35 -0
- package/runtime/dist/src/core/camera-session.js +32 -0
- package/runtime/dist/src/core/causal-runtime.js +650 -0
- package/runtime/dist/src/core/clock.js +139 -0
- package/runtime/dist/src/core/context-view.js +156 -0
- package/runtime/dist/src/core/effects.js +62 -0
- package/runtime/dist/src/core/events.js +217 -0
- package/runtime/dist/src/core/executor-diagnostic.js +9 -0
- package/runtime/dist/src/core/ids.js +32 -0
- package/runtime/dist/src/core/media-store.js +104 -0
- package/runtime/dist/src/core/memory.js +296 -0
- package/runtime/dist/src/core/pending-decision.js +64 -0
- package/runtime/dist/src/core/ports.js +125 -0
- package/runtime/dist/src/core/runtime.js +1459 -0
- package/runtime/dist/src/core/schedule-tools.js +15 -0
- package/runtime/dist/src/core/sims.js +186 -0
- package/runtime/dist/src/core/slots.js +97 -0
- package/runtime/dist/src/core/source-processing-instructions.js +3 -0
- package/runtime/dist/src/core/source-processing-tools.js +12 -0
- package/runtime/dist/src/core/suggestions.js +143 -0
- package/runtime/dist/src/core/task-tools.js +22 -0
- package/runtime/dist/src/core/tool-schema.js +212 -0
- package/runtime/dist/src/core/trace.js +34 -0
- package/runtime/dist/src/core/work-tools.js +94 -0
- package/runtime/dist/src/desktop/desktop-camera-source.js +31 -0
- package/runtime/dist/src/desktop/desktop-camera.js +281 -0
- package/runtime/dist/src/desktop/desktop-control.js +140 -0
- package/runtime/dist/src/desktop/desktop-progress.js +162 -0
- package/runtime/dist/src/desktop/desktop-session.js +2106 -0
- package/runtime/dist/src/desktop/desktop-tasks.js +80 -0
- package/runtime/dist/src/desktop/desktop-wire.js +605 -0
- package/runtime/dist/src/desktop/phone-desktop-entry.js +17 -0
- package/runtime/dist/src/desktop/startup-error.js +18 -0
- package/runtime/dist/src/desktop/workbench-acceptance.js +262 -0
- package/runtime/dist/src/desktop-entry.js +106 -0
- package/runtime/dist/src/desktop.js +1092 -0
- package/runtime/dist/src/executors/acp/backends.js +105 -0
- package/runtime/dist/src/executors/acp/mcp.js +81 -0
- package/runtime/dist/src/executors/acp/preflight.js +14 -0
- package/runtime/dist/src/executors/acp/process-owner.js +112 -0
- package/runtime/dist/src/executors/acp/transport.js +760 -0
- package/runtime/dist/src/executors/acp/windows-launch.js +68 -0
- package/runtime/dist/src/executors/agent-controller.js +244 -0
- package/runtime/dist/src/executors/autoglm.js +376 -0
- package/runtime/dist/src/executors/browser-device.js +102 -0
- package/runtime/dist/src/executors/browser.js +61 -0
- package/runtime/dist/src/executors/camera.js +101 -0
- package/runtime/dist/src/executors/chromium-frame-source.js +173 -0
- package/runtime/dist/src/executors/codex/adapter-live.js +292 -0
- package/runtime/dist/src/executors/codex/adapter-project.js +1306 -0
- package/runtime/dist/src/executors/codex/app-server-schema.js +712 -0
- package/runtime/dist/src/executors/codex/app-server-transport.js +1798 -0
- package/runtime/dist/src/executors/codex/approval-protocol.js +439 -0
- package/runtime/dist/src/executors/codex/common.js +655 -0
- package/runtime/dist/src/executors/codex/contract.js +581 -0
- package/runtime/dist/src/executors/codex/controller.js +141 -0
- package/runtime/dist/src/executors/codex/credential-snapshot.js +195 -0
- package/runtime/dist/src/executors/codex/factory.js +463 -0
- package/runtime/dist/src/executors/codex/host-config.js +238 -0
- package/runtime/dist/src/executors/codex/host.js +17 -0
- package/runtime/dist/src/executors/codex/index.js +19 -0
- package/runtime/dist/src/executors/codex/launch-profile.js +37 -0
- package/runtime/dist/src/executors/codex/local-sessions.js +119 -0
- package/runtime/dist/src/executors/codex/managed-mcp.js +196 -0
- package/runtime/dist/src/executors/codex/process-owner.js +398 -0
- package/runtime/dist/src/executors/codex/production-host.js +887 -0
- package/runtime/dist/src/executors/codex/progress-instructions.js +10 -0
- package/runtime/dist/src/executors/codex/protocol.js +581 -0
- package/runtime/dist/src/executors/codex/safe-json.js +87 -0
- package/runtime/dist/src/executors/codex/session-title.js +61 -0
- package/runtime/dist/src/executors/codex/shared-home.js +29 -0
- package/runtime/dist/src/executors/codex/spawn-env.js +162 -0
- package/runtime/dist/src/executors/codex/turn-projection.js +435 -0
- package/runtime/dist/src/executors/codex/version.js +38 -0
- package/runtime/dist/src/executors/codex/windows-guardian.js +716 -0
- package/runtime/dist/src/executors/coding/intake-model.js +103 -0
- package/runtime/dist/src/executors/coding/intake.js +824 -0
- package/runtime/dist/src/executors/coding/json-completion.js +14 -0
- package/runtime/dist/src/executors/coding/target-resolution.js +61 -0
- package/runtime/dist/src/executors/coding/work-order.js +50 -0
- package/runtime/dist/src/executors/coding-executor.js +23 -0
- package/runtime/dist/src/executors/computer-backend.js +188 -0
- package/runtime/dist/src/executors/computer-device.js +187 -0
- package/runtime/dist/src/executors/computer-worker.js +125 -0
- package/runtime/dist/src/executors/computer.js +100 -0
- package/runtime/dist/src/executors/device-lock.js +127 -0
- package/runtime/dist/src/executors/frame-source.js +29 -0
- package/runtime/dist/src/executors/gui-evidence.js +30 -0
- package/runtime/dist/src/executors/gui-execution.js +237 -0
- package/runtime/dist/src/executors/gui-runner.js +88 -0
- package/runtime/dist/src/executors/host-executor-capability.js +12 -0
- package/runtime/dist/src/executors/index.js +13 -0
- package/runtime/dist/src/executors/mcp-client.js +198 -0
- package/runtime/dist/src/executors/mcp.js +210 -0
- package/runtime/dist/src/executors/mobile-android.js +180 -0
- package/runtime/dist/src/executors/mobile-ios.js +303 -0
- package/runtime/dist/src/executors/mobile.js +78 -0
- package/runtime/dist/src/executors/search-mcp.js +146 -0
- package/runtime/dist/src/executors/search.js +524 -0
- package/runtime/dist/src/executors/task-resources.js +38 -0
- package/runtime/dist/src/executors/vision/assess.js +296 -0
- package/runtime/dist/src/executors/vision/controller-core.js +373 -0
- package/runtime/dist/src/executors/vision/controller.js +164 -0
- package/runtime/dist/src/executors/vision/lifecycle.js +69 -0
- package/runtime/dist/src/executors/vision.js +5 -0
- package/runtime/dist/src/executors/watcher.js +718 -0
- package/runtime/dist/src/http/bounded-response.js +37 -0
- package/runtime/dist/src/index.js +56 -0
- package/runtime/dist/src/knowledge/assembly.js +60 -0
- package/runtime/dist/src/knowledge/documents.js +520 -0
- package/runtime/dist/src/knowledge/embeddings.js +201 -0
- package/runtime/dist/src/knowledge/mcp.js +218 -0
- package/runtime/dist/src/knowledge/parse-worker.js +122 -0
- package/runtime/dist/src/knowledge/references.js +51 -0
- package/runtime/dist/src/knowledge/service.js +526 -0
- package/runtime/dist/src/knowledge/store-client.js +185 -0
- package/runtime/dist/src/knowledge/store-worker.js +843 -0
- package/runtime/dist/src/knowledge/types.js +2 -0
- package/runtime/dist/src/mcp/http-server.js +177 -0
- package/runtime/dist/src/mem0/resource.js +35 -0
- package/runtime/dist/src/mem0/store-worker.js +330 -0
- package/runtime/dist/src/memory/blackboard-session.js +205 -0
- package/runtime/dist/src/memory/blackboard-store.js +194 -0
- package/runtime/dist/src/memory/blackboard-worker.js +369 -0
- package/runtime/dist/src/memory/entry.js +39 -0
- package/runtime/dist/src/memory/factory.js +20 -0
- package/runtime/dist/src/memory/personal-memory-inspection.js +18 -0
- package/runtime/dist/src/memory/personal-memory.js +10 -0
- package/runtime/dist/src/memory/prerecall.js +20 -0
- package/runtime/dist/src/memory/provenance.js +17 -0
- package/runtime/dist/src/memory/remote-personal-memory.js +194 -0
- package/runtime/dist/src/memory/retrieval.js +235 -0
- package/runtime/dist/src/memory/sensitivity.js +261 -0
- package/runtime/dist/src/memory-ledger/models.js +98 -0
- package/runtime/dist/src/memory-ledger/store-client.js +210 -0
- package/runtime/dist/src/memory-ledger/store-worker.js +130 -0
- package/runtime/dist/src/memory-ledger/store.js +597 -0
- package/runtime/dist/src/memory-substrate/candidates.js +16 -0
- package/runtime/dist/src/memory-substrate/consolidation.js +124 -0
- package/runtime/dist/src/memory-substrate/file-authority.js +111 -0
- package/runtime/dist/src/memory-substrate/life-operations.js +280 -0
- package/runtime/dist/src/memory-substrate/markdown-repository.js +610 -0
- package/runtime/dist/src/memory-substrate/migration.js +87 -0
- package/runtime/dist/src/memory-substrate/profile-source-input.js +9 -0
- package/runtime/dist/src/memory-substrate/purge.js +398 -0
- package/runtime/dist/src/memory-substrate/resolution.js +32 -0
- package/runtime/dist/src/memory-substrate/resource.js +867 -0
- package/runtime/dist/src/memory-substrate/retrieval.js +85 -0
- package/runtime/dist/src/memory-substrate/source-operations.js +306 -0
- package/runtime/dist/src/memory-substrate/source-processing.js +326 -0
- package/runtime/dist/src/memory-substrate/source-state.js +93 -0
- package/runtime/dist/src/memory-substrate/store.js +534 -0
- package/runtime/dist/src/memory-substrate/workspace-projections.js +106 -0
- package/runtime/dist/src/memory-substrate/workspace.js +21 -0
- package/runtime/dist/src/model/jev-client.js +25 -0
- package/runtime/dist/src/model/model-adapters.js +64 -0
- package/runtime/dist/src/model/model-gateway.js +399 -0
- package/runtime/dist/src/model/model-lane.js +34 -0
- package/runtime/dist/src/model/model-purpose.js +5 -0
- package/runtime/dist/src/model/personal-writer.js +361 -0
- package/runtime/dist/src/model/proactivity.js +72 -0
- package/runtime/dist/src/model/prompting.js +279 -0
- package/runtime/dist/src/model/task-verifier.js +217 -0
- package/runtime/dist/src/model/vision-capability.js +10 -0
- package/runtime/dist/src/news/feeds.js +114 -0
- package/runtime/dist/src/news/jev-ranking.js +25 -0
- package/runtime/dist/src/news/ranking.js +26 -0
- package/runtime/dist/src/news/service.js +262 -0
- package/runtime/dist/src/notifications/adapters/feishu.js +10 -0
- package/runtime/dist/src/notifications/adapters/nova.js +15 -0
- package/runtime/dist/src/notifications/content.js +15 -0
- package/runtime/dist/src/notifications/contracts.js +9 -0
- package/runtime/dist/src/notifications/feed.js +8 -0
- package/runtime/dist/src/notifications/service.js +412 -0
- package/runtime/dist/src/notifications/store.js +4 -0
- package/runtime/dist/src/personal-agent/app-context.js +113 -0
- package/runtime/dist/src/personal-agent/approval-scope.js +8 -0
- package/runtime/dist/src/personal-agent/coding-targets.js +82 -0
- package/runtime/dist/src/personal-agent/context-candidates.js +94 -0
- package/runtime/dist/src/personal-agent/contracts.js +32 -0
- package/runtime/dist/src/personal-agent/conversation-runtime.js +536 -0
- package/runtime/dist/src/personal-agent/conversations.js +187 -0
- package/runtime/dist/src/personal-agent/daily-brief.js +53 -0
- package/runtime/dist/src/personal-agent/host.js +2403 -0
- package/runtime/dist/src/personal-agent/intake-task.js +37 -0
- package/runtime/dist/src/personal-agent/life.js +260 -0
- package/runtime/dist/src/personal-agent/memory-overview.js +19 -0
- package/runtime/dist/src/personal-agent/profile-sources.js +34 -0
- package/runtime/dist/src/personal-agent/profile-warmup.js +244 -0
- package/runtime/dist/src/personal-agent/project-digests.js +242 -0
- package/runtime/dist/src/personal-agent/sampling.js +20 -0
- package/runtime/dist/src/personal-agent/schedule-agent.js +60 -0
- package/runtime/dist/src/personal-agent/schedule-api.js +61 -0
- package/runtime/dist/src/personal-agent/schedule-presets.js +13 -0
- package/runtime/dist/src/personal-agent/schedule-reference.js +3 -0
- package/runtime/dist/src/personal-agent/scheduled-response-scope.js +38 -0
- package/runtime/dist/src/personal-agent/scheduled-run-authority.js +44 -0
- package/runtime/dist/src/personal-agent/scheduled-tasks.js +280 -0
- package/runtime/dist/src/personal-agent/scheduled-time.js +99 -0
- package/runtime/dist/src/personal-agent/scheduled-tool-runtime.js +109 -0
- package/runtime/dist/src/personal-agent/source-priority.js +142 -0
- package/runtime/dist/src/personal-agent/source-processing-agent.js +158 -0
- package/runtime/dist/src/personal-agent/source-walk.js +25 -0
- package/runtime/dist/src/personal-agent/sources.js +1484 -0
- package/runtime/dist/src/personal-agent/store-lock-worker.js +17 -0
- package/runtime/dist/src/personal-agent/store.js +146 -0
- package/runtime/dist/src/personal-agent/task-loop.js +163 -0
- package/runtime/dist/src/personal-agent/tasks.js +920 -0
- package/runtime/dist/src/personal-agent/turn-deadline.js +55 -0
- package/runtime/dist/src/personal-agent/understanding.js +160 -0
- package/runtime/dist/src/personal-agent/workbench-context.js +239 -0
- package/runtime/dist/src/projects/confirmed-project-capability.js +60 -0
- package/runtime/dist/src/projects/host-paths.js +133 -0
- package/runtime/dist/src/projects/managed-workspace-maintenance.js +351 -0
- package/runtime/dist/src/projects/project-confirmation.js +486 -0
- package/runtime/dist/src/projects/project-native-resource.js +284 -0
- package/runtime/dist/src/projects/project-node-files.js +169 -0
- package/runtime/dist/src/projects/project-root-file.js +16 -0
- package/runtime/dist/src/projects/project-state.js +504 -0
- package/runtime/dist/src/projects/project-store-files.js +1271 -0
- package/runtime/dist/src/projects/project-store.js +1345 -0
- package/runtime/dist/src/realtime/aoq.js +141 -0
- package/runtime/dist/src/realtime/bridge.js +652 -0
- package/runtime/dist/src/realtime/cascaded/adapter.js +1669 -0
- package/runtime/dist/src/realtime/cascaded/ark-llm.js +219 -0
- package/runtime/dist/src/realtime/cascaded/chat-completions-llm.js +478 -0
- package/runtime/dist/src/realtime/cascaded/gemini-speech.js +232 -0
- package/runtime/dist/src/realtime/cascaded/llm.js +37 -0
- package/runtime/dist/src/realtime/cascaded/ports.js +2 -0
- package/runtime/dist/src/realtime/cascaded/provider.js +216 -0
- package/runtime/dist/src/realtime/cascaded/qwen-llm.js +7 -0
- package/runtime/dist/src/realtime/cascaded/self-hosted-asr.js +110 -0
- package/runtime/dist/src/realtime/cascaded/self-hosted-tts.js +137 -0
- package/runtime/dist/src/realtime/cascaded/transcribe.js +42 -0
- package/runtime/dist/src/realtime/coding-progress-narration.js +28 -0
- package/runtime/dist/src/realtime/confirmation-turn-isolation.js +586 -0
- package/runtime/dist/src/realtime/dictation.js +28 -0
- package/runtime/dist/src/realtime/evidence.js +276 -0
- package/runtime/dist/src/realtime/floor.js +43 -0
- package/runtime/dist/src/realtime/frontend-instructions.js +195 -0
- package/runtime/dist/src/realtime/gemini.js +517 -0
- package/runtime/dist/src/realtime/history.js +122 -0
- package/runtime/dist/src/realtime/host-delivery.js +1711 -0
- package/runtime/dist/src/realtime/integrated-wire-profile.js +128 -0
- package/runtime/dist/src/realtime/memory-board.js +105 -0
- package/runtime/dist/src/realtime/openai-wire-profile.js +46 -0
- package/runtime/dist/src/realtime/playback.js +242 -0
- package/runtime/dist/src/realtime/project-confirmation-flow.js +1428 -0
- package/runtime/dist/src/realtime/prompt-language.js +17 -0
- package/runtime/dist/src/realtime/protocol.js +428 -0
- package/runtime/dist/src/realtime/provider-projection.js +526 -0
- package/runtime/dist/src/realtime/provider-session.js +491 -0
- package/runtime/dist/src/realtime/qwen-transport.js +144 -0
- package/runtime/dist/src/realtime/qwen.js +1377 -0
- package/runtime/dist/src/realtime/recall.js +341 -0
- package/runtime/dist/src/realtime/service-ports.js +8 -0
- package/runtime/dist/src/realtime/service-state.js +259 -0
- package/runtime/dist/src/realtime/service.js +1726 -0
- package/runtime/dist/src/realtime/session-state.js +684 -0
- package/runtime/dist/src/realtime/session.js +1976 -0
- package/runtime/dist/src/realtime/speech-prep.js +63 -0
- package/runtime/dist/src/realtime/streaming-speech.js +120 -0
- package/runtime/dist/src/realtime/system-prompts.en.js +136 -0
- package/runtime/dist/src/realtime/telemetry.js +144 -0
- package/runtime/dist/src/realtime/tool-continuations.js +1510 -0
- package/runtime/dist/src/realtime/transport.js +8 -0
- package/runtime/dist/src/realtime/usage.js +55 -0
- package/runtime/dist/src/realtime/user-origin-binding.js +173 -0
- package/runtime/dist/src/realtime/volcengine/ark.js +428 -0
- package/runtime/dist/src/realtime/volcengine/asr.js +573 -0
- package/runtime/dist/src/realtime/volcengine/audio.js +39 -0
- package/runtime/dist/src/realtime/volcengine/endpointing-capability.js +834 -0
- package/runtime/dist/src/realtime/volcengine/livekit-endpointing.js +714 -0
- package/runtime/dist/src/realtime/volcengine/local-eot-executor.js +33 -0
- package/runtime/dist/src/realtime/volcengine/protocol.js +247 -0
- package/runtime/dist/src/realtime/volcengine/silence-endpointing.js +237 -0
- package/runtime/dist/src/realtime/volcengine/tts.js +444 -0
- package/runtime/dist/src/realtime/volcengine/websocket.js +293 -0
- package/runtime/dist/src/server/aoq-chat-server.js +497 -0
- package/runtime/dist/src/server/client-pairing.js +192 -0
- package/runtime/dist/src/server/client-protocol.js +87 -0
- package/runtime/dist/src/server/client-server.js +312 -0
- package/runtime/dist/src/server/server-config.js +72 -0
- package/runtime/dist/src/server-entry.js +135 -0
- package/runtime/dist/src/storage/bounded-json.js +63 -0
- package/runtime/dist/src/storage/native-file-lock.js +8 -0
- package/runtime/dist/src/storage/native-resource-snapshot.js +41 -0
- package/runtime/dist/src/storage/private-database.js +120 -0
- package/runtime/dist/src/text/canonical-json.js +60 -0
- package/runtime/dist/src/text/python-number.js +18 -0
- package/runtime/dist/src/text/python-text.js +92 -0
- package/runtime/dist/src/text/unicode-casefold.js +29 -0
- package/runtime/dist/src/text/unicode-normalize.js +138 -0
- package/runtime/dist/src/text/unicode-tables.js +210 -0
- package/runtime/dist/src/understanding/candidates.js +77 -0
- package/runtime/dist/src/understanding/fixture.js +7 -0
- package/runtime/dist/src/understanding/jev.js +20 -0
- package/runtime/dist/src/understanding/pipeline.js +38 -0
- package/runtime/dist/src/voicemem/store-client.js +476 -0
- package/runtime/dist/src/voicemem/store-worker.js +380 -0
- package/runtime/dist/src/voicemem/versioned-memory.js +170 -0
- package/runtime/scripts/pair-device.mjs +109 -0
- package/src/command.mjs +48 -0
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { ENGLISH_SYSTEM_PROMPTS } from './system-prompts.en.js';
|
|
2
|
+
export function parsePromptLanguage(value) {
|
|
3
|
+
if (value === undefined)
|
|
4
|
+
return undefined;
|
|
5
|
+
if (value === 'zh-CN' || value === 'en')
|
|
6
|
+
return value;
|
|
7
|
+
throw new TypeError('unsupported prompt language');
|
|
8
|
+
}
|
|
9
|
+
/** Only developer-owned system instructions belong here, never user text or host facts. */
|
|
10
|
+
export function translateSystemPrompt(text, language = 'zh-CN') {
|
|
11
|
+
if (language !== 'en')
|
|
12
|
+
return text;
|
|
13
|
+
if (ENGLISH_SYSTEM_PROMPTS[text] !== undefined)
|
|
14
|
+
return ENGLISH_SYSTEM_PROMPTS[text];
|
|
15
|
+
return text.split('\n').map(line => ENGLISH_SYSTEM_PROMPTS[line] ?? line).join('\n');
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=prompt-language.js.map
|
|
@@ -0,0 +1,428 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { jsonValueSchema } from '../core/events.js';
|
|
3
|
+
import { MAX_PACKED_RECOVERY_CONTENT } from './history.js';
|
|
4
|
+
export const MAX_REALTIME_TEXT = 4_000;
|
|
5
|
+
export const MAX_REALTIME_PCM_BYTES = 64 * 1_024;
|
|
6
|
+
const pythonWhitespaceOnly = /^[\u0009-\u000d\u001c-\u0020\u0085\u00a0\u1680\u2000-\u200a\u2028\u2029\u202f\u205f\u3000]*$/u;
|
|
7
|
+
export const realtimeIdentifierSchema = z.string().refine(value => !pythonWhitespaceOnly.test(value), 'identifier must be non-empty');
|
|
8
|
+
const epochSchema = z.number().int().positive();
|
|
9
|
+
const jsonObjectSchema = z.record(z.string(), jsonValueSchema);
|
|
10
|
+
function boundedText(allowEmpty = false) {
|
|
11
|
+
return z.string()
|
|
12
|
+
.refine(value => allowEmpty || !pythonWhitespaceOnly.test(value), 'text must be non-empty')
|
|
13
|
+
.refine(value => [...value].length <= MAX_REALTIME_TEXT, `text exceeds ${MAX_REALTIME_TEXT} characters`);
|
|
14
|
+
}
|
|
15
|
+
export const hostItemKindSchema = z.enum([
|
|
16
|
+
'progress',
|
|
17
|
+
'final',
|
|
18
|
+
'recovery',
|
|
19
|
+
'scheduled_task',
|
|
20
|
+
'dialogue_context',
|
|
21
|
+
'tool_output',
|
|
22
|
+
'workspace_context',
|
|
23
|
+
]);
|
|
24
|
+
const hostWorkSourceSchema = z.object({
|
|
25
|
+
work_id: realtimeIdentifierSchema,
|
|
26
|
+
/** Canonical host event sequence, scoped by work_id; unrelated to provider epochs. */
|
|
27
|
+
event_seq: z.number().int().nonnegative().optional(),
|
|
28
|
+
executor: realtimeIdentifierSchema,
|
|
29
|
+
project: z.string().min(1).max(240).optional(),
|
|
30
|
+
title: z.string().min(1).max(240).optional(),
|
|
31
|
+
}).strict();
|
|
32
|
+
export const hostContextItemSchema = z.object({
|
|
33
|
+
kind: hostItemKindSchema,
|
|
34
|
+
host_item_id: realtimeIdentifierSchema,
|
|
35
|
+
event_id: realtimeIdentifierSchema,
|
|
36
|
+
content: z.string().refine(value => !pythonWhitespaceOnly.test(value), 'text must be non-empty'),
|
|
37
|
+
context_read: z.literal(true).optional(),
|
|
38
|
+
/** Host-authored public wording; private context is never used as the narration payload. */
|
|
39
|
+
speech_content: boundedText().optional(),
|
|
40
|
+
/** Explicit host classification: control receipts are not recoverable results. */
|
|
41
|
+
recovery_eligible: z.boolean().optional(),
|
|
42
|
+
source: hostWorkSourceSchema.optional(),
|
|
43
|
+
call_id: realtimeIdentifierSchema.nullable().default(null),
|
|
44
|
+
session_epoch: epochSchema.optional(),
|
|
45
|
+
workspace_instance_id: realtimeIdentifierSchema.optional(),
|
|
46
|
+
revision: z.number().int().nonnegative().optional(),
|
|
47
|
+
}).strict().superRefine((item, context) => {
|
|
48
|
+
if (item.context_read && item.kind !== 'tool_output')
|
|
49
|
+
context.addIssue({ code: 'custom', path: ['context_read'], message: 'structured reads require tool output' });
|
|
50
|
+
if (item.context_read ? Buffer.byteLength(item.content) > 32768 : [...item.content].length > (item.kind === 'scheduled_task' ? 160000 : MAX_REALTIME_TEXT))
|
|
51
|
+
context.addIssue({ code: 'custom', path: ['content'], message: 'host context exceeds text limit' });
|
|
52
|
+
if (item.speech_content !== undefined && item.kind !== 'progress' && item.kind !== 'final') {
|
|
53
|
+
context.addIssue({ code: 'custom', path: ['speech_content'], message: 'public narration requires a progress or final fact' });
|
|
54
|
+
}
|
|
55
|
+
if (item.kind === 'dialogue_context'
|
|
56
|
+
&& [...item.content].length > MAX_PACKED_RECOVERY_CONTENT) {
|
|
57
|
+
context.addIssue({
|
|
58
|
+
code: 'custom',
|
|
59
|
+
path: ['content'],
|
|
60
|
+
message: `dialogue context exceeds ${MAX_PACKED_RECOVERY_CONTENT} characters`,
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
if (item.kind === 'tool_output' && item.call_id === null) {
|
|
64
|
+
context.addIssue({ code: 'custom', path: ['call_id'], message: 'tool output call_id is required' });
|
|
65
|
+
}
|
|
66
|
+
else if (item.kind !== 'tool_output' && item.call_id !== null) {
|
|
67
|
+
context.addIssue({
|
|
68
|
+
code: 'custom',
|
|
69
|
+
path: ['call_id'],
|
|
70
|
+
message: 'call_id is only valid for tool output',
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
const workspaceContextFields = [
|
|
74
|
+
item.session_epoch,
|
|
75
|
+
item.workspace_instance_id,
|
|
76
|
+
item.revision,
|
|
77
|
+
];
|
|
78
|
+
if (item.kind === 'workspace_context') {
|
|
79
|
+
for (const [index, field] of workspaceContextFields.entries()) {
|
|
80
|
+
if (field === undefined) {
|
|
81
|
+
context.addIssue({
|
|
82
|
+
code: 'custom',
|
|
83
|
+
path: [['session_epoch', 'workspace_instance_id', 'revision'][index]],
|
|
84
|
+
message: 'workspace context requires session_epoch, workspace_instance_id, and revision',
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
else if (workspaceContextFields.some(field => field !== undefined)) {
|
|
90
|
+
context.addIssue({
|
|
91
|
+
code: 'custom',
|
|
92
|
+
message: 'workspace context fields are only valid for workspace_context',
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
/**
|
|
97
|
+
* A provider adapter reports one of these capabilities before it is allowed to make a
|
|
98
|
+
* workspace-context item provider-visible. This is a contract declaration, not proof that a
|
|
99
|
+
* specific provider implements the operation; provider-specific proof belongs at the adapter.
|
|
100
|
+
*/
|
|
101
|
+
export const workspaceContextDeliveryCapabilitySchema = z.enum([
|
|
102
|
+
'replace_provider_item',
|
|
103
|
+
'refresh_session',
|
|
104
|
+
'unavailable',
|
|
105
|
+
]);
|
|
106
|
+
/**
|
|
107
|
+
* The provider-visible transition for a workspace-context revision. A previous provider item is
|
|
108
|
+
* never left visible while a newer revision is accepted: it is either superseded explicitly or a
|
|
109
|
+
* session refresh is recorded. `unavailable` is intentionally a non-delivery state.
|
|
110
|
+
*/
|
|
111
|
+
const workspaceContextDeliveryIdentity = {
|
|
112
|
+
session_epoch: epochSchema,
|
|
113
|
+
workspace_instance_id: realtimeIdentifierSchema,
|
|
114
|
+
revision: z.number().int().nonnegative(),
|
|
115
|
+
// The adapter must attest to the prior provider-visible state, even when it was empty.
|
|
116
|
+
prior_provider_item_id: realtimeIdentifierSchema.nullable(),
|
|
117
|
+
};
|
|
118
|
+
const replaceWorkspaceContextDeliverySchema = z.object({
|
|
119
|
+
capability: z.literal('replace_provider_item'),
|
|
120
|
+
delivered: z.literal(true),
|
|
121
|
+
...workspaceContextDeliveryIdentity,
|
|
122
|
+
provider_item_id: realtimeIdentifierSchema,
|
|
123
|
+
superseded_provider_item_id: realtimeIdentifierSchema.nullable(),
|
|
124
|
+
}).strict().superRefine((delivery, context) => {
|
|
125
|
+
if (delivery.superseded_provider_item_id !== delivery.prior_provider_item_id) {
|
|
126
|
+
context.addIssue({
|
|
127
|
+
code: 'custom',
|
|
128
|
+
path: ['superseded_provider_item_id'],
|
|
129
|
+
message: 'prior provider state must be explicitly superseded before a newer revision is visible',
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
if (delivery.prior_provider_item_id !== null
|
|
133
|
+
&& delivery.provider_item_id === delivery.prior_provider_item_id) {
|
|
134
|
+
context.addIssue({
|
|
135
|
+
code: 'custom',
|
|
136
|
+
path: ['provider_item_id'],
|
|
137
|
+
message: 'newer revision requires a distinct provider item id',
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
});
|
|
141
|
+
const refreshWorkspaceContextDeliverySchema = z.object({
|
|
142
|
+
capability: z.literal('refresh_session'),
|
|
143
|
+
delivered: z.literal(true),
|
|
144
|
+
...workspaceContextDeliveryIdentity,
|
|
145
|
+
refresh_id: realtimeIdentifierSchema,
|
|
146
|
+
}).strict();
|
|
147
|
+
const unavailableWorkspaceContextDeliverySchema = z.object({
|
|
148
|
+
capability: z.literal('unavailable'),
|
|
149
|
+
delivered: z.literal(false),
|
|
150
|
+
...workspaceContextDeliveryIdentity,
|
|
151
|
+
}).strict();
|
|
152
|
+
export const workspaceContextDeliverySchema = z.discriminatedUnion('capability', [
|
|
153
|
+
replaceWorkspaceContextDeliverySchema,
|
|
154
|
+
refreshWorkspaceContextDeliverySchema,
|
|
155
|
+
unavailableWorkspaceContextDeliverySchema,
|
|
156
|
+
]);
|
|
157
|
+
export const workspaceContextDeliveryRecordSchema = z.object({
|
|
158
|
+
item: hostContextItemSchema,
|
|
159
|
+
asUserActivation: z.literal(false),
|
|
160
|
+
delivery: workspaceContextDeliverySchema,
|
|
161
|
+
}).strict().superRefine((injection, context) => {
|
|
162
|
+
if (injection.item.kind !== 'workspace_context') {
|
|
163
|
+
context.addIssue({
|
|
164
|
+
code: 'custom',
|
|
165
|
+
path: ['item'],
|
|
166
|
+
message: 'workspace context injection requires workspace_context item kind',
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
if (injection.item.session_epoch !== injection.delivery.session_epoch
|
|
170
|
+
|| injection.item.workspace_instance_id !== injection.delivery.workspace_instance_id
|
|
171
|
+
|| injection.item.revision !== injection.delivery.revision)
|
|
172
|
+
context.addIssue({
|
|
173
|
+
code: 'custom',
|
|
174
|
+
path: ['delivery'],
|
|
175
|
+
message: 'workspace context delivery proof must bind the exact session_epoch, workspace_instance_id, and revision',
|
|
176
|
+
});
|
|
177
|
+
});
|
|
178
|
+
export const workspaceContextInjectionSchema = workspaceContextDeliveryRecordSchema.superRefine((injection, context) => {
|
|
179
|
+
if (injection.delivery.capability === 'unavailable') {
|
|
180
|
+
context.addIssue({
|
|
181
|
+
code: 'custom',
|
|
182
|
+
path: ['delivery', 'capability'],
|
|
183
|
+
message: 'workspace context is unavailable and cannot be injected',
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
});
|
|
187
|
+
export const hostResponseKindSchema = z.enum([
|
|
188
|
+
'host_fact',
|
|
189
|
+
'task_continuation',
|
|
190
|
+
'scheduled_task',
|
|
191
|
+
'tool_result',
|
|
192
|
+
'delegation_acknowledgement',
|
|
193
|
+
]);
|
|
194
|
+
export const hostResponseIntentSchema = z.object({
|
|
195
|
+
kind: hostResponseKindSchema,
|
|
196
|
+
item: hostContextItemSchema,
|
|
197
|
+
task_summary: boundedText().nullable().default(null),
|
|
198
|
+
origin_spoken: z.boolean().default(false),
|
|
199
|
+
}).strict().superRefine((intent, context) => {
|
|
200
|
+
if (intent.kind === 'scheduled_task') {
|
|
201
|
+
let purpose;
|
|
202
|
+
try {
|
|
203
|
+
purpose = JSON.parse(intent.item.content).purpose;
|
|
204
|
+
}
|
|
205
|
+
catch { /* invalid activation */ }
|
|
206
|
+
if (intent.item.kind !== 'scheduled_task' || purpose !== 'run_scheduled_task')
|
|
207
|
+
context.addIssue({ code: 'custom', path: ['item'], message: 'scheduled task requires host scheduled activation' });
|
|
208
|
+
}
|
|
209
|
+
else if (intent.item.kind === 'scheduled_task')
|
|
210
|
+
context.addIssue({ code: 'custom', path: ['item'], message: 'scheduled activation requires scheduled task response' });
|
|
211
|
+
if (intent.kind === 'task_continuation' && intent.item.kind !== 'recovery')
|
|
212
|
+
context.addIssue({ code: 'custom', path: ['item'], message: 'task continuation requires recovery context' });
|
|
213
|
+
if (intent.item.kind === 'workspace_context') {
|
|
214
|
+
context.addIssue({
|
|
215
|
+
code: 'custom',
|
|
216
|
+
path: ['item'],
|
|
217
|
+
message: 'workspace context cannot create a response',
|
|
218
|
+
});
|
|
219
|
+
}
|
|
220
|
+
if (intent.kind === 'host_fact' && intent.item.kind === 'tool_output') {
|
|
221
|
+
context.addIssue({ code: 'custom', path: ['item'], message: 'host fact cannot be tool output' });
|
|
222
|
+
}
|
|
223
|
+
if (intent.kind === 'host_fact' && intent.item.kind === 'dialogue_context') {
|
|
224
|
+
context.addIssue({
|
|
225
|
+
code: 'custom',
|
|
226
|
+
path: ['item'],
|
|
227
|
+
message: 'dialogue context cannot create a response',
|
|
228
|
+
});
|
|
229
|
+
}
|
|
230
|
+
if (intent.kind === 'tool_result' && intent.item.kind !== 'tool_output') {
|
|
231
|
+
context.addIssue({ code: 'custom', path: ['item'], message: 'tool result requires tool output' });
|
|
232
|
+
}
|
|
233
|
+
if (intent.kind === 'delegation_acknowledgement') {
|
|
234
|
+
if (intent.item.kind !== 'tool_output') {
|
|
235
|
+
context.addIssue({
|
|
236
|
+
code: 'custom',
|
|
237
|
+
path: ['item'],
|
|
238
|
+
message: 'delegation acknowledgement requires tool output',
|
|
239
|
+
});
|
|
240
|
+
}
|
|
241
|
+
if (intent.task_summary === null) {
|
|
242
|
+
context.addIssue({ code: 'custom', path: ['task_summary'], message: 'task_summary is required' });
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
else {
|
|
246
|
+
if (intent.task_summary !== null) {
|
|
247
|
+
context.addIssue({
|
|
248
|
+
code: 'custom',
|
|
249
|
+
path: ['task_summary'],
|
|
250
|
+
message: 'task_summary is only valid for delegation acknowledgement',
|
|
251
|
+
});
|
|
252
|
+
}
|
|
253
|
+
if (intent.origin_spoken) {
|
|
254
|
+
context.addIssue({
|
|
255
|
+
code: 'custom',
|
|
256
|
+
path: ['origin_spoken'],
|
|
257
|
+
message: 'origin_spoken is only valid for delegation acknowledgement',
|
|
258
|
+
});
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
});
|
|
262
|
+
export const sessionIdentitySchema = z.object({
|
|
263
|
+
epoch: epochSchema,
|
|
264
|
+
provider_session_id: realtimeIdentifierSchema,
|
|
265
|
+
}).strict();
|
|
266
|
+
export const itemIdentitySchema = z.object({
|
|
267
|
+
session_epoch: epochSchema,
|
|
268
|
+
host_item_id: realtimeIdentifierSchema,
|
|
269
|
+
provider_item_id: realtimeIdentifierSchema,
|
|
270
|
+
/** Omission preserves older adapters; staged means local ownership, not remote acknowledgment. */
|
|
271
|
+
delivery: z.enum(['staged', 'acknowledged']).optional(),
|
|
272
|
+
}).strict();
|
|
273
|
+
const sessionEvent = (kind, shape) => z.object({ kind, session_epoch: epochSchema, ...shape }).strict();
|
|
274
|
+
const itemTextShape = {
|
|
275
|
+
item_id: realtimeIdentifierSchema,
|
|
276
|
+
text: boundedText(true),
|
|
277
|
+
};
|
|
278
|
+
const responseTextShape = {
|
|
279
|
+
response_id: realtimeIdentifierSchema,
|
|
280
|
+
text: boundedText(true),
|
|
281
|
+
};
|
|
282
|
+
export const userSpeechStartedSchema = sessionEvent(z.literal('user_speech_started'), {
|
|
283
|
+
speech_id: realtimeIdentifierSchema,
|
|
284
|
+
provider_item_id: realtimeIdentifierSchema.nullable().default(null),
|
|
285
|
+
});
|
|
286
|
+
export const userSpeechEndedSchema = sessionEvent(z.literal('user_speech_ended'), {
|
|
287
|
+
speech_id: realtimeIdentifierSchema,
|
|
288
|
+
provider_item_id: realtimeIdentifierSchema.nullable().default(null),
|
|
289
|
+
});
|
|
290
|
+
export const userTranscriptDeltaSchema = sessionEvent(z.literal('user_transcript_delta'), { ...itemTextShape, replace: z.boolean().optional() });
|
|
291
|
+
export const userTranscriptFailedSchema = sessionEvent(z.literal('user_transcript_failed'), {
|
|
292
|
+
item_id: realtimeIdentifierSchema,
|
|
293
|
+
});
|
|
294
|
+
export const userTranscriptFinalSchema = sessionEvent(z.literal('user_transcript_final'), { ...itemTextShape, input_kind: z.literal('text').optional(),
|
|
295
|
+
/** Independent transcription streams do not prove a new response is owed. */
|
|
296
|
+
response_expected: z.boolean().optional() });
|
|
297
|
+
/** Provider evidence, never a host turn identity or an authorization decision.
|
|
298
|
+
* Omission preserves automatic-provider legacy correlation; explicit unknown must not claim a user item.
|
|
299
|
+
* Requested responses echo the host's per-attempt request_id on start and terminal. This identity
|
|
300
|
+
* settles generation ownership, never authorization or the current user-input revision.
|
|
301
|
+
*/
|
|
302
|
+
export const responseOriginSchema = z.discriminatedUnion('kind', [
|
|
303
|
+
z.object({ kind: z.literal('user_item'), item_id: realtimeIdentifierSchema,
|
|
304
|
+
request_id: realtimeIdentifierSchema.optional() }).strict(),
|
|
305
|
+
z.object({ kind: z.literal('host_request'), host_item_id: realtimeIdentifierSchema }).strict(),
|
|
306
|
+
z.object({ kind: z.literal('unknown') }).strict(),
|
|
307
|
+
]);
|
|
308
|
+
export const responseStartedSchema = sessionEvent(z.literal('response_started'), {
|
|
309
|
+
response_id: realtimeIdentifierSchema,
|
|
310
|
+
origin: responseOriginSchema.optional(),
|
|
311
|
+
});
|
|
312
|
+
/**
|
|
313
|
+
* Inbound provider audio is bounded by alignment, not by size.
|
|
314
|
+
*
|
|
315
|
+
* `ResponseAudioDelta.__post_init__` requires only non-empty PCM16 alignment, and the playback
|
|
316
|
+
* registry is built for larger deltas: it splits one into `MAX_PLAYBACK_FRAME_BYTES` frames. A
|
|
317
|
+
* size bound here would make that split unreachable from the provider path and would refuse audio
|
|
318
|
+
* the oracle accepts -- narrowing the accepted domain on one leg only. `MAX_REALTIME_PCM_BYTES`
|
|
319
|
+
* still bounds what we *send*, which is a different direction with its own reason.
|
|
320
|
+
*/
|
|
321
|
+
export const responseAudioDeltaSchema = sessionEvent(z.literal('response_audio_delta'), {
|
|
322
|
+
response_id: realtimeIdentifierSchema,
|
|
323
|
+
pcm: z.instanceof(Uint8Array)
|
|
324
|
+
.refine(value => value.byteLength > 0 && value.byteLength % 2 === 0, 'pcm must be non-empty aligned PCM16 bytes'),
|
|
325
|
+
});
|
|
326
|
+
export const responseTranscriptDeltaSchema = sessionEvent(z.literal('response_transcript_delta'), responseTextShape);
|
|
327
|
+
export const responseTranscriptFinalSchema = sessionEvent(z.literal('response_transcript_final'), responseTextShape);
|
|
328
|
+
export const toolCallReadySchema = sessionEvent(z.literal('tool_call_ready'), {
|
|
329
|
+
call_id: realtimeIdentifierSchema,
|
|
330
|
+
item_id: realtimeIdentifierSchema,
|
|
331
|
+
name: realtimeIdentifierSchema,
|
|
332
|
+
arguments: jsonObjectSchema,
|
|
333
|
+
response_id: realtimeIdentifierSchema.nullable().default(null),
|
|
334
|
+
});
|
|
335
|
+
export const itemConfirmedSchema = sessionEvent(z.literal('item_confirmed'), {
|
|
336
|
+
host_item_id: realtimeIdentifierSchema,
|
|
337
|
+
provider_item_id: realtimeIdentifierSchema,
|
|
338
|
+
});
|
|
339
|
+
export const responseTerminalSchema = sessionEvent(z.literal('response_terminal'), {
|
|
340
|
+
origin: responseOriginSchema.optional(),
|
|
341
|
+
response_id: realtimeIdentifierSchema,
|
|
342
|
+
status: z.enum(['completed', 'cancelled', 'failed']),
|
|
343
|
+
reason: boundedText(),
|
|
344
|
+
});
|
|
345
|
+
/** A generation segment yielded to tools. It is not a completed provider turn.
|
|
346
|
+
* All calls in this segment precede this event; continuation uses a new response id.
|
|
347
|
+
*/
|
|
348
|
+
export const responseYieldedSchema = sessionEvent(z.literal('response_yielded'), {
|
|
349
|
+
response_id: realtimeIdentifierSchema,
|
|
350
|
+
reason: z.literal('tool_calls'),
|
|
351
|
+
call_ids: z.array(realtimeIdentifierSchema).min(1).max(128).refine(ids => new Set(ids).size === ids.length),
|
|
352
|
+
});
|
|
353
|
+
export const responseCancelRejectedSchema = sessionEvent(z.literal('response_cancel_rejected'), {
|
|
354
|
+
response_id: realtimeIdentifierSchema,
|
|
355
|
+
cancel_request_id: realtimeIdentifierSchema,
|
|
356
|
+
reason: z.literal('no_active_response'),
|
|
357
|
+
});
|
|
358
|
+
export const providerErrorEventSchema = sessionEvent(z.literal('provider_error'), {
|
|
359
|
+
code: realtimeIdentifierSchema,
|
|
360
|
+
recoverable: z.boolean().default(false),
|
|
361
|
+
});
|
|
362
|
+
export const realtimeProviderEventSchema = z.discriminatedUnion('kind', [
|
|
363
|
+
userSpeechStartedSchema,
|
|
364
|
+
userSpeechEndedSchema,
|
|
365
|
+
userTranscriptDeltaSchema,
|
|
366
|
+
userTranscriptFailedSchema,
|
|
367
|
+
userTranscriptFinalSchema,
|
|
368
|
+
responseStartedSchema,
|
|
369
|
+
responseAudioDeltaSchema,
|
|
370
|
+
responseTranscriptDeltaSchema,
|
|
371
|
+
responseTranscriptFinalSchema,
|
|
372
|
+
toolCallReadySchema,
|
|
373
|
+
itemConfirmedSchema,
|
|
374
|
+
responseTerminalSchema,
|
|
375
|
+
responseYieldedSchema,
|
|
376
|
+
responseCancelRejectedSchema,
|
|
377
|
+
providerErrorEventSchema,
|
|
378
|
+
]);
|
|
379
|
+
export const responseAdaptationContextSchema = z.object({
|
|
380
|
+
revision: z.number().int().min(0).max(Number.MAX_SAFE_INTEGER),
|
|
381
|
+
content: z.string().max(16_000).nullable(),
|
|
382
|
+
delivery_version: z.number().int().nonnegative().optional(),
|
|
383
|
+
user_sources: z.array(z.object({ ref: z.string(), text: z.string() }).strict()).max(8)
|
|
384
|
+
.refine(sources => JSON.stringify(sources).length <= 6000).optional(),
|
|
385
|
+
}).strict();
|
|
386
|
+
export class RealtimeProtocolError extends Error {
|
|
387
|
+
constructor(message) {
|
|
388
|
+
super(message);
|
|
389
|
+
this.name = 'RealtimeProtocolError';
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
/** A response was rejected before any request bytes were sent. */
|
|
393
|
+
export class ProviderResponseRejectedError extends RealtimeProtocolError {
|
|
394
|
+
}
|
|
395
|
+
export class ItemDeliveryUncertainError extends Error {
|
|
396
|
+
session_epoch;
|
|
397
|
+
host_item_id;
|
|
398
|
+
provider_item_id;
|
|
399
|
+
item_kind;
|
|
400
|
+
constructor(input) {
|
|
401
|
+
super('host item confirmation timed out; delivery is uncertain');
|
|
402
|
+
const identity = itemIdentitySchema.parse({
|
|
403
|
+
session_epoch: input.session_epoch,
|
|
404
|
+
host_item_id: input.host_item_id,
|
|
405
|
+
provider_item_id: input.provider_item_id,
|
|
406
|
+
});
|
|
407
|
+
this.name = 'ItemDeliveryUncertainError';
|
|
408
|
+
this.session_epoch = identity.session_epoch;
|
|
409
|
+
this.host_item_id = identity.host_item_id;
|
|
410
|
+
this.provider_item_id = identity.provider_item_id;
|
|
411
|
+
this.item_kind = hostItemKindSchema.parse(input.item_kind);
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
export function hostFact(item) {
|
|
415
|
+
return hostResponseIntentSchema.parse({ kind: 'host_fact', item });
|
|
416
|
+
}
|
|
417
|
+
export function toolResult(item) {
|
|
418
|
+
return hostResponseIntentSchema.parse({ kind: 'tool_result', item });
|
|
419
|
+
}
|
|
420
|
+
export function delegationAcknowledgement(item, taskSummary, originSpoken = false) {
|
|
421
|
+
return hostResponseIntentSchema.parse({
|
|
422
|
+
kind: 'delegation_acknowledgement',
|
|
423
|
+
item,
|
|
424
|
+
task_summary: taskSummary,
|
|
425
|
+
origin_spoken: originSpoken,
|
|
426
|
+
});
|
|
427
|
+
}
|
|
428
|
+
//# sourceMappingURL=protocol.js.map
|