@pinecall/protocol 0.3.0 → 0.4.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,6 +1,6 @@
1
1
  // Generated from schema/rest.json: the envelopes the read doors answer in. Never edited by hand.
2
2
  import { z } from "zod";
3
- import { ChannelSchema, ContactSchema, CostSchema, DirectionSchema, EndReasonSchema, EnvSchema, KnowledgeFileSchema, PlatformToolSchema, } from "./defs.js";
3
+ import { ChannelSchema, ContactSchema, CostSchema, DirectionSchema, DocsConfigSchema, EndReasonSchema, EnvSchema, GreetingConfigSchema, HangupConfigSchema, KnowledgeFileSchema, MemoryConfigSchema, PlatformToolSchema, PronunciationSchema, TurnConfigSchema, } from "./defs.js";
4
4
  import { EntrySchema } from "./envelope.js";
5
5
  import { CallStatusSchema, StateSchema } from "./state.js";
6
6
  /** GET /v1/calls/{call}/state: the whole log folded, and the seq a stream resumes from. */
@@ -399,13 +399,15 @@ export const KnowledgeScoreSchema = z.strictObject({
399
399
  misses: z.array(GoldenMissSchema),
400
400
  });
401
401
  /**
402
- * PUT /v1/knowledge/{base}, the answer: which base, how many chunks it became, and how long that
403
- * took.
402
+ * PUT /v1/knowledge/{base}, the answer: which base, how many chunks it became, how long that took,
403
+ * and what its whole files weigh on every call.
404
404
  */
405
405
  export const KnowledgePushedSchema = z.strictObject({
406
406
  base: z.string(),
407
407
  chunks: z.int(),
408
408
  took_ms: z.number(),
409
+ whole_tokens: z.int().nullish(),
410
+ notice: z.string().nullable().nullish(),
409
411
  });
410
412
  /** One knowledge base as the list draws it: its name, its size, and when it was last pushed. */
411
413
  export const KnowledgeBaseSchema = z.strictObject({
@@ -551,8 +553,9 @@ export const ExtractionRunSchema = z.strictObject({
551
553
  });
552
554
  /**
553
555
  * POST /v1/calls/{call}/lookup, the body: which platform tool to run for this turn, and what to
554
- * run it with. Worker-only; the gateway runs it against its own stores and writes memory.ops or
555
- * docs.sources on the call's log itself.
556
+ * run it with. Asked by the worker for the call it serves, and by the app for a call of its own
557
+ * org — `this.knowledge.search` in a tool; the gateway runs it against its own stores and writes
558
+ * memory.ops or docs.sources on the call's log itself.
556
559
  */
557
560
  export const LookupRequestSchema = z.strictObject({
558
561
  tool: PlatformToolSchema,
@@ -568,6 +571,19 @@ export const LookupResultSchema = z.strictObject({
568
571
  output: z.record(z.string(), z.unknown()),
569
572
  took_ms: z.number(),
570
573
  });
574
+ /** One chunk search found: the file it came from, the heading it sits under, and its text. */
575
+ export const FoundChunkSchema = z.strictObject({
576
+ path: z.string(),
577
+ heading: z.string().nullable(),
578
+ text: z.string(),
579
+ });
580
+ /**
581
+ * What search answers in a lookup's output: the best chunks of every base the agent reads, the
582
+ * best first. The app's `this.knowledge.search` hands the chunks to the tool that asked.
583
+ */
584
+ export const SearchFoundSchema = z.strictObject({
585
+ chunks: z.array(FoundChunkSchema),
586
+ });
571
587
  /**
572
588
  * POST /v1/calls/{call}/remember, the answer: what the call taught about the contact, counted.
573
589
  * Worker-only; the body is empty, the gateway reads the turns off its own log and writes
@@ -614,3 +630,137 @@ export const OutboundProvisionedSchema = z.strictObject({
614
630
  trunk: z.string().nullish(),
615
631
  address: z.string().nullish(),
616
632
  });
633
+ /**
634
+ * An agent's tuning: what the org set over what the app declared, per world and per corner. Every
635
+ * field is optional; one left out is not set, and what the app declared — or the runtime's own
636
+ * default — stands for it.
637
+ */
638
+ export const TuningBodySchema = z.strictObject({
639
+ voice: z.string().nullish(),
640
+ tts: z.string().nullish(),
641
+ tts_model: z.string().nullish(),
642
+ stt: z.string().nullish(),
643
+ llm: z.string().nullish(),
644
+ greeting: GreetingConfigSchema.nullish(),
645
+ hangup: HangupConfigSchema.nullish(),
646
+ turn: TurnConfigSchema.nullish(),
647
+ memory: MemoryConfigSchema.nullish(),
648
+ knowledge: z.array(DocsConfigSchema).nullish(),
649
+ });
650
+ /**
651
+ * One kept version of an agent's tuning: whose corner, which version, who set it and when, and
652
+ * what it says.
653
+ */
654
+ export const TuningRowSchema = z.strictObject({
655
+ holder: z.string(),
656
+ version: z.int(),
657
+ author: z.string(),
658
+ note: z.string().nullable(),
659
+ set_at: z.number(),
660
+ config: TuningBodySchema,
661
+ });
662
+ /**
663
+ * GET /v1/agents/{slug}/settings: the agent's tuning as this key sees it — its own corner's, the
664
+ * team's and production's, each corner's own newest row, or null when that corner set nothing.
665
+ */
666
+ export const TuningAnswerSchema = z.strictObject({
667
+ world: EnvSchema,
668
+ yours: TuningRowSchema.nullable(),
669
+ team: TuningRowSchema.nullable(),
670
+ production: TuningRowSchema.nullable(),
671
+ });
672
+ /**
673
+ * PUT /v1/agents/{slug}/settings, the body: the whole set, the version it was read at, why, and
674
+ * whose corner.
675
+ */
676
+ export const TuningPutSchema = z.strictObject({
677
+ config: TuningBodySchema,
678
+ if_version: z.int().nullable().nullish(),
679
+ note: z.string().nullable().nullish(),
680
+ team: z.boolean().nullish(),
681
+ });
682
+ /** GET /v1/agents/{slug}/settings/history: one corner's versions, newest first. */
683
+ export const TuningHistorySchema = z.strictObject({
684
+ world: EnvSchema,
685
+ holder: z.string(),
686
+ rows: z.array(TuningRowSchema),
687
+ });
688
+ /**
689
+ * GET /v1/agents/{slug}/settings/diff: what this key's corner reads against another corner's
690
+ * newest, and which fields differ.
691
+ */
692
+ export const TuningDiffSchema = z.strictObject({
693
+ ours: TuningRowSchema.nullable(),
694
+ theirs: TuningRowSchema.nullable(),
695
+ changed: z.array(z.string()),
696
+ });
697
+ /**
698
+ * POST /v1/agents/{slug}/settings/rollback, the body: which version to bring back. It comes back
699
+ * as a NEW version; nothing is deleted.
700
+ */
701
+ export const RollbackSchema = z.strictObject({
702
+ version: z.int(),
703
+ team: z.boolean().nullish(),
704
+ });
705
+ /**
706
+ * The org's lexicon: how the voice says the words it would get wrong, and the words the ears must
707
+ * know. Shared by every agent of the org, laid over each one's own says and hears.
708
+ */
709
+ export const LexiconBodySchema = z.strictObject({
710
+ said: z.array(PronunciationSchema),
711
+ heard: z.array(z.string()),
712
+ });
713
+ /** One kept version of the org's lexicon. */
714
+ export const LexiconRowSchema = z.strictObject({
715
+ holder: z.string(),
716
+ version: z.int(),
717
+ author: z.string(),
718
+ note: z.string().nullable(),
719
+ set_at: z.number(),
720
+ lexicon: LexiconBodySchema,
721
+ });
722
+ /**
723
+ * GET /v1/lexicon: the org's words as this key sees them — its own corner's, the team's and
724
+ * production's, each corner's own newest, or null.
725
+ */
726
+ export const LexiconAnswerSchema = z.strictObject({
727
+ world: EnvSchema,
728
+ yours: LexiconRowSchema.nullable(),
729
+ team: LexiconRowSchema.nullable(),
730
+ production: LexiconRowSchema.nullable(),
731
+ });
732
+ /** PUT /v1/lexicon, the body: the whole lexicon, the version it was read at, why, and whose corner. */
733
+ export const LexiconPutSchema = z.strictObject({
734
+ lexicon: LexiconBodySchema,
735
+ if_version: z.int().nullable().nullish(),
736
+ note: z.string().nullable().nullish(),
737
+ team: z.boolean().nullish(),
738
+ });
739
+ /** GET /v1/lexicon/history: one corner's versions, newest first. */
740
+ export const LexiconHistorySchema = z.strictObject({
741
+ world: EnvSchema,
742
+ holder: z.string(),
743
+ rows: z.array(LexiconRowSchema),
744
+ });
745
+ /**
746
+ * GET /v1/calls/{call}/settings: the exact tuning and lexicon a call was built on, by the versions
747
+ * its head row recorded.
748
+ */
749
+ export const CallTuningSchema = z.strictObject({
750
+ config_version: z.int().nullable(),
751
+ lexicon_version: z.int().nullable(),
752
+ config: TuningRowSchema.nullable(),
753
+ lexicon: LexiconRowSchema.nullable(),
754
+ });
755
+ /** One base and the agents whose settings attach it. */
756
+ export const KnowledgeUseSchema = z.strictObject({
757
+ base: z.string(),
758
+ agents: z.array(z.string()),
759
+ });
760
+ /**
761
+ * GET /v1/knowledge/attached: which agents read each base, off every agent's newest settings in
762
+ * this world.
763
+ */
764
+ export const KnowledgeUsesSchema = z.strictObject({
765
+ bases: z.array(KnowledgeUseSchema),
766
+ });
@@ -23,9 +23,9 @@ export declare const ParticipantJoinedSchema: z.ZodObject<{
23
23
  kind: z.ZodEnum<{
24
24
  agent: "agent";
25
25
  caller: "caller";
26
- supervisor: "supervisor";
27
26
  listener: "listener";
28
27
  sip: "sip";
28
+ supervisor: "supervisor";
29
29
  }>;
30
30
  name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
31
31
  attributes: z.ZodRecord<z.ZodString, z.ZodUnknown>;
@@ -51,15 +51,15 @@ export declare const TrackPublishedSchema: z.ZodObject<{
51
51
  identity: z.ZodString;
52
52
  kind: z.ZodEnum<{
53
53
  audio: "audio";
54
- video: "video";
55
54
  screen: "screen";
55
+ video: "video";
56
56
  }>;
57
57
  source: z.ZodEnum<{
58
- unknown: "unknown";
59
- microphone: "microphone";
60
58
  camera: "camera";
59
+ microphone: "microphone";
61
60
  screen_share: "screen_share";
62
61
  screen_share_audio: "screen_share_audio";
62
+ unknown: "unknown";
63
63
  }>;
64
64
  }, z.core.$strict>;
65
65
  export type TrackPublished = z.infer<typeof TrackPublishedSchema>;
@@ -71,15 +71,15 @@ export declare const TrackUnpublishedSchema: z.ZodObject<{
71
71
  identity: z.ZodString;
72
72
  kind: z.ZodEnum<{
73
73
  audio: "audio";
74
- video: "video";
75
74
  screen: "screen";
75
+ video: "video";
76
76
  }>;
77
77
  source: z.ZodEnum<{
78
- unknown: "unknown";
79
- microphone: "microphone";
80
78
  camera: "camera";
79
+ microphone: "microphone";
81
80
  screen_share: "screen_share";
82
81
  screen_share_audio: "screen_share_audio";
82
+ unknown: "unknown";
83
83
  }>;
84
84
  }, z.core.$strict>;
85
85
  export type TrackUnpublished = z.infer<typeof TrackUnpublishedSchema>;
@@ -4,11 +4,11 @@ import { z } from "zod";
4
4
  * looks like.
5
5
  */
6
6
  export declare const CallStatusSchema: z.ZodEnum<{
7
- idle: "idle";
8
- ringing: "ringing";
9
- dialing: "dialing";
10
7
  active: "active";
8
+ dialing: "dialing";
11
9
  ended: "ended";
10
+ idle: "idle";
11
+ ringing: "ringing";
12
12
  }>;
13
13
  export type CallStatus = z.infer<typeof CallStatusSchema>;
14
14
  /** One finished turn of the caller, with what the session measured about it. */
@@ -277,9 +277,9 @@ export declare const ToolRunSchema: z.ZodObject<{
277
277
  arguments: z.ZodRecord<z.ZodString, z.ZodUnknown>;
278
278
  speech_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
279
279
  status: z.ZodEnum<{
280
- running: "running";
281
280
  done: "done";
282
281
  failed: "failed";
282
+ running: "running";
283
283
  }>;
284
284
  output: z.ZodOptional<z.ZodNullable<z.ZodUnknown>>;
285
285
  error: z.ZodOptional<z.ZodNullable<z.ZodString>>;
@@ -312,9 +312,9 @@ export declare const ConfirmSchema: z.ZodObject<{
312
312
  audience: z.ZodString;
313
313
  phrase: z.ZodString;
314
314
  status: z.ZodEnum<{
315
- pending: "pending";
316
- granted: "granted";
317
315
  declined: "declined";
316
+ granted: "granted";
317
+ pending: "pending";
318
318
  }>;
319
319
  said: z.ZodOptional<z.ZodNullable<z.ZodString>>;
320
320
  reason: z.ZodOptional<z.ZodNullable<z.ZodString>>;
@@ -372,9 +372,9 @@ export declare const ParticipantSchema: z.ZodObject<{
372
372
  kind: z.ZodEnum<{
373
373
  agent: "agent";
374
374
  caller: "caller";
375
- supervisor: "supervisor";
376
375
  listener: "listener";
377
376
  sip: "sip";
377
+ supervisor: "supervisor";
378
378
  }>;
379
379
  name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
380
380
  joined_at: z.ZodNumber;
@@ -391,9 +391,9 @@ export declare const RoomSchema: z.ZodObject<{
391
391
  kind: z.ZodEnum<{
392
392
  agent: "agent";
393
393
  caller: "caller";
394
- supervisor: "supervisor";
395
394
  listener: "listener";
396
395
  sip: "sip";
396
+ supervisor: "supervisor";
397
397
  }>;
398
398
  name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
399
399
  joined_at: z.ZodNumber;
@@ -430,11 +430,11 @@ export declare const StateSchema: z.ZodObject<{
430
430
  agent: z.ZodString;
431
431
  call: z.ZodNullable<z.ZodString>;
432
432
  status: z.ZodEnum<{
433
- idle: "idle";
434
- ringing: "ringing";
435
- dialing: "dialing";
436
433
  active: "active";
434
+ dialing: "dialing";
437
435
  ended: "ended";
436
+ idle: "idle";
437
+ ringing: "ringing";
438
438
  }>;
439
439
  channel: z.ZodNullable<z.ZodEnum<{
440
440
  phone: "phone";
@@ -462,9 +462,9 @@ export declare const StateSchema: z.ZodObject<{
462
462
  kind: z.ZodEnum<{
463
463
  agent: "agent";
464
464
  caller: "caller";
465
- supervisor: "supervisor";
466
465
  listener: "listener";
467
466
  sip: "sip";
467
+ supervisor: "supervisor";
468
468
  }>;
469
469
  name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
470
470
  joined_at: z.ZodNumber;
@@ -476,29 +476,29 @@ export declare const StateSchema: z.ZodObject<{
476
476
  started_at: z.ZodNullable<z.ZodNumber>;
477
477
  ended_at: z.ZodNullable<z.ZodNumber>;
478
478
  end_reason: z.ZodNullable<z.ZodEnum<{
479
- caller_hung_up: "caller_hung_up";
480
479
  agent_hung_up: "agent_hung_up";
481
- supervisor_ended: "supervisor_ended";
482
- transferred: "transferred";
483
- no_answer: "no_answer";
480
+ app_detached: "app_detached";
484
481
  busy: "busy";
482
+ caller_hung_up: "caller_hung_up";
485
483
  dial_failed: "dial_failed";
486
- timeout: "timeout";
487
484
  drained: "drained";
488
- app_detached: "app_detached";
489
485
  error: "error";
486
+ no_answer: "no_answer";
487
+ supervisor_ended: "supervisor_ended";
488
+ timeout: "timeout";
489
+ transferred: "transferred";
490
490
  }>>;
491
491
  outcome: z.ZodNullable<z.ZodString>;
492
492
  user_state: z.ZodNullable<z.ZodEnum<{
493
+ away: "away";
493
494
  listening: "listening";
494
495
  speaking: "speaking";
495
- away: "away";
496
496
  }>>;
497
497
  agent_state: z.ZodNullable<z.ZodEnum<{
498
+ idle: "idle";
499
+ initializing: "initializing";
498
500
  listening: "listening";
499
501
  speaking: "speaking";
500
- initializing: "initializing";
501
- idle: "idle";
502
502
  thinking: "thinking";
503
503
  }>>;
504
504
  live: z.ZodObject<{
@@ -714,9 +714,9 @@ export declare const StateSchema: z.ZodObject<{
714
714
  arguments: z.ZodRecord<z.ZodString, z.ZodUnknown>;
715
715
  speech_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
716
716
  status: z.ZodEnum<{
717
- running: "running";
718
717
  done: "done";
719
718
  failed: "failed";
719
+ running: "running";
720
720
  }>;
721
721
  output: z.ZodOptional<z.ZodNullable<z.ZodUnknown>>;
722
722
  error: z.ZodOptional<z.ZodNullable<z.ZodString>>;
@@ -746,18 +746,18 @@ export declare const StateSchema: z.ZodObject<{
746
746
  audience: z.ZodString;
747
747
  phrase: z.ZodString;
748
748
  status: z.ZodEnum<{
749
- pending: "pending";
750
- granted: "granted";
751
749
  declined: "declined";
750
+ granted: "granted";
751
+ pending: "pending";
752
752
  }>;
753
753
  said: z.ZodOptional<z.ZodNullable<z.ZodString>>;
754
754
  reason: z.ZodOptional<z.ZodNullable<z.ZodString>>;
755
755
  }, z.core.$strict>>;
756
756
  memory: z.ZodArray<z.ZodObject<{
757
757
  op: z.ZodEnum<{
758
+ forget: "forget";
758
759
  recall: "recall";
759
760
  remember: "remember";
760
- forget: "forget";
761
761
  }>;
762
762
  contact: z.ZodOptional<z.ZodNullable<z.ZodString>>;
763
763
  query: z.ZodOptional<z.ZodNullable<z.ZodString>>;
@@ -857,12 +857,12 @@ export declare const StateSchema: z.ZodObject<{
857
857
  provider: z.ZodString;
858
858
  model: z.ZodString;
859
859
  unit: z.ZodEnum<{
860
- input_tokens: "input_tokens";
861
- cached_input_tokens: "cached_input_tokens";
860
+ audio_seconds: "audio_seconds";
862
861
  cache_creation_tokens: "cache_creation_tokens";
863
- output_tokens: "output_tokens";
862
+ cached_input_tokens: "cached_input_tokens";
864
863
  characters: "characters";
865
- audio_seconds: "audio_seconds";
864
+ input_tokens: "input_tokens";
865
+ output_tokens: "output_tokens";
866
866
  requests: "requests";
867
867
  session_seconds: "session_seconds";
868
868
  }>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pinecall/protocol",
3
- "version": "0.3.0",
3
+ "version": "0.4.0",
4
4
  "description": "The Pinecall wire: zod schemas and types generated from the protocol schema, and the log reducer",
5
5
  "license": "Apache-2.0",
6
6
  "author": "Pinecall <hello@pinecall.io>",