@pinecall/protocol 0.1.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.
- package/LICENSE +202 -0
- package/dist/fixtures/call-log-golden.json +127 -0
- package/dist/fixtures/call-log-golden.state.json +39 -0
- package/dist/generated/codec.d.ts +53 -0
- package/dist/generated/codec.js +67 -0
- package/dist/generated/commands.d.ts +423 -0
- package/dist/generated/commands.js +168 -0
- package/dist/generated/defs.d.ts +604 -0
- package/dist/generated/defs.js +328 -0
- package/dist/generated/envelope.d.ts +27 -0
- package/dist/generated/envelope.js +26 -0
- package/dist/generated/events.d.ts +1234 -0
- package/dist/generated/events.js +388 -0
- package/dist/generated/index.d.ts +12 -0
- package/dist/generated/index.js +13 -0
- package/dist/generated/metrics.d.ts +386 -0
- package/dist/generated/metrics.js +268 -0
- package/dist/generated/registry.d.ts +1591 -0
- package/dist/generated/registry.js +130 -0
- package/dist/generated/rest.d.ts +1031 -0
- package/dist/generated/rest.js +291 -0
- package/dist/generated/room.d.ts +111 -0
- package/dist/generated/room.js +72 -0
- package/dist/generated/state.d.ts +902 -0
- package/dist/generated/state.js +179 -0
- package/dist/generated/units.d.ts +2 -0
- package/dist/generated/units.js +80 -0
- package/dist/generated/verbs.d.ts +77 -0
- package/dist/generated/verbs.js +49 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +3 -0
- package/dist/reduce.d.ts +10 -0
- package/dist/reduce.js +352 -0
- package/package.json +38 -0
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
// Generated from schema/state.json: what a log reduces to. Never edited by hand.
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
import { AgentStateSchema, ChannelSchema, ContactSchema, CostSchema, DirectionSchema, DocSourceSchema, EndReasonSchema, EventSourceSchema, MemoryOpSchema, ParticipantKindSchema, RouteSchema, SupervisorSchema, TransferModeSchema, UserStateSchema, } from "./defs.js";
|
|
4
|
+
import { AgentTurnMetricsSchema, AvatarMetricsSchema, EOTInferenceMetricsSchema, EOUMetricsSchema, InterruptionMetricsSchema, LLMMetricsSchema, ModelUsageSchema, RealtimeModelMetricsSchema, STTMetricsSchema, TTSMetricsSchema, UserTurnMetricsSchema, VADMetricsSchema, } from "./metrics.js";
|
|
5
|
+
/**
|
|
6
|
+
* Where the call is in its life. idle before any call.* entry, which is what an agent's own log
|
|
7
|
+
* looks like.
|
|
8
|
+
*/
|
|
9
|
+
export const CallStatusSchema = z.enum(["idle", "ringing", "dialing", "active", "ended"]);
|
|
10
|
+
/** One finished turn of the caller, with what the session measured about it. */
|
|
11
|
+
export const UserTurnSchema = z.strictObject({
|
|
12
|
+
role: z.literal("user"),
|
|
13
|
+
speech_id: z.string(),
|
|
14
|
+
item_id: z.string().nullish(),
|
|
15
|
+
text: z.string(),
|
|
16
|
+
language: z.string().nullish(),
|
|
17
|
+
transcript_confidence: z.number().nullish(),
|
|
18
|
+
metrics: UserTurnMetricsSchema,
|
|
19
|
+
});
|
|
20
|
+
/** One finished reply of the agent, with what the session measured about it. */
|
|
21
|
+
export const AgentTurnSchema = z.strictObject({
|
|
22
|
+
role: z.literal("agent"),
|
|
23
|
+
speech_id: z.string(),
|
|
24
|
+
item_id: z.string().nullish(),
|
|
25
|
+
text: z.string(),
|
|
26
|
+
interrupted: z.boolean(),
|
|
27
|
+
metrics: AgentTurnMetricsSchema,
|
|
28
|
+
});
|
|
29
|
+
/** One turn of either side, told apart by role. */
|
|
30
|
+
export const TurnSchema = z.discriminatedUnion("role", [UserTurnSchema, AgentTurnSchema]);
|
|
31
|
+
/**
|
|
32
|
+
* Every raw metric block of the call, by kind, in the order it arrived. The turns hold the join;
|
|
33
|
+
* this holds the measurements.
|
|
34
|
+
*/
|
|
35
|
+
export const CollectedMetricsSchema = z.strictObject({
|
|
36
|
+
llm: z.array(LLMMetricsSchema),
|
|
37
|
+
stt: z.array(STTMetricsSchema),
|
|
38
|
+
tts: z.array(TTSMetricsSchema),
|
|
39
|
+
vad: z.array(VADMetricsSchema),
|
|
40
|
+
eou: z.array(EOUMetricsSchema),
|
|
41
|
+
eot: z.array(EOTInferenceMetricsSchema),
|
|
42
|
+
interruption: z.array(InterruptionMetricsSchema),
|
|
43
|
+
realtime: z.array(RealtimeModelMetricsSchema),
|
|
44
|
+
avatar: z.array(AvatarMetricsSchema),
|
|
45
|
+
});
|
|
46
|
+
/** One tool call and, once the app answered, its result. */
|
|
47
|
+
export const ToolRunSchema = z.strictObject({
|
|
48
|
+
call_id: z.string(),
|
|
49
|
+
name: z.string(),
|
|
50
|
+
arguments: z.record(z.string(), z.unknown()),
|
|
51
|
+
speech_id: z.string().nullish(),
|
|
52
|
+
status: z.enum(["running", "done", "failed"]),
|
|
53
|
+
output: z.unknown().nullish(),
|
|
54
|
+
error: z.string().nullish(),
|
|
55
|
+
summary: z.string().nullish(),
|
|
56
|
+
duration_s: z.number().nullish(),
|
|
57
|
+
seq: z.int(),
|
|
58
|
+
});
|
|
59
|
+
/** What is known about one block of the prompt without storing its text. */
|
|
60
|
+
export const PromptBlockStateSchema = z.strictObject({
|
|
61
|
+
hash: z.string(),
|
|
62
|
+
chars: z.int(),
|
|
63
|
+
seq: z.int(),
|
|
64
|
+
});
|
|
65
|
+
/**
|
|
66
|
+
* Every block the app has written, by name, without its text. The history between the static and
|
|
67
|
+
* the dynamic blocks is the turns.
|
|
68
|
+
*/
|
|
69
|
+
export const PromptStateSchema = z.record(z.string(), PromptBlockStateSchema);
|
|
70
|
+
/** One confirmation the platform asked for, and how it went. */
|
|
71
|
+
export const ConfirmSchema = z.strictObject({
|
|
72
|
+
tool: z.string(),
|
|
73
|
+
call_id: z.string(),
|
|
74
|
+
audience: z.string(),
|
|
75
|
+
phrase: z.string(),
|
|
76
|
+
status: z.enum(["pending", "granted", "declined"]),
|
|
77
|
+
said: z.string().nullish(),
|
|
78
|
+
reason: z.string().nullish(),
|
|
79
|
+
});
|
|
80
|
+
/** Whether a supervisor holds the line right now. */
|
|
81
|
+
export const HandoffSchema = z.strictObject({
|
|
82
|
+
active: z.boolean(),
|
|
83
|
+
by: SupervisorSchema.nullable(),
|
|
84
|
+
});
|
|
85
|
+
/** The transfer in flight or the one that happened. */
|
|
86
|
+
export const TransferStateSchema = z.strictObject({
|
|
87
|
+
to: z.string(),
|
|
88
|
+
mode: TransferModeSchema,
|
|
89
|
+
status: z.enum(["requested", "done", "failed"]),
|
|
90
|
+
by: z.enum(["agent", "supervisor"]),
|
|
91
|
+
});
|
|
92
|
+
/** The words on screen right now: interim transcripts that a finished turn clears. */
|
|
93
|
+
export const LiveTranscriptSchema = z.strictObject({
|
|
94
|
+
user: z.string().nullable(),
|
|
95
|
+
agent: z.string().nullable(),
|
|
96
|
+
});
|
|
97
|
+
/** A stretch of seqs this reader never saw. */
|
|
98
|
+
export const GapSchema = z.strictObject({
|
|
99
|
+
from_seq: z.int(),
|
|
100
|
+
to_seq: z.int(),
|
|
101
|
+
});
|
|
102
|
+
/** An error entry, kept so the console can show what went wrong and when. */
|
|
103
|
+
export const LoggedErrorSchema = z.strictObject({
|
|
104
|
+
seq: z.int(),
|
|
105
|
+
code: z.string(),
|
|
106
|
+
message: z.string(),
|
|
107
|
+
});
|
|
108
|
+
/** One participant in the room right now, as the room reported them when they joined. */
|
|
109
|
+
export const ParticipantSchema = z.strictObject({
|
|
110
|
+
identity: z.string(),
|
|
111
|
+
kind: ParticipantKindSchema,
|
|
112
|
+
name: z.string().nullish(),
|
|
113
|
+
joined_at: z.number(),
|
|
114
|
+
speaking: z.boolean(),
|
|
115
|
+
attributes: z.record(z.string(), z.unknown()),
|
|
116
|
+
});
|
|
117
|
+
/** The LiveKit room the call lives in, and who is in it right now. */
|
|
118
|
+
export const RoomSchema = z.strictObject({
|
|
119
|
+
name: z.string(),
|
|
120
|
+
sid: z.string(),
|
|
121
|
+
participants: z.array(ParticipantSchema),
|
|
122
|
+
caller: z.string().nullable(),
|
|
123
|
+
});
|
|
124
|
+
/**
|
|
125
|
+
* One fact that reached the agent from outside the conversation, kept by name and origin. Its data
|
|
126
|
+
* is in the log at that seq.
|
|
127
|
+
*/
|
|
128
|
+
export const ReceivedEventSchema = z.strictObject({
|
|
129
|
+
seq: z.int(),
|
|
130
|
+
name: z.string(),
|
|
131
|
+
source: EventSourceSchema,
|
|
132
|
+
identity: z.string().nullish(),
|
|
133
|
+
});
|
|
134
|
+
/** A line the app wrote into the log with call.log. */
|
|
135
|
+
export const CustomNoteSchema = z.strictObject({
|
|
136
|
+
seq: z.int(),
|
|
137
|
+
name: z.string(),
|
|
138
|
+
data: z.record(z.string(), z.unknown()),
|
|
139
|
+
});
|
|
140
|
+
/** The whole of what a log says, at the seq it was read to. */
|
|
141
|
+
export const StateSchema = z.strictObject({
|
|
142
|
+
seq: z.int(),
|
|
143
|
+
agent: z.string(),
|
|
144
|
+
call: z.string().nullable(),
|
|
145
|
+
status: CallStatusSchema,
|
|
146
|
+
channel: ChannelSchema.nullable(),
|
|
147
|
+
direction: DirectionSchema.nullable(),
|
|
148
|
+
from: z.string().nullable(),
|
|
149
|
+
to: z.string().nullable(),
|
|
150
|
+
caller: ContactSchema.nullable(),
|
|
151
|
+
room: RoomSchema.nullable(),
|
|
152
|
+
started_at: z.number().nullable(),
|
|
153
|
+
ended_at: z.number().nullable(),
|
|
154
|
+
end_reason: EndReasonSchema.nullable(),
|
|
155
|
+
outcome: z.string().nullable(),
|
|
156
|
+
user_state: UserStateSchema.nullable(),
|
|
157
|
+
agent_state: AgentStateSchema.nullable(),
|
|
158
|
+
live: LiveTranscriptSchema,
|
|
159
|
+
turns: z.array(TurnSchema),
|
|
160
|
+
metrics: CollectedMetricsSchema,
|
|
161
|
+
tools: z.array(ToolRunSchema),
|
|
162
|
+
app_state: z.record(z.string(), z.unknown()),
|
|
163
|
+
events: z.array(ReceivedEventSchema),
|
|
164
|
+
prompt: PromptStateSchema,
|
|
165
|
+
tools_visible: z.array(z.string()),
|
|
166
|
+
confirms: z.array(ConfirmSchema),
|
|
167
|
+
memory: z.array(MemoryOpSchema),
|
|
168
|
+
sources: z.array(DocSourceSchema),
|
|
169
|
+
handoff: HandoffSchema,
|
|
170
|
+
held: z.boolean(),
|
|
171
|
+
muted: z.boolean(),
|
|
172
|
+
transfer: TransferStateSchema.nullable(),
|
|
173
|
+
usage: z.array(ModelUsageSchema),
|
|
174
|
+
cost: CostSchema.nullable(),
|
|
175
|
+
routes: z.array(RouteSchema),
|
|
176
|
+
gaps: z.array(GapSchema),
|
|
177
|
+
errors: z.array(LoggedErrorSchema),
|
|
178
|
+
custom: z.array(CustomNoteSchema),
|
|
179
|
+
});
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
// Generated from schema: the unit each measured field is written in. Never edited by hand.
|
|
2
|
+
/** What one field is measured in, by the name the wire uses: `UNITS.ttft` is `"s"`. */
|
|
3
|
+
export const UNITS = {
|
|
4
|
+
acquire_time: "s",
|
|
5
|
+
audio_duration: "s",
|
|
6
|
+
audio_tokens: "tokens",
|
|
7
|
+
avatar_joined_time: "unix s",
|
|
8
|
+
cache_creation_tokens: "tokens",
|
|
9
|
+
cached_tokens: "tokens",
|
|
10
|
+
cached_tokens_details: "object",
|
|
11
|
+
cancelled: "flag",
|
|
12
|
+
characters_count: "chars",
|
|
13
|
+
completion_tokens: "tokens",
|
|
14
|
+
connection_reused: "flag",
|
|
15
|
+
detection_delay: "s",
|
|
16
|
+
duration: "s",
|
|
17
|
+
e2e_latency: "s",
|
|
18
|
+
end_of_turn_delay: "s",
|
|
19
|
+
end_of_utterance_delay: "s",
|
|
20
|
+
idle_time: "s",
|
|
21
|
+
image_tokens: "tokens",
|
|
22
|
+
inference_count: "count",
|
|
23
|
+
inference_duration_total: "s",
|
|
24
|
+
input_audio_tokens: "tokens",
|
|
25
|
+
input_cache_creation_tokens: "tokens",
|
|
26
|
+
input_cached_audio_tokens: "tokens",
|
|
27
|
+
input_cached_image_tokens: "tokens",
|
|
28
|
+
input_cached_text_tokens: "tokens",
|
|
29
|
+
input_cached_tokens: "tokens",
|
|
30
|
+
input_image_tokens: "tokens",
|
|
31
|
+
input_text_tokens: "tokens",
|
|
32
|
+
input_token_details: "object",
|
|
33
|
+
input_tokens: "tokens",
|
|
34
|
+
label: "name",
|
|
35
|
+
llm_metadata: "object",
|
|
36
|
+
llm_node_tps: "tokens/s",
|
|
37
|
+
llm_node_ttfs: "s",
|
|
38
|
+
llm_node_ttft: "s",
|
|
39
|
+
metadata: "object",
|
|
40
|
+
model: "name",
|
|
41
|
+
model_name: "name",
|
|
42
|
+
model_provider: "name",
|
|
43
|
+
num_backchannels: "count",
|
|
44
|
+
num_interruptions: "count",
|
|
45
|
+
num_requests: "count",
|
|
46
|
+
on_user_turn_completed_delay: "s",
|
|
47
|
+
output_audio_tokens: "tokens",
|
|
48
|
+
output_reasoning_tokens: "tokens",
|
|
49
|
+
output_text_tokens: "tokens",
|
|
50
|
+
output_token_details: "object",
|
|
51
|
+
output_tokens: "tokens",
|
|
52
|
+
playback_latency: "s",
|
|
53
|
+
prediction_duration: "s",
|
|
54
|
+
prompt_cached_tokens: "tokens",
|
|
55
|
+
prompt_tokens: "tokens",
|
|
56
|
+
provider: "name",
|
|
57
|
+
provider_request_ids: "ids",
|
|
58
|
+
reasoning_tokens: "tokens",
|
|
59
|
+
request_id: "id",
|
|
60
|
+
segment_id: "id",
|
|
61
|
+
session_duration: "s",
|
|
62
|
+
session_started_time: "unix s",
|
|
63
|
+
speech_id: "id",
|
|
64
|
+
started_speaking_at: "unix s",
|
|
65
|
+
stopped_speaking_at: "unix s",
|
|
66
|
+
streamed: "flag",
|
|
67
|
+
stt_metadata: "object",
|
|
68
|
+
text_tokens: "tokens",
|
|
69
|
+
timestamp: "unix s",
|
|
70
|
+
tokens_per_second: "tokens/s",
|
|
71
|
+
total_duration: "s",
|
|
72
|
+
total_requests: "count",
|
|
73
|
+
total_tokens: "tokens",
|
|
74
|
+
transcription_delay: "s",
|
|
75
|
+
ttfb: "s",
|
|
76
|
+
ttft: "s",
|
|
77
|
+
tts_metadata: "object",
|
|
78
|
+
tts_node_ttfb: "s",
|
|
79
|
+
type: "tag",
|
|
80
|
+
};
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
/** Make the agent say this, verbatim, to the caller. Logged as supervisor.said. */
|
|
3
|
+
export declare const SayVerbSchema: z.ZodObject<{
|
|
4
|
+
verb: z.ZodLiteral<"say">;
|
|
5
|
+
text: z.ZodString;
|
|
6
|
+
}, z.core.$strict>;
|
|
7
|
+
export type SayVerb = z.infer<typeof SayVerbSchema>;
|
|
8
|
+
/**
|
|
9
|
+
* Tell the agent something the caller never hears. It reaches the agent as an instruction for its
|
|
10
|
+
* next reply; logged as supervisor.whispered.
|
|
11
|
+
*/
|
|
12
|
+
export declare const WhisperVerbSchema: z.ZodObject<{
|
|
13
|
+
verb: z.ZodLiteral<"whisper">;
|
|
14
|
+
text: z.ZodString;
|
|
15
|
+
}, z.core.$strict>;
|
|
16
|
+
export type WhisperVerb = z.infer<typeof WhisperVerbSchema>;
|
|
17
|
+
/**
|
|
18
|
+
* The supervisor takes the line: the agent goes quiet and the supervisor's audio replaces it.
|
|
19
|
+
* Logged as supervisor.took_over.
|
|
20
|
+
*/
|
|
21
|
+
export declare const TakeoverVerbSchema: z.ZodObject<{
|
|
22
|
+
verb: z.ZodLiteral<"takeover">;
|
|
23
|
+
}, z.core.$strict>;
|
|
24
|
+
export type TakeoverVerb = z.infer<typeof TakeoverVerbSchema>;
|
|
25
|
+
/**
|
|
26
|
+
* The supervisor hands the line back to the agent, which resumes with the history intact. Logged
|
|
27
|
+
* as supervisor.released.
|
|
28
|
+
*/
|
|
29
|
+
export declare const ReleaseVerbSchema: z.ZodObject<{
|
|
30
|
+
verb: z.ZodLiteral<"release">;
|
|
31
|
+
}, z.core.$strict>;
|
|
32
|
+
export type ReleaseVerb = z.infer<typeof ReleaseVerbSchema>;
|
|
33
|
+
/**
|
|
34
|
+
* Send the caller to another number. Logged as supervisor.transferred, then call.transferred says
|
|
35
|
+
* whether it worked.
|
|
36
|
+
*/
|
|
37
|
+
export declare const TransferVerbSchema: z.ZodObject<{
|
|
38
|
+
verb: z.ZodLiteral<"transfer">;
|
|
39
|
+
to: z.ZodString;
|
|
40
|
+
mode: z.ZodEnum<{
|
|
41
|
+
cold: "cold";
|
|
42
|
+
warm: "warm";
|
|
43
|
+
}>;
|
|
44
|
+
}, z.core.$strict>;
|
|
45
|
+
export type TransferVerb = z.infer<typeof TransferVerbSchema>;
|
|
46
|
+
/**
|
|
47
|
+
* Hang up on the caller's behalf. Logged as supervisor.ended, then call.ended with reason
|
|
48
|
+
* supervisor_ended.
|
|
49
|
+
*/
|
|
50
|
+
export declare const EndVerbSchema: z.ZodObject<{
|
|
51
|
+
verb: z.ZodLiteral<"end">;
|
|
52
|
+
reason: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
53
|
+
}, z.core.$strict>;
|
|
54
|
+
export type EndVerb = z.infer<typeof EndVerbSchema>;
|
|
55
|
+
/** One supervise verb, told apart by its verb field. */
|
|
56
|
+
export declare const VerbSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
57
|
+
verb: z.ZodLiteral<"say">;
|
|
58
|
+
text: z.ZodString;
|
|
59
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
60
|
+
verb: z.ZodLiteral<"whisper">;
|
|
61
|
+
text: z.ZodString;
|
|
62
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
63
|
+
verb: z.ZodLiteral<"takeover">;
|
|
64
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
65
|
+
verb: z.ZodLiteral<"release">;
|
|
66
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
67
|
+
verb: z.ZodLiteral<"transfer">;
|
|
68
|
+
to: z.ZodString;
|
|
69
|
+
mode: z.ZodEnum<{
|
|
70
|
+
cold: "cold";
|
|
71
|
+
warm: "warm";
|
|
72
|
+
}>;
|
|
73
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
74
|
+
verb: z.ZodLiteral<"end">;
|
|
75
|
+
reason: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
76
|
+
}, z.core.$strict>], "verb">;
|
|
77
|
+
export type Verb = z.infer<typeof VerbSchema>;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
// Generated from schema/verbs.json: the supervise verbs. Never edited by hand.
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
import { TransferModeSchema } from "./defs.js";
|
|
4
|
+
/** Make the agent say this, verbatim, to the caller. Logged as supervisor.said. */
|
|
5
|
+
export const SayVerbSchema = z.strictObject({
|
|
6
|
+
verb: z.literal("say"),
|
|
7
|
+
text: z.string(),
|
|
8
|
+
});
|
|
9
|
+
/**
|
|
10
|
+
* Tell the agent something the caller never hears. It reaches the agent as an instruction for its
|
|
11
|
+
* next reply; logged as supervisor.whispered.
|
|
12
|
+
*/
|
|
13
|
+
export const WhisperVerbSchema = z.strictObject({
|
|
14
|
+
verb: z.literal("whisper"),
|
|
15
|
+
text: z.string(),
|
|
16
|
+
});
|
|
17
|
+
/**
|
|
18
|
+
* The supervisor takes the line: the agent goes quiet and the supervisor's audio replaces it.
|
|
19
|
+
* Logged as supervisor.took_over.
|
|
20
|
+
*/
|
|
21
|
+
export const TakeoverVerbSchema = z.strictObject({
|
|
22
|
+
verb: z.literal("takeover"),
|
|
23
|
+
});
|
|
24
|
+
/**
|
|
25
|
+
* The supervisor hands the line back to the agent, which resumes with the history intact. Logged
|
|
26
|
+
* as supervisor.released.
|
|
27
|
+
*/
|
|
28
|
+
export const ReleaseVerbSchema = z.strictObject({
|
|
29
|
+
verb: z.literal("release"),
|
|
30
|
+
});
|
|
31
|
+
/**
|
|
32
|
+
* Send the caller to another number. Logged as supervisor.transferred, then call.transferred says
|
|
33
|
+
* whether it worked.
|
|
34
|
+
*/
|
|
35
|
+
export const TransferVerbSchema = z.strictObject({
|
|
36
|
+
verb: z.literal("transfer"),
|
|
37
|
+
to: z.string(),
|
|
38
|
+
mode: TransferModeSchema,
|
|
39
|
+
});
|
|
40
|
+
/**
|
|
41
|
+
* Hang up on the caller's behalf. Logged as supervisor.ended, then call.ended with reason
|
|
42
|
+
* supervisor_ended.
|
|
43
|
+
*/
|
|
44
|
+
export const EndVerbSchema = z.strictObject({
|
|
45
|
+
verb: z.literal("end"),
|
|
46
|
+
reason: z.string().nullish(),
|
|
47
|
+
});
|
|
48
|
+
/** One supervise verb, told apart by its verb field. */
|
|
49
|
+
export const VerbSchema = z.discriminatedUnion("verb", [SayVerbSchema, WhisperVerbSchema, TakeoverVerbSchema, ReleaseVerbSchema, TransferVerbSchema, EndVerbSchema]);
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
package/dist/reduce.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Entry } from "./generated/envelope.js";
|
|
2
|
+
import type { State } from "./generated/state.js";
|
|
3
|
+
/** Fold every entry, in the order given, into the state an empty log starts from. */
|
|
4
|
+
export declare function reduce(entries: Iterable<Entry>): State;
|
|
5
|
+
/** What an empty log is: nothing known, every list empty, status idle. */
|
|
6
|
+
export declare function initialState(): State;
|
|
7
|
+
/** What a reader says about an entry it cannot read, in the log's own errors list. */
|
|
8
|
+
export declare const UNREADABLE = "unreadable";
|
|
9
|
+
/** One entry folded in. Returns the state to keep going with. */
|
|
10
|
+
export declare function apply(state: State, entry: Entry): State;
|