@graphorin/core 0.6.0 → 0.7.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/CHANGELOG.md +88 -0
- package/README.md +14 -8
- package/dist/channels/channels.d.ts.map +1 -1
- package/dist/channels/index.d.ts +2 -2
- package/dist/channels/index.js +2 -2
- package/dist/channels/pause.d.ts +47 -2
- package/dist/channels/pause.d.ts.map +1 -1
- package/dist/channels/pause.js +62 -2
- package/dist/channels/pause.js.map +1 -1
- package/dist/contracts/checkpoint-store.d.ts +97 -1
- package/dist/contracts/checkpoint-store.d.ts.map +1 -1
- package/dist/contracts/checkpoint-store.js.map +1 -1
- package/dist/contracts/index.d.ts +5 -5
- package/dist/contracts/index.js +2 -1
- package/dist/contracts/memory-store.d.ts +59 -2
- package/dist/contracts/memory-store.d.ts.map +1 -1
- package/dist/contracts/provider.d.ts +20 -6
- package/dist/contracts/provider.d.ts.map +1 -1
- package/dist/contracts/session-store.d.ts +10 -2
- package/dist/contracts/session-store.d.ts.map +1 -1
- package/dist/contracts/tool.d.ts +75 -1
- package/dist/contracts/tool.d.ts.map +1 -1
- package/dist/contracts/tool.js +57 -0
- package/dist/contracts/tool.js.map +1 -0
- package/dist/contracts/tracer.d.ts +53 -5
- package/dist/contracts/tracer.d.ts.map +1 -1
- package/dist/contracts/tracer.js.map +1 -1
- package/dist/index.d.ts +14 -9
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +11 -7
- package/dist/index.js.map +1 -1
- package/dist/package.js +6 -0
- package/dist/package.js.map +1 -0
- package/dist/types/agent-event-wire.d.ts +74 -0
- package/dist/types/agent-event-wire.d.ts.map +1 -0
- package/dist/types/agent-event-wire.js +130 -0
- package/dist/types/agent-event-wire.js.map +1 -0
- package/dist/types/agent-event.d.ts +48 -6
- package/dist/types/agent-event.d.ts.map +1 -1
- package/dist/types/index.d.ts +3 -2
- package/dist/types/index.js +2 -1
- package/dist/types/memory.d.ts +11 -0
- package/dist/types/memory.d.ts.map +1 -1
- package/dist/types/run.d.ts +86 -4
- package/dist/types/run.d.ts.map +1 -1
- package/dist/types/run.js.map +1 -1
- package/dist/types/tool.d.ts +10 -0
- package/dist/types/tool.d.ts.map +1 -1
- package/dist/types/usage.d.ts +11 -1
- package/dist/types/usage.d.ts.map +1 -1
- package/dist/types/usage.js.map +1 -1
- package/dist/utils/binary-json.d.ts +165 -0
- package/dist/utils/binary-json.d.ts.map +1 -0
- package/dist/utils/binary-json.js +240 -0
- package/dist/utils/binary-json.js.map +1 -0
- package/dist/utils/index.d.ts +2 -1
- package/dist/utils/index.js +2 -1
- package/dist/utils/validation.d.ts +10 -1
- package/dist/utils/validation.d.ts.map +1 -1
- package/dist/utils/validation.js +1 -1
- package/dist/utils/validation.js.map +1 -1
- package/package.json +9 -7
- package/src/channels/channels.ts +206 -0
- package/src/channels/directive.ts +41 -0
- package/src/channels/dispatch.ts +37 -0
- package/src/channels/durable.ts +151 -0
- package/src/channels/index.ts +62 -0
- package/src/channels/pause.ts +216 -0
- package/src/contracts/auth-token-store.ts +42 -0
- package/src/contracts/checkpoint-store.ts +256 -0
- package/src/contracts/embedder.ts +42 -0
- package/src/contracts/eval-scorer.ts +44 -0
- package/src/contracts/index.ts +112 -0
- package/src/contracts/local-provider-trust.ts +33 -0
- package/src/contracts/logger.ts +61 -0
- package/src/contracts/memory-store.ts +187 -0
- package/src/contracts/oauth-server-store.ts +78 -0
- package/src/contracts/preferred-model.ts +56 -0
- package/src/contracts/provider.ts +316 -0
- package/src/contracts/reasoning-retention.ts +52 -0
- package/src/contracts/redaction-validator.ts +56 -0
- package/src/contracts/sandbox.ts +70 -0
- package/src/contracts/secret-ref.ts +22 -0
- package/src/contracts/secret-value.ts +117 -0
- package/src/contracts/secrets-store.ts +90 -0
- package/src/contracts/session-store.ts +163 -0
- package/src/contracts/token-counter.ts +23 -0
- package/src/contracts/tool.ts +397 -0
- package/src/contracts/tracer.ts +219 -0
- package/src/contracts/trigger-store.ts +40 -0
- package/src/index.ts +23 -0
- package/src/types/agent-event-wire.ts +193 -0
- package/src/types/agent-event.ts +579 -0
- package/src/types/handoff.ts +111 -0
- package/src/types/index.ts +148 -0
- package/src/types/memory.ts +427 -0
- package/src/types/message.ts +174 -0
- package/src/types/run.ts +312 -0
- package/src/types/sensitivity.ts +35 -0
- package/src/types/session-scope.ts +18 -0
- package/src/types/stop-condition.ts +108 -0
- package/src/types/tool-call.ts +24 -0
- package/src/types/tool.ts +324 -0
- package/src/types/usage.ts +120 -0
- package/src/types/workflow-event.ts +132 -0
- package/src/utils/assert-never.ts +24 -0
- package/src/utils/async-context.ts +55 -0
- package/src/utils/binary-json.ts +425 -0
- package/src/utils/hash.ts +122 -0
- package/src/utils/index.ts +57 -0
- package/src/utils/streams.ts +233 -0
- package/src/utils/validation.ts +82 -0
package/dist/index.d.ts
CHANGED
|
@@ -2,9 +2,9 @@ import { AnyValue, Barrier, Channel, ChannelKind, Ephemeral, LatestValue, ListAg
|
|
|
2
2
|
import { Directive, DirectiveOptions } from "./channels/directive.js";
|
|
3
3
|
import { Dispatch, dispatch } from "./channels/dispatch.js";
|
|
4
4
|
import { APPROVAL_PAUSE_KIND, AWAKEABLE_PAUSE_KIND, ApprovalPauseValue, AwakeablePauseValue, TIMER_PAUSE_KIND, TimerPauseValue, awaitExternal, isApprovalPauseValue, isAwakeablePauseValue, isTimerPauseValue, requestApproval, sleepFor, sleepUntil } from "./channels/durable.js";
|
|
5
|
-
import { PAUSE_SIGNAL_BRAND, PauseResumeScope, PauseSignal, isPauseSignal, pause, runWithPauseResume } from "./channels/pause.js";
|
|
5
|
+
import { PAUSE_SIGNAL_BRAND, PauseIdentity, PauseResumeScope, PauseSignal, REPLAY_DIVERGENCE_BRAND, ReplayDivergenceSignal, isPauseSignal, isReplayDivergenceSignal, pause, runWithPauseResume } from "./channels/pause.js";
|
|
6
6
|
import { AuthTokenRecord, AuthTokenStore } from "./contracts/auth-token-store.js";
|
|
7
|
-
import { Checkpoint, CheckpointConflictError, CheckpointId, CheckpointMetadata, CheckpointPutOptions, CheckpointStore, CheckpointTuple, ListOptions, PendingWrite } from "./contracts/checkpoint-store.js";
|
|
7
|
+
import { Checkpoint, CheckpointConflictError, CheckpointId, CheckpointMetadata, CheckpointPutOptions, CheckpointStore, CheckpointStoreExt, CheckpointTuple, ListOptions, PendingWrite, PruneThreadsOptions } from "./contracts/checkpoint-store.js";
|
|
8
8
|
import { EmbedOptions, EmbedderProvider } from "./contracts/embedder.js";
|
|
9
9
|
import { EvalSample, EvalScore, EvalScorer } from "./contracts/eval-scorer.js";
|
|
10
10
|
import { LocalProviderTrust, OllamaTrust } from "./contracts/local-provider-trust.js";
|
|
@@ -14,10 +14,10 @@ import { Block, EntityRole, Episode, Fact, GraphEntity, Insight, MemoryHit, Memo
|
|
|
14
14
|
import { ToolCall } from "./types/tool-call.js";
|
|
15
15
|
import { AssistantMessage, AudioContent, FileContent, ImageContent, Message, MessageContent, MessageRole, ReasoningContent, ReasoningContentMeta, SystemMessage, TextContent, ToolMessage, UserMessage } from "./types/message.js";
|
|
16
16
|
import { SessionScope } from "./types/session-scope.js";
|
|
17
|
-
import { EpisodicMemoryStore, MemoryStore, MessageRef, ProceduralMemoryStore, SemanticMemoryStore, SessionListOptions, SessionMemoryStore, SessionMessageWithMetadata, SharedMemoryStore, WorkingMemoryStore } from "./contracts/memory-store.js";
|
|
17
|
+
import { EpisodicMemoryStore, MemoryStore, MemoryStoreExt, MessageRef, ProceduralMemoryStore, SemanticMemoryStore, SessionListOptions, SessionMemoryStore, SessionMessageWithMetadata, SharedMemoryStore, WorkingMemoryStore } from "./contracts/memory-store.js";
|
|
18
18
|
import { OAuthServerRecord, OAuthServerStore } from "./contracts/oauth-server-store.js";
|
|
19
19
|
import { MODEL_HINTS, ModelHint, ModelSpec, ProviderLike } from "./contracts/preferred-model.js";
|
|
20
|
-
import { AISpan, NOOP_TRACER, SpanAttributeValue, SpanAttributes, SpanStatus, SpanType, StartSpanOptions, Tracer } from "./contracts/tracer.js";
|
|
20
|
+
import { AISpan, AddEventOptions, CustomSpanType, KnownSpanType, NOOP_TRACER, SpanAttributeValue, SpanAttributes, SpanStatus, SpanType, StartSpanOptions, Tracer } from "./contracts/tracer.js";
|
|
21
21
|
import { Cost, ModelUsage, Usage, UsageAccumulator, UsageSnapshot, zeroUsage } from "./types/usage.js";
|
|
22
22
|
import { ReasoningContract, ReasoningRetention } from "./contracts/reasoning-retention.js";
|
|
23
23
|
import { ComposeProviderMiddleware, FinishReason, OutputSpec, Provider, ProviderCachePolicy, ProviderCapabilities, ProviderError, ProviderErrorKind, ProviderEvent, ProviderMiddleware, ProviderRequest, ProviderRequestMetadata, ProviderResponse, ResponseMetadata, ToolChoice, ToolDefinition, ToolDefinitionExample } from "./contracts/provider.js";
|
|
@@ -30,11 +30,13 @@ import { Handoff, HandoffFilter, HandoffInputFilterDescriptor, HandoffRecord, Ha
|
|
|
30
30
|
import { AgentRegistryEntry, SessionAuditEntry, SessionMetadata, SessionStore, SessionStoreExt, SessionWorkflowRun } from "./contracts/session-store.js";
|
|
31
31
|
import { TokenCounter } from "./contracts/token-counter.js";
|
|
32
32
|
import { CompletedToolCall, ContentChunk, InboundSanitizationPolicy, MemoryGuardTier, RecoveryHint, ResultHandle, SandboxPolicy, SideEffectClass, ToolApproval, ToolError, ToolErrorKind, ToolOutcome, ToolResult, ToolSource, ToolTrustClass, TruncationStrategy } from "./types/tool.js";
|
|
33
|
-
import { RunContext, RunError, RunState, RunStateUsageByModel, RunStatus, RunStep, RunStepProviderResponse, RunTaintSummary, TodoItem, flattenUsageByModel } from "./types/run.js";
|
|
33
|
+
import { ReadonlyRunState, RunContext, RunError, RunState, RunStateUsageByModel, RunStatus, RunStep, RunStepProviderResponse, RunTaintSummary, TodoItem, flattenUsageByModel } from "./types/run.js";
|
|
34
34
|
import { ValidationResult, ZodLikeError, ZodLikeSafeParseResult, ZodLikeSchema, validate, validateOrThrow } from "./utils/validation.js";
|
|
35
|
-
import { ResolvedTool, Tool, ToolExample, ToolExecutionContext, ToolReturn, ToolSecretsAccessor } from "./contracts/tool.js";
|
|
35
|
+
import { AnyTool, ResolvedTool, TOOL_RETURN_BRAND, Tool, ToolExample, ToolExecutionContext, ToolReturn, ToolSecretsAccessor, isToolReturnEnvelope, isUnbrandedToolReturn, toolReturn } from "./contracts/tool.js";
|
|
36
36
|
import { TriggerState, TriggerStore } from "./contracts/trigger-store.js";
|
|
37
37
|
import { AgentCancellingEvent, AgentEndEvent, AgentErrorEvent, AgentEvaluatorConvergedEvent, AgentEvaluatorIterationEvent, AgentEvent, AgentFanOutMergedEvent, AgentFanOutSpawnedEvent, AgentFollowUpQueuedEvent, AgentLateralLeakDetectedEvent, AgentModelFellbackEvent, AgentProgressReadEvent, AgentProgressWrittenEvent, AgentResult, AgentStartEvent, AgentSteeredEvent, ContextCompactedEvent, FanOutChildMetadata, GuardrailTrippedEvent, HandoffEvent, LateralLeakVector, ProgressArtifactRef, ReasoningDeltaEvent, StepEndEvent, StepStartEvent, TextCompleteEvent, TextDeltaEvent, ToolApprovalDeniedEvent, ToolApprovalGrantedEvent, ToolApprovalRequestedEvent, ToolCallDeltaEvent, ToolCallEndEvent, ToolCallStartEvent, ToolExecuteEndEvent, ToolExecuteErrorEvent, ToolExecutePartialEvent, ToolExecuteProgressEvent, ToolExecuteStartEvent, VerifierResultEvent } from "./types/agent-event.js";
|
|
38
|
+
import { EncodedBinary, EncodedBytes, EncodedUrl, WireAssistantMessage, WireAudioContent, WireCompletedToolCall, WireFileContent, WireImageContent, WireMessage, WireMessageContent, WireRunState, WireRunStep, WireToolMessage, WireToolOutcome, WireToolResult, WireUserMessage, base64ToBytes, bytesToBase64, fromJsonSafeContentParts, fromJsonSafeMessage, fromJsonSafeRunState, toJsonSafeContentParts, toJsonSafeMessage, toJsonSafeRunState } from "./utils/binary-json.js";
|
|
39
|
+
import { WireAgentEndEvent, WireAgentEvent, WireContentChunk, WireFileGeneratedEvent, WireToolExecutePartialEvent, fromWireAgentEvent, toWireAgentEvent } from "./types/agent-event-wire.js";
|
|
38
40
|
import { StopCondition, and, hasToolCall, isStepCount, isTerminal, not, or } from "./types/stop-condition.js";
|
|
39
41
|
import { WorkflowChannelUpdateEvent, WorkflowCheckpointWrittenEvent, WorkflowCustomEvent, WorkflowEndEvent, WorkflowErrorEvent, WorkflowEvent, WorkflowResumedEvent, WorkflowStartEvent, WorkflowStepEndEvent, WorkflowStepStartEvent, WorkflowSuspendedEvent, WorkflowTaskEndEvent, WorkflowTaskStartEvent } from "./types/workflow-event.js";
|
|
40
42
|
import { assertNever } from "./utils/assert-never.js";
|
|
@@ -53,8 +55,11 @@ import { collect, filter, mapStream, merge, take, takeWhile, withSignal } from "
|
|
|
53
55
|
*
|
|
54
56
|
* @packageDocumentation
|
|
55
57
|
*/
|
|
56
|
-
/**
|
|
57
|
-
|
|
58
|
+
/**
|
|
59
|
+
* Canonical version constant, derived from `package.json` at build
|
|
60
|
+
* time so a release bump never has to edit source.
|
|
61
|
+
*/
|
|
62
|
+
declare const VERSION: string;
|
|
58
63
|
//#endregion
|
|
59
|
-
export { AISpan, APPROVAL_PAUSE_KIND, AWAKEABLE_PAUSE_KIND, AgentCancellingEvent, AgentEndEvent, AgentErrorEvent, AgentEvaluatorConvergedEvent, AgentEvaluatorIterationEvent, AgentEvent, AgentFanOutMergedEvent, AgentFanOutSpawnedEvent, AgentFollowUpQueuedEvent, AgentLateralLeakDetectedEvent, AgentModelFellbackEvent, AgentProgressReadEvent, AgentProgressWrittenEvent, AgentRegistryEntry, AgentResult, AgentStartEvent, AgentSteeredEvent, AnyValue, ApprovalPauseValue, AssistantMessage, AsyncContext, AudioContent, AuthTokenRecord, AuthTokenStore, AwakeablePauseValue, Barrier, Block, Channel, ChannelKind, Checkpoint, CheckpointConflictError, CheckpointId, CheckpointMetadata, CheckpointPutOptions, CheckpointStore, CheckpointTuple, CompletedToolCall, ComposeProviderMiddleware, ContentChunk, ContextCompactedEvent, Cost, Directive, DirectiveOptions, Dispatch, EmbedOptions, EmbedderProvider, EntityRole, Ephemeral, Episode, EpisodicMemoryStore, EvalSample, EvalScore, EvalScorer, Fact, FanOutChildMetadata, FileContent, FinishReason, GraphEntity, GuardrailTrippedEvent, Handoff, HandoffEvent, HandoffFilter, HandoffInputFilterDescriptor, HandoffRecord, HandoffSecretsInheritance, ImageContent, InboundSanitizationPolicy, Insight, LateralLeakVector, LatestValue, ListAggregate, ListOptions, LocalProviderTrust, LogFields, LogLevel, Logger, MODEL_HINTS, MemoryGuardTier, MemoryHit, MemoryKind, MemoryMetadata, MemoryOwner, MemoryProvenance, MemoryRecord, MemorySearchOptions, MemoryStatus, MemoryStore, Message, MessageContent, MessageRef, MessageRole, ModelHint, ModelSpec, ModelUsage, NODEJS_INSPECT_CUSTOM, NOOP_LOGGER, NOOP_TRACER, OAuthServerRecord, OAuthServerStore, OllamaTrust, OutputSpec, PAUSE_SIGNAL_BRAND, PauseResumeScope, PauseSignal, PendingWrite, ProceduralMemoryStore, ProgressArtifactRef, Provider, ProviderCachePolicy, ProviderCapabilities, ProviderError, ProviderErrorKind, ProviderEvent, ProviderLike, ProviderMiddleware, ProviderRequest, ProviderRequestMetadata, ProviderResponse, ReasoningContent, ReasoningContentMeta, ReasoningContract, ReasoningDeltaEvent, ReasoningRetention, RecoveryHint, RedactionInput, RedactionOutput, RedactionValidator, Reducer, ResolvedTool, ResponseMetadata, ResultHandle, Rule, RunContext, RunError, RunState, RunStateUsageByModel, RunStatus, RunStep, RunStepProviderResponse, RunTaintSummary, SECRET_VALUE_BRAND, SENSITIVITY_ORDER, Sandbox, SandboxCode, SandboxPolicy, SandboxResult, SandboxRunOptions, SecretMetadata, SecretRef, SecretResolver, SecretResolverContext, SecretValue, SecretValueOptions, SecretValueStatic, SecretsSetOptions, SecretsStore, SemanticMemoryStore, Sensitivity, SessionAuditEntry, SessionListOptions, SessionMemoryStore, SessionMessageWithMetadata, SessionMetadata, SessionScope, SessionStore, SessionStoreExt, SessionWorkflowRun, SharedMemoryStore, SideEffectClass, SpanAttributeValue, SpanAttributes, SpanStatus, SpanType, StartSpanOptions, StepEndEvent, StepStartEvent, StopCondition, Stream, SystemMessage, TIMER_PAUSE_KIND, TextCompleteEvent, TextContent, TextDeltaEvent, TimerPauseValue, TodoItem, TokenCounter, Tool, ToolApproval, ToolApprovalDeniedEvent, ToolApprovalGrantedEvent, ToolApprovalRequestedEvent, ToolCall, ToolCallDeltaEvent, ToolCallEndEvent, ToolCallStartEvent, ToolChoice, ToolDefinition, ToolDefinitionExample, ToolError, ToolErrorKind, ToolExample, ToolExecuteEndEvent, ToolExecuteErrorEvent, ToolExecutePartialEvent, ToolExecuteProgressEvent, ToolExecuteStartEvent, ToolExecutionContext, ToolMessage, ToolOutcome, ToolResult, ToolReturn, ToolSecretsAccessor, ToolSource, ToolTrustClass, Tracer, TriggerState, TriggerStore, TruncationStrategy, Usage, UsageAccumulator, UsageSnapshot, UserMessage, VERSION, ValidationResult, VerifierResultEvent, WorkflowChannelUpdateEvent, WorkflowCheckpointWrittenEvent, WorkflowCustomEvent, WorkflowEndEvent, WorkflowErrorEvent, WorkflowEvent, WorkflowResumedEvent, WorkflowStartEvent, WorkflowStepEndEvent, WorkflowStepStartEvent, WorkflowSuspendedEvent, WorkflowTaskEndEvent, WorkflowTaskStartEvent, WorkingMemoryStore, ZodLikeError, ZodLikeSafeParseResult, ZodLikeSchema, acceptsSensitivity, and, anyValue, assertNever, awaitExternal, barrier, collect, createAsyncContext, dispatch, ephemeral, filter, flattenUsageByModel, hasToolCall, isApprovalPauseValue, isAwakeablePauseValue, isPauseSignal, isStepCount, isTerminal, isTimerPauseValue, latestValue, listAggregate, mapStream, md5, merge, not, or, pause, reducer, requestApproval, runWithPauseResume, sleepFor, sleepUntil, stream, take, takeWhile, validate, validateOrThrow, withSignal, xxhash, zeroUsage };
|
|
64
|
+
export { AISpan, APPROVAL_PAUSE_KIND, AWAKEABLE_PAUSE_KIND, AddEventOptions, AgentCancellingEvent, AgentEndEvent, AgentErrorEvent, AgentEvaluatorConvergedEvent, AgentEvaluatorIterationEvent, AgentEvent, AgentFanOutMergedEvent, AgentFanOutSpawnedEvent, AgentFollowUpQueuedEvent, AgentLateralLeakDetectedEvent, AgentModelFellbackEvent, AgentProgressReadEvent, AgentProgressWrittenEvent, AgentRegistryEntry, AgentResult, AgentStartEvent, AgentSteeredEvent, AnyTool, AnyValue, ApprovalPauseValue, AssistantMessage, AsyncContext, AudioContent, AuthTokenRecord, AuthTokenStore, AwakeablePauseValue, Barrier, Block, Channel, ChannelKind, Checkpoint, CheckpointConflictError, CheckpointId, CheckpointMetadata, CheckpointPutOptions, CheckpointStore, CheckpointStoreExt, CheckpointTuple, CompletedToolCall, ComposeProviderMiddleware, ContentChunk, ContextCompactedEvent, Cost, CustomSpanType, Directive, DirectiveOptions, Dispatch, EmbedOptions, EmbedderProvider, EncodedBinary, EncodedBytes, EncodedUrl, EntityRole, Ephemeral, Episode, EpisodicMemoryStore, EvalSample, EvalScore, EvalScorer, Fact, FanOutChildMetadata, FileContent, FinishReason, GraphEntity, GuardrailTrippedEvent, Handoff, HandoffEvent, HandoffFilter, HandoffInputFilterDescriptor, HandoffRecord, HandoffSecretsInheritance, ImageContent, InboundSanitizationPolicy, Insight, KnownSpanType, LateralLeakVector, LatestValue, ListAggregate, ListOptions, LocalProviderTrust, LogFields, LogLevel, Logger, MODEL_HINTS, MemoryGuardTier, MemoryHit, MemoryKind, MemoryMetadata, MemoryOwner, MemoryProvenance, MemoryRecord, MemorySearchOptions, MemoryStatus, MemoryStore, MemoryStoreExt, Message, MessageContent, MessageRef, MessageRole, ModelHint, ModelSpec, ModelUsage, NODEJS_INSPECT_CUSTOM, NOOP_LOGGER, NOOP_TRACER, OAuthServerRecord, OAuthServerStore, OllamaTrust, OutputSpec, PAUSE_SIGNAL_BRAND, PauseIdentity, PauseResumeScope, PauseSignal, PendingWrite, ProceduralMemoryStore, ProgressArtifactRef, Provider, ProviderCachePolicy, ProviderCapabilities, ProviderError, ProviderErrorKind, ProviderEvent, ProviderLike, ProviderMiddleware, ProviderRequest, ProviderRequestMetadata, ProviderResponse, PruneThreadsOptions, REPLAY_DIVERGENCE_BRAND, ReadonlyRunState, ReasoningContent, ReasoningContentMeta, ReasoningContract, ReasoningDeltaEvent, ReasoningRetention, RecoveryHint, RedactionInput, RedactionOutput, RedactionValidator, Reducer, ReplayDivergenceSignal, ResolvedTool, ResponseMetadata, ResultHandle, Rule, RunContext, RunError, RunState, RunStateUsageByModel, RunStatus, RunStep, RunStepProviderResponse, RunTaintSummary, SECRET_VALUE_BRAND, SENSITIVITY_ORDER, Sandbox, SandboxCode, SandboxPolicy, SandboxResult, SandboxRunOptions, SecretMetadata, SecretRef, SecretResolver, SecretResolverContext, SecretValue, SecretValueOptions, SecretValueStatic, SecretsSetOptions, SecretsStore, SemanticMemoryStore, Sensitivity, SessionAuditEntry, SessionListOptions, SessionMemoryStore, SessionMessageWithMetadata, SessionMetadata, SessionScope, SessionStore, SessionStoreExt, SessionWorkflowRun, SharedMemoryStore, SideEffectClass, SpanAttributeValue, SpanAttributes, SpanStatus, SpanType, StartSpanOptions, StepEndEvent, StepStartEvent, StopCondition, Stream, SystemMessage, TIMER_PAUSE_KIND, TOOL_RETURN_BRAND, TextCompleteEvent, TextContent, TextDeltaEvent, TimerPauseValue, TodoItem, TokenCounter, Tool, ToolApproval, ToolApprovalDeniedEvent, ToolApprovalGrantedEvent, ToolApprovalRequestedEvent, ToolCall, ToolCallDeltaEvent, ToolCallEndEvent, ToolCallStartEvent, ToolChoice, ToolDefinition, ToolDefinitionExample, ToolError, ToolErrorKind, ToolExample, ToolExecuteEndEvent, ToolExecuteErrorEvent, ToolExecutePartialEvent, ToolExecuteProgressEvent, ToolExecuteStartEvent, ToolExecutionContext, ToolMessage, ToolOutcome, ToolResult, ToolReturn, ToolSecretsAccessor, ToolSource, ToolTrustClass, Tracer, TriggerState, TriggerStore, TruncationStrategy, Usage, UsageAccumulator, UsageSnapshot, UserMessage, VERSION, ValidationResult, VerifierResultEvent, WireAgentEndEvent, WireAgentEvent, WireAssistantMessage, WireAudioContent, WireCompletedToolCall, WireContentChunk, WireFileContent, WireFileGeneratedEvent, WireImageContent, WireMessage, WireMessageContent, WireRunState, WireRunStep, WireToolExecutePartialEvent, WireToolMessage, WireToolOutcome, WireToolResult, WireUserMessage, WorkflowChannelUpdateEvent, WorkflowCheckpointWrittenEvent, WorkflowCustomEvent, WorkflowEndEvent, WorkflowErrorEvent, WorkflowEvent, WorkflowResumedEvent, WorkflowStartEvent, WorkflowStepEndEvent, WorkflowStepStartEvent, WorkflowSuspendedEvent, WorkflowTaskEndEvent, WorkflowTaskStartEvent, WorkingMemoryStore, ZodLikeError, ZodLikeSafeParseResult, ZodLikeSchema, acceptsSensitivity, and, anyValue, assertNever, awaitExternal, barrier, base64ToBytes, bytesToBase64, collect, createAsyncContext, dispatch, ephemeral, filter, flattenUsageByModel, fromJsonSafeContentParts, fromJsonSafeMessage, fromJsonSafeRunState, fromWireAgentEvent, hasToolCall, isApprovalPauseValue, isAwakeablePauseValue, isPauseSignal, isReplayDivergenceSignal, isStepCount, isTerminal, isTimerPauseValue, isToolReturnEnvelope, isUnbrandedToolReturn, latestValue, listAggregate, mapStream, md5, merge, not, or, pause, reducer, requestApproval, runWithPauseResume, sleepFor, sleepUntil, stream, take, takeWhile, toJsonSafeContentParts, toJsonSafeMessage, toJsonSafeRunState, toWireAgentEvent, toolReturn, validate, validateOrThrow, withSignal, xxhash, zeroUsage };
|
|
60
65
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/index.ts"],"sourcesContent":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/index.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAiBa"}
|
package/dist/index.js
CHANGED
|
@@ -1,15 +1,17 @@
|
|
|
1
|
+
import { version } from "./package.js";
|
|
1
2
|
import { anyValue, barrier, ephemeral, latestValue, listAggregate, reducer, stream } from "./channels/channels.js";
|
|
2
3
|
import { Directive } from "./channels/directive.js";
|
|
3
4
|
import { Dispatch, dispatch } from "./channels/dispatch.js";
|
|
4
|
-
import { PAUSE_SIGNAL_BRAND, PauseSignal, isPauseSignal, pause, runWithPauseResume } from "./channels/pause.js";
|
|
5
|
+
import { PAUSE_SIGNAL_BRAND, PauseSignal, REPLAY_DIVERGENCE_BRAND, ReplayDivergenceSignal, isPauseSignal, isReplayDivergenceSignal, pause, runWithPauseResume } from "./channels/pause.js";
|
|
5
6
|
import { APPROVAL_PAUSE_KIND, AWAKEABLE_PAUSE_KIND, TIMER_PAUSE_KIND, awaitExternal, isApprovalPauseValue, isAwakeablePauseValue, isTimerPauseValue, requestApproval, sleepFor, sleepUntil } from "./channels/durable.js";
|
|
6
|
-
import "./channels/index.js";
|
|
7
7
|
import { CheckpointConflictError } from "./contracts/checkpoint-store.js";
|
|
8
8
|
import { NOOP_LOGGER } from "./contracts/logger.js";
|
|
9
9
|
import { MODEL_HINTS } from "./contracts/preferred-model.js";
|
|
10
10
|
import { NODEJS_INSPECT_CUSTOM, SECRET_VALUE_BRAND } from "./contracts/secret-value.js";
|
|
11
|
+
import { TOOL_RETURN_BRAND, isToolReturnEnvelope, isUnbrandedToolReturn, toolReturn } from "./contracts/tool.js";
|
|
11
12
|
import { NOOP_TRACER } from "./contracts/tracer.js";
|
|
12
|
-
import "./
|
|
13
|
+
import { base64ToBytes, bytesToBase64, fromJsonSafeContentParts, fromJsonSafeMessage, fromJsonSafeRunState, toJsonSafeContentParts, toJsonSafeMessage, toJsonSafeRunState } from "./utils/binary-json.js";
|
|
14
|
+
import { fromWireAgentEvent, toWireAgentEvent } from "./types/agent-event-wire.js";
|
|
13
15
|
import { flattenUsageByModel } from "./types/run.js";
|
|
14
16
|
import { SENSITIVITY_ORDER, acceptsSensitivity } from "./types/sensitivity.js";
|
|
15
17
|
import { and, hasToolCall, isStepCount, isTerminal, not, or } from "./types/stop-condition.js";
|
|
@@ -19,7 +21,6 @@ import { createAsyncContext } from "./utils/async-context.js";
|
|
|
19
21
|
import { md5, xxhash } from "./utils/hash.js";
|
|
20
22
|
import { collect, filter, mapStream, merge, take, takeWhile, withSignal } from "./utils/streams.js";
|
|
21
23
|
import { validate, validateOrThrow } from "./utils/validation.js";
|
|
22
|
-
import "./utils/index.js";
|
|
23
24
|
|
|
24
25
|
//#region src/index.ts
|
|
25
26
|
/**
|
|
@@ -32,9 +33,12 @@ import "./utils/index.js";
|
|
|
32
33
|
*
|
|
33
34
|
* @packageDocumentation
|
|
34
35
|
*/
|
|
35
|
-
/**
|
|
36
|
-
|
|
36
|
+
/**
|
|
37
|
+
* Canonical version constant, derived from `package.json` at build
|
|
38
|
+
* time so a release bump never has to edit source.
|
|
39
|
+
*/
|
|
40
|
+
const VERSION = version;
|
|
37
41
|
|
|
38
42
|
//#endregion
|
|
39
|
-
export { APPROVAL_PAUSE_KIND, AWAKEABLE_PAUSE_KIND, CheckpointConflictError, Directive, Dispatch, MODEL_HINTS, NODEJS_INSPECT_CUSTOM, NOOP_LOGGER, NOOP_TRACER, PAUSE_SIGNAL_BRAND, PauseSignal, SECRET_VALUE_BRAND, SENSITIVITY_ORDER, TIMER_PAUSE_KIND, VERSION, acceptsSensitivity, and, anyValue, assertNever, awaitExternal, barrier, collect, createAsyncContext, dispatch, ephemeral, filter, flattenUsageByModel, hasToolCall, isApprovalPauseValue, isAwakeablePauseValue, isPauseSignal, isStepCount, isTerminal, isTimerPauseValue, latestValue, listAggregate, mapStream, md5, merge, not, or, pause, reducer, requestApproval, runWithPauseResume, sleepFor, sleepUntil, stream, take, takeWhile, validate, validateOrThrow, withSignal, xxhash, zeroUsage };
|
|
43
|
+
export { APPROVAL_PAUSE_KIND, AWAKEABLE_PAUSE_KIND, CheckpointConflictError, Directive, Dispatch, MODEL_HINTS, NODEJS_INSPECT_CUSTOM, NOOP_LOGGER, NOOP_TRACER, PAUSE_SIGNAL_BRAND, PauseSignal, REPLAY_DIVERGENCE_BRAND, ReplayDivergenceSignal, SECRET_VALUE_BRAND, SENSITIVITY_ORDER, TIMER_PAUSE_KIND, TOOL_RETURN_BRAND, VERSION, acceptsSensitivity, and, anyValue, assertNever, awaitExternal, barrier, base64ToBytes, bytesToBase64, collect, createAsyncContext, dispatch, ephemeral, filter, flattenUsageByModel, fromJsonSafeContentParts, fromJsonSafeMessage, fromJsonSafeRunState, fromWireAgentEvent, hasToolCall, isApprovalPauseValue, isAwakeablePauseValue, isPauseSignal, isReplayDivergenceSignal, isStepCount, isTerminal, isTimerPauseValue, isToolReturnEnvelope, isUnbrandedToolReturn, latestValue, listAggregate, mapStream, md5, merge, not, or, pause, reducer, requestApproval, runWithPauseResume, sleepFor, sleepUntil, stream, take, takeWhile, toJsonSafeContentParts, toJsonSafeMessage, toJsonSafeRunState, toWireAgentEvent, toolReturn, validate, validateOrThrow, withSignal, xxhash, zeroUsage };
|
|
40
44
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["/**\n * @graphorin/core - types, contracts, and utilities for the Graphorin\n * framework. Dependency-free root package every other `@graphorin/*`\n * package depends on.\n *\n * The full documentation lives in the package `README.md` and the\n * sub-module barrels (`./types`, `./contracts`, `./utils`, `./channels`).\n *\n * @packageDocumentation\n */\n\n
|
|
1
|
+
{"version":3,"file":"index.js","names":["VERSION: string","pkg.version"],"sources":["../src/index.ts"],"sourcesContent":["/**\n * @graphorin/core - types, contracts, and utilities for the Graphorin\n * framework. Dependency-free root package every other `@graphorin/*`\n * package depends on.\n *\n * The full documentation lives in the package `README.md` and the\n * sub-module barrels (`./types`, `./contracts`, `./utils`, `./channels`).\n *\n * @packageDocumentation\n */\n\nimport pkg from '../package.json' with { type: 'json' };\n\n/**\n * Canonical version constant, derived from `package.json` at build\n * time so a release bump never has to edit source.\n */\nexport const VERSION: string = pkg.version;\n\nexport * from './channels/index.js';\nexport * from './contracts/index.js';\nexport * from './types/index.js';\nexport * from './utils/index.js';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiBA,MAAaA,UAAkBC"}
|
package/dist/package.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"package.js","names":[],"sources":["../package.json"],"sourcesContent":["{\n \"name\": \"@graphorin/core\",\n \"version\": \"0.7.0\",\n \"description\": \"Core types, contracts, and utilities for the Graphorin framework. Dependency-free root package every other @graphorin/* package depends on.\",\n \"license\": \"MIT\",\n \"author\": \"Oleksiy Stepurenko\",\n \"homepage\": \"https://github.com/o-stepper/graphorin/tree/main/packages/core\",\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"git+https://github.com/o-stepper/graphorin.git\",\n \"directory\": \"packages/core\"\n },\n \"bugs\": {\n \"url\": \"https://github.com/o-stepper/graphorin/issues\"\n },\n \"keywords\": [\n \"graphorin\",\n \"ai\",\n \"agents\",\n \"framework\",\n \"types\",\n \"contracts\"\n ],\n \"type\": \"module\",\n \"sideEffects\": false,\n \"engines\": {\n \"node\": \">=22.12.0\"\n },\n \"main\": \"./dist/index.js\",\n \"module\": \"./dist/index.js\",\n \"types\": \"./dist/index.d.ts\",\n \"exports\": {\n \".\": {\n \"types\": \"./dist/index.d.ts\",\n \"default\": \"./dist/index.js\"\n },\n \"./types\": {\n \"types\": \"./dist/types/index.d.ts\",\n \"default\": \"./dist/types/index.js\"\n },\n \"./contracts\": {\n \"types\": \"./dist/contracts/index.d.ts\",\n \"default\": \"./dist/contracts/index.js\"\n },\n \"./utils\": {\n \"types\": \"./dist/utils/index.d.ts\",\n \"default\": \"./dist/utils/index.js\"\n },\n \"./channels\": {\n \"types\": \"./dist/channels/index.d.ts\",\n \"default\": \"./dist/channels/index.js\"\n },\n \"./package.json\": \"./package.json\"\n },\n \"files\": [\n \"dist\",\n \"src\",\n \"README.md\",\n \"CHANGELOG.md\",\n \"LICENSE\"\n ],\n \"scripts\": {\n \"build\": \"tsdown\",\n \"typecheck\": \"tsc --noEmit && tsc -p tsconfig.tests.json\",\n \"test\": \"vitest run\",\n \"lint\": \"biome check .\",\n \"clean\": \"rimraf dist .turbo *.tsbuildinfo\"\n },\n \"peerDependencies\": {\n \"zod\": \"^3.23.0 || ^4.0.0\"\n },\n \"peerDependenciesMeta\": {\n \"zod\": {\n \"optional\": false\n }\n },\n \"publishConfig\": {\n \"access\": \"public\",\n \"provenance\": true\n },\n \"devDependencies\": {\n \"zod\": \"^3.25.0\"\n }\n}\n"],"mappings":";cAEa"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { ContentChunk } from "./tool.js";
|
|
2
|
+
import { AgentEndEvent, AgentEvent, AgentResult, FileGeneratedEvent, SubagentEvent, ToolExecutePartialEvent } from "./agent-event.js";
|
|
3
|
+
import { EncodedBytes, WireRunState } from "../utils/binary-json.js";
|
|
4
|
+
|
|
5
|
+
//#region src/types/agent-event-wire.d.ts
|
|
6
|
+
|
|
7
|
+
/** Wire twin of the binary {@link ContentChunk} variant. @stable */
|
|
8
|
+
type WireContentChunk = Exclude<ContentChunk, {
|
|
9
|
+
readonly kind: 'image';
|
|
10
|
+
}> | {
|
|
11
|
+
readonly kind: 'image';
|
|
12
|
+
readonly data: EncodedBytes;
|
|
13
|
+
readonly mediaType: string;
|
|
14
|
+
};
|
|
15
|
+
/** Wire twin of `FileGeneratedEvent`. @stable */
|
|
16
|
+
interface WireFileGeneratedEvent extends Omit<FileGeneratedEvent, 'data'> {
|
|
17
|
+
readonly data: EncodedBytes;
|
|
18
|
+
}
|
|
19
|
+
/** Wire twin of {@link ToolExecutePartialEvent}. @stable */
|
|
20
|
+
interface WireToolExecutePartialEvent extends Omit<ToolExecutePartialEvent, 'chunk'> {
|
|
21
|
+
readonly chunk: WireContentChunk;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Wire twin of {@link AgentEndEvent}: `result.state` is the JSON-safe
|
|
25
|
+
* {@link WireRunState} projection.
|
|
26
|
+
*
|
|
27
|
+
* @stable
|
|
28
|
+
*/
|
|
29
|
+
interface WireAgentEndEvent<TOutput = string> extends Omit<AgentEndEvent<TOutput>, 'result'> {
|
|
30
|
+
readonly result: Omit<AgentResult<TOutput>, 'state'> & {
|
|
31
|
+
readonly state: WireRunState;
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* JSON-safe twin of {@link AgentEvent}: the three binary-bearing
|
|
36
|
+
* variants are replaced by their wire twins, every other variant
|
|
37
|
+
* passes through structurally unchanged.
|
|
38
|
+
*
|
|
39
|
+
* This is the actual payload shape a server puts on the wire (inside
|
|
40
|
+
* the `{ eventId, subject, type, payload }` envelope) - see
|
|
41
|
+
* {@link toWireAgentEvent}.
|
|
42
|
+
*
|
|
43
|
+
* @stable
|
|
44
|
+
*/
|
|
45
|
+
/**
|
|
46
|
+
* Wire twin of {@link SubagentEvent} (W-036): the wrapped child event
|
|
47
|
+
* projects recursively - a forwarded child `agent.end` carries a full
|
|
48
|
+
* `RunState` of its own.
|
|
49
|
+
*
|
|
50
|
+
* @stable
|
|
51
|
+
*/
|
|
52
|
+
interface WireSubagentEvent extends Omit<SubagentEvent, 'event'> {
|
|
53
|
+
readonly event: WireAgentEvent<unknown>;
|
|
54
|
+
}
|
|
55
|
+
type WireAgentEvent<TOutput = string> = Exclude<AgentEvent<TOutput>, FileGeneratedEvent | ToolExecutePartialEvent | AgentEndEvent<TOutput> | SubagentEvent> | WireFileGeneratedEvent | WireToolExecutePartialEvent | WireSubagentEvent | WireAgentEndEvent<TOutput>;
|
|
56
|
+
/**
|
|
57
|
+
* Project an {@link AgentEvent} into its JSON-safe {@link WireAgentEvent}
|
|
58
|
+
* twin. Idempotent: projecting an already-wire event returns an
|
|
59
|
+
* equivalent value. Events of unknown `type` pass through untouched.
|
|
60
|
+
*
|
|
61
|
+
* @stable
|
|
62
|
+
*/
|
|
63
|
+
declare function toWireAgentEvent<TOutput = string>(ev: AgentEvent<TOutput> | WireAgentEvent<TOutput>): WireAgentEvent<TOutput>;
|
|
64
|
+
/**
|
|
65
|
+
* Inverse of {@link toWireAgentEvent}: decode base64 envelopes back
|
|
66
|
+
* into `Uint8Array` / `URL` instances. Exposed for `@graphorin/client`
|
|
67
|
+
* consumers that want runtime types back after `JSON.parse`.
|
|
68
|
+
*
|
|
69
|
+
* @stable
|
|
70
|
+
*/
|
|
71
|
+
declare function fromWireAgentEvent<TOutput = string>(ev: WireAgentEvent<TOutput> | AgentEvent<TOutput>): AgentEvent<TOutput>;
|
|
72
|
+
//#endregion
|
|
73
|
+
export { WireAgentEndEvent, WireAgentEvent, WireContentChunk, WireFileGeneratedEvent, WireToolExecutePartialEvent, fromWireAgentEvent, toWireAgentEvent };
|
|
74
|
+
//# sourceMappingURL=agent-event-wire.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-event-wire.d.ts","names":[],"sources":["../../src/types/agent-event-wire.ts"],"sourcesContent":[],"mappings":";;;;;;AAyDA;AAC6B,KArBjB,gBAAA,GACR,OAoByB,CApBjB,YAoBiB,EAAA;EAAd,SAAA,IAAA,EAAA,OAAA;CACqB,CAAA,GAAA;EAAZ,SAAA,IAAA,EAAA,OAAA;EAAL,SAAA,IAAA,EApB0B,YAoB1B;EAAwD,SAAA,SAAA,EAAA,MAAA;CADjE;;AAsBO,UAtCA,sBAAA,SAA+B,IAsCb,CAtCkB,kBAsClB,EAAA,MAAA,CAAA,CAAA;EAAa,SAAA,IAAA,EArC/B,YAqC+B;;;AAAD,UAjC9B,2BAAA,SAAoC,IAiCN,CAjCW,uBAiCX,EAAA,OAAA,CAAA,CAAA;EAInC,SAAA,KAAA,EApCM,gBAoCQ;;;;;;;;AACtB,UA5Ba,iBA4Bb,CAAA,UAAA,MAAA,CAAA,SA3BM,IA2BN,CA3BW,aA2BX,CA3ByB,OA2BzB,CAAA,EAAA,QAAA,CAAA,CAAA;EAIA,SAAA,MAAA,EA9Be,IA8Bf,CA9BoB,WA8BpB,CA9BgC,OA8BhC,CAAA,EAAA,OAAA,CAAA,GAAA;IACA,SAAA,KAAA,EA/BuE,YA+BvE;EACA,CAAA;;;;AAwCJ;;;;;;;;AAkCA;;;;;;;;UArFiB,iBAAA,SAA0B,KAAK;kBAC9B;;KAGN,mCACR,QACE,WAAW,UACX,qBAAqB,0BAA0B,cAAc,WAAW,iBAE1E,yBACA,8BACA,oBACA,kBAAkB;;;;;;;;iBAuCN,uCACV,WAAW,WAAW,eAAe,WACxC,eAAe;;;;;;;;iBAgCF,yCACV,eAAe,WAAW,WAAW,WACxC,WAAW"}
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import { base64ToBytes, bytesToBase64, fromJsonSafeRunState, toJsonSafeRunState } from "../utils/binary-json.js";
|
|
2
|
+
|
|
3
|
+
//#region src/types/agent-event-wire.ts
|
|
4
|
+
/**
|
|
5
|
+
* JSON-safe wire projection of {@link AgentEvent} (W-046).
|
|
6
|
+
*
|
|
7
|
+
* Three `AgentEvent` variants carry payloads that `JSON.stringify`
|
|
8
|
+
* corrupts: `file.generated` (`data: Uint8Array`),
|
|
9
|
+
* `tool.execute.partial` (binary `ContentChunk`) and - the bulk -
|
|
10
|
+
* `agent.end`, whose `result.state: RunState` embeds multimodal
|
|
11
|
+
* messages and tool-outcome `contentParts`. The wire twins below
|
|
12
|
+
* project those payloads through the binary codec so a server can
|
|
13
|
+
* `JSON.stringify` any event without silently mangling it.
|
|
14
|
+
*
|
|
15
|
+
* `AgentResult.output` (`TOutput`) is assumed JSON-safe already
|
|
16
|
+
* (a string, or a value parsed from JSON structured output) - the
|
|
17
|
+
* projection does not touch it.
|
|
18
|
+
*
|
|
19
|
+
* @packageDocumentation
|
|
20
|
+
*/
|
|
21
|
+
function isRecord(v) {
|
|
22
|
+
return typeof v === "object" && v !== null && !Array.isArray(v);
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Registry-hosted agents are structurally typed and may emit an
|
|
26
|
+
* `agent.end` without a full `result.state` (e.g. plain `{ status,
|
|
27
|
+
* output }`). Only a state that actually carries the walked arrays is
|
|
28
|
+
* projected; anything else passes through untouched.
|
|
29
|
+
*/
|
|
30
|
+
function hasProjectableState(result) {
|
|
31
|
+
if (!isRecord(result)) return false;
|
|
32
|
+
const state = result.state;
|
|
33
|
+
return isRecord(state) && Array.isArray(state.messages) && Array.isArray(state.steps);
|
|
34
|
+
}
|
|
35
|
+
function encodeBytesField(data) {
|
|
36
|
+
if (data instanceof Uint8Array) return {
|
|
37
|
+
enc: "base64",
|
|
38
|
+
data: bytesToBase64(data)
|
|
39
|
+
};
|
|
40
|
+
return data;
|
|
41
|
+
}
|
|
42
|
+
function decodeBytesField(data) {
|
|
43
|
+
if (data instanceof Uint8Array) return data;
|
|
44
|
+
if (isRecord(data) && data.enc === "base64" && typeof data.data === "string") return base64ToBytes(data.data);
|
|
45
|
+
return new Uint8Array(0);
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Project an {@link AgentEvent} into its JSON-safe {@link WireAgentEvent}
|
|
49
|
+
* twin. Idempotent: projecting an already-wire event returns an
|
|
50
|
+
* equivalent value. Events of unknown `type` pass through untouched.
|
|
51
|
+
*
|
|
52
|
+
* @stable
|
|
53
|
+
*/
|
|
54
|
+
function toWireAgentEvent(ev) {
|
|
55
|
+
switch (ev.type) {
|
|
56
|
+
case "file.generated": return {
|
|
57
|
+
...ev,
|
|
58
|
+
data: encodeBytesField(ev.data)
|
|
59
|
+
};
|
|
60
|
+
case "tool.execute.partial": {
|
|
61
|
+
const chunk = ev.chunk;
|
|
62
|
+
if (chunk.kind === "image") return {
|
|
63
|
+
...ev,
|
|
64
|
+
chunk: {
|
|
65
|
+
...chunk,
|
|
66
|
+
data: encodeBytesField(chunk.data)
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
return ev;
|
|
70
|
+
}
|
|
71
|
+
case "agent.end":
|
|
72
|
+
if (!hasProjectableState(ev.result)) return ev;
|
|
73
|
+
return {
|
|
74
|
+
...ev,
|
|
75
|
+
result: {
|
|
76
|
+
...ev.result,
|
|
77
|
+
state: toJsonSafeRunState(ev.result.state)
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
case "subagent.event": return {
|
|
81
|
+
...ev,
|
|
82
|
+
event: toWireAgentEvent(ev.event)
|
|
83
|
+
};
|
|
84
|
+
default: return ev;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Inverse of {@link toWireAgentEvent}: decode base64 envelopes back
|
|
89
|
+
* into `Uint8Array` / `URL` instances. Exposed for `@graphorin/client`
|
|
90
|
+
* consumers that want runtime types back after `JSON.parse`.
|
|
91
|
+
*
|
|
92
|
+
* @stable
|
|
93
|
+
*/
|
|
94
|
+
function fromWireAgentEvent(ev) {
|
|
95
|
+
switch (ev.type) {
|
|
96
|
+
case "file.generated": return {
|
|
97
|
+
...ev,
|
|
98
|
+
data: decodeBytesField(ev.data)
|
|
99
|
+
};
|
|
100
|
+
case "tool.execute.partial": {
|
|
101
|
+
const chunk = ev.chunk;
|
|
102
|
+
if (chunk.kind === "image") return {
|
|
103
|
+
...ev,
|
|
104
|
+
chunk: {
|
|
105
|
+
...chunk,
|
|
106
|
+
data: decodeBytesField(chunk.data)
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
return ev;
|
|
110
|
+
}
|
|
111
|
+
case "agent.end":
|
|
112
|
+
if (!hasProjectableState(ev.result)) return ev;
|
|
113
|
+
return {
|
|
114
|
+
...ev,
|
|
115
|
+
result: {
|
|
116
|
+
...ev.result,
|
|
117
|
+
state: fromJsonSafeRunState(ev.result.state)
|
|
118
|
+
}
|
|
119
|
+
};
|
|
120
|
+
case "subagent.event": return {
|
|
121
|
+
...ev,
|
|
122
|
+
event: fromWireAgentEvent(ev.event)
|
|
123
|
+
};
|
|
124
|
+
default: return ev;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
//#endregion
|
|
129
|
+
export { fromWireAgentEvent, toWireAgentEvent };
|
|
130
|
+
//# sourceMappingURL=agent-event-wire.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-event-wire.js","names":[],"sources":["../../src/types/agent-event-wire.ts"],"sourcesContent":["/**\n * JSON-safe wire projection of {@link AgentEvent} (W-046).\n *\n * Three `AgentEvent` variants carry payloads that `JSON.stringify`\n * corrupts: `file.generated` (`data: Uint8Array`),\n * `tool.execute.partial` (binary `ContentChunk`) and - the bulk -\n * `agent.end`, whose `result.state: RunState` embeds multimodal\n * messages and tool-outcome `contentParts`. The wire twins below\n * project those payloads through the binary codec so a server can\n * `JSON.stringify` any event without silently mangling it.\n *\n * `AgentResult.output` (`TOutput`) is assumed JSON-safe already\n * (a string, or a value parsed from JSON structured output) - the\n * projection does not touch it.\n *\n * @packageDocumentation\n */\n\nimport {\n base64ToBytes,\n bytesToBase64,\n type EncodedBytes,\n fromJsonSafeRunState,\n toJsonSafeRunState,\n type WireRunState,\n} from '../utils/binary-json.js';\nimport type {\n AgentEndEvent,\n AgentEvent,\n AgentResult,\n FileGeneratedEvent,\n SubagentEvent,\n ToolExecutePartialEvent,\n} from './agent-event.js';\nimport type { ContentChunk } from './tool.js';\n\n/** Wire twin of the binary {@link ContentChunk} variant. @stable */\nexport type WireContentChunk =\n | Exclude<ContentChunk, { readonly kind: 'image' }>\n | { readonly kind: 'image'; readonly data: EncodedBytes; readonly mediaType: string };\n\n/** Wire twin of `FileGeneratedEvent`. @stable */\nexport interface WireFileGeneratedEvent extends Omit<FileGeneratedEvent, 'data'> {\n readonly data: EncodedBytes;\n}\n\n/** Wire twin of {@link ToolExecutePartialEvent}. @stable */\nexport interface WireToolExecutePartialEvent extends Omit<ToolExecutePartialEvent, 'chunk'> {\n readonly chunk: WireContentChunk;\n}\n\n/**\n * Wire twin of {@link AgentEndEvent}: `result.state` is the JSON-safe\n * {@link WireRunState} projection.\n *\n * @stable\n */\nexport interface WireAgentEndEvent<TOutput = string>\n extends Omit<AgentEndEvent<TOutput>, 'result'> {\n readonly result: Omit<AgentResult<TOutput>, 'state'> & { readonly state: WireRunState };\n}\n\n/**\n * JSON-safe twin of {@link AgentEvent}: the three binary-bearing\n * variants are replaced by their wire twins, every other variant\n * passes through structurally unchanged.\n *\n * This is the actual payload shape a server puts on the wire (inside\n * the `{ eventId, subject, type, payload }` envelope) - see\n * {@link toWireAgentEvent}.\n *\n * @stable\n */\n/**\n * Wire twin of {@link SubagentEvent} (W-036): the wrapped child event\n * projects recursively - a forwarded child `agent.end` carries a full\n * `RunState` of its own.\n *\n * @stable\n */\nexport interface WireSubagentEvent extends Omit<SubagentEvent, 'event'> {\n readonly event: WireAgentEvent<unknown>;\n}\n\nexport type WireAgentEvent<TOutput = string> =\n | Exclude<\n AgentEvent<TOutput>,\n FileGeneratedEvent | ToolExecutePartialEvent | AgentEndEvent<TOutput> | SubagentEvent\n >\n | WireFileGeneratedEvent\n | WireToolExecutePartialEvent\n | WireSubagentEvent\n | WireAgentEndEvent<TOutput>;\n\nfunction isRecord(v: unknown): v is Record<string, unknown> {\n return typeof v === 'object' && v !== null && !Array.isArray(v);\n}\n\n/**\n * Registry-hosted agents are structurally typed and may emit an\n * `agent.end` without a full `result.state` (e.g. plain `{ status,\n * output }`). Only a state that actually carries the walked arrays is\n * projected; anything else passes through untouched.\n */\nfunction hasProjectableState(result: unknown): result is { state: { messages: unknown[] } } {\n if (!isRecord(result)) return false;\n const state = result.state;\n return isRecord(state) && Array.isArray(state.messages) && Array.isArray(state.steps);\n}\n\nfunction encodeBytesField(data: Uint8Array | EncodedBytes): EncodedBytes {\n if (data instanceof Uint8Array) return { enc: 'base64', data: bytesToBase64(data) };\n return data;\n}\n\nfunction decodeBytesField(data: EncodedBytes | Uint8Array | unknown): Uint8Array {\n if (data instanceof Uint8Array) return data;\n if (isRecord(data) && data.enc === 'base64' && typeof data.data === 'string') {\n return base64ToBytes(data.data);\n }\n // Unrecoverable legacy shape - degrade to empty bytes rather than throw.\n return new Uint8Array(0);\n}\n\n/**\n * Project an {@link AgentEvent} into its JSON-safe {@link WireAgentEvent}\n * twin. Idempotent: projecting an already-wire event returns an\n * equivalent value. Events of unknown `type` pass through untouched.\n *\n * @stable\n */\nexport function toWireAgentEvent<TOutput = string>(\n ev: AgentEvent<TOutput> | WireAgentEvent<TOutput>,\n): WireAgentEvent<TOutput> {\n switch (ev.type) {\n case 'file.generated':\n return { ...ev, data: encodeBytesField(ev.data) };\n case 'tool.execute.partial': {\n const chunk = ev.chunk;\n if (chunk.kind === 'image') {\n return { ...ev, chunk: { ...chunk, data: encodeBytesField(chunk.data) } };\n }\n return ev as WireAgentEvent<TOutput>;\n }\n case 'agent.end':\n if (!hasProjectableState(ev.result)) return ev as WireAgentEvent<TOutput>;\n return {\n ...ev,\n result: { ...ev.result, state: toJsonSafeRunState(ev.result.state) },\n };\n case 'subagent.event':\n // W-036: the wrapped child event projects recursively.\n return { ...ev, event: toWireAgentEvent(ev.event) };\n default:\n return ev as WireAgentEvent<TOutput>;\n }\n}\n\n/**\n * Inverse of {@link toWireAgentEvent}: decode base64 envelopes back\n * into `Uint8Array` / `URL` instances. Exposed for `@graphorin/client`\n * consumers that want runtime types back after `JSON.parse`.\n *\n * @stable\n */\nexport function fromWireAgentEvent<TOutput = string>(\n ev: WireAgentEvent<TOutput> | AgentEvent<TOutput>,\n): AgentEvent<TOutput> {\n switch (ev.type) {\n case 'file.generated':\n return { ...ev, data: decodeBytesField(ev.data) };\n case 'tool.execute.partial': {\n const chunk = ev.chunk;\n if (chunk.kind === 'image') {\n return { ...ev, chunk: { ...chunk, data: decodeBytesField(chunk.data) } };\n }\n return ev as AgentEvent<TOutput>;\n }\n case 'agent.end':\n if (!hasProjectableState(ev.result)) return ev as AgentEvent<TOutput>;\n return {\n ...ev,\n result: {\n ...ev.result,\n state: fromJsonSafeRunState(ev.result.state as unknown as WireRunState),\n },\n } as AgentEvent<TOutput>;\n case 'subagent.event':\n return { ...ev, event: fromWireAgentEvent(ev.event) } as AgentEvent<TOutput>;\n default:\n return ev as AgentEvent<TOutput>;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AA8FA,SAAS,SAAS,GAA0C;AAC1D,QAAO,OAAO,MAAM,YAAY,MAAM,QAAQ,CAAC,MAAM,QAAQ,EAAE;;;;;;;;AASjE,SAAS,oBAAoB,QAA+D;AAC1F,KAAI,CAAC,SAAS,OAAO,CAAE,QAAO;CAC9B,MAAM,QAAQ,OAAO;AACrB,QAAO,SAAS,MAAM,IAAI,MAAM,QAAQ,MAAM,SAAS,IAAI,MAAM,QAAQ,MAAM,MAAM;;AAGvF,SAAS,iBAAiB,MAA+C;AACvE,KAAI,gBAAgB,WAAY,QAAO;EAAE,KAAK;EAAU,MAAM,cAAc,KAAK;EAAE;AACnF,QAAO;;AAGT,SAAS,iBAAiB,MAAuD;AAC/E,KAAI,gBAAgB,WAAY,QAAO;AACvC,KAAI,SAAS,KAAK,IAAI,KAAK,QAAQ,YAAY,OAAO,KAAK,SAAS,SAClE,QAAO,cAAc,KAAK,KAAK;AAGjC,QAAO,IAAI,WAAW,EAAE;;;;;;;;;AAU1B,SAAgB,iBACd,IACyB;AACzB,SAAQ,GAAG,MAAX;EACE,KAAK,iBACH,QAAO;GAAE,GAAG;GAAI,MAAM,iBAAiB,GAAG,KAAK;GAAE;EACnD,KAAK,wBAAwB;GAC3B,MAAM,QAAQ,GAAG;AACjB,OAAI,MAAM,SAAS,QACjB,QAAO;IAAE,GAAG;IAAI,OAAO;KAAE,GAAG;KAAO,MAAM,iBAAiB,MAAM,KAAK;KAAE;IAAE;AAE3E,UAAO;;EAET,KAAK;AACH,OAAI,CAAC,oBAAoB,GAAG,OAAO,CAAE,QAAO;AAC5C,UAAO;IACL,GAAG;IACH,QAAQ;KAAE,GAAG,GAAG;KAAQ,OAAO,mBAAmB,GAAG,OAAO,MAAM;KAAE;IACrE;EACH,KAAK,iBAEH,QAAO;GAAE,GAAG;GAAI,OAAO,iBAAiB,GAAG,MAAM;GAAE;EACrD,QACE,QAAO;;;;;;;;;;AAWb,SAAgB,mBACd,IACqB;AACrB,SAAQ,GAAG,MAAX;EACE,KAAK,iBACH,QAAO;GAAE,GAAG;GAAI,MAAM,iBAAiB,GAAG,KAAK;GAAE;EACnD,KAAK,wBAAwB;GAC3B,MAAM,QAAQ,GAAG;AACjB,OAAI,MAAM,SAAS,QACjB,QAAO;IAAE,GAAG;IAAI,OAAO;KAAE,GAAG;KAAO,MAAM,iBAAiB,MAAM,KAAK;KAAE;IAAE;AAE3E,UAAO;;EAET,KAAK;AACH,OAAI,CAAC,oBAAoB,GAAG,OAAO,CAAE,QAAO;AAC5C,UAAO;IACL,GAAG;IACH,QAAQ;KACN,GAAG,GAAG;KACN,OAAO,qBAAqB,GAAG,OAAO,MAAiC;KACxE;IACF;EACH,KAAK,iBACH,QAAO;GAAE,GAAG;GAAI,OAAO,mBAAmB,GAAG,MAAM;GAAE;EACvD,QACE,QAAO"}
|
|
@@ -11,14 +11,44 @@ import { RunError, RunState, RunStatus } from "./run.js";
|
|
|
11
11
|
* union is exhaustive: `assertNever(...)` catches missed variants at
|
|
12
12
|
* compile time.
|
|
13
13
|
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
14
|
+
* Wire contract (two layers): the server delivers events inside an
|
|
15
|
+
* envelope `{ eventId, subject, type, payload }` where `payload` is the
|
|
16
|
+
* JSON-safe `WireAgentEvent` projection (`toWireAgentEvent`), NOT this
|
|
17
|
+
* raw union - three variants (`file.generated`, `tool.execute.partial`,
|
|
18
|
+
* `agent.end`) carry `Uint8Array`/`URL` payloads that plain
|
|
19
|
+
* `JSON.stringify` would corrupt. `@graphorin/protocol` validates the
|
|
20
|
+
* envelope and leaves `payload` opaque (`z.unknown()`); clients decode
|
|
21
|
+
* with `fromWireAgentEvent`. Adding a variant here counts as a
|
|
22
|
+
* wire-format change; track it through changesets.
|
|
23
|
+
*
|
|
24
|
+
* Correlation policy (W-049): events are consumed from a per-run
|
|
25
|
+
* stream, so cross-run attribution is the ENVELOPE's job (`subject`
|
|
26
|
+
* carries `agentId`/`runId`); an in-payload `runId` exists only on the
|
|
27
|
+
* variants that historically carry one and is deliberately NOT
|
|
28
|
+
* retrofitted onto the rest. Within one tool lifecycle the correlation
|
|
29
|
+
* key is `toolCallId`; `toolName` is duplicated onto the
|
|
30
|
+
* `tool.execute.*` variants purely for subscriber convenience.
|
|
31
|
+
*
|
|
32
|
+
* @stable
|
|
33
|
+
*/
|
|
34
|
+
type AgentEvent<TOutput = string> = AgentStartEvent | StepStartEvent | TextDeltaEvent | TextCompleteEvent | ReasoningDeltaEvent | ToolCallStartEvent | ToolCallDeltaEvent | ToolCallEndEvent | ToolExecuteStartEvent | ToolExecuteProgressEvent | ToolExecutePartialEvent | ToolExecuteEndEvent | ToolExecuteErrorEvent | ToolApprovalRequestedEvent | ToolApprovalGrantedEvent | ToolApprovalDeniedEvent | ContextCompactedEvent | HandoffEvent | AgentSteeredEvent | AgentFollowUpQueuedEvent | AgentCancellingEvent | AgentModelFellbackEvent | AgentFanOutSpawnedEvent | AgentFanOutMergedEvent | AgentEvaluatorIterationEvent | AgentEvaluatorConvergedEvent | AgentProgressWrittenEvent | AgentProgressReadEvent | AgentLateralLeakDetectedEvent | FileGeneratedEvent | SourceCitedEvent | StepEndEvent | GuardrailTrippedEvent | VerifierResultEvent | SubagentEvent | AgentEndEvent<TOutput> | AgentErrorEvent;
|
|
35
|
+
/**
|
|
36
|
+
* W-036: a CHILD sub-agent's event forwarded into the parent stream,
|
|
37
|
+
* wrapped so it never aliases the parent's own step/run events. Which
|
|
38
|
+
* child events forward is governed by the `forwardEvents` policy on
|
|
39
|
+
* the handoff entry / `AgentToToolOptions` (default `'lifecycle'`).
|
|
18
40
|
*
|
|
19
41
|
* @stable
|
|
20
42
|
*/
|
|
21
|
-
|
|
43
|
+
interface SubagentEvent {
|
|
44
|
+
readonly type: 'subagent.event';
|
|
45
|
+
/** The PARENT-side toolCallId of the handoff / sub-agent call. */
|
|
46
|
+
readonly toolCallId: string;
|
|
47
|
+
/** The child agent's configured name. */
|
|
48
|
+
readonly agentName: string;
|
|
49
|
+
/** The child's event, verbatim. */
|
|
50
|
+
readonly event: AgentEvent<unknown>;
|
|
51
|
+
}
|
|
22
52
|
/** @stable */
|
|
23
53
|
interface AgentStartEvent {
|
|
24
54
|
readonly type: 'agent.start';
|
|
@@ -68,6 +98,14 @@ interface ToolCallEndEvent {
|
|
|
68
98
|
interface ToolExecuteStartEvent {
|
|
69
99
|
readonly type: 'tool.execute.start';
|
|
70
100
|
readonly toolCallId: string;
|
|
101
|
+
/**
|
|
102
|
+
* Convenience duplicate of the executing tool's name (W-049).
|
|
103
|
+
* Correlation within a tool lifecycle is by `toolCallId`; this field
|
|
104
|
+
* spares direct subscribers a stateful join back to the
|
|
105
|
+
* `tool.call.start` that carried the name. Optional for wire
|
|
106
|
+
* compatibility; the agent runtime always fills it.
|
|
107
|
+
*/
|
|
108
|
+
readonly toolName?: string;
|
|
71
109
|
}
|
|
72
110
|
/**
|
|
73
111
|
* Emitted by streaming-hint tools via `ctx.reportProgress(...)`. Counter
|
|
@@ -107,6 +145,8 @@ interface ToolExecutePartialEvent {
|
|
|
107
145
|
interface ToolExecuteEndEvent {
|
|
108
146
|
readonly type: 'tool.execute.end';
|
|
109
147
|
readonly toolCallId: string;
|
|
148
|
+
/** See {@link ToolExecuteStartEvent.toolName} (W-049). */
|
|
149
|
+
readonly toolName?: string;
|
|
110
150
|
readonly result: unknown;
|
|
111
151
|
readonly durationMs: number;
|
|
112
152
|
}
|
|
@@ -114,6 +154,8 @@ interface ToolExecuteEndEvent {
|
|
|
114
154
|
interface ToolExecuteErrorEvent {
|
|
115
155
|
readonly type: 'tool.execute.error';
|
|
116
156
|
readonly toolCallId: string;
|
|
157
|
+
/** See {@link ToolExecuteStartEvent.toolName} (W-049). */
|
|
158
|
+
readonly toolName?: string;
|
|
117
159
|
readonly error: ToolError;
|
|
118
160
|
}
|
|
119
161
|
/** @stable */
|
|
@@ -459,5 +501,5 @@ interface AgentResult<TOutput = string> {
|
|
|
459
501
|
readonly state: RunState;
|
|
460
502
|
}
|
|
461
503
|
//#endregion
|
|
462
|
-
export { AgentCancellingEvent, AgentEndEvent, AgentErrorEvent, AgentEvaluatorConvergedEvent, AgentEvaluatorIterationEvent, AgentEvent, AgentFanOutMergedEvent, AgentFanOutSpawnedEvent, AgentFollowUpQueuedEvent, AgentLateralLeakDetectedEvent, AgentModelFellbackEvent, AgentProgressReadEvent, AgentProgressWrittenEvent, AgentResult, AgentStartEvent, AgentSteeredEvent, ContextCompactedEvent, FanOutChildMetadata, GuardrailTrippedEvent, HandoffEvent, LateralLeakVector, ProgressArtifactRef, ReasoningDeltaEvent, StepEndEvent, StepStartEvent, TextCompleteEvent, TextDeltaEvent, ToolApprovalDeniedEvent, ToolApprovalGrantedEvent, ToolApprovalRequestedEvent, ToolCallDeltaEvent, ToolCallEndEvent, ToolCallStartEvent, ToolExecuteEndEvent, ToolExecuteErrorEvent, ToolExecutePartialEvent, ToolExecuteProgressEvent, ToolExecuteStartEvent, VerifierResultEvent };
|
|
504
|
+
export { AgentCancellingEvent, AgentEndEvent, AgentErrorEvent, AgentEvaluatorConvergedEvent, AgentEvaluatorIterationEvent, AgentEvent, AgentFanOutMergedEvent, AgentFanOutSpawnedEvent, AgentFollowUpQueuedEvent, AgentLateralLeakDetectedEvent, AgentModelFellbackEvent, AgentProgressReadEvent, AgentProgressWrittenEvent, AgentResult, AgentStartEvent, AgentSteeredEvent, ContextCompactedEvent, FanOutChildMetadata, FileGeneratedEvent, GuardrailTrippedEvent, HandoffEvent, LateralLeakVector, ProgressArtifactRef, ReasoningDeltaEvent, StepEndEvent, StepStartEvent, SubagentEvent, TextCompleteEvent, TextDeltaEvent, ToolApprovalDeniedEvent, ToolApprovalGrantedEvent, ToolApprovalRequestedEvent, ToolCallDeltaEvent, ToolCallEndEvent, ToolCallStartEvent, ToolExecuteEndEvent, ToolExecuteErrorEvent, ToolExecutePartialEvent, ToolExecuteProgressEvent, ToolExecuteStartEvent, VerifierResultEvent };
|
|
463
505
|
//# sourceMappingURL=agent-event.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent-event.d.ts","names":[],"sources":["../../src/types/agent-event.ts"],"sourcesContent":[],"mappings":";;;;;;;;
|
|
1
|
+
{"version":3,"file":"agent-event.d.ts","names":[],"sources":["../../src/types/agent-event.ts"],"sourcesContent":[],"mappings":";;;;;;;;AA+BA;;;;;;;;;;;;;;;;;;;;;;;;;AAyBI,KAzBQ,UAyBR,CAAA,UAAA,MAAA,CAAA,GAxBA,eAwBA,GAvBA,cAuBA,GAtBA,cAsBA,GArBA,iBAqBA,GApBA,mBAoBA,GAnBA,kBAmBA,GAlBA,kBAkBA,GAjBA,gBAiBA,GAhBA,qBAgBA,GAfA,wBAeA,GAdA,uBAcA,GAbA,mBAaA,GAZA,qBAYA,GAXA,0BAWA,GAVA,wBAUA,GATA,uBASA,GARA,qBAQA,GAPA,YAOA,GANA,iBAMA,GALA,wBAKA,GAJA,oBAIA,GAHA,uBAGA,GAFA,uBAEA,GADA,sBACA,GAAA,4BAAA,GACA,4BADA,GAEA,yBAFA,GAGA,sBAHA,GAIA,6BAJA,GAKA,kBALA,GAMA,gBANA,GAOA,YAPA,GAQA,qBARA,GASA,mBATA,GAUA,aAVA,GAWA,aAXA,CAWc,OAXd,CAAA,GAYA,eAZA;;;;;;;;;AASA,UAaa,aAAA,CAbb;EACA,SAAA,IAAA,EAAA,gBAAA;EACc;EAAd,SAAA,UAAA,EAAA,MAAA;EACA;EAAe,SAAA,SAAA,EAAA,MAAA;EAUF;EAWA,SAAA,KAAA,EAJC,UAIc,CAAA,OAAA,CAAA;AAOhC;AAMA;AAMiB,UAnBA,eAAA,CAmBiB;EAMjB,SAAA,IAAA,EAAA,aAAmB;EAMnB,SAAA,KAAA,EAAA,MAAkB;EAQlB,SAAA,OAAA,EAAA,MAAkB;AAOnC;AAOA;AAoBiB,UAlEA,cAAA,CAkEwB;EAmBxB,SAAA,IAAA,EAAA,YAAuB;EAWvB,SAAA,UAAA,EAAA,MAAmB;AAUpC;AASA;AAOiB,UApHA,cAAA,CAoHwB;EAMxB,SAAA,IAAA,EAAA,YAAuB;EAYvB,SAAA,KAAA,EAAA,MAAA;AAcjB;AAaA;AAYiB,UAvKA,iBAAA,CAuKgB;EAOhB,SAAA,IAAA,EAAY,eAGX;EAID,SAAA,IAAA,EAAA,MAAA;AAcjB;AASA;AAOiB,UA7MA,mBAAA,CA6Me;EAWf,SAAA,IAAA,EAAA,iBAAiB;EAWjB,SAAA,KAAA,EAAA,MAAA;AAYjB;AAmBA;AAiBiB,UA7QA,kBAAA,CA6QuB;EAiBvB,SAAA,IAAA,EAAA,iBAAmB;EAanB,SAAA,UAAA,EAAA,MAAsB;EAkBtB,SAAA,QAAA,EAAA,MAAA;EAiBA,SAAA,IAAA,EAAA,OAAA;AAgBjB;AAgBA;AAaiB,UAnXA,kBAAA,CAmXsB;EA2B3B,SAAA,IAAA,EAAA,iBAAiB;EAYZ,SAAA,UAAA,EAAA,MAAA;EA0BA,SAAA,SAAW,EAAA,MAAA;;;AAIT,UAjbF,gBAAA,CAibE;EAEA,SAAA,IAAA,EAAA,eAAA;EAOD,SAAA,UAAA,EAAA,MAAA;EAAQ,SAAA,SAAA,EAAA,OAAA;;;UAnbT,qBAAA;;;;;;;;;;;;;;;;;;;UAoBA,wBAAA;;;;;;;;;;;;;;;;;;UAmBA,uBAAA;;;;kBAIC;;;;;;UAOD,mBAAA;;;;;;;;;UAUA,qBAAA;;;;;kBAKC;;;UAID,0BAAA;;;;;;UAOA,wBAAA;;;;;UAMA,uBAAA;;;;;;;;;;;UAYA,qBAAA;;;;;;;;;;;;;UAcA,YAAA;;;;;;;;;;;;UAaA,kBAAA;;;iBAGA;;;;;;;;UASA,gBAAA;;;;;;UAOA,YAAA;;;kBAGC;;;UAID,qBAAA;;;;;;;;;;;;;UAcA,mBAAA;;;;;;;;UASA;;;mBAGE,YAAY;;;UAId,eAAA;;;;;;;;;;;;;UAWA,iBAAA;;;;;;;;;;UAWA,wBAAA;;;;;;;;;;;UAYA,oBAAA;;;;;;;;;;;;;;;;;;UAmBA,uBAAA;;;;;;;;;;;;;;;;UAiBA,uBAAA;;;;;;;;;;;;;;;;UAiBA,mBAAA;;;;;;;;;;;;UAaA,sBAAA;;;;;;;;;;0BAUS,cAAc;;;;;;;UAQvB,4BAAA;;;;;;;;;;;;;;;;UAiBA,4BAAA;;;;;;;;;;;;;;;UAgBA,mBAAA;;;;;;kBAMC;;;;;;;;;UAUD,yBAAA;;;;;gBAKD;;;;;;;UAQC,sBAAA;;;;;iBAKA,cAAc;;;;;;;;;;;;;;;;;;;;;KAsBnB,iBAAA;;;;;;;UAYK,6BAAA;;;;;mBAKE;;2BAEQ;;;;;;;;;;;;;;;;;;UAmBV;mBACE;kBACD;;mBAEC;;mBAEA;;;;;;;kBAOD"}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -6,8 +6,9 @@ import { SessionScope } from "./session-scope.js";
|
|
|
6
6
|
import { Cost, ModelUsage, Usage, UsageAccumulator, UsageSnapshot, zeroUsage } from "./usage.js";
|
|
7
7
|
import { Handoff, HandoffFilter, HandoffInputFilterDescriptor, HandoffRecord, HandoffSecretsInheritance } from "./handoff.js";
|
|
8
8
|
import { CompletedToolCall, ContentChunk, InboundSanitizationPolicy, MemoryGuardTier, RecoveryHint, ResultHandle, SandboxPolicy, SideEffectClass, ToolApproval, ToolError, ToolErrorKind, ToolOutcome, ToolResult, ToolSource, ToolTrustClass, TruncationStrategy } from "./tool.js";
|
|
9
|
-
import { RunContext, RunError, RunState, RunStateUsageByModel, RunStatus, RunStep, RunStepProviderResponse, RunTaintSummary, TodoItem, flattenUsageByModel } from "./run.js";
|
|
9
|
+
import { ReadonlyRunState, RunContext, RunError, RunState, RunStateUsageByModel, RunStatus, RunStep, RunStepProviderResponse, RunTaintSummary, TodoItem, flattenUsageByModel } from "./run.js";
|
|
10
10
|
import { AgentCancellingEvent, AgentEndEvent, AgentErrorEvent, AgentEvaluatorConvergedEvent, AgentEvaluatorIterationEvent, AgentEvent, AgentFanOutMergedEvent, AgentFanOutSpawnedEvent, AgentFollowUpQueuedEvent, AgentLateralLeakDetectedEvent, AgentModelFellbackEvent, AgentProgressReadEvent, AgentProgressWrittenEvent, AgentResult, AgentStartEvent, AgentSteeredEvent, ContextCompactedEvent, FanOutChildMetadata, GuardrailTrippedEvent, HandoffEvent, LateralLeakVector, ProgressArtifactRef, ReasoningDeltaEvent, StepEndEvent, StepStartEvent, TextCompleteEvent, TextDeltaEvent, ToolApprovalDeniedEvent, ToolApprovalGrantedEvent, ToolApprovalRequestedEvent, ToolCallDeltaEvent, ToolCallEndEvent, ToolCallStartEvent, ToolExecuteEndEvent, ToolExecuteErrorEvent, ToolExecutePartialEvent, ToolExecuteProgressEvent, ToolExecuteStartEvent, VerifierResultEvent } from "./agent-event.js";
|
|
11
|
+
import { WireAgentEndEvent, WireAgentEvent, WireContentChunk, WireFileGeneratedEvent, WireToolExecutePartialEvent, fromWireAgentEvent, toWireAgentEvent } from "./agent-event-wire.js";
|
|
11
12
|
import { StopCondition, and, hasToolCall, isStepCount, isTerminal, not, or } from "./stop-condition.js";
|
|
12
13
|
import { WorkflowChannelUpdateEvent, WorkflowCheckpointWrittenEvent, WorkflowCustomEvent, WorkflowEndEvent, WorkflowErrorEvent, WorkflowEvent, WorkflowResumedEvent, WorkflowStartEvent, WorkflowStepEndEvent, WorkflowStepStartEvent, WorkflowSuspendedEvent, WorkflowTaskEndEvent, WorkflowTaskStartEvent } from "./workflow-event.js";
|
|
13
|
-
export { type AgentCancellingEvent, type AgentEndEvent, type AgentErrorEvent, type AgentEvaluatorConvergedEvent, type AgentEvaluatorIterationEvent, type AgentEvent, type AgentFanOutMergedEvent, type AgentFanOutSpawnedEvent, type AgentFollowUpQueuedEvent, type AgentLateralLeakDetectedEvent, type AgentModelFellbackEvent, type AgentProgressReadEvent, type AgentProgressWrittenEvent, type AgentResult, type AgentStartEvent, type AgentSteeredEvent, type AssistantMessage, type AudioContent, type Block, type CompletedToolCall, type ContentChunk, type ContextCompactedEvent, type Cost, type EntityRole, type Episode, type Fact, type FanOutChildMetadata, type FileContent, type GraphEntity, type GuardrailTrippedEvent, type Handoff, type HandoffEvent, type HandoffFilter, type HandoffInputFilterDescriptor, type HandoffRecord, type HandoffSecretsInheritance, type ImageContent, type InboundSanitizationPolicy, type Insight, type LateralLeakVector, type MemoryGuardTier, type MemoryHit, type MemoryKind, type MemoryMetadata, type MemoryOwner, type MemoryProvenance, type MemoryRecord, type MemorySearchOptions, type MemoryStatus, type Message, type MessageContent, type MessageRole, type ModelUsage, type ProgressArtifactRef, type ReasoningContent, type ReasoningContentMeta, type ReasoningDeltaEvent, type RecoveryHint, type ResultHandle, type Rule, type RunContext, type RunError, type RunState, type RunStateUsageByModel, type RunStatus, type RunStep, type RunStepProviderResponse, type RunTaintSummary, SENSITIVITY_ORDER, type SandboxPolicy, type Sensitivity, type SessionScope, type SideEffectClass, type StepEndEvent, type StepStartEvent, type StopCondition, type SystemMessage, type TextCompleteEvent, type TextContent, type TextDeltaEvent, type TodoItem, type ToolApproval, type ToolApprovalDeniedEvent, type ToolApprovalGrantedEvent, type ToolApprovalRequestedEvent, type ToolCall, type ToolCallDeltaEvent, type ToolCallEndEvent, type ToolCallStartEvent, type ToolError, type ToolErrorKind, type ToolExecuteEndEvent, type ToolExecuteErrorEvent, type ToolExecutePartialEvent, type ToolExecuteProgressEvent, type ToolExecuteStartEvent, type ToolMessage, type ToolOutcome, type ToolResult, type ToolSource, type ToolTrustClass, type TruncationStrategy, type Usage, type UsageAccumulator, type UsageSnapshot, type UserMessage, type VerifierResultEvent, type WorkflowChannelUpdateEvent, type WorkflowCheckpointWrittenEvent, type WorkflowCustomEvent, type WorkflowEndEvent, type WorkflowErrorEvent, type WorkflowEvent, type WorkflowResumedEvent, type WorkflowStartEvent, type WorkflowStepEndEvent, type WorkflowStepStartEvent, type WorkflowSuspendedEvent, type WorkflowTaskEndEvent, type WorkflowTaskStartEvent, acceptsSensitivity, and, flattenUsageByModel, hasToolCall, isStepCount, isTerminal, not, or, zeroUsage };
|
|
14
|
+
export { type AgentCancellingEvent, type AgentEndEvent, type AgentErrorEvent, type AgentEvaluatorConvergedEvent, type AgentEvaluatorIterationEvent, type AgentEvent, type AgentFanOutMergedEvent, type AgentFanOutSpawnedEvent, type AgentFollowUpQueuedEvent, type AgentLateralLeakDetectedEvent, type AgentModelFellbackEvent, type AgentProgressReadEvent, type AgentProgressWrittenEvent, type AgentResult, type AgentStartEvent, type AgentSteeredEvent, type AssistantMessage, type AudioContent, type Block, type CompletedToolCall, type ContentChunk, type ContextCompactedEvent, type Cost, type EntityRole, type Episode, type Fact, type FanOutChildMetadata, type FileContent, type GraphEntity, type GuardrailTrippedEvent, type Handoff, type HandoffEvent, type HandoffFilter, type HandoffInputFilterDescriptor, type HandoffRecord, type HandoffSecretsInheritance, type ImageContent, type InboundSanitizationPolicy, type Insight, type LateralLeakVector, type MemoryGuardTier, type MemoryHit, type MemoryKind, type MemoryMetadata, type MemoryOwner, type MemoryProvenance, type MemoryRecord, type MemorySearchOptions, type MemoryStatus, type Message, type MessageContent, type MessageRole, type ModelUsage, type ProgressArtifactRef, type ReadonlyRunState, type ReasoningContent, type ReasoningContentMeta, type ReasoningDeltaEvent, type RecoveryHint, type ResultHandle, type Rule, type RunContext, type RunError, type RunState, type RunStateUsageByModel, type RunStatus, type RunStep, type RunStepProviderResponse, type RunTaintSummary, SENSITIVITY_ORDER, type SandboxPolicy, type Sensitivity, type SessionScope, type SideEffectClass, type StepEndEvent, type StepStartEvent, type StopCondition, type SystemMessage, type TextCompleteEvent, type TextContent, type TextDeltaEvent, type TodoItem, type ToolApproval, type ToolApprovalDeniedEvent, type ToolApprovalGrantedEvent, type ToolApprovalRequestedEvent, type ToolCall, type ToolCallDeltaEvent, type ToolCallEndEvent, type ToolCallStartEvent, type ToolError, type ToolErrorKind, type ToolExecuteEndEvent, type ToolExecuteErrorEvent, type ToolExecutePartialEvent, type ToolExecuteProgressEvent, type ToolExecuteStartEvent, type ToolMessage, type ToolOutcome, type ToolResult, type ToolSource, type ToolTrustClass, type TruncationStrategy, type Usage, type UsageAccumulator, type UsageSnapshot, type UserMessage, type VerifierResultEvent, type WireAgentEndEvent, type WireAgentEvent, type WireContentChunk, type WireFileGeneratedEvent, type WireToolExecutePartialEvent, type WorkflowChannelUpdateEvent, type WorkflowCheckpointWrittenEvent, type WorkflowCustomEvent, type WorkflowEndEvent, type WorkflowErrorEvent, type WorkflowEvent, type WorkflowResumedEvent, type WorkflowStartEvent, type WorkflowStepEndEvent, type WorkflowStepStartEvent, type WorkflowSuspendedEvent, type WorkflowTaskEndEvent, type WorkflowTaskStartEvent, acceptsSensitivity, and, flattenUsageByModel, fromWireAgentEvent, hasToolCall, isStepCount, isTerminal, not, or, toWireAgentEvent, zeroUsage };
|
package/dist/types/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import { fromWireAgentEvent, toWireAgentEvent } from "./agent-event-wire.js";
|
|
1
2
|
import { flattenUsageByModel } from "./run.js";
|
|
2
3
|
import { SENSITIVITY_ORDER, acceptsSensitivity } from "./sensitivity.js";
|
|
3
4
|
import { and, hasToolCall, isStepCount, isTerminal, not, or } from "./stop-condition.js";
|
|
4
5
|
import { zeroUsage } from "./usage.js";
|
|
5
6
|
|
|
6
|
-
export { SENSITIVITY_ORDER, acceptsSensitivity, and, flattenUsageByModel, hasToolCall, isStepCount, isTerminal, not, or, zeroUsage };
|
|
7
|
+
export { SENSITIVITY_ORDER, acceptsSensitivity, and, flattenUsageByModel, fromWireAgentEvent, hasToolCall, isStepCount, isTerminal, not, or, toWireAgentEvent, zeroUsage };
|
package/dist/types/memory.d.ts
CHANGED
|
@@ -261,6 +261,11 @@ interface Rule extends MemoryRecord {
|
|
|
261
261
|
* an ExpeL-style salience counter (new insights start at `2`, pruned at
|
|
262
262
|
* `≤ 0`) and are retrieval-ranked **below** the primary facts they cite.
|
|
263
263
|
*
|
|
264
|
+
* Core defines only the record shape; the storage surface for insights
|
|
265
|
+
* is NOT part of the baseline {@link MemoryStore} contract - it lives in
|
|
266
|
+
* the optional `InsightMemoryStoreExt` exported from `@graphorin/memory`
|
|
267
|
+
* (W-048). Adapters without it simply have no insight tier.
|
|
268
|
+
*
|
|
264
269
|
* @stable
|
|
265
270
|
*/
|
|
266
271
|
interface Insight extends MemoryRecord {
|
|
@@ -314,6 +319,12 @@ type EntityRole = 'subject' | 'object';
|
|
|
314
319
|
* ledger, and `mergedInto` is single-level (it always points directly at
|
|
315
320
|
* a root), so `mergedInto ?? id` is the canonical id.
|
|
316
321
|
*
|
|
322
|
+
* Core defines only the record shape; the storage surface for the graph
|
|
323
|
+
* (upsert / link / merge / one-hop expansion) is NOT part of the
|
|
324
|
+
* baseline {@link MemoryStore} contract - it lives in the optional
|
|
325
|
+
* `GraphMemoryStoreExt` exported from `@graphorin/memory` (W-048).
|
|
326
|
+
* Adapters without it simply have no relation graph.
|
|
327
|
+
*
|
|
317
328
|
* @stable
|
|
318
329
|
*/
|
|
319
330
|
interface GraphEntity {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"memory.d.ts","names":[],"sources":["../../src/types/memory.ts"],"sourcesContent":[],"mappings":";;;;;;AAYA;AAwBA;AAgBA;AAeA;AAUA;AAuBA;;;AAckB,KAtGN,UAAA,GAsGM,SAAA,GAAA,SAAA,GAAA,UAAA,GAAA,UAAA,GAAA,YAAA,GAAA,QAAA,GAAA,SAAA;;AASlB;AAcA;;;;;;AA4DA;;;;;;AAsBA;AAWmB,KAlMP,gBAAA,GAkMO,MAAA,GAAA,MAAA,GAAA,YAAA,GAAA,YAAA,GAAA,WAAA,GAAA,UAAA;;;;;;;;
|
|
1
|
+
{"version":3,"file":"memory.d.ts","names":[],"sources":["../../src/types/memory.ts"],"sourcesContent":[],"mappings":";;;;;;AAYA;AAwBA;AAgBA;AAeA;AAUA;AAuBA;;;AAckB,KAtGN,UAAA,GAsGM,SAAA,GAAA,SAAA,GAAA,UAAA,GAAA,UAAA,GAAA,YAAA,GAAA,QAAA,GAAA,SAAA;;AASlB;AAcA;;;;;;AA4DA;;;;;;AAsBA;AAWmB,KAlMP,gBAAA,GAkMO,MAAA,GAAA,MAAA,GAAA,YAAA,GAAA,YAAA,GAAA,WAAA,GAAA,UAAA;;;;;;;;AA6DnB;AASkB,KAxPN,YAAA,GAwPM,QAAA,GAAA,aAAA;;;;;;AA4BlB;AAwBA;AAuBA;;;;;;AAsC8C,KA1VlC,WAAA,GA0VkC,MAAA,GAAA,OAAA,GAAA,QAAA;AAQ9C;;;;;;;;UAxViB,cAAA;;;;;;;;;;;;;;kBAcC;;;;;;;;UASD,YAAA;;iBAEA;;;;wBAIO;;;;;;;;kBAQN;;;;;;;;UASD,KAAA,SAAc;;;;;;;;;;;;;UAcd,IAAA,SAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBAwCN;;;;;;oBAMJ;;;;;;mBAMD;;;;;;;UAQF,OAAA,SAAgB;;;;;;;;;;wBAUT;;oBAEJ;;mBAED;;;;;;;UAQF,IAAA,SAAa;;;;;;;;;;;mBAWX;;;;;;;uBAOI;;;;;;6BAMM;;;;;;wBAML;;;;;;;oBAOJ;;;;;;;;;;mBAUD;;;;;;;;;;;;;;;;;;;;;;;;UAyBF,OAAA,SAAgB;;;;;;;;;kBASf;;;;;;;;;;;wBAWM;;;;;oBAKJ;;mBAED;;;;;;;;;KAUP,UAAA;;;;;;;;;;;;;;;;;;;;;;;UAwBK,WAAA;;;;;;;;;;;;;;;;;;;;;;UAuBA,mBAAA;;;kBAGC;;;;;;;;;;;;;oBAUE;;;;;;;;;;;;;;;;;;;;;;;;;mBAyBD,cAAc,cAAc;;;;;;;UAQ9B,0BAA0B,eAAe;mBACvC;;;qBAGE,SAAS"}
|