@ethosagent/core 0.4.1 → 0.4.3
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/index.d.ts +122 -5
- package/dist/index.js +436 -78
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as _ethosagent_types from '@ethosagent/types';
|
|
2
|
-
import { ClarifyStore, PendingClarify, ClarifyResponse, ClarifyAnswerableBy, ClarifySurfaceType, PersonalityObservabilityConfig, SpanKind, EventSeverity, HookRegistry, LLMProvider, ToolRegistry, PersonalityRegistry, MemoryProvider, SessionStore, ContextInjector, Storage, ContextEngineRegistry, RequestDumpStore, SteerSink, Attachment, KeyValueStore, SecretRef, ToolCapabilities, ToolContext, Tool, PersonalityConfig, ContextEngine, ContextEngineCompactInput, ContextEngineCompactOutput, Message, Session, SessionFilter, StoredMessage, SessionUsage, SearchResult, CompressionEvent, MemoryContext, MemorySnapshot, MemoryEntry, SearchOpts, MemoryUpdate, ListOpts, MemoryEntryRef, ToolResult, VoidHooks, ModifyingHooks, ClaimingHooks, ToolDefinitionLite, CompletionOptions, CompletionChunk, LLMProviderRegistry, LLMProviderFactory, MemoryProviderRegistry, MemoryProviderFactory, RequestDumpRecord, ScopedFetch, ScopedFs, ScopedFsEntry, ScopedProcess, SpawnOpts, ProcessResult, ScopedSecretsResolver, ToolResultReducerRegistry, ToolResultReducer, ToolFilterOpts } from '@ethosagent/types';
|
|
2
|
+
import { ClarifyStore, PendingClarify, ClarifyResponse, ClarifyAnswerableBy, ClarifySurfaceType, PersonalityObservabilityConfig, SpanKind, EventSeverity, HookRegistry, LLMProvider, ToolRegistry, PersonalityRegistry, MemoryProvider, SessionStore, ContextInjector, Storage, ContextEngineRegistry, RequestDumpStore, SteerSink, Attachment, KeyValueStore, SecretRef, ToolCapabilities, ToolContext, Tool, PersonalityConfig, ContextEngine, ContextEngineCompactInput, ContextEngineCompactOutput, Message, Session, SessionFilter, StoredMessage, SessionUsage, SearchResult, CompressionEvent, MemoryContext, MemorySnapshot, MemoryEntry, SearchOpts, MemoryUpdate, ListOpts, MemoryEntryRef, ToolResult, VoidHooks, ModifyingHooks, ClaimingHooks, ToolTransport, ToolProgressEvent, ToolExecuteRequest, NotificationRouter, NotifyOptions, NotificationAdapter, ToolDefinitionLite, CompletionOptions, CompletionChunk, LLMProviderRegistry, LLMProviderFactory, MemoryProviderRegistry, MemoryProviderFactory, RequestDumpRecord, ScopedFetch, ScopedFs, ScopedFsEntry, ScopedProcess, SpawnOpts, ProcessResult, ScopedSecretsResolver, SimpleCompletion, SimpleCompletionOptions, ToolResultReducerRegistry, ToolResultReducer, ToolFilterOpts } from '@ethosagent/types';
|
|
3
3
|
export { MemoryConflictError } from '@ethosagent/types';
|
|
4
4
|
import * as _ethosagent_safety_watcher from '@ethosagent/safety-watcher';
|
|
5
5
|
import { InjectionClassifier } from '@ethosagent/safety-injection';
|
|
@@ -150,7 +150,7 @@ interface AgentLoopObservability {
|
|
|
150
150
|
flush(): void;
|
|
151
151
|
}
|
|
152
152
|
|
|
153
|
-
declare const KNOWN_AGENT_EVENT_TYPES: readonly ["text_delta", "thinking_delta", "tool_start", "tool_progress", "tool_end", "usage", "error", "done", "context_meta", "run_start", "dry_run_summary"];
|
|
153
|
+
declare const KNOWN_AGENT_EVENT_TYPES: readonly ["text_delta", "thinking_delta", "tool_start", "tool_progress", "tool_end", "usage", "error", "done", "context_meta", "run_start", "dry_run_summary", "tool_approval_required", "tool_approval_response", "evaluators_complete", "credential_required", "notification_received"];
|
|
154
154
|
type KnownAgentEventType = (typeof KNOWN_AGENT_EVENT_TYPES)[number];
|
|
155
155
|
/**
|
|
156
156
|
* Returns true when the event's `type` is one a current consumer knows
|
|
@@ -239,6 +239,41 @@ type AgentEvent = {
|
|
|
239
239
|
type: 'dry_run_summary';
|
|
240
240
|
plan: DryRunToolPlan[];
|
|
241
241
|
capped: number;
|
|
242
|
+
} | {
|
|
243
|
+
type: 'tool_approval_required';
|
|
244
|
+
toolCallId: string;
|
|
245
|
+
toolName: string;
|
|
246
|
+
args: unknown;
|
|
247
|
+
} | {
|
|
248
|
+
type: 'tool_approval_response';
|
|
249
|
+
toolCallId: string;
|
|
250
|
+
approved: boolean;
|
|
251
|
+
reason?: string;
|
|
252
|
+
} | {
|
|
253
|
+
type: 'evaluators_complete';
|
|
254
|
+
results: Array<{
|
|
255
|
+
name: string;
|
|
256
|
+
pass: boolean;
|
|
257
|
+
reason?: string;
|
|
258
|
+
score?: number;
|
|
259
|
+
}>;
|
|
260
|
+
} | {
|
|
261
|
+
type: 'credential_required';
|
|
262
|
+
pluginId: string;
|
|
263
|
+
credentialKey: string;
|
|
264
|
+
kind: 'oauth' | 'api_key' | 'text';
|
|
265
|
+
label: string;
|
|
266
|
+
description?: string;
|
|
267
|
+
authUrl?: string;
|
|
268
|
+
sessionKey: string;
|
|
269
|
+
pendingUserMessage: string;
|
|
270
|
+
} | {
|
|
271
|
+
type: 'notification_received';
|
|
272
|
+
pluginId: string;
|
|
273
|
+
sessionKey: string;
|
|
274
|
+
message: string;
|
|
275
|
+
startTurn: boolean;
|
|
276
|
+
payload?: Record<string, unknown>;
|
|
242
277
|
};
|
|
243
278
|
interface AgentLoopConfig {
|
|
244
279
|
llm: LLMProvider;
|
|
@@ -337,6 +372,28 @@ interface AgentLoopConfig {
|
|
|
337
372
|
* record of each LLM request/response for offline analysis and debugging.
|
|
338
373
|
*/
|
|
339
374
|
requestDumpStore?: RequestDumpStore;
|
|
375
|
+
/** v2.2 — Callback to emit tool invocation metrics to the diagnostic store.
|
|
376
|
+
* Wiring provides this; core never imports DiagnosticStore directly. */
|
|
377
|
+
onToolMetric?: (opts: {
|
|
378
|
+
pluginId: string;
|
|
379
|
+
toolName: string;
|
|
380
|
+
ok: boolean;
|
|
381
|
+
durationMs: number;
|
|
382
|
+
sessionId: string;
|
|
383
|
+
turnId: string;
|
|
384
|
+
}) => void;
|
|
385
|
+
/** v2.2 — Pre-turn credential check. Returns the first missing credential,
|
|
386
|
+
* or null if all required credentials are present. Opt-in: when undefined,
|
|
387
|
+
* the check is skipped. Wiring provides this when plugins declare required
|
|
388
|
+
* credentials. */
|
|
389
|
+
credentialCheck?: (sessionKey: string, pendingUserMessage: string) => Promise<{
|
|
390
|
+
pluginId: string;
|
|
391
|
+
credentialKey: string;
|
|
392
|
+
kind: 'oauth' | 'api_key' | 'text';
|
|
393
|
+
label: string;
|
|
394
|
+
description?: string;
|
|
395
|
+
authUrl?: string;
|
|
396
|
+
} | null>;
|
|
340
397
|
options?: {
|
|
341
398
|
maxIterations?: number;
|
|
342
399
|
historyLimit?: number;
|
|
@@ -449,10 +506,16 @@ declare class AgentLoop {
|
|
|
449
506
|
private readonly teamId?;
|
|
450
507
|
/** Per-personality MCP tool policy from mcp.yaml (NOT on PersonalityConfig). */
|
|
451
508
|
private readonly mcpPolicy?;
|
|
509
|
+
/** v2.2 — Callback to emit per-tool invocation metrics to the diagnostic store. */
|
|
510
|
+
private readonly onToolMetric?;
|
|
511
|
+
/** v2.2 — Pre-turn credential check callback. */
|
|
512
|
+
private readonly credentialCheck?;
|
|
452
513
|
/** Per-session accumulated spend in USD. Keyed by sessionKey. Reset via resetSessionCost(). */
|
|
453
514
|
private readonly sessionCosts;
|
|
454
515
|
/** FW-28 — per-session mtime registry. Keyed by sessionKey → (absPath → record). */
|
|
455
516
|
private readonly sessionReadMtimes;
|
|
517
|
+
/** v2: per-run key/value store threaded into ToolContext for plugin communication. */
|
|
518
|
+
private readonly contextStore;
|
|
456
519
|
constructor(config: AgentLoopConfig);
|
|
457
520
|
/**
|
|
458
521
|
* Resolve a pending clarify request — called by an interactive surface when
|
|
@@ -591,6 +654,17 @@ declare function estimateTokens(text: string): number;
|
|
|
591
654
|
declare function estimateMessageTokens(message: Message): number;
|
|
592
655
|
declare function estimateMessagesTokens(input: Message | Message[] | string): number;
|
|
593
656
|
|
|
657
|
+
declare class ContextStore {
|
|
658
|
+
private readonly store;
|
|
659
|
+
get<T>(key: string): T | undefined;
|
|
660
|
+
set<T>(key: string, value: T): void;
|
|
661
|
+
clear(): void;
|
|
662
|
+
asContextMethods(): {
|
|
663
|
+
getContext: <T>(key: string) => T | undefined;
|
|
664
|
+
setContext: <T>(key: string, value: T) => void;
|
|
665
|
+
};
|
|
666
|
+
}
|
|
667
|
+
|
|
594
668
|
declare class InMemorySessionStore implements SessionStore {
|
|
595
669
|
private sessions;
|
|
596
670
|
private messages;
|
|
@@ -684,6 +758,23 @@ declare class DefaultHookRegistry implements HookRegistry {
|
|
|
684
758
|
private remove;
|
|
685
759
|
}
|
|
686
760
|
|
|
761
|
+
interface LocalToolTransportLiveCtx {
|
|
762
|
+
emit: (event: ToolProgressEvent) => void;
|
|
763
|
+
readMtimes?: Map<string, {
|
|
764
|
+
mtimeMs: number;
|
|
765
|
+
readAtTurn: number;
|
|
766
|
+
}>;
|
|
767
|
+
storage?: _ethosagent_types.Storage;
|
|
768
|
+
inboundAttachments?: Attachment[];
|
|
769
|
+
}
|
|
770
|
+
declare class LocalToolTransport implements ToolTransport {
|
|
771
|
+
private readonly lookup;
|
|
772
|
+
private readonly backends?;
|
|
773
|
+
private readonly getLiveCtx?;
|
|
774
|
+
constructor(lookup: (name: string) => Tool | undefined, backends?: CapabilityBackends | undefined, getLiveCtx?: (() => LocalToolTransportLiveCtx) | undefined);
|
|
775
|
+
execute(request: ToolExecuteRequest, signal: AbortSignal): Promise<ToolResult>;
|
|
776
|
+
}
|
|
777
|
+
|
|
687
778
|
/**
|
|
688
779
|
* Pass-through decorator that makes the wiring intent explicit: this provider
|
|
689
780
|
* uses eager prefetch (all content injected at session start). The AgentLoop
|
|
@@ -779,6 +870,13 @@ declare class LastWriteWinsPolicy implements MemoryProvider {
|
|
|
779
870
|
list(ctx: MemoryContext, opts?: ListOpts): Promise<MemoryEntryRef[]>;
|
|
780
871
|
}
|
|
781
872
|
|
|
873
|
+
declare class DefaultNotificationRouter implements NotificationRouter {
|
|
874
|
+
private readonly adapters;
|
|
875
|
+
route(pluginId: string, opts: NotifyOptions): Promise<void>;
|
|
876
|
+
register(sessionKey: string, adapter: NotificationAdapter): void;
|
|
877
|
+
deregister(sessionKey: string): void;
|
|
878
|
+
}
|
|
879
|
+
|
|
782
880
|
/**
|
|
783
881
|
* Verify that `target` resolves to a path within (or equal to) `base`.
|
|
784
882
|
* Both paths are resolved to absolute before comparison.
|
|
@@ -967,6 +1065,17 @@ declare class ScopedSecretsImpl implements ScopedSecretsResolver {
|
|
|
967
1065
|
get(ref: SecretRef): Promise<string>;
|
|
968
1066
|
}
|
|
969
1067
|
|
|
1068
|
+
declare class SimpleCompletionImpl implements SimpleCompletion {
|
|
1069
|
+
private readonly provider;
|
|
1070
|
+
private readonly defaultModel;
|
|
1071
|
+
private readonly onUsage;
|
|
1072
|
+
constructor(provider: LLMProvider, defaultModel: string, onUsage: (tokens: {
|
|
1073
|
+
input: number;
|
|
1074
|
+
output: number;
|
|
1075
|
+
}) => void);
|
|
1076
|
+
complete(prompt: string, options?: SimpleCompletionOptions): Promise<string>;
|
|
1077
|
+
}
|
|
1078
|
+
|
|
970
1079
|
declare function parseTemporalBound(input: string): Date | undefined;
|
|
971
1080
|
declare function toJournalKey(date: Date): string;
|
|
972
1081
|
declare function applyTemporalDecay(results: SearchResult[], options?: {
|
|
@@ -982,9 +1091,14 @@ declare class DefaultToolResultReducerRegistry implements ToolResultReducerRegis
|
|
|
982
1091
|
|
|
983
1092
|
declare class DefaultToolRegistry implements ToolRegistry {
|
|
984
1093
|
private readonly tools;
|
|
1094
|
+
private readonly resultCache;
|
|
985
1095
|
private readonly backends?;
|
|
986
1096
|
private readonly reducers?;
|
|
987
|
-
|
|
1097
|
+
private readonly transport;
|
|
1098
|
+
private turnLiveCtx;
|
|
1099
|
+
constructor(backends?: CapabilityBackends, reducers?: ToolResultReducerRegistry, transport?: ToolTransport);
|
|
1100
|
+
private cacheGet;
|
|
1101
|
+
private cacheSet;
|
|
988
1102
|
register(tool: Tool, opts?: {
|
|
989
1103
|
pluginId?: string;
|
|
990
1104
|
}): void;
|
|
@@ -1002,6 +1116,8 @@ declare class DefaultToolRegistry implements ToolRegistry {
|
|
|
1002
1116
|
get(name: string): Tool | undefined;
|
|
1003
1117
|
getAvailable(): Tool[];
|
|
1004
1118
|
getForToolset(toolset: string): Tool[];
|
|
1119
|
+
/** v2.2 — Return the plugin id that registered a tool, if any. */
|
|
1120
|
+
getPluginId(name: string): string | undefined;
|
|
1005
1121
|
toDefinitions(allowedTools?: string[], filterOpts?: ToolFilterOpts): {
|
|
1006
1122
|
name: string;
|
|
1007
1123
|
description: string;
|
|
@@ -1016,11 +1132,12 @@ declare class DefaultToolRegistry implements ToolRegistry {
|
|
|
1016
1132
|
* Used by IngestFilter to check skill.required_tools ⊆ effective_reach.
|
|
1017
1133
|
*/
|
|
1018
1134
|
toolNamesForPersonality(personality: PersonalityConfig): Set<string>;
|
|
1135
|
+
private applyFilters;
|
|
1019
1136
|
executeParallel(calls: Array<{
|
|
1020
1137
|
toolCallId: string;
|
|
1021
1138
|
name: string;
|
|
1022
1139
|
args: unknown;
|
|
1023
|
-
}>, ctx: ToolContext, allowedTools?: string[], filterOpts?: ToolFilterOpts, turnAttachments?: _ethosagent_types.Attachment[]): Promise<Array<{
|
|
1140
|
+
}>, ctx: ToolContext, allowedTools?: string[], filterOpts?: ToolFilterOpts, turnAttachments?: _ethosagent_types.Attachment[], filters?: _ethosagent_types.ToolInvocationFilter[]): Promise<Array<{
|
|
1024
1141
|
toolCallId: string;
|
|
1025
1142
|
name: string;
|
|
1026
1143
|
result: ToolResult;
|
|
@@ -1051,4 +1168,4 @@ declare class SsrfError extends Error {
|
|
|
1051
1168
|
*/
|
|
1052
1169
|
declare function validateUrl(urlStr: string, opts?: ValidateUrlOptions): URL;
|
|
1053
1170
|
|
|
1054
|
-
export { type AgentEvent, AgentLoop, type AgentLoopConfig, type AgentLoopObservability, BoundaryEscapeError, type CapabilityBackends, type CapabilityScopeIds, type CapabilityValidationError, ChainedProvider, type ChainedProviderOptions, ClarifyBridge, ClarifyBusyError, ClarifyNoSurfaceError, type ClarifyPresenter, type ClarifyRequestInput, type ClarifyResolvedListener, ClarifyTimedOutNoDefaultError, DefaultContextEngineRegistry, type DefaultContextEngineRegistryOptions, DefaultHookRegistry, DefaultLLMProviderRegistry, DefaultMemoryProviderRegistry, DefaultPersonalityRegistry, DefaultToolRegistry, DefaultToolResultReducerRegistry, DropOldestEngine, type DryRunToolPlan, EagerPrefetchPolicy, FileClarifyStore, InMemoryRequestDumpStore, InMemorySessionStore, type InMemoryToolContextOptions, KNOWN_AGENT_EVENT_TYPES, type KnownAgentEventType, LastWriteWinsPolicy, LazyOnDemandPolicy, NoopMemoryProvider, type PluginFactory, PluginRegistry, ReferencePreservingEngine, type RunOptions, ScopedFetchImpl, ScopedFsImpl, ScopedProcessImpl, ScopedSecretsImpl, type SecretsBackend, SemanticSummaryEngine, SsrfError, type SummarizerFn, type ValidateUrlOptions, applyTemporalDecay, assertWithinBase, buildAttachmentAnnotation, deriveBotKey, estimateMessageTokens, estimateMessagesTokens, estimateTokens, isKnownAgentEvent, makeTestToolContext, parseTemporalBound, redactArgs, resolveCapabilities, stripAnsiEscapes, synthesizeDryRunCapResult, synthesizeDryRunResult, toJournalKey, validateRegistration, validateUrl };
|
|
1171
|
+
export { type AgentEvent, AgentLoop, type AgentLoopConfig, type AgentLoopObservability, BoundaryEscapeError, type CapabilityBackends, type CapabilityScopeIds, type CapabilityValidationError, ChainedProvider, type ChainedProviderOptions, ClarifyBridge, ClarifyBusyError, ClarifyNoSurfaceError, type ClarifyPresenter, type ClarifyRequestInput, type ClarifyResolvedListener, ClarifyTimedOutNoDefaultError, ContextStore, DefaultContextEngineRegistry, type DefaultContextEngineRegistryOptions, DefaultHookRegistry, DefaultLLMProviderRegistry, DefaultMemoryProviderRegistry, DefaultNotificationRouter, DefaultPersonalityRegistry, DefaultToolRegistry, DefaultToolResultReducerRegistry, DropOldestEngine, type DryRunToolPlan, EagerPrefetchPolicy, FileClarifyStore, InMemoryRequestDumpStore, InMemorySessionStore, type InMemoryToolContextOptions, KNOWN_AGENT_EVENT_TYPES, type KnownAgentEventType, LastWriteWinsPolicy, LazyOnDemandPolicy, LocalToolTransport, type LocalToolTransportLiveCtx, NoopMemoryProvider, type PluginFactory, PluginRegistry, ReferencePreservingEngine, type RunOptions, ScopedFetchImpl, ScopedFsImpl, ScopedProcessImpl, ScopedSecretsImpl, type SecretsBackend, SemanticSummaryEngine, SimpleCompletionImpl, SsrfError, type SummarizerFn, type ValidateUrlOptions, applyTemporalDecay, assertWithinBase, buildAttachmentAnnotation, deriveBotKey, estimateMessageTokens, estimateMessagesTokens, estimateTokens, isKnownAgentEvent, makeTestToolContext, parseTemporalBound, redactArgs, resolveCapabilities, stripAnsiEscapes, synthesizeDryRunCapResult, synthesizeDryRunResult, toJournalKey, validateRegistration, validateUrl };
|