@framers/agentos 0.12.5 → 0.12.7

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 (32) hide show
  1. package/dist/cognition/emergent/ComposableToolBuilder.d.ts +3 -1
  2. package/dist/cognition/emergent/ComposableToolBuilder.d.ts.map +1 -1
  3. package/dist/cognition/emergent/ComposableToolBuilder.js +9 -5
  4. package/dist/cognition/emergent/ComposableToolBuilder.js.map +1 -1
  5. package/dist/cognition/emergent/EmergentCapabilityEngine.d.ts +33 -4
  6. package/dist/cognition/emergent/EmergentCapabilityEngine.d.ts.map +1 -1
  7. package/dist/cognition/emergent/EmergentCapabilityEngine.js +190 -48
  8. package/dist/cognition/emergent/EmergentCapabilityEngine.js.map +1 -1
  9. package/dist/cognition/emergent/EmergentToolRegistry.d.ts +107 -20
  10. package/dist/cognition/emergent/EmergentToolRegistry.d.ts.map +1 -1
  11. package/dist/cognition/emergent/EmergentToolRegistry.js +252 -37
  12. package/dist/cognition/emergent/EmergentToolRegistry.js.map +1 -1
  13. package/dist/cognition/emergent/StepGate.d.ts +10 -3
  14. package/dist/cognition/emergent/StepGate.d.ts.map +1 -1
  15. package/dist/cognition/emergent/StepGate.js +13 -2
  16. package/dist/cognition/emergent/StepGate.js.map +1 -1
  17. package/dist/core/llm/providers/implementations/OpenRouterProvider.d.ts.map +1 -1
  18. package/dist/core/llm/providers/implementations/OpenRouterProvider.js +41 -5
  19. package/dist/core/llm/providers/implementations/OpenRouterProvider.js.map +1 -1
  20. package/dist/core/tools/ITool.d.ts +7 -0
  21. package/dist/core/tools/ITool.d.ts.map +1 -1
  22. package/dist/core/tools/ToolExecutor.d.ts +3 -1
  23. package/dist/core/tools/ToolExecutor.d.ts.map +1 -1
  24. package/dist/core/tools/ToolExecutor.js +3 -1
  25. package/dist/core/tools/ToolExecutor.js.map +1 -1
  26. package/dist/core/tools/ToolOrchestrator.d.ts.map +1 -1
  27. package/dist/core/tools/ToolOrchestrator.js +14 -6
  28. package/dist/core/tools/ToolOrchestrator.js.map +1 -1
  29. package/dist/io/media/images/imageToBuffer.d.ts.map +1 -1
  30. package/dist/io/media/images/imageToBuffer.js +6 -4
  31. package/dist/io/media/images/imageToBuffer.js.map +1 -1
  32. package/package.json +1 -1
@@ -137,7 +137,9 @@ export declare class ComposableToolBuilder {
137
137
  *
138
138
  * Compositions nest no deeper than {@link MAX_COMPOSITION_DEPTH}: the depth
139
139
  * travels in `context.sessionData.emergentDepth`, and a run at the limit is
140
- * refused with `step_cycle`.
140
+ * refused with `nesting_too_deep`, a code no composition is suspended for (a
141
+ * chain that long is not a cycle; the engine refuses a composition that
142
+ * reaches itself at its own call).
141
143
  *
142
144
  * A refusal or a failure ends the run; `details` then names the step, the
143
145
  * steps that completed before it, and the effects so far.
@@ -1 +1 @@
1
- {"version":3,"file":"ComposableToolBuilder.d.ts","sourceRoot":"","sources":["../../../src/cognition/emergent/ComposableToolBuilder.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,KAAK,EAAE,kBAAkB,EAAkB,MAAM,YAAY,CAAC;AACrE,OAAO,EAIL,KAAK,YAAY,EACjB,KAAK,QAAQ,EACd,MAAM,eAAe,CAAC;AACvB,OAAO,KAAK,EACV,KAAK,EAEL,mBAAmB,EACnB,oBAAoB,EACpB,gBAAgB,EACjB,MAAM,2BAA2B,CAAC;AA0BnC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;AACH,qBAAa,qBAAqB;IAChC;;;;OAIG;IACH,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAC;IAE7B,OAAO,CAAC,IAAI,CAAuB;IACnC,OAAO,CAAC,kBAAkB,CAAyB;IAEnD;;;;;;;;OAQG;gBAED,aAAa,EACT,QAAQ,GACR,CAAC,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,oBAAoB,KAAK,OAAO,CAAC,mBAAm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,EAAE,gBAAgB,EAC7B,IAAI,EAAE,kBAAkB,GACvB,KAAK;IAeR;;;;;;;;;;;;;;;;;OAiBG;IACG,WAAW,CACf,IAAI,EAAE,kBAAkB,EACxB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC7B,OAAO,EAAE,oBAAoB,EAC7B,OAAO,GAAE;QAAE,GAAG,CAAC,EAAE;YAAE,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;SAAE,CAAC;QAAC,MAAM,CAAC,EAAE,WAAW,CAAA;KAAO,GACrF,OAAO,CAAC,mBAAmB,CAAC;IA8G/B;;;;;;;;;;;;;;;;;;;;;;OAsBG;IACH,QAAQ,CAAC,IAAI,EAAE,kBAAkB,GAAG;QAAE,KAAK,EAAE,OAAO,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,EAAE,CAAA;KAAE;CAgB1E"}
@@ -153,7 +153,9 @@ export class ComposableToolBuilder {
153
153
  description,
154
154
  inputSchema,
155
155
  hasSideEffects: true,
156
- execute: (args, context) => this.runPipeline(spec, args, context),
156
+ // The call's expiry reaches every step's run, so a step whose approval
157
+ // arrives after the call expired starts nothing.
158
+ execute: (args, context) => this.runPipeline(spec, args, context, context.signal ? { signal: context.signal } : {}),
157
159
  };
158
160
  }
159
161
  /**
@@ -167,7 +169,9 @@ export class ComposableToolBuilder {
167
169
  *
168
170
  * Compositions nest no deeper than {@link MAX_COMPOSITION_DEPTH}: the depth
169
171
  * travels in `context.sessionData.emergentDepth`, and a run at the limit is
170
- * refused with `step_cycle`.
172
+ * refused with `nesting_too_deep`, a code no composition is suspended for (a
173
+ * chain that long is not a cycle; the engine refuses a composition that
174
+ * reaches itself at its own call).
171
175
  *
172
176
  * A refusal or a failure ends the run; `details` then names the step, the
173
177
  * steps that completed before it, and the effects so far.
@@ -186,9 +190,9 @@ export class ComposableToolBuilder {
186
190
  if (depth >= MAX_COMPOSITION_DEPTH) {
187
191
  return {
188
192
  success: false,
189
- error: `step_cycle: compositions nest more than ${MAX_COMPOSITION_DEPTH} deep; ` +
190
- 'a composition that reaches itself, or a chain that long, does not run',
191
- details: { code: 'step_cycle', depth },
193
+ error: `nesting_too_deep: compositions nest more than ${MAX_COMPOSITION_DEPTH} deep; ` +
194
+ 'a chain that long does not run',
195
+ details: { code: 'nesting_too_deep', depth },
192
196
  };
193
197
  }
194
198
  const stepContext = {
@@ -1 +1 @@
1
- {"version":3,"file":"ComposableToolBuilder.js","sourceRoot":"","sources":["../../../src/cognition/emergent/ComposableToolBuilder.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAGH,OAAO,EACL,0BAA0B,EAC1B,qBAAqB,EACrB,cAAc,GAGf,MAAM,eAAe,CAAC;AA6BvB,+EAA+E;AAC/E,0BAA0B;AAC1B,+EAA+E;AAE/E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;AACH,MAAM,OAAO,qBAAqB;IAWhC;;;;;;;;OAQG;IACH,YACE,aAEsG,EACtG,OAAkC;QAf5B,uBAAkB,GAAsB,EAAE,CAAC;QAiBjD,IAAI,CAAC,UAAU,GAAG,OAAO,EAAE,UAAU,IAAI,KAAK,CAAC;QAC/C,IAAI,CAAC,IAAI,GAAG,OAAO,aAAa,KAAK,UAAU,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,aAAa,CAAC;IAC9E,CAAC;IAED;;;;OAIG;IACH,IAAI,CAAC,OAAoE;QACvE,IAAI,OAAO,CAAC,IAAI,EAAE,CAAC;YACjB,IAAI,CAAC,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;QAC3B,CAAC;QACD,IAAI,OAAO,CAAC,kBAAkB,EAAE,CAAC;YAC/B,IAAI,CAAC,kBAAkB,GAAG,OAAO,CAAC,kBAAkB,CAAC;QACvD,CAAC;IACH,CAAC;IAED,wDAAwD;IACxD,OAAO;QACL,OAAO,IAAI,CAAC,IAAI,KAAK,SAAS,CAAC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,CAAC;IACH,CAAC;IAED,wEAAwE;IACxE,2EAA2E;IAC3E,IAAI,MAAM,EAAE,CAAC;QACX,MAAM,IAAI,KAAK,CACb,qCAAqC,IAAI,wCAAwC,CAClF,CAAC;IACJ,CAAC;IACD,2EAA2E;IAC3E,4DAA4D;IAC5D,OAAO,CAAC,IAAI,CAAC,iDAAiD,IAAI,sBAAsB,CAAC,CAAC;IAC1F,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;;;;;;;;GASG;AACH,SAAS,WAAW,CAAC,IAAa,EAAE,IAAY;IAC9C,MAAM,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACjC,IAAI,OAAO,GAAY,IAAI,CAAC;IAC5B,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE,CAAC;QAC/B,IAAI,OAAO,IAAI,IAAI,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE,CAAC;YACnD,OAAO,SAAS,CAAC;QACnB,CAAC;QACD,OAAO,GAAI,OAAmC,CAAC,OAAO,CAAC,CAAC;IAC1D,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC;AAED;;;;;GAKG;AACH,SAAS,aAAa,CAAC,KAAc;IACnC,OAAO,CACL,KAAK,KAAK,IAAI;QACd,OAAO,KAAK,KAAK,QAAQ;QACzB,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;QACrB,MAAM,CAAC,cAAc,CAAC,KAAK,CAAC,KAAK,MAAM,CAAC,SAAS,CAClD,CAAC;AACJ,CAAC"}
1
+ {"version":3,"file":"ComposableToolBuilder.js","sourceRoot":"","sources":["../../../src/cognition/emergent/ComposableToolBuilder.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAGH,OAAO,EACL,0BAA0B,EAC1B,qBAAqB,EACrB,cAAc,GAGf,MAAM,eAAe,CAAC;AA6BvB,+EAA+E;AAC/E,0BAA0B;AAC1B,+EAA+E;AAE/E;;;;;;;;;;;;;;;;;;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CAAC,CAAC;IACjC,IAAI,OAAO,GAAY,IAAI,CAAC;IAC5B,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE,CAAC;QAC/B,IAAI,OAAO,IAAI,IAAI,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE,CAAC;YACnD,OAAO,SAAS,CAAC;QACnB,CAAC;QACD,OAAO,GAAI,OAAmC,CAAC,OAAO,CAAC,CAAC;IAC1D,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC;AAED;;;;;GAKG;AACH,SAAS,aAAa,CAAC,KAAc;IACnC,OAAO,CACL,KAAK,KAAK,IAAI;QACd,OAAO,KAAK,KAAK,QAAQ;QACzB,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;QACrB,MAAM,CAAC,cAAc,CAAC,KAAK,CAAC,KAAK,MAAM,CAAC,SAAS,CAClD,CAAC;AACJ,CAAC"}
@@ -252,9 +252,13 @@ export declare class EmergentCapabilityEngine {
252
252
  * Clean up all session tools for a given session.
253
253
  *
254
254
  * Delegates to the registry's `EmergentToolRegistry.cleanupSession()`
255
- * method and clears the local session index.
255
+ * method and clears the local session index. A tool forged in the session
256
+ * and promoted out of it since (now at the agent tier) is not the
257
+ * session's any more: it stays held, registered and indexed under its
258
+ * agent.
256
259
  *
257
260
  * @param sessionId - The session identifier to clean up.
261
+ * @returns the tools the cleanup removed.
258
262
  */
259
263
  cleanupSession(sessionId: string): EmergentTool[];
260
264
  /**
@@ -370,6 +374,12 @@ export declare class EmergentCapabilityEngine {
370
374
  private settleRegistration;
371
375
  /** Take a tool's executable out of the host, best-effort. */
372
376
  private dropExecutable;
377
+ /**
378
+ * The forge's refusal of a composition under what is registered now: a step
379
+ * that may not be chained, or a chain that reaches the composition itself,
380
+ * with the step or the path named; `null` when it may be forged.
381
+ */
382
+ private composeRefusal;
373
383
  /**
374
384
  * The library's reason for not running an implementation under the
375
385
  * configuration in force, or `null`. Later steps add their checks here, so
@@ -388,13 +398,32 @@ export declare class EmergentCapabilityEngine {
388
398
  /**
389
399
  * A suspension the library sets from a run or a promotion check: written as
390
400
  * the library's (so a later load, or a registration of the missing step
391
- * tool, re-checks it), held here, and the executable taken out.
401
+ * tool, re-checks it), held here, and the executable taken out. It gives
402
+ * way to the host's word: when this process holds a host's suspension or a
403
+ * demotion nothing is written, and a row another process restricted that
404
+ * way is left as it is and held here (`yieldToHost`), so the library never
405
+ * turns a host's restriction into one of its own that a re-check lifts.
406
+ *
407
+ * It takes its turn with the tool's admissions (`serializeAdmission`): a
408
+ * re-check that a registration starts while the suspension is written runs
409
+ * after it, reads the row it leaves and lifts it when the step fits again,
410
+ * instead of reading the row from before it and holding the suspension
411
+ * whose write was still under way.
412
+ *
413
+ * @returns whether the library's suspension is what holds now.
392
414
  */
393
415
  private suspendAsLibrary;
416
+ private suspendAsLibraryNow;
394
417
  private unregisterIfLive;
395
418
  /**
396
- * A restriction this process holds that is newer than the row it just read:
397
- * its write is in flight, so the row does not yet show it.
419
+ * A restriction this process holds that the row read from `readAt` on may
420
+ * not show: one requested here whose write is still queued or running, or
421
+ * settled after the read began, or a host's whose write failed (it stays
422
+ * in force here until the host reactivates the tool). Decided by the
423
+ * registry's record of its own writes, not by timestamps, so a contended
424
+ * hold, a library suspension whose write failed and a record taken from an
425
+ * earlier row read give way to the row, and so does a restriction another
426
+ * process lifted after it, whatever the processes' clocks say.
398
427
  */
399
428
  private newerRestrictionHeld;
400
429
  /** A stored restriction, held in this process too when the tool is live here. */
@@ -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,EAIT,MAAM,YAAY,CAAC;AAmBpB,OAAO,KAAK,EAAE,KAAK,EAAoB,oBAAoB,EAA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iF;IACjF,OAAO,CAAC,UAAU;IAgBlB;;;;;;;;;;;;;;;;OAgBG;IACG,0BAA0B,CAAC,IAAI,EAAE,uBAAuB,GAAG,OAAO,CAAC,KAAK,EAAE,CAAC;IAqGjF;;;;;;;OAOG;IACH,oBAAoB,CAAC,IAAI,EAAE,YAAY,GAAG,sBAAsB;IAgKhE;;;;;;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"}
@@ -116,6 +116,20 @@ function sameGrant(a, b) {
116
116
  }
117
117
  return JSON.stringify(a) === JSON.stringify(b);
118
118
  }
119
+ /** A restriction only the host clears: its own suspension, or a demotion. */
120
+ function isHostRestriction(record) {
121
+ return record.state === 'demoted' || (record.state === 'suspended' && record.setBy === 'host');
122
+ }
123
+ /**
124
+ * The ids of the emergent compositions running further up a call, outermost
125
+ * first. Each composition's executable adds its own before its steps run;
126
+ * the list travels in `sessionData.emergentChain`, through every step's
127
+ * call, as the depth does.
128
+ */
129
+ function compositionChain(context) {
130
+ const chain = context.sessionData?.emergentChain;
131
+ return Array.isArray(chain) ? chain.filter((id) => typeof id === 'string') : [];
132
+ }
119
133
  export class EmergentCapabilityEngine {
120
134
  /**
121
135
  * Create a new EmergentCapabilityEngine.
@@ -207,23 +221,11 @@ export class EmergentCapabilityEngine {
207
221
  if (request.implementation.mode === 'compose') {
208
222
  // ---- COMPOSE MODE ----
209
223
  source = JSON.stringify(request.implementation);
210
- // Every step must be chainable before any test case runs.
211
- for (const step of request.implementation.steps) {
212
- const verdict = this.composableBuilder.check(step.tool);
213
- if (!verdict.ok) {
214
- return {
215
- success: false,
216
- error: `${verdict.code}: step "${step.name}" (tool "${step.tool}"): ${verdict.message}`,
217
- };
218
- }
219
- }
220
- // A composition must not reach itself, through any nesting.
221
- const cycle = this.compositionCycle(request.name, request.implementation.steps);
222
- if (cycle) {
223
- return {
224
- success: false,
225
- error: `step_cycle: "${request.name}" reaches itself through ${cycle.join(' -> ')}`,
226
- };
224
+ // Every step must be chainable before any test case runs, and the
225
+ // composition must not reach itself, through any nesting.
226
+ const refused = this.composeRefusal(request.name, request.implementation);
227
+ if (refused) {
228
+ return { success: false, error: refused };
227
229
  }
228
230
  // The test steps run as the forging caller, so they meet the checks the
229
231
  // caller's direct calls meet; a host that builds the engine itself and
@@ -252,7 +254,13 @@ export class EmergentCapabilityEngine {
252
254
  if (details?.code === 'dry_run_needs_output') {
253
255
  return { success: false, error: result.error };
254
256
  }
255
- if (details?.code === 'permission_denied' && !context.caller) {
257
+ // Refused a capability by the permission manager (permission_denied),
258
+ // or by the executor's own check, which names what is missing and
259
+ // carries no code (a manager that does not check capabilities lets
260
+ // the call through to it).
261
+ const missing = details?.missingCapabilities;
262
+ const capabilityRefused = details?.code === 'permission_denied' || (Array.isArray(missing) && missing.length > 0);
263
+ if (capabilityRefused && !context.caller) {
256
264
  // A step needs a capability the stand-in context does not carry:
257
265
  // the test says nothing about the tool, so the forge asks for the
258
266
  // caller instead of recording a failed test.
@@ -340,6 +348,16 @@ export class EmergentCapabilityEngine {
340
348
  const verdict = await this.judge.reviewCreation(candidate);
341
349
  // Step 5: Register if approved.
342
350
  if (verdict.approved) {
351
+ if (request.implementation.mode === 'compose') {
352
+ // The tests and the judge took time, and what the steps name may have
353
+ // changed meanwhile (another forge registered a composition that
354
+ // closes a cycle with this one, say): checked again before anything
355
+ // is registered.
356
+ const refused = this.composeRefusal(request.name, request.implementation);
357
+ if (refused) {
358
+ return { success: false, verdict, error: refused };
359
+ }
360
+ }
343
361
  const now = new Date().toISOString();
344
362
  const usageStats = {
345
363
  totalUses: 0,
@@ -364,7 +382,6 @@ export class EmergentCapabilityEngine {
364
382
  source: `forged by agent ${context.agentId} during session ${context.sessionId}`,
365
383
  };
366
384
  this.registry.register(tool, 'session');
367
- const registered = this.registry.generation(toolId);
368
385
  let written;
369
386
  try {
370
387
  written = await this.registry.setState(toolId, 'active', null, {
@@ -377,8 +394,11 @@ export class EmergentCapabilityEngine {
377
394
  // is re-derived from its source at the next load.
378
395
  console.warn(`[agentos:emergent] could not store the request of "${request.name}" (${toolId}):`, error instanceof Error ? error.message : error);
379
396
  }
380
- if (this.registry.generation(toolId) !== registered) {
381
- // Removed while it was being forged: nothing is registered.
397
+ if (!this.registry.get(toolId)) {
398
+ // Removed while it was being forged: nothing is registered. (Another
399
+ // change while the state was written, such as a load of the session
400
+ // that adopted the tool from its row, leaves it registered: the forge
401
+ // goes on with the object the registry holds.)
382
402
  return { success: false, error: 'the tool was removed while it was being forged' };
383
403
  }
384
404
  if (written && written.state === 'demoted' && written.reason === 'removed') {
@@ -434,6 +454,26 @@ export class EmergentCapabilityEngine {
434
454
  return { success: false, error: 'the tool was removed while it was being forged' };
435
455
  }
436
456
  }
457
+ if (request.implementation.mode === 'compose') {
458
+ // A composition registered between the check above and this one's own
459
+ // registration can close a cycle with it, and neither check saw the
460
+ // other: checked once more now that this one resolves by its name, and
461
+ // taken out again when it reaches itself.
462
+ const cycle = this.compositionCycle(request.name, request.implementation.steps);
463
+ if (cycle) {
464
+ const held = this.registry.get(toolId);
465
+ if (held) {
466
+ await this.dropExecutable(held);
467
+ }
468
+ this.registry.remove(toolId);
469
+ this.removeIndexedToolEverywhere(toolId);
470
+ return {
471
+ success: false,
472
+ verdict,
473
+ error: `step_cycle: "${request.name}" reaches itself through ${cycle.join(' -> ')}`,
474
+ };
475
+ }
476
+ }
437
477
  return {
438
478
  success: true,
439
479
  toolId,
@@ -473,6 +513,11 @@ export class EmergentCapabilityEngine {
473
513
  if (!tool) {
474
514
  return null;
475
515
  }
516
+ // A suspended or demoted tool is neither promoted nor suspended again
517
+ // here: the restriction in force stays, whoever set it.
518
+ if (!this.registry.isActive(toolId)) {
519
+ return null;
520
+ }
476
521
  // A tool that no longer fits what is in force is suspended, not promoted.
477
522
  const refusal = this.refusalFor(tool.implementation, tool.name);
478
523
  if (refusal) {
@@ -496,6 +541,14 @@ export class EmergentCapabilityEngine {
496
541
  // Submit to the promotion panel.
497
542
  const promotionVerdict = await this.judge.reviewPromotion(tool);
498
543
  tool.judgeVerdicts.push(promotionVerdict);
544
+ // Suspended, demoted or removed while the panel reviewed it: not promoted.
545
+ if (this.registry.get(toolId) !== tool || !this.registry.isActive(toolId)) {
546
+ return {
547
+ success: false,
548
+ verdict: promotionVerdict,
549
+ error: 'The tool was suspended, demoted or removed during its review and was not promoted.',
550
+ };
551
+ }
499
552
  if (promotionVerdict.approved) {
500
553
  await this.registry.promote(toolId, 'agent');
501
554
  const promotedTool = this.registry.get(toolId);
@@ -555,14 +608,20 @@ export class EmergentCapabilityEngine {
555
608
  * Clean up all session tools for a given session.
556
609
  *
557
610
  * Delegates to the registry's `EmergentToolRegistry.cleanupSession()`
558
- * method and clears the local session index.
611
+ * method and clears the local session index. A tool forged in the session
612
+ * and promoted out of it since (now at the agent tier) is not the
613
+ * session's any more: it stays held, registered and indexed under its
614
+ * agent.
559
615
  *
560
616
  * @param sessionId - The session identifier to clean up.
617
+ * @returns the tools the cleanup removed.
561
618
  */
562
619
  cleanupSession(sessionId) {
563
- const removedTools = this.getSessionTools(sessionId);
620
+ const indexed = this.getSessionTools(sessionId);
564
621
  this.registry.cleanupSession(sessionId);
565
622
  this.index.bySession.delete(sessionId);
623
+ // Only the tools the registry removed go; a promoted tool is still held.
624
+ const removedTools = indexed.filter((tool) => !this.registry.get(tool.id));
566
625
  for (const tool of removedTools) {
567
626
  // The agent index too, so a lookup by agent never names a tool that is gone.
568
627
  this.removeIndexedToolEverywhere(tool.id);
@@ -836,6 +895,12 @@ export class EmergentCapabilityEngine {
836
895
  }
837
896
  const tool = this.registry.get(toolId);
838
897
  if (!tool) {
898
+ // Neither a row nor a tool: a state held for it here (a stored
899
+ // suspension another process has since removed) is let go, so no
900
+ // later registration re-checks it.
901
+ if (this.registry.getState(toolId)) {
902
+ this.registry.forget(toolId);
903
+ }
839
904
  return undefined;
840
905
  }
841
906
  const held = this.registry.getState(toolId);
@@ -1085,8 +1150,10 @@ export class EmergentCapabilityEngine {
1085
1150
  }
1086
1151
  }
1087
1152
  else {
1088
- // The row already says so; this process holds it too when the tool is live here.
1089
- this.holdStored(toolId, stored);
1153
+ // The row already says so; this process holds it too. A row that
1154
+ // holds no request it can read is held with the one derived from its
1155
+ // source, so a registration of a step tool it names finds it.
1156
+ this.holdStored(toolId, stored.request ? stored : { ...stored, request });
1090
1157
  }
1091
1158
  await this.unregisterIfLive(toolId);
1092
1159
  return { toolId, name, state: 'suspended', reason };
@@ -1126,9 +1193,10 @@ export class EmergentCapabilityEngine {
1126
1193
  }
1127
1194
  // A suspension or demotion that arrived while the row was being written,
1128
1195
  // in this process or in another, is the newer word: the tool is not
1129
- // registered. A restriction this process holds from an earlier read is
1130
- // older than the row and gives way to it.
1131
- const held = written && written.state !== 'active' ? written : this.newerRestrictionHeld(toolId, stored);
1196
+ // registered. A restriction this process holds from an earlier read, or
1197
+ // whose write has settled (or failed) before this read, is older than the
1198
+ // row and gives way to it.
1199
+ const held = written && written.state !== 'active' ? written : this.newerRestrictionHeld(toolId, readAt);
1132
1200
  if (held && held.state !== 'active') {
1133
1201
  this.holdStored(toolId, held);
1134
1202
  await this.unregisterIfLive(toolId);
@@ -1257,6 +1325,21 @@ export class EmergentCapabilityEngine {
1257
1325
  console.warn(`[agentos:emergent] could not take out the executable of "${tool.name}" (${tool.id}):`, error instanceof Error ? error.message : error);
1258
1326
  }
1259
1327
  }
1328
+ /**
1329
+ * The forge's refusal of a composition under what is registered now: a step
1330
+ * that may not be chained, or a chain that reaches the composition itself,
1331
+ * with the step or the path named; `null` when it may be forged.
1332
+ */
1333
+ composeRefusal(name, implementation) {
1334
+ for (const step of implementation.steps) {
1335
+ const verdict = this.composableBuilder.check(step.tool);
1336
+ if (!verdict.ok) {
1337
+ return `${verdict.code}: step "${step.name}" (tool "${step.tool}"): ${verdict.message}`;
1338
+ }
1339
+ }
1340
+ const cycle = this.compositionCycle(name, implementation.steps);
1341
+ return cycle ? `step_cycle: "${name}" reaches itself through ${cycle.join(' -> ')}` : null;
1342
+ }
1260
1343
  /**
1261
1344
  * The library's reason for not running an implementation under the
1262
1345
  * configuration in force, or `null`. Later steps add their checks here, so
@@ -1325,16 +1408,42 @@ export class EmergentCapabilityEngine {
1325
1408
  /**
1326
1409
  * A suspension the library sets from a run or a promotion check: written as
1327
1410
  * the library's (so a later load, or a registration of the missing step
1328
- * tool, re-checks it), held here, and the executable taken out.
1411
+ * tool, re-checks it), held here, and the executable taken out. It gives
1412
+ * way to the host's word: when this process holds a host's suspension or a
1413
+ * demotion nothing is written, and a row another process restricted that
1414
+ * way is left as it is and held here (`yieldToHost`), so the library never
1415
+ * turns a host's restriction into one of its own that a re-check lifts.
1416
+ *
1417
+ * It takes its turn with the tool's admissions (`serializeAdmission`): a
1418
+ * re-check that a registration starts while the suspension is written runs
1419
+ * after it, reads the row it leaves and lifts it when the step fits again,
1420
+ * instead of reading the row from before it and holding the suspension
1421
+ * whose write was still under way.
1422
+ *
1423
+ * @returns whether the library's suspension is what holds now.
1329
1424
  */
1330
- async suspendAsLibrary(toolId, reason) {
1331
- try {
1332
- await this.registry.setState(toolId, 'suspended', reason, { setBy: 'library' });
1333
- }
1334
- catch (error) {
1335
- console.warn(`[agentos:emergent] could not store the suspension of "${toolId}" (${reason}):`, error instanceof Error ? error.message : error);
1425
+ suspendAsLibrary(toolId, reason) {
1426
+ return this.serializeAdmission(toolId, () => this.suspendAsLibraryNow(toolId, reason));
1427
+ }
1428
+ async suspendAsLibraryNow(toolId, reason) {
1429
+ const held = this.registry.getState(toolId);
1430
+ let suspended = false;
1431
+ if (!held || !isHostRestriction(held)) {
1432
+ try {
1433
+ const inForce = await this.registry.setState(toolId, 'suspended', reason, {
1434
+ setBy: 'library',
1435
+ yieldToHost: true,
1436
+ });
1437
+ suspended = inForce.state === 'suspended' && inForce.setBy === 'library';
1438
+ }
1439
+ catch (error) {
1440
+ // Held here even though the row did not take it.
1441
+ suspended = true;
1442
+ console.warn(`[agentos:emergent] could not store the suspension of "${toolId}" (${reason}):`, error instanceof Error ? error.message : error);
1443
+ }
1336
1444
  }
1337
1445
  await this.unregisterIfLive(toolId);
1446
+ return suspended;
1338
1447
  }
1339
1448
  async unregisterIfLive(toolId) {
1340
1449
  const live = this.registry.get(toolId);
@@ -1343,17 +1452,21 @@ export class EmergentCapabilityEngine {
1343
1452
  }
1344
1453
  }
1345
1454
  /**
1346
- * A restriction this process holds that is newer than the row it just read:
1347
- * its write is in flight, so the row does not yet show it.
1455
+ * A restriction this process holds that the row read from `readAt` on may
1456
+ * not show: one requested here whose write is still queued or running, or
1457
+ * settled after the read began, or a host's whose write failed (it stays
1458
+ * in force here until the host reactivates the tool). Decided by the
1459
+ * registry's record of its own writes, not by timestamps, so a contended
1460
+ * hold, a library suspension whose write failed and a record taken from an
1461
+ * earlier row read give way to the row, and so does a restriction another
1462
+ * process lifted after it, whatever the processes' clocks say.
1348
1463
  */
1349
- newerRestrictionHeld(toolId, stored) {
1464
+ newerRestrictionHeld(toolId, readAt) {
1350
1465
  const memory = this.registry.getState(toolId);
1351
1466
  if (!memory || memory.state === 'active') {
1352
1467
  return undefined;
1353
1468
  }
1354
- // At the row's own time the restriction is the later of the two: two
1355
- // writes in one millisecond are told apart by nothing else.
1356
- return !stored || memory.at >= stored.at ? memory : undefined;
1469
+ return this.registry.restrictionUnread(toolId, readAt) ? memory : undefined;
1357
1470
  }
1358
1471
  /** A stored restriction, held in this process too when the tool is live here. */
1359
1472
  holdStored(toolId, record) {
@@ -1361,6 +1474,12 @@ export class EmergentCapabilityEngine {
1361
1474
  if (live) {
1362
1475
  this.registry.adopt(live, record);
1363
1476
  }
1477
+ else if (record.state !== 'active') {
1478
+ // Held without a tool: a stored step suspension must reach
1479
+ // onHostToolRegistered, which walks the held states, on every start
1480
+ // and in every process that reads it, not only where it was written.
1481
+ this.registry.holdState(record);
1482
+ }
1364
1483
  }
1365
1484
  // --------------------------------------------------------------------------
1366
1485
  // PUBLIC: createSelfImprovementTools
@@ -1530,8 +1649,28 @@ export class EmergentCapabilityEngine {
1530
1649
  error: `Emergent tool "${tool.name}" belongs to agent ${owner}; it is not callable as ${caller}.`,
1531
1650
  };
1532
1651
  }
1652
+ // A composition already running further up this call reaches itself:
1653
+ // the call is refused before any step runs, and this composition is
1654
+ // suspended for the cycle. A long chain without a cycle is refused at
1655
+ // the depth limit (nesting_too_deep) and suspends nothing.
1656
+ let runContext = context;
1657
+ if (tool.implementation.mode === 'compose') {
1658
+ const chain = compositionChain(context);
1659
+ if (chain.includes(tool.id)) {
1660
+ await this.suspendAsLibrary(tool.id, 'step_cycle');
1661
+ return {
1662
+ success: false,
1663
+ error: `step_cycle: "${tool.name}" reaches itself at run time; it was suspended`,
1664
+ details: { code: 'step_cycle' },
1665
+ };
1666
+ }
1667
+ runContext = {
1668
+ ...context,
1669
+ sessionData: { ...(context.sessionData ?? {}), emergentChain: [...chain, tool.id] },
1670
+ };
1671
+ }
1533
1672
  const startTime = performance.now();
1534
- const result = await baseTool.execute(args, context);
1673
+ const result = await baseTool.execute(args, runContext);
1535
1674
  const executionTimeMs = Math.round(performance.now() - startTime);
1536
1675
  // A step that can no longer be chained (its tool was removed or
1537
1676
  // replaced, or the chain reaches itself) suspends the composition
@@ -1539,17 +1678,20 @@ export class EmergentCapabilityEngine {
1539
1678
  const refused = result.details?.code;
1540
1679
  const suspendFor = !result.success && refused ? RUN_REFUSAL_REASONS[refused] : undefined;
1541
1680
  if (suspendFor) {
1542
- await this.suspendAsLibrary(tool.id, suspendFor);
1543
- if (refused === 'step_replaced') {
1681
+ const suspended = await this.suspendAsLibrary(tool.id, suspendFor);
1682
+ const implementation = this.registry.get(tool.id)?.implementation ?? tool.implementation;
1683
+ if (suspended && (refused === 'step_replaced' || this.refusalFor(implementation, tool.name) === null)) {
1544
1684
  // The step's tool changed hands between its check and its run (the
1545
- // gate's refusal; nothing ran). The registration that swapped it ran
1546
- // before this suspension existed, so it did not re-check this
1547
- // composition: check it now against the tool that holds the name.
1685
+ // gate's refusal; nothing ran), or a fitting tool was registered
1686
+ // before this suspension was held (it may have waited for an
1687
+ // admission of this tool). The registration ran before the
1688
+ // suspension existed, so it did not re-check this composition:
1689
+ // check it now against the tools registered now.
1548
1690
  try {
1549
1691
  await this.recheck(tool.id, false);
1550
1692
  }
1551
1693
  catch (recheckError) {
1552
- console.warn(`[agentos:emergent] could not re-check "${tool.name}" (${tool.id}) after its step was replaced:`, recheckError instanceof Error ? recheckError.message : recheckError);
1694
+ console.warn(`[agentos:emergent] could not re-check "${tool.name}" (${tool.id}) after its step was refused:`, recheckError instanceof Error ? recheckError.message : recheckError);
1553
1695
  }
1554
1696
  }
1555
1697
  return {