@voicelayer/sdk 0.2.0 → 0.3.1

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-oMqJh6SF.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.
@@ -539,7 +543,12 @@ var init_agents = __esm({
539
543
  z.object({
540
544
  status: z.enum(["online", "degraded"]).optional(),
541
545
  statusDetail: z.string().max(512).optional(),
542
- metadata: AgentMetadata.optional()
546
+ metadata: AgentMetadata.optional(),
547
+ // The text-turn protocol the worker speaks (G-4), repeated on every heartbeat: a registration answered by an older API
548
+ // during a rollout drops the field, and the next heartbeat restores it. SDK ≥ 0.3.1 always sends it — `null` when the
549
+ // worker takes no text turns, so a leftover beat can't keep a stale "text-capable" alive either. Absent (an older SDK)
550
+ // leaves the stored value as is.
551
+ textTurns: z.number().int().min(1).max(1e3).nullable().optional()
543
552
  });
544
553
  z.object({
545
554
  agent: AgentDTO,
@@ -756,6 +765,55 @@ var init_call_events = __esm({
756
765
  });
757
766
  }
758
767
  });
768
+ var TextTurnHistoryEntry, TextTurnUsage, TextTurnErrorCode;
769
+ var init_text_turns = __esm({
770
+ "../contracts/src/text-turns.ts"() {
771
+ z.object({
772
+ mode: z.literal("text"),
773
+ turnId: z.string().uuid(),
774
+ projectId: z.string().min(1),
775
+ agentId: z.string().uuid()
776
+ });
777
+ TextTurnHistoryEntry = z.object({
778
+ role: z.enum(["user", "assistant"]),
779
+ content: z.string().max(16e3)
780
+ });
781
+ z.object({
782
+ turnId: z.string().uuid(),
783
+ agentId: z.string().uuid(),
784
+ /** The Line the message came in on (`sms`, `discord`, `web`, `playground`, …). */
785
+ channel: z.string().min(1).max(40),
786
+ /** The sender on that Line (phone number, Discord user, widget visitor) — the agent's caller-scoped memory key. */
787
+ from: z.string().min(1).max(200),
788
+ /** The conversation this turn belongs to (stable across turns) — the tool context's call id. */
789
+ conversationKey: z.string().min(1).max(300),
790
+ history: z.array(TextTurnHistoryEntry).max(80),
791
+ text: z.string().min(1).max(8e3),
792
+ /** When the API stops waiting; the worker stops the run before it. */
793
+ deadlineAt: z.string().datetime()
794
+ });
795
+ TextTurnUsage = z.object({
796
+ provider: z.string().min(1).max(60),
797
+ model: z.string().min(1).max(200),
798
+ inputTokens: z.number().int().nonnegative(),
799
+ outputTokens: z.number().int().nonnegative(),
800
+ /** Only a first-party worker's label is used; a customer's worker runs on its own key (the API decides). */
801
+ byok: z.boolean()
802
+ });
803
+ TextTurnErrorCode = z.enum(["agent_unavailable", "agent_timeout"]);
804
+ z.union([
805
+ z.object({
806
+ agentId: z.string().uuid(),
807
+ replies: z.array(z.string().max(16e3)).max(20),
808
+ usage: z.array(TextTurnUsage).max(50).default([])
809
+ }),
810
+ z.object({
811
+ agentId: z.string().uuid(),
812
+ error: z.object({ code: TextTurnErrorCode, detail: z.string().max(500).optional() })
813
+ })
814
+ ]);
815
+ }
816
+ });
759
817
  var VoiceConfig, ModelConfig, SttConfig, RealtimeConfig, PipelineMode, ToolBinding, ProcessFieldType, ProcessFieldSpec, ProcessCompleteWhen, ProcessBackendAckSpec, ProcessSpec, TriggerConditionSpec, TriggerActionSpec, TriggerSpec, RequiredInfoField, AgentConfig;
760
818
  var init_agent_config = __esm({
761
819
  "../contracts/src/agent-config.ts"() {
@@ -3441,6 +3499,7 @@ var init_src = __esm({
3441
3499
  init_agents();
3442
3500
  init_process_state();
3443
3501
  init_call_events();
3502
+ init_text_turns();
3444
3503
  init_call_plan();
3445
3504
  init_memory();
3446
3505
  init_participants();
@@ -191,6 +191,12 @@ interface SessionFactoryInput {
191
191
  /** Connector-brain agent: disable preemptive generation (a multi-second remote
192
192
  * turn otherwise regenerates on the final transcript and drops the reply). */
193
193
  readonly connectorAgentMode?: boolean;
194
+ /**
195
+ * The SecurityPrimitive wraps this session (SecureAgent): preemptive generation is off. It would send the raw,
196
+ * unsealed transcript (PII included) to the model before the input guard runs — and its reply is always discarded,
197
+ * since the guard rewrites the message it was generated from.
198
+ */
199
+ readonly secured?: boolean;
194
200
  readonly captureDtmf: boolean;
195
201
  readonly pipeline?: {
196
202
  readonly stt?: unknown;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@voicelayer/sdk",
3
- "version": "0.2.0",
3
+ "version": "0.3.1",
4
4
  "description": "Official SDK for VoiceLayer — define, run, and orchestrate voice AI agents on the VoiceLayer control plane.",
5
5
  "license": "Apache-2.0",
6
6
  "author": "VoiceLayer",
@@ -80,15 +80,15 @@
80
80
  "vitest": "^4.1.5",
81
81
  "@voicelayer/contracts": "0.1.0",
82
82
  "@voicelayer/llm-client": "0.1.0",
83
- "@voicelayer/primitive-audio-experience": "0.1.0",
84
83
  "@voicelayer/observability": "0.1.0",
84
+ "@voicelayer/primitive-audio-experience": "0.1.0",
85
85
  "@voicelayer/primitive-audio-routing": "0.1.0",
86
+ "@voicelayer/primitive-process-schema": "0.1.0",
86
87
  "@voicelayer/primitive-security": "0.1.0",
88
+ "@voicelayer/agents-plugin-deepgram": "1.0.1",
87
89
  "@voicelayer/agents-plugin-livekit": "1.0.1",
88
- "@voicelayer/agents-plugin-openai": "1.0.1",
89
90
  "@voicelayer/agents-plugin-silero": "1.0.1",
90
- "@voicelayer/primitive-process-schema": "0.1.0",
91
- "@voicelayer/agents-plugin-deepgram": "1.0.1"
91
+ "@voicelayer/agents-plugin-openai": "1.0.1"
92
92
  },
93
93
  "scripts": {
94
94
  "typecheck": "tsc -b --pretty false",