@spine-event-engine/server 2.0.0-snapshot.22 → 2.0.0-snapshot.24
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/README.md +104 -7
- package/REFERENCE.md +272 -31
- package/dist/agent/agent-admission.d.ts +80 -0
- package/dist/agent/agent-admission.d.ts.map +1 -0
- package/dist/agent/agent-admission.js +127 -0
- package/dist/agent/agent-admission.js.map +1 -0
- package/dist/agent/agent-ai-binding.d.ts +24 -0
- package/dist/agent/agent-ai-binding.d.ts.map +1 -0
- package/dist/agent/agent-ai-binding.js +48 -0
- package/dist/agent/agent-ai-binding.js.map +1 -0
- package/dist/agent/agent-ai-runtime.d.ts +76 -0
- package/dist/agent/agent-ai-runtime.d.ts.map +1 -0
- package/dist/agent/agent-ai-runtime.js +1269 -0
- package/dist/agent/agent-ai-runtime.js.map +1 -0
- package/dist/agent/agent-execution-capacity.d.ts +43 -0
- package/dist/agent/agent-execution-capacity.d.ts.map +1 -0
- package/dist/agent/agent-execution-capacity.js +147 -0
- package/dist/agent/agent-execution-capacity.js.map +1 -0
- package/dist/agent/agent-execution-fault.d.ts +18 -0
- package/dist/agent/agent-execution-fault.d.ts.map +1 -0
- package/dist/agent/agent-execution-fault.js +31 -0
- package/dist/agent/agent-execution-fault.js.map +1 -0
- package/dist/agent/agent-execution-session.d.ts +103 -0
- package/dist/agent/agent-execution-session.d.ts.map +1 -0
- package/dist/agent/agent-execution-session.js +238 -0
- package/dist/agent/agent-execution-session.js.map +1 -0
- package/dist/agent/agent-history.d.ts +148 -0
- package/dist/agent/agent-history.d.ts.map +1 -0
- package/dist/agent/agent-history.js +340 -0
- package/dist/agent/agent-history.js.map +1 -0
- package/dist/agent/agent-interaction-audit.d.ts +58 -0
- package/dist/agent/agent-interaction-audit.d.ts.map +1 -0
- package/dist/agent/agent-interaction-audit.js +114 -0
- package/dist/agent/agent-interaction-audit.js.map +1 -0
- package/dist/agent/agent-interaction-events.d.ts +40 -0
- package/dist/agent/agent-interaction-events.d.ts.map +1 -0
- package/dist/agent/agent-interaction-events.js +129 -0
- package/dist/agent/agent-interaction-events.js.map +1 -0
- package/dist/agent/agent-mcp-budget.d.ts +125 -0
- package/dist/agent/agent-mcp-budget.d.ts.map +1 -0
- package/dist/agent/agent-mcp-budget.js +566 -0
- package/dist/agent/agent-mcp-budget.js.map +1 -0
- package/dist/agent/agent-mcp-host.d.ts +125 -0
- package/dist/agent/agent-mcp-host.d.ts.map +1 -0
- package/dist/agent/agent-mcp-host.js +15 -0
- package/dist/agent/agent-mcp-host.js.map +1 -0
- package/dist/agent/agent-mcp-runtime.d.ts +199 -0
- package/dist/agent/agent-mcp-runtime.d.ts.map +1 -0
- package/dist/agent/agent-mcp-runtime.js +621 -0
- package/dist/agent/agent-mcp-runtime.js.map +1 -0
- package/dist/agent/agent-model-selection.d.ts +129 -0
- package/dist/agent/agent-model-selection.d.ts.map +1 -0
- package/dist/agent/agent-model-selection.js +342 -0
- package/dist/agent/agent-model-selection.js.map +1 -0
- package/dist/agent/agent-read-runtime.d.ts +70 -0
- package/dist/agent/agent-read-runtime.d.ts.map +1 -0
- package/dist/agent/agent-read-runtime.js +320 -0
- package/dist/agent/agent-read-runtime.js.map +1 -0
- package/dist/agent/agent-revisions.d.ts +35 -0
- package/dist/agent/agent-revisions.d.ts.map +1 -0
- package/dist/agent/agent-revisions.js +133 -0
- package/dist/agent/agent-revisions.js.map +1 -0
- package/dist/agent/agent-scheduler.d.ts +99 -0
- package/dist/agent/agent-scheduler.d.ts.map +1 -0
- package/dist/agent/agent-scheduler.js +398 -0
- package/dist/agent/agent-scheduler.js.map +1 -0
- package/dist/bus/command-bus.d.ts +62 -0
- package/dist/bus/command-bus.d.ts.map +1 -1
- package/dist/bus/command-bus.js +51 -2
- package/dist/bus/command-bus.js.map +1 -1
- package/dist/bus/event-bus.d.ts +101 -2
- package/dist/bus/event-bus.d.ts.map +1 -1
- package/dist/bus/event-bus.js +74 -13
- package/dist/bus/event-bus.js.map +1 -1
- package/dist/bus/saved-dispatcher-binding.d.ts +53 -0
- package/dist/bus/saved-dispatcher-binding.d.ts.map +1 -0
- package/dist/bus/saved-dispatcher-binding.js +27 -0
- package/dist/bus/saved-dispatcher-binding.js.map +1 -0
- package/dist/context/bounded-context.d.ts +45 -12
- package/dist/context/bounded-context.d.ts.map +1 -1
- package/dist/context/bounded-context.js +306 -86
- package/dist/context/bounded-context.js.map +1 -1
- package/dist/context/entity-inbox.d.ts.map +1 -1
- package/dist/context/entity-inbox.js +21 -7
- package/dist/context/entity-inbox.js.map +1 -1
- package/dist/context/local-inbox-handoff.d.ts +1 -0
- package/dist/context/local-inbox-handoff.d.ts.map +1 -1
- package/dist/context/local-inbox-handoff.js +31 -1
- package/dist/context/local-inbox-handoff.js.map +1 -1
- package/dist/context/projection-handoff.d.ts.map +1 -1
- package/dist/context/projection-handoff.js +2 -0
- package/dist/context/projection-handoff.js.map +1 -1
- package/dist/context/tenant-index.d.ts +25 -0
- package/dist/context/tenant-index.d.ts.map +1 -1
- package/dist/context/tenant-index.js +45 -1
- package/dist/context/tenant-index.js.map +1 -1
- package/dist/delivery/delivery-monitor.d.ts +12 -9
- package/dist/delivery/delivery-monitor.d.ts.map +1 -1
- package/dist/delivery/delivery-monitor.js +15 -9
- package/dist/delivery/delivery-monitor.js.map +1 -1
- package/dist/delivery/delivery-ports.d.ts +6 -13
- package/dist/delivery/delivery-ports.d.ts.map +1 -1
- package/dist/delivery/delivery-run-control.d.ts +15 -0
- package/dist/delivery/delivery-run-control.d.ts.map +1 -1
- package/dist/delivery/delivery-run-control.js.map +1 -1
- package/dist/delivery/delivery-supervisor.d.ts +33 -5
- package/dist/delivery/delivery-supervisor.d.ts.map +1 -1
- package/dist/delivery/delivery-supervisor.js +150 -22
- package/dist/delivery/delivery-supervisor.js.map +1 -1
- package/dist/delivery/delivery.d.ts.map +1 -1
- package/dist/delivery/delivery.js +128 -54
- package/dist/delivery/delivery.js.map +1 -1
- package/dist/delivery/inbox-storage.d.ts +8 -11
- package/dist/delivery/inbox-storage.d.ts.map +1 -1
- package/dist/delivery/inbox-storage.js +33 -76
- package/dist/delivery/inbox-storage.js.map +1 -1
- package/dist/delivery/inbox.d.ts +9 -12
- package/dist/delivery/inbox.d.ts.map +1 -1
- package/dist/delivery/inbox.js +10 -13
- package/dist/delivery/inbox.js.map +1 -1
- package/dist/delivery/reception-observation.d.ts +56 -0
- package/dist/delivery/reception-observation.d.ts.map +1 -0
- package/dist/delivery/reception-observation.js +67 -0
- package/dist/delivery/reception-observation.js.map +1 -0
- package/dist/entity/entity.d.ts +82 -3
- package/dist/entity/entity.d.ts.map +1 -1
- package/dist/entity/entity.js +121 -22
- package/dist/entity/entity.js.map +1 -1
- package/dist/handler/generated-handler-registry.js +8 -3
- package/dist/handler/generated-handler-registry.js.map +1 -1
- package/dist/handler/handler-metadata.d.ts +17 -1
- package/dist/handler/handler-metadata.d.ts.map +1 -1
- package/dist/handler/handler-metadata.js +10 -4
- package/dist/handler/handler-metadata.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/repository/commit-fence.d.ts +11 -0
- package/dist/repository/commit-fence.d.ts.map +1 -1
- package/dist/repository/commit-fence.js +13 -0
- package/dist/repository/commit-fence.js.map +1 -1
- package/dist/repository/repository.d.ts +221 -13
- package/dist/repository/repository.d.ts.map +1 -1
- package/dist/repository/repository.js +2323 -134
- package/dist/repository/repository.js.map +1 -1
- package/dist/runtime/runtime.d.ts +11 -0
- package/dist/runtime/runtime.d.ts.map +1 -1
- package/dist/runtime/runtime.js +13 -0
- package/dist/runtime/runtime.js.map +1 -1
- package/dist/runtime/signal-metadata.d.ts.map +1 -1
- package/dist/runtime/signal-metadata.js +3 -10
- package/dist/runtime/signal-metadata.js.map +1 -1
- package/dist/runtime/signal-publisher.d.ts +14 -30
- package/dist/runtime/signal-publisher.d.ts.map +1 -1
- package/dist/runtime/signal-publisher.js +75 -47
- package/dist/runtime/signal-publisher.js.map +1 -1
- package/dist/runtime/standalone-handler-runtime.d.ts +7 -0
- package/dist/runtime/standalone-handler-runtime.d.ts.map +1 -1
- package/dist/runtime/standalone-handler-runtime.js +118 -11
- package/dist/runtime/standalone-handler-runtime.js.map +1 -1
- package/dist/server/environment-delivery-worker.d.ts.map +1 -1
- package/dist/server/environment-delivery-worker.js +305 -5
- package/dist/server/environment-delivery-worker.js.map +1 -1
- package/dist/server/managed-server-application.d.ts +2 -2
- package/dist/server/managed-server-application.d.ts.map +1 -1
- package/dist/server/managed-server-application.js +467 -177
- package/dist/server/managed-server-application.js.map +1 -1
- package/dist/server/node-coordinator.d.ts +14 -0
- package/dist/server/node-coordinator.d.ts.map +1 -1
- package/dist/server/node-coordinator.js +266 -45
- package/dist/server/node-coordinator.js.map +1 -1
- package/dist/server/server-log.d.ts.map +1 -1
- package/dist/server/server-log.js +4 -0
- package/dist/server/server-log.js.map +1 -1
- package/dist/server/server.d.ts +9 -0
- package/dist/server/server.d.ts.map +1 -1
- package/dist/server/server.js +33 -8
- package/dist/server/server.js.map +1 -1
- package/dist/services/spine-services.d.ts.map +1 -1
- package/dist/services/spine-services.js +200 -72
- package/dist/services/spine-services.js.map +1 -1
- package/dist/stand/event-origin-filter.d.ts +16 -0
- package/dist/stand/event-origin-filter.d.ts.map +1 -0
- package/dist/stand/event-origin-filter.js +124 -0
- package/dist/stand/event-origin-filter.js.map +1 -0
- package/dist/stand/subscription-observer.d.ts.map +1 -1
- package/dist/stand/subscription-observer.js +7 -0
- package/dist/stand/subscription-observer.js.map +1 -1
- package/dist/stand/subscription-runtime.d.ts +18 -1
- package/dist/stand/subscription-runtime.d.ts.map +1 -1
- package/dist/stand/subscription-runtime.js +32 -4
- package/dist/stand/subscription-runtime.js.map +1 -1
- package/dist/testing/index.d.ts +57 -1
- package/dist/testing/index.d.ts.map +1 -1
- package/dist/testing/index.js +88 -1
- package/dist/testing/index.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +15 -13
|
@@ -0,0 +1,340 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2026, CodeMatters. All rights reserved.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
|
|
5
|
+
* in compliance with the License. You may obtain a copy of the License at
|
|
6
|
+
*
|
|
7
|
+
* https://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
*
|
|
9
|
+
* Unless required by applicable law or agreed to in writing, software distributed under the License
|
|
10
|
+
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
|
|
11
|
+
* or implied. See the License for the specific language governing permissions and limitations under
|
|
12
|
+
* the License.
|
|
13
|
+
*/
|
|
14
|
+
import { create } from "@bufbuild/protobuf";
|
|
15
|
+
import { TimestampSchema } from "@bufbuild/protobuf/wkt";
|
|
16
|
+
import { AgentHistoryCursorSchema, AgentHistoryEntrySchema, } from "@spine-event-engine/proto/agent";
|
|
17
|
+
import { AgentHistoryKeys, } from "@spine-event-engine/storage/provider";
|
|
18
|
+
const bindings = new WeakMap();
|
|
19
|
+
/**
|
|
20
|
+
* Binds protected Agent history reads to repository storage.
|
|
21
|
+
*/
|
|
22
|
+
export const AgentHistoryReads = Object.freeze({
|
|
23
|
+
/**
|
|
24
|
+
* Attaches one mandatory storage handle to a restored Agent.
|
|
25
|
+
*
|
|
26
|
+
* @typeParam Id Typed Agent identifier.
|
|
27
|
+
* @param entity Restored Agent.
|
|
28
|
+
* @param binding Repository history binding.
|
|
29
|
+
*/
|
|
30
|
+
bind(entity, binding) {
|
|
31
|
+
bindings.set(entity, binding);
|
|
32
|
+
},
|
|
33
|
+
withJournal(entity, journal) {
|
|
34
|
+
const binding = bindings.get(entity);
|
|
35
|
+
if (binding === undefined)
|
|
36
|
+
throw new Error("Agent history is available only from repository execution.");
|
|
37
|
+
bindings.set(entity, { ...binding, journal });
|
|
38
|
+
return () => {
|
|
39
|
+
bindings.set(entity, binding);
|
|
40
|
+
};
|
|
41
|
+
},
|
|
42
|
+
/**
|
|
43
|
+
* Persists the exact genuine System envelope before an Agent handler runs.
|
|
44
|
+
*
|
|
45
|
+
* @param entity Restored Agent.
|
|
46
|
+
* @param event Original System Event envelope.
|
|
47
|
+
* @returns Completion after append.
|
|
48
|
+
*/
|
|
49
|
+
appendSystem(entity, event) {
|
|
50
|
+
const binding = bindings.get(entity);
|
|
51
|
+
if (binding === undefined)
|
|
52
|
+
throw new Error("Agent history is available only from repository execution.");
|
|
53
|
+
if (event.context?.timestamp === undefined)
|
|
54
|
+
throw new Error("Agent System Event requires its original timestamp.");
|
|
55
|
+
return binding.storage.append(binding.entityId, create(AgentHistoryEntrySchema, {
|
|
56
|
+
occurredAt: event.context.timestamp,
|
|
57
|
+
item: { case: "systemEvent", value: event },
|
|
58
|
+
}));
|
|
59
|
+
},
|
|
60
|
+
/**
|
|
61
|
+
* Reads all categories, newest first.
|
|
62
|
+
*
|
|
63
|
+
* @param entity Restored Agent.
|
|
64
|
+
* @param request Page request.
|
|
65
|
+
* @returns Complete entries and continuation.
|
|
66
|
+
*/
|
|
67
|
+
full(entity, request) {
|
|
68
|
+
return this.read(entity, { kind: "full" }, request);
|
|
69
|
+
},
|
|
70
|
+
/**
|
|
71
|
+
* Reads one explicit conversation, newest first.
|
|
72
|
+
*
|
|
73
|
+
* @param entity Restored Agent.
|
|
74
|
+
* @param request Conversation and page request.
|
|
75
|
+
* @returns Conversation records and continuation.
|
|
76
|
+
*/
|
|
77
|
+
async conversation(entity, request) {
|
|
78
|
+
const conversation = request.conversation;
|
|
79
|
+
if (conversation === null ||
|
|
80
|
+
typeof conversation !== "object" ||
|
|
81
|
+
!("value" in conversation) ||
|
|
82
|
+
typeof conversation.value !== "string" ||
|
|
83
|
+
conversation.value.length === 0)
|
|
84
|
+
throw new TypeError("Agent conversation history requires a ConversationId.");
|
|
85
|
+
const page = await this.read(entity, { kind: "conversation", conversation: request.conversation }, request);
|
|
86
|
+
return {
|
|
87
|
+
items: page.items.map((entry) => {
|
|
88
|
+
if (entry.item.case !== "conversationRecord")
|
|
89
|
+
throw new Error("Agent history provider returned the wrong category.");
|
|
90
|
+
return entry.item.value;
|
|
91
|
+
}),
|
|
92
|
+
...(page.nextCursor === undefined ? {} : { nextCursor: page.nextCursor }),
|
|
93
|
+
};
|
|
94
|
+
},
|
|
95
|
+
/**
|
|
96
|
+
* Reads System Event envelopes, newest first.
|
|
97
|
+
*
|
|
98
|
+
* @param entity Restored Agent.
|
|
99
|
+
* @param request Page request.
|
|
100
|
+
* @returns Original Event envelopes and continuation.
|
|
101
|
+
*/
|
|
102
|
+
async system(entity, request) {
|
|
103
|
+
const page = await this.read(entity, { kind: "system" }, request);
|
|
104
|
+
return {
|
|
105
|
+
items: page.items.map((entry) => {
|
|
106
|
+
if (entry.item.case !== "systemEvent")
|
|
107
|
+
throw new Error("Agent history provider returned the wrong category.");
|
|
108
|
+
return entry.item.value;
|
|
109
|
+
}),
|
|
110
|
+
...(page.nextCursor === undefined ? {} : { nextCursor: page.nextCursor }),
|
|
111
|
+
};
|
|
112
|
+
},
|
|
113
|
+
/**
|
|
114
|
+
* Reads emitted domain Event envelopes, newest first.
|
|
115
|
+
*
|
|
116
|
+
* @param entity Restored Agent.
|
|
117
|
+
* @param request Page request.
|
|
118
|
+
* @returns Original Event envelopes and continuation.
|
|
119
|
+
*/
|
|
120
|
+
async domain(entity, request) {
|
|
121
|
+
const page = await this.read(entity, { kind: "domain" }, request);
|
|
122
|
+
return {
|
|
123
|
+
items: page.items.map((entry) => {
|
|
124
|
+
if (entry.item.case !== "domainEvent")
|
|
125
|
+
throw new Error("Agent history provider returned the wrong category.");
|
|
126
|
+
return entry.item.value;
|
|
127
|
+
}),
|
|
128
|
+
...(page.nextCursor === undefined ? {} : { nextCursor: page.nextCursor }),
|
|
129
|
+
};
|
|
130
|
+
},
|
|
131
|
+
/**
|
|
132
|
+
* Validates the cursor before asking the indexed provider for a page.
|
|
133
|
+
*
|
|
134
|
+
* @param entity Restored Agent.
|
|
135
|
+
* @param view Indexed history view.
|
|
136
|
+
* @param request Page request.
|
|
137
|
+
* @returns Complete entries and continuation.
|
|
138
|
+
*/
|
|
139
|
+
async read(entity, view, request) {
|
|
140
|
+
const binding = bindings.get(entity);
|
|
141
|
+
if (binding === undefined)
|
|
142
|
+
throw new Error("Agent history is available only from repository execution.");
|
|
143
|
+
return this.readBound(binding, view, request);
|
|
144
|
+
},
|
|
145
|
+
/**
|
|
146
|
+
* Reads a bounded provider page or reuses the page saved by the active handler.
|
|
147
|
+
*
|
|
148
|
+
* @typeParam Id Typed Agent identifier supplied by the repository binding.
|
|
149
|
+
* @param binding Repository storage, identity and optional handler journal.
|
|
150
|
+
* @param view Indexed category and optional conversation filter.
|
|
151
|
+
* @param request Page size and opaque continuation from a previous page.
|
|
152
|
+
* @returns Retained entries with the next cursor when older entries remain.
|
|
153
|
+
*/
|
|
154
|
+
async readBound(binding, view, request) {
|
|
155
|
+
if (!Number.isSafeInteger(request.pageSize) || request.pageSize <= 0)
|
|
156
|
+
throw new RangeError("Agent history pageSize must be a positive safe integer.");
|
|
157
|
+
const maxBytes = AgentHistoryPages.limit(binding.maxBytes);
|
|
158
|
+
const after = AgentHistoryCursorValues.decode(request.cursor?.value, binding.scope, view, maxBytes);
|
|
159
|
+
const live = () => AgentHistoryPages.load(binding, view, request, after, maxBytes);
|
|
160
|
+
const page = binding.journal === undefined
|
|
161
|
+
? await live()
|
|
162
|
+
: await binding.journal(binding.scope, view, request, live, maxBytes);
|
|
163
|
+
return AgentHistoryPages.present(binding.scope, view, page);
|
|
164
|
+
},
|
|
165
|
+
});
|
|
166
|
+
/**
|
|
167
|
+
* Loads and presents complete provider pages at the protected read boundary.
|
|
168
|
+
*/
|
|
169
|
+
const AgentHistoryPages = Object.freeze({
|
|
170
|
+
/**
|
|
171
|
+
* Loads a scoped provider page after validating the request.
|
|
172
|
+
*
|
|
173
|
+
* @typeParam Id Typed Agent identifier.
|
|
174
|
+
* @param binding Repository storage binding.
|
|
175
|
+
* @param view Indexed history view.
|
|
176
|
+
* @param request Public read request.
|
|
177
|
+
* @param after Validated continuation key.
|
|
178
|
+
* @param maxBytes Response byte limit.
|
|
179
|
+
* @returns Complete provider page.
|
|
180
|
+
*/
|
|
181
|
+
load(binding, view, request, after, maxBytes) {
|
|
182
|
+
return binding.storage.read({
|
|
183
|
+
entityId: binding.entityId,
|
|
184
|
+
view,
|
|
185
|
+
...(after === undefined ? {} : { after }),
|
|
186
|
+
count: request.pageSize,
|
|
187
|
+
...(maxBytes === undefined ? {} : { maxBytes }),
|
|
188
|
+
});
|
|
189
|
+
},
|
|
190
|
+
/**
|
|
191
|
+
* Validates a supplied byte budget before live or journaled reads.
|
|
192
|
+
*
|
|
193
|
+
* @param configured Optional runtime byte limit.
|
|
194
|
+
* @returns Validated byte limit.
|
|
195
|
+
*/
|
|
196
|
+
limit(configured) {
|
|
197
|
+
if (configured !== undefined && (!Number.isSafeInteger(configured) || configured <= 0))
|
|
198
|
+
throw new RangeError("Agent history maxBytes must be a positive safe integer.");
|
|
199
|
+
return configured;
|
|
200
|
+
},
|
|
201
|
+
/**
|
|
202
|
+
* Converts the complete page into the public cursor shape.
|
|
203
|
+
*
|
|
204
|
+
* @param scope Exact Agent repository scope.
|
|
205
|
+
* @param view Indexed history view.
|
|
206
|
+
* @param page Complete provider page.
|
|
207
|
+
* @returns Public page with a bound continuation cursor.
|
|
208
|
+
*/
|
|
209
|
+
present(scope, view, page) {
|
|
210
|
+
const last = page.entries.at(-1);
|
|
211
|
+
if (page.hasMore && last === undefined)
|
|
212
|
+
throw new Error("Agent history provider returned an empty continuation.");
|
|
213
|
+
return {
|
|
214
|
+
items: page.entries,
|
|
215
|
+
...(page.hasMore && last !== undefined
|
|
216
|
+
? {
|
|
217
|
+
nextCursor: create(AgentHistoryCursorSchema, {
|
|
218
|
+
value: AgentHistoryCursorValues.encode(scope, view, AgentHistoryKeys.fromEntry(last)),
|
|
219
|
+
}),
|
|
220
|
+
}
|
|
221
|
+
: {}),
|
|
222
|
+
};
|
|
223
|
+
},
|
|
224
|
+
});
|
|
225
|
+
/**
|
|
226
|
+
* Encodes the complete existing-key continuation without allocating a position.
|
|
227
|
+
*/
|
|
228
|
+
const AgentHistoryCursorValues = Object.freeze({
|
|
229
|
+
/**
|
|
230
|
+
* Returns an opaque versioned cursor for one view and scope.
|
|
231
|
+
*
|
|
232
|
+
* @param scope Exact repository and Agent scope.
|
|
233
|
+
* @param view Indexed history view.
|
|
234
|
+
* @param key Complete last key.
|
|
235
|
+
* @returns Opaque cursor bytes.
|
|
236
|
+
*/
|
|
237
|
+
encode(scope, view, key) {
|
|
238
|
+
const payload = {
|
|
239
|
+
version: 1,
|
|
240
|
+
scope,
|
|
241
|
+
method: view.kind,
|
|
242
|
+
conversation: view.kind === "conversation" ? view.conversation.value : null,
|
|
243
|
+
seconds: key.occurredAt.seconds.toString(),
|
|
244
|
+
nanos: key.occurredAt.nanos,
|
|
245
|
+
category: key.category,
|
|
246
|
+
recordId: key.recordId,
|
|
247
|
+
};
|
|
248
|
+
return Buffer.from(JSON.stringify(payload), "utf8").toString("base64url");
|
|
249
|
+
},
|
|
250
|
+
/**
|
|
251
|
+
* Rejects malformed and cross-scope cursors before a provider read.
|
|
252
|
+
*
|
|
253
|
+
* @param value Cursor bytes, when continuing.
|
|
254
|
+
* @param scope Exact repository and Agent scope.
|
|
255
|
+
* @param view Indexed history view.
|
|
256
|
+
* @param maxBytes Maximum serialized page bytes.
|
|
257
|
+
* @returns Complete last key, when continuing.
|
|
258
|
+
*/
|
|
259
|
+
decode(value, scope, view, maxBytes) {
|
|
260
|
+
if (value === undefined)
|
|
261
|
+
return undefined;
|
|
262
|
+
try {
|
|
263
|
+
if (maxBytes !== undefined && value.length > this.maxLength(scope, view, maxBytes))
|
|
264
|
+
throw new Error();
|
|
265
|
+
const cursor = this.parse(value);
|
|
266
|
+
if (cursor.version !== 1 ||
|
|
267
|
+
cursor.method !== view.kind ||
|
|
268
|
+
cursor.conversation !== (view.kind === "conversation" ? view.conversation.value : null) ||
|
|
269
|
+
JSON.stringify(cursor.scope) !== JSON.stringify(scope))
|
|
270
|
+
throw new Error();
|
|
271
|
+
const key = this.key(cursor);
|
|
272
|
+
if (view.kind !== "full" && key.category !== view.kind)
|
|
273
|
+
throw new Error();
|
|
274
|
+
return key;
|
|
275
|
+
}
|
|
276
|
+
catch {
|
|
277
|
+
throw new TypeError("Invalid Agent history cursor for this repository view.");
|
|
278
|
+
}
|
|
279
|
+
},
|
|
280
|
+
/**
|
|
281
|
+
* Calculates a bound for a full byte-budget key, JSON escapes, and the actual scope.
|
|
282
|
+
*
|
|
283
|
+
* @param scope Exact repository and Agent scope.
|
|
284
|
+
* @param view Indexed history view.
|
|
285
|
+
* @param maxBytes Maximum serialized page bytes.
|
|
286
|
+
* @returns Maximum encoded cursor character count.
|
|
287
|
+
*/
|
|
288
|
+
maxLength(scope, view, maxBytes) {
|
|
289
|
+
const scopeBytes = Buffer.byteLength(JSON.stringify(scope), "utf8");
|
|
290
|
+
const conversation = view.kind === "conversation" ? view.conversation.value : null;
|
|
291
|
+
const viewBytes = Buffer.byteLength(JSON.stringify(conversation), "utf8");
|
|
292
|
+
const rawBytes = maxBytes * 6 + scopeBytes + viewBytes + 256;
|
|
293
|
+
return Math.min(Number.MAX_SAFE_INTEGER, Math.ceil(rawBytes / 3) * 4);
|
|
294
|
+
},
|
|
295
|
+
/**
|
|
296
|
+
* Decodes exact versioned payload fields.
|
|
297
|
+
*
|
|
298
|
+
* @param value Opaque cursor bytes.
|
|
299
|
+
* @returns Parsed cursor fields.
|
|
300
|
+
*/
|
|
301
|
+
parse(value) {
|
|
302
|
+
if (!/^[A-Za-z0-9_-]+$/.test(value))
|
|
303
|
+
throw new Error();
|
|
304
|
+
const raw = Buffer.from(value, "base64url").toString("utf8");
|
|
305
|
+
if (Buffer.from(raw, "utf8").toString("base64url") !== value)
|
|
306
|
+
throw new Error();
|
|
307
|
+
const data = JSON.parse(raw);
|
|
308
|
+
if (data === null || typeof data !== "object")
|
|
309
|
+
throw new Error();
|
|
310
|
+
const cursor = data;
|
|
311
|
+
if (Object.keys(cursor).sort().join(",") !==
|
|
312
|
+
"category,conversation,method,nanos,recordId,scope,seconds,version")
|
|
313
|
+
throw new Error();
|
|
314
|
+
return cursor;
|
|
315
|
+
},
|
|
316
|
+
/**
|
|
317
|
+
* Restores and validates the complete continuation key.
|
|
318
|
+
*
|
|
319
|
+
* @param cursor Parsed cursor fields.
|
|
320
|
+
* @returns Complete continuation key.
|
|
321
|
+
*/
|
|
322
|
+
key(cursor) {
|
|
323
|
+
if (typeof cursor.seconds !== "string" ||
|
|
324
|
+
!/^-?(0|[1-9][0-9]*)$/.test(cursor.seconds) ||
|
|
325
|
+
typeof cursor.nanos !== "number" ||
|
|
326
|
+
typeof cursor.recordId !== "string" ||
|
|
327
|
+
(cursor.category !== "conversation" &&
|
|
328
|
+
cursor.category !== "system" &&
|
|
329
|
+
cursor.category !== "domain"))
|
|
330
|
+
throw new Error();
|
|
331
|
+
const key = {
|
|
332
|
+
occurredAt: create(TimestampSchema, { seconds: BigInt(cursor.seconds), nanos: cursor.nanos }),
|
|
333
|
+
category: cursor.category,
|
|
334
|
+
recordId: cursor.recordId,
|
|
335
|
+
};
|
|
336
|
+
AgentHistoryKeys.indexValue(key);
|
|
337
|
+
return key;
|
|
338
|
+
},
|
|
339
|
+
});
|
|
340
|
+
//# sourceMappingURL=agent-history.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-history.js","sourceRoot":"","sources":["../../src/agent/agent-history.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC5C,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAGzD,OAAO,EACL,wBAAwB,EACxB,uBAAuB,GAGxB,MAAM,iCA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AE/B,MAAM,IAAI,KAAK,EAAE,CAAC;QACpB,MAAM,GAAG,GAAyB;YAChC,UAAU,EAAE,MAAM,CAAC,eAAe,EAAE,EAAE,OAAO,EAAE,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,EAAE,CAAC;YAC7F,QAAQ,EAAE,MAAM,CAAC,QAAQ;YACzB,QAAQ,EAAE,MAAM,CAAC,QAAQ;SAC1B,CAAC;QACF,gBAAgB,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;QACjC,OAAO,GAAG,CAAC;IACb,CAAC;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { type MessageShape } from "@bufbuild/protobuf";
|
|
2
|
+
import { type MessageSchema } from "@spine-event-engine/core";
|
|
3
|
+
import { type Event } from "@spine-event-engine/proto";
|
|
4
|
+
import { AiModelKind, type AgentHistoryEntry, type AgentOperationRef } from "@spine-event-engine/proto/agent";
|
|
5
|
+
import { type AgentAcceptedInvocation, type AgentExecutionRecord, type AgentNamedOperation } from "@spine-event-engine/proto/generated/spine/server/agent/execution_record_pb.js";
|
|
6
|
+
import type { SignalMetadata } from "../runtime/signal-metadata.js";
|
|
7
|
+
import { AgentExecutionSession } from "./agent-execution-session.js";
|
|
8
|
+
/**
|
|
9
|
+
* Saves one original Agent interaction Event and posts it to the System Context.
|
|
10
|
+
*/
|
|
11
|
+
export declare class AgentInteractionAudit {
|
|
12
|
+
private readonly session;
|
|
13
|
+
private readonly accepted;
|
|
14
|
+
private readonly stateSchema;
|
|
15
|
+
private readonly metadata;
|
|
16
|
+
private readonly onRegisterSchema;
|
|
17
|
+
private readonly onPublish;
|
|
18
|
+
/**
|
|
19
|
+
* Binds interaction evidence to one accepted Agent invocation.
|
|
20
|
+
*
|
|
21
|
+
* @param session Fenced execution journal and history writer.
|
|
22
|
+
* @param accepted Original accepted signal and recipient.
|
|
23
|
+
* @param stateSchema Generated Agent state descriptor.
|
|
24
|
+
* @param metadata Canonical signal metadata service.
|
|
25
|
+
* @param onRegisterSchema Registers a System event payload descriptor.
|
|
26
|
+
* @param onPublish Persists the System Context copy of an original Event.
|
|
27
|
+
*/
|
|
28
|
+
constructor(session: AgentExecutionSession, accepted: AgentAcceptedInvocation, stateSchema: MessageSchema, metadata: SignalMetadata, onRegisterSchema: (schema: MessageSchema) => void, onPublish: (event: Event) => Promise<void>);
|
|
29
|
+
/**
|
|
30
|
+
* Creates a named call reference with its model fixed at invocation start.
|
|
31
|
+
*
|
|
32
|
+
* @param operation Saved named operation.
|
|
33
|
+
* @param kind Selected generation or decision kind.
|
|
34
|
+
* @returns Reference with the accepted Agent, source, and model identities.
|
|
35
|
+
*/
|
|
36
|
+
reference(operation: AgentNamedOperation, kind: AiModelKind): AgentOperationRef;
|
|
37
|
+
/**
|
|
38
|
+
* Calculates an original typed System row size with this invocation's full scope.
|
|
39
|
+
*
|
|
40
|
+
* @typeParam Schema Generated System event payload descriptor.
|
|
41
|
+
* @param schema Payload descriptor.
|
|
42
|
+
* @param payload Matching typed event payload.
|
|
43
|
+
* @returns Encoded provider history-row size in bytes.
|
|
44
|
+
*/
|
|
45
|
+
historyBytes<Schema extends MessageSchema>(schema: Schema, payload: MessageShape<Schema>): number;
|
|
46
|
+
/**
|
|
47
|
+
* Writes the original Event with its journal change before publication.
|
|
48
|
+
*
|
|
49
|
+
* @typeParam Schema Generated System event payload descriptor.
|
|
50
|
+
* @param schema Payload descriptor.
|
|
51
|
+
* @param payload Matching typed event payload.
|
|
52
|
+
* @param change Journal mutation guarded by the current claim.
|
|
53
|
+
* @param history Conversation rows included in the same fenced mutation.
|
|
54
|
+
* @returns When the journal and System Context publication both complete.
|
|
55
|
+
*/
|
|
56
|
+
save<Schema extends MessageSchema>(schema: Schema, payload: MessageShape<Schema>, change: (record: AgentExecutionRecord) => AgentExecutionRecord, history?: readonly AgentHistoryEntry[]): Promise<void>;
|
|
57
|
+
}
|
|
58
|
+
//# sourceMappingURL=agent-interaction-audit.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-interaction-audit.d.ts","sourceRoot":"","sources":["../../src/agent/agent-interaction-audit.ts"],"names":[],"mappings":"AAcA,OAAO,EAAU,KAAK,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAC/D,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAC9D,OAAO,EAAE,KAAK,KAAK,EAAE,MAAM,2BAA2B,CAAC;AACvD,OAAO,EAEL,WAAW,EACX,KAAK,iBAAiB,EACtB,KAAK,iBAAiB,EACvB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EACL,KAAK,uBAAuB,EAC5B,KAAK,oBAAoB,EACzB,KAAK,mBAAmB,EACzB,MAAM,+EAA+E,CAAC;AAEvF,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AACpE,OAAO,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AAGrE;;GAEG;AACH,qBAAa,qBAAqB;IAY9B,OAAO,CAAC,QAAQ,CAAC,OAAO;IACxB,OAAO,CAAC,QAAQ,CAAC,QAAQ;IACzB,OAAO,CAAC,QAAQ,CAAC,WAAW;IAC5B,OAAO,CAAC,QAAQ,CAAC,QAAQ;IACzB,OAAO,CAAC,QAAQ,CAAC,gBAAgB;IACjC,OAAO,CAAC,QAAQ,CAAC,SAAS;IAhB5B;;;;;;;;;OASG;gBAEgB,OAAO,EAAE,qBAAqB,EAC9B,QAAQ,EAAE,uBAAuB,EACjC,WAAW,EAAE,aAAa,EAC1B,QAAQ,EAAE,cAAc,EACxB,gBAAgB,EAAE,CAAC,MAAM,EAAE,aAAa,KAAK,IAAI,EACjD,SAAS,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,OAAO,CAAC,IAAI,CAAC;IAG7D;;;;;;OAMG;IACH,SAAS,CAAC,SAAS,EAAE,mBAAmB,EAAE,IAAI,EAAE,WAAW,GAAG,iBAAiB;IAW/E;;;;;;;OAOG;IACH,YAAY,CAAC,MAAM,SAAS,aAAa,EACvC,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,YAAY,CAAC,MAAM,CAAC,GAC5B,MAAM;IAuBT;;;;;;;;;OASG;IACG,IAAI,CAAC,MAAM,SAAS,aAAa,EACrC,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,YAAY,CAAC,MAAM,CAAC,EAC7B,MAAM,EAAE,CAAC,MAAM,EAAE,oBAAoB,KAAK,oBAAoB,EAC9D,OAAO,GAAE,SAAS,iBAAiB,EAAO,GACzC,OAAO,CAAC,IAAI,CAAC;CAsBjB"}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2026, CodeMatters. All rights reserved.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
|
|
5
|
+
* in compliance with the License. You may obtain a copy of the License at
|
|
6
|
+
*
|
|
7
|
+
* https://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
*
|
|
9
|
+
* Unless required by applicable law or agreed to in writing, software distributed under the License
|
|
10
|
+
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
|
|
11
|
+
* or implied. See the License for the specific language governing permissions and limitations under
|
|
12
|
+
* the License.
|
|
13
|
+
*/
|
|
14
|
+
import { create } from "@bufbuild/protobuf";
|
|
15
|
+
import {} from "@spine-event-engine/core";
|
|
16
|
+
import {} from "@spine-event-engine/proto";
|
|
17
|
+
import { AgentHistoryEntrySchema, AiModelKind, } from "@spine-event-engine/proto/agent";
|
|
18
|
+
import {} from "@spine-event-engine/proto/generated/spine/server/agent/execution_record_pb.js";
|
|
19
|
+
import { AgentExecutionSizes } from "@spine-event-engine/storage/provider";
|
|
20
|
+
import { AgentExecutionSession } from "./agent-execution-session.js";
|
|
21
|
+
import { AgentInteractionEvents } from "./agent-interaction-events.js";
|
|
22
|
+
/**
|
|
23
|
+
* Saves one original Agent interaction Event and posts it to the System Context.
|
|
24
|
+
*/
|
|
25
|
+
export class AgentInteractionAudit {
|
|
26
|
+
session;
|
|
27
|
+
accepted;
|
|
28
|
+
stateSchema;
|
|
29
|
+
metadata;
|
|
30
|
+
onRegisterSchema;
|
|
31
|
+
onPublish;
|
|
32
|
+
/**
|
|
33
|
+
* Binds interaction evidence to one accepted Agent invocation.
|
|
34
|
+
*
|
|
35
|
+
* @param session Fenced execution journal and history writer.
|
|
36
|
+
* @param accepted Original accepted signal and recipient.
|
|
37
|
+
* @param stateSchema Generated Agent state descriptor.
|
|
38
|
+
* @param metadata Canonical signal metadata service.
|
|
39
|
+
* @param onRegisterSchema Registers a System event payload descriptor.
|
|
40
|
+
* @param onPublish Persists the System Context copy of an original Event.
|
|
41
|
+
*/
|
|
42
|
+
constructor(session, accepted, stateSchema, metadata, onRegisterSchema, onPublish) {
|
|
43
|
+
this.session = session;
|
|
44
|
+
this.accepted = accepted;
|
|
45
|
+
this.stateSchema = stateSchema;
|
|
46
|
+
this.metadata = metadata;
|
|
47
|
+
this.onRegisterSchema = onRegisterSchema;
|
|
48
|
+
this.onPublish = onPublish;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Creates a named call reference with its model fixed at invocation start.
|
|
52
|
+
*
|
|
53
|
+
* @param operation Saved named operation.
|
|
54
|
+
* @param kind Selected generation or decision kind.
|
|
55
|
+
* @returns Reference with the accepted Agent, source, and model identities.
|
|
56
|
+
*/
|
|
57
|
+
reference(operation, kind) {
|
|
58
|
+
const selected = this.session.record().started?.models.find((item) => item.kind === kind);
|
|
59
|
+
if (selected === undefined)
|
|
60
|
+
throw new Error("Agent audit requires a saved selected model.");
|
|
61
|
+
return AgentInteractionEvents.operationRef(this.accepted, operation, this.stateSchema, selected);
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Calculates an original typed System row size with this invocation's full scope.
|
|
65
|
+
*
|
|
66
|
+
* @typeParam Schema Generated System event payload descriptor.
|
|
67
|
+
* @param schema Payload descriptor.
|
|
68
|
+
* @param payload Matching typed event payload.
|
|
69
|
+
* @returns Encoded provider history-row size in bytes.
|
|
70
|
+
*/
|
|
71
|
+
historyBytes(schema, payload) {
|
|
72
|
+
const scope = this.accepted.key?.scope;
|
|
73
|
+
const id = this.accepted.recipientId;
|
|
74
|
+
if (scope === undefined || id === undefined)
|
|
75
|
+
throw new Error("Agent audit sizing requires accepted scope and recipient.");
|
|
76
|
+
const event = AgentInteractionEvents.envelope(this.accepted, this.metadata, id, schema, payload);
|
|
77
|
+
const occurredAt = event.context?.timestamp;
|
|
78
|
+
if (occurredAt === undefined)
|
|
79
|
+
throw new Error("Agent audit sizing requires Time.");
|
|
80
|
+
return AgentExecutionSizes.history(scope, create(AgentHistoryEntrySchema, {
|
|
81
|
+
occurredAt,
|
|
82
|
+
item: { case: "systemEvent", value: event },
|
|
83
|
+
}));
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Writes the original Event with its journal change before publication.
|
|
87
|
+
*
|
|
88
|
+
* @typeParam Schema Generated System event payload descriptor.
|
|
89
|
+
* @param schema Payload descriptor.
|
|
90
|
+
* @param payload Matching typed event payload.
|
|
91
|
+
* @param change Journal mutation guarded by the current claim.
|
|
92
|
+
* @param history Conversation rows included in the same fenced mutation.
|
|
93
|
+
* @returns When the journal and System Context publication both complete.
|
|
94
|
+
*/
|
|
95
|
+
async save(schema, payload, change, history = []) {
|
|
96
|
+
const id = this.accepted.recipientId;
|
|
97
|
+
if (id === undefined)
|
|
98
|
+
throw new Error("Agent audit requires a typed recipient.");
|
|
99
|
+
const event = AgentInteractionEvents.envelope(this.accepted, this.metadata, id, schema, payload);
|
|
100
|
+
const occurredAt = event.context?.timestamp;
|
|
101
|
+
if (occurredAt === undefined)
|
|
102
|
+
throw new Error("Agent audit Event requires Time.");
|
|
103
|
+
this.onRegisterSchema(schema);
|
|
104
|
+
await this.session.update(change, [
|
|
105
|
+
...history,
|
|
106
|
+
create(AgentHistoryEntrySchema, {
|
|
107
|
+
occurredAt,
|
|
108
|
+
item: { case: "systemEvent", value: event },
|
|
109
|
+
}),
|
|
110
|
+
]);
|
|
111
|
+
await this.onPublish(event);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
//# sourceMappingURL=agent-interaction-audit.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-interaction-audit.js","sourceRoot":"","sources":["../../src/agent/agent-interaction-audit.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,MAAM,EAAqB,MAAM,oBAAoB,CAAC;AAC/D,OAAO,EAAsB,MAAM,0BAA0B,CAAC;AAC9D,OAAO,EAAc,MAAM,2BAA2B,CAAC;AACvD,OAAO,EACL,uBAAuB,EACvB,WAAW,GAGZ,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAIN,MAAM,+EAA+E,CAAC;AACvF,OAAO,EAAE,mBAAmB,EAAE,MAAM,sCAAsC,CAAC;AAE3E,OAAO,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AACrE,OAAO,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAC;AAEvE;;GAEG;AACH,MAAM,OAAO,qBAAqB;IAYb;IACA;IACA;IACA;IACA;IACA;IAhBnB;;;;;;;;;OASG;IACH,YACmB,OAA8B,EAC9B,QAAiC,EACjC,WAA0B,EAC1B,QAAwB,EACxB,gBAAiD,EACjD,SAA0C;QAL1C,YAAO,GAAP,OAAO,CAAuB;QAC9B,aAAQ,GAAR,QAAQ,CAAyB;QACjC,gBAAW,GAAX,WAAW,CAAe;QAC1B,aAAQ,GAAR,QAAQ,CAAgB;QACxB,qBAAgB,GAAhB,gBAAgB,CAAiC;QACjD,cAAS,GAAT,SAAS,CAAiC;IAC1D,CAAC;IAEJ;;;;;;OAMG;IACH,SAAS,CAAC,SAA8B,EAAE,IAAiB;QACzD,MAAM,QAAQ,GAAG,IAAI,CAA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AM,EAAE,GAAG,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC;QACrC,IAAI,EAAE,KAAK,SAAS;YAAE,MAAM,IAAI,KAAK,CAAC,yCAAyC,CAAC,CAAC;QACjF,MAAM,KAAK,GAAG,sBAAsB,CAAC,QAAQ,CAC3C,IAAI,CAAC,QAAQ,EACb,IAAI,CAAC,QAAQ,EACb,EAAE,EACF,MAAM,EACN,OAAO,CACR,CAAC;QACF,MAAM,UAAU,GAAG,KAAK,CAAC,OAAO,EAAE,SAAS,CAAC;QAC5C,IAAI,UAAU,KAAK,SAAS;YAAE,MAAM,IAAI,KAAK,CAAC,kCAAkC,CAAC,CAAC;QAClF,IAAI,CAAC,gBAAgB,CAAC,MAAM,CAAC,CAAC;QAC9B,MAAM,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE;YAChC,GAAG,OAAO;YACV,MAAM,CAAC,uBAAuB,EAAE;gBAC9B,UAAU;gBACV,IAAI,EAAE,EAAE,IAAI,EAAE,aAAa,EAAE,KAAK,EAAE,KAAK,EAAE;aAC5C,CAAC;SACH,CAAC,CAAC;QACH,MAAM,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;IAC9B,CAAC;CACF"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { type MessageShape } from "@bufbuild/protobuf";
|
|
2
|
+
import { type Any } from "@bufbuild/protobuf/wkt";
|
|
3
|
+
import { type MessageSchema } from "@spine-event-engine/core";
|
|
4
|
+
import { type Event } from "@spine-event-engine/proto";
|
|
5
|
+
import { type AgentOperationRef } from "@spine-event-engine/proto/agent";
|
|
6
|
+
import { type AgentAcceptedInvocation, type AgentNamedOperation, type AgentSelectedModel } from "@spine-event-engine/proto/generated/spine/server/agent/execution_record_pb.js";
|
|
7
|
+
import type { SignalMetadata } from "../runtime/signal-metadata.js";
|
|
8
|
+
/**
|
|
9
|
+
* Creates references and typed envelopes for Agent interaction events.
|
|
10
|
+
*/
|
|
11
|
+
interface AgentInteractionEventFactory {
|
|
12
|
+
/**
|
|
13
|
+
* Creates a reference to accepted work and its selected model.
|
|
14
|
+
*
|
|
15
|
+
* @param accepted Durable accepted invocation.
|
|
16
|
+
* @param operation Named model operation.
|
|
17
|
+
* @param stateSchema Generated Agent state descriptor.
|
|
18
|
+
* @param selected Selected deployment for this operation kind.
|
|
19
|
+
* @returns Complete operation reference.
|
|
20
|
+
*/
|
|
21
|
+
operationRef(accepted: AgentAcceptedInvocation, operation: AgentNamedOperation, stateSchema: MessageSchema, selected: AgentSelectedModel): AgentOperationRef;
|
|
22
|
+
/**
|
|
23
|
+
* Wraps a typed System-event payload with the original causal context.
|
|
24
|
+
*
|
|
25
|
+
* @typeParam Schema Generated System-event descriptor.
|
|
26
|
+
* @param accepted Durable source Command, Event, or rejection.
|
|
27
|
+
* @param metadata Spine ID, Time, and origin metadata provider.
|
|
28
|
+
* @param agentId Original typed Agent identifier.
|
|
29
|
+
* @param schema Generated System-event descriptor.
|
|
30
|
+
* @param payload Matching typed System-event message.
|
|
31
|
+
* @returns Fresh Event envelope.
|
|
32
|
+
*/
|
|
33
|
+
envelope<Schema extends MessageSchema>(accepted: AgentAcceptedInvocation, metadata: SignalMetadata, agentId: Any, schema: Schema, payload: MessageShape<Schema>): Event;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Creates immutable System-event facts from accepted Agent work.
|
|
37
|
+
*/
|
|
38
|
+
export declare const AgentInteractionEvents: AgentInteractionEventFactory;
|
|
39
|
+
export {};
|
|
40
|
+
//# sourceMappingURL=agent-interaction-events.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-interaction-events.d.ts","sourceRoot":"","sources":["../../src/agent/agent-interaction-events.ts"],"names":[],"mappings":"AAcA,OAAO,EAAkB,KAAK,YAAY,EAAE,MAAM,oBAAoB,CAAC;AACvE,OAAO,EAAa,KAAK,GAAG,EAAE,MAAM,wBAAwB,CAAC;AAC7D,OAAO,EAAmC,KAAK,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAC/F,OAAO,EAKL,KAAK,KAAK,EACX,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAGL,KAAK,iBAAiB,EACvB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EACL,KAAK,uBAAuB,EAC5B,KAAK,mBAAmB,EACxB,KAAK,kBAAkB,EACxB,MAAM,+EAA+E,CAAC;AACvF,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAuCpE;;GAEG;AACH,UAAU,4BAA4B;IACpC;;;;;;;;OAQG;IACH,YAAY,CACV,QAAQ,EAAE,uBAAuB,EACjC,SAAS,EAAE,mBAAmB,EAC9B,WAAW,EAAE,aAAa,EAC1B,QAAQ,EAAE,kBAAkB,GAC3B,iBAAiB,CAAC;IAErB;;;;;;;;;;OAUG;IACH,QAAQ,CAAC,MAAM,SAAS,aAAa,EACnC,QAAQ,EAAE,uBAAuB,EACjC,QAAQ,EAAE,cAAc,EACxB,OAAO,EAAE,GAAG,EACZ,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,YAAY,CAAC,MAAM,CAAC,GAC5B,KAAK,CAAC;CACV;AAED;;GAEG;AACH,eAAO,MAAM,sBAAsB,EAAE,4BAkFnC,CAAC"}
|