glove-foundry 0.5.1 → 0.6.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/README.md +104 -15
- package/dist/{chunk-GKZLWD5M.js → chunk-7F7QVO6I.js} +4 -1
- package/dist/chunk-B36BGF5R.js +530 -0
- package/dist/{chunk-5NFLGHOC.js → chunk-K2EU63MB.js} +216 -29
- package/dist/{chunk-KBMD4RYU.js → chunk-OBTOFA7W.js} +63 -198
- package/dist/{chunk-LW5PJ2FN.js → chunk-RSU7NEDK.js} +9 -3
- package/dist/{chunk-TH5ETCG2.js → chunk-TFGETZYH.js} +198 -11
- package/dist/{chunk-SGF3CFUR.js → chunk-X6EWEWWM.js} +942 -57
- package/dist/cli.js +8 -5
- package/dist/client-DWPYe_Nc.d.ts +888 -0
- package/dist/client.d.ts +2 -1
- package/dist/client.js +1 -1
- package/dist/{client-DcsnudMI.d.ts → definition-A8o11aez.d.ts} +195 -812
- package/dist/execution-agent.js +5 -4
- package/dist/execution-daemon.js +37 -2
- package/dist/execution-loader.js +5 -4
- package/dist/index.d.ts +8 -3
- package/dist/index.js +39 -14
- package/dist/voice.d.ts +168 -0
- package/dist/voice.js +348 -0
- package/docs/building-with-foundry.md +32 -21
- package/docs/durable-execution.md +56 -0
- package/docs/release-verification.md +1 -1
- package/package.json +16 -9
- package/templates/minimal/README.md +34 -8
- package/templates/minimal/agents/assistant/agent.ts +24 -10
- package/templates/minimal/foundry.application.ts +11 -3
- package/templates/minimal/gitignore +1 -0
- package/templates/minimal/lib/file-store.ts +95 -0
- package/templates/travel-concierge/README.md +46 -12
- package/templates/travel-concierge/agents/concierge/agent.ts +10 -4
- package/templates/travel-concierge/agents/concierge/composition.ts +9 -2
- package/templates/travel-concierge/agents/concierge/flights.ts +43 -0
- package/templates/travel-concierge/agents/concierge/instances.ts +42 -0
- package/templates/travel-concierge/agents/concierge/memory/traveller.memory.ts +13 -8
- package/templates/travel-concierge/agents/concierge/tools/convert-currency.tool.ts +34 -0
- package/templates/travel-concierge/agents/concierge/workbench.ts +4 -1
- package/templates/travel-concierge/foundry.application.ts +15 -6
- package/templates/travel-concierge/gitignore +1 -0
- package/templates/travel-concierge/lib/demo-model.ts +89 -25
- package/templates/travel-concierge/lib/file-context.ts +60 -0
- package/templates/travel-concierge/lib/file-store.ts +95 -0
- package/templates/minimal/agents/assistant/tools/current-time.tool.ts +0 -17
- package/templates/travel-concierge/agents/concierge/tools/find-flights.tool.ts +0 -49
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import {
|
|
2
|
+
EMPTY_NATIVE_REGISTRY,
|
|
3
|
+
FOUNDRY_LAYER_BRAND,
|
|
4
|
+
FOUNDRY_SUBSCRIBER_BRAND,
|
|
2
5
|
bindFileIdentity,
|
|
3
6
|
defineAgentFromModule,
|
|
4
7
|
fileDefinitionKey,
|
|
5
8
|
fileDefinitionLabel,
|
|
6
9
|
fileIdentified,
|
|
7
10
|
internalAgentName
|
|
8
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-K2EU63MB.js";
|
|
9
12
|
|
|
10
13
|
// src/application.ts
|
|
11
14
|
var FOUNDRY_APPLICATION_BRAND = /* @__PURE__ */ Symbol.for(
|
|
@@ -408,149 +411,6 @@ function isFoundryCapability(value) {
|
|
|
408
411
|
return object[FOUNDRY_SHARED_TOOL_BRAND] === true || object[FOUNDRY_AGENT_APPLICATION_BRAND] === true || object[FOUNDRY_MCP_BRAND] === true || object[FOUNDRY_MEMORY_BRAND] === true;
|
|
409
412
|
}
|
|
410
413
|
|
|
411
|
-
// src/surfaces.ts
|
|
412
|
-
import { Effect as Effect2 } from "effect";
|
|
413
|
-
var FOUNDRY_LAYER_BRAND = /* @__PURE__ */ Symbol.for("glove-foundry-layer");
|
|
414
|
-
var FOUNDRY_SUBSCRIBER_BRAND = /* @__PURE__ */ Symbol.for(
|
|
415
|
-
"glove-foundry-subscriber"
|
|
416
|
-
);
|
|
417
|
-
var SURFACE_ID = /^[a-z][a-z0-9-]*(?:\/[a-z][a-z0-9-]*)*$/;
|
|
418
|
-
function assertSurfaceId(id2, label) {
|
|
419
|
-
if (!SURFACE_ID.test(id2)) {
|
|
420
|
-
throw new Error(
|
|
421
|
-
`Invalid Foundry ${label} id "${id2}". Use lowercase path segments containing letters, digits, and hyphens.`
|
|
422
|
-
);
|
|
423
|
-
}
|
|
424
|
-
}
|
|
425
|
-
function defineLayer(options) {
|
|
426
|
-
if (options.id) assertSurfaceId(options.id, "layer");
|
|
427
|
-
const { id: id2, ...definition } = options;
|
|
428
|
-
return Object.freeze(fileIdentified({
|
|
429
|
-
...definition,
|
|
430
|
-
[FOUNDRY_LAYER_BRAND]: true
|
|
431
|
-
}, "layer", id2));
|
|
432
|
-
}
|
|
433
|
-
function configureLayer(layer, config) {
|
|
434
|
-
return Object.freeze({ layer, config });
|
|
435
|
-
}
|
|
436
|
-
function defineSubscriber(options) {
|
|
437
|
-
if (options.id) assertSurfaceId(options.id, "subscriber");
|
|
438
|
-
const { id: id2, ...definition } = options;
|
|
439
|
-
return Object.freeze(fileIdentified({
|
|
440
|
-
...definition,
|
|
441
|
-
[FOUNDRY_SUBSCRIBER_BRAND]: true
|
|
442
|
-
}, "subscriber", id2));
|
|
443
|
-
}
|
|
444
|
-
var EMPTY_NATIVE_REGISTRY = Object.freeze({
|
|
445
|
-
layers: Object.freeze([]),
|
|
446
|
-
subscribers: Object.freeze([])
|
|
447
|
-
});
|
|
448
|
-
function indexById(values, label) {
|
|
449
|
-
const indexed = /* @__PURE__ */ new Map();
|
|
450
|
-
for (const value of values) {
|
|
451
|
-
if (indexed.has(value.id)) {
|
|
452
|
-
throw new Error(`Duplicate Foundry ${label} id "${value.id}".`);
|
|
453
|
-
}
|
|
454
|
-
indexed.set(value.id, value);
|
|
455
|
-
}
|
|
456
|
-
return indexed;
|
|
457
|
-
}
|
|
458
|
-
async function mountFoundrySurfaces(options) {
|
|
459
|
-
const layers = indexById(options.registry.layers, "layer");
|
|
460
|
-
const subscribers = indexById(options.registry.subscribers, "subscriber");
|
|
461
|
-
const cleanup = [];
|
|
462
|
-
const disposeAll = async () => {
|
|
463
|
-
const failures = [];
|
|
464
|
-
for (const dispose of cleanup.reverse()) {
|
|
465
|
-
try {
|
|
466
|
-
const result = dispose();
|
|
467
|
-
if (Effect2.isEffect(result)) await Effect2.runPromise(result);
|
|
468
|
-
else await Promise.resolve(result);
|
|
469
|
-
} catch (cause) {
|
|
470
|
-
failures.push(cause);
|
|
471
|
-
}
|
|
472
|
-
}
|
|
473
|
-
if (failures.length > 0) {
|
|
474
|
-
throw new AggregateError(failures, "Foundry surface cleanup failed.");
|
|
475
|
-
}
|
|
476
|
-
};
|
|
477
|
-
try {
|
|
478
|
-
for (const selected of options.subscribers ?? []) {
|
|
479
|
-
let definition = selected;
|
|
480
|
-
if (typeof definition === "object" && definition !== null && FOUNDRY_SUBSCRIBER_BRAND in definition) {
|
|
481
|
-
const registered = subscribers.get(definition.id);
|
|
482
|
-
if (!registered) {
|
|
483
|
-
throw new Error(
|
|
484
|
-
`Agent "${options.context.agentId}" references unknown subscriber "${definition.id}".`
|
|
485
|
-
);
|
|
486
|
-
}
|
|
487
|
-
definition = registered;
|
|
488
|
-
}
|
|
489
|
-
let subscriber;
|
|
490
|
-
let subscriberId = "inline";
|
|
491
|
-
if (typeof definition === "object" && definition !== null && definition[FOUNDRY_SUBSCRIBER_BRAND] === true) {
|
|
492
|
-
const foundrySubscriber = definition;
|
|
493
|
-
const created = typeof foundrySubscriber.create === "function" ? foundrySubscriber.create(options.context) : foundrySubscriber.create;
|
|
494
|
-
subscriber = Effect2.isEffect(created) ? await Effect2.runPromise(created) : await Promise.resolve(created);
|
|
495
|
-
subscriberId = foundrySubscriber.id;
|
|
496
|
-
} else {
|
|
497
|
-
subscriber = definition;
|
|
498
|
-
}
|
|
499
|
-
options.context.glove.addSubscriber(subscriber);
|
|
500
|
-
cleanup.push(() => options.context.glove.removeSubscriber(subscriber));
|
|
501
|
-
options.context.emit({
|
|
502
|
-
type: "foundry.subscriber.mounted",
|
|
503
|
-
data: { id: subscriberId }
|
|
504
|
-
});
|
|
505
|
-
}
|
|
506
|
-
for (const selected of options.layers ?? []) {
|
|
507
|
-
const reference = FOUNDRY_LAYER_BRAND in selected ? { layer: selected } : selected;
|
|
508
|
-
const definition = layers.get(reference.layer.id);
|
|
509
|
-
if (!definition) {
|
|
510
|
-
throw new Error(
|
|
511
|
-
`Agent "${options.context.agentId}" references unknown layer "${reference.layer.id}".`
|
|
512
|
-
);
|
|
513
|
-
}
|
|
514
|
-
const referenceConfig = "config" in reference ? reference.config : void 0;
|
|
515
|
-
const parsed = definition.config ? definition.config.safeParse(referenceConfig ?? {}) : { success: true, data: referenceConfig };
|
|
516
|
-
if (!parsed.success) {
|
|
517
|
-
throw new Error(
|
|
518
|
-
`Invalid config for layer "${definition.id}": ${parsed.error.message}`
|
|
519
|
-
);
|
|
520
|
-
}
|
|
521
|
-
const dispose = await Effect2.runPromise(
|
|
522
|
-
definition.setup({ ...options.context, config: parsed.data })
|
|
523
|
-
);
|
|
524
|
-
if (dispose) cleanup.push(dispose);
|
|
525
|
-
options.context.emit({
|
|
526
|
-
type: "foundry.layer.mounted",
|
|
527
|
-
data: { id: definition.id }
|
|
528
|
-
});
|
|
529
|
-
}
|
|
530
|
-
} catch (cause) {
|
|
531
|
-
try {
|
|
532
|
-
await disposeAll();
|
|
533
|
-
} catch (cleanupCause) {
|
|
534
|
-
throw new AggregateError(
|
|
535
|
-
[cause, cleanupCause],
|
|
536
|
-
"Foundry surface mount and cleanup failed."
|
|
537
|
-
);
|
|
538
|
-
}
|
|
539
|
-
throw cause;
|
|
540
|
-
}
|
|
541
|
-
return disposeAll;
|
|
542
|
-
}
|
|
543
|
-
function isFoundryLayer(value) {
|
|
544
|
-
return Boolean(
|
|
545
|
-
value && typeof value === "object" && value[FOUNDRY_LAYER_BRAND] === true
|
|
546
|
-
);
|
|
547
|
-
}
|
|
548
|
-
function isFoundrySubscriber(value) {
|
|
549
|
-
return Boolean(
|
|
550
|
-
value && typeof value === "object" && value[FOUNDRY_SUBSCRIBER_BRAND] === true
|
|
551
|
-
);
|
|
552
|
-
}
|
|
553
|
-
|
|
554
414
|
// src/composition.ts
|
|
555
415
|
var composedToolBodies = /* @__PURE__ */ new WeakMap();
|
|
556
416
|
function isToolBody(value) {
|
|
@@ -1274,7 +1134,7 @@ function createManifest(agents) {
|
|
|
1274
1134
|
|
|
1275
1135
|
// src/primitives.ts
|
|
1276
1136
|
import { randomUUID } from "node:crypto";
|
|
1277
|
-
import { Effect as
|
|
1137
|
+
import { Effect as Effect3 } from "effect";
|
|
1278
1138
|
function toGloveMessage(input) {
|
|
1279
1139
|
if (typeof input === "string") {
|
|
1280
1140
|
return freezeGloveMessage({ sender: "user", text: input });
|
|
@@ -1311,6 +1171,7 @@ var MemoryFoundryDataAdapter = class {
|
|
|
1311
1171
|
agentsByProvisioningKey = /* @__PURE__ */ new Map();
|
|
1312
1172
|
subscriptions = /* @__PURE__ */ new Map();
|
|
1313
1173
|
inboundDeliveries = /* @__PURE__ */ new Map();
|
|
1174
|
+
pendingInbound = /* @__PURE__ */ new Map();
|
|
1314
1175
|
activations = /* @__PURE__ */ new Map();
|
|
1315
1176
|
conversations = /* @__PURE__ */ new Map();
|
|
1316
1177
|
workspace = /* @__PURE__ */ new Map();
|
|
@@ -1346,13 +1207,13 @@ var MemoryFoundryDataAdapter = class {
|
|
|
1346
1207
|
this.pendingSubscriptions = [];
|
|
1347
1208
|
}
|
|
1348
1209
|
getAgent(id2) {
|
|
1349
|
-
return
|
|
1210
|
+
return Effect3.sync(() => {
|
|
1350
1211
|
this.materializeSeeds();
|
|
1351
1212
|
return this.agents.get(id2) ?? null;
|
|
1352
1213
|
});
|
|
1353
1214
|
}
|
|
1354
1215
|
putAgent(agent) {
|
|
1355
|
-
return
|
|
1216
|
+
return Effect3.sync(() => {
|
|
1356
1217
|
this.materializeSeeds();
|
|
1357
1218
|
const reconstructed = reconstructAgentInstance(agent);
|
|
1358
1219
|
const prior = this.agents.get(agent.id);
|
|
@@ -1366,13 +1227,13 @@ var MemoryFoundryDataAdapter = class {
|
|
|
1366
1227
|
});
|
|
1367
1228
|
}
|
|
1368
1229
|
listAgents(definitionId) {
|
|
1369
|
-
return
|
|
1230
|
+
return Effect3.sync(() => {
|
|
1370
1231
|
this.materializeSeeds();
|
|
1371
1232
|
return [...this.agents.values()].filter((item) => !definitionId || item.definitionId === definitionId);
|
|
1372
1233
|
});
|
|
1373
1234
|
}
|
|
1374
1235
|
provisionAgent(input) {
|
|
1375
|
-
return
|
|
1236
|
+
return Effect3.sync(() => {
|
|
1376
1237
|
this.materializeSeeds();
|
|
1377
1238
|
const existingId = this.agentsByProvisioningKey.get(input.provisioningKey);
|
|
1378
1239
|
if (existingId) return this.agents.get(existingId);
|
|
@@ -1386,34 +1247,34 @@ var MemoryFoundryDataAdapter = class {
|
|
|
1386
1247
|
});
|
|
1387
1248
|
}
|
|
1388
1249
|
getPlaybookSubscription(id2) {
|
|
1389
|
-
return
|
|
1250
|
+
return Effect3.sync(() => {
|
|
1390
1251
|
this.materializeSeeds();
|
|
1391
1252
|
return this.subscriptions.get(id2) ?? null;
|
|
1392
1253
|
});
|
|
1393
1254
|
}
|
|
1394
1255
|
putPlaybookSubscription(subscription) {
|
|
1395
|
-
return
|
|
1256
|
+
return Effect3.sync(() => {
|
|
1396
1257
|
this.materializeSeeds();
|
|
1397
1258
|
this.subscriptions.set(subscription.id, reconstructPlaybookSubscription(subscription));
|
|
1398
1259
|
});
|
|
1399
1260
|
}
|
|
1400
1261
|
deletePlaybookSubscription(id2) {
|
|
1401
|
-
return
|
|
1262
|
+
return Effect3.sync(() => {
|
|
1402
1263
|
this.materializeSeeds();
|
|
1403
1264
|
return this.subscriptions.delete(id2);
|
|
1404
1265
|
});
|
|
1405
1266
|
}
|
|
1406
1267
|
listPlaybookSubscriptions(workspaceId) {
|
|
1407
|
-
return
|
|
1268
|
+
return Effect3.sync(() => {
|
|
1408
1269
|
this.materializeSeeds();
|
|
1409
1270
|
return [...this.subscriptions.values()].filter((item) => !workspaceId || item.workspaceId === workspaceId);
|
|
1410
1271
|
});
|
|
1411
1272
|
}
|
|
1412
1273
|
getInboundDelivery(key) {
|
|
1413
|
-
return
|
|
1274
|
+
return Effect3.succeed(this.inboundDeliveries.get(key) ?? null);
|
|
1414
1275
|
}
|
|
1415
1276
|
claimInboundDelivery(key) {
|
|
1416
|
-
return
|
|
1277
|
+
return Effect3.sync(() => {
|
|
1417
1278
|
if (this.inboundDeliveries.has(key)) return false;
|
|
1418
1279
|
this.inboundDeliveries.set(key, Object.freeze({
|
|
1419
1280
|
key,
|
|
@@ -1425,7 +1286,7 @@ var MemoryFoundryDataAdapter = class {
|
|
|
1425
1286
|
});
|
|
1426
1287
|
}
|
|
1427
1288
|
completeInboundDelivery(key, runIds) {
|
|
1428
|
-
return
|
|
1289
|
+
return Effect3.sync(() => {
|
|
1429
1290
|
const prior = this.inboundDeliveries.get(key);
|
|
1430
1291
|
if (!prior) throw new Error(`Inbound delivery claim "${key}" does not exist.`);
|
|
1431
1292
|
this.inboundDeliveries.set(key, Object.freeze({
|
|
@@ -1437,46 +1298,59 @@ var MemoryFoundryDataAdapter = class {
|
|
|
1437
1298
|
});
|
|
1438
1299
|
}
|
|
1439
1300
|
releaseInboundDelivery(key) {
|
|
1440
|
-
return
|
|
1301
|
+
return Effect3.sync(() => {
|
|
1441
1302
|
if (this.inboundDeliveries.get(key)?.status === "pending") {
|
|
1442
1303
|
this.inboundDeliveries.delete(key);
|
|
1443
1304
|
}
|
|
1444
1305
|
});
|
|
1445
1306
|
}
|
|
1307
|
+
putPendingInbound(record) {
|
|
1308
|
+
return Effect3.sync(() => {
|
|
1309
|
+
this.pendingInbound.set(record.id, structuredClone(record));
|
|
1310
|
+
});
|
|
1311
|
+
}
|
|
1312
|
+
deletePendingInbound(id2) {
|
|
1313
|
+
return Effect3.sync(() => {
|
|
1314
|
+
this.pendingInbound.delete(id2);
|
|
1315
|
+
});
|
|
1316
|
+
}
|
|
1317
|
+
listPendingInbound() {
|
|
1318
|
+
return Effect3.sync(() => [...this.pendingInbound.values()].map((record) => structuredClone(record)));
|
|
1319
|
+
}
|
|
1446
1320
|
getActivation(id2) {
|
|
1447
|
-
return
|
|
1321
|
+
return Effect3.succeed(this.activations.get(id2) ?? null);
|
|
1448
1322
|
}
|
|
1449
1323
|
putActivation(activation) {
|
|
1450
|
-
return
|
|
1324
|
+
return Effect3.sync(() => {
|
|
1451
1325
|
this.activations.set(activation.id, reconstructActivation(activation));
|
|
1452
1326
|
});
|
|
1453
1327
|
}
|
|
1454
1328
|
listActivations(workspaceId) {
|
|
1455
|
-
return
|
|
1329
|
+
return Effect3.succeed(
|
|
1456
1330
|
[...this.activations.values()].filter((item) => !workspaceId || item.workspaceId === workspaceId)
|
|
1457
1331
|
);
|
|
1458
1332
|
}
|
|
1459
1333
|
getConversation(id2) {
|
|
1460
|
-
return
|
|
1334
|
+
return Effect3.succeed(this.conversations.get(id2) ?? null);
|
|
1461
1335
|
}
|
|
1462
1336
|
putConversation(conversation) {
|
|
1463
|
-
return
|
|
1337
|
+
return Effect3.sync(() => {
|
|
1464
1338
|
this.conversations.set(conversation.id, Object.freeze({ ...conversation }));
|
|
1465
1339
|
});
|
|
1466
1340
|
}
|
|
1467
1341
|
listConversations(agentId) {
|
|
1468
|
-
return
|
|
1342
|
+
return Effect3.succeed([...this.conversations.values()].filter((item) => item.agentId === agentId));
|
|
1469
1343
|
}
|
|
1470
1344
|
getWorkspaceEntry(workspaceId, key) {
|
|
1471
|
-
return
|
|
1345
|
+
return Effect3.succeed(this.workspace.get(`${workspaceId}:${key}`) ?? null);
|
|
1472
1346
|
}
|
|
1473
1347
|
putWorkspaceEntry(entry) {
|
|
1474
|
-
return
|
|
1348
|
+
return Effect3.sync(() => {
|
|
1475
1349
|
this.workspace.set(`${entry.workspaceId}:${entry.key}`, Object.freeze({ ...entry }));
|
|
1476
1350
|
});
|
|
1477
1351
|
}
|
|
1478
1352
|
compareAndSetWorkspaceEntry(entry, expectedUpdatedAt) {
|
|
1479
|
-
return
|
|
1353
|
+
return Effect3.sync(() => {
|
|
1480
1354
|
const key = `${entry.workspaceId}:${entry.key}`;
|
|
1481
1355
|
const current = this.workspace.get(key);
|
|
1482
1356
|
if ((current?.updatedAt ?? null) !== expectedUpdatedAt) return false;
|
|
@@ -1488,16 +1362,16 @@ var MemoryFoundryDataAdapter = class {
|
|
|
1488
1362
|
});
|
|
1489
1363
|
}
|
|
1490
1364
|
listWorkspaceEntries(workspaceId) {
|
|
1491
|
-
return
|
|
1365
|
+
return Effect3.succeed([...this.workspace.values()].filter((item) => item.workspaceId === workspaceId));
|
|
1492
1366
|
}
|
|
1493
1367
|
getWorkingEnvironmentSnapshot(owner) {
|
|
1494
|
-
return
|
|
1368
|
+
return Effect3.sync(() => {
|
|
1495
1369
|
const snapshot = this.workingEnvironments.get(workingEnvironmentOwnerKey(owner));
|
|
1496
1370
|
return snapshot ? structuredClone(snapshot) : null;
|
|
1497
1371
|
});
|
|
1498
1372
|
}
|
|
1499
1373
|
putWorkingEnvironmentSnapshot(owner, snapshot) {
|
|
1500
|
-
return
|
|
1374
|
+
return Effect3.sync(() => {
|
|
1501
1375
|
this.workingEnvironments.set(
|
|
1502
1376
|
workingEnvironmentOwnerKey(owner),
|
|
1503
1377
|
structuredClone(snapshot)
|
|
@@ -1505,23 +1379,23 @@ var MemoryFoundryDataAdapter = class {
|
|
|
1505
1379
|
});
|
|
1506
1380
|
}
|
|
1507
1381
|
putInboxItem(item) {
|
|
1508
|
-
return
|
|
1382
|
+
return Effect3.sync(() => {
|
|
1509
1383
|
this.inbox.set(item.id, Object.freeze({ ...item }));
|
|
1510
1384
|
});
|
|
1511
1385
|
}
|
|
1512
1386
|
listInboxItems(workspaceId) {
|
|
1513
|
-
return
|
|
1387
|
+
return Effect3.succeed([...this.inbox.values()].filter((item) => item.workspaceId === workspaceId));
|
|
1514
1388
|
}
|
|
1515
1389
|
putTask(task) {
|
|
1516
|
-
return
|
|
1390
|
+
return Effect3.sync(() => {
|
|
1517
1391
|
this.tasks.set(task.id, Object.freeze({ ...task }));
|
|
1518
1392
|
});
|
|
1519
1393
|
}
|
|
1520
1394
|
listTasks(workspaceId) {
|
|
1521
|
-
return
|
|
1395
|
+
return Effect3.succeed([...this.tasks.values()].filter((item) => item.workspaceId === workspaceId));
|
|
1522
1396
|
}
|
|
1523
1397
|
listEnvironment(scope) {
|
|
1524
|
-
return
|
|
1398
|
+
return Effect3.succeed(this.environment.filter(
|
|
1525
1399
|
(item) => item.workspaceId === scope.workspaceId && (item.scope === "workspace" || item.scope === "agent" && item.agentId === scope.agentId || item.scope === "conversation" && item.conversationId === scope.conversationId)
|
|
1526
1400
|
));
|
|
1527
1401
|
}
|
|
@@ -1676,7 +1550,7 @@ function agentScheduleRevision(schedule) {
|
|
|
1676
1550
|
|
|
1677
1551
|
// src/core-tools.ts
|
|
1678
1552
|
import { randomUUID as randomUUID2 } from "node:crypto";
|
|
1679
|
-
import { Effect as
|
|
1553
|
+
import { Effect as Effect4, JSONSchema as JSONSchema2, Schema as Schema2 } from "effect";
|
|
1680
1554
|
import { z } from "zod";
|
|
1681
1555
|
|
|
1682
1556
|
// src/core-command-result.ts
|
|
@@ -2036,7 +1910,7 @@ function createFoundryCoreTools(context, desiredSchedules = []) {
|
|
|
2036
1910
|
};
|
|
2037
1911
|
const scheduleView = async () => {
|
|
2038
1912
|
const records = new Map(
|
|
2039
|
-
[...context.activations, ...await
|
|
1913
|
+
[...context.activations, ...await Effect4.runPromise(context.data.listActivations(context.workspaceId))].filter((item) => item.kind === "scheduled" && item.agentId === context.agentId).map((item) => [item.id, item])
|
|
2040
1914
|
);
|
|
2041
1915
|
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
2042
1916
|
for (const desired of desiredSchedules) {
|
|
@@ -2354,7 +2228,7 @@ function createFoundryCoreTools(context, desiredSchedules = []) {
|
|
|
2354
2228
|
description: "List the conversations owned by this runtime agent instance.",
|
|
2355
2229
|
inputSchema: z.object({}),
|
|
2356
2230
|
async do() {
|
|
2357
|
-
return { status: "success", data: await
|
|
2231
|
+
return { status: "success", data: await Effect4.runPromise(context.data.listConversations(context.agentId)) };
|
|
2358
2232
|
}
|
|
2359
2233
|
},
|
|
2360
2234
|
{
|
|
@@ -2367,12 +2241,12 @@ function createFoundryCoreTools(context, desiredSchedules = []) {
|
|
|
2367
2241
|
]),
|
|
2368
2242
|
async do(input) {
|
|
2369
2243
|
if (input.action === "get") {
|
|
2370
|
-
return { status: "success", data: await
|
|
2244
|
+
return { status: "success", data: await Effect4.runPromise(context.data.getWorkspaceEntry(context.workspaceId, input.key)) };
|
|
2371
2245
|
}
|
|
2372
2246
|
if (input.action === "list") {
|
|
2373
|
-
return { status: "success", data: await
|
|
2247
|
+
return { status: "success", data: await Effect4.runPromise(context.data.listWorkspaceEntries(context.workspaceId)) };
|
|
2374
2248
|
}
|
|
2375
|
-
await
|
|
2249
|
+
await Effect4.runPromise(context.data.putWorkspaceEntry({
|
|
2376
2250
|
workspaceId: context.workspaceId,
|
|
2377
2251
|
key: input.key,
|
|
2378
2252
|
value: input.value,
|
|
@@ -2401,13 +2275,13 @@ function createFoundryCoreTools(context, desiredSchedules = []) {
|
|
|
2401
2275
|
]),
|
|
2402
2276
|
async do(input) {
|
|
2403
2277
|
if (input.action === "list") {
|
|
2404
|
-
return { status: "success", data: await
|
|
2278
|
+
return { status: "success", data: await Effect4.runPromise(context.data.listInboxItems(context.workspaceId)) };
|
|
2405
2279
|
}
|
|
2406
2280
|
if (input.action === "update") {
|
|
2407
|
-
const current = (await
|
|
2281
|
+
const current = (await Effect4.runPromise(context.data.listInboxItems(context.workspaceId))).find((item3) => item3.id === input.itemId);
|
|
2408
2282
|
if (!current) return { status: "error", data: null, error: `Shared inbox item "${input.itemId}" was not found.` };
|
|
2409
2283
|
const item2 = { ...current, status: input.status, updatedAt: (/* @__PURE__ */ new Date()).toISOString() };
|
|
2410
|
-
await
|
|
2284
|
+
await Effect4.runPromise(context.data.putInboxItem(item2));
|
|
2411
2285
|
return { status: "success", data: item2 };
|
|
2412
2286
|
}
|
|
2413
2287
|
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
@@ -2422,7 +2296,7 @@ function createFoundryCoreTools(context, desiredSchedules = []) {
|
|
|
2422
2296
|
createdAt: now,
|
|
2423
2297
|
updatedAt: now
|
|
2424
2298
|
};
|
|
2425
|
-
await
|
|
2299
|
+
await Effect4.runPromise(context.data.putInboxItem(item));
|
|
2426
2300
|
return { status: "success", data: item };
|
|
2427
2301
|
}
|
|
2428
2302
|
},
|
|
@@ -2440,13 +2314,13 @@ function createFoundryCoreTools(context, desiredSchedules = []) {
|
|
|
2440
2314
|
]),
|
|
2441
2315
|
async do(input) {
|
|
2442
2316
|
if (input.action === "list") {
|
|
2443
|
-
return { status: "success", data: await
|
|
2317
|
+
return { status: "success", data: await Effect4.runPromise(context.data.listTasks(context.workspaceId)) };
|
|
2444
2318
|
}
|
|
2445
2319
|
if (input.action === "update") {
|
|
2446
|
-
const current = (await
|
|
2320
|
+
const current = (await Effect4.runPromise(context.data.listTasks(context.workspaceId))).find((task3) => task3.id === input.taskId);
|
|
2447
2321
|
if (!current) return { status: "error", data: null, error: `Task "${input.taskId}" was not found.` };
|
|
2448
2322
|
const task2 = { ...current, status: input.status, updatedAt: (/* @__PURE__ */ new Date()).toISOString() };
|
|
2449
|
-
await
|
|
2323
|
+
await Effect4.runPromise(context.data.putTask(task2));
|
|
2450
2324
|
return { status: "success", data: task2 };
|
|
2451
2325
|
}
|
|
2452
2326
|
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
@@ -2461,7 +2335,7 @@ function createFoundryCoreTools(context, desiredSchedules = []) {
|
|
|
2461
2335
|
createdAt: now,
|
|
2462
2336
|
updatedAt: now
|
|
2463
2337
|
};
|
|
2464
|
-
await
|
|
2338
|
+
await Effect4.runPromise(context.data.putTask(task));
|
|
2465
2339
|
return { status: "success", data: task };
|
|
2466
2340
|
}
|
|
2467
2341
|
},
|
|
@@ -2472,7 +2346,7 @@ function createFoundryCoreTools(context, desiredSchedules = []) {
|
|
|
2472
2346
|
async do() {
|
|
2473
2347
|
return {
|
|
2474
2348
|
status: "success",
|
|
2475
|
-
data: await
|
|
2349
|
+
data: await Effect4.runPromise(context.data.listEnvironment({
|
|
2476
2350
|
workspaceId: context.workspaceId,
|
|
2477
2351
|
agentId: context.agentId,
|
|
2478
2352
|
conversationId: context.conversationId
|
|
@@ -2716,15 +2590,6 @@ export {
|
|
|
2716
2590
|
mountAgentDefinitionMemory,
|
|
2717
2591
|
installRegistry,
|
|
2718
2592
|
isFoundryCapability,
|
|
2719
|
-
FOUNDRY_LAYER_BRAND,
|
|
2720
|
-
FOUNDRY_SUBSCRIBER_BRAND,
|
|
2721
|
-
defineLayer,
|
|
2722
|
-
configureLayer,
|
|
2723
|
-
defineSubscriber,
|
|
2724
|
-
EMPTY_NATIVE_REGISTRY,
|
|
2725
|
-
mountFoundrySurfaces,
|
|
2726
|
-
isFoundryLayer,
|
|
2727
|
-
isFoundrySubscriber,
|
|
2728
2593
|
composeAgent,
|
|
2729
2594
|
EMPTY_AGENT_COMPOSITION,
|
|
2730
2595
|
FOUNDRY_CONNECTION_BRAND,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
resolveResolvable
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-K2EU63MB.js";
|
|
4
4
|
|
|
5
5
|
// src/guidance.ts
|
|
6
6
|
import { createHash } from "node:crypto";
|
|
@@ -104,7 +104,13 @@ async function mountFoundryGuidance(glove, context, options) {
|
|
|
104
104
|
};
|
|
105
105
|
const cleanups = [];
|
|
106
106
|
try {
|
|
107
|
-
for (const
|
|
107
|
+
for (const entry of options.contextProviders) {
|
|
108
|
+
if (typeof entry === "function") cleanups.push(glove.addContextProvider(entry));
|
|
109
|
+
else {
|
|
110
|
+
const { provider, ...delivery } = entry;
|
|
111
|
+
cleanups.push(glove.addContextProvider(provider, delivery));
|
|
112
|
+
}
|
|
113
|
+
}
|
|
108
114
|
if (facts || goals || forms) {
|
|
109
115
|
await snapshot();
|
|
110
116
|
cleanups.push(glove.addContextProvider(async () => {
|
|
@@ -285,7 +291,7 @@ function programmaticToolFunction(selection, options) {
|
|
|
285
291
|
);
|
|
286
292
|
}
|
|
287
293
|
const validated = parsed?.success ? parsed.data : input;
|
|
288
|
-
const permission = typeof tool.requiresPermission === "function" ? tool.requiresPermission(validated) : Boolean(tool.requiresPermission);
|
|
294
|
+
const permission = typeof tool.requiresPermission === "function" ? Boolean(await tool.requiresPermission(validated)) : Boolean(tool.requiresPermission);
|
|
289
295
|
if (permission) {
|
|
290
296
|
options.context.controls.emit({
|
|
291
297
|
type: "foundry.repl.programmatic-tool.denied",
|