@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
package/dist/brain/index.d.ts
CHANGED
|
@@ -79,14 +79,14 @@ declare const ConnectorUpFrame: z.ZodDiscriminatedUnion<"kind", [z.ZodObject<{
|
|
|
79
79
|
code: z.ZodEnum<["upstream_timeout", "upstream_error", "bad_response", "normalize_failed", "unreachable"]>;
|
|
80
80
|
message: z.ZodString;
|
|
81
81
|
}, "strip", z.ZodTypeAny, {
|
|
82
|
-
kind: "brain.error";
|
|
83
82
|
code: "upstream_timeout" | "upstream_error" | "bad_response" | "normalize_failed" | "unreachable";
|
|
84
83
|
message: string;
|
|
84
|
+
kind: "brain.error";
|
|
85
85
|
streamId: string;
|
|
86
86
|
}, {
|
|
87
|
-
kind: "brain.error";
|
|
88
87
|
code: "upstream_timeout" | "upstream_error" | "bad_response" | "normalize_failed" | "unreachable";
|
|
89
88
|
message: string;
|
|
89
|
+
kind: "brain.error";
|
|
90
90
|
streamId: string;
|
|
91
91
|
}>]>;
|
|
92
92
|
type ConnectorUpFrame = z.infer<typeof ConnectorUpFrame>;
|
package/dist/brain/index.js
CHANGED
|
@@ -622,9 +622,11 @@ var ProcessToolDTO = z.object({
|
|
|
622
622
|
});
|
|
623
623
|
var ProcessSchemaDTO = z.object({
|
|
624
624
|
id: z.string().min(1).max(64),
|
|
625
|
-
// System-prompt fragments compiled from say/confirm nodes. The SDK bridge
|
|
626
|
-
// composes these into the agent's prompt.
|
|
627
|
-
|
|
625
|
+
// System-prompt fragments compiled from say/confirm/llm nodes. The SDK bridge
|
|
626
|
+
// composes these into the agent's prompt. An AI step's instructions are a
|
|
627
|
+
// system prompt in their own right, so the cap is generous (2,000 refused real
|
|
628
|
+
// flows — G-27); publish checks it (validateFlowGraph → compiledSchemaIssues).
|
|
629
|
+
prompts: z.array(z.object({ id: z.string().min(1).max(128), text: z.string().max(16e3) })).max(64).optional(),
|
|
628
630
|
fields: z.array(ProcessFieldDTO).max(64),
|
|
629
631
|
completionGate: z.object({
|
|
630
632
|
requiredFields: z.array(z.string()).max(64),
|
|
@@ -855,7 +857,10 @@ var CallEventKind = z.enum([
|
|
|
855
857
|
// presses a key on their leg; `dtmf.sent` fires when our agent (or a
|
|
856
858
|
// programmatic caller via /v1/calls/:id/dtmf) emits one outbound.
|
|
857
859
|
"dtmf.received",
|
|
858
|
-
"dtmf.sent"
|
|
860
|
+
"dtmf.sent",
|
|
861
|
+
// A host's runtime intervention (burn-down G-6): call_say / call_send_guidance / call_inject_context / call_instruct,
|
|
862
|
+
// with masked args and the API key — written by the API only, never through the worker's /events endpoint.
|
|
863
|
+
"mcp.interaction"
|
|
859
864
|
]);
|
|
860
865
|
var OP_CALL_EVENT_KIND = /^(tool|handoff|lookup|record|notify|engine)\.[a-z0-9_]{1,48}(\.[a-z0-9_]{1,48})?$/;
|
|
861
866
|
var OpCallEventKind = z.string().regex(OP_CALL_EVENT_KIND);
|
|
@@ -901,7 +906,7 @@ z.object({
|
|
|
901
906
|
payload: z.unknown(),
|
|
902
907
|
ts: z.string().datetime()
|
|
903
908
|
});
|
|
904
|
-
z.enum(["say", "hangup", "dtmf", "instruct", "guidance"]);
|
|
909
|
+
z.enum(["say", "hangup", "dtmf", "instruct", "inject_context", "guidance"]);
|
|
905
910
|
var commandId = z.string().uuid().optional();
|
|
906
911
|
var SayCommand = z.object({
|
|
907
912
|
kind: z.literal("say"),
|
|
@@ -924,20 +929,26 @@ var DtmfCommand = z.object({
|
|
|
924
929
|
var InstructCommand = z.object({
|
|
925
930
|
kind: z.literal("instruct"),
|
|
926
931
|
commandId,
|
|
927
|
-
text: z.string().min(1)
|
|
932
|
+
text: z.string().min(1).max(4e3)
|
|
933
|
+
});
|
|
934
|
+
var InjectContextCommand = z.object({
|
|
935
|
+
kind: z.literal("inject_context"),
|
|
936
|
+
commandId,
|
|
937
|
+
text: z.string().min(1).max(4e3)
|
|
928
938
|
});
|
|
929
939
|
z.discriminatedUnion("kind", [
|
|
930
940
|
SayCommand,
|
|
931
941
|
HangupCommand,
|
|
932
942
|
DtmfCommand,
|
|
933
943
|
InstructCommand,
|
|
944
|
+
InjectContextCommand,
|
|
934
945
|
GuidanceCommand
|
|
935
946
|
]);
|
|
936
947
|
z.object({
|
|
937
948
|
commandId: z.string().uuid(),
|
|
938
949
|
outcome: z.enum(["applied", "refused", "failed"]),
|
|
939
950
|
// machine code: output_blocked · not_supported · unknown_consultation · no_consultation · invalid_command ·
|
|
940
|
-
// say_unavailable · dtmf_unavailable
|
|
951
|
+
// say_unavailable · dtmf_unavailable · context_full · instructions_unavailable
|
|
941
952
|
code: z.string().max(64).optional(),
|
|
942
953
|
detail: z.string().max(500).optional()
|
|
943
954
|
});
|
|
@@ -1714,35 +1725,6 @@ z.object({
|
|
|
1714
1725
|
note: z.string().max(2e3).nullable().optional(),
|
|
1715
1726
|
reviewed: z.boolean().optional()
|
|
1716
1727
|
});
|
|
1717
|
-
var ToolExposure = z.enum(["agent", "mcp"]);
|
|
1718
|
-
z.object({
|
|
1719
|
-
name: z.string().min(1).max(64).regex(/^[a-z][a-z0-9_]*$/, "snake_case"),
|
|
1720
|
-
// The string that routes the LLM/orchestrator to invoke this tool.
|
|
1721
|
-
description: z.string().min(1).max(2e3),
|
|
1722
|
-
// Zod serialized to JSON Schema at registration time. Persisted as
|
|
1723
|
-
// JSON Schema; SDK and dashboard rehydrate to Zod when needed.
|
|
1724
|
-
inputSchema: z.record(z.unknown()),
|
|
1725
|
-
// When present, the runtime validates the handler's return value.
|
|
1726
|
-
outputSchema: z.record(z.unknown()).optional(),
|
|
1727
|
-
exposedVia: z.array(ToolExposure).min(1),
|
|
1728
|
-
// ── Tool/Plugin SDK (PRD P0.2). All optional for back-compat. ──
|
|
1729
|
-
// Latency class (PRD §4.6.3). Runtime defaults to 'in_call' when omitted.
|
|
1730
|
-
mode: z.enum(["in_call", "async_only"]).optional(),
|
|
1731
|
-
// Hard timeout for an in-call tool (ms).
|
|
1732
|
-
timeoutMs: z.number().int().min(50).max(6e4).optional(),
|
|
1733
|
-
// 'connection' resolves a credential from the vault by `connectionRef`.
|
|
1734
|
-
auth: z.enum(["none", "connection"]).optional(),
|
|
1735
|
-
connectionRef: z.string().max(128).optional(),
|
|
1736
|
-
// Retry policy for safe/async verbs.
|
|
1737
|
-
retry: z.object({
|
|
1738
|
-
maxAttempts: z.number().int().min(1).max(5),
|
|
1739
|
-
backoffMs: z.number().int().min(0).max(6e4)
|
|
1740
|
-
}).optional(),
|
|
1741
|
-
// Normalized result kinds the flow/decision layer branches on (result.kind).
|
|
1742
|
-
resultKinds: z.array(z.string().min(1).max(64)).max(24).optional(),
|
|
1743
|
-
// Free-form dashboard metadata (icon, group, etc.). No `category` enum.
|
|
1744
|
-
metadata: z.record(z.unknown()).optional()
|
|
1745
|
-
});
|
|
1746
1728
|
var TranscriptTurn = z.object({
|
|
1747
1729
|
speaker: z.enum(["caller", "agent"]),
|
|
1748
1730
|
text: z.string(),
|
|
@@ -1759,24 +1741,28 @@ var ConsultationAudit = z.object({
|
|
|
1759
1741
|
latencyMs: z.number().int().min(0)
|
|
1760
1742
|
});
|
|
1761
1743
|
var ToolCallAudit = z.object({
|
|
1744
|
+
invocationId: z.string(),
|
|
1762
1745
|
toolName: z.string(),
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
args: z.record(z.unknown()),
|
|
1766
|
-
result: z.unknown(),
|
|
1746
|
+
args: z.string(),
|
|
1747
|
+
result: z.string().optional(),
|
|
1767
1748
|
startedAt: z.string().datetime(),
|
|
1768
1749
|
durationMs: z.number().int().min(0),
|
|
1769
1750
|
ok: z.boolean(),
|
|
1751
|
+
// refused by the Action Guard before it ran
|
|
1752
|
+
blocked: z.boolean(),
|
|
1770
1753
|
errorMessage: z.string().optional()
|
|
1771
1754
|
});
|
|
1772
1755
|
var McpInteractionAudit = z.object({
|
|
1773
1756
|
// One of the four runtime tools — closed set, no growth allowed.
|
|
1774
1757
|
tool: z.enum(["call_say", "call_send_guidance", "call_inject_context", "call_instruct"]),
|
|
1775
|
-
// Args
|
|
1758
|
+
// Args with PII masked (burn-down G-6, owner decision: the audit never keeps a raw value).
|
|
1776
1759
|
args: z.record(z.unknown()),
|
|
1777
1760
|
ts: z.string().datetime(),
|
|
1778
1761
|
// Attribution. The API key that drove the orchestrator session.
|
|
1779
|
-
apiKeyId: z.string()
|
|
1762
|
+
apiKeyId: z.string(),
|
|
1763
|
+
// 'applied' = the agent confirmed it; 'unknown' = sent, but no confirmation in time (a 504 to the host — it may have
|
|
1764
|
+
// been applied).
|
|
1765
|
+
outcome: z.enum(["applied", "unknown"])
|
|
1780
1766
|
});
|
|
1781
1767
|
z.object({
|
|
1782
1768
|
callId: z.string().uuid(),
|
|
@@ -2000,6 +1986,39 @@ byokProviders().map((p) => ({
|
|
|
2000
1986
|
keyPlaceholder: p.keyPlaceholder ?? "",
|
|
2001
1987
|
supportsBaseUrl: p.supportsBaseUrl
|
|
2002
1988
|
}));
|
|
1989
|
+
z.object({
|
|
1990
|
+
id: z.string().min(1),
|
|
1991
|
+
label: z.string().min(1),
|
|
1992
|
+
/** The vault `provider` the resulting connection is stored under. */
|
|
1993
|
+
vaultProvider: z.string().min(1),
|
|
1994
|
+
category: z.enum(["model", "tool"])
|
|
1995
|
+
});
|
|
1996
|
+
z.object({
|
|
1997
|
+
authorizeUrl: z.string().url()
|
|
1998
|
+
});
|
|
1999
|
+
z.object({
|
|
2000
|
+
state: z.string().min(1).max(512),
|
|
2001
|
+
code: z.string().min(1).max(4096)
|
|
2002
|
+
});
|
|
2003
|
+
z.object({
|
|
2004
|
+
providerId: z.string().min(1),
|
|
2005
|
+
/** The provider's display name ("ChatGPT"). */
|
|
2006
|
+
providerLabel: z.string().min(1),
|
|
2007
|
+
/** What the connection is for — which group the dashboard files it under. */
|
|
2008
|
+
category: z.enum(["model", "tool"]),
|
|
2009
|
+
/** The account's stable id at the provider (OIDC `sub`); reconnecting the same account updates the same row. */
|
|
2010
|
+
subject: z.string().min(1).nullable(),
|
|
2011
|
+
email: z.string().nullable(),
|
|
2012
|
+
displayName: z.string().nullable(),
|
|
2013
|
+
scopes: z.array(z.string()),
|
|
2014
|
+
/**
|
|
2015
|
+
* The workspace user who signed in. A person's model plan (category 'model') serves only them — never teammates or
|
|
2016
|
+
* API keys. Absent on rows connected before it was recorded.
|
|
2017
|
+
*/
|
|
2018
|
+
connectedBy: z.string().nullable().optional(),
|
|
2019
|
+
/** Set when a refresh was refused (e.g. `invalid_grant`): the owner must connect again. */
|
|
2020
|
+
reauthRequired: z.boolean().optional()
|
|
2021
|
+
});
|
|
2003
2022
|
var E164 = z.string().regex(/^\+[1-9]\d{6,14}$/, "must be E.164 (+15551234567)");
|
|
2004
2023
|
var RoomPrefix = z.string().regex(/^[a-z0-9][a-z0-9-]{0,30}[a-z0-9-]?$/, "lowercase letters, digits, dashes; max 32");
|
|
2005
2024
|
var RecordingPrefix = z.string().min(1).max(128).refine((v) => !v.startsWith("/") && !v.includes(".."), "relative key prefix only");
|
|
@@ -2302,6 +2321,10 @@ z.discriminatedUnion("kind", [
|
|
|
2302
2321
|
BrainRequestFrame,
|
|
2303
2322
|
BrainCancelFrame
|
|
2304
2323
|
]);
|
|
2324
|
+
var FLOW_BOOT_FAILURES = ["schema_fetch_failed", "no_process_schema", "missing_agent_id", "no_api_key"];
|
|
2325
|
+
z.enum(
|
|
2326
|
+
FLOW_BOOT_FAILURES.map((cause) => `flow_boot:${cause}`)
|
|
2327
|
+
);
|
|
2305
2328
|
var EnvironmentSpec = z.enum(["draft", "live"]);
|
|
2306
2329
|
z.object({
|
|
2307
2330
|
agentName: z.string().min(1),
|