@animalabs/agent-framework 0.22.0 → 0.22.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 +11 -4
- package/dist/src/agent.d.ts.map +1 -1
- package/dist/src/agent.js +3 -1
- package/dist/src/agent.js.map +1 -1
- package/dist/src/api/server.d.ts.map +1 -1
- package/dist/src/api/server.js +41 -4
- package/dist/src/api/server.js.map +1 -1
- package/dist/src/framework.d.ts +319 -20
- package/dist/src/framework.d.ts.map +1 -1
- package/dist/src/framework.js +1500 -182
- package/dist/src/framework.js.map +1 -1
- package/dist/src/index.d.ts +2 -2
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js.map +1 -1
- package/dist/src/mcpl/index.d.ts +2 -0
- package/dist/src/mcpl/index.d.ts.map +1 -1
- package/dist/src/mcpl/index.js.map +1 -1
- package/dist/src/mcpl/reference-fetcher.d.ts +2 -1
- package/dist/src/mcpl/reference-fetcher.d.ts.map +1 -1
- package/dist/src/mcpl/reference-fetcher.js +20 -9
- package/dist/src/mcpl/reference-fetcher.js.map +1 -1
- package/dist/src/mcpl/references.d.ts +29 -6
- package/dist/src/mcpl/references.d.ts.map +1 -1
- package/dist/src/mcpl/references.js +57 -16
- package/dist/src/mcpl/references.js.map +1 -1
- package/dist/src/mcpl/server-connection.d.ts +28 -1
- package/dist/src/mcpl/server-connection.d.ts.map +1 -1
- package/dist/src/mcpl/server-connection.js +32 -4
- package/dist/src/mcpl/server-connection.js.map +1 -1
- package/dist/src/module-registry.d.ts +9 -3
- package/dist/src/module-registry.d.ts.map +1 -1
- package/dist/src/module-registry.js +3 -2
- package/dist/src/module-registry.js.map +1 -1
- package/dist/src/modules/workspace/index.d.ts.map +1 -1
- package/dist/src/modules/workspace/index.js +46 -4
- package/dist/src/modules/workspace/index.js.map +1 -1
- package/dist/src/modules/workspace/observe.d.ts +13 -3
- package/dist/src/modules/workspace/observe.d.ts.map +1 -1
- package/dist/src/modules/workspace/observe.js +24 -4
- package/dist/src/modules/workspace/observe.js.map +1 -1
- package/dist/src/modules/workspace/reconcile.d.ts +14 -0
- package/dist/src/modules/workspace/reconcile.d.ts.map +1 -1
- package/dist/src/modules/workspace/reconcile.js +10 -2
- package/dist/src/modules/workspace/reconcile.js.map +1 -1
- package/dist/src/operator-log.d.ts +41 -0
- package/dist/src/operator-log.d.ts.map +1 -1
- package/dist/src/operator-log.js.map +1 -1
- package/dist/src/provider-waits.d.ts +216 -0
- package/dist/src/provider-waits.d.ts.map +1 -0
- package/dist/src/provider-waits.js +482 -0
- package/dist/src/provider-waits.js.map +1 -0
- package/dist/src/refusal-reactions.d.ts +14 -12
- package/dist/src/refusal-reactions.d.ts.map +1 -1
- package/dist/src/refusal-reactions.js +14 -12
- package/dist/src/refusal-reactions.js.map +1 -1
- package/dist/src/tool-result-guard.d.ts +30 -13
- package/dist/src/tool-result-guard.d.ts.map +1 -1
- package/dist/src/tool-result-guard.js +71 -25
- package/dist/src/tool-result-guard.js.map +1 -1
- package/dist/src/types/events.d.ts +12 -0
- package/dist/src/types/events.d.ts.map +1 -1
- package/dist/src/types/module.d.ts +12 -4
- package/dist/src/types/module.d.ts.map +1 -1
- package/dist/src/types/trace.d.ts +14 -3
- package/dist/src/types/trace.d.ts.map +1 -1
- package/dist/test/discord-awareness-outbox.test.js +3 -0
- package/dist/test/discord-awareness-outbox.test.js.map +1 -1
- package/dist/test/explicit-prose-routing.test.js +0 -2
- package/dist/test/explicit-prose-routing.test.js.map +1 -1
- package/dist/test/framework.test.js +160 -1
- package/dist/test/framework.test.js.map +1 -1
- package/dist/test/helpers/coalescing-fixture.d.ts.map +1 -1
- package/dist/test/helpers/coalescing-fixture.js +3 -2
- package/dist/test/helpers/coalescing-fixture.js.map +1 -1
- package/dist/test/inference-exhaustion-rewind.test.js +142 -14
- package/dist/test/inference-exhaustion-rewind.test.js.map +1 -1
- package/dist/test/inference-failure-bounds.test.d.ts +2 -0
- package/dist/test/inference-failure-bounds.test.d.ts.map +1 -0
- package/dist/test/inference-failure-bounds.test.js +1201 -0
- package/dist/test/inference-failure-bounds.test.js.map +1 -0
- package/dist/test/late-events-after-stop.test.d.ts +2 -0
- package/dist/test/late-events-after-stop.test.d.ts.map +1 -0
- package/dist/test/late-events-after-stop.test.js +122 -0
- package/dist/test/late-events-after-stop.test.js.map +1 -0
- package/dist/test/mcpl-awareness-barrier.test.js +141 -0
- package/dist/test/mcpl-awareness-barrier.test.js.map +1 -1
- package/dist/test/mcpl-coalescing.test.js +78 -16
- package/dist/test/mcpl-coalescing.test.js.map +1 -1
- package/dist/test/mcpl-config-diagnostics.test.js +6 -3
- package/dist/test/mcpl-config-diagnostics.test.js.map +1 -1
- package/dist/test/mcpl-manifest-changed.test.js +2 -1
- package/dist/test/mcpl-manifest-changed.test.js.map +1 -1
- package/dist/test/mcpl-reference-fetcher.test.js +232 -4
- package/dist/test/mcpl-reference-fetcher.test.js.map +1 -1
- package/dist/test/mcpl-reference-fields.test.js +69 -2
- package/dist/test/mcpl-reference-fields.test.js.map +1 -1
- package/dist/test/mcpl-ws-transport.test.js +103 -0
- package/dist/test/mcpl-ws-transport.test.js.map +1 -1
- package/dist/test/ops-alert.test.js +2 -1
- package/dist/test/ops-alert.test.js.map +1 -1
- package/dist/test/placed-reaction-baseline.test.d.ts +2 -0
- package/dist/test/placed-reaction-baseline.test.d.ts.map +1 -0
- package/dist/test/placed-reaction-baseline.test.js +312 -0
- package/dist/test/placed-reaction-baseline.test.js.map +1 -0
- package/dist/test/provider-acceleration-cooldown.test.js +5 -1
- package/dist/test/provider-acceleration-cooldown.test.js.map +1 -1
- package/dist/test/provider-waits.test.d.ts +2 -0
- package/dist/test/provider-waits.test.d.ts.map +1 -0
- package/dist/test/provider-waits.test.js +2196 -0
- package/dist/test/provider-waits.test.js.map +1 -0
- package/dist/test/reaction-baseline-platform.test.d.ts +2 -0
- package/dist/test/reaction-baseline-platform.test.d.ts.map +1 -0
- package/dist/test/reaction-baseline-platform.test.js +124 -0
- package/dist/test/reaction-baseline-platform.test.js.map +1 -0
- package/dist/test/refusal-reaction-baseline.test.js +10 -3
- package/dist/test/refusal-reaction-baseline.test.js.map +1 -1
- package/dist/test/save-recent-image.test.js +138 -2
- package/dist/test/save-recent-image.test.js.map +1 -1
- package/dist/test/surgery-marks-receipt.test.d.ts +2 -0
- package/dist/test/surgery-marks-receipt.test.d.ts.map +1 -0
- package/dist/test/surgery-marks-receipt.test.js +540 -0
- package/dist/test/surgery-marks-receipt.test.js.map +1 -0
- package/dist/test/tool-result-guard.test.js +221 -7
- package/dist/test/tool-result-guard.test.js.map +1 -1
- package/dist/test/workspace-three-way.test.js +115 -0
- package/dist/test/workspace-three-way.test.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/agent.ts +4 -1
- package/src/api/server.ts +43 -4
- package/src/framework.ts +1538 -189
- package/src/index.ts +7 -2
- package/src/mcpl/index.ts +2 -0
- package/src/mcpl/reference-fetcher.ts +18 -8
- package/src/mcpl/references.ts +57 -13
- package/src/mcpl/server-connection.ts +55 -4
- package/src/module-registry.ts +17 -9
- package/src/modules/workspace/index.ts +44 -4
- package/src/modules/workspace/observe.ts +31 -5
- package/src/modules/workspace/reconcile.ts +23 -2
- package/src/operator-log.ts +30 -0
- package/src/provider-waits.ts +523 -0
- package/src/refusal-reactions.ts +14 -12
- package/src/tool-result-guard.ts +72 -24
- package/src/types/events.ts +12 -0
- package/src/types/module.ts +12 -4
- package/src/types/trace.ts +14 -3
package/package.json
CHANGED
package/src/agent.ts
CHANGED
|
@@ -667,7 +667,10 @@ export class Agent {
|
|
|
667
667
|
const wireResults = content.flatMap((block) => block.type === 'tool_result'
|
|
668
668
|
// buildToolResultMessages serializes every payload to a string.
|
|
669
669
|
? [{ toolUseId: block.toolUseId, content: block.content as string, isError: block.isError }] : []);
|
|
670
|
-
|
|
670
|
+
// Stored under the house default cap (buildToolResultMessages), as what a
|
|
671
|
+
// stub keeps is too.
|
|
672
|
+
this.toolResultGuard.storeResults(content, wireResults, this._state.toolResults, undefined,
|
|
673
|
+
DEFAULT_TOOL_RESULT_INLINE_MAX_CHARS);
|
|
671
674
|
}
|
|
672
675
|
|
|
673
676
|
// Compile the context (with optional injections) into a request. The
|
package/src/api/server.ts
CHANGED
|
@@ -12,6 +12,7 @@ import { timingSafeEqual } from 'node:crypto';
|
|
|
12
12
|
import type { ContentBlock } from '@animalabs/membrane';
|
|
13
13
|
import type { AgentFramework } from '../framework.js';
|
|
14
14
|
import { ResumeBlockedError } from '../framework.js';
|
|
15
|
+
import { isReleaseModel } from '../provider-waits.js';
|
|
15
16
|
import type { TraceEvent, ProcessEvent } from '../types/index.js';
|
|
16
17
|
import type {
|
|
17
18
|
ApiServerConfig,
|
|
@@ -420,6 +421,37 @@ export class ApiServer {
|
|
|
420
421
|
case 'host.maintenanceTick':
|
|
421
422
|
this.requireAdminToken(params);
|
|
422
423
|
return this.framework.maintenanceTick();
|
|
424
|
+
// A provider's stated retry-after is honoured across restarts; this is
|
|
425
|
+
// the explicit operator override (recorded, so a restart keeps it).
|
|
426
|
+
case 'host.releaseProviderWait': {
|
|
427
|
+
this.requireAdminToken(params);
|
|
428
|
+
const p = (params ?? {}) as { agentName?: unknown; model?: unknown; requester?: unknown };
|
|
429
|
+
if (typeof p.agentName !== 'string' || p.agentName === '') throw new Error('agentName is required');
|
|
430
|
+
// Only an omitted model, or '*', releases every model: a malformed one
|
|
431
|
+
// is refused before anything changes, never widened.
|
|
432
|
+
const model = p.model;
|
|
433
|
+
if (!isReleaseModel(model)) throw new Error("model must be a model name, or '*' (or omitted) for every model");
|
|
434
|
+
// A requester over this surface names itself, so the record says
|
|
435
|
+
// where the name came from ('api:<name>'), and it can't pass for a
|
|
436
|
+
// host command's requester.
|
|
437
|
+
return {
|
|
438
|
+
released: this.framework.releaseProviderWait(
|
|
439
|
+
p.agentName,
|
|
440
|
+
model,
|
|
441
|
+
typeof p.requester === 'string' && p.requester !== '' ? `api:${p.requester}` : 'api',
|
|
442
|
+
),
|
|
443
|
+
};
|
|
444
|
+
}
|
|
445
|
+
// A read, like host.status: the admin token gates the verbs that change
|
|
446
|
+
// something. (The HTTP /hostmode read takes it because that response is
|
|
447
|
+
// readable cross-origin; this surface checks the origin.)
|
|
448
|
+
case 'host.providerWaits': {
|
|
449
|
+
const agentName = params?.agentName;
|
|
450
|
+
if (agentName !== undefined && typeof agentName !== 'string') {
|
|
451
|
+
throw new Error('agentName must be an agent name, or omitted for every agent');
|
|
452
|
+
}
|
|
453
|
+
return { waits: this.framework.providerWaitSnapshot(agentName) };
|
|
454
|
+
}
|
|
423
455
|
|
|
424
456
|
default:
|
|
425
457
|
throw new Error(`Unknown command: ${command}`);
|
|
@@ -543,8 +575,13 @@ export class ApiServer {
|
|
|
543
575
|
this.currentBranch = params.name;
|
|
544
576
|
|
|
545
577
|
// Reversible Discord awareness markers are part of the branch projection.
|
|
546
|
-
//
|
|
547
|
-
|
|
578
|
+
// The switch is acknowledged once it has landed: delivery of the marks it
|
|
579
|
+
// adds and removes starts behind the MCPL data-plane gate, which holds
|
|
580
|
+
// channel traffic that arrives after it until they are attempted, or
|
|
581
|
+
// deferred while their server is disconnected, and a failure is an ops
|
|
582
|
+
// alert rather than a failed switch. (It used to await the awareness
|
|
583
|
+
// sync, which after a large rollback took the drain's whole length.)
|
|
584
|
+
this.framework.startDiscordAwarenessDelivery('branch switch');
|
|
548
585
|
|
|
549
586
|
// Materialize config files from the new branch
|
|
550
587
|
const ws = this.framework.getModule('workspace');
|
|
@@ -598,7 +635,8 @@ export class ApiServer {
|
|
|
598
635
|
|
|
599
636
|
if (result.undone) {
|
|
600
637
|
this.currentBranch = result.toBranch!;
|
|
601
|
-
|
|
638
|
+
// Marks follow behind the data-plane gate; the undo doesn't wait for Discord.
|
|
639
|
+
this.framework.startDiscordAwarenessDelivery('undo', params.agentName);
|
|
602
640
|
this.broadcast('branch:switched', {
|
|
603
641
|
from: result.fromBranch,
|
|
604
642
|
to: result.toBranch,
|
|
@@ -618,7 +656,8 @@ export class ApiServer {
|
|
|
618
656
|
|
|
619
657
|
if (result.redone) {
|
|
620
658
|
this.currentBranch = result.toBranch!;
|
|
621
|
-
|
|
659
|
+
// Marks follow behind the data-plane gate; the redo doesn't wait for Discord.
|
|
660
|
+
this.framework.startDiscordAwarenessDelivery('redo', params.agentName);
|
|
622
661
|
this.broadcast('branch:switched', {
|
|
623
662
|
from: result.fromBranch,
|
|
624
663
|
to: result.toBranch,
|