@theokit/agents 0.30.1 → 0.31.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/dist/{bridge-entry-DVhOQc_f.d.ts → bridge-entry-DtDotZGW.d.ts} +376 -7
- package/dist/bridge.d.ts +1 -1
- package/dist/bridge.js +7 -1
- package/dist/{chunk-XCQNYAVU.js → chunk-BWYBOMKR.js} +477 -61
- package/dist/chunk-BWYBOMKR.js.map +1 -0
- package/dist/index.d.ts +270 -31
- package/dist/index.js +313 -3
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/chunk-XCQNYAVU.js.map +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
export { Agent, Artifact, ArtifactOptions, ArtifactResult, Audit, Budget, CommandPermissions, CompactionStrategy, Conversation, ConversationOptions, ConversationStorage, EditFormat, EditFormatType, FilesystemPermissions, Hook, HookEntry, HookPoint, MainLoop, Mixin, Model, Observable, ObservableEntry, Policy, RequiresApproval, RequiresCapability, Sandbox, SandboxOptions, SubAgents, Tool, Toolbox, Trace, applyDecorators, getAgentConfig, getArtifactConfig, getConversationConfig, getHooks, getHooksByPoint, getMainLoop, getMixins, getObservableByChannel, getObservables, getSandboxConfig, getSubAgents, getToolConfig, getToolMethods, getToolboxConfig, isCommandAllowed, isPathAllowed } from './decorators.js';
|
|
2
2
|
import { R as ReasoningEffort } from './skills-Dx_KJ6Eg.js';
|
|
3
3
|
export { A as AgentOptions, a as ApprovalOptions, B as BudgetOptions, C as Checkpoint, b as CheckpointOptions, c as CheckpointState, d as CheckpointStorage, e as CheckpointStrategy, f as Compaction, g as CompactionDecoratorConfig, h as ContextCompactionStrategy, i as ContextWindow, j as ContextWindowOptions, G as Gateway, k as GatewayOptions, H as HumanInTheLoop, l as HumanInTheLoopOptions, I as IndexStrategy, M as MCP, m as MainLoopMeta, n as MainLoopOptions, o as McpServerConfig, p as McpServersMap, q as Memory, r as MemoryOptions, s as MemoryProvider, t as MemoryScope, P as PlatformName, u as PolicyHandler, v as ProjectContext, w as ProjectContextOptions, x as RelevanceStrategy, S as SessionStrategy, y as Skills, z as SkillsOptions, T as TimeoutAction, D as ToolOptions, E as ToolboxOptions, F as getCheckpointConfig, J as getCompactionConfig, K as getContextWindowConfig, L as getGatewayConfig, N as getHumanInTheLoopConfig, O as getMcpConfig, Q as getMemoryConfig, U as getProjectContextConfig, V as getSkillsConfig, W as resolveSessionId } from './skills-Dx_KJ6Eg.js';
|
|
4
|
-
import {
|
|
5
|
-
export {
|
|
4
|
+
import { G as Guardrail, L as LoopStrategy, R as ReflectionStrategy, C as CompiledAgentOptions, a as CompiledTool, b as RoundStreamFactory, S as StreamEvent, D as DelegationResult, A as AgentManifestEntry } from './bridge-entry-DtDotZGW.js';
|
|
5
|
+
export { c as AGENT_BRAND, d as AfterToolCallContext, e as AgentBuilder, f as AgentDefinition, g as AgentDefinitionError, h as AgentExecutionContext, i as AgentManifest, j as AgentManifestTool, k as AgentRoute, l as AgentRouteContext, m as AgentRunInfo, n as AgentStreamEvent, o as AgentWalkResult, p as AgentWarningCode, q as AgentsPluginOptions, r as ApprovalRequiredEvent, s as ArtifactChunkEvent, t as ArtifactStartEvent, B as BeforeToolCallContext, u as BudgetExceededError, v as CheckpointSavedEvent, w as CompiledContextWindow, x as ContextualTool, y as CostBudgetExceededError, z as DEFAULT_MAX_ITERATIONS, E as DefineAgentConfig, F as DelegateOptions, H as DelegationError, I as DoneEvent, J as ErrorEvent, K as FileEditEvent, M as GuardrailAction, N as GuardrailPhase, O as GuardrailResult, P as GuardrailViolationError, Q as InferAgentInput, T as InferAgentToolNames, U as IterationEvent, V as LLMCallContext, W as LoopFinishReason, X as LoopOutcome, Y as LoopStrategyConfig, Z as PartialToolCallEvent, _ as ReflectionContext, $ as ReflectionResult, a0 as ReflectionStrategyConfig, a1 as RunStartedEvent, a2 as SdkMessage, a3 as Segment, a4 as SkillsRequestContext, a5 as SkillsSelection, a6 as StateUpdateEvent, a7 as TextDeltaEvent, a8 as ThinkingEvent, a9 as ToolCallEvent, aa as ToolCallVeto, ab as ToolHooks, ac as ToolHooksPlugin, ad as ToolResultEvent, ae as ToolWalkResult, af as ToolboxWalkResult, ag as agent, ah as agentsPlugin, ai as buildModelSelection, aj as compileAgent, ak as compileAgentDefinition, al as compileAgentModule, am as compileContextWindow, an as compileProjectContext, ao as compileSkills, ap as compileTools, aq as contextualTool, ar as createAgentExecutionContext, as as createSdkAgentStream, at as createThinkTagExtractor, au as createToolHooksPlugin, av as defineAgent, aw as delegate, ax as extractThinkTagStream, ay as generateAgentManifest, az as generateAgentRoutes, aA as isAgentContext, aB as isAgentDefinition, aC as isApprovalRequired, aD as isDone, aE as isError, aF as isPartialToolCall, aG as isTextDelta, aH as isToolCall, aI as isToolResult, aJ as ladderReflectionStrategy, aK as loopStrategyConfigSchema, aL as noopReflectionStrategy, aM as projectContextMetadataOnlyKnobs, aN as reflectionStrategyConfigSchema, aO as resolveEnabledSkills, aP as resolveLoopStrategy, aQ as streamAgentResponse, aR as streamAgentUIMessages, aS as translateSdkEvent, aT as translateToUIMessageStream, aU as validateUniqueRoutes, aV as walkAgentMetadata } from './bridge-entry-DtDotZGW.js';
|
|
6
6
|
import { PluginsSettings, Plugin, ProviderRoutingSettings, AgentDefinition, BudgetTracker, ConversationStorageAdapter, CustomTool } from '@theokit/sdk';
|
|
7
7
|
import { RetryOptions } from '@theokit/sdk/retry';
|
|
8
8
|
import { CompressibleMessage } from '@theokit/sdk/compaction';
|
|
@@ -11,6 +11,80 @@ import { z } from 'zod';
|
|
|
11
11
|
import '@theokit/http';
|
|
12
12
|
import 'ai';
|
|
13
13
|
|
|
14
|
+
/**
|
|
15
|
+
* M9 (theokit-ai-first) — built-in guardrail detectors.
|
|
16
|
+
*
|
|
17
|
+
* Each factory returns a {@link Guardrail}. None call an LLM (G2 / sdk-runtime.md):
|
|
18
|
+
* `outputModeration` takes an INJECTED predicate so the provider call (if any) lives in the
|
|
19
|
+
* consumer's code, never in `packages/`.
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
/** Rough token estimate — ~4 chars/token (documented heuristic; exact counting is provider-specific). */
|
|
23
|
+
declare function estimateTokens(text: string): number;
|
|
24
|
+
interface PromptInjectionOptions {
|
|
25
|
+
/** Additional project-specific trigger phrases (compared lowercased, substring). */
|
|
26
|
+
extra?: readonly string[];
|
|
27
|
+
}
|
|
28
|
+
/** Blocks input containing a known injection trigger phrase. */
|
|
29
|
+
declare function promptInjectionDetector(options?: PromptInjectionOptions): Guardrail;
|
|
30
|
+
interface PiiOptions {
|
|
31
|
+
/** When true (default), matched PII is replaced with `[REDACTED]`. */
|
|
32
|
+
redact?: boolean;
|
|
33
|
+
/** Placeholder token. Default `[REDACTED]`. */
|
|
34
|
+
placeholder?: string;
|
|
35
|
+
}
|
|
36
|
+
/** Redacts CPF, email and phone numbers from input. */
|
|
37
|
+
declare function piiDetector(options?: PiiOptions): Guardrail;
|
|
38
|
+
/** NFKC-normalizes and strips zero-width / RTL-override characters. */
|
|
39
|
+
declare function unicodeNormalizer(): Guardrail;
|
|
40
|
+
interface CostGuardOptions {
|
|
41
|
+
/** Cumulative input-token budget per guard instance (per session — one guard per run). */
|
|
42
|
+
maxTokens: number;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Enforces a cumulative input-token budget. Stateful: one instance accumulates across the calls
|
|
46
|
+
* it sees within a run. Throws {@link CostBudgetExceededError} fail-fast when exceeded.
|
|
47
|
+
*/
|
|
48
|
+
declare function costGuard(options: CostGuardOptions): Guardrail;
|
|
49
|
+
interface OutputModerationOptions {
|
|
50
|
+
/**
|
|
51
|
+
* Injected predicate — returns `true` when the text is prohibited. The provider call (OpenAI
|
|
52
|
+
* moderation API, a classifier, etc.) lives HERE, in consumer code — never inside `packages/`
|
|
53
|
+
* (G2). Keeps the module runtime-free.
|
|
54
|
+
*/
|
|
55
|
+
moderate: (text: string) => boolean | Promise<boolean>;
|
|
56
|
+
}
|
|
57
|
+
/** Blocks model output the injected predicate flags as prohibited. */
|
|
58
|
+
declare function outputModeration(options: OutputModerationOptions): Guardrail;
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* M9 (theokit-ai-first) — the guardrail pipeline: apply guards in order at a boundary phase.
|
|
62
|
+
*
|
|
63
|
+
* Fail-fast (error-handling.md): a `block` throws {@link GuardrailViolationError} immediately.
|
|
64
|
+
* A `redact` threads the transformed text into the next guard. Independent of the SDK runtime —
|
|
65
|
+
* this runs at the framework boundary, before/after the SDK does its work.
|
|
66
|
+
*/
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Run every guard's `checkInput` in order against `text`. Returns the (possibly redacted) text.
|
|
70
|
+
* Throws {@link GuardrailViolationError} on the first `block`. Guards without `checkInput` are skipped.
|
|
71
|
+
*/
|
|
72
|
+
declare function runInputGuards(text: string, guards: readonly Guardrail[]): Promise<string>;
|
|
73
|
+
/**
|
|
74
|
+
* Run every guard's `checkOutput` in order against `text`. Returns the (possibly redacted) text.
|
|
75
|
+
* Throws {@link GuardrailViolationError} on the first `block`. Guards without `checkOutput` are skipped.
|
|
76
|
+
*/
|
|
77
|
+
declare function runOutputGuards(text: string, guards: readonly Guardrail[]): Promise<string>;
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Wrap `inner`, moderating its accumulated text output.
|
|
81
|
+
*
|
|
82
|
+
* @param inner the source stream (yields events, returns a result).
|
|
83
|
+
* @param guards the guardrails; only those with `checkOutput` participate.
|
|
84
|
+
* @param extractText pulls the human-visible text out of an event (return `undefined` for non-text).
|
|
85
|
+
*/
|
|
86
|
+
declare function moderateOutputStream<E, R>(inner: AsyncGenerator<E, R>, guards: readonly Guardrail[], extractText: (event: E) => string | undefined): AsyncGenerator<E, R>;
|
|
87
|
+
|
|
14
88
|
/**
|
|
15
89
|
* TranscriptCompactionStrategy — a named, callable transcript-compaction authoring layer
|
|
16
90
|
* (Strategy pattern, V4-F). Mirrors `ReflectionStrategy`/`LoopStrategy`: interface
|
|
@@ -94,34 +168,6 @@ declare function resolveCompactionStrategy(name: string, config: {
|
|
|
94
168
|
*/
|
|
95
169
|
declare const tokenBudgetCompactionStrategy: TranscriptCompactionStrategy;
|
|
96
170
|
|
|
97
|
-
/**
|
|
98
|
-
* runReflectiveLoop — the multi-round reflective driver that gives `@MainLoop`
|
|
99
|
-
* its runtime (closes the metadata-only gap, V4-A / plan ADR D2).
|
|
100
|
-
*
|
|
101
|
-
* Per round it consumes ONE SDK stream turn (the model call stays in the SDK —
|
|
102
|
-
* the factory is `createSdkAgentStream(...)`, injected for testability), derives
|
|
103
|
-
* a {@link LoopOutcome}, asks the {@link ReflectionStrategy} for feedback, then
|
|
104
|
-
* the {@link LoopStrategy} whether to continue. Bounded by `maxIterations`
|
|
105
|
-
* (forced terminal at the ceiling — never an infinite loop). The bridge owns the
|
|
106
|
-
* loop; the SDK owns the model call (sdk-runtime.md / ADR 0031 — no second runtime).
|
|
107
|
-
*
|
|
108
|
-
* `runReflectiveLoop` is INTERNAL (not re-exported from the package barrel,
|
|
109
|
-
* Drawback #4) — consumed by `delegate()` (T2.2) and `AgentRunner` (T3.1).
|
|
110
|
-
*
|
|
111
|
-
* referencia: knowledge-base/references/mastra agent.ts (re-enter the loop with feedback).
|
|
112
|
-
*/
|
|
113
|
-
|
|
114
|
-
/** One SDK stream turn: `createSdkAgentStream(...)` returns this shape. */
|
|
115
|
-
/**
|
|
116
|
-
* Opens one round's SDK stream. `opts.disableTools` (step-cap force-close) asks the factory to
|
|
117
|
-
* gate tools OFF for THIS round (the SDK adapter maps it to `tool_choice:"none"` at send-time, so a
|
|
118
|
-
* cached agent — whose tools can't be un-registered — is still forced to a text summary). Optional +
|
|
119
|
-
* ignored by injected test factories ⇒ backward-compatible.
|
|
120
|
-
*/
|
|
121
|
-
type RoundStreamFactory = (message: string, sessionId: string, opts?: {
|
|
122
|
-
disableTools?: boolean;
|
|
123
|
-
}) => AsyncIterable<StreamEvent>;
|
|
124
|
-
|
|
125
171
|
/**
|
|
126
172
|
* AgentRunner — the imperative twin of `@MainLoop` (plan ADR D4, V4-B).
|
|
127
173
|
*
|
|
@@ -291,6 +337,8 @@ declare class AgentRunner {
|
|
|
291
337
|
* builder set `.stream(false)`, callers should use {@link run} instead.
|
|
292
338
|
*/
|
|
293
339
|
stream(message: string, opts: AgentRunnerRunOptions): AsyncGenerator<StreamEvent, DelegationResult>;
|
|
340
|
+
/** The core stream path, after input guardrails have run (M9). */
|
|
341
|
+
private streamUnguarded;
|
|
294
342
|
/** Run the agent to a terminal result via the shared reflective loop (collect mode). */
|
|
295
343
|
run(message: string, opts: AgentRunnerRunOptions): Promise<DelegationResult>;
|
|
296
344
|
}
|
|
@@ -317,4 +365,195 @@ declare class AgentRunnerBuilder {
|
|
|
317
365
|
build(): AgentRunner;
|
|
318
366
|
}
|
|
319
367
|
|
|
320
|
-
|
|
368
|
+
/**
|
|
369
|
+
* M15 (theokit-ai-first) — A2A agent card generation (ADR-0040 § D2, home/discovery concern).
|
|
370
|
+
*
|
|
371
|
+
* Produces an [A2A](https://github.com/google/A2A)-spec Agent Card from the framework's
|
|
372
|
+
* `AgentManifestEntry`, so other systems can discover a TheoKit agent's capabilities over HTTP at
|
|
373
|
+
* `/.well-known/<name>/agent-card.json`. Pure data transform — no LLM, no runtime (G2).
|
|
374
|
+
*/
|
|
375
|
+
|
|
376
|
+
/** A single capability exposed by an A2A agent (maps from a TheoKit tool). */
|
|
377
|
+
interface A2ASkill {
|
|
378
|
+
id: string;
|
|
379
|
+
name: string;
|
|
380
|
+
description: string;
|
|
381
|
+
}
|
|
382
|
+
/** A2A agent-card capabilities block. */
|
|
383
|
+
interface A2ACapabilities {
|
|
384
|
+
streaming: boolean;
|
|
385
|
+
pushNotifications: boolean;
|
|
386
|
+
stateTransitionHistory: boolean;
|
|
387
|
+
}
|
|
388
|
+
/** An A2A-spec Agent Card (the subset TheoKit advertises). */
|
|
389
|
+
interface AgentCard {
|
|
390
|
+
name: string;
|
|
391
|
+
description: string;
|
|
392
|
+
url: string;
|
|
393
|
+
version: string;
|
|
394
|
+
capabilities: A2ACapabilities;
|
|
395
|
+
defaultInputModes: string[];
|
|
396
|
+
defaultOutputModes: string[];
|
|
397
|
+
skills: A2ASkill[];
|
|
398
|
+
}
|
|
399
|
+
interface BuildAgentCardOptions {
|
|
400
|
+
/** Absolute base URL of the deployment (e.g. `https://app.example.com`). A trailing slash is trimmed. */
|
|
401
|
+
baseUrl: string;
|
|
402
|
+
/** Human description of the agent. Defaults to a generated sentence when omitted (spec requires non-empty). */
|
|
403
|
+
description?: string;
|
|
404
|
+
}
|
|
405
|
+
/** Build an A2A agent card from a manifest entry. */
|
|
406
|
+
declare function buildAgentCard(entry: AgentManifestEntry, options: BuildAgentCardOptions): AgentCard;
|
|
407
|
+
/** The A2A discovery path for an agent: `/.well-known/<name>/agent-card.json`. */
|
|
408
|
+
declare function wellKnownCardPath(agentName: string): string;
|
|
409
|
+
|
|
410
|
+
/**
|
|
411
|
+
* M16 (theokit-ai-first) — MCP server manifest generation (ADR-0040 § D2, home concern).
|
|
412
|
+
*
|
|
413
|
+
* Exposes a TheoKit agent's tools to external MCP clients as `tools/list` descriptors, so the app
|
|
414
|
+
* can advertise its agents over its OWN HTTP routes. Pure data transform — no LLM, no runtime, and
|
|
415
|
+
* NO stdio transport (that stays SDK-side per sdk-runtime.md). Serving these over `GET /mcp` and the
|
|
416
|
+
* JSON-RPC envelope are follow-ups (mount path).
|
|
417
|
+
*/
|
|
418
|
+
|
|
419
|
+
/** The MCP protocol revision these descriptors target. */
|
|
420
|
+
declare const MCP_PROTOCOL_VERSION = "2024-11-05";
|
|
421
|
+
/** A JSON-schema object (the shape MCP expects for a tool's `inputSchema`). */
|
|
422
|
+
interface McpJsonSchema {
|
|
423
|
+
type: 'object';
|
|
424
|
+
properties: Record<string, unknown>;
|
|
425
|
+
required?: string[];
|
|
426
|
+
}
|
|
427
|
+
/** An MCP `tools/list` tool descriptor. */
|
|
428
|
+
interface McpToolDescriptor {
|
|
429
|
+
name: string;
|
|
430
|
+
description: string;
|
|
431
|
+
inputSchema: McpJsonSchema;
|
|
432
|
+
}
|
|
433
|
+
/** MCP `initialize` server info. */
|
|
434
|
+
interface McpServerInfo {
|
|
435
|
+
name: string;
|
|
436
|
+
version: string;
|
|
437
|
+
protocolVersion: string;
|
|
438
|
+
}
|
|
439
|
+
/**
|
|
440
|
+
* Map an agent's tools to MCP tool descriptors. The manifest tool carries name + description; the
|
|
441
|
+
* per-tool JSON schema is not retained in the manifest, so a permissive empty-object schema is
|
|
442
|
+
* emitted (MCP clients accept it and pass through arbitrary args). Wiring the real per-tool schema
|
|
443
|
+
* is a follow-up once the manifest carries it.
|
|
444
|
+
*/
|
|
445
|
+
declare function buildMcpToolDescriptors(entry: AgentManifestEntry): McpToolDescriptor[];
|
|
446
|
+
/** Build the MCP `initialize` server-info block for an agent. */
|
|
447
|
+
declare function mcpServerInfo(entry: AgentManifestEntry): McpServerInfo;
|
|
448
|
+
|
|
449
|
+
/**
|
|
450
|
+
* M15 (theokit-ai-first) — A2A client: call a remote A2A agent as a tool (ADR-0040 § D2).
|
|
451
|
+
*
|
|
452
|
+
* `createA2ATool` returns a `CustomTool` whose handler POSTs the input message to a remote agent's
|
|
453
|
+
* HTTP endpoint and returns its text response — cross-network delegation. Uses `fetch` (Web
|
|
454
|
+
* Standards, G8). The target is a remote AGENT endpoint, not an LLM provider, so the G2 grep guard
|
|
455
|
+
* (`openrouter.ai|api.openai.com|api.anthropic.com`) is unaffected. `fetchImpl` is injectable for tests.
|
|
456
|
+
*/
|
|
457
|
+
|
|
458
|
+
/** How to authenticate to the remote agent. */
|
|
459
|
+
interface A2AAuth {
|
|
460
|
+
/** Bearer token → `Authorization: Bearer <token>`. */
|
|
461
|
+
bearer?: string;
|
|
462
|
+
/** API-key header pair → `<name>: <value>` (e.g. `x-api-key`). */
|
|
463
|
+
apiKey?: {
|
|
464
|
+
header: string;
|
|
465
|
+
value: string;
|
|
466
|
+
};
|
|
467
|
+
}
|
|
468
|
+
interface A2AToolConfig {
|
|
469
|
+
/** Remote agent endpoint URL (POST target). */
|
|
470
|
+
url: string;
|
|
471
|
+
/** Tool name the model calls. */
|
|
472
|
+
name: string;
|
|
473
|
+
/** Tool description surfaced to the model. */
|
|
474
|
+
description: string;
|
|
475
|
+
/** Static headers merged into every request. */
|
|
476
|
+
headers?: Record<string, string>;
|
|
477
|
+
/** Auth applied to every request. */
|
|
478
|
+
auth?: A2AAuth;
|
|
479
|
+
/** Injected fetch (defaults to the global). Narrowed to the call shape this client uses. */
|
|
480
|
+
fetchImpl?: (url: string, init: RequestInit) => Promise<Response>;
|
|
481
|
+
}
|
|
482
|
+
/**
|
|
483
|
+
* Create a tool that delegates to a remote A2A agent. The remote is expected to answer a
|
|
484
|
+
* `{ message }` POST with a JSON body carrying a `response` (or `text`) string.
|
|
485
|
+
*/
|
|
486
|
+
declare function createA2ATool(config: A2AToolConfig): CustomTool;
|
|
487
|
+
|
|
488
|
+
/**
|
|
489
|
+
* M11 (theokit-ai-first) — {resource, thread} conversation scoping (ADR-0040 § D2, home concern).
|
|
490
|
+
*
|
|
491
|
+
* Maps a request's (resource, thread) pair to a deterministic, collision-safe conversation id so
|
|
492
|
+
* multi-tenant apps isolate history without hand-building `user-${id}-thread-${id}` strings. This
|
|
493
|
+
* is the app's request→conversation mapping — NOT the SDK's storage engine (which the derived id is
|
|
494
|
+
* simply handed to). Background compression of long histories stays SDK-side.
|
|
495
|
+
*
|
|
496
|
+
* Encoding: each component is `encodeURIComponent`-escaped and joined with `/`. Since
|
|
497
|
+
* `encodeURIComponent` escapes a raw `/` to `%2F`, the separator is unambiguous — `('a/b','c')` and
|
|
498
|
+
* `('a','b/c')` derive DIFFERENT ids (collision-safe). Reversible via {@link parseConversationId}.
|
|
499
|
+
*/
|
|
500
|
+
/** Derive a deterministic conversation id from a (resource, thread) pair. Fails fast on empty input. */
|
|
501
|
+
declare function deriveConversationId(resource: string, thread: string): string;
|
|
502
|
+
/**
|
|
503
|
+
* Reverse a derived conversation id back to its (resource, thread). Returns `null` for a value that
|
|
504
|
+
* is not a derived scope id (no separator, or an empty component) — callers treat that as "opaque id,
|
|
505
|
+
* not scoped".
|
|
506
|
+
*/
|
|
507
|
+
declare function parseConversationId(id: string): {
|
|
508
|
+
resource: string;
|
|
509
|
+
thread: string;
|
|
510
|
+
} | null;
|
|
511
|
+
|
|
512
|
+
/**
|
|
513
|
+
* M17 (theokit-ai-first) — ACP (Agent Client Protocol) stdio framing.
|
|
514
|
+
*
|
|
515
|
+
* ACP talks to a coding agent (Claude Code, Amp, Codex) over stdio as newline-delimited JSON. This
|
|
516
|
+
* is the transport-agnostic CORE: encode a message to a line, and decode a byte/char stream that may
|
|
517
|
+
* split a message across chunks. Pure — no subprocess, no Node API. The subprocess spawn lives in the
|
|
518
|
+
* adapter layer (G8) / SDK; `createACPTool` (wrapping this codec + an injected transport) is a
|
|
519
|
+
* follow-up once the adapter ships.
|
|
520
|
+
*/
|
|
521
|
+
/** Serialize a message to a single newline-terminated JSON line. */
|
|
522
|
+
declare function encodeAcpMessage(message: unknown): string;
|
|
523
|
+
/**
|
|
524
|
+
* Incremental decoder for newline-delimited JSON. Feed it chunks with {@link push}; it buffers a
|
|
525
|
+
* partial trailing line across calls and returns every WHOLE message parsed so far. Blank lines are
|
|
526
|
+
* skipped. A completed non-JSON line fails fast with a typed error (error-handling.md) — a corrupt
|
|
527
|
+
* frame must never be silently dropped.
|
|
528
|
+
*/
|
|
529
|
+
declare class AcpMessageDecoder {
|
|
530
|
+
private buffer;
|
|
531
|
+
/** Feed a chunk; returns the messages completed by this chunk (possibly empty). */
|
|
532
|
+
push(chunk: string): unknown[];
|
|
533
|
+
}
|
|
534
|
+
|
|
535
|
+
/** The stdio channel to the coding-agent subprocess (abstracted for testability + G8). */
|
|
536
|
+
interface AcpTransport {
|
|
537
|
+
/** Write one already-encoded (newline-terminated) line to the agent's stdin. */
|
|
538
|
+
send(line: string): void;
|
|
539
|
+
/** Subscribe to raw lines/chunks from the agent's stdout. */
|
|
540
|
+
subscribe(onData: (chunk: string) => void): void;
|
|
541
|
+
}
|
|
542
|
+
/** Return a value or a Promise — `unknown` already includes `Promise<unknown>`; `await` handles both. */
|
|
543
|
+
type ServerRequestHandler = (params: unknown) => unknown;
|
|
544
|
+
declare class AcpClient {
|
|
545
|
+
private readonly transport;
|
|
546
|
+
private nextId;
|
|
547
|
+
private readonly pending;
|
|
548
|
+
private readonly handlers;
|
|
549
|
+
private readonly decoder;
|
|
550
|
+
constructor(transport: AcpTransport);
|
|
551
|
+
/** Send a JSON-RPC request and resolve with its `result` (or reject on `error`). */
|
|
552
|
+
request(method: string, params: unknown): Promise<unknown>;
|
|
553
|
+
/** Register a handler for a server→client request method (e.g. `session/request_permission`). */
|
|
554
|
+
onRequest(method: string, handler: ServerRequestHandler): void;
|
|
555
|
+
private dispatch;
|
|
556
|
+
private handleServerRequest;
|
|
557
|
+
}
|
|
558
|
+
|
|
559
|
+
export { type A2AAuth, type A2ACapabilities, type A2ASkill, type A2AToolConfig, AcpClient, AcpMessageDecoder, type AcpTransport, type AgentCard, AgentManifestEntry, AgentRunner, AgentRunnerBuilder, type AgentRunnerRunOptions, type BuildAgentCardOptions, type CompactionCallOptions, type CompactionStrategyConfig, CompiledAgentOptions, CompiledTool, type CostGuardOptions, DEFAULT_KEEP_TOKENS, DelegationResult, Guardrail, LoopStrategy, MCP_PROTOCOL_VERSION, type McpJsonSchema, type McpServerInfo, type McpToolDescriptor, type OutputModerationOptions, type PiiOptions, type PromptInjectionOptions, ReasoningEffort, ReflectionStrategy, RoundStreamFactory, StreamEvent, type Summarize, type TranscriptCompactionStrategy, buildAgentCard, buildMcpToolDescriptors, compactionStrategyConfigSchema, costGuard, createA2ATool, deriveConversationId, encodeAcpMessage, estimateTokens, mcpServerInfo, moderateOutputStream, outputModeration, parseConversationId, piiDetector, promptInjectionDetector, resolveCompactionStrategy, runInputGuards, runOutputGuards, tokenBudgetCompactionStrategy, unicodeNormalizer, wellKnownCardPath };
|