@framers/agentos 0.12.3 → 0.12.5

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.
Files changed (119) hide show
  1. package/dist/api/agent.d.ts +7 -5
  2. package/dist/api/agent.d.ts.map +1 -1
  3. package/dist/api/agent.js.map +1 -1
  4. package/dist/api/generateObject.d.ts +5 -5
  5. package/dist/api/generateText.d.ts +173 -50
  6. package/dist/api/generateText.d.ts.map +1 -1
  7. package/dist/api/generateText.js +272 -81
  8. package/dist/api/generateText.js.map +1 -1
  9. package/dist/api/index.d.ts +6 -1
  10. package/dist/api/index.d.ts.map +1 -1
  11. package/dist/api/index.js +5 -1
  12. package/dist/api/index.js.map +1 -1
  13. package/dist/api/runtime/GMIChunkTransformer.d.ts +1 -1
  14. package/dist/api/runtime/GMIChunkTransformer.d.ts.map +1 -1
  15. package/dist/api/runtime/GMIChunkTransformer.js +7 -2
  16. package/dist/api/runtime/GMIChunkTransformer.js.map +1 -1
  17. package/dist/api/runtime/completionGateway.d.ts +98 -0
  18. package/dist/api/runtime/completionGateway.d.ts.map +1 -0
  19. package/dist/api/runtime/completionGateway.js +347 -0
  20. package/dist/api/runtime/completionGateway.js.map +1 -0
  21. package/dist/api/runtime/contextWindowFit.d.ts +49 -0
  22. package/dist/api/runtime/contextWindowFit.d.ts.map +1 -0
  23. package/dist/api/runtime/contextWindowFit.js +109 -0
  24. package/dist/api/runtime/contextWindowFit.js.map +1 -0
  25. package/dist/api/runtime/gatewayProviderManager.d.ts +37 -0
  26. package/dist/api/runtime/gatewayProviderManager.d.ts.map +1 -0
  27. package/dist/api/runtime/gatewayProviderManager.js +49 -0
  28. package/dist/api/runtime/gatewayProviderManager.js.map +1 -0
  29. package/dist/api/streamText.d.ts.map +1 -1
  30. package/dist/api/streamText.js +90 -6
  31. package/dist/api/streamText.js.map +1 -1
  32. package/dist/cognition/emergent/ComposableToolBuilder.d.ts.map +1 -1
  33. package/dist/cognition/emergent/ComposableToolBuilder.js +16 -8
  34. package/dist/cognition/emergent/ComposableToolBuilder.js.map +1 -1
  35. package/dist/cognition/emergent/EffectsStore.d.ts +58 -0
  36. package/dist/cognition/emergent/EffectsStore.d.ts.map +1 -0
  37. package/dist/cognition/emergent/EffectsStore.js +96 -0
  38. package/dist/cognition/emergent/EffectsStore.js.map +1 -0
  39. package/dist/cognition/emergent/EmergentCapabilityEngine.d.ts +22 -2
  40. package/dist/cognition/emergent/EmergentCapabilityEngine.d.ts.map +1 -1
  41. package/dist/cognition/emergent/EmergentCapabilityEngine.js +128 -19
  42. package/dist/cognition/emergent/EmergentCapabilityEngine.js.map +1 -1
  43. package/dist/cognition/emergent/EmergentJudge.d.ts +1 -1
  44. package/dist/cognition/emergent/EmergentJudge.d.ts.map +1 -1
  45. package/dist/cognition/emergent/EmergentToolRegistry.d.ts +12 -3
  46. package/dist/cognition/emergent/EmergentToolRegistry.d.ts.map +1 -1
  47. package/dist/cognition/emergent/EmergentToolRegistry.js +51 -4
  48. package/dist/cognition/emergent/EmergentToolRegistry.js.map +1 -1
  49. package/dist/cognition/emergent/ForgeToolMetaTool.d.ts.map +1 -1
  50. package/dist/cognition/emergent/ForgeToolMetaTool.js +4 -1
  51. package/dist/cognition/emergent/ForgeToolMetaTool.js.map +1 -1
  52. package/dist/cognition/emergent/SandboxedToolForge.d.ts +55 -51
  53. package/dist/cognition/emergent/SandboxedToolForge.d.ts.map +1 -1
  54. package/dist/cognition/emergent/SandboxedToolForge.js +103 -109
  55. package/dist/cognition/emergent/SandboxedToolForge.js.map +1 -1
  56. package/dist/cognition/emergent/ToolPackage.d.ts +2 -2
  57. package/dist/cognition/emergent/ToolPackage.d.ts.map +1 -1
  58. package/dist/cognition/emergent/broker/CapabilityBroker.d.ts +58 -0
  59. package/dist/cognition/emergent/broker/CapabilityBroker.d.ts.map +1 -0
  60. package/dist/cognition/emergent/broker/CapabilityBroker.js +288 -0
  61. package/dist/cognition/emergent/broker/CapabilityBroker.js.map +1 -0
  62. package/dist/cognition/emergent/broker/fetch.d.ts +44 -0
  63. package/dist/cognition/emergent/broker/fetch.d.ts.map +1 -0
  64. package/dist/cognition/emergent/broker/fetch.js +197 -0
  65. package/dist/cognition/emergent/broker/fetch.js.map +1 -0
  66. package/dist/cognition/emergent/broker/fs-read.d.ts +63 -0
  67. package/dist/cognition/emergent/broker/fs-read.d.ts.map +1 -0
  68. package/dist/cognition/emergent/broker/fs-read.js +133 -0
  69. package/dist/cognition/emergent/broker/fs-read.js.map +1 -0
  70. package/dist/cognition/emergent/broker/refusal.d.ts +10 -0
  71. package/dist/cognition/emergent/broker/refusal.d.ts.map +1 -0
  72. package/dist/cognition/emergent/broker/refusal.js +13 -0
  73. package/dist/cognition/emergent/broker/refusal.js.map +1 -0
  74. package/dist/cognition/emergent/ceiling.d.ts +75 -0
  75. package/dist/cognition/emergent/ceiling.d.ts.map +1 -0
  76. package/dist/cognition/emergent/ceiling.js +166 -0
  77. package/dist/cognition/emergent/ceiling.js.map +1 -0
  78. package/dist/cognition/emergent/index.d.ts +2 -0
  79. package/dist/cognition/emergent/index.d.ts.map +1 -1
  80. package/dist/cognition/emergent/index.js +1 -0
  81. package/dist/cognition/emergent/index.js.map +1 -1
  82. package/dist/cognition/emergent/types.d.ts +75 -2
  83. package/dist/cognition/emergent/types.d.ts.map +1 -1
  84. package/dist/cognition/emergent/types.js.map +1 -1
  85. package/dist/cognition/substrate/GMI.d.ts +21 -0
  86. package/dist/cognition/substrate/GMI.d.ts.map +1 -1
  87. package/dist/cognition/substrate/GMI.js +286 -88
  88. package/dist/cognition/substrate/GMI.js.map +1 -1
  89. package/dist/cognition/substrate/IGMI.d.ts +48 -1
  90. package/dist/cognition/substrate/IGMI.d.ts.map +1 -1
  91. package/dist/cognition/substrate/IGMI.js +4 -0
  92. package/dist/cognition/substrate/IGMI.js.map +1 -1
  93. package/dist/core/llm/providers/errors/ContextWindowExceededError.d.ts +22 -0
  94. package/dist/core/llm/providers/errors/ContextWindowExceededError.d.ts.map +1 -0
  95. package/dist/core/llm/providers/errors/ContextWindowExceededError.js +21 -0
  96. package/dist/core/llm/providers/errors/ContextWindowExceededError.js.map +1 -0
  97. package/dist/core/llm/providers/implementations/OpenRouterProvider.d.ts.map +1 -1
  98. package/dist/core/llm/providers/implementations/OpenRouterProvider.js +34 -13
  99. package/dist/core/llm/providers/implementations/OpenRouterProvider.js.map +1 -1
  100. package/dist/core/llm/routing/IModelRouter.d.ts +6 -0
  101. package/dist/core/llm/routing/IModelRouter.d.ts.map +1 -1
  102. package/dist/core/llm/routing/PolicyAwareRouter.d.ts +7 -0
  103. package/dist/core/llm/routing/PolicyAwareRouter.d.ts.map +1 -1
  104. package/dist/core/llm/routing/PolicyAwareRouter.js +12 -0
  105. package/dist/core/llm/routing/PolicyAwareRouter.js.map +1 -1
  106. package/dist/core/llm/routing/UncensoredModelCatalog.d.ts +37 -0
  107. package/dist/core/llm/routing/UncensoredModelCatalog.d.ts.map +1 -1
  108. package/dist/core/llm/routing/UncensoredModelCatalog.js +64 -74
  109. package/dist/core/llm/routing/UncensoredModelCatalog.js.map +1 -1
  110. package/dist/core/tools/ITool.d.ts +45 -0
  111. package/dist/core/tools/ITool.d.ts.map +1 -1
  112. package/dist/core/tools/ToolOrchestrator.d.ts.map +1 -1
  113. package/dist/core/tools/ToolOrchestrator.js +4 -8
  114. package/dist/core/tools/ToolOrchestrator.js.map +1 -1
  115. package/dist/index.d.ts +5 -0
  116. package/dist/index.d.ts.map +1 -1
  117. package/dist/index.js +4 -0
  118. package/dist/index.js.map +1 -1
  119. package/package.json +1 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EffectsStore.d.ts","sourceRoot":"","sources":["../../../src/cognition/emergent/EffectsStore.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAEjE,qEAAqE;AACrE,MAAM,MAAM,aAAa,GAAG,IAAI,GAAG,OAAO,GAAG,SAAS,GAA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cAAc,GAAG,OAAO,CAAC,IAAI,CAAC;IA4BlE;;;;;OAKG;IACH,OAAO,CAAC,OAAO;CAsBhB"}
@@ -0,0 +1,96 @@
1
+ /**
2
+ * @fileoverview Effect records for code-forged tools under a ceiling: an
3
+ * intent row written before each capability call, and a terminal update after
4
+ * it, in `agentos_emergent_effects`. A row without an outcome reads as
5
+ * unknown: its run's process ended, or its terminal write failed.
6
+ * @module @framers/agentos/emergent/EffectsStore
7
+ */
8
+ import { createHash, randomUUID } from 'node:crypto';
9
+ /** The target as a record keeps it. */
10
+ export function recordedTarget(target, content) {
11
+ return content === 'full' ? target : createHash('sha256').update(target).digest('hex');
12
+ }
13
+ const DAY_MS = 86400000;
14
+ export class EffectsStore {
15
+ constructor(db, options) {
16
+ this.db = db;
17
+ this.options = options;
18
+ }
19
+ /** Writes the intent row and resolves to its id. Rejects when the write fails; the caller refuses the call. */
20
+ async intent(row) {
21
+ await this.prepare();
22
+ const id = randomUUID();
23
+ await this.db.run(`INSERT INTO agentos_emergent_effects
24
+ (id, tool_id, call_id, agent_id, capability, target, target_form, decision, decided_by, intent_at)
25
+ VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`, [
26
+ id,
27
+ row.toolId,
28
+ row.callId,
29
+ row.agentId,
30
+ row.capability,
31
+ recordedTarget(row.target, this.options.content),
32
+ this.options.content,
33
+ row.decision,
34
+ row.decidedBy,
35
+ Date.now(),
36
+ ]);
37
+ return id;
38
+ }
39
+ /** Writes the terminal half of an intent row. Rejects when the write fails; the row then reads unknown. */
40
+ async terminal(id, end) {
41
+ await this.db.run(`UPDATE agentos_emergent_effects
42
+ SET outcome = ?, code = ?, bytes = ?, uses = ?, terminal_at = ?
43
+ WHERE id = ?`, [end.outcome, end.code ?? null, end.bytes ?? null, end.uses ?? null, Date.now(), id]);
44
+ }
45
+ /** One row holding both halves: a refused call, or a run's crypto count. */
46
+ async whole(row, end) {
47
+ await this.prepare();
48
+ const at = Date.now();
49
+ await this.db.run(`INSERT INTO agentos_emergent_effects
50
+ (id, tool_id, call_id, agent_id, capability, target, target_form, decision, decided_by, intent_at,
51
+ outcome, code, bytes, uses, terminal_at)
52
+ VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`, [
53
+ randomUUID(),
54
+ row.toolId,
55
+ row.callId,
56
+ row.agentId,
57
+ row.capability,
58
+ recordedTarget(row.target, this.options.content),
59
+ this.options.content,
60
+ row.decision,
61
+ row.decidedBy,
62
+ at,
63
+ end.outcome,
64
+ end.code ?? null,
65
+ end.bytes ?? null,
66
+ end.uses ?? null,
67
+ at,
68
+ ]);
69
+ }
70
+ /**
71
+ * The schema made ready, then, once per store, the rows older than
72
+ * `retainDays` deleted from this table (never tool rows or state). A failed
73
+ * preparation is tried again by the next write; a failed prune is logged
74
+ * and not tried again.
75
+ */
76
+ prepare() {
77
+ if (!this.ready) {
78
+ this.ready = (async () => {
79
+ await this.options.ensureSchema();
80
+ if (this.options.retainDays !== undefined) {
81
+ const cutoff = Date.now() - this.options.retainDays * DAY_MS;
82
+ await this.db
83
+ .run('DELETE FROM agentos_emergent_effects WHERE intent_at < ?', [cutoff])
84
+ .catch((error) => {
85
+ console.warn('[agentos:emergent] could not prune effect records:', error instanceof Error ? error.message : error);
86
+ });
87
+ }
88
+ })().catch((error) => {
89
+ this.ready = undefined;
90
+ throw error;
91
+ });
92
+ }
93
+ return this.ready;
94
+ }
95
+ }
96
+ //# sourceMappingURL=EffectsStore.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EffectsStore.js","sourceRoot":"","sources":["../../../src/cognition/emergent/EffectsStore.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AA6BrD,uCAAuC;AACvC,MAAM,UAAU,cAAc,CAAC,MAAc,EAAE,OAA0B;IACvE,OAAO,OAAO,KAAK,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC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AAC,CAAC,CAAC;gBACP,CAAC;YACH,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,KAAc,EAAE,EAAE;gBAC5B,IAAI,CAAC,KAAK,GAAG,SAAS,CAAC;gBACvB,MAAM,KAAK,CAAC;YACd,CAAC,CAAC,CAAC;QACL,CAAC;QACD,OAAO,IAAI,CAAC,KAAK,CAAC;IACpB,CAAC;CACF"}
@@ -135,8 +135,15 @@ export interface EmergentCapabilityEngineDeps {
135
135
  config: EmergentConfig;
136
136
  /** Builder for composable (tool-chaining) implementations. */
137
137
  composableBuilder: ComposableToolBuilder;
138
- /** Sandboxed code executor for arbitrary-code implementations. */
139
- sandboxForge: SandboxedToolForge;
138
+ /**
139
+ * The executor for code-forged tools. Optional: without it the engine
140
+ * builds one from `config.sandboxMemoryMB` and `config.sandboxTimeoutMs`.
141
+ * Under a ceiling (`config.capabilities`) a forge given here must be no
142
+ * wider than the ceiling (construction fails with
143
+ * `forge_wider_than_ceiling` naming the option), narrows it where it is
144
+ * narrower, and serves this engine only.
145
+ */
146
+ sandboxForge?: SandboxedToolForge;
140
147
  /** LLM-as-judge evaluator for creation and promotion reviews. */
141
148
  judge: EmergentJudge;
142
149
  /** Tiered registry for storing and querying emergent tools. */
@@ -165,6 +172,10 @@ export declare class EmergentCapabilityEngine {
165
172
  private readonly onToolForged?;
166
173
  private readonly onToolPromoted?;
167
174
  private readonly onToolRemoved?;
175
+ /** The host's ceiling for code-forged tools, resolved; absent on the legacy path. */
176
+ private readonly ceiling?;
177
+ /** The broker the forge's injected functions come from under a ceiling. */
178
+ private readonly broker?;
168
179
  /** Internal index for fast session/agent → tool lookups. */
169
180
  private readonly index;
170
181
  /**
@@ -427,5 +438,14 @@ export declare class EmergentCapabilityEngine {
427
438
  private removeIndexedToolEverywhere;
428
439
  private extractSessionId;
429
440
  private buildSandboxExecutable;
441
+ /**
442
+ * One run of forged code, as a forge test or a call. Under a ceiling the
443
+ * run has its own call handle, which ends when the run does, however it
444
+ * ends (it returns, throws or times out): the broker refuses capability
445
+ * calls from then on, aborts the ones in flight, waits up to a second for
446
+ * them, and hands back the run's effects. The handle is per run, so ending
447
+ * one never touches a concurrent run of the same tool.
448
+ */
449
+ private runSandboxed;
430
450
  }
431
451
  //# sourceMappingURL=EmergentCapabilityEngine.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"EmergentCapabilityEngine.d.ts","sourceRoot":"","sources":["../../../src/cognition/emergent/EmergentCapabilityEngine.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EACV,cAAc,EACd,gBAAgB,EAChB,WAAW,EACX,eAAe,EACf,YAAY,EAKZ,SAAS,EAET,QAAQ,EACT,MAAM,YAAY,CAAC;AAgBpB,OAAO,KAAK,EAAE,KAAK,EAAE,oBAAoB,EAAuB,MAAM,2BAA2B,CAAC;AAClG,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,+BAA+B,CAAC;AAE9E,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AACnE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AAMjE;;;;;;GAMG;AACH,MAAM,WAAW,uBAAuB;IACtC;;;;OAIG;IACH,cAAc,EAAE,CAAC,OAAO,CAAC,EAAE,oBAAoB,KAAK,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAE3E;;;;OAIG;IACH,cAAc,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,oBAAoB,KAAK,OAAO,GAAG,IAAI,CAAC;IAEjG,8FAA8F;IAC9F,aAAa,CAAC,EAAE,wBAAwB,CAAC;IAEzC,mDA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AiB,GAAG,SAAS,CAAC;IAI5E;;;;;OAKG;IACG,oBAAoB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;YAuB7C,OAAO;YAIP,UAAU;IA4BxB;;;;OAIG;YACW,QAAQ;IAStB,gFAAgF;IAChF,OAAO,CAAC,kBAAkB;IAc1B,OAAO,CAAC,QAAQ;IAgDhB;;;OAGG;IACH;;;;;OAKG;YACW,OAAO;YA6BP,KAAK;IAmPnB;;;;;;;;;;;;;OAaG;YACW,kBAAkB;IAwChC,6DAA6D;YAC/C,cAAc;IAc5B;;;;OAIG;IACH,OAAO,CAAC,UAAU;IAsBlB;;;;;OAKG;IACH,OAAO,CAAC,gBAAgB;IAoBxB,oFAAoF;IACpF,OAAO,CAAC,WAAW;IASnB;;;;OAIG;YACW,gBAAgB;YAYhB,gBAAgB;IAO9B;;;OAGG;IACH,OAAO,CAAC,oBAAoB;IAU5B,iFAAiF;IACjF,OAAO,CAAC,UAAU;IAWlB;;;;;;;;;;;;;;;;OAgBG;IACG,0BAA0B,CAAC,IAAI,EAAE,uBAAuB,GAAG,OAAO,CAAC,KAAK,EAAE,CAAC;IAqGjF;;;;;;;OAOG;IACH,oBAAoB,CAAC,IAAI,EAAE,YAAY,GAAG,sBAAsB;IAuIhE;;;;;;OAMG;IACH,OAAO,CAAC,SAAS;IAcjB,OAAO,CAAC,iBAAiB;IAKzB,OAAO,CAAC,2BAA2B;IASnC,OAAO,CAAC,gBAAgB;IAIxB,OAAO,CAAC,sBAAsB;CAgC/B"}
1
+ {"version":3,"file":"EmergentCapabilityEngine.d.ts","sourceRoot":"","sources":["../../../src/cognition/emergent/EmergentCapabilityEngine.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EACV,cAAc,EACd,gBAAgB,EAChB,WAAW,EACX,eAAe,EACf,YAAY,EAKZ,SAAS,EAET,QAAQ,EAIT,MAAM,YAAY,CAAC;AAmBpB,OAAO,KAAK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6DAA6D;YAC/C,cAAc;IAc5B;;;;OAIG;IACH,OAAO,CAAC,UAAU;IA+BlB;;;;;OAKG;IACH,OAAO,CAAC,gBAAgB;IAoBxB,oFAAoF;IACpF,OAAO,CAAC,WAAW;IASnB;;;;OAIG;YACW,gBAAgB;YAYhB,gBAAgB;IAO9B;;;OAGG;IACH,OAAO,CAAC,oBAAoB;IAU5B,iFAAiF;IACjF,OAAO,CAAC,UAAU;IAWlB;;;;;;;;;;;;;;;;OAgBG;IACG,0BAA0B,CAAC,IAAI,EAAE,uBAAuB,GAAG,OAAO,CAAC,KAAK,EAAE,CAAC;IAqGjF;;;;;;;OAOG;IACH,oBAAoB,CAAC,IAAI,EAAE,YAAY,GAAG,sBAAsB;IAyIhE;;;;;;OAMG;IACH,OAAO,CAAC,SAAS;IAcjB,OAAO,CAAC,iBAAiB;IAKzB,OAAO,CAAC,2BAA2B;IASnC,OAAO,CAAC,gBAAgB;IAIxB,OAAO,CAAC,sBAAsB;IAkC9B;;;;;;;OAOG;YACW,YAAY;CAqC3B"}
@@ -16,6 +16,10 @@
16
16
  import { GMI_INSTANCE_ID_PREFIX } from './types.js';
17
17
  import { parsePersistedSource, parseRowSchemas, parseStoredRequest, requestFromImplementation, sessionFromSource, requestFromSource, sourceFromImplementation, stateSetterFromColumn, toolFromRow, } from './persisted-source.js';
18
18
  import { normalizeAllowlist, toSandboxApis } from './capabilities.js';
19
+ import { randomUUID } from 'node:crypto';
20
+ import { checkRequest, narrowToForge, resolveCeiling } from './ceiling.js';
21
+ import { CapabilityBroker } from './broker/CapabilityBroker.js';
22
+ import { SandboxedToolForge } from './SandboxedToolForge.js';
19
23
  // ============================================================================
20
24
  // DEPENDENCY BUNDLE
21
25
  // ============================================================================
@@ -30,7 +34,23 @@ const REASON_CONFIG_KEYS = {
30
34
  step_not_chainable: 'emergent.compose.sideEffectingTools',
31
35
  side_effects_undeclared: "the step tool's hasSideEffects",
32
36
  step_cycle: "the composition's steps (a step reaches the composition itself)",
37
+ capability_not_granted: 'emergent.capabilities',
38
+ request_unreadable: "the tool's stored request (a release that reads it)",
33
39
  };
40
+ /**
41
+ * The start-up line of an engine that runs code-forged tools without a
42
+ * ceiling: what runs unscoped, and the ceiling that comes closest.
43
+ */
44
+ function legacyLine(options) {
45
+ const everyHost = options.fetchDomainAllowlist.length === 0;
46
+ const hosts = everyHost ? 'any host' : options.fetchDomainAllowlist.join(', ');
47
+ const domains = everyHost ? "'*'" : JSON.stringify(options.fetchDomainAllowlist);
48
+ return ('[agentos:emergent] code-forged tools run without a ceiling: a tool granted fetch sends any method to ' +
49
+ `${hosts} (only the first host is checked; redirects go anywhere), fs.readFile reads under ` +
50
+ `${options.fsReadRoots.join(', ')}, and crypto is unscoped. The closest ceiling: ` +
51
+ `capabilities: { fetch: { domains: ${domains} }, 'fs.read': { roots: ${JSON.stringify(options.fsReadRoots)} }, crypto: {} } ` +
52
+ '(a ceiling sends GET and HEAD only, checks every redirect, and bounds bodies, reads and time).');
53
+ }
34
54
  /**
35
55
  * The library's suspensions of a composition that a change in what is
36
56
  * registered can lift: the composition is checked again when a tool one of
@@ -116,7 +136,6 @@ export class EmergentCapabilityEngine {
116
136
  this.admissionChains = new Map();
117
137
  this.config = deps.config;
118
138
  this.composableBuilder = deps.composableBuilder;
119
- this.sandboxForge = deps.sandboxForge;
120
139
  this.judge = deps.judge;
121
140
  this.registry = deps.registry;
122
141
  this.onToolForged = deps.onToolForged;
@@ -128,6 +147,28 @@ export class EmergentCapabilityEngine {
128
147
  this.composableBuilder.bind({
129
148
  sideEffectingTools: this.config.compose?.sideEffectingTools ?? [],
130
149
  });
150
+ const forge = deps.sandboxForge ??
151
+ new SandboxedToolForge({ memoryMB: this.config.sandboxMemoryMB, timeoutMs: this.config.sandboxTimeoutMs });
152
+ if (this.config.capabilities) {
153
+ // Throws a CeilingError naming the key of the first failure.
154
+ const resolved = resolveCeiling(this.config.capabilities, this.config.audit, {
155
+ hasStorage: this.registry.hasStorage(),
156
+ });
157
+ this.ceiling = deps.sandboxForge ? narrowToForge(resolved, deps.sandboxForge.effectiveOptions()) : resolved;
158
+ const store = this.ceiling.audit.store === 'storage'
159
+ ? this.registry.effectsStore({
160
+ content: this.ceiling.audit.content,
161
+ ...(this.ceiling.audit.retainDays !== undefined ? { retainDays: this.ceiling.audit.retainDays } : {}),
162
+ })
163
+ : undefined;
164
+ this.broker = new CapabilityBroker(this.ceiling, store);
165
+ forge.attachBroker(this.broker);
166
+ }
167
+ else if (this.config.allowSandboxTools) {
168
+ // A direct host never calls the loader, so the line comes from here.
169
+ console.warn(legacyLine(forge.effectiveOptions()));
170
+ }
171
+ this.sandboxForge = forge;
131
172
  }
132
173
  // --------------------------------------------------------------------------
133
174
  // PUBLIC: forge
@@ -226,7 +267,7 @@ export class EmergentCapabilityEngine {
226
267
  output: result.output,
227
268
  success: result.success,
228
269
  error: result.error,
229
- ...(details?.effects && details.effects.length > 0 ? { effects: details.effects } : {}),
270
+ ...(result.effects && result.effects.length > 0 ? { effects: result.effects } : {}),
230
271
  });
231
272
  }
232
273
  }
@@ -249,7 +290,20 @@ export class EmergentCapabilityEngine {
249
290
  error: `allowlist names capabilities outside the catalogue: ${list.unknown.join(', ')}`,
250
291
  };
251
292
  }
252
- // Step 2b: Static code validation before any execution.
293
+ // Step 2b: under a ceiling the list is a request, and a name the ceiling
294
+ // does not grant refuses the forge before any test case runs.
295
+ if (this.ceiling) {
296
+ const fit = checkRequest(list.capabilities, this.ceiling);
297
+ if (!fit.ok) {
298
+ return {
299
+ success: false,
300
+ error: `capability_not_granted: ${fit.refused.join(', ')}; this host grants ` +
301
+ (fit.allowed.length > 0 ? fit.allowed.join(', ') : 'no capability') +
302
+ ' to code-forged tools',
303
+ };
304
+ }
305
+ }
306
+ // Step 2c: Static code validation before any execution.
253
307
  const validation = this.sandboxForge.validateCode(request.implementation.code, request.implementation.allowlist);
254
308
  if (!validation.valid) {
255
309
  return {
@@ -257,20 +311,18 @@ export class EmergentCapabilityEngine {
257
311
  error: `Code validation failed: ${validation.violations.join('; ')}`,
258
312
  };
259
313
  }
260
- // Step 3: Execute test cases in the sandbox.
314
+ // Step 3: Execute test cases in the sandbox, each as a run of its own.
261
315
  for (const tc of request.testCases) {
262
- const sandboxResult = await this.sandboxForge.execute({
263
- code: request.implementation.code,
264
- input: tc.input,
265
- allowlist: request.implementation.allowlist,
266
- memoryMB: this.config.sandboxMemoryMB,
267
- timeoutMs: this.config.sandboxTimeoutMs,
316
+ const sandboxResult = await this.runSandboxed(request.implementation, tc.input, {
317
+ toolId,
318
+ agentId: context.agentId,
268
319
  });
269
320
  testResults.push({
270
321
  input: tc.input,
271
322
  output: sandboxResult.output,
272
323
  success: sandboxResult.success,
273
324
  error: sandboxResult.error,
325
+ ...(sandboxResult.effects ? { effects: sandboxResult.effects } : {}),
274
326
  });
275
327
  }
276
328
  }
@@ -1004,6 +1056,12 @@ export class EmergentCapabilityEngine {
1004
1056
  if (!refusal && candidate.tier === 'agent' && candidate.createdBy.startsWith(GMI_INSTANCE_ID_PREFIX)) {
1005
1057
  refusal = 'legacy_owner';
1006
1058
  }
1059
+ // 3b. Under a ceiling, a stored request this release cannot read is not
1060
+ // replaced by one derived from the source, which could narrow the
1061
+ // tool silently: it waits, suspended, for a release that reads it.
1062
+ if (!refusal && this.ceiling && implementation?.mode === 'sandbox' && requestStored && !stored?.request) {
1063
+ refusal = 'request_unreadable';
1064
+ }
1007
1065
  if (implementation && !refusal) {
1008
1066
  refusal = this.refusalFor(implementation, name);
1009
1067
  }
@@ -1212,6 +1270,15 @@ export class EmergentCapabilityEngine {
1212
1270
  if (implementation.code.trim() === '') {
1213
1271
  return 'source_not_persisted';
1214
1272
  }
1273
+ if (this.ceiling) {
1274
+ // The grant must fit the ceiling in force: a lowered ceiling
1275
+ // suspends the tool, and the next load under a ceiling that covers
1276
+ // it again lifts the suspension (the library's, so it is re-checked).
1277
+ const list = normalizeAllowlist(implementation.allowlist);
1278
+ if (list.unknown.length > 0 || !checkRequest(list.capabilities, this.ceiling).ok) {
1279
+ return 'capability_not_granted';
1280
+ }
1281
+ }
1215
1282
  return null;
1216
1283
  }
1217
1284
  for (const step of implementation.steps) {
@@ -1490,6 +1557,7 @@ export class EmergentCapabilityEngine {
1490
1557
  output: result.output,
1491
1558
  error: result.error ?? 'A step of this composition can no longer be chained.',
1492
1559
  details: result.details,
1560
+ ...(result.effects ? { effects: result.effects } : {}),
1493
1561
  };
1494
1562
  }
1495
1563
  let success = result.success;
@@ -1520,6 +1588,7 @@ export class EmergentCapabilityEngine {
1520
1588
  output: result.output,
1521
1589
  error: error ?? 'Emergent tool execution failed.',
1522
1590
  ...(result.details ? { details: result.details } : {}),
1591
+ ...(result.effects ? { effects: result.effects } : {}),
1523
1592
  };
1524
1593
  },
1525
1594
  };
@@ -1571,25 +1640,65 @@ export class EmergentCapabilityEngine {
1571
1640
  outputSchema: tool.outputSchema,
1572
1641
  category: 'emergent',
1573
1642
  hasSideEffects: true,
1574
- execute: async (args) => {
1643
+ execute: async (args, context) => {
1575
1644
  if (tool.implementation.mode !== 'sandbox') {
1576
1645
  return {
1577
1646
  success: false,
1578
1647
  error: 'Sandbox executor received a non-sandbox emergent tool.',
1579
1648
  };
1580
1649
  }
1581
- const sandboxResult = await this.sandboxForge.execute({
1582
- code: tool.implementation.code,
1583
- input: args,
1584
- allowlist: tool.implementation.allowlist,
1585
- memoryMB: this.config.sandboxMemoryMB,
1586
- timeoutMs: this.config.sandboxTimeoutMs,
1650
+ const sandboxResult = await this.runSandboxed(tool.implementation, args, {
1651
+ toolId: tool.id,
1652
+ agentId: context?.personaId ?? 'unknown',
1587
1653
  });
1654
+ const effects = sandboxResult.effects ? { effects: sandboxResult.effects } : {};
1588
1655
  return sandboxResult.success
1589
- ? { success: true, output: sandboxResult.output }
1590
- : { success: false, error: sandboxResult.error };
1656
+ ? { success: true, output: sandboxResult.output, ...effects }
1657
+ : { success: false, error: sandboxResult.error, ...effects };
1591
1658
  },
1592
1659
  };
1593
1660
  }
1661
+ /**
1662
+ * One run of forged code, as a forge test or a call. Under a ceiling the
1663
+ * run has its own call handle, which ends when the run does, however it
1664
+ * ends (it returns, throws or times out): the broker refuses capability
1665
+ * calls from then on, aborts the ones in flight, waits up to a second for
1666
+ * them, and hands back the run's effects. The handle is per run, so ending
1667
+ * one never touches a concurrent run of the same tool.
1668
+ */
1669
+ async runSandboxed(implementation, input, who) {
1670
+ const request = {
1671
+ code: implementation.code,
1672
+ input,
1673
+ allowlist: implementation.allowlist,
1674
+ memoryMB: this.config.sandboxMemoryMB,
1675
+ timeoutMs: this.config.sandboxTimeoutMs,
1676
+ };
1677
+ if (!this.broker) {
1678
+ return this.sandboxForge.execute(request);
1679
+ }
1680
+ const controller = new AbortController();
1681
+ const call = {
1682
+ id: randomUUID(),
1683
+ toolId: who.toolId,
1684
+ agentId: who.agentId,
1685
+ signal: controller.signal,
1686
+ };
1687
+ let result;
1688
+ try {
1689
+ result = await this.sandboxForge.execute({ ...request, call });
1690
+ }
1691
+ catch (error) {
1692
+ result = {
1693
+ success: false,
1694
+ error: error instanceof Error ? error.message : String(error),
1695
+ executionTimeMs: 0,
1696
+ memoryUsedBytes: 0,
1697
+ };
1698
+ }
1699
+ controller.abort();
1700
+ const effects = await this.broker.endCall(call.id);
1701
+ return effects.length > 0 ? { ...result, effects } : result;
1702
+ }
1594
1703
  }
1595
1704
  //# sourceMappingURL=EmergentCapabilityEngine.js.map