@voicelayer/sdk 0.2.0 → 0.3.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.
@@ -1,4 +1,4 @@
1
- export { ab as GraphTraceEvent, ac as LiveTextConversation, ad as LiveTurnResult, ae as RunLiveTextOptions, u as RunTextSessionOptions, v as RunTextTranscriptOptions, V as TextSession, W as TextTranscriptResult, af as runLiveTextConversation, a8 as runTextSession, a9 as runTextTranscript, ag as runWithOpenAIScope } from '../text-session-BqMWaNsN.js';
1
+ export { ab as GraphTraceEvent, ac as LiveTextConversation, ad as LiveTurnResult, ae as RunLiveTextOptions, u as RunTextSessionOptions, v as RunTextTranscriptOptions, V as TextSession, W as TextTranscriptResult, af as runLiveTextConversation, a8 as runTextSession, a9 as runTextTranscript, ag as runWithOpenAIScope } from '../text-session-B7oyrhwQ.js';
2
2
  import '@livekit/agents';
3
3
  import 'zod';
4
4
  import 'openai';
@@ -493,6 +493,10 @@ var init_agents = __esm({
493
493
  // fail registration outright (which agent.ts swallows → agent runs but never
494
494
  // registers/heartbeats).
495
495
  prompt: z.string().max(64e3).nullable().optional(),
496
+ // The text-turn protocol this worker speaks (burn-down G-4): it registers `<name>::text` and runs text turns as the
497
+ // agent. Absent = it can't (an older SDK, a puppet, a flow pool) — stored as null, so a downgrade stops text turns.
498
+ // Any version is accepted (a newer SDK never fails registration); the API decides which versions it dispatches to.
499
+ textTurns: z.number().int().min(1).max(1e3).optional(),
496
500
  // Opt into MCP exposure. When true the API upserts a matching agent_config
497
501
  // row keyed by (project_id, name, environment) so MCP / dashboard / REST
498
502
  // can list and inspect this agent's identity. When false / omitted, the
@@ -513,8 +517,8 @@ var init_agents = __esm({
513
517
  metadata: AgentMetadata,
514
518
  processSchema: ProcessSchemaDTO.nullable().optional(),
515
519
  // Whether this agent can run through the engine over text: a flow agent (its
516
- // compiled graph rides in processSchema.program) OR a code-first agent whose
517
- // base prompt was synced on register. Drives the dashboard's chat gate so it
520
+ // compiled graph rides in processSchema.program), a brain-connector agent, OR a
521
+ // code-first agent whose worker takes text turns (G-4). Drives the dashboard's chat gate so it
518
522
  // no longer hard-codes "flow only". Computed server-side; not stored. OPTIONAL
519
523
  // on the wire so a new worker validating a response from an OLD api pod during
520
524
  // a rolling deploy doesn't fail register/heartbeat on a missing field.
@@ -756,6 +760,55 @@ var init_call_events = __esm({
756
760
  });
757
761
  }
758
762
  });
763
+ var TextTurnHistoryEntry, TextTurnUsage, TextTurnErrorCode;
764
+ var init_text_turns = __esm({
765
+ "../contracts/src/text-turns.ts"() {
766
+ z.object({
767
+ mode: z.literal("text"),
768
+ turnId: z.string().uuid(),
769
+ projectId: z.string().min(1),
770
+ agentId: z.string().uuid()
771
+ });
772
+ TextTurnHistoryEntry = z.object({
773
+ role: z.enum(["user", "assistant"]),
774
+ content: z.string().max(16e3)
775
+ });
776
+ z.object({
777
+ turnId: z.string().uuid(),
778
+ agentId: z.string().uuid(),
779
+ /** The Line the message came in on (`sms`, `discord`, `web`, `playground`, …). */
780
+ channel: z.string().min(1).max(40),
781
+ /** The sender on that Line (phone number, Discord user, widget visitor) — the agent's caller-scoped memory key. */
782
+ from: z.string().min(1).max(200),
783
+ /** The conversation this turn belongs to (stable across turns) — the tool context's call id. */
784
+ conversationKey: z.string().min(1).max(300),
785
+ history: z.array(TextTurnHistoryEntry).max(80),
786
+ text: z.string().min(1).max(8e3),
787
+ /** When the API stops waiting; the worker stops the run before it. */
788
+ deadlineAt: z.string().datetime()
789
+ });
790
+ TextTurnUsage = z.object({
791
+ provider: z.string().min(1).max(60),
792
+ model: z.string().min(1).max(200),
793
+ inputTokens: z.number().int().nonnegative(),
794
+ outputTokens: z.number().int().nonnegative(),
795
+ /** Only a first-party worker's label is used; a customer's worker runs on its own key (the API decides). */
796
+ byok: z.boolean()
797
+ });
798
+ TextTurnErrorCode = z.enum(["agent_unavailable", "agent_timeout"]);
799
+ z.union([
800
+ z.object({
801
+ agentId: z.string().uuid(),
802
+ replies: z.array(z.string().max(16e3)).max(20),
803
+ usage: z.array(TextTurnUsage).max(50).default([])
804
+ }),
805
+ z.object({
806
+ agentId: z.string().uuid(),
807
+ error: z.object({ code: TextTurnErrorCode, detail: z.string().max(500).optional() })
808
+ })
809
+ ]);
810
+ }
811
+ });
759
812
  var VoiceConfig, ModelConfig, SttConfig, RealtimeConfig, PipelineMode, ToolBinding, ProcessFieldType, ProcessFieldSpec, ProcessCompleteWhen, ProcessBackendAckSpec, ProcessSpec, TriggerConditionSpec, TriggerActionSpec, TriggerSpec, RequiredInfoField, AgentConfig;
760
813
  var init_agent_config = __esm({
761
814
  "../contracts/src/agent-config.ts"() {
@@ -3441,6 +3494,7 @@ var init_src = __esm({
3441
3494
  init_agents();
3442
3495
  init_process_state();
3443
3496
  init_call_events();
3497
+ init_text_turns();
3444
3498
  init_call_plan();
3445
3499
  init_memory();
3446
3500
  init_participants();