@moureau/pipeflow 0.0.1 → 0.0.2
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/README.md +245 -117
- package/dist/cjs/agents/agent.js +1 -1
- package/dist/cjs/agents/agent.js.map +3 -3
- package/dist/cjs/agents/tools/tools.js +1 -1
- package/dist/cjs/agents/tools/tools.js.map +3 -3
- package/dist/cjs/conversations/conversation/conversation.js +1 -1
- package/dist/cjs/conversations/conversation/conversation.js.map +3 -3
- package/dist/cjs/conversations/conversations.js +1 -1
- package/dist/cjs/conversations/conversations.js.map +3 -3
- package/dist/cjs/conversations/index.js +1 -1
- package/dist/cjs/conversations/index.js.map +3 -3
- package/dist/cjs/conversations/orchestration/coordination/coordination.js +10 -0
- package/dist/cjs/conversations/orchestration/coordination/coordination.js.map +7 -0
- package/dist/cjs/conversations/orchestration/coordination/index.js +2 -0
- package/dist/cjs/conversations/orchestration/coordination/index.js.map +7 -0
- package/dist/cjs/conversations/orchestration/orchestrator/coordination-runner/coordination-runner.js +4 -0
- package/dist/cjs/conversations/orchestration/orchestrator/coordination-runner/coordination-runner.js.map +7 -0
- package/dist/cjs/conversations/orchestration/orchestrator/coordination-runner/index.js +2 -0
- package/dist/cjs/conversations/orchestration/orchestrator/coordination-runner/index.js.map +7 -0
- package/dist/cjs/conversations/orchestration/orchestrator/generation/generation.js +2 -0
- package/dist/cjs/conversations/orchestration/orchestrator/generation/generation.js.map +7 -0
- package/dist/cjs/conversations/orchestration/orchestrator/generation/index.js +2 -0
- package/dist/cjs/conversations/orchestration/orchestrator/generation/index.js.map +7 -0
- package/dist/cjs/conversations/orchestration/orchestrator/history/history.js +4 -0
- package/dist/cjs/conversations/orchestration/orchestrator/history/history.js.map +7 -0
- package/dist/cjs/conversations/orchestration/orchestrator/history/index.js +2 -0
- package/dist/cjs/conversations/orchestration/orchestrator/history/index.js.map +7 -0
- package/dist/cjs/conversations/orchestration/orchestrator/index.js +1 -1
- package/dist/cjs/conversations/orchestration/orchestrator/index.js.map +3 -3
- package/dist/cjs/conversations/orchestration/orchestrator/orchestrator.js +1 -2
- package/dist/cjs/conversations/orchestration/orchestrator/orchestrator.js.map +3 -3
- package/dist/cjs/conversations/orchestration/orchestrator/routing/index.js +2 -0
- package/dist/cjs/conversations/orchestration/orchestrator/routing/index.js.map +7 -0
- package/dist/cjs/conversations/orchestration/orchestrator/routing/routing.js +23 -0
- package/dist/cjs/conversations/orchestration/orchestrator/routing/routing.js.map +7 -0
- package/dist/cjs/conversations/orchestration/orchestrator/speech/index.js +2 -0
- package/dist/cjs/conversations/orchestration/orchestrator/speech/index.js.map +7 -0
- package/dist/cjs/conversations/orchestration/orchestrator/speech/speech.js +2 -0
- package/dist/cjs/conversations/orchestration/orchestrator/speech/speech.js.map +7 -0
- package/dist/cjs/conversations/orchestration/orchestrator/tools/index.js +2 -0
- package/dist/cjs/conversations/orchestration/orchestrator/tools/index.js.map +7 -0
- package/dist/cjs/conversations/orchestration/orchestrator/tools/tools.js +2 -0
- package/dist/cjs/conversations/orchestration/orchestrator/tools/tools.js.map +7 -0
- package/dist/cjs/conversations/orchestration/test-harness.js +2 -0
- package/dist/cjs/conversations/orchestration/test-harness.js.map +7 -0
- package/dist/cjs/conversations/orchestration/text-chunker/index.js +2 -0
- package/dist/cjs/conversations/orchestration/text-chunker/index.js.map +7 -0
- package/dist/cjs/conversations/orchestration/text-chunker/text-chunker.js +3 -0
- package/dist/cjs/conversations/orchestration/text-chunker/text-chunker.js.map +7 -0
- package/dist/cjs/conversations/stream/conversation-stream.js +2 -0
- package/dist/cjs/conversations/stream/conversation-stream.js.map +7 -0
- package/dist/cjs/conversations/stream/index.js +2 -0
- package/dist/cjs/conversations/stream/index.js.map +7 -0
- package/dist/cjs/conversations/types.js +1 -1
- package/dist/cjs/conversations/types.js.map +2 -2
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/index.js.map +3 -3
- package/dist/cjs/persistence/adapters/sqlite/sqlite.js +18 -14
- package/dist/cjs/persistence/adapters/sqlite/sqlite.js.map +3 -3
- package/dist/cjs/pipeflow/index.js +2 -0
- package/dist/cjs/pipeflow/index.js.map +7 -0
- package/dist/cjs/pipeflow/pipeflow.js +2 -0
- package/dist/cjs/pipeflow/pipeflow.js.map +7 -0
- package/dist/cjs/providers/index.js +1 -1
- package/dist/cjs/providers/index.js.map +2 -2
- package/dist/cjs/providers/llm/adapters/claude/claude.js +5 -0
- package/dist/cjs/providers/llm/adapters/claude/claude.js.map +7 -0
- package/dist/cjs/providers/llm/adapters/claude/index.js +2 -0
- package/dist/cjs/providers/llm/adapters/claude/index.js.map +7 -0
- package/dist/cjs/providers/llm/adapters/deepseek/deepseek.js +1 -1
- package/dist/cjs/providers/llm/adapters/deepseek/deepseek.js.map +3 -3
- package/dist/cjs/providers/llm/adapters/index.js +1 -1
- package/dist/cjs/providers/llm/adapters/index.js.map +3 -3
- package/dist/cjs/providers/llm/adapters/openai/index.js +2 -0
- package/dist/cjs/providers/llm/adapters/openai/index.js.map +7 -0
- package/dist/cjs/providers/llm/adapters/openai/openai.js +2 -0
- package/dist/cjs/providers/llm/adapters/openai/openai.js.map +7 -0
- package/dist/cjs/providers/llm/adapters/openai-compatible.js +10 -0
- package/dist/cjs/providers/llm/adapters/openai-compatible.js.map +7 -0
- package/dist/cjs/providers/llm/adapters/openrouter/index.js +2 -0
- package/dist/cjs/providers/llm/adapters/openrouter/index.js.map +7 -0
- package/dist/cjs/providers/llm/adapters/openrouter/openrouter.js +2 -0
- package/dist/cjs/providers/llm/adapters/openrouter/openrouter.js.map +7 -0
- package/dist/cjs/providers/llm/index.js +1 -1
- package/dist/cjs/providers/llm/index.js.map +3 -3
- package/dist/cjs/providers/llm/toolmode/index.js +2 -0
- package/dist/cjs/providers/llm/toolmode/index.js.map +7 -0
- package/dist/cjs/providers/llm/toolmode/toolmode.js +2 -0
- package/dist/cjs/providers/llm/toolmode/toolmode.js.map +7 -0
- package/dist/cjs/providers/llm/types.js +1 -1
- package/dist/cjs/providers/llm/types.js.map +3 -3
- package/dist/cjs/providers/stt/adapters/deepgram/deepgram.js +1 -1
- package/dist/cjs/providers/stt/adapters/deepgram/deepgram.js.map +3 -3
- package/dist/cjs/providers/stt/adapters/index.js +1 -1
- package/dist/cjs/providers/stt/adapters/index.js.map +3 -3
- package/dist/cjs/providers/stt/adapters/openrouter/index.js +2 -0
- package/dist/cjs/providers/stt/adapters/openrouter/index.js.map +7 -0
- package/dist/cjs/providers/stt/adapters/openrouter/openrouter.js +2 -0
- package/dist/cjs/providers/stt/adapters/openrouter/openrouter.js.map +7 -0
- package/dist/cjs/providers/tts/adapters/index.js +1 -1
- package/dist/cjs/providers/tts/adapters/index.js.map +3 -3
- package/dist/cjs/providers/tts/adapters/kokoro/kokoro.js +4 -1
- package/dist/cjs/providers/tts/adapters/kokoro/kokoro.js.map +3 -3
- package/dist/cjs/providers/tts/adapters/openrouter/index.js +2 -0
- package/dist/cjs/providers/tts/adapters/openrouter/index.js.map +7 -0
- package/dist/cjs/providers/tts/adapters/openrouter/openrouter.js +2 -0
- package/dist/cjs/providers/tts/adapters/openrouter/openrouter.js.map +7 -0
- package/dist/cjs/transport/streamobject/field-stream/field-stream.js +2 -0
- package/dist/cjs/transport/streamobject/field-stream/field-stream.js.map +7 -0
- package/dist/cjs/transport/streamobject/field-stream/index.js +2 -0
- package/dist/cjs/transport/streamobject/field-stream/index.js.map +7 -0
- package/dist/cjs/transport/streamobject/index.js +2 -0
- package/dist/cjs/transport/streamobject/index.js.map +7 -0
- package/dist/cjs/transport/streamobject/json-adapter/index.js +2 -0
- package/dist/cjs/transport/streamobject/json-adapter/index.js.map +7 -0
- package/dist/cjs/transport/streamobject/json-adapter/json-adapter.js +4 -0
- package/dist/cjs/transport/streamobject/json-adapter/json-adapter.js.map +7 -0
- package/dist/cjs/transport/streamobject/reference/index.js +2 -0
- package/dist/cjs/transport/streamobject/reference/index.js.map +7 -0
- package/dist/cjs/transport/streamobject/reference/reference.js +2 -0
- package/dist/cjs/transport/streamobject/reference/reference.js.map +7 -0
- package/dist/cjs/transport/streamobject/stream-object/index.js +2 -0
- package/dist/cjs/transport/streamobject/stream-object/index.js.map +7 -0
- package/dist/cjs/transport/streamobject/stream-object/stream-object.js +2 -0
- package/dist/cjs/transport/streamobject/stream-object/stream-object.js.map +7 -0
- package/dist/esm/agents/agent.js +1 -1
- package/dist/esm/agents/agent.js.map +3 -3
- package/dist/esm/agents/tools/tools.js +1 -1
- package/dist/esm/agents/tools/tools.js.map +3 -3
- package/dist/esm/conversations/conversation/conversation.js +1 -1
- package/dist/esm/conversations/conversation/conversation.js.map +3 -3
- package/dist/esm/conversations/conversations.js +1 -1
- package/dist/esm/conversations/conversations.js.map +3 -3
- package/dist/esm/conversations/index.js +1 -1
- package/dist/esm/conversations/index.js.map +3 -3
- package/dist/esm/conversations/orchestration/coordination/coordination.js +10 -0
- package/dist/esm/conversations/orchestration/coordination/coordination.js.map +7 -0
- package/dist/esm/conversations/orchestration/coordination/index.js +2 -0
- package/dist/esm/conversations/orchestration/coordination/index.js.map +7 -0
- package/dist/esm/conversations/orchestration/orchestrator/coordination-runner/coordination-runner.js +4 -0
- package/dist/esm/conversations/orchestration/orchestrator/coordination-runner/coordination-runner.js.map +7 -0
- package/dist/esm/conversations/orchestration/orchestrator/coordination-runner/index.js +2 -0
- package/dist/esm/conversations/orchestration/orchestrator/coordination-runner/index.js.map +7 -0
- package/dist/esm/conversations/orchestration/orchestrator/generation/generation.js +2 -0
- package/dist/esm/conversations/orchestration/orchestrator/generation/generation.js.map +7 -0
- package/dist/esm/conversations/orchestration/orchestrator/generation/index.js +2 -0
- package/dist/esm/conversations/orchestration/orchestrator/generation/index.js.map +7 -0
- package/dist/esm/conversations/orchestration/orchestrator/history/history.js +4 -0
- package/dist/esm/conversations/orchestration/orchestrator/history/history.js.map +7 -0
- package/dist/esm/conversations/orchestration/orchestrator/history/index.js +2 -0
- package/dist/esm/conversations/orchestration/orchestrator/history/index.js.map +7 -0
- package/dist/esm/conversations/orchestration/orchestrator/index.js +1 -1
- package/dist/esm/conversations/orchestration/orchestrator/index.js.map +3 -3
- package/dist/esm/conversations/orchestration/orchestrator/orchestrator.js +1 -2
- package/dist/esm/conversations/orchestration/orchestrator/orchestrator.js.map +3 -3
- package/dist/esm/conversations/orchestration/orchestrator/routing/index.js +2 -0
- package/dist/esm/conversations/orchestration/orchestrator/routing/index.js.map +7 -0
- package/dist/esm/conversations/orchestration/orchestrator/routing/routing.js +23 -0
- package/dist/esm/conversations/orchestration/orchestrator/routing/routing.js.map +7 -0
- package/dist/esm/conversations/orchestration/orchestrator/speech/index.js +2 -0
- package/dist/esm/conversations/orchestration/orchestrator/speech/index.js.map +7 -0
- package/dist/esm/conversations/orchestration/orchestrator/speech/speech.js +2 -0
- package/dist/esm/conversations/orchestration/orchestrator/speech/speech.js.map +7 -0
- package/dist/esm/conversations/orchestration/orchestrator/tools/index.js +2 -0
- package/dist/esm/conversations/orchestration/orchestrator/tools/index.js.map +7 -0
- package/dist/esm/conversations/orchestration/orchestrator/tools/tools.js +2 -0
- package/dist/esm/conversations/orchestration/orchestrator/tools/tools.js.map +7 -0
- package/dist/esm/conversations/orchestration/test-harness.js +2 -0
- package/dist/esm/conversations/orchestration/test-harness.js.map +7 -0
- package/dist/esm/conversations/orchestration/text-chunker/index.js +2 -0
- package/dist/esm/conversations/orchestration/text-chunker/index.js.map +7 -0
- package/dist/esm/conversations/orchestration/text-chunker/text-chunker.js +3 -0
- package/dist/esm/conversations/orchestration/text-chunker/text-chunker.js.map +7 -0
- package/dist/esm/conversations/stream/conversation-stream.js +2 -0
- package/dist/esm/conversations/stream/conversation-stream.js.map +7 -0
- package/dist/esm/conversations/stream/index.js +2 -0
- package/dist/esm/conversations/stream/index.js.map +7 -0
- package/dist/esm/conversations/types.js +1 -1
- package/dist/esm/conversations/types.js.map +2 -2
- package/dist/esm/index.js +1 -1
- package/dist/esm/index.js.map +3 -3
- package/dist/esm/persistence/adapters/sqlite/sqlite.js +18 -14
- package/dist/esm/persistence/adapters/sqlite/sqlite.js.map +3 -3
- package/dist/esm/pipeflow/index.js +2 -0
- package/dist/esm/pipeflow/index.js.map +7 -0
- package/dist/esm/pipeflow/pipeflow.js +2 -0
- package/dist/esm/pipeflow/pipeflow.js.map +7 -0
- package/dist/esm/providers/index.js +1 -1
- package/dist/esm/providers/index.js.map +3 -3
- package/dist/esm/providers/llm/adapters/claude/claude.js +5 -0
- package/dist/esm/providers/llm/adapters/claude/claude.js.map +7 -0
- package/dist/esm/providers/llm/adapters/claude/index.js +2 -0
- package/dist/esm/providers/llm/adapters/claude/index.js.map +7 -0
- package/dist/esm/providers/llm/adapters/deepseek/deepseek.js +1 -1
- package/dist/esm/providers/llm/adapters/deepseek/deepseek.js.map +3 -3
- package/dist/esm/providers/llm/adapters/index.js +1 -1
- package/dist/esm/providers/llm/adapters/index.js.map +3 -3
- package/dist/esm/providers/llm/adapters/openai/index.js +2 -0
- package/dist/esm/providers/llm/adapters/openai/index.js.map +7 -0
- package/dist/esm/providers/llm/adapters/openai/openai.js +2 -0
- package/dist/esm/providers/llm/adapters/openai/openai.js.map +7 -0
- package/dist/esm/providers/llm/adapters/openai-compatible.js +10 -0
- package/dist/esm/providers/llm/adapters/openai-compatible.js.map +7 -0
- package/dist/esm/providers/llm/adapters/openrouter/index.js +2 -0
- package/dist/esm/providers/llm/adapters/openrouter/index.js.map +7 -0
- package/dist/esm/providers/llm/adapters/openrouter/openrouter.js +2 -0
- package/dist/esm/providers/llm/adapters/openrouter/openrouter.js.map +7 -0
- package/dist/esm/providers/llm/index.js +1 -1
- package/dist/esm/providers/llm/index.js.map +3 -3
- package/dist/esm/providers/llm/toolmode/index.js +2 -0
- package/dist/esm/providers/llm/toolmode/index.js.map +7 -0
- package/dist/esm/providers/llm/toolmode/toolmode.js +2 -0
- package/dist/esm/providers/llm/toolmode/toolmode.js.map +7 -0
- package/dist/esm/providers/llm/types.js +1 -0
- package/dist/esm/providers/llm/types.js.map +4 -4
- package/dist/esm/providers/stt/adapters/deepgram/deepgram.js +1 -1
- package/dist/esm/providers/stt/adapters/deepgram/deepgram.js.map +3 -3
- package/dist/esm/providers/stt/adapters/index.js +1 -1
- package/dist/esm/providers/stt/adapters/index.js.map +3 -3
- package/dist/esm/providers/stt/adapters/openrouter/index.js +2 -0
- package/dist/esm/providers/stt/adapters/openrouter/index.js.map +7 -0
- package/dist/esm/providers/stt/adapters/openrouter/openrouter.js +2 -0
- package/dist/esm/providers/stt/adapters/openrouter/openrouter.js.map +7 -0
- package/dist/esm/providers/tts/adapters/index.js +1 -1
- package/dist/esm/providers/tts/adapters/index.js.map +3 -3
- package/dist/esm/providers/tts/adapters/kokoro/kokoro.js +4 -1
- package/dist/esm/providers/tts/adapters/kokoro/kokoro.js.map +3 -3
- package/dist/esm/providers/tts/adapters/openrouter/index.js +2 -0
- package/dist/esm/providers/tts/adapters/openrouter/index.js.map +7 -0
- package/dist/esm/providers/tts/adapters/openrouter/openrouter.js +2 -0
- package/dist/esm/providers/tts/adapters/openrouter/openrouter.js.map +7 -0
- package/dist/esm/transport/streamobject/field-stream/field-stream.js +2 -0
- package/dist/esm/transport/streamobject/field-stream/field-stream.js.map +7 -0
- package/dist/esm/transport/streamobject/field-stream/index.js +2 -0
- package/dist/esm/transport/streamobject/field-stream/index.js.map +7 -0
- package/dist/esm/transport/streamobject/index.js +2 -0
- package/dist/esm/transport/streamobject/index.js.map +7 -0
- package/dist/esm/transport/streamobject/json-adapter/index.js +2 -0
- package/dist/esm/transport/streamobject/json-adapter/index.js.map +7 -0
- package/dist/esm/transport/streamobject/json-adapter/json-adapter.js +4 -0
- package/dist/esm/transport/streamobject/json-adapter/json-adapter.js.map +7 -0
- package/dist/esm/transport/streamobject/reference/index.js +2 -0
- package/dist/esm/transport/streamobject/reference/index.js.map +7 -0
- package/dist/esm/transport/streamobject/reference/reference.js +2 -0
- package/dist/esm/transport/streamobject/reference/reference.js.map +7 -0
- package/dist/esm/transport/streamobject/stream-object/index.js +2 -0
- package/dist/esm/transport/streamobject/stream-object/index.js.map +7 -0
- package/dist/esm/transport/streamobject/stream-object/stream-object.js +2 -0
- package/dist/esm/transport/streamobject/stream-object/stream-object.js.map +7 -0
- package/dist/types/agents/agent.d.ts +3 -0
- package/dist/types/agents/tools/tools.d.ts +28 -6
- package/dist/types/conversations/conversation/conversation.d.ts +85 -6
- package/dist/types/conversations/conversations.d.ts +11 -1
- package/dist/types/conversations/index.d.ts +2 -1
- package/dist/types/conversations/orchestration/coordination/coordination.d.ts +192 -0
- package/dist/types/conversations/orchestration/coordination/index.d.ts +2 -0
- package/dist/types/conversations/orchestration/orchestrator/coordination-runner/coordination-runner.d.ts +108 -0
- package/dist/types/conversations/orchestration/orchestrator/coordination-runner/index.d.ts +2 -0
- package/dist/types/conversations/orchestration/orchestrator/generation/generation.d.ts +43 -0
- package/dist/types/conversations/orchestration/orchestrator/generation/index.d.ts +2 -0
- package/dist/types/conversations/orchestration/orchestrator/history/history.d.ts +62 -0
- package/dist/types/conversations/orchestration/orchestrator/history/index.d.ts +1 -0
- package/dist/types/conversations/orchestration/orchestrator/index.d.ts +10 -0
- package/dist/types/conversations/orchestration/orchestrator/orchestrator.d.ts +45 -27
- package/dist/types/conversations/orchestration/orchestrator/routing/index.d.ts +1 -0
- package/dist/types/conversations/orchestration/orchestrator/routing/routing.d.ts +19 -0
- package/dist/types/conversations/orchestration/orchestrator/speech/index.d.ts +2 -0
- package/dist/types/conversations/orchestration/orchestrator/speech/speech.d.ts +49 -0
- package/dist/types/conversations/orchestration/orchestrator/tools/index.d.ts +2 -0
- package/dist/types/conversations/orchestration/orchestrator/tools/tools.d.ts +31 -0
- package/dist/types/conversations/orchestration/test-harness.d.ts +96 -0
- package/dist/types/conversations/orchestration/text-chunker/index.d.ts +1 -0
- package/dist/types/conversations/orchestration/text-chunker/text-chunker.d.ts +39 -0
- package/dist/types/conversations/stream/conversation-stream.d.ts +42 -0
- package/dist/types/conversations/stream/index.d.ts +1 -0
- package/dist/types/conversations/types.d.ts +32 -0
- package/dist/types/index.d.ts +5 -38
- package/dist/types/pipeflow/index.d.ts +2 -0
- package/dist/types/pipeflow/pipeflow.d.ts +35 -0
- package/dist/types/providers/index.d.ts +1 -1
- package/dist/types/providers/llm/adapters/claude/claude.d.ts +45 -0
- package/dist/types/providers/llm/adapters/claude/index.d.ts +2 -0
- package/dist/types/providers/llm/adapters/deepseek/deepseek.d.ts +23 -2
- package/dist/types/providers/llm/adapters/index.d.ts +3 -0
- package/dist/types/providers/llm/adapters/openai/index.d.ts +2 -0
- package/dist/types/providers/llm/adapters/openai/openai.d.ts +45 -0
- package/dist/types/providers/llm/adapters/openai-compatible.d.ts +44 -0
- package/dist/types/providers/llm/adapters/openrouter/index.d.ts +2 -0
- package/dist/types/providers/llm/adapters/openrouter/openrouter.d.ts +60 -0
- package/dist/types/providers/llm/index.d.ts +5 -2
- package/dist/types/providers/llm/toolmode/index.d.ts +2 -0
- package/dist/types/providers/llm/toolmode/toolmode.d.ts +99 -0
- package/dist/types/providers/llm/types.d.ts +62 -0
- package/dist/types/providers/stt/adapters/deepgram/deepgram.d.ts +4 -1
- package/dist/types/providers/stt/adapters/index.d.ts +1 -0
- package/dist/types/providers/stt/adapters/openrouter/index.d.ts +2 -0
- package/dist/types/providers/stt/adapters/openrouter/openrouter.d.ts +94 -0
- package/dist/types/providers/tts/adapters/index.d.ts +1 -0
- package/dist/types/providers/tts/adapters/kokoro/kokoro.d.ts +17 -2
- package/dist/types/providers/tts/adapters/openrouter/index.d.ts +2 -0
- package/dist/types/providers/tts/adapters/openrouter/openrouter.d.ts +45 -0
- package/dist/types/transport/streamobject/field-stream/field-stream.d.ts +85 -0
- package/dist/types/transport/streamobject/field-stream/index.d.ts +2 -0
- package/dist/types/transport/streamobject/index.d.ts +8 -0
- package/dist/types/transport/streamobject/json-adapter/index.d.ts +2 -0
- package/dist/types/transport/streamobject/json-adapter/json-adapter.d.ts +65 -0
- package/dist/types/transport/streamobject/reference/index.d.ts +2 -0
- package/dist/types/transport/streamobject/reference/reference.d.ts +127 -0
- package/dist/types/transport/streamobject/stream-object/index.d.ts +2 -0
- package/dist/types/transport/streamobject/stream-object/stream-object.d.ts +31 -0
- package/package.json +23 -2
|
@@ -13,7 +13,10 @@ export interface STTSocket {
|
|
|
13
13
|
}
|
|
14
14
|
export interface DeepgramOptions extends STTOptions {
|
|
15
15
|
apiKey: string;
|
|
16
|
-
/**
|
|
16
|
+
/**
|
|
17
|
+
* Overrides the listen endpoint. Defaults to `wss://api.deepgram.com/v2/listen`
|
|
18
|
+
* for Flux models (`flux-*`) and `wss://api.deepgram.com/v1/listen` otherwise.
|
|
19
|
+
*/
|
|
17
20
|
endpoint?: string;
|
|
18
21
|
/** Injectable socket factory, mainly for tests. */
|
|
19
22
|
createSocket?: (url: string) => STTSocket;
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import type { STT, STTOptions, STTSession } from "../../types.js";
|
|
2
|
+
import type { FetchLike } from "../../../shared.js";
|
|
3
|
+
/** Audio formats the OpenRouter transcription endpoint accepts. */
|
|
4
|
+
export type OpenRouterAudioFormat = "pcm" | "mp3" | "flac" | "m4a" | "ogg" | "webm" | "aac";
|
|
5
|
+
export interface OpenRouterSTTOptions extends STTOptions {
|
|
6
|
+
apiKey: string;
|
|
7
|
+
/** Defaults to `https://openrouter.ai/api/v1`. */
|
|
8
|
+
baseUrl?: string;
|
|
9
|
+
/** The STT model. Defaults to `openai/whisper-large-v3-turbo`. */
|
|
10
|
+
model?: string;
|
|
11
|
+
/**
|
|
12
|
+
* Silence (ms) that ends an utterance. OpenRouter's transcription endpoint
|
|
13
|
+
* is batch-only (one request per audio clip), so the adapter segments the
|
|
14
|
+
* incoming stream client-side and transcribes a clip once this much silence
|
|
15
|
+
* has elapsed since the last audio. Default 800.
|
|
16
|
+
*/
|
|
17
|
+
silenceMs?: number;
|
|
18
|
+
/**
|
|
19
|
+
* Format of the audio written to the session. `"pcm"` (the default)
|
|
20
|
+
* assumes raw linear16 samples at `sampleRate` and wraps each clip in a
|
|
21
|
+
* WAV container. Pass the actual encoding (e.g. `"mp3"`, `"ogg"`, …) when
|
|
22
|
+
* feeding pre-encoded audio — those formats are self-describing and are
|
|
23
|
+
* sent as-is.
|
|
24
|
+
*/
|
|
25
|
+
audioFormat?: OpenRouterAudioFormat;
|
|
26
|
+
/** Injectable fetch, mainly for tests. */
|
|
27
|
+
fetch?: FetchLike;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* OpenRouter batch STT adapter (`POST /api/v1/audio/transcriptions`).
|
|
31
|
+
*
|
|
32
|
+
* OpenRouter does not stream transcripts — it transcribes a complete audio
|
|
33
|
+
* clip and returns the text. The adapter therefore buffers the raw audio
|
|
34
|
+
* written by `write()`, assumes linear16 PCM (mono, `sampleRate`, default
|
|
35
|
+
* 16 kHz — matching the Deepgram adapter's defaults), wraps each utterance
|
|
36
|
+
* in a WAV header, and posts it after `silenceMs` of silence. Interim
|
|
37
|
+
* results are unavailable, so no `partial` events are ever emitted: a turn
|
|
38
|
+
* arrives whole at the `final` event once its clip has been transcribed.
|
|
39
|
+
*
|
|
40
|
+
* `language` accepts an ISO-639-1 code to force a language (which whisper
|
|
41
|
+
* docs say improves accuracy and latency); omitting it — or passing `"auto"`,
|
|
42
|
+
* the whisper convention, which is normalized to "omit" — leaves detection to
|
|
43
|
+
* the provider, matching OpenRouter's "auto-detected if omitted" contract.
|
|
44
|
+
*
|
|
45
|
+
* By default the written audio is treated as raw linear16 PCM and wrapped in
|
|
46
|
+
* a WAV container; set `audioFormat` to the real encoding (e.g. `"mp3"`) to
|
|
47
|
+
* send pre-encoded audio as-is instead.
|
|
48
|
+
*
|
|
49
|
+
* `end()` transcribes any remaining buffered audio; `cancel()` drops
|
|
50
|
+
* buffered audio and aborts in-flight requests.
|
|
51
|
+
*/
|
|
52
|
+
export declare class OpenRouterSTT implements STT {
|
|
53
|
+
private readonly options;
|
|
54
|
+
private readonly sessions;
|
|
55
|
+
constructor(options: OpenRouterSTTOptions);
|
|
56
|
+
start(options?: STTOptions): STTSession;
|
|
57
|
+
cancel(): void;
|
|
58
|
+
}
|
|
59
|
+
export declare class OpenRouterSession implements STTSession {
|
|
60
|
+
private readonly listeners;
|
|
61
|
+
private readonly apiKey;
|
|
62
|
+
private readonly baseUrl;
|
|
63
|
+
private readonly model;
|
|
64
|
+
private readonly language;
|
|
65
|
+
private readonly sampleRate;
|
|
66
|
+
private readonly silenceMs;
|
|
67
|
+
private readonly audioFormat;
|
|
68
|
+
private readonly fetchImpl;
|
|
69
|
+
private chunks;
|
|
70
|
+
private timer;
|
|
71
|
+
private chain;
|
|
72
|
+
private readonly controllers;
|
|
73
|
+
private ended;
|
|
74
|
+
private aborted;
|
|
75
|
+
constructor(options: OpenRouterSTTOptions);
|
|
76
|
+
write(audio: Uint8Array): void;
|
|
77
|
+
end(): Promise<void>;
|
|
78
|
+
/** Drop buffered audio and abort in-flight requests (cancel). */
|
|
79
|
+
abort(): void;
|
|
80
|
+
on(event: "partial", listener: (transcript: string) => void): void;
|
|
81
|
+
on(event: "final", listener: (transcript: string) => void): void;
|
|
82
|
+
on(event: "error", listener: (error: Error) => void): void;
|
|
83
|
+
on(event: "close", listener: () => void): void;
|
|
84
|
+
/** Queue a transcription of whatever audio is buffered (serialized). */
|
|
85
|
+
private flush;
|
|
86
|
+
private takeBuffer;
|
|
87
|
+
private transcribe;
|
|
88
|
+
private emit;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Wrap linear16 PCM (mono) in a minimal WAV container so whisper can read it.
|
|
92
|
+
* The header is the standard 44-byte RIFF/WAVE layout.
|
|
93
|
+
*/
|
|
94
|
+
export declare function toWav(pcm: Uint8Array, sampleRate: number): Uint8Array;
|
|
@@ -4,21 +4,35 @@ export interface KokoroOptions {
|
|
|
4
4
|
/**
|
|
5
5
|
* Base URL of a Kokoro TTS server exposing the OpenAI-compatible
|
|
6
6
|
* `/v1/audio/speech` endpoint. Defaults to a local kokoro-fastapi server.
|
|
7
|
+
* For Together AI use `https://api.together.ai`.
|
|
7
8
|
*/
|
|
8
9
|
baseUrl?: string;
|
|
9
10
|
/** Default voice, e.g. `af_heart`. */
|
|
10
11
|
voice?: string;
|
|
12
|
+
/**
|
|
13
|
+
* Model name. Defaults to `kokoro` (local kokoro-fastapi); Together AI
|
|
14
|
+
* serves the model as `hexgrad/Kokoro-82M`.
|
|
15
|
+
*/
|
|
11
16
|
model?: string;
|
|
12
17
|
apiKey?: string;
|
|
13
18
|
/** Size of the audio chunks yielded from the response stream. */
|
|
14
19
|
chunkSize?: number;
|
|
20
|
+
/**
|
|
21
|
+
* Ask the server for progressive (streaming) synthesis. Local
|
|
22
|
+
* kokoro-fastapi streams by default; hosted endpoints such as Together AI
|
|
23
|
+
* require this flag. Together AI responds with server-sent events carrying
|
|
24
|
+
* base64-encoded audio deltas (pcm_s16le, 24 kHz for Kokoro) terminated by
|
|
25
|
+
* `data: [DONE]`; the adapter decodes them into raw audio chunks. wav/mp3
|
|
26
|
+
* formats are not streamable.
|
|
27
|
+
*/
|
|
28
|
+
stream?: boolean;
|
|
15
29
|
/** Injectable fetch implementation, mainly for tests. */
|
|
16
30
|
fetch?: FetchLike;
|
|
17
31
|
}
|
|
18
32
|
/**
|
|
19
33
|
* Kokoro TTS adapter. Consumes a Kokoro server's OpenAI-compatible speech
|
|
20
|
-
* endpoint
|
|
21
|
-
* arrives.
|
|
34
|
+
* endpoint (local kokoro-fastapi or a hosted service such as Together AI)
|
|
35
|
+
* and re-chunks the returned audio so it can be played as it arrives.
|
|
22
36
|
*/
|
|
23
37
|
export declare class KokoroTTS implements TTS {
|
|
24
38
|
private readonly baseUrl;
|
|
@@ -26,6 +40,7 @@ export declare class KokoroTTS implements TTS {
|
|
|
26
40
|
private readonly model;
|
|
27
41
|
private readonly apiKey;
|
|
28
42
|
private readonly chunkSize;
|
|
43
|
+
private readonly streaming;
|
|
29
44
|
private readonly fetchImpl;
|
|
30
45
|
private abort;
|
|
31
46
|
constructor(options?: KokoroOptions);
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { TTS, TTSRequest } from "../../types.js";
|
|
2
|
+
import type { FetchLike } from "../../../shared.js";
|
|
3
|
+
export interface OpenRouterTTSOptions {
|
|
4
|
+
apiKey: string;
|
|
5
|
+
/** Defaults to `https://openrouter.ai/api/v1`. */
|
|
6
|
+
baseUrl?: string;
|
|
7
|
+
/**
|
|
8
|
+
* TTS model. Defaults to the free `fish-audio/s2.1-pro-free:free` variant —
|
|
9
|
+
* fast, per-character priced. Pass `fish-audio/s2.1-pro` for the paid tier
|
|
10
|
+
* (no free-variant rate limits).
|
|
11
|
+
*/
|
|
12
|
+
model?: string;
|
|
13
|
+
/**
|
|
14
|
+
* Default voice, sent when the request carries none. Omitted entirely when
|
|
15
|
+
* unset: providers with a built-in default voice (e.g. fish-audio) accept
|
|
16
|
+
* omission, and some reject an explicit `voice` outright — while providers
|
|
17
|
+
* that require one (e.g. OpenAI TTS) need it set. Voice support varies by
|
|
18
|
+
* model and provider.
|
|
19
|
+
*/
|
|
20
|
+
voice?: string;
|
|
21
|
+
/** Size of the audio chunks yielded from the response stream. Default 8192. */
|
|
22
|
+
chunkSize?: number;
|
|
23
|
+
/** Injectable fetch, mainly for tests. */
|
|
24
|
+
fetch?: FetchLike;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* OpenRouter TTS adapter (`POST /api/v1/audio/speech`, OpenAI-compatible).
|
|
28
|
+
*
|
|
29
|
+
* The endpoint returns raw audio bytes (not JSON) in `mp3` or `pcm` format.
|
|
30
|
+
* The adapter re-chunks the response stream so audio can be played as it
|
|
31
|
+
* arrives; `stop()` aborts the in-flight synthesis. `pcm` is the default
|
|
32
|
+
* output (OpenRouter's own recommendation for realtime pipelines).
|
|
33
|
+
*/
|
|
34
|
+
export declare class OpenRouterTTS implements TTS {
|
|
35
|
+
private readonly apiKey;
|
|
36
|
+
private readonly baseUrl;
|
|
37
|
+
private readonly model;
|
|
38
|
+
private readonly voice;
|
|
39
|
+
private readonly chunkSize;
|
|
40
|
+
private readonly fetchImpl;
|
|
41
|
+
private abort;
|
|
42
|
+
constructor(options: OpenRouterTTSOptions);
|
|
43
|
+
stop(): void;
|
|
44
|
+
stream(request: TTSRequest): AsyncGenerator<Uint8Array>;
|
|
45
|
+
}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* FieldStream — the semantic completion core shared by every source adapter.
|
|
3
|
+
*
|
|
4
|
+
* A FieldStream registers completion handlers (`when`/`whenItem`/`whenObjectDone`)
|
|
5
|
+
* and dispatches completion events to them. It knows nothing about JSON, wire
|
|
6
|
+
* records, SSE, or any particular producer: subclasses turn their source into
|
|
7
|
+
* completion events via the protected emit helpers.
|
|
8
|
+
*
|
|
9
|
+
* Implementations:
|
|
10
|
+
* - StreamObject — consumes an AsyncIterable of text chunks (JSON source)
|
|
11
|
+
* - ConversationStream — consumes conversation events (provider-native source)
|
|
12
|
+
*
|
|
13
|
+
* Lifecycle, per object:
|
|
14
|
+
*
|
|
15
|
+
* STREAMING ──emitObject──▶ DONE
|
|
16
|
+
* │
|
|
17
|
+
* ├──cancel()──▶ CANCELLED
|
|
18
|
+
* └──fail()────▶ FAILED
|
|
19
|
+
*
|
|
20
|
+
* Exactly-once: within an object, completion handlers fire at most once per
|
|
21
|
+
* boundary and never after a terminal state (events after DONE/CANCELLED/
|
|
22
|
+
* FAILED are dropped). cancel() is idempotent. Multi-object sources call
|
|
23
|
+
* beginObject() to start each object.
|
|
24
|
+
*
|
|
25
|
+
* `when` means completion, not mutation: handlers never see chunks or source
|
|
26
|
+
* format. Handlers are invoked synchronously at the completion boundary and
|
|
27
|
+
* never block the producer; async handlers run concurrently and their
|
|
28
|
+
* rejections are routed to onError.
|
|
29
|
+
*
|
|
30
|
+
* Errors: delivered to onError handlers when registered; otherwise the
|
|
31
|
+
* subclass decides (StreamObject rejects start(); callers of `fail()` get the
|
|
32
|
+
* throw).
|
|
33
|
+
*/
|
|
34
|
+
import type { Event, FieldValue, ScalarValue, Schema } from "../reference/reference.js";
|
|
35
|
+
export type FieldHandler = (value: FieldValue) => void;
|
|
36
|
+
export type ItemHandler = (value: ScalarValue, index: number) => void;
|
|
37
|
+
export type ObjectDoneHandler = (object: Record<string, unknown>) => void;
|
|
38
|
+
export type ErrorHandler = (error: Error) => void;
|
|
39
|
+
export interface FieldStreamOptions {
|
|
40
|
+
/** Invoked by cancel() — e.g. to abort the producer's request. */
|
|
41
|
+
onCancel?: () => void;
|
|
42
|
+
}
|
|
43
|
+
export declare abstract class FieldStream {
|
|
44
|
+
protected readonly schema: Schema;
|
|
45
|
+
private readonly fieldHandlers;
|
|
46
|
+
private readonly itemHandlers;
|
|
47
|
+
private readonly objectHandlers;
|
|
48
|
+
private readonly errorHandlers;
|
|
49
|
+
private readonly onCancel;
|
|
50
|
+
/** Stream-level: set by cancel(); consumed by source-driven subclasses. */
|
|
51
|
+
protected cancelled: boolean;
|
|
52
|
+
private objectState;
|
|
53
|
+
constructor(schema: Schema, options?: FieldStreamOptions);
|
|
54
|
+
when(field: string | string[], handler: FieldHandler): this;
|
|
55
|
+
whenItem(field: string | string[], handler: ItemHandler): this;
|
|
56
|
+
whenObjectDone(handler: ObjectDoneHandler): this;
|
|
57
|
+
onError(handler: ErrorHandler): this;
|
|
58
|
+
/**
|
|
59
|
+
* Abort the current object and stop the producer (idempotent). The object
|
|
60
|
+
* will not complete; already-delivered items remain valid partial state.
|
|
61
|
+
*/
|
|
62
|
+
cancel(): void;
|
|
63
|
+
/** Start a new object's lifecycle (multi-object sources call this per object). */
|
|
64
|
+
protected beginObject(): void;
|
|
65
|
+
/** Emit a completed field value (subclasses call this at the completion boundary). */
|
|
66
|
+
protected emitField(field: number, value: FieldValue): void;
|
|
67
|
+
/** Emit a completed array item. */
|
|
68
|
+
protected emitItem(field: number, index: number, value: ScalarValue): void;
|
|
69
|
+
/**
|
|
70
|
+
* Complete the current object: materializes and fires whenObjectDone exactly
|
|
71
|
+
* once (a second call, or a call after cancel/fail, is ignored).
|
|
72
|
+
*/
|
|
73
|
+
protected emitObject(events: Event[]): void;
|
|
74
|
+
/** Abort the current object without completing it (idempotent). */
|
|
75
|
+
protected cancelObject(): void;
|
|
76
|
+
/**
|
|
77
|
+
* Route a source/adapter failure to onError (or rethrow when unhandled) and
|
|
78
|
+
* mark the current object failed.
|
|
79
|
+
*/
|
|
80
|
+
protected fail(error: unknown): void;
|
|
81
|
+
protected get objectCompleted(): boolean;
|
|
82
|
+
protected resolveIndex(field: string | string[]): number;
|
|
83
|
+
private fire;
|
|
84
|
+
private dispatchError;
|
|
85
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { FieldStream } from "./field-stream/index.js";
|
|
2
|
+
export type { ErrorHandler, FieldHandler, FieldStreamOptions, ItemHandler, ObjectDoneHandler, } from "./field-stream/index.js";
|
|
3
|
+
export { StreamObject } from "./stream-object/index.js";
|
|
4
|
+
export type { StreamObjectOptions } from "./stream-object/index.js";
|
|
5
|
+
export { IncrementalJsonParser, JsonToStreamObjectAdapter } from "./json-adapter/index.js";
|
|
6
|
+
export type { JsonAdapterCallbacks, JsonValue } from "./json-adapter/index.js";
|
|
7
|
+
export { ReferenceDecoder, Receiver, decode, encodeText, executeRecords, materializeObject, parseBooleanPayload, parseIntegerPayload, parseNumberPayload, } from "./reference/index.js";
|
|
8
|
+
export type { Decoder, Event, FieldDef, FieldType, FieldValue, Payload, ScalarValue, Schema, StreamRecord, } from "./reference/index.js";
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Incremental JSON → StreamObject adapter.
|
|
3
|
+
*
|
|
4
|
+
* Consumes a JSON token stream (e.g. LLM output deltas) and emits StreamObject
|
|
5
|
+
* field-completion events as soon as each schema field's value is complete —
|
|
6
|
+
* without waiting for the rest of the object. This is the designed production
|
|
7
|
+
* shape of the protocol: the model emits ordinary output, deterministic
|
|
8
|
+
* software does the parsing, and consumers react at field boundaries.
|
|
9
|
+
*
|
|
10
|
+
* The wire encoding is irrelevant here; only the Event model matters.
|
|
11
|
+
*/
|
|
12
|
+
import type { Event, FieldValue, ScalarValue, Schema } from "../reference/reference.js";
|
|
13
|
+
export type JsonValue = string | number | boolean | null | JsonValue[] | {
|
|
14
|
+
[key: string]: JsonValue;
|
|
15
|
+
};
|
|
16
|
+
/** Minimal incremental JSON parser. Emits every completed value with its path. */
|
|
17
|
+
export declare class IncrementalJsonParser {
|
|
18
|
+
private readonly onValueDone;
|
|
19
|
+
private readonly stack;
|
|
20
|
+
private value;
|
|
21
|
+
private started;
|
|
22
|
+
private done;
|
|
23
|
+
constructor(onValueDone: (path: string[], value: JsonValue) => void);
|
|
24
|
+
push(chunk: string): void;
|
|
25
|
+
private pushChar;
|
|
26
|
+
private dispatch;
|
|
27
|
+
private startValue;
|
|
28
|
+
private feedValue;
|
|
29
|
+
private completeValue;
|
|
30
|
+
private closeContainer;
|
|
31
|
+
}
|
|
32
|
+
export interface JsonAdapterCallbacks {
|
|
33
|
+
onFieldDone?: (field: number, value: FieldValue) => void;
|
|
34
|
+
/** Fires for each completed array element, before the array field completes. */
|
|
35
|
+
onItemDone?: (field: number, index: number, value: ScalarValue) => void;
|
|
36
|
+
/** Fires when the root object closes. */
|
|
37
|
+
onObjectDone?: () => void;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Feeds a JSON token stream into the reference Event model and emits a
|
|
41
|
+
* completion hierarchy as soon as each piece is known:
|
|
42
|
+
*
|
|
43
|
+
* VALUE_COMPLETE → every parsed value (parser level, per path)
|
|
44
|
+
* ITEM_COMPLETE → each array element of an array-typed schema field
|
|
45
|
+
* FIELD_COMPLETE → a schema field's whole value (incl. a closed array)
|
|
46
|
+
* OBJECT_COMPLETE → the object closed
|
|
47
|
+
*
|
|
48
|
+
* The v0.1 wire decoder only exposes FIELD/OBJECT; item completion is a
|
|
49
|
+
* semantic projection of array boundaries that every source already carries
|
|
50
|
+
* (each JSON array element, each array append), not a wire record. Strictly
|
|
51
|
+
* typed against the schema — a value that violates its field type throws.
|
|
52
|
+
*/
|
|
53
|
+
export declare class JsonToStreamObjectAdapter {
|
|
54
|
+
private readonly fields;
|
|
55
|
+
private readonly parser;
|
|
56
|
+
private readonly events;
|
|
57
|
+
private readonly onFieldDone;
|
|
58
|
+
private readonly onItemDone;
|
|
59
|
+
private readonly onObjectDone;
|
|
60
|
+
constructor(schema: Schema, callbacks?: JsonAdapterCallbacks);
|
|
61
|
+
push(chunk: string): void;
|
|
62
|
+
getEvents(): Event[];
|
|
63
|
+
private handleValue;
|
|
64
|
+
private matchArrayItem;
|
|
65
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export { ReferenceDecoder, Receiver, decode, encodeText, executeRecords, materializeObject, parseBooleanPayload, parseIntegerPayload, parseNumberPayload, } from "./reference.js";
|
|
2
|
+
export type { Decoder, Event, FieldDef, FieldType, FieldValue, Payload, ScalarValue, Schema, StreamRecord, } from "./reference.js";
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* StreamObject Protocol v0.1 — reference implementation (the executable spec).
|
|
3
|
+
*
|
|
4
|
+
* Deliberately boring: no arena, no pooling, no typed-array chunk chains.
|
|
5
|
+
* Its purpose is to pin down semantics so the optimized receiver can be
|
|
6
|
+
* validated against it instead of inventing behavior.
|
|
7
|
+
*
|
|
8
|
+
* Layering:
|
|
9
|
+
* records --(encodeText)--> text --(fragment)--> chunks
|
|
10
|
+
* chunks --(ReferenceDecoder)--> events
|
|
11
|
+
* records --(Receiver / executeRecords)--> events <- the oracle
|
|
12
|
+
*
|
|
13
|
+
* Contract (the property every decoder must satisfy):
|
|
14
|
+
* decode(fragment(encodeText(records))) === executeRecords(records)
|
|
15
|
+
*
|
|
16
|
+
* See README.md (in this directory) for the normative spec this implements.
|
|
17
|
+
*/
|
|
18
|
+
export type Payload = string;
|
|
19
|
+
export type StreamRecord = {
|
|
20
|
+
kind: "append";
|
|
21
|
+
field: number;
|
|
22
|
+
payload: Payload;
|
|
23
|
+
} | {
|
|
24
|
+
kind: "complete";
|
|
25
|
+
field: number;
|
|
26
|
+
} | {
|
|
27
|
+
kind: "object-complete";
|
|
28
|
+
} | {
|
|
29
|
+
kind: "object-abort";
|
|
30
|
+
};
|
|
31
|
+
export type FieldType = "string" | "integer" | "number" | "boolean";
|
|
32
|
+
export interface FieldDef {
|
|
33
|
+
path: string[];
|
|
34
|
+
type: FieldType;
|
|
35
|
+
mode?: "array";
|
|
36
|
+
/** Required for array fields. */
|
|
37
|
+
maxItems?: number;
|
|
38
|
+
/** Scalar: cap on accumulated payload length. Array: cap per item. */
|
|
39
|
+
maxLength?: number;
|
|
40
|
+
}
|
|
41
|
+
export type Schema = FieldDef[];
|
|
42
|
+
export type ScalarValue = string | number | boolean;
|
|
43
|
+
export type FieldValue = ScalarValue | ScalarValue[];
|
|
44
|
+
export type Event = {
|
|
45
|
+
kind: "field";
|
|
46
|
+
field: number;
|
|
47
|
+
value: FieldValue;
|
|
48
|
+
}
|
|
49
|
+
/** Adapter-observable item completion (arrays); not emitted by the v0.1 wire decoder. */
|
|
50
|
+
| {
|
|
51
|
+
kind: "item";
|
|
52
|
+
field: number;
|
|
53
|
+
index: number;
|
|
54
|
+
value: ScalarValue;
|
|
55
|
+
} | {
|
|
56
|
+
kind: "object-complete";
|
|
57
|
+
} | {
|
|
58
|
+
kind: "object-abort";
|
|
59
|
+
};
|
|
60
|
+
export declare function parseIntegerPayload(s: string): number | null;
|
|
61
|
+
export declare function parseNumberPayload(s: string): number | null;
|
|
62
|
+
export declare function parseBooleanPayload(s: string): boolean | null;
|
|
63
|
+
export declare class Receiver {
|
|
64
|
+
private readonly schema;
|
|
65
|
+
private readonly state;
|
|
66
|
+
private readonly acc;
|
|
67
|
+
private readonly events;
|
|
68
|
+
private readonly onEvent;
|
|
69
|
+
private ended;
|
|
70
|
+
constructor(schema: Schema, onEvent?: (event: Event) => void);
|
|
71
|
+
append(field: number, payload: string): void;
|
|
72
|
+
complete(field: number): void;
|
|
73
|
+
objectComplete(): void;
|
|
74
|
+
objectAbort(): void;
|
|
75
|
+
getEvents(): Event[];
|
|
76
|
+
get isEnded(): boolean;
|
|
77
|
+
private assertActive;
|
|
78
|
+
private assertField;
|
|
79
|
+
private emit;
|
|
80
|
+
}
|
|
81
|
+
/** The oracle: execute logical records directly. */
|
|
82
|
+
export declare function executeRecords(schema: Schema, records: StreamRecord[]): Event[];
|
|
83
|
+
export declare function materializeObject(schema: Schema, events: Event[]): Record<string, unknown>;
|
|
84
|
+
export declare function encodeText(records: StreamRecord[]): string;
|
|
85
|
+
/**
|
|
86
|
+
* The contract every implementation (including the future arena-backed
|
|
87
|
+
* receiver) must satisfy:
|
|
88
|
+
*
|
|
89
|
+
* push(fragment(encodeText(records))) + end() === executeRecords(schema, records)
|
|
90
|
+
*/
|
|
91
|
+
export interface Decoder {
|
|
92
|
+
push(chunk: string): void;
|
|
93
|
+
end(): Event[];
|
|
94
|
+
}
|
|
95
|
+
export declare class ReferenceDecoder implements Decoder {
|
|
96
|
+
private readonly receiver;
|
|
97
|
+
private state;
|
|
98
|
+
private fieldId;
|
|
99
|
+
private length;
|
|
100
|
+
private payload;
|
|
101
|
+
private remaining;
|
|
102
|
+
constructor(schema: Schema, onEvent?: (event: Event) => void);
|
|
103
|
+
push(chunk: string): void;
|
|
104
|
+
end(): Event[];
|
|
105
|
+
private onHeader;
|
|
106
|
+
private onFieldId;
|
|
107
|
+
private onLength;
|
|
108
|
+
private onPayload;
|
|
109
|
+
private onPayloadEnd;
|
|
110
|
+
private onControl;
|
|
111
|
+
private onAbort;
|
|
112
|
+
private reset;
|
|
113
|
+
}
|
|
114
|
+
/** Decode a sequence of transport chunks into events. */
|
|
115
|
+
export declare function decode(chunks: string[], schema: Schema): Event[];
|
|
116
|
+
export type Rng = () => number;
|
|
117
|
+
export declare function mulberry32(seed: number): Rng;
|
|
118
|
+
export declare function fragment(text: string, rng: Rng): string[];
|
|
119
|
+
/** Every single-cut fragmentation of a message. */
|
|
120
|
+
export declare function allSingleCuts(text: string): string[][];
|
|
121
|
+
/** Every composition into 1..n chunks — 2^(n-1) cases. Only for small messages. */
|
|
122
|
+
export declare function allCompositions(text: string): string[][];
|
|
123
|
+
export declare function randomSchema(rng: Rng): Schema;
|
|
124
|
+
/** Records for one field: appends (one item each for arrays), maybe a completion. */
|
|
125
|
+
export declare function fieldRecords(rng: Rng, schema: Schema, field: number): StreamRecord[];
|
|
126
|
+
/** A valid record sequence for the schema, randomly scheduled. */
|
|
127
|
+
export declare function generateValidRecords(rng: Rng, schema: Schema): StreamRecord[];
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* StreamObject — consumes an AsyncIterable of text chunks through the
|
|
3
|
+
* incremental JSON adapter and exposes the FieldStream completion API.
|
|
4
|
+
*
|
|
5
|
+
* const stream = new StreamObject(source, schema);
|
|
6
|
+
* stream.when("summary", (summary) => { ... }); // field completion
|
|
7
|
+
* stream.whenItem("searchQueries", (query, i) => { ... }); // item completion
|
|
8
|
+
* stream.whenObjectDone((object) => { ... }); // whole object
|
|
9
|
+
* stream.onError((error) => { ... }); // failures
|
|
10
|
+
* await stream.start();
|
|
11
|
+
*
|
|
12
|
+
* `when` means completion, not mutation: handlers never see chunks, JSON,
|
|
13
|
+
* SSE, or the wire codec. Handlers are invoked synchronously at the
|
|
14
|
+
* completion boundary and never block the source; async handlers run
|
|
15
|
+
* concurrently and their rejections are routed to onError. `cancel()` stops
|
|
16
|
+
* the source and invokes the optional onCancel hook (e.g. to abort the
|
|
17
|
+
* producer's request).
|
|
18
|
+
*
|
|
19
|
+
* Errors: delivered to onError handlers when registered; otherwise start()
|
|
20
|
+
* rejects with the error. Cancelling the stream is not an error.
|
|
21
|
+
*/
|
|
22
|
+
import { FieldStream, type FieldStreamOptions } from "../field-stream/field-stream.js";
|
|
23
|
+
import type { Schema } from "../reference/reference.js";
|
|
24
|
+
export type { ErrorHandler, FieldHandler, FieldStreamOptions, ItemHandler, ObjectDoneHandler, } from "../field-stream/field-stream.js";
|
|
25
|
+
export type StreamObjectOptions = FieldStreamOptions;
|
|
26
|
+
export declare class StreamObject extends FieldStream {
|
|
27
|
+
private readonly source;
|
|
28
|
+
private started;
|
|
29
|
+
constructor(source: AsyncIterable<string>, schema: Schema, options?: StreamObjectOptions);
|
|
30
|
+
start(): Promise<void>;
|
|
31
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@moureau/pipeflow",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"private": false,
|
|
6
6
|
"sideEffects": false,
|
|
@@ -63,13 +63,31 @@
|
|
|
63
63
|
"import": "./dist/esm/transport/*/index.js",
|
|
64
64
|
"require": "./dist/cjs/transport/*/index.js",
|
|
65
65
|
"default": "./dist/esm/transport/*/index.js"
|
|
66
|
+
},
|
|
67
|
+
"./conversations": {
|
|
68
|
+
"types": "./dist/types/conversations/index.d.ts",
|
|
69
|
+
"import": "./dist/esm/conversations/index.js",
|
|
70
|
+
"require": "./dist/cjs/conversations/index.js",
|
|
71
|
+
"default": "./dist/esm/conversations/index.js"
|
|
72
|
+
},
|
|
73
|
+
"./conversations/*": {
|
|
74
|
+
"types": "./dist/types/conversations/*/index.d.ts",
|
|
75
|
+
"import": "./dist/esm/conversations/*/index.js",
|
|
76
|
+
"require": "./dist/cjs/conversations/*/index.js",
|
|
77
|
+
"default": "./dist/esm/conversations/*/index.js"
|
|
66
78
|
}
|
|
67
79
|
},
|
|
68
|
-
"files": [
|
|
80
|
+
"files": [
|
|
81
|
+
"dist"
|
|
82
|
+
],
|
|
69
83
|
"scripts": {
|
|
70
84
|
"build": "bun scripts/build.mjs",
|
|
71
85
|
"prepublishOnly": "bun run build",
|
|
72
86
|
"test": "bun test",
|
|
87
|
+
"test:unit": "bun test src/index.test.ts src/agents src/conversations src/providers src/persistence src/transport",
|
|
88
|
+
"test:e2e": "bun test src/e2e",
|
|
89
|
+
"benchmark": "bun scripts/benchmark.ts",
|
|
90
|
+
"benchmark:stream": "bun scripts/benchmark-conversation-stream.ts",
|
|
73
91
|
"typecheck": "bunx tsc --noEmit"
|
|
74
92
|
},
|
|
75
93
|
"devDependencies": {
|
|
@@ -78,5 +96,8 @@
|
|
|
78
96
|
},
|
|
79
97
|
"peerDependencies": {
|
|
80
98
|
"typescript": "^5"
|
|
99
|
+
},
|
|
100
|
+
"dependencies": {
|
|
101
|
+
"zod": "^4.4.3"
|
|
81
102
|
}
|
|
82
103
|
}
|