glove-foundry 0.9.0 → 0.10.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/README.md +1 -1
- package/dist/{chunk-LI7VIGVH.js → chunk-L72FKI7P.js} +329 -143
- package/dist/{chunk-L5JQVTHD.js → chunk-N2GVJ257.js} +12 -0
- package/dist/{chunk-EUGKVW3J.js → chunk-VLD3DKPI.js} +166 -12
- package/dist/cli.js +2 -2
- package/dist/{client-CCY4_vqN.d.ts → client-HM2x2-Ut.d.ts} +41 -5
- package/dist/client.d.ts +2 -2
- package/dist/client.js +1 -1
- package/dist/{event-delivery-CNCsVqi8.d.ts → event-delivery-C7rYiNPs.d.ts} +148 -50
- package/dist/execution-daemon.js +0 -7
- package/dist/execution-loader.js +4 -2
- package/dist/index.d.ts +9 -5
- package/dist/index.js +44 -3
- package/dist/voice.d.ts +1 -1
- package/docs/architecture.md +18 -0
- package/docs/building-with-foundry.md +1 -1
- package/package.json +6 -6
|
@@ -252,6 +252,18 @@ var FoundryClient = class {
|
|
|
252
252
|
await this.fetcher(`${this.baseUrl}/api/activations${query}`)
|
|
253
253
|
);
|
|
254
254
|
}
|
|
255
|
+
/** Occurrences of schedules and sleeps: when each was meant for, the run that took it and how it ended. */
|
|
256
|
+
async scheduleOccurrences(filter = {}) {
|
|
257
|
+
const query = new URLSearchParams();
|
|
258
|
+
if (filter.activationId) query.set("activation", filter.activationId);
|
|
259
|
+
if (filter.workspaceId) query.set("workspace", filter.workspaceId);
|
|
260
|
+
if (filter.agentId) query.set("agent", filter.agentId);
|
|
261
|
+
for (const status of typeof filter.status === "string" ? [filter.status] : filter.status ?? []) query.append("status", status);
|
|
262
|
+
const suffix = query.size ? `?${query}` : "";
|
|
263
|
+
return readResponse(
|
|
264
|
+
await this.fetcher(`${this.baseUrl}/api/schedule-occurrences${suffix}`)
|
|
265
|
+
);
|
|
266
|
+
}
|
|
255
267
|
async putPlaybookSubscription(subscription) {
|
|
256
268
|
return readResponse(
|
|
257
269
|
await this.fetcher(`${this.baseUrl}/api/playbook-subscriptions`, {
|
|
@@ -61,6 +61,107 @@ var EMPTY_FOUNDRY_APPLICATION = defineApplication({
|
|
|
61
61
|
name: "Glove Foundry"
|
|
62
62
|
});
|
|
63
63
|
|
|
64
|
+
// src/schedule-occurrences.ts
|
|
65
|
+
import { createHash } from "node:crypto";
|
|
66
|
+
import { nextCronOccurrence } from "station-schedules";
|
|
67
|
+
var TERMINAL_OCCURRENCE_STATUSES = /* @__PURE__ */ new Set(["completed", "failed", "skipped", "cancelled"]);
|
|
68
|
+
var SCHEDULE_MISFIRE_GRACE_MS = 6e4;
|
|
69
|
+
var RETAINED_TERMINAL_OCCURRENCES = 100;
|
|
70
|
+
function canonicalJson(value) {
|
|
71
|
+
const text = JSON.stringify(value);
|
|
72
|
+
if (text === void 0) return "null";
|
|
73
|
+
const sort = (item) => {
|
|
74
|
+
if (Array.isArray(item)) return item.map(sort);
|
|
75
|
+
if (item && typeof item === "object") {
|
|
76
|
+
const record = item;
|
|
77
|
+
return Object.fromEntries(Object.keys(record).sort().map((key) => [key, sort(record[key])]));
|
|
78
|
+
}
|
|
79
|
+
return item;
|
|
80
|
+
};
|
|
81
|
+
return JSON.stringify(sort(JSON.parse(text)));
|
|
82
|
+
}
|
|
83
|
+
function configuration(activation) {
|
|
84
|
+
return {
|
|
85
|
+
definitionId: activation.definitionId,
|
|
86
|
+
agentId: activation.agentId,
|
|
87
|
+
conversationId: activation.conversationId,
|
|
88
|
+
message: activation.message,
|
|
89
|
+
payload: activation.payload ?? null,
|
|
90
|
+
timing: activation.timing
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
function activationScheduleRevision(activation) {
|
|
94
|
+
return createHash("sha256").update(canonicalJson(configuration(activation))).digest("hex");
|
|
95
|
+
}
|
|
96
|
+
function permutations(items) {
|
|
97
|
+
if (items.length <= 1) return [[...items]];
|
|
98
|
+
return items.flatMap((item, index) => permutations([...items.slice(0, index), ...items.slice(index + 1)]).map((rest) => [item, ...rest]));
|
|
99
|
+
}
|
|
100
|
+
function legacyScheduleRevisions(activation) {
|
|
101
|
+
const timing = activation.timing;
|
|
102
|
+
return permutations(Object.keys(timing)).map((keys) => createHash("sha256").update(JSON.stringify({
|
|
103
|
+
...configuration(activation),
|
|
104
|
+
timing: Object.fromEntries(keys.map((key) => [key, timing[key]]))
|
|
105
|
+
})).digest("hex"));
|
|
106
|
+
}
|
|
107
|
+
function scheduleRevisionMatches(activation, revision) {
|
|
108
|
+
return revision === activationScheduleRevision(activation) || legacyScheduleRevisions(activation).includes(revision);
|
|
109
|
+
}
|
|
110
|
+
function scheduleOccurrenceId(activationId, revision, scheduledFor) {
|
|
111
|
+
const instant = new Date(scheduledFor).toISOString();
|
|
112
|
+
return `occurrence_${createHash("sha256").update(JSON.stringify([activationId, revision, instant])).digest("hex")}`;
|
|
113
|
+
}
|
|
114
|
+
function scheduleMisfirePolicy(timing) {
|
|
115
|
+
return timing.kind === "at" ? "fire-once" : timing.misfire ?? "fire-once";
|
|
116
|
+
}
|
|
117
|
+
function nextScheduledTime(timing, after) {
|
|
118
|
+
if (timing.kind === "every") return new Date(after.getTime() + timing.intervalMs);
|
|
119
|
+
if (timing.kind === "cron") return nextCronOccurrence(timing.expression, timing.timezone, after);
|
|
120
|
+
const at = new Date(timing.at);
|
|
121
|
+
return at.getTime() > after.getTime() ? at : void 0;
|
|
122
|
+
}
|
|
123
|
+
function firstScheduledTime(timing, now) {
|
|
124
|
+
if (timing.kind === "at") return new Date(timing.at);
|
|
125
|
+
return nextScheduledTime(timing, now);
|
|
126
|
+
}
|
|
127
|
+
function planScheduleOccurrence(timing, scheduledFor, now) {
|
|
128
|
+
const policy = scheduleMisfirePolicy(timing);
|
|
129
|
+
let next = nextScheduledTime(timing, scheduledFor);
|
|
130
|
+
if (policy === "catch-up" || !next) {
|
|
131
|
+
return { deliver: true, ...next ? { next } : {}, coalesced: 0 };
|
|
132
|
+
}
|
|
133
|
+
let coalesced = 0;
|
|
134
|
+
while (next.getTime() <= now.getTime()) {
|
|
135
|
+
coalesced++;
|
|
136
|
+
next = nextScheduledTime(timing, next);
|
|
137
|
+
}
|
|
138
|
+
const late = now.getTime() - scheduledFor.getTime() > SCHEDULE_MISFIRE_GRACE_MS;
|
|
139
|
+
if (policy === "skip" && late) return { deliver: false, next, coalesced: 0 };
|
|
140
|
+
return { deliver: true, next, coalesced };
|
|
141
|
+
}
|
|
142
|
+
function matchesOccurrenceFilter(occurrence, filter = {}) {
|
|
143
|
+
if (filter.activationId && occurrence.activationId !== filter.activationId) return false;
|
|
144
|
+
if (filter.workspaceId && occurrence.workspaceId !== filter.workspaceId) return false;
|
|
145
|
+
if (filter.agentId && occurrence.agentId !== filter.agentId) return false;
|
|
146
|
+
if (filter.status) {
|
|
147
|
+
const statuses = typeof filter.status === "string" ? [filter.status] : filter.status;
|
|
148
|
+
if (!statuses.includes(occurrence.status)) return false;
|
|
149
|
+
}
|
|
150
|
+
return true;
|
|
151
|
+
}
|
|
152
|
+
function compareOccurrences(left, right) {
|
|
153
|
+
return left.scheduledFor.localeCompare(right.scheduledFor) || left.id.localeCompare(right.id);
|
|
154
|
+
}
|
|
155
|
+
function prunableOccurrences(occurrences, activationId, keep = RETAINED_TERMINAL_OCCURRENCES) {
|
|
156
|
+
const terminal = [...occurrences].filter((item) => item.activationId === activationId && TERMINAL_OCCURRENCE_STATUSES.has(item.status)).sort(compareOccurrences);
|
|
157
|
+
return terminal.slice(0, Math.max(0, terminal.length - keep)).map((item) => item.id);
|
|
158
|
+
}
|
|
159
|
+
function assertScheduleOccurrence(occurrence) {
|
|
160
|
+
if (!occurrence.id.startsWith("occurrence_")) throw new Error("Schedule occurrence id is invalid.");
|
|
161
|
+
if (!occurrence.activationId || !occurrence.revision) throw new Error("Schedule occurrence must name its activation and revision.");
|
|
162
|
+
if (Number.isNaN(Date.parse(occurrence.scheduledFor))) throw new Error("Schedule occurrence has an invalid scheduled time.");
|
|
163
|
+
}
|
|
164
|
+
|
|
64
165
|
// src/composition.ts
|
|
65
166
|
var composedToolBodies = /* @__PURE__ */ new WeakMap();
|
|
66
167
|
function isToolBody(value) {
|
|
@@ -364,7 +465,7 @@ function defineTransmission(options) {
|
|
|
364
465
|
}
|
|
365
466
|
|
|
366
467
|
// src/playbook.ts
|
|
367
|
-
import { createHash } from "node:crypto";
|
|
468
|
+
import { createHash as createHash2 } from "node:crypto";
|
|
368
469
|
var ID2 = /^[a-z][a-z0-9-]*(?:\/[a-z][a-z0-9-]*)*$/;
|
|
369
470
|
function assertData(value, path, seen = /* @__PURE__ */ new Set()) {
|
|
370
471
|
if (value === void 0) throw new Error(`Playbook ${path} cannot contain undefined.`);
|
|
@@ -508,12 +609,12 @@ function reconstructPlaybook(playbook) {
|
|
|
508
609
|
var FOUNDRY_PLAYBOOK_ACTION_BRAND = /* @__PURE__ */ Symbol.for("glove-foundry-playbook-action");
|
|
509
610
|
var FOUNDRY_COMPOSED_PLAYBOOK_BRAND = /* @__PURE__ */ Symbol.for("glove-foundry-composed-playbook");
|
|
510
611
|
function agentPlaybookId(definitionId, agentId, name) {
|
|
511
|
-
return `playbook-${
|
|
612
|
+
return `playbook-${createHash2("sha256").update(`${definitionId}\0${agentId}\0${name}`).digest("hex").slice(0, 24)}`;
|
|
512
613
|
}
|
|
513
614
|
function composedPlaybookRevision(playbook) {
|
|
514
615
|
const materialized = materializeComposedPlaybook(playbook, "playbook-revision", "pending");
|
|
515
616
|
const { id: _id, definitionRevision: _revision, ...data } = materialized;
|
|
516
|
-
return
|
|
617
|
+
return createHash2("sha256").update(JSON.stringify(data)).digest("hex");
|
|
517
618
|
}
|
|
518
619
|
function definePlaybookAction(options = {}) {
|
|
519
620
|
if (options.id && !ID2.test(options.id)) {
|
|
@@ -841,6 +942,7 @@ var MemoryFoundryDataAdapter = class {
|
|
|
841
942
|
pendingInbound = /* @__PURE__ */ new Map();
|
|
842
943
|
approvals = /* @__PURE__ */ new Map();
|
|
843
944
|
activations = /* @__PURE__ */ new Map();
|
|
945
|
+
occurrences = /* @__PURE__ */ new Map();
|
|
844
946
|
conversations = /* @__PURE__ */ new Map();
|
|
845
947
|
workspace = /* @__PURE__ */ new Map();
|
|
846
948
|
workingEnvironments = /* @__PURE__ */ new Map();
|
|
@@ -925,6 +1027,7 @@ var MemoryFoundryDataAdapter = class {
|
|
|
925
1027
|
for (const [id2, item] of this.pendingInbound) if (item.request.agentId === agentId) this.pendingInbound.delete(id2);
|
|
926
1028
|
for (const [id2, item] of this.approvals) if (item.agentId === agentId) this.approvals.delete(id2);
|
|
927
1029
|
for (const [id2, item] of this.activations) if (item.agentId === agentId) this.activations.delete(id2);
|
|
1030
|
+
for (const [id2, item] of this.occurrences) if (item.agentId === agentId) this.occurrences.delete(id2);
|
|
928
1031
|
for (const id2 of conversationIds) this.conversations.delete(id2);
|
|
929
1032
|
for (const [id2, item] of this.inbox) if (item.agentId === agentId || conversationIds.has(item.conversationId ?? "")) this.inbox.delete(id2);
|
|
930
1033
|
for (const [id2, item] of this.tasks) if (item.agentId === agentId || conversationIds.has(item.conversationId ?? "")) this.tasks.delete(id2);
|
|
@@ -1010,6 +1113,30 @@ var MemoryFoundryDataAdapter = class {
|
|
|
1010
1113
|
listEvents() {
|
|
1011
1114
|
return Effect2.sync(() => [...this.events.values()].map((record) => structuredClone(record)));
|
|
1012
1115
|
}
|
|
1116
|
+
claimScheduleOccurrence(occurrence) {
|
|
1117
|
+
return Effect2.sync(() => {
|
|
1118
|
+
assertScheduleOccurrence(occurrence);
|
|
1119
|
+
if (this.occurrences.has(occurrence.id)) return false;
|
|
1120
|
+
this.occurrences.set(occurrence.id, structuredClone(occurrence));
|
|
1121
|
+
return true;
|
|
1122
|
+
});
|
|
1123
|
+
}
|
|
1124
|
+
putScheduleOccurrence(occurrence) {
|
|
1125
|
+
return Effect2.sync(() => {
|
|
1126
|
+
assertScheduleOccurrence(occurrence);
|
|
1127
|
+
this.occurrences.set(occurrence.id, structuredClone(occurrence));
|
|
1128
|
+
for (const id2 of prunableOccurrences(this.occurrences.values(), occurrence.activationId)) this.occurrences.delete(id2);
|
|
1129
|
+
});
|
|
1130
|
+
}
|
|
1131
|
+
getScheduleOccurrence(id2) {
|
|
1132
|
+
return Effect2.sync(() => {
|
|
1133
|
+
const occurrence = this.occurrences.get(id2);
|
|
1134
|
+
return occurrence ? structuredClone(occurrence) : null;
|
|
1135
|
+
});
|
|
1136
|
+
}
|
|
1137
|
+
listScheduleOccurrences(filter) {
|
|
1138
|
+
return Effect2.sync(() => [...this.occurrences.values()].filter((item) => matchesOccurrenceFilter(item, filter)).sort(compareOccurrences).map((item) => structuredClone(item)));
|
|
1139
|
+
}
|
|
1013
1140
|
putPendingInbound(record) {
|
|
1014
1141
|
return Effect2.sync(() => {
|
|
1015
1142
|
this.pendingInbound.set(record.id, structuredClone(record));
|
|
@@ -1218,8 +1345,9 @@ function id(prefix) {
|
|
|
1218
1345
|
}
|
|
1219
1346
|
|
|
1220
1347
|
// src/schedule.ts
|
|
1221
|
-
import { createHash as
|
|
1348
|
+
import { createHash as createHash3 } from "node:crypto";
|
|
1222
1349
|
import { Duration } from "effect";
|
|
1350
|
+
import { validateCron } from "station-schedules";
|
|
1223
1351
|
var FOUNDRY_SCHEDULE_BRAND = /* @__PURE__ */ Symbol.for("glove-foundry-schedule");
|
|
1224
1352
|
var COMPACT_DURATION = /^(\d+)\s*(ms|s|m|h|d|w)$/i;
|
|
1225
1353
|
function durationMillis(value) {
|
|
@@ -1231,16 +1359,31 @@ function durationMillis(value) {
|
|
|
1231
1359
|
}
|
|
1232
1360
|
return milliseconds;
|
|
1233
1361
|
}
|
|
1362
|
+
function misfirePolicy(value) {
|
|
1363
|
+
if (value === "fire-once" || value === "skip" || value === "catch-up") return value;
|
|
1364
|
+
throw new Error(`Unknown misfire policy "${value}".`);
|
|
1365
|
+
}
|
|
1234
1366
|
function normalizeScheduleTiming(timing, now = Date.now()) {
|
|
1235
1367
|
if (timing.kind === "after") {
|
|
1236
1368
|
return Object.freeze({ kind: "at", at: new Date(now + durationMillis(timing.duration)).toISOString() });
|
|
1237
1369
|
}
|
|
1238
1370
|
if (timing.kind === "every") {
|
|
1239
|
-
return Object.freeze({
|
|
1371
|
+
return Object.freeze({
|
|
1372
|
+
kind: "every",
|
|
1373
|
+
intervalMs: durationMillis(timing.interval),
|
|
1374
|
+
...timing.misfire ? { misfire: misfirePolicy(timing.misfire) } : {}
|
|
1375
|
+
});
|
|
1240
1376
|
}
|
|
1241
1377
|
if (timing.kind === "cron") {
|
|
1242
1378
|
if (!timing.expression.trim()) throw new Error("A cron expression is required.");
|
|
1243
|
-
|
|
1379
|
+
const timezone = timing.timezone ?? "UTC";
|
|
1380
|
+
validateCron(timing.expression, timezone);
|
|
1381
|
+
return Object.freeze({
|
|
1382
|
+
kind: "cron",
|
|
1383
|
+
expression: timing.expression,
|
|
1384
|
+
timezone,
|
|
1385
|
+
...timing.misfire ? { misfire: misfirePolicy(timing.misfire) } : {}
|
|
1386
|
+
});
|
|
1244
1387
|
}
|
|
1245
1388
|
const at = new Date(timing.at);
|
|
1246
1389
|
if (Number.isNaN(at.getTime())) throw new Error(`Invalid schedule date "${timing.at}".`);
|
|
@@ -1262,11 +1405,11 @@ function isFoundrySchedule(value) {
|
|
|
1262
1405
|
return Boolean(value && typeof value === "object" && value[FOUNDRY_SCHEDULE_BRAND] === true);
|
|
1263
1406
|
}
|
|
1264
1407
|
function agentScheduleActivationId(definitionId, agentId, name) {
|
|
1265
|
-
const digest =
|
|
1408
|
+
const digest = createHash3("sha256").update(`${definitionId}\0${agentId}\0${name}`).digest("hex").slice(0, 24);
|
|
1266
1409
|
return `activation_${digest}`;
|
|
1267
1410
|
}
|
|
1268
1411
|
function agentScheduleRevision(schedule) {
|
|
1269
|
-
return
|
|
1412
|
+
return createHash3("sha256").update(JSON.stringify({
|
|
1270
1413
|
message: schedule.message,
|
|
1271
1414
|
payload: schedule.payload,
|
|
1272
1415
|
timing: schedule.timing,
|
|
@@ -1298,11 +1441,12 @@ function durationSchema(description) {
|
|
|
1298
1441
|
function afterDuration(value) {
|
|
1299
1442
|
return normalizeScheduleTiming({ kind: "after", duration: value }).at;
|
|
1300
1443
|
}
|
|
1444
|
+
var misfireSchema = z.enum(["fire-once", "skip", "catch-up"]).optional().describe("Occurrences missed while the runtime was down: fire-once (default) delivers one, catch-up delivers each, skip drops any more than a minute late");
|
|
1301
1445
|
var timingInputSchema = z.discriminatedUnion("kind", [
|
|
1302
1446
|
z.object({ kind: z.literal("at"), at: z.string().datetime() }),
|
|
1303
1447
|
z.object({ kind: z.literal("after"), duration: durationSchema("Delay before the one-time activation") }),
|
|
1304
|
-
z.object({ kind: z.literal("every"), interval: durationSchema("Interval between recurring activations") }),
|
|
1305
|
-
z.object({ kind: z.literal("cron"), expression: z.string().min(1), timezone: z.string().min(1).default("UTC") })
|
|
1448
|
+
z.object({ kind: z.literal("every"), interval: durationSchema("Interval between recurring activations"), misfire: misfireSchema }),
|
|
1449
|
+
z.object({ kind: z.literal("cron"), expression: z.string().min(1), timezone: z.string().min(1).default("UTC"), misfire: misfireSchema })
|
|
1306
1450
|
]);
|
|
1307
1451
|
function toolSegment(value) {
|
|
1308
1452
|
return value.replaceAll("/", "__").replaceAll("-", "_");
|
|
@@ -2254,7 +2398,7 @@ function withFoundryPermissions(store) {
|
|
|
2254
2398
|
}
|
|
2255
2399
|
|
|
2256
2400
|
// src/request-trace.ts
|
|
2257
|
-
import { createHash as
|
|
2401
|
+
import { createHash as createHash4 } from "node:crypto";
|
|
2258
2402
|
var FOUNDRY_MODEL_REQUESTS_ENV = "GLOVE_FOUNDRY_MODEL_REQUESTS";
|
|
2259
2403
|
var TEXT_LIMIT = 16e3;
|
|
2260
2404
|
var JSON_LIMIT = 16e3;
|
|
@@ -2262,7 +2406,7 @@ var SYSTEM_PROMPT_LIMIT = 64e3;
|
|
|
2262
2406
|
var TOOL_SCHEMA_LIMIT = 8e3;
|
|
2263
2407
|
var MESSAGES_BUDGET = 4e5;
|
|
2264
2408
|
function hash(value) {
|
|
2265
|
-
return
|
|
2409
|
+
return createHash4("sha256").update(value).digest("base64url").slice(0, 16);
|
|
2266
2410
|
}
|
|
2267
2411
|
function json(value) {
|
|
2268
2412
|
try {
|
|
@@ -2417,6 +2561,16 @@ export {
|
|
|
2417
2561
|
isFoundryApplication,
|
|
2418
2562
|
defineApplication,
|
|
2419
2563
|
EMPTY_FOUNDRY_APPLICATION,
|
|
2564
|
+
TERMINAL_OCCURRENCE_STATUSES,
|
|
2565
|
+
activationScheduleRevision,
|
|
2566
|
+
scheduleRevisionMatches,
|
|
2567
|
+
scheduleOccurrenceId,
|
|
2568
|
+
firstScheduledTime,
|
|
2569
|
+
planScheduleOccurrence,
|
|
2570
|
+
matchesOccurrenceFilter,
|
|
2571
|
+
compareOccurrences,
|
|
2572
|
+
prunableOccurrences,
|
|
2573
|
+
assertScheduleOccurrence,
|
|
2420
2574
|
FOUNDRY_MODEL_REQUESTS_ENV,
|
|
2421
2575
|
requestTracer,
|
|
2422
2576
|
composeAgent,
|
package/dist/cli.js
CHANGED
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
FoundryRuntime,
|
|
4
4
|
FoundryServer,
|
|
5
5
|
writeGeneratedTypes
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-L72FKI7P.js";
|
|
7
7
|
import {
|
|
8
8
|
DEFAULT_FOUNDRY_CONFIG
|
|
9
9
|
} from "./chunk-ZFNMFE3T.js";
|
|
@@ -11,7 +11,7 @@ import "./chunk-J7ZBJM54.js";
|
|
|
11
11
|
import {
|
|
12
12
|
EMPTY_FOUNDRY_APPLICATION,
|
|
13
13
|
isFoundryApplication
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-VLD3DKPI.js";
|
|
15
15
|
import "./chunk-J6NHL4SM.js";
|
|
16
16
|
import "./chunk-CYOIHSUX.js";
|
|
17
17
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { StoreAdapter, AgentEvent, Message, TokenConsumptionCounter } from 'glove-core';
|
|
2
|
-
import {
|
|
2
|
+
import { x as AccountId, o as AccountReference, y as AccountNotFound, d1 as TransmissionId, cV as RouteId, cU as Route, cW as RouteNotFound, c_ as TopologyConflict, a3 as BindingId, q as AgentBinding, a4 as BindingNotFound, Q as AgentId, ax as EventReference, av as EventId, aw as EventNotFound, cY as RunId, z as AccountSessionUnavailable, b as FoundryDataAdapter, bB as FoundryInstanceProvisioner, j as FoundryApproval, a$ as FoundryAgentDefinition, cX as RunGrant, cx as GrantResolutionError, n as AnyFoundryTransmission, bg as FoundryCapabilityRegistry, bZ as FoundryNativeRegistry, c5 as FoundryRequest, a9 as CreateAgentInstanceOptions, c as AgentInstance, bV as FoundryMessageOptions, V as AgentMessageReceipt, br as FoundryEventTarget, bq as FoundryEventPolicy, C as Conversation, f as FoundryEventRecord, d as FoundryActivationRecord, i as FoundryPendingInbound, l as FoundryTask, S as SharedInboxItem, aa as CreateConversationOptions, m as AgentPlaybook, P as PlaybookSubscription, al as DefinePlaybookSubscriptionOptions, a1 as ApplicationConnectionState, d5 as UpdateAgentInstanceOptions, d6 as UpdateConversationOptions, W as WorkspaceEntry, E as EnvironmentValue, bU as FoundryMessageInput, c8 as FoundryResult, b9 as FoundryApprovalStatus, b6 as FoundryApprovalDecision, be as FoundryCapabilityManifest, bX as FoundryNativeManifest, T as AgentInstallation, bo as FoundryDelegationStatus, bm as FoundryDelegation, bT as FoundryMeshThreadStatus, bS as FoundryMeshThread, h as FoundryScheduleOccurrenceFilter, g as FoundryScheduleOccurrence, c9 as FoundryRouteMap, B as AccountSummary, _ as AnyFoundryAgent } from './event-delivery-C7rYiNPs.js';
|
|
3
3
|
import * as effect_Brand from 'effect/Brand';
|
|
4
4
|
import { Context, Effect, Layer, Schema } from 'effect';
|
|
5
5
|
import { FoundryStationDaemonAdapter } from './station.js';
|
|
@@ -423,13 +423,20 @@ declare class FoundryRuntime {
|
|
|
423
423
|
private readonly execution;
|
|
424
424
|
private readonly observer;
|
|
425
425
|
private readonly signalRunner;
|
|
426
|
-
private readonly scheduleAdapter;
|
|
427
426
|
private readonly services;
|
|
428
427
|
private readonly runnerLoops;
|
|
429
428
|
private readonly materializedActivations;
|
|
430
429
|
private readonly activationTransitions;
|
|
431
430
|
private readonly activationDispatches;
|
|
432
431
|
private readonly activationTimers;
|
|
432
|
+
/** Occurrences when the data adapter does not store them. */
|
|
433
|
+
private readonly memoryOccurrences;
|
|
434
|
+
/** Occurrences this process handed (or is handing) to a run. */
|
|
435
|
+
private readonly occurrencesInHand;
|
|
436
|
+
/** Run id to the occurrence it delivers. */
|
|
437
|
+
private readonly occurrenceRuns;
|
|
438
|
+
/** How recent runs settled, for an occurrence recorded after its run already finished. */
|
|
439
|
+
private readonly recentlySettledRuns;
|
|
433
440
|
/** Whether each run's child process still holds its conversation, from FOUNDRY_RUN_PROCESS_EVENT. */
|
|
434
441
|
private readonly runProcesses;
|
|
435
442
|
private readonly approvalDirectory;
|
|
@@ -614,10 +621,10 @@ declare class FoundryRuntime {
|
|
|
614
621
|
installCapability(agentId: string, installation: AgentInstallation): Promise<AgentInstance>;
|
|
615
622
|
uninstallCapability(agentId: string, installation: AgentInstallation): Promise<AgentInstance>;
|
|
616
623
|
listAccounts(): Promise<{
|
|
624
|
+
label?: string | undefined;
|
|
617
625
|
id: string & effect_Brand.Brand<"FoundryAccountId">;
|
|
618
626
|
transmissionId: string & effect_Brand.Brand<"FoundryTransmissionId">;
|
|
619
627
|
externalAccountId: string;
|
|
620
|
-
label?: string | undefined;
|
|
621
628
|
metadata: {
|
|
622
629
|
readonly [x: string]: unknown;
|
|
623
630
|
};
|
|
@@ -797,7 +804,6 @@ declare class FoundryRuntime {
|
|
|
797
804
|
private executeCoreCommandUnlocked;
|
|
798
805
|
private syncAgentPlaybooks;
|
|
799
806
|
private assertActivationOwnership;
|
|
800
|
-
private backendScheduleId;
|
|
801
807
|
private disarmActivation;
|
|
802
808
|
private syncDefinitionSchedules;
|
|
803
809
|
private updateScheduledActivation;
|
|
@@ -805,8 +811,36 @@ declare class FoundryRuntime {
|
|
|
805
811
|
private resumeScheduledActivation;
|
|
806
812
|
private cancelScheduledActivation;
|
|
807
813
|
private reconstructActivations;
|
|
814
|
+
/** List occurrences of schedules and sleeps: what came due, when it was meant for, and what became of it. */
|
|
815
|
+
listScheduleOccurrences(filter?: FoundryScheduleOccurrenceFilter): Promise<ReadonlyArray<FoundryScheduleOccurrence>>;
|
|
816
|
+
private durableOccurrences;
|
|
817
|
+
private claimOccurrence;
|
|
818
|
+
private putOccurrence;
|
|
819
|
+
private getOccurrence;
|
|
808
820
|
private materializeActivation;
|
|
809
|
-
|
|
821
|
+
/** A one-shot that fired before a restart: finish it if its occurrence has settled. */
|
|
822
|
+
private settleFiredOneShot;
|
|
823
|
+
/** Wait for the activation's cursor, then fire; repeat while it has one. */
|
|
824
|
+
private armActivation;
|
|
825
|
+
/**
|
|
826
|
+
* Take the occurrence at the activation's cursor: store it, then move the
|
|
827
|
+
* cursor past it, then hand it to a run. Returns the new cursor.
|
|
828
|
+
*/
|
|
829
|
+
private fireActivation;
|
|
830
|
+
private newOccurrence;
|
|
831
|
+
/**
|
|
832
|
+
* Hand an occurrence to its conversation. Runs under the activation lock,
|
|
833
|
+
* so a pause or cancel never sees it half handed over.
|
|
834
|
+
*/
|
|
835
|
+
private deliverOccurrence;
|
|
836
|
+
/** The run handling an occurrence settled. A run stopped by shutdown did not: the next start delivers it again. */
|
|
837
|
+
private settleOccurrence;
|
|
838
|
+
/**
|
|
839
|
+
* After a restart: hand over every occurrence a previous process claimed
|
|
840
|
+
* and no run finished, unless its activation has since been paused,
|
|
841
|
+
* cancelled or changed.
|
|
842
|
+
*/
|
|
843
|
+
private replayScheduleOccurrences;
|
|
810
844
|
private deliverOutbound;
|
|
811
845
|
private executionEnvelope;
|
|
812
846
|
private toFoundryRun;
|
|
@@ -920,6 +954,8 @@ declare class FoundryClient<TRoutes extends FoundryRouteMap> {
|
|
|
920
954
|
}): Promise<ReadonlyArray<FoundryRun>>;
|
|
921
955
|
playbookSubscriptions(workspaceId?: string): Promise<ReadonlyArray<PlaybookSubscription>>;
|
|
922
956
|
activations(workspaceId?: string): Promise<ReadonlyArray<FoundryActivationRecord>>;
|
|
957
|
+
/** Occurrences of schedules and sleeps: when each was meant for, the run that took it and how it ended. */
|
|
958
|
+
scheduleOccurrences(filter?: FoundryScheduleOccurrenceFilter): Promise<ReadonlyArray<FoundryScheduleOccurrence>>;
|
|
923
959
|
putPlaybookSubscription(subscription: PlaybookSubscription): Promise<PlaybookSubscription>;
|
|
924
960
|
deletePlaybookSubscription(id: string): Promise<boolean>;
|
|
925
961
|
applicationConnections(): Promise<ReadonlyArray<ApplicationConnectionState>>;
|
package/dist/client.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import 'glove-core';
|
|
2
|
-
import './event-delivery-
|
|
3
|
-
export { k as FoundryClient, l as FoundryClientAuthorizationAdapter, m as FoundryClientOptions, q as FoundryHealth, y as FoundryRunHandle, G as FoundrySteerHandleResult, W as WaitOptions, N as createFoundryClient } from './client-
|
|
2
|
+
import './event-delivery-C7rYiNPs.js';
|
|
3
|
+
export { k as FoundryClient, l as FoundryClientAuthorizationAdapter, m as FoundryClientOptions, q as FoundryHealth, y as FoundryRunHandle, G as FoundrySteerHandleResult, W as WaitOptions, N as createFoundryClient } from './client-HM2x2-Ut.js';
|
|
4
4
|
import 'effect';
|
|
5
5
|
import 'zod';
|
|
6
6
|
import 'glove-mesh';
|