@tangle-network/agent-runtime 0.7.0 → 0.9.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 +42 -13
- package/dist/index.d.ts +235 -35
- package/dist/index.js +282 -3
- package/dist/index.js.map +1 -1
- package/dist/platform.d.ts +197 -0
- package/dist/platform.js +185 -0
- package/dist/platform.js.map +1 -0
- package/package.json +11 -3
- package/docs/domain-agent-runtime-integration-issues.md +0 -165
- package/docs/product-runtime-kernel.md +0 -326
package/README.md
CHANGED
|
@@ -15,8 +15,8 @@ pnpm add @tangle-network/agent-runtime @tangle-network/agent-eval
|
|
|
15
15
|
|---|---|
|
|
16
16
|
| `runAgentTask` | Single-shot adapter-driven task with eval/verification |
|
|
17
17
|
| `runAgentTaskStream` | Streaming product loop with session resume + backends |
|
|
18
|
-
| `startRuntimeRun` | Canonical production-run row + cost ledger
|
|
19
|
-
| `createTraceBridge` | Map `RuntimeStreamEvent` → `agent-eval` `TraceEvent`
|
|
18
|
+
| `startRuntimeRun` | Canonical production-run row + cost ledger |
|
|
19
|
+
| `createTraceBridge` | Map `RuntimeStreamEvent` → `agent-eval` `TraceEvent` |
|
|
20
20
|
| `decideKnowledgeReadiness` | `ready` / `blocked` / `caveat` branch for routes / UI |
|
|
21
21
|
| `createOpenAICompatibleBackend` | OpenAI-compatible streaming backend (TCloud / cli-bridge) |
|
|
22
22
|
| `createSandboxPromptBackend` | Sandbox / sidecar `streamPrompt` clients |
|
|
@@ -50,13 +50,11 @@ const result = await runAgentTask({
|
|
|
50
50
|
console.log(result.status, result.runRecords)
|
|
51
51
|
```
|
|
52
52
|
|
|
53
|
-
## Canonical production-run lifecycle
|
|
53
|
+
## Canonical production-run lifecycle
|
|
54
54
|
|
|
55
|
-
`startRuntimeRun`
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
`completeProductionAgentRun` + `persistRuntimeRun` pair is the canonical
|
|
59
|
-
example of what this subsumes).
|
|
55
|
+
`startRuntimeRun` records what the agent did on behalf of a customer,
|
|
56
|
+
what it cost, and how it ended. Replaces bespoke `agentRuns`-row helpers
|
|
57
|
+
across consumer repos with a single contract.
|
|
60
58
|
|
|
61
59
|
```ts
|
|
62
60
|
import { startRuntimeRun, runAgentTaskStream } from '@tangle-network/agent-runtime'
|
|
@@ -87,11 +85,11 @@ console.log(run.cost()) // { tokensIn, tokensOut, costUsd, wallMs, llmCalls }
|
|
|
87
85
|
|
|
88
86
|
Full runnable: [`examples/runtime-run/`](./examples/runtime-run/).
|
|
89
87
|
|
|
90
|
-
## agent-eval trace bridge
|
|
88
|
+
## agent-eval trace bridge
|
|
91
89
|
|
|
92
|
-
If you persist traces in agent-eval's `TraceStore`,
|
|
93
|
-
events to `TraceEvent`
|
|
94
|
-
|
|
90
|
+
If you persist traces in agent-eval's `TraceStore`, the bridge maps
|
|
91
|
+
runtime stream events to `TraceEvent` so consumer repos don't hand-roll
|
|
92
|
+
the adapter:
|
|
95
93
|
|
|
96
94
|
```ts
|
|
97
95
|
import { createTraceBridge } from '@tangle-network/agent-runtime'
|
|
@@ -146,10 +144,41 @@ details. Private diagnostics opt-in via `RuntimeTelemetryOptions`.
|
|
|
146
144
|
| Package | Owns |
|
|
147
145
|
|---|---|
|
|
148
146
|
| `agent-runtime` | Lifecycle, adapters, backends, `RuntimeRunHandle`, trace bridge |
|
|
147
|
+
| `agent-runtime/platform` | Server-side clients for the Tangle platform: cross-site SSO (`PlatformAuthClient`) and integrations hub (`PlatformHubClient`) |
|
|
149
148
|
| `agent-eval` | Control loops, readiness scoring, traces, evals, failure classes, release evidence |
|
|
150
149
|
| `agent-knowledge` | Evidence, claims, wiki pages, retrieval, knowledge bundle builders |
|
|
151
150
|
| Domain packages | Domain tools, policies, credentials, UI text, rubrics |
|
|
152
151
|
|
|
152
|
+
### `agent-runtime/platform` — Login with Tangle + integrations hub
|
|
153
|
+
|
|
154
|
+
```ts
|
|
155
|
+
import {
|
|
156
|
+
PlatformAuthClient,
|
|
157
|
+
PlatformHubClient,
|
|
158
|
+
} from '@tangle-network/agent-runtime/platform'
|
|
159
|
+
|
|
160
|
+
// Login with Tangle (cross-site SSO bridge).
|
|
161
|
+
const auth = new PlatformAuthClient({
|
|
162
|
+
baseUrl: process.env.TANGLE_PLATFORM_URL!, // https://id.tangle.tools
|
|
163
|
+
appId: 'gtm-agent', // must be registered in TRUSTED_APPS
|
|
164
|
+
})
|
|
165
|
+
const url = auth.authorizeUrl({ state: csrfToken, redirectUri: callbackUrl })
|
|
166
|
+
// …user redirected to `url`, returns to callbackUrl with ?code=…
|
|
167
|
+
const { apiKey, user } = await auth.exchange(code)
|
|
168
|
+
|
|
169
|
+
// Integrations hub (uses the user's apiKey from cross-site exchange).
|
|
170
|
+
const hub = new PlatformHubClient({
|
|
171
|
+
baseUrl: process.env.TANGLE_PLATFORM_URL!,
|
|
172
|
+
bearer: apiKey,
|
|
173
|
+
})
|
|
174
|
+
const connections = await hub.listConnections()
|
|
175
|
+
const { authorizationUrl } = await hub.startAuth({
|
|
176
|
+
providerId: 'google',
|
|
177
|
+
connectorId: 'gmail',
|
|
178
|
+
returnUrl: 'https://gtm.tangle.tools/integrations',
|
|
179
|
+
})
|
|
180
|
+
```
|
|
181
|
+
|
|
153
182
|
The API uses `runAgentTask`, not `runVerticalAgentTask`. `domain` is
|
|
154
183
|
metadata on the task because the runtime is reusable across many kinds of
|
|
155
184
|
agents without baking taxonomy into type names.
|
|
@@ -165,4 +194,4 @@ Runnable in [`examples/`](./examples/):
|
|
|
165
194
|
- [`sse-stream/`](./examples/sse-stream/) — Server-Sent Events for browser clients
|
|
166
195
|
- [`sandbox-stream-backend/`](./examples/sandbox-stream-backend/) — `createSandboxPromptBackend`
|
|
167
196
|
- [`openai-stream-backend/`](./examples/openai-stream-backend/) — `createOpenAICompatibleBackend`
|
|
168
|
-
- [`runtime-run/`](./examples/runtime-run/) — `startRuntimeRun` + cost ledger + persistence adapter
|
|
197
|
+
- [`runtime-run/`](./examples/runtime-run/) — `startRuntimeRun` + cost ledger + persistence adapter
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { ControlEvalResult, KnowledgeRequirement, ControlBudget, KnowledgeReadinessReport, ControlStep, ControlDecision, UserQuestion, DataAcquisitionPlan, ControlRunResult, RunRecord, TraceStore, AgentEvalError, TraceEvent } from '@tangle-network/agent-eval';
|
|
2
2
|
export { AgentEvalError, AgentEvalErrorCode, CaptureIntegrityError, ConfigError, ControlBudget, ControlDecision, ControlEvalResult, ControlRunResult, ControlStep, DataAcquisitionPlan, JudgeError, KnowledgeReadinessReport, KnowledgeRequirement, NotFoundError, ReplayError, RunRecord, UserQuestion, ValidationError, VerificationError } from '@tangle-network/agent-eval';
|
|
3
|
+
import { AgentProfilePrompt, AgentProfileResources, AgentSubagentProfile, AgentProfile, SandboxInstance } from '@tangle-network/sandbox';
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
6
|
* @stable
|
|
@@ -427,6 +428,105 @@ declare function createOpenAICompatibleBackend<TInput extends AgentBackendInput
|
|
|
427
428
|
fetchImpl?: typeof fetch;
|
|
428
429
|
}): AgentExecutionBackend<TInput>;
|
|
429
430
|
|
|
431
|
+
/**
|
|
432
|
+
* Send an AgentProfile to a sandbox runtime for one chat turn. Composes
|
|
433
|
+
* the per-turn overlay (user message, prior history, knowledge flags)
|
|
434
|
+
* via `mergeAgentProfiles`, POSTs the full profile to the runtime's
|
|
435
|
+
* `/runtime/agents/run/stream` endpoint, and yields `RuntimeStreamEvent`s
|
|
436
|
+
* from the SSE response. The full profile — subagents, MCP servers,
|
|
437
|
+
* permissions, file mounts — reaches the sandbox by construction.
|
|
438
|
+
*/
|
|
439
|
+
|
|
440
|
+
/** A message in the chat turn's prior context. Provider-neutral. */
|
|
441
|
+
interface ChatTurnMessage {
|
|
442
|
+
role: 'user' | 'assistant' | 'system';
|
|
443
|
+
content: string;
|
|
444
|
+
/** Optional metadata the consumer wants threaded through (timestamps, msg id, etc). */
|
|
445
|
+
metadata?: Record<string, unknown>;
|
|
446
|
+
}
|
|
447
|
+
/**
|
|
448
|
+
* Per-turn profile overlay. The caller's profile is the durable contract;
|
|
449
|
+
* the overlay carries volatile per-turn context (workspace facts, dynamic-
|
|
450
|
+
* advisor instructions, RAG hits) that the runtime should see but that
|
|
451
|
+
* doesn't belong in the canonical profile. Composed via `mergeAgentProfiles`.
|
|
452
|
+
*/
|
|
453
|
+
interface ChatTurnOverlay {
|
|
454
|
+
/** Volatile prompt additions: dynamic-advisor context, intake gate output, RAG citations. */
|
|
455
|
+
promptOverlay?: AgentProfilePrompt;
|
|
456
|
+
/** Per-turn additional file mounts (vault docs, recent uploads). */
|
|
457
|
+
resourcesOverlay?: AgentProfileResources;
|
|
458
|
+
/** Override or augment the subagent map for this turn (rare). */
|
|
459
|
+
subagentsOverlay?: Record<string, AgentSubagentProfile>;
|
|
460
|
+
/** Free-form metadata threaded into the runtime call. */
|
|
461
|
+
metadata?: Record<string, unknown>;
|
|
462
|
+
}
|
|
463
|
+
/**
|
|
464
|
+
* Sandbox runtime contract — the subset of `SandboxInstance` `runChatTurn`
|
|
465
|
+
* actually invokes. Defined as an interface so consumers can inject a
|
|
466
|
+
* stub in tests without standing up a real sandbox.
|
|
467
|
+
*/
|
|
468
|
+
interface ChatTurnSandbox {
|
|
469
|
+
/** Sandbox identifier used in the runtime URL. */
|
|
470
|
+
readonly id: string;
|
|
471
|
+
/** Base URL of the sandbox runtime, e.g. `https://sandbox.tangle.tools/v1/sandboxes/<id>`. */
|
|
472
|
+
readonly runtimeUrl: string;
|
|
473
|
+
/** Optional bearer for the runtime call (sidecar auth). */
|
|
474
|
+
readonly authHeader?: {
|
|
475
|
+
name: string;
|
|
476
|
+
value: string;
|
|
477
|
+
};
|
|
478
|
+
}
|
|
479
|
+
interface RunChatTurnOptions {
|
|
480
|
+
/** Canonical agent profile — the durable contract. */
|
|
481
|
+
profile: AgentProfile;
|
|
482
|
+
/** Volatile per-turn additions. */
|
|
483
|
+
overlay?: ChatTurnOverlay;
|
|
484
|
+
/** Current user message. */
|
|
485
|
+
message: string;
|
|
486
|
+
/** Prior conversation. */
|
|
487
|
+
priorMessages: readonly ChatTurnMessage[];
|
|
488
|
+
/** Sandbox the turn should run inside. */
|
|
489
|
+
sandbox: ChatTurnSandbox;
|
|
490
|
+
/** Override model for this turn (otherwise profile.model.default is used). */
|
|
491
|
+
modelOverride?: string;
|
|
492
|
+
/** AbortSignal for cancellation (timeouts, client disconnect, etc). */
|
|
493
|
+
signal?: AbortSignal;
|
|
494
|
+
/** Override fetch (for tests). */
|
|
495
|
+
fetch?: typeof fetch;
|
|
496
|
+
}
|
|
497
|
+
/**
|
|
498
|
+
* Compose the per-turn profile via `mergeAgentProfiles(profile, overlay)`,
|
|
499
|
+
* POST the FULL composed profile to the sandbox's runtime streaming endpoint,
|
|
500
|
+
* and yield parsed `RuntimeStreamEvent`s. The runtime resolves prompt,
|
|
501
|
+
* subagents, MCP servers, and permissions from the profile — callers do not
|
|
502
|
+
* hand-craft a `backend.profile` shape.
|
|
503
|
+
*
|
|
504
|
+
* for await (const event of runChatTurn({ profile, overlay, message, priorMessages, sandbox })) {
|
|
505
|
+
* // event.type === 'message' / 'tool_call' / 'task_complete' / etc.
|
|
506
|
+
* }
|
|
507
|
+
*/
|
|
508
|
+
declare function runChatTurn(options: RunChatTurnOptions): AsyncIterable<RuntimeStreamEvent>;
|
|
509
|
+
/**
|
|
510
|
+
* Compose the per-turn AgentProfile. Public-and-pure so consumers can
|
|
511
|
+
* preview/log/persist the composed shape without firing a runtime call.
|
|
512
|
+
*/
|
|
513
|
+
declare function composeTurnProfile(base: AgentProfile, overlay: ChatTurnOverlay): AgentProfile;
|
|
514
|
+
declare class ChatTurnError extends Error {
|
|
515
|
+
readonly status?: number | undefined;
|
|
516
|
+
constructor(message: string, status?: number | undefined);
|
|
517
|
+
}
|
|
518
|
+
/**
|
|
519
|
+
* Convenience: build a `ChatTurnSandbox` from a full `SandboxInstance`. Most
|
|
520
|
+
* callers already have one of these from `client.create()`. The runtime URL
|
|
521
|
+
* is derived from the instance's transport configuration.
|
|
522
|
+
*/
|
|
523
|
+
declare function sandboxAsChatTurnTarget(instance: SandboxInstance, opts?: {
|
|
524
|
+
authHeader?: {
|
|
525
|
+
name: string;
|
|
526
|
+
value: string;
|
|
527
|
+
};
|
|
528
|
+
}): ChatTurnSandbox;
|
|
529
|
+
|
|
430
530
|
/**
|
|
431
531
|
* @stable
|
|
432
532
|
*
|
|
@@ -492,6 +592,124 @@ declare class RuntimeRunStateError extends AgentEvalError {
|
|
|
492
592
|
});
|
|
493
593
|
}
|
|
494
594
|
|
|
595
|
+
/**
|
|
596
|
+
* Classify a user message against a profile's subagent map. Routes are
|
|
597
|
+
* declared on each `AgentSubagentProfile.metadata.matchers` (keywords +
|
|
598
|
+
* regex patterns); `classifyIntent` scores every subagent against the
|
|
599
|
+
* message and returns a typed result. Pure scoring — no LLM call. Caller
|
|
600
|
+
* decides whether the score is high enough to dispatch the subagent.
|
|
601
|
+
*/
|
|
602
|
+
|
|
603
|
+
/** Matcher shape attached to `subagent.metadata.matchers`. */
|
|
604
|
+
interface SubagentMatcher {
|
|
605
|
+
/** Literal keywords (case-insensitive substring match). +1 per match unless `weight` overrides. */
|
|
606
|
+
keywords?: readonly string[];
|
|
607
|
+
/** Regex patterns (case-insensitive). +`weight` per match (default 1.5). */
|
|
608
|
+
patterns?: readonly (string | RegExp)[];
|
|
609
|
+
/** Per-rule weight override. */
|
|
610
|
+
weight?: number;
|
|
611
|
+
/** Minimum score for this subagent to be considered "matched". Default 1. */
|
|
612
|
+
minScore?: number;
|
|
613
|
+
}
|
|
614
|
+
interface ClassifyIntentResult {
|
|
615
|
+
/** Best-scoring subagent id; null if no subagent crossed `minScore`. */
|
|
616
|
+
id: string | null;
|
|
617
|
+
/** Best subagent's `AgentSubagentProfile`; null if no match. */
|
|
618
|
+
subagent: AgentSubagentProfile | null;
|
|
619
|
+
/** Score of the chosen subagent. */
|
|
620
|
+
score: number;
|
|
621
|
+
/** All subagent scores keyed by id — useful for telemetry / debugging. */
|
|
622
|
+
scores: Record<string, number>;
|
|
623
|
+
/** The matchers checked, for debugging "why didn't X route?" */
|
|
624
|
+
evaluated: Record<string, {
|
|
625
|
+
keywordHits: number;
|
|
626
|
+
patternHits: number;
|
|
627
|
+
minScore: number;
|
|
628
|
+
}>;
|
|
629
|
+
}
|
|
630
|
+
interface ClassifyIntentOptions {
|
|
631
|
+
/** Override the global default `minScore` (used when a subagent omits its own). */
|
|
632
|
+
defaultMinScore?: number;
|
|
633
|
+
/** Subagent ids to skip (e.g. scaffold-only subagents with `metadata.status === 'scaffold'`). */
|
|
634
|
+
skip?: readonly string[];
|
|
635
|
+
/** Only consider subagents whose metadata predicate returns true (e.g. `m => m.status === 'full'`). */
|
|
636
|
+
filter?: (subagent: AgentSubagentProfile, id: string) => boolean;
|
|
637
|
+
}
|
|
638
|
+
/**
|
|
639
|
+
* Pure intent classifier.
|
|
640
|
+
*
|
|
641
|
+
* For each subagent in `profile.subagents`: read `metadata.matchers`,
|
|
642
|
+
* score keyword + pattern hits against the user message, return the
|
|
643
|
+
* highest-scoring subagent (or null if none crossed `minScore`). No LLM
|
|
644
|
+
* call, no side effects. The runtime decides what to do with the result.
|
|
645
|
+
*/
|
|
646
|
+
declare function classifyIntent(profile: AgentProfile, message: string, opts?: ClassifyIntentOptions): ClassifyIntentResult;
|
|
647
|
+
|
|
648
|
+
/**
|
|
649
|
+
* Validate an AgentProfile against canonical conformance rules: tool keys
|
|
650
|
+
* must map to an MCP server entry (not be shell capabilities masquerading
|
|
651
|
+
* as tools), subagents marked `metadata.status: 'scaffold'` must not be
|
|
652
|
+
* dispatchable, system prompts must be substantive. Pure — no I/O — so
|
|
653
|
+
* callers run it in a unit test or at module load to fail-fast on
|
|
654
|
+
* misconfiguration.
|
|
655
|
+
*/
|
|
656
|
+
|
|
657
|
+
interface ConformanceIssue {
|
|
658
|
+
severity: 'error' | 'warn';
|
|
659
|
+
/** Stable kebab-case code, useful for CI matching. */
|
|
660
|
+
code: string;
|
|
661
|
+
/** Profile path the issue is anchored to, e.g. `tools.bash` or `subagents.foo`. */
|
|
662
|
+
path: string;
|
|
663
|
+
/** Human-readable failure reason. */
|
|
664
|
+
message: string;
|
|
665
|
+
}
|
|
666
|
+
interface ConformanceResult {
|
|
667
|
+
valid: boolean;
|
|
668
|
+
errors: ConformanceIssue[];
|
|
669
|
+
warnings: ConformanceIssue[];
|
|
670
|
+
}
|
|
671
|
+
interface ConformanceOptions {
|
|
672
|
+
/**
|
|
673
|
+
* Shell-style capabilities that may appear in `permissions` but NEVER in
|
|
674
|
+
* `tools`. Declaring these as tools is decorative — the runtime doesn't
|
|
675
|
+
* dispatch them as MCP servers. Default covers the observed offenders.
|
|
676
|
+
*/
|
|
677
|
+
knownShellCapabilities?: readonly string[];
|
|
678
|
+
/**
|
|
679
|
+
* If true, treat `subagents[id].metadata.status === 'scaffold'` as an
|
|
680
|
+
* error rather than a warning. Default false — scaffolds are honest
|
|
681
|
+
* stubs as long as the router skips them.
|
|
682
|
+
*/
|
|
683
|
+
strictNoScaffolds?: boolean;
|
|
684
|
+
/**
|
|
685
|
+
* Names that may appear in `tools` without a corresponding MCP server or
|
|
686
|
+
* resource mount. Default empty — kills decorative-tool anti-pattern.
|
|
687
|
+
*/
|
|
688
|
+
toolsAllowedWithoutMcp?: readonly string[];
|
|
689
|
+
/**
|
|
690
|
+
* Minimum length of `prompt.systemPrompt`. Profiles below this are
|
|
691
|
+
* likely incomplete. Default 800 chars (rough lower bound for the
|
|
692
|
+
* partner-tier prompts the product agents target).
|
|
693
|
+
*/
|
|
694
|
+
minSystemPromptChars?: number;
|
|
695
|
+
}
|
|
696
|
+
/**
|
|
697
|
+
* Run all conformance checks against a profile. Designed to be called from
|
|
698
|
+
* a unit test:
|
|
699
|
+
*
|
|
700
|
+
* it('legalAgentProfile passes conformance', () => {
|
|
701
|
+
* const result = assertProfileConformance(legalAgentProfile, {
|
|
702
|
+
* toolsAllowedWithoutMcp: ['agent-knowledge:query'], // in-process function
|
|
703
|
+
* })
|
|
704
|
+
* expect(result.valid).toBe(true)
|
|
705
|
+
* expect(result.errors).toEqual([])
|
|
706
|
+
* })
|
|
707
|
+
*
|
|
708
|
+
* Issues carry `path` + `code` so tests can pinpoint failures rather than
|
|
709
|
+
* collapse to a generic "validation failed."
|
|
710
|
+
*/
|
|
711
|
+
declare function assertProfileConformance(profile: AgentProfile, opts?: ConformanceOptions): ConformanceResult;
|
|
712
|
+
|
|
495
713
|
/**
|
|
496
714
|
* @stable
|
|
497
715
|
*
|
|
@@ -534,34 +752,27 @@ declare function runAgentTaskStream<TInput extends AgentBackendInput = AgentBack
|
|
|
534
752
|
/**
|
|
535
753
|
* @stable
|
|
536
754
|
*
|
|
537
|
-
*
|
|
538
|
-
*
|
|
539
|
-
* ended." Consumer agents (legal, tax, gtm, creative, agent-builder) reach for
|
|
540
|
-
* `startRuntimeRun` instead of inventing their own `agentRuns`-row helpers.
|
|
755
|
+
* Production-run lifecycle: record what the agent did on behalf of a customer,
|
|
756
|
+
* what it cost, and how it ended.
|
|
541
757
|
*
|
|
542
758
|
* Three concerns live in this module:
|
|
543
759
|
*
|
|
544
760
|
* 1. **Lifecycle state machine** — `running` -> `completed | failed | cancelled`,
|
|
545
|
-
* enforced by `RuntimeRunStateError`. Completion is idempotent
|
|
546
|
-
* `complete()` call
|
|
547
|
-
*
|
|
548
|
-
*
|
|
761
|
+
* enforced by `RuntimeRunStateError`. Completion is idempotent for the same
|
|
762
|
+
* status (a second `complete()` call is a no-op so retries / cleanup paths
|
|
763
|
+
* don't double-fire side effects). A different terminal status is a state
|
|
764
|
+
* error.
|
|
549
765
|
*
|
|
550
766
|
* 2. **Cost ledger** — every `llm_call` event the handle observes contributes
|
|
551
767
|
* `tokensIn`, `tokensOut`, `costUsd`, and bumps `llmCalls`. Wall time is
|
|
552
768
|
* measured from `startRuntimeRun()` to `complete()`. Surface via
|
|
553
|
-
* `handle.cost()` for
|
|
769
|
+
* `handle.cost()` for cost-per-task dashboards.
|
|
554
770
|
*
|
|
555
771
|
* 3. **Persistence adapter** — `RuntimeRunPersistenceAdapter` is the seam
|
|
556
772
|
* consumers plug in to write a `RuntimeRunRow` to their D1 / postgres /
|
|
557
773
|
* KV store. The adapter receives a sanitized row shape; no telemetry
|
|
558
774
|
* payload bytes flow through it unless the consumer opts in via
|
|
559
775
|
* `RuntimeRunOptions.telemetryEvents`.
|
|
560
|
-
*
|
|
561
|
-
* The pattern replaces legal-agent's bespoke `completeProductionAgentRun` /
|
|
562
|
-
* `persistRuntimeRun` pair from `eval-evidence.ts` + `api.chat.ts`. Both are
|
|
563
|
-
* marked `@deprecated` in this release; consumers ditch them on their own
|
|
564
|
-
* version bumps.
|
|
565
776
|
*/
|
|
566
777
|
|
|
567
778
|
/** @stable */
|
|
@@ -770,16 +981,12 @@ declare function createRuntimeEventCollector<TState = unknown, TAction = unknown
|
|
|
770
981
|
/**
|
|
771
982
|
* @stable
|
|
772
983
|
*
|
|
773
|
-
* Streaming-event counterpart of `createRuntimeEventCollector`.
|
|
774
|
-
* `runAgentTaskStream`
|
|
775
|
-
*
|
|
776
|
-
*
|
|
777
|
-
*
|
|
778
|
-
*
|
|
779
|
-
* sessions, text/tool deltas) so this is a sibling factory rather than an
|
|
780
|
-
* overload of `createRuntimeEventCollector`; the unified-union alternative
|
|
781
|
-
* was rejected because dispatching on `type` alone would silently misroute
|
|
782
|
-
* events whose `type` literals overlap (`task_start`, `readiness_end`, etc.).
|
|
984
|
+
* Streaming-event counterpart of `createRuntimeEventCollector`. Pass each
|
|
985
|
+
* event yielded by `runAgentTaskStream` through `onEvent` and read the
|
|
986
|
+
* sanitized copies off `events`; the same `RuntimeTelemetryOptions` redaction
|
|
987
|
+
* flags apply. Kept distinct from `createRuntimeEventCollector` because the
|
|
988
|
+
* stream and non-stream event shapes overlap on `type` literals — dispatching
|
|
989
|
+
* on `type` alone would misroute events.
|
|
783
990
|
*/
|
|
784
991
|
declare function createRuntimeStreamEventCollector(options?: RuntimeTelemetryOptions): RuntimeStreamEventCollector;
|
|
785
992
|
|
|
@@ -829,17 +1036,10 @@ declare function runtimeStreamServerSentEvent(event: RuntimeStreamEvent, options
|
|
|
829
1036
|
/**
|
|
830
1037
|
* @stable
|
|
831
1038
|
*
|
|
832
|
-
*
|
|
833
|
-
*
|
|
834
|
-
* Before this module, consumers (legal-agent's chat.ts, gtm-agent's runtime
|
|
835
|
-
* route) hand-rolled an adapter from `RuntimeStreamEvent` -> `TraceEvent` per
|
|
836
|
-
* repo. The mapping is mechanical and the destination schema is owned by
|
|
837
|
-
* agent-eval, so the adapter belongs in runtime, not in N consumer repos.
|
|
1039
|
+
* One-way bridge from `RuntimeStreamEvent` to agent-eval's `TraceEvent`.
|
|
838
1040
|
*
|
|
839
|
-
* The
|
|
840
|
-
*
|
|
841
|
-
* and would invite consumers to round-trip through agent-eval, defeating the
|
|
842
|
-
* point of the runtime-specific shape.
|
|
1041
|
+
* The reverse direction is intentionally unsupported — agent-eval events
|
|
1042
|
+
* have no session / task affinity, so round-tripping would erase information.
|
|
843
1043
|
*/
|
|
844
1044
|
|
|
845
1045
|
/** @stable */
|
|
@@ -890,4 +1090,4 @@ declare function createTraceBridge(options: TraceBridgeOptions): TraceBridge;
|
|
|
890
1090
|
*/
|
|
891
1091
|
declare function toAgentEvalTrace(event: RuntimeStreamEvent, options: TraceBridgeOptions): TraceEvent | undefined;
|
|
892
1092
|
|
|
893
|
-
export { type AgentAdapter, type AgentBackendContext, type AgentBackendInput, type AgentExecutionBackend, type AgentKnowledgeProvider, type AgentRuntimeEvent, type AgentRuntimeEventSink, type AgentTaskContext, type AgentTaskRunResult, type AgentTaskRunSummary, type AgentTaskSpec, type AgentTaskStatus, BackendTransportError, InMemoryRuntimeSessionStore, type KnowledgeReadinessDecision, type RunAgentTaskOptions, type RunAgentTaskStreamOptions, type RuntimeEventCollector, type RuntimeRunCompleteInput, type RuntimeRunCost, type RuntimeRunHandle, type RuntimeRunOptions, type RuntimeRunPersistenceAdapter, type RuntimeRunRow, RuntimeRunStateError, type RuntimeRunStatus, type RuntimeSession, type RuntimeSessionStore, type RuntimeStreamEvent, type RuntimeStreamEventCollector, type RuntimeStreamEventSink, type RuntimeStreamEventSummary, type RuntimeTelemetryOptions, type SanitizedKnowledgeReadinessReport, type SanitizedKnowledgeRequirement, type ServerSentEventOptions, SessionMismatchError, type TraceBridge, type TraceBridgeOptions, createIterableBackend, createOpenAICompatibleBackend, createRuntimeEventCollector, createRuntimeStreamEventCollector, createSandboxPromptBackend, createTraceBridge, decideKnowledgeReadiness, encodeServerSentEvent, readinessServerSentEvent, runAgentTask, runAgentTaskStream, runtimeStreamServerSentEvent, sanitizeAgentRuntimeEvent, sanitizeKnowledgeReadinessReport, sanitizeRuntimeStreamEvent, startRuntimeRun, summarizeAgentTaskRun, toAgentEvalTrace };
|
|
1093
|
+
export { type AgentAdapter, type AgentBackendContext, type AgentBackendInput, type AgentExecutionBackend, type AgentKnowledgeProvider, type AgentRuntimeEvent, type AgentRuntimeEventSink, type AgentTaskContext, type AgentTaskRunResult, type AgentTaskRunSummary, type AgentTaskSpec, type AgentTaskStatus, BackendTransportError, ChatTurnError, type ChatTurnMessage, type ChatTurnOverlay, type ChatTurnSandbox, type ClassifyIntentOptions, type ClassifyIntentResult, type ConformanceIssue, type ConformanceOptions, type ConformanceResult, InMemoryRuntimeSessionStore, type KnowledgeReadinessDecision, type RunAgentTaskOptions, type RunAgentTaskStreamOptions, type RunChatTurnOptions, type RuntimeEventCollector, type RuntimeRunCompleteInput, type RuntimeRunCost, type RuntimeRunHandle, type RuntimeRunOptions, type RuntimeRunPersistenceAdapter, type RuntimeRunRow, RuntimeRunStateError, type RuntimeRunStatus, type RuntimeSession, type RuntimeSessionStore, type RuntimeStreamEvent, type RuntimeStreamEventCollector, type RuntimeStreamEventSink, type RuntimeStreamEventSummary, type RuntimeTelemetryOptions, type SanitizedKnowledgeReadinessReport, type SanitizedKnowledgeRequirement, type ServerSentEventOptions, SessionMismatchError, type SubagentMatcher, type TraceBridge, type TraceBridgeOptions, assertProfileConformance, classifyIntent, composeTurnProfile, createIterableBackend, createOpenAICompatibleBackend, createRuntimeEventCollector, createRuntimeStreamEventCollector, createSandboxPromptBackend, createTraceBridge, decideKnowledgeReadiness, encodeServerSentEvent, readinessServerSentEvent, runAgentTask, runAgentTaskStream, runChatTurn, runtimeStreamServerSentEvent, sandboxAsChatTurnTarget, sanitizeAgentRuntimeEvent, sanitizeKnowledgeReadinessReport, sanitizeRuntimeStreamEvent, startRuntimeRun, summarizeAgentTaskRun, toAgentEvalTrace };
|