@voicelayer/sdk 0.3.1 → 0.4.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.
- package/dist/brain/index.d.ts +2 -2
- package/dist/brain/index.js +65 -42
- package/dist/index.d.ts +255 -249
- package/dist/index.js +1187 -878
- package/dist/runtime/text-session.d.ts +1 -1
- package/dist/runtime/text-session.js +120 -66
- package/dist/{text-session-oMqJh6SF.d.ts → text-session-BB0dLLH2.d.ts} +106 -98
- package/package.json +4 -4
|
@@ -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-
|
|
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-BB0dLLH2.js';
|
|
2
2
|
import '@livekit/agents';
|
|
3
3
|
import 'zod';
|
|
4
4
|
import 'openai';
|
|
@@ -430,9 +430,11 @@ var init_agents = __esm({
|
|
|
430
430
|
});
|
|
431
431
|
ProcessSchemaDTO = z.object({
|
|
432
432
|
id: z.string().min(1).max(64),
|
|
433
|
-
// System-prompt fragments compiled from say/confirm nodes. The SDK bridge
|
|
434
|
-
// composes these into the agent's prompt.
|
|
435
|
-
|
|
433
|
+
// System-prompt fragments compiled from say/confirm/llm nodes. The SDK bridge
|
|
434
|
+
// composes these into the agent's prompt. An AI step's instructions are a
|
|
435
|
+
// system prompt in their own right, so the cap is generous (2,000 refused real
|
|
436
|
+
// flows — G-27); publish checks it (validateFlowGraph → compiledSchemaIssues).
|
|
437
|
+
prompts: z.array(z.object({ id: z.string().min(1).max(128), text: z.string().max(16e3) })).max(64).optional(),
|
|
436
438
|
fields: z.array(ProcessFieldDTO).max(64),
|
|
437
439
|
completionGate: z.object({
|
|
438
440
|
requiredFields: z.array(z.string()).max(64),
|
|
@@ -654,7 +656,7 @@ var init_consultation = __esm({
|
|
|
654
656
|
});
|
|
655
657
|
}
|
|
656
658
|
});
|
|
657
|
-
var CallEventKind, OP_CALL_EVENT_KIND, OpCallEventKind, commandId, SayCommand, HangupCommand, DtmfCommand, InstructCommand;
|
|
659
|
+
var CallEventKind, OP_CALL_EVENT_KIND, OpCallEventKind, commandId, SayCommand, HangupCommand, DtmfCommand, InstructCommand, InjectContextCommand;
|
|
658
660
|
var init_call_events = __esm({
|
|
659
661
|
"../contracts/src/call-events.ts"() {
|
|
660
662
|
init_consultation();
|
|
@@ -677,7 +679,10 @@ var init_call_events = __esm({
|
|
|
677
679
|
// presses a key on their leg; `dtmf.sent` fires when our agent (or a
|
|
678
680
|
// programmatic caller via /v1/calls/:id/dtmf) emits one outbound.
|
|
679
681
|
"dtmf.received",
|
|
680
|
-
"dtmf.sent"
|
|
682
|
+
"dtmf.sent",
|
|
683
|
+
// A host's runtime intervention (burn-down G-6): call_say / call_send_guidance / call_inject_context / call_instruct,
|
|
684
|
+
// with masked args and the API key — written by the API only, never through the worker's /events endpoint.
|
|
685
|
+
"mcp.interaction"
|
|
681
686
|
]);
|
|
682
687
|
OP_CALL_EVENT_KIND = /^(tool|handoff|lookup|record|notify|engine)\.[a-z0-9_]{1,48}(\.[a-z0-9_]{1,48})?$/;
|
|
683
688
|
OpCallEventKind = z.string().regex(OP_CALL_EVENT_KIND);
|
|
@@ -723,7 +728,7 @@ var init_call_events = __esm({
|
|
|
723
728
|
payload: z.unknown(),
|
|
724
729
|
ts: z.string().datetime()
|
|
725
730
|
});
|
|
726
|
-
z.enum(["say", "hangup", "dtmf", "instruct", "guidance"]);
|
|
731
|
+
z.enum(["say", "hangup", "dtmf", "instruct", "inject_context", "guidance"]);
|
|
727
732
|
commandId = z.string().uuid().optional();
|
|
728
733
|
SayCommand = z.object({
|
|
729
734
|
kind: z.literal("say"),
|
|
@@ -746,20 +751,26 @@ var init_call_events = __esm({
|
|
|
746
751
|
InstructCommand = z.object({
|
|
747
752
|
kind: z.literal("instruct"),
|
|
748
753
|
commandId,
|
|
749
|
-
text: z.string().min(1)
|
|
754
|
+
text: z.string().min(1).max(4e3)
|
|
755
|
+
});
|
|
756
|
+
InjectContextCommand = z.object({
|
|
757
|
+
kind: z.literal("inject_context"),
|
|
758
|
+
commandId,
|
|
759
|
+
text: z.string().min(1).max(4e3)
|
|
750
760
|
});
|
|
751
761
|
z.discriminatedUnion("kind", [
|
|
752
762
|
SayCommand,
|
|
753
763
|
HangupCommand,
|
|
754
764
|
DtmfCommand,
|
|
755
765
|
InstructCommand,
|
|
766
|
+
InjectContextCommand,
|
|
756
767
|
GuidanceCommand
|
|
757
768
|
]);
|
|
758
769
|
z.object({
|
|
759
770
|
commandId: z.string().uuid(),
|
|
760
771
|
outcome: z.enum(["applied", "refused", "failed"]),
|
|
761
772
|
// machine code: output_blocked · not_supported · unknown_consultation · no_consultation · invalid_command ·
|
|
762
|
-
// say_unavailable · dtmf_unavailable
|
|
773
|
+
// say_unavailable · dtmf_unavailable · context_full · instructions_unavailable
|
|
763
774
|
code: z.string().max(64).optional(),
|
|
764
775
|
detail: z.string().max(500).optional()
|
|
765
776
|
});
|
|
@@ -1609,40 +1620,6 @@ var init_call_review = __esm({
|
|
|
1609
1620
|
});
|
|
1610
1621
|
}
|
|
1611
1622
|
});
|
|
1612
|
-
var ToolExposure;
|
|
1613
|
-
var init_agent_tools = __esm({
|
|
1614
|
-
"../contracts/src/agent-tools.ts"() {
|
|
1615
|
-
ToolExposure = z.enum(["agent", "mcp"]);
|
|
1616
|
-
z.object({
|
|
1617
|
-
name: z.string().min(1).max(64).regex(/^[a-z][a-z0-9_]*$/, "snake_case"),
|
|
1618
|
-
// The string that routes the LLM/orchestrator to invoke this tool.
|
|
1619
|
-
description: z.string().min(1).max(2e3),
|
|
1620
|
-
// Zod serialized to JSON Schema at registration time. Persisted as
|
|
1621
|
-
// JSON Schema; SDK and dashboard rehydrate to Zod when needed.
|
|
1622
|
-
inputSchema: z.record(z.unknown()),
|
|
1623
|
-
// When present, the runtime validates the handler's return value.
|
|
1624
|
-
outputSchema: z.record(z.unknown()).optional(),
|
|
1625
|
-
exposedVia: z.array(ToolExposure).min(1),
|
|
1626
|
-
// ── Tool/Plugin SDK (PRD P0.2). All optional for back-compat. ──
|
|
1627
|
-
// Latency class (PRD §4.6.3). Runtime defaults to 'in_call' when omitted.
|
|
1628
|
-
mode: z.enum(["in_call", "async_only"]).optional(),
|
|
1629
|
-
// Hard timeout for an in-call tool (ms).
|
|
1630
|
-
timeoutMs: z.number().int().min(50).max(6e4).optional(),
|
|
1631
|
-
// 'connection' resolves a credential from the vault by `connectionRef`.
|
|
1632
|
-
auth: z.enum(["none", "connection"]).optional(),
|
|
1633
|
-
connectionRef: z.string().max(128).optional(),
|
|
1634
|
-
// Retry policy for safe/async verbs.
|
|
1635
|
-
retry: z.object({
|
|
1636
|
-
maxAttempts: z.number().int().min(1).max(5),
|
|
1637
|
-
backoffMs: z.number().int().min(0).max(6e4)
|
|
1638
|
-
}).optional(),
|
|
1639
|
-
// Normalized result kinds the flow/decision layer branches on (result.kind).
|
|
1640
|
-
resultKinds: z.array(z.string().min(1).max(64)).max(24).optional(),
|
|
1641
|
-
// Free-form dashboard metadata (icon, group, etc.). No `category` enum.
|
|
1642
|
-
metadata: z.record(z.unknown()).optional()
|
|
1643
|
-
});
|
|
1644
|
-
}
|
|
1645
|
-
});
|
|
1646
1623
|
var TranscriptTurn, ConsultationAudit, ToolCallAudit, McpInteractionAudit;
|
|
1647
1624
|
var init_call_result = __esm({
|
|
1648
1625
|
"../contracts/src/call-result.ts"() {
|
|
@@ -1662,24 +1639,28 @@ var init_call_result = __esm({
|
|
|
1662
1639
|
latencyMs: z.number().int().min(0)
|
|
1663
1640
|
});
|
|
1664
1641
|
ToolCallAudit = z.object({
|
|
1642
|
+
invocationId: z.string(),
|
|
1665
1643
|
toolName: z.string(),
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
args: z.record(z.unknown()),
|
|
1669
|
-
result: z.unknown(),
|
|
1644
|
+
args: z.string(),
|
|
1645
|
+
result: z.string().optional(),
|
|
1670
1646
|
startedAt: z.string().datetime(),
|
|
1671
1647
|
durationMs: z.number().int().min(0),
|
|
1672
1648
|
ok: z.boolean(),
|
|
1649
|
+
// refused by the Action Guard before it ran
|
|
1650
|
+
blocked: z.boolean(),
|
|
1673
1651
|
errorMessage: z.string().optional()
|
|
1674
1652
|
});
|
|
1675
1653
|
McpInteractionAudit = z.object({
|
|
1676
1654
|
// One of the four runtime tools — closed set, no growth allowed.
|
|
1677
1655
|
tool: z.enum(["call_say", "call_send_guidance", "call_inject_context", "call_instruct"]),
|
|
1678
|
-
// Args
|
|
1656
|
+
// Args with PII masked (burn-down G-6, owner decision: the audit never keeps a raw value).
|
|
1679
1657
|
args: z.record(z.unknown()),
|
|
1680
1658
|
ts: z.string().datetime(),
|
|
1681
1659
|
// Attribution. The API key that drove the orchestrator session.
|
|
1682
|
-
apiKeyId: z.string()
|
|
1660
|
+
apiKeyId: z.string(),
|
|
1661
|
+
// 'applied' = the agent confirmed it; 'unknown' = sent, but no confirmation in time (a 504 to the host — it may have
|
|
1662
|
+
// been applied).
|
|
1663
|
+
outcome: z.enum(["applied", "unknown"])
|
|
1683
1664
|
});
|
|
1684
1665
|
z.object({
|
|
1685
1666
|
callId: z.string().uuid(),
|
|
@@ -1779,10 +1760,41 @@ var init_flow_ports = __esm({
|
|
|
1779
1760
|
INCOMPLETE_PORT_ID = "incomplete";
|
|
1780
1761
|
}
|
|
1781
1762
|
});
|
|
1763
|
+
|
|
1764
|
+
// ../contracts/src/flow-edges.ts
|
|
1765
|
+
var init_flow_edges = __esm({
|
|
1766
|
+
"../contracts/src/flow-edges.ts"() {
|
|
1767
|
+
}
|
|
1768
|
+
});
|
|
1769
|
+
|
|
1770
|
+
// ../contracts/src/flow-enrichment.ts
|
|
1771
|
+
var init_flow_enrichment = __esm({
|
|
1772
|
+
"../contracts/src/flow-enrichment.ts"() {
|
|
1773
|
+
}
|
|
1774
|
+
});
|
|
1775
|
+
|
|
1776
|
+
// ../contracts/src/flow-compile.ts
|
|
1777
|
+
var init_flow_compile = __esm({
|
|
1778
|
+
"../contracts/src/flow-compile.ts"() {
|
|
1779
|
+
init_flow_enrichment();
|
|
1780
|
+
init_flow_edges();
|
|
1781
|
+
}
|
|
1782
|
+
});
|
|
1783
|
+
|
|
1784
|
+
// ../contracts/src/flow-compile-check.ts
|
|
1785
|
+
var init_flow_compile_check = __esm({
|
|
1786
|
+
"../contracts/src/flow-compile-check.ts"() {
|
|
1787
|
+
init_agents();
|
|
1788
|
+
init_flow_compile();
|
|
1789
|
+
}
|
|
1790
|
+
});
|
|
1782
1791
|
var FlowIssueSeverity, FlowIssue;
|
|
1783
1792
|
var init_flow_validate = __esm({
|
|
1784
1793
|
"../contracts/src/flow-validate.ts"() {
|
|
1785
1794
|
init_flow_ports();
|
|
1795
|
+
init_flow_edges();
|
|
1796
|
+
init_flow_compile_check();
|
|
1797
|
+
init_flow_edges();
|
|
1786
1798
|
FlowIssueSeverity = z.enum(["error", "warning"]);
|
|
1787
1799
|
FlowIssue = z.object({
|
|
1788
1800
|
code: z.string().max(64),
|
|
@@ -1958,6 +1970,39 @@ var init_connection = __esm({
|
|
|
1958
1970
|
keyPlaceholder: p.keyPlaceholder ?? "",
|
|
1959
1971
|
supportsBaseUrl: p.supportsBaseUrl
|
|
1960
1972
|
}));
|
|
1973
|
+
z.object({
|
|
1974
|
+
id: z.string().min(1),
|
|
1975
|
+
label: z.string().min(1),
|
|
1976
|
+
/** The vault `provider` the resulting connection is stored under. */
|
|
1977
|
+
vaultProvider: z.string().min(1),
|
|
1978
|
+
category: z.enum(["model", "tool"])
|
|
1979
|
+
});
|
|
1980
|
+
z.object({
|
|
1981
|
+
authorizeUrl: z.string().url()
|
|
1982
|
+
});
|
|
1983
|
+
z.object({
|
|
1984
|
+
state: z.string().min(1).max(512),
|
|
1985
|
+
code: z.string().min(1).max(4096)
|
|
1986
|
+
});
|
|
1987
|
+
z.object({
|
|
1988
|
+
providerId: z.string().min(1),
|
|
1989
|
+
/** The provider's display name ("ChatGPT"). */
|
|
1990
|
+
providerLabel: z.string().min(1),
|
|
1991
|
+
/** What the connection is for — which group the dashboard files it under. */
|
|
1992
|
+
category: z.enum(["model", "tool"]),
|
|
1993
|
+
/** The account's stable id at the provider (OIDC `sub`); reconnecting the same account updates the same row. */
|
|
1994
|
+
subject: z.string().min(1).nullable(),
|
|
1995
|
+
email: z.string().nullable(),
|
|
1996
|
+
displayName: z.string().nullable(),
|
|
1997
|
+
scopes: z.array(z.string()),
|
|
1998
|
+
/**
|
|
1999
|
+
* The workspace user who signed in. A person's model plan (category 'model') serves only them — never teammates or
|
|
2000
|
+
* API keys. Absent on rows connected before it was recorded.
|
|
2001
|
+
*/
|
|
2002
|
+
connectedBy: z.string().nullable().optional(),
|
|
2003
|
+
/** Set when a refresh was refused (e.g. `invalid_grant`): the owner must connect again. */
|
|
2004
|
+
reauthRequired: z.boolean().optional()
|
|
2005
|
+
});
|
|
1961
2006
|
}
|
|
1962
2007
|
});
|
|
1963
2008
|
var E164, RoomPrefix, RecordingPrefix, Cidr, TelephonySettings, ProfileSource, EffectiveCallProfile;
|
|
@@ -2280,18 +2325,13 @@ var init_connector_stream = __esm({
|
|
|
2280
2325
|
]);
|
|
2281
2326
|
}
|
|
2282
2327
|
});
|
|
2283
|
-
|
|
2284
|
-
|
|
2285
|
-
|
|
2286
|
-
|
|
2287
|
-
|
|
2288
|
-
})
|
|
2289
|
-
|
|
2290
|
-
// ../contracts/src/flow-compile.ts
|
|
2291
|
-
var init_flow_compile = __esm({
|
|
2292
|
-
"../contracts/src/flow-compile.ts"() {
|
|
2293
|
-
init_flow_enrichment();
|
|
2294
|
-
init_flow_validate();
|
|
2328
|
+
var FLOW_BOOT_FAILURES;
|
|
2329
|
+
var init_call_end_reason = __esm({
|
|
2330
|
+
"../contracts/src/call-end-reason.ts"() {
|
|
2331
|
+
FLOW_BOOT_FAILURES = ["schema_fetch_failed", "no_process_schema", "missing_agent_id", "no_api_key"];
|
|
2332
|
+
z.enum(
|
|
2333
|
+
FLOW_BOOT_FAILURES.map((cause) => `flow_boot:${cause}`)
|
|
2334
|
+
);
|
|
2295
2335
|
}
|
|
2296
2336
|
});
|
|
2297
2337
|
var EnvironmentSpec;
|
|
@@ -3512,7 +3552,6 @@ var init_src = __esm({
|
|
|
3512
3552
|
init_evaluations();
|
|
3513
3553
|
init_tests();
|
|
3514
3554
|
init_call_review();
|
|
3515
|
-
init_agent_tools();
|
|
3516
3555
|
init_call_result();
|
|
3517
3556
|
init_numbers();
|
|
3518
3557
|
init_project_limits();
|
|
@@ -3531,6 +3570,8 @@ var init_src = __esm({
|
|
|
3531
3570
|
init_connector();
|
|
3532
3571
|
init_connector_stream();
|
|
3533
3572
|
init_flow_compile();
|
|
3573
|
+
init_flow_compile_check();
|
|
3574
|
+
init_call_end_reason();
|
|
3534
3575
|
init_flow_enrichment();
|
|
3535
3576
|
init_environments();
|
|
3536
3577
|
init_variables();
|
|
@@ -4458,7 +4499,10 @@ ${text}`
|
|
|
4458
4499
|
await handle.waitForPlayout();
|
|
4459
4500
|
graphLog("said", { chars: text.length, interrupted: handle.interrupted });
|
|
4460
4501
|
}
|
|
4461
|
-
async function genReply(deps,
|
|
4502
|
+
async function genReply(deps, nodeInstructions) {
|
|
4503
|
+
const instructions = deps.realtime && deps.live ? `${deps.live.full()}
|
|
4504
|
+
|
|
4505
|
+
${nodeInstructions}` : nodeInstructions;
|
|
4462
4506
|
if (deps.ctx.adapter) {
|
|
4463
4507
|
await deps.ctx.adapter.generateReply({ instructions });
|
|
4464
4508
|
return;
|
|
@@ -5120,7 +5164,9 @@ ${collected}`);
|
|
|
5120
5164
|
let turnResult;
|
|
5121
5165
|
try {
|
|
5122
5166
|
turnResult = await runner({
|
|
5123
|
-
|
|
5167
|
+
// an out-of-band completion: it sees none of the agent's instructions, so the host's layers (and the seal —
|
|
5168
|
+
// the caller's words are in these instructions) ride in front (burn-down G-6)
|
|
5169
|
+
instructions: [deps.live?.additions(), ...parts].filter(Boolean).join("\n\n"),
|
|
5124
5170
|
transcript,
|
|
5125
5171
|
tools: agentTools,
|
|
5126
5172
|
exits: exitOptions,
|
|
@@ -5277,6 +5323,7 @@ ${collected}`);
|
|
|
5277
5323
|
...deps.history ? { history: deps.history } : {},
|
|
5278
5324
|
...deps.realtime ? { realtime: true } : {},
|
|
5279
5325
|
...deps.resolvers ? { resolvers: deps.resolvers } : {},
|
|
5326
|
+
...deps.live ? { live: deps.live } : {},
|
|
5280
5327
|
depth: depth + 1
|
|
5281
5328
|
});
|
|
5282
5329
|
deps.events.note("subflow.exit", { node: node.id, ref, outcome: outcome.kind });
|
|
@@ -5380,7 +5427,8 @@ async function runFlowGraph(program, deps) {
|
|
|
5380
5427
|
...deps.realtime ? { realtime: true } : {},
|
|
5381
5428
|
...deps.resolvers ? { resolvers: deps.resolvers } : {},
|
|
5382
5429
|
...deps.depth !== void 0 ? { depth: deps.depth } : {},
|
|
5383
|
-
...deps.busy ? { busy: deps.busy } : {}
|
|
5430
|
+
...deps.busy ? { busy: deps.busy } : {},
|
|
5431
|
+
...deps.live ? { live: deps.live } : {}
|
|
5384
5432
|
});
|
|
5385
5433
|
} catch (err) {
|
|
5386
5434
|
const message = err instanceof Error ? err.message : String(err);
|
|
@@ -5784,7 +5832,8 @@ async function runFlowProgram(program, ctx, opts) {
|
|
|
5784
5832
|
...opts.maxNodeVisits !== void 0 ? { maxNodeVisits: opts.maxNodeVisits } : {},
|
|
5785
5833
|
...opts.realtime ? { realtime: true } : {},
|
|
5786
5834
|
...opts.resolvers ? { resolvers: opts.resolvers } : {},
|
|
5787
|
-
...opts.busy ? { busy: opts.busy } : {}
|
|
5835
|
+
...opts.busy ? { busy: opts.busy } : {},
|
|
5836
|
+
...opts.live ? { live: opts.live } : {}
|
|
5788
5837
|
});
|
|
5789
5838
|
graphLog("outcome", outcome);
|
|
5790
5839
|
return outcome;
|
|
@@ -6648,7 +6697,9 @@ function createTextSessionAdapter(transport) {
|
|
|
6648
6697
|
canBargeIn: false,
|
|
6649
6698
|
canReceiveDtmf: false,
|
|
6650
6699
|
canPublishDtmf: false,
|
|
6651
|
-
canResolveSpeaker: true
|
|
6700
|
+
canResolveSpeaker: true,
|
|
6701
|
+
// a text turn has no live session to steer
|
|
6702
|
+
canUpdateInstructions: false
|
|
6652
6703
|
};
|
|
6653
6704
|
const adapter = {
|
|
6654
6705
|
capabilities,
|
|
@@ -6691,6 +6742,9 @@ function createTextSessionAdapter(transport) {
|
|
|
6691
6742
|
await transport.send(text);
|
|
6692
6743
|
return { interrupted: false };
|
|
6693
6744
|
},
|
|
6745
|
+
async setInstructions() {
|
|
6746
|
+
throw new Error("setInstructions unsupported: canUpdateInstructions=false");
|
|
6747
|
+
},
|
|
6694
6748
|
async enqueueSay(text) {
|
|
6695
6749
|
fire("agent_turn", { text });
|
|
6696
6750
|
await transport.send(text);
|