glove-foundry 0.10.0 → 0.11.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/dist/index.js CHANGED
@@ -43,7 +43,7 @@ import {
43
43
  memoryTopologyStore,
44
44
  serializeInboundTransmissionXml,
45
45
  writeGeneratedTypes
46
- } from "./chunk-PMNRLJIQ.js";
46
+ } from "./chunk-YCW66WKQ.js";
47
47
  import {
48
48
  FoundryClient,
49
49
  FoundryRunHandle,
@@ -63,7 +63,7 @@ import {
63
63
  defineWorkingEnvironment,
64
64
  foundryDataEnvironmentPersistence,
65
65
  foundryGuidanceSubject
66
- } from "./chunk-X3HZYVZS.js";
66
+ } from "./chunk-LCDEHWRB.js";
67
67
  import {
68
68
  DEFAULT_APPROVAL_EXPIRES_AFTER_MS,
69
69
  DEFAULT_APPROVAL_WAIT_MS,
@@ -116,14 +116,20 @@ import {
116
116
  resolveFoundryApproval,
117
117
  routeFromAgentFile,
118
118
  scheduleOccurrenceId,
119
+ scheduleRevisionMatches,
119
120
  toGloveMessage,
120
121
  toGloveRequestInput,
121
122
  transmissionPredicate,
122
123
  withFoundryPermissions
123
- } from "./chunk-T6YLIGER.js";
124
+ } from "./chunk-4WBQ7XVF.js";
124
125
  import {
126
+ assertEventReceipt,
127
+ eventReceiptStore,
128
+ eventTranscriptMessageId,
129
+ lateChatEffectId,
130
+ matchesReceiptFilter,
125
131
  meshIdentity
126
- } from "./chunk-J6NHL4SM.js";
132
+ } from "./chunk-2JCISE2U.js";
127
133
  import {
128
134
  EMPTY_CAPABILITY_REGISTRY,
129
135
  EMPTY_NATIVE_REGISTRY,
@@ -170,7 +176,7 @@ import {
170
176
  mountFoundrySurfaces,
171
177
  restrictApp,
172
178
  routeFromInternalAgentName
173
- } from "./chunk-CYOIHSUX.js";
179
+ } from "./chunk-NWFOY3L7.js";
174
180
 
175
181
  // src/file-data.ts
176
182
  import { randomUUID } from "node:crypto";
@@ -188,6 +194,7 @@ function emptyState(environment) {
188
194
  approvals: [],
189
195
  activations: [],
190
196
  occurrences: [],
197
+ receipts: [],
191
198
  conversations: [],
192
199
  workspaceEntries: [],
193
200
  workingEnvironments: [],
@@ -298,6 +305,7 @@ var FileFoundryDataAdapter = class {
298
305
  approvals: parsed.approvals ?? [],
299
306
  activations: parsed.activations ?? [],
300
307
  occurrences: parsed.occurrences ?? [],
308
+ receipts: parsed.receipts ?? [],
301
309
  conversations: parsed.conversations ?? [],
302
310
  workspaceEntries: parsed.workspaceEntries ?? [],
303
311
  workingEnvironments: parsed.workingEnvironments ?? [],
@@ -423,6 +431,7 @@ var FileFoundryDataAdapter = class {
423
431
  state.approvals = state.approvals.filter((item) => item.agentId !== agentId);
424
432
  state.activations = state.activations.filter((item) => item.agentId !== agentId);
425
433
  state.occurrences = state.occurrences.filter((item) => item.agentId !== agentId);
434
+ state.receipts = state.receipts.filter((item) => item.agentId !== agentId);
426
435
  state.conversations = state.conversations.filter((item) => item.agentId !== agentId);
427
436
  state.workingEnvironments = state.workingEnvironments.filter((item) => item.owner.agentId !== agentId);
428
437
  state.inbox = state.inbox.filter((item) => item.agentId !== agentId && !ids.has(item.conversationId ?? ""));
@@ -514,6 +523,32 @@ var FileFoundryDataAdapter = class {
514
523
  listEvents() {
515
524
  return effect(async () => structuredClone((await this.snapshot()).events));
516
525
  }
526
+ claimEventReceipt(receipt) {
527
+ return effect(async () => {
528
+ assertEventReceipt(receipt);
529
+ await this.ensureInitialized();
530
+ return this.mutate((state) => {
531
+ if (state.receipts.some((item) => item.id === receipt.id)) return false;
532
+ state.receipts.push(structuredClone(receipt));
533
+ return true;
534
+ });
535
+ });
536
+ }
537
+ putEventReceipt(receipt) {
538
+ return effect(async () => {
539
+ assertEventReceipt(receipt);
540
+ await this.ensureInitialized();
541
+ await this.mutate((state) => {
542
+ replaceById(state.receipts, receipt);
543
+ });
544
+ });
545
+ }
546
+ getEventReceipt(id) {
547
+ return effect(async () => structuredClone((await this.snapshot()).receipts.find((item) => item.id === id) ?? null));
548
+ }
549
+ listEventReceipts(filter) {
550
+ return effect(async () => structuredClone((await this.snapshot()).receipts.filter((item) => matchesReceiptFilter(item, filter))));
551
+ }
517
552
  claimScheduleOccurrence(occurrence) {
518
553
  return effect(async () => {
519
554
  assertScheduleOccurrence(occurrence);
@@ -994,6 +1029,8 @@ export {
994
1029
  defineTransmissionPredicate,
995
1030
  defineWorkingEnvironment,
996
1031
  discoverAgents,
1032
+ eventReceiptStore,
1033
+ eventTranscriptMessageId,
997
1034
  fileTopologyStore,
998
1035
  findAgentFiles,
999
1036
  foundryDataEnvironmentPersistence,
@@ -1015,6 +1052,7 @@ export {
1015
1052
  isFoundryTransmission,
1016
1053
  isInboxCapableStore,
1017
1054
  isMeshTransport,
1055
+ lateChatEffectId,
1018
1056
  listFoundryApprovals,
1019
1057
  memoryAccountDirectory,
1020
1058
  memoryEventStore,
@@ -1030,6 +1068,7 @@ export {
1030
1068
  routeFromAgentFile,
1031
1069
  routeFromInternalAgentName,
1032
1070
  scheduleOccurrenceId,
1071
+ scheduleRevisionMatches,
1033
1072
  serializeInboundTransmissionXml,
1034
1073
  toGloveMessage,
1035
1074
  toGloveRequestInput,
package/dist/voice.d.ts CHANGED
@@ -1,6 +1,6 @@
1
- import { IGloveRunnable } from 'glove-core';
1
+ import { AgentEvent, IGloveRunnable } from 'glove-core';
2
2
  import { RealtimeAgent, RealtimeAgentConfig } from 'glove-voice-s2s';
3
- import { A as AgentHandlerContext, F as FoundryDelegationUpdate, a as FoundryMeshMessage } from './event-delivery-a9B1Qq_u.js';
3
+ import { F as FoundryEventPreparation, a as FoundryEventReceipt, A as AgentHandlerContext, b as FoundryDelegationUpdate, c as FoundryMeshMessage } from './event-delivery-BfSL9sGo.js';
4
4
  import 'effect';
5
5
  import 'zod';
6
6
  import 'glove-mesh';
@@ -15,6 +15,73 @@ import 'glove-facts';
15
15
  import 'glove-memory/goals';
16
16
  import 'glove-memory/forms';
17
17
 
18
+ /**
19
+ * Addressed events on a voice call: told at a pause in speech, from facts
20
+ * read just before telling, as product context rather than as the caller,
21
+ * with a durable receipt so that no restart says one twice.
22
+ *
23
+ * Each event moves through a receipt (see event-receipts.ts):
24
+ *
25
+ * queued ──prepare──▶ suppressed (nothing due: silent)
26
+ * │
27
+ * └─▶ dispatching ──inject──▶ accepted ──▶ transcript written ──▶ ack
28
+ * │
29
+ * └─ (crash here: the outcome is unknown; never replayed)
30
+ *
31
+ * queued at call end ──afterCall──▶ redirecting ──▶ redirected ──▶ ack
32
+ *
33
+ * The receipt is written before every step that has an effect, so recovery
34
+ * knows which steps happened. "accepted" means the provider's transport took
35
+ * the text locally: not that anyone heard it.
36
+ */
37
+
38
+ interface VoiceEventContext {
39
+ readonly runId: string;
40
+ /** This call: with the run id, the generation a dispatch belongs to. */
41
+ readonly callId: string;
42
+ readonly agentId: string;
43
+ readonly conversationId: string;
44
+ readonly workspaceId: string;
45
+ /** The event's journal id: the same on every redelivery. */
46
+ readonly eventRecordId: string;
47
+ readonly signal: AbortSignal;
48
+ }
49
+ interface VoiceCallEvents {
50
+ /** Which addressed events (agent messages and transmissions) this call tells. Others are left to the run. */
51
+ readonly accept: (event: AgentEvent) => boolean;
52
+ /**
53
+ * Read current facts just before telling, once the call has paused. Return
54
+ * `{ say }` with what to tell now or `{ suppress }` when nothing is due any
55
+ * more (cancelled, moved, too late). Throwing tells nothing and keeps the
56
+ * event for a later pause. Default: say the event's text.
57
+ */
58
+ readonly prepare?: (event: AgentEvent, context: VoiceEventContext) => FoundryEventPreparation | Promise<FoundryEventPreparation>;
59
+ /** The transcript line for a told event. Default: `[event from <source>] <text>`. */
60
+ readonly transcript?: (event: AgentEvent, said: string) => string;
61
+ /**
62
+ * Tell an event some other way (a chat message, say) when its call ended
63
+ * before it was ever attempted, or when it arrives with no call open. Runs
64
+ * only for events never dispatched to the call, and under an `effectId`
65
+ * derived from the event that is the same on every retry: make the effect
66
+ * idempotent on it. Without this, such events stay pending for the
67
+ * conversation's next run.
68
+ */
69
+ readonly afterCall?: (event: AgentEvent, context: VoiceEventContext & {
70
+ readonly effectId: string;
71
+ }) => Promise<void>;
72
+ /**
73
+ * An event whose dispatch began on another run or call and whose outcome
74
+ * is unknown (the process died mid-dispatch). Return "accepted" or
75
+ * "suppressed" when the product can tell, from a provider receipt for
76
+ * instance. Anything else keeps it held: it is never spoken again or sent
77
+ * to chat automatically.
78
+ */
79
+ readonly resolveUncertain?: (receipt: FoundryEventReceipt, context: VoiceEventContext) => Promise<"accepted" | "suppressed" | undefined>;
80
+ /** Ask the model to say something about a told event. Default true. */
81
+ readonly respond?: boolean;
82
+ }
83
+ declare function defaultEventTranscript(event: AgentEvent, said: string): string;
84
+
18
85
  /**
19
86
  * Foundry tools that have no place in a spoken conversation. Durable,
20
87
  * long-running or bookkeeping work belongs to a delegate, not the call.
@@ -86,6 +153,15 @@ interface VoiceCallOptions {
86
153
  * call starts knowing it.
87
154
  */
88
155
  readonly offCall?: (agent: IGloveRunnable, context: AgentHandlerContext) => unknown;
156
+ /**
157
+ * Tell addressed events (agent messages and transmissions) on the call:
158
+ * the ones `accept` takes wait for a pause, are prepared from current facts
159
+ * just before they are told, go to the model as system context rather than
160
+ * as the caller, and keep a durable receipt so that no restart tells one
161
+ * twice. A run started only by such events, with no call to tell them on,
162
+ * opens no room: `afterCall` handles them, or they stay pending.
163
+ */
164
+ readonly events?: VoiceCallEvents;
89
165
  }
90
166
  interface VoiceCallResult {
91
167
  readonly endedBecause: string;
@@ -94,6 +170,8 @@ interface VoiceCallResult {
94
170
  readonly turns: number;
95
171
  /** Delegation updates and mesh messages put to the caller during the call. */
96
172
  readonly updatesSpoken: number;
173
+ /** Addressed events told on the call (accepted by the provider, which is not proof they were heard). */
174
+ readonly eventsTold?: number;
97
175
  }
98
176
  /** The default way a delegation update is put to the model mid-call. */
99
177
  declare function announceDelegationUpdate(update: FoundryDelegationUpdate): string;
@@ -169,4 +247,4 @@ interface WebSocketRoomOptions {
169
247
  */
170
248
  declare function webSocketRoom(options: WebSocketRoomOptions): FoundryVoiceRoom;
171
249
 
172
- export { type FoundryVoiceCall, type FoundryVoiceRoom, VOICE_EXCLUDED_FOUNDRY_TOOLS, type VoiceCallOptions, type VoiceCallResult, type VoiceRoomClientMessage, type VoiceRoomServerMessage, type WebSocketRoomOptions, announceDelegationUpdate, announceMeshMessage, voiceCall, webSocketRoom };
250
+ export { type FoundryVoiceCall, type FoundryVoiceRoom, VOICE_EXCLUDED_FOUNDRY_TOOLS, type VoiceCallEvents, type VoiceCallOptions, type VoiceCallResult, type VoiceEventContext, type VoiceRoomClientMessage, type VoiceRoomServerMessage, type WebSocketRoomOptions, announceDelegationUpdate, announceMeshMessage, defaultEventTranscript, voiceCall, webSocketRoom };