@makaio/framework 1.0.0-dev-1783355411417 → 1.0.0-dev-1783477169057
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/.makaio-build.json +2 -2
- package/dist/adapter-Lx6K7yQS.mjs +1 -0
- package/dist/adapter-subsystem/index.mjs +1 -1
- package/dist/adapters/config/index.d.mts +1 -1
- package/dist/adapters/index.d.mts +219 -40
- package/dist/adapters/index.mjs +6 -6
- package/dist/adapters/node.d.mts +1 -1
- package/dist/adapters/node.mjs +4 -4
- package/dist/{base-orchestrator-BNysGvaM.d.mts → base-orchestrator-J1WKAUkF.d.mts} +32 -3
- package/dist/bus/index.d.mts +22 -22
- package/dist/bus/index.mjs +1 -1
- package/dist/client-l1Rq5p6X.mjs +1 -0
- package/dist/clients/index.d.mts +30 -0
- package/dist/clients/index.mjs +2 -2
- package/dist/contracts/adapter/index.d.mts +2 -2
- package/dist/contracts/adapter/index.mjs +1 -1
- package/dist/contracts/adapter/schemas/session-lineage.d.mts +1 -1
- package/dist/contracts/adapter/schemas/session-lineage.mjs +1 -1
- package/dist/contracts/artifact/index.d.mts +1 -1
- package/dist/contracts/canonical-model/index.d.mts +1 -1
- package/dist/contracts/client/index.d.mts +2 -2
- package/dist/contracts/client/index.mjs +1 -1
- package/dist/contracts/config/index.d.mts +12 -12
- package/dist/contracts/extension/index.d.mts +3 -3
- package/dist/contracts/facet/index.d.mts +1 -1
- package/dist/contracts/harness/index.d.mts +1 -1
- package/dist/contracts/index.d.mts +454 -276
- package/dist/contracts/index.mjs +1 -1
- package/dist/contracts/materialization/index.d.mts +3 -3
- package/dist/contracts/provider/index.d.mts +1 -1
- package/dist/contracts/session/index.d.mts +3 -3
- package/dist/contracts/session/index.mjs +1 -1
- package/dist/contracts/shared/index.d.mts +1 -1
- package/dist/contracts/skill/index.d.mts +1 -1
- package/dist/contracts/variant/index.d.mts +1 -1
- package/dist/contracts/workflow/index.d.mts +2 -2
- package/dist/{definition-b9jyJqPD.d.mts → definition-DePb3ke-.d.mts} +1 -1
- package/dist/drizzle/0023_m_mr9gc37m.sql +1 -0
- package/dist/drizzle/meta/_journal.json +7 -0
- package/dist/handlers-B74FvKlA.mjs +57 -0
- package/dist/hooks/index.d.mts +19 -2
- package/dist/{identity-BarL3JYI.mjs → identity-DC3Pk0ps.mjs} +1 -1
- package/dist/{index-BwGfdbI0.d.mts → index-2fK9iSHI.d.mts} +9 -9
- package/dist/{index-D7rWAEY0.d.mts → index-B-6DtLLz.d.mts} +1 -1
- package/dist/{index-4eP9DRL_.d.mts → index-B3fjN5HX.d.mts} +7 -7
- package/dist/{index-O08Q2ikz.d.mts → index-BMbmoarE.d.mts} +8 -8
- package/dist/{index-DV4nRk0h.d.mts → index-BX1MxwFr.d.mts} +28 -28
- package/dist/{index-CqCe7Phc.d.mts → index-BcwOnvUh.d.mts} +6 -6
- package/dist/{index-D6aAzr32.d.mts → index-BeouVICp.d.mts} +36 -36
- package/dist/{index-DQYj8-53.d.mts → index-BjO4Zkap.d.mts} +1 -1
- package/dist/{index-B5w-0Gg9.d.mts → index-Bl42SCEI.d.mts} +8 -8
- package/dist/{index-BYfSAJRC.d.mts → index-BvTd61i5.d.mts} +151 -29
- package/dist/{index-3X0368CL.d.mts → index-CA-AJbq6.d.mts} +4 -4
- package/dist/{index-C5C1tk9f.d.mts → index-CQQcnpev.d.mts} +41 -41
- package/dist/{index-BKZhnb2B.d.mts → index-C_xQM96Y.d.mts} +802 -422
- package/dist/{index-31vR1sxk.d.mts → index-CwFSL4xI.d.mts} +144 -21
- package/dist/{index-WHUV7neB.d.mts → index-DMz-2ACU.d.mts} +105 -105
- package/dist/{index-3J0HZlPH.d.mts → index-DScUb-hF.d.mts} +334 -13
- package/dist/{index-DEzdNQum.d.mts → index-Di84JjS0.d.mts} +2 -2
- package/dist/{index-DvHYpi-J.d.mts → index-Dv4oGVZK.d.mts} +1246 -397
- package/dist/{index-CaerrEDH.d.mts → index-NkNbYFud.d.mts} +1 -1
- package/dist/{index-D9-vOJvZ.d.mts → index-h5go5Dtd.d.mts} +1 -1
- package/dist/{index-DLNRgZPo2.d.mts → index-j_X5xefv2.d.mts} +26 -26
- package/dist/{index-C6Ys8pxt.d.mts → index-uM4KZopE.d.mts} +9 -9
- package/dist/kernel/extension/index.d.mts +1 -1
- package/dist/kernel/index.d.mts +2 -2
- package/dist/kernel/observability/index.d.mts +1 -1
- package/dist/{namespace-j7vFsmYL.d.mts → namespace-3yGm4WF9.d.mts} +2 -2
- package/dist/{namespace-D8P8Sxce2.d.mts → namespace-6sIu5nBI2.d.mts} +2 -2
- package/dist/{namespace-B3ol3pc-.d.mts → namespace-BigVYQyx.d.mts} +12 -0
- package/dist/{namespace-DmqoDDRD.d.mts → namespace-Boh42UoL.d.mts} +66 -22
- package/dist/{namespace-CfvtDD_U.d.mts → namespace-COEUMuHL.d.mts} +156 -156
- package/dist/{namespace-B4cV_pk3.d.mts → namespace-D94HrTtq.d.mts} +58 -58
- package/dist/{namespace-DhDY0juT.d.mts → namespace-OLAh9wHU.d.mts} +375 -27
- package/dist/{namespace-Bm77p82L.d.mts → namespace-TPbegIMi.d.mts} +27 -27
- package/dist/{package-MmQvNJ3u.d.mts → package-B6mEMD8r.d.mts} +5 -0
- package/dist/{package-BmRhhi-3.mjs → package-BQn_RTo7.mjs} +1 -1
- package/dist/package.json +1 -1
- package/dist/{schema-DLNBajAV.d.mts → schema-B5vHi7Uu.d.mts} +28 -1
- package/dist/{schemas-CoFCV42v.d.mts → schemas-CDBn9MTz.d.mts} +156 -156
- package/dist/schemas-CkOigLAT.mjs +1 -0
- package/dist/{schemas-lnE9YoG7.d.mts → schemas-CscdPqCt.d.mts} +3 -3
- package/dist/{schemas-DMMWmWjq.d.mts → schemas-D512XweP.d.mts} +4 -4
- package/dist/{schemas-DuuVuhHX2.d.mts → schemas-DOV4UouN2.d.mts} +13 -13
- package/dist/{schemas-DmGRSeIq.d.mts → schemas-t6h9oSct.d.mts} +28 -1
- package/dist/services/adapter-runtime/index.d.mts +4 -4
- package/dist/services/adapter-runtime/index.mjs +1 -1
- package/dist/services/adapter-runtime/namespace.d.mts +1 -1
- package/dist/services/adapter-runtime/schemas.d.mts +2 -2
- package/dist/services/adapter-runtime/schemas.mjs +1 -1
- package/dist/services/adapter-subsystem/index.d.mts +2 -2
- package/dist/services/adapter-subsystem/namespace.d.mts +1 -1
- package/dist/services/agent-runtime/index.d.mts +2 -2
- package/dist/services/agent-runtime/namespace.d.mts +1 -1
- package/dist/services/agent-runtime/schemas.d.mts +1 -1
- package/dist/services/context-rules/index.d.mts +8 -8
- package/dist/services/execution-target/index.d.mts +1 -1
- package/dist/services/filesystem/namespace.d.mts +12 -12
- package/dist/services/filesystem/schemas.d.mts +6 -6
- package/dist/services/git/namespace.d.mts +2 -2
- package/dist/services/git/schemas.d.mts +1 -1
- package/dist/services/harness/index.d.mts +3 -3
- package/dist/services/index.d.mts +147 -140
- package/dist/services/index.mjs +1 -1
- package/dist/services/log-import/browser.d.mts +2 -2
- package/dist/services/log-import/index.d.mts +15 -2
- package/dist/services/log-import/index.mjs +2 -2
- package/dist/services/log-import/log-import.d.mts +1 -1
- package/dist/services/log-import/namespace.d.mts +2 -2
- package/dist/services/log-import/schemas.d.mts +1 -1
- package/dist/services/session/handlers/index.d.mts +1 -1
- package/dist/services/session/handlers/index.mjs +1 -1
- package/dist/services/session/index.d.mts +7 -7
- package/dist/services/session/index.mjs +1 -1
- package/dist/services/session/messages/namespace.d.mts +1 -1
- package/dist/services/session/session-events/namespace.d.mts +1 -1
- package/dist/services/session/storage/namespace.d.mts +1 -1
- package/dist/services/session/storage/schema.d.mts +1 -1
- package/dist/services/session/storage/schema.mjs +1 -1
- package/dist/services/session/testing/index.mjs +3 -2
- package/dist/services/session-editor/index.d.mts +1 -1
- package/dist/services/settings/namespace.d.mts +10 -10
- package/dist/services/settings/storage/extension-configs/namespace.d.mts +3 -3
- package/dist/services/subagent-template/index.d.mts +2 -2
- package/dist/services/subagent-template/namespace.d.mts +1 -1
- package/dist/services/subagent-template/schemas.d.mts +1 -1
- package/dist/services/tool-approval/index.mjs +1 -1
- package/dist/services/tools/index.mjs +1 -1
- package/dist/services/tray-menu/index.d.mts +2 -2
- package/dist/services/tray-menu/namespace.d.mts +1 -1
- package/dist/services/tray-menu/schemas.d.mts +1 -1
- package/dist/session-CoGaTin6.mjs +69 -0
- package/dist/session-Dp7z5N1d.mjs +1 -0
- package/dist/{session-lineage-DR-9DU-U.d.mts → session-lineage-C1M7-O3C.d.mts} +3 -3
- package/dist/{tool-approval-service-MU_DmJsf.mjs → tool-approval-service-BNXgr-az.mjs} +1 -1
- package/dist/tools-BaO4GYj0.mjs +1 -0
- package/dist/{transition-Dq41YCkc.d.mts → transition-Bbjlwv5K.d.mts} +1 -1
- package/dist/{types-BMS6yfLS.d.mts → types-BNW5n6qm.d.mts} +1 -1
- package/dist/{types-BMlzmWp6.d.mts → types-CNkx2awa.d.mts} +12 -1
- package/dist/{types-Cse8s_cD.d.mts → types-D7W0ntGr.d.mts} +45 -18
- package/dist/{types-C76EP81O.d.mts → types-jruUn6oW.d.mts} +694 -282
- package/dist/workflow-engine/index.d.mts +41 -41
- package/dist/workflow-engine/index.mjs +1 -1
- package/dist/workflow-engine/package.d.mts +1 -1
- package/dist/workflow-engine/package.mjs +1 -1
- package/package.json +1 -1
- package/dist/adapter-BRxCc72E.mjs +0 -1
- package/dist/client-BgUjVbXX.mjs +0 -1
- package/dist/handlers-v47Gbsr1.mjs +0 -57
- package/dist/schemas-ftgVeWIG.mjs +0 -1
- package/dist/session-CKWfn3oc.mjs +0 -1
- package/dist/session-DCbJwYEU.mjs +0 -69
- package/dist/tools-BrNm-een.mjs +0 -1
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { A as MessageHandle, B as ReasoningLevelMap, C as SendMessageRequestPayload, D as IAdapterConfigFactory, E as ConfigFactoryInput, F as MessageState, H as LedgerSessionContext, I as ProcessingState, L as SendMessageOptions, M as NormalizedMessageInput, N as normalizeMessageInput, O as AIAgentConnector, P as MessageResult, R as AIModel, S as NormalizedCallUsage, T as StartAgentOptions, U as SessionToolLedger, V as ISessionToolLedger, W as ToolLedgerEntry, _ as ConnectorSendMessageOptions, a as AgentCwdChangeRequestPayload, b as ExecutionContext, c as AgentInterruptRequestPayload, d as AgentMcpServersSetResponsePayload, f as AgentModelChangeRequestPayload, g as BaseAgentConnectorConfig, h as AgentStartResult, i as AgentCredentialChangeResponsePayload, j as markCompletedWithFinalResult, k as MessageDeliveryMode, l as AgentInterruptResponsePayload, m as AgentSendMessageOptions, n as AgentContext, o as AgentCwdChangeResponsePayload, p as AgentModelChangeResponsePayload, r as AgentCredentialChangeRequestPayload, s as AgentIdentity, t as AIAgentConfig, u as AgentMcpServersSetRequestPayload, v as ConnectorStartOptions, w as SendMessageResponsePayload, x as GetCapabilitiesResponsePayload, y as ContextWindowInput, z as AIReasoningLevel } from "../types-
|
|
2
|
-
import { S as toImportSegment, _ as LogImporter, a as CompactionMetadata, b as ProcessLogFileResult, c as ExternalToolIdentifiers, d as ImportMetadata, f as ImportSegment, g as LogImportTestConfig, h as LogImportSessionContext, l as ExternalToolMeta, m as ImportSegmentTurn, n as LogOrchestratorConfig, o as DiscoveryMetadata, p as ImportSegmentLineage, r as ParseFileResult, s as ExternalToolIdentifier, u as ImportCursorPosition, v as LogImporterConfig, x as StorageMessagePayload, y as NormalizedEvent } from "../base-orchestrator-
|
|
1
|
+
import { A as MessageHandle, B as ReasoningLevelMap, C as SendMessageRequestPayload, D as IAdapterConfigFactory, E as ConfigFactoryInput, F as MessageState, H as LedgerSessionContext, I as ProcessingState, L as SendMessageOptions, M as NormalizedMessageInput, N as normalizeMessageInput, O as AIAgentConnector, P as MessageResult, R as AIModel, S as NormalizedCallUsage, T as StartAgentOptions, U as SessionToolLedger, V as ISessionToolLedger, W as ToolLedgerEntry, _ as ConnectorSendMessageOptions, a as AgentCwdChangeRequestPayload, b as ExecutionContext, c as AgentInterruptRequestPayload, d as AgentMcpServersSetResponsePayload, f as AgentModelChangeRequestPayload, g as BaseAgentConnectorConfig, h as AgentStartResult, i as AgentCredentialChangeResponsePayload, j as markCompletedWithFinalResult, k as MessageDeliveryMode, l as AgentInterruptResponsePayload, m as AgentSendMessageOptions, n as AgentContext, o as AgentCwdChangeResponsePayload, p as AgentModelChangeResponsePayload, r as AgentCredentialChangeRequestPayload, s as AgentIdentity, t as AIAgentConfig, u as AgentMcpServersSetRequestPayload, v as ConnectorStartOptions, w as SendMessageResponsePayload, x as GetCapabilitiesResponsePayload, y as ContextWindowInput, z as AIReasoningLevel } from "../types-D7W0ntGr.mjs";
|
|
2
|
+
import { S as toImportSegment, _ as LogImporter, a as CompactionMetadata, b as ProcessLogFileResult, c as ExternalToolIdentifiers, d as ImportMetadata, f as ImportSegment, g as LogImportTestConfig, h as LogImportSessionContext, l as ExternalToolMeta, m as ImportSegmentTurn, n as LogOrchestratorConfig, o as DiscoveryMetadata, p as ImportSegmentLineage, r as ParseFileResult, s as ExternalToolIdentifier, u as ImportCursorPosition, v as LogImporterConfig, x as StorageMessagePayload, y as NormalizedEvent } from "../base-orchestrator-J1WKAUkF.mjs";
|
|
3
3
|
import { z } from "zod";
|
|
4
4
|
import * as _$_makaio_core0 from "@makaio/framework/core";
|
|
5
5
|
import { CreateBusNamespaceOptions, ExtractSubjectPayload, FilterablePayloadIntersection, HandlerForSubjectDefinition, RegistrableBusNamespaceDefinition, RequestContext, SchemaRecord, ScopedSubjectDefinition, SubjectDefinition, SubjectRecordFromSchemaRecord } from "@makaio/framework/core";
|
|
6
6
|
import { BusNamespace, IMakaioBus, OnOptions, ScopedBus, ScopedBusFor } from "@makaio/framework/bus";
|
|
7
|
-
import { AIReasoningLevel as AIReasoningLevel$1, AdapterClientRef, AdapterDefinitionContract, AdapterProviderDefinitionContract, AdapterSubjects, AgentSchemas, AgentStarted, AgentSubjects, AgentToolApproveRequest, AgentToolApproveResponse, BlockData, HarnessDefinition, HarnessSubjects, JsonValue, McpResolvedServer, McpRuntimeSessionContext, McpSessionContext, McpToolState, Message, MessageInput, ProviderContext, ProviderDefinitionInput, ReasoningLevelMap as ReasoningLevelMap$1, ResponseSchemaDescriptor, SendMessageRequest, SendMessageResponse, SessionContext, SessionMessageBlock, StartAgentRequest, StartAgentResponse, StepType, SystemPrompt, ToolListItem } from "@makaio/framework/contracts";
|
|
7
|
+
import { AIReasoningLevel as AIReasoningLevel$1, AdapterClientRef, AdapterDefinitionContract, AdapterProviderDefinitionContract, AdapterSubjects, AgentSchemas, AgentStarted, AgentSubjects, AgentToolApproveRequest, AgentToolApproveResponse, BlockData, HarnessDefinition, HarnessSubjects, JsonValue, McpResolvedServer, McpRuntimeSessionContext, McpSessionContext, McpToolState, Message, MessageInput, NativeForkDirective, ProviderContext, ProviderDefinitionInput, ReasoningLevelMap as ReasoningLevelMap$1, ResponseSchemaDescriptor, SendMessageRequest, SendMessageResponse, SessionContext, SessionMessageBlock, StartAgentRequest, StartAgentResponse, StartMode, StepType, SystemPrompt, ToolListItem } from "@makaio/framework/contracts";
|
|
8
8
|
import * as _$_makaio_storage_core0 from "@makaio/framework/storage";
|
|
9
9
|
import * as _$_makaio_ai_adapters_core0 from "@makaio/framework/adapters";
|
|
10
10
|
import * as _$type_fest0 from "type-fest";
|
|
@@ -266,6 +266,7 @@ interface AIAdapterCapabilityRegistry {
|
|
|
266
266
|
session: {
|
|
267
267
|
resume: boolean;
|
|
268
268
|
fork: boolean;
|
|
269
|
+
forkAtMessage: boolean;
|
|
269
270
|
};
|
|
270
271
|
chat: {
|
|
271
272
|
inTurnMessages: boolean;
|
|
@@ -1413,7 +1414,7 @@ declare const ScopedToolApprovalSchema: {
|
|
|
1413
1414
|
agentId: z.ZodString;
|
|
1414
1415
|
adapterId: z.ZodString;
|
|
1415
1416
|
adapterName: z.ZodString;
|
|
1416
|
-
adapterSessionId: z.ZodString
|
|
1417
|
+
adapterSessionId: z.ZodOptional<z.ZodString>;
|
|
1417
1418
|
messageId: z.ZodOptional<z.ZodString>;
|
|
1418
1419
|
turnId: z.ZodOptional<z.ZodString>;
|
|
1419
1420
|
clientId: z.ZodOptional<z.ZodString>;
|
|
@@ -1550,7 +1551,9 @@ type ConnectorEventHandlers<TMessage, TDiscriminator extends string> = { [K in D
|
|
|
1550
1551
|
* Emit function type for global bus emissions.
|
|
1551
1552
|
* Matches the signature of AIAgent.emitGlobal.
|
|
1552
1553
|
*/
|
|
1553
|
-
type EmitGlobalFn = <S extends SubjectDefinition>(subject: S, payload: Omit<ExtractSubjectPayload<S>, keyof AgentContext>
|
|
1554
|
+
type EmitGlobalFn = <S extends SubjectDefinition>(subject: S, payload: Omit<ExtractSubjectPayload<S>, keyof AgentContext> & {
|
|
1555
|
+
turnId?: string;
|
|
1556
|
+
}) => Promise<void>;
|
|
1554
1557
|
/**
|
|
1555
1558
|
* Configuration for MessageLifecycleTracker.
|
|
1556
1559
|
*/
|
|
@@ -1558,6 +1561,11 @@ interface MessageLifecycleTrackerConfig {
|
|
|
1558
1561
|
/** Function to emit events to global bus with auto-enrichment */
|
|
1559
1562
|
emitGlobal: EmitGlobalFn;
|
|
1560
1563
|
}
|
|
1564
|
+
/** Options for tracking a connector message handle. */
|
|
1565
|
+
interface MessageLifecycleTrackOptions {
|
|
1566
|
+
/** Turn ID captured before connector dispatch, if the request belongs to a session turn. */
|
|
1567
|
+
turnId: string | undefined;
|
|
1568
|
+
}
|
|
1561
1569
|
/**
|
|
1562
1570
|
* Tracks message lifecycle and emits corresponding events.
|
|
1563
1571
|
*
|
|
@@ -1606,8 +1614,9 @@ declare class MessageLifecycleTracker {
|
|
|
1606
1614
|
* - user_message.acknowledged
|
|
1607
1615
|
* - agent.turn.started
|
|
1608
1616
|
* @param handle - The message handle being acknowledged
|
|
1617
|
+
* @param turnId - Turn ID captured when the handle was registered
|
|
1609
1618
|
*/
|
|
1610
|
-
acknowledge(handle: MessageHandle): void;
|
|
1619
|
+
acknowledge(handle: MessageHandle, turnId?: string): void;
|
|
1611
1620
|
/**
|
|
1612
1621
|
* Complete a message - marks turn end.
|
|
1613
1622
|
*
|
|
@@ -1616,8 +1625,9 @@ declare class MessageLifecycleTracker {
|
|
|
1616
1625
|
* - user_message.completed (always, with outcome)
|
|
1617
1626
|
* @param handle - The message handle being completed
|
|
1618
1627
|
* @param result - The completion result with outcome
|
|
1628
|
+
* @param turnId - Turn ID captured when the handle was registered
|
|
1619
1629
|
*/
|
|
1620
|
-
complete(handle: MessageHandle, result: MessageResult): void;
|
|
1630
|
+
complete(handle: MessageHandle, result: MessageResult, turnId?: string): void;
|
|
1621
1631
|
/**
|
|
1622
1632
|
* Wire up a message handle for lifecycle tracking.
|
|
1623
1633
|
*
|
|
@@ -1628,8 +1638,9 @@ declare class MessageLifecycleTracker {
|
|
|
1628
1638
|
* @param handle - The message handle to track
|
|
1629
1639
|
* @param onTerminal - Optional callback for any terminal outcome (emits agent.complete)
|
|
1630
1640
|
* @param transformTerminal - Optional async transform applied before public completion resolves
|
|
1641
|
+
* @param options - Optional tracking metadata captured before connector dispatch
|
|
1631
1642
|
*/
|
|
1632
|
-
track(handle: MessageHandle, onTerminal?: (messageId: string, result: MessageResult) => void, transformTerminal?: (result: MessageResult) => Promise<MessageResult
|
|
1643
|
+
track(handle: MessageHandle, onTerminal?: (messageId: string, result: MessageResult, turnId: string | undefined) => void, transformTerminal?: (result: MessageResult) => Promise<MessageResult>, options?: MessageLifecycleTrackOptions): void;
|
|
1633
1644
|
}
|
|
1634
1645
|
//#endregion
|
|
1635
1646
|
//#region adapters/core/src/agent/tool-call-tracker.d.ts
|
|
@@ -1739,6 +1750,15 @@ declare abstract class AIAgent<TBus extends ScopedBus<string> = ScopedBus<string
|
|
|
1739
1750
|
private latestMessageCompletion?;
|
|
1740
1751
|
/** Current content block index within the turn, reset on each turn start */
|
|
1741
1752
|
private currentBlockIndex;
|
|
1753
|
+
/**
|
|
1754
|
+
* Start mode for the next `emitStart()` call (consume-on-read).
|
|
1755
|
+
*
|
|
1756
|
+
* Set before dispatch; {@link emitStart} reads and clears the slot so
|
|
1757
|
+
* subsequent calls within the same dispatch (e.g. Copilot SDK sub-turns)
|
|
1758
|
+
* fall back to `'rotation'`. The `undefined` initial value is safe —
|
|
1759
|
+
* every first-start path sets the mode before the connector fires.
|
|
1760
|
+
*/
|
|
1761
|
+
private pendingStartMode;
|
|
1742
1762
|
/** Normalized config with defaults applied */
|
|
1743
1763
|
protected readonly config: SetRequired<AIAgentConfig<TBus, TConnector>, 'globalBus'>;
|
|
1744
1764
|
/** Available models for context window lookup */
|
|
@@ -1781,7 +1801,23 @@ declare abstract class AIAgent<TBus extends ScopedBus<string> = ScopedBus<string
|
|
|
1781
1801
|
* @throws Error if already initialized
|
|
1782
1802
|
*/
|
|
1783
1803
|
init(): Promise<void>;
|
|
1784
|
-
|
|
1804
|
+
/**
|
|
1805
|
+
* Emit `agent.started` with the pending start mode (consume-on-read).
|
|
1806
|
+
*
|
|
1807
|
+
* Reads and clears {@link pendingStartMode}; subsequent calls within
|
|
1808
|
+
* the same dispatch fall back to `'rotation'`.
|
|
1809
|
+
* @param event - Optional additional fields to merge into the payload
|
|
1810
|
+
*/
|
|
1811
|
+
protected emitStart(event?: Omit<AgentStarted, 'agentId' | 'adapterId' | 'adapterName' | 'adapterSessionId' | 'model' | 'cwd' | 'startMode'>): Promise<void>;
|
|
1812
|
+
/**
|
|
1813
|
+
* Set the start mode for the next `emitStart()` invocation.
|
|
1814
|
+
*
|
|
1815
|
+
* Called by the turn executor or `initialize()` before dispatching to
|
|
1816
|
+
* the connector. The value is consumed (cleared) by the first
|
|
1817
|
+
* `emitStart()` call, enforcing the one-shot invariant.
|
|
1818
|
+
* @param mode - The start mode to embed in the next `agent.started` event
|
|
1819
|
+
*/
|
|
1820
|
+
setPendingStartMode(mode: StartMode): void;
|
|
1785
1821
|
protected emitCompletion(result: Omit<z.infer<typeof AgentSchemas.complete>, keyof AgentContext>): Promise<void>;
|
|
1786
1822
|
/**
|
|
1787
1823
|
* Stash error metadata for the next emitCompletion call.
|
|
@@ -1805,7 +1841,7 @@ declare abstract class AIAgent<TBus extends ScopedBus<string> = ScopedBus<string
|
|
|
1805
1841
|
* @param payload - The base payload to enrich
|
|
1806
1842
|
* @returns Payload with AgentContext fields and optional messageId added
|
|
1807
1843
|
*/
|
|
1808
|
-
protected enrichPayload<T extends object>(payload: T): Promise<T &
|
|
1844
|
+
protected enrichPayload<T extends object>(payload: T): Promise<T & AgentIdentity & {
|
|
1809
1845
|
messageId?: string;
|
|
1810
1846
|
}>;
|
|
1811
1847
|
/**
|
|
@@ -2012,46 +2048,46 @@ declare abstract class AIAgent<TBus extends ScopedBus<string> = ScopedBus<string
|
|
|
2012
2048
|
/**
|
|
2013
2049
|
* Ensure the connector is initialized, throwing if not.
|
|
2014
2050
|
* @returns The initialized connector instance
|
|
2015
|
-
* @throws Error if connector is not initialized
|
|
2016
2051
|
*/
|
|
2017
2052
|
private ensureConnector;
|
|
2018
2053
|
/**
|
|
2019
|
-
* Determine whether to use native session resume
|
|
2020
|
-
*
|
|
2021
|
-
* Native resume: SDK manages history, don't inject messageHistory, preserve cache.
|
|
2022
|
-
* Fresh with history: Create new session, inject messageHistory.
|
|
2023
|
-
*
|
|
2024
|
-
* Override in adapter-specific agents if needed.
|
|
2054
|
+
* Determine whether to use native session resume (SDK manages history) or
|
|
2055
|
+
* fresh-with-history (new session, injected messageHistory).
|
|
2025
2056
|
* @param sessionContext - Context signals from SessionOrchestrator
|
|
2026
2057
|
* @returns true if native resume should be used
|
|
2027
2058
|
*/
|
|
2028
2059
|
protected shouldUseNativeResume(sessionContext?: SessionContext): boolean;
|
|
2029
2060
|
/**
|
|
2030
|
-
* Whether this adapter supports native session resume.
|
|
2031
|
-
* Override in adapter-specific agents that can resume SDK sessions.
|
|
2061
|
+
* Whether this adapter supports native session resume. Override in concrete agents.
|
|
2032
2062
|
* @returns true if native resume is supported
|
|
2033
2063
|
*/
|
|
2034
2064
|
protected supportsNativeResume(): boolean;
|
|
2065
|
+
/**
|
|
2066
|
+
* Whether this adapter supports provider-native session fork.
|
|
2067
|
+
* Override in concrete agents that can branch from an existing provider session.
|
|
2068
|
+
* @returns true if native fork is supported
|
|
2069
|
+
*/
|
|
2070
|
+
protected supportsNativeFork(): boolean;
|
|
2035
2071
|
/**
|
|
2036
2072
|
* Start the agent with an initial message.
|
|
2037
2073
|
*
|
|
2038
|
-
* Ensures the agent is initialized (idempotent)
|
|
2039
|
-
*
|
|
2040
|
-
*
|
|
2041
|
-
* HookAbortError propagates to caller.
|
|
2074
|
+
* Ensures the agent is initialized (idempotent), runs PreUserMessage hooks,
|
|
2075
|
+
* and uses sessionContext signals to decide between native resume and fresh
|
|
2076
|
+
* with history. HookAbortError propagates to caller.
|
|
2042
2077
|
* @param message - User message (normalized or unnormalized)
|
|
2043
2078
|
* @param options - Optional start options (e.g., delivery mode, sessionContext)
|
|
2044
2079
|
* @returns Session ID, agent ID, and message handle for tracking
|
|
2045
2080
|
*/
|
|
2046
2081
|
start(message: NormalizedMessageInput | MessageInput, options?: StartAgentOptions): Promise<AgentStartResult>;
|
|
2047
2082
|
/**
|
|
2048
|
-
* Initialize
|
|
2049
|
-
*
|
|
2083
|
+
* Initialize idle (no message). Returns confirmed adapter session ID or `undefined`
|
|
2084
|
+
* when the provider has not yet confirmed (idle fork sessions).
|
|
2050
2085
|
* @param options - Optional initialization options (system prompt, sessionContext)
|
|
2086
|
+
* @returns Confirmed adapter session ID, or `undefined` for unconfirmed fork sessions.
|
|
2051
2087
|
*/
|
|
2052
|
-
initialize(options?: StartAgentOptions): Promise<
|
|
2088
|
+
initialize(options?: StartAgentOptions): Promise<string | undefined>;
|
|
2053
2089
|
protected onBeforeEmitCompletion(): Promise<void>;
|
|
2054
|
-
protected onMessageHandle(messageHandle: MessageHandle): Promise<void>;
|
|
2090
|
+
protected onMessageHandle(messageHandle: MessageHandle, turnId?: string): Promise<void>;
|
|
2055
2091
|
/**
|
|
2056
2092
|
* Abort the agent immediately (panic mode).
|
|
2057
2093
|
* Triggers AbortController which may cause provider errors.
|
|
@@ -2271,6 +2307,7 @@ declare class AgentEventBridge {
|
|
|
2271
2307
|
/**
|
|
2272
2308
|
* Runtime dependencies for AgentTurnExecutor.
|
|
2273
2309
|
*/
|
|
2310
|
+
type AgentMessageHandleCallback = (messageHandle: MessageHandle, turnId: string | undefined) => Promise<void>;
|
|
2274
2311
|
interface AgentTurnExecutorConfig {
|
|
2275
2312
|
/** Stable agent identifier. */
|
|
2276
2313
|
agentId: string;
|
|
@@ -2286,8 +2323,26 @@ interface AgentTurnExecutorConfig {
|
|
|
2286
2323
|
getConnector: () => AIAgentConnector;
|
|
2287
2324
|
/** Native resume decision function. */
|
|
2288
2325
|
shouldUseNativeResume: ShouldUseNativeResumeFn;
|
|
2326
|
+
/**
|
|
2327
|
+
* Whether the agent config carries a concrete resume target
|
|
2328
|
+
* (`resumeAdapterSessionId`).
|
|
2329
|
+
*
|
|
2330
|
+
* Used by {@link AgentTurnExecutor.deriveStartMode} to distinguish
|
|
2331
|
+
* native-attach starts (resume target, no sessionContext) from
|
|
2332
|
+
* truly sessionless/ephemeral starts (no resume target, no context).
|
|
2333
|
+
*/
|
|
2334
|
+
hasResumeTarget: () => boolean;
|
|
2335
|
+
/**
|
|
2336
|
+
* Set the start mode on the owning agent before connector dispatch.
|
|
2337
|
+
*
|
|
2338
|
+
* The turn executor computes the mode from session context signals and
|
|
2339
|
+
* calls this so `emitStart()` can include it in the `agent.started`
|
|
2340
|
+
* payload when the connector fires its lifecycle event.
|
|
2341
|
+
* @param mode - Derived start mode for this turn
|
|
2342
|
+
*/
|
|
2343
|
+
setPendingStartMode: (mode: StartMode) => void;
|
|
2289
2344
|
/** Completion/lifecycle tracker hook. */
|
|
2290
|
-
onMessageHandle:
|
|
2345
|
+
onMessageHandle: AgentMessageHandleCallback;
|
|
2291
2346
|
/** Side-effect callback to mark agent status active before dispatch. */
|
|
2292
2347
|
onBeforeDispatch?: () => void | Promise<void>;
|
|
2293
2348
|
/** When true, PreUserMessage hooks are skipped. */
|
|
@@ -2308,10 +2363,51 @@ declare class AgentTurnExecutor {
|
|
|
2308
2363
|
private readonly globalBus;
|
|
2309
2364
|
private readonly getConnector;
|
|
2310
2365
|
private readonly shouldUseNativeResume;
|
|
2366
|
+
private readonly hasResumeTarget;
|
|
2367
|
+
private readonly setPendingStartMode;
|
|
2311
2368
|
private readonly onMessageHandle;
|
|
2312
2369
|
private readonly onBeforeDispatch?;
|
|
2313
2370
|
private readonly ephemeral;
|
|
2314
2371
|
constructor(config: AgentTurnExecutorConfig);
|
|
2372
|
+
/**
|
|
2373
|
+
* Derive the {@link StartMode} from session context, resume decision, and
|
|
2374
|
+
* resume-target presence.
|
|
2375
|
+
*
|
|
2376
|
+
* Decision table (evaluated top-to-bottom, first match wins):
|
|
2377
|
+
*
|
|
2378
|
+
* | sessionContext | nativeFork | hasResumeTarget | useNativeResume | isFirstTurn | Mode |
|
|
2379
|
+
* |----------------|------------|-----------------|-----------------|-------------|------------|
|
|
2380
|
+
* | present | yes | — | — | — | `fork` |
|
|
2381
|
+
* | absent | — | yes | — | — | `resume` |
|
|
2382
|
+
* | absent | — | no | — | — | `fresh` |
|
|
2383
|
+
* | present | no | — | true | — | `resume` |
|
|
2384
|
+
* | present | no | — | false | true | `fresh` |
|
|
2385
|
+
* | present | no | — | false | false | `rotation` |
|
|
2386
|
+
*
|
|
2387
|
+
* The `hasResumeTarget` rule distinguishes native-attach starts (concrete
|
|
2388
|
+
* provider session to reconnect to, but no orchestrator session context) from
|
|
2389
|
+
* truly sessionless/ephemeral starts. Without this signal, both cases
|
|
2390
|
+
* collapsed to `'fresh'` — causing SDK SessionStart hooks to run
|
|
2391
|
+
* initialization logic on a resumed conversation.
|
|
2392
|
+
*
|
|
2393
|
+
* `hasResumeTarget` fires only when sessionContext is absent. Once the
|
|
2394
|
+
* orchestrator supplies context (turn 2+), rules 4-6 take over and the
|
|
2395
|
+
* resume target on the config has no further effect on mode derivation.
|
|
2396
|
+
* @param sessionContext - Session context signals from the orchestrator
|
|
2397
|
+
* @param useNativeResume - Whether native resume was selected for this turn
|
|
2398
|
+
* @param hasResumeTarget - Whether a concrete resume target
|
|
2399
|
+
* (`resumeAdapterSessionId`) exists on the agent config
|
|
2400
|
+
* @returns The derived start mode
|
|
2401
|
+
*/
|
|
2402
|
+
static deriveStartMode(sessionContext: SessionContext | undefined, useNativeResume: boolean, hasResumeTarget?: boolean): StartMode;
|
|
2403
|
+
/**
|
|
2404
|
+
* Derive the start mode for the given resolved session context, stash it
|
|
2405
|
+
* as the pending mode for the next lifecycle start emission, and return
|
|
2406
|
+
* the native-resume decision shared by the dispatch that follows.
|
|
2407
|
+
* @param sessionContext - Session context after pre-user-message hooks
|
|
2408
|
+
* @returns Whether the connector should rely on native resume
|
|
2409
|
+
*/
|
|
2410
|
+
private deriveAndSetPendingStartMode;
|
|
2315
2411
|
/**
|
|
2316
2412
|
* Execute the turn pipeline for agent.sendMessage.
|
|
2317
2413
|
* @param payload - agent.sendMessage request payload
|
|
@@ -2358,6 +2454,43 @@ type AgentCreationOptions = Omit<Partial<Pick<StartAgentRequestPayload, 'model'
|
|
|
2358
2454
|
adapterSessionId?: string;
|
|
2359
2455
|
resumeAdapterSessionId?: string; /** Unresolved provider context (credential refs, not plaintext). */
|
|
2360
2456
|
providerContext?: ProviderContext;
|
|
2457
|
+
/**
|
|
2458
|
+
* Source Makaio session ID when mode is 'fork'.
|
|
2459
|
+
* Forwarded verbatim from the fork-mode startAgent request.
|
|
2460
|
+
*/
|
|
2461
|
+
sourceSessionId?: string;
|
|
2462
|
+
/**
|
|
2463
|
+
* Provider-native source session ID when mode is 'fork'.
|
|
2464
|
+
* Forwarded verbatim from the fork-mode startAgent request.
|
|
2465
|
+
*/
|
|
2466
|
+
sourceAdapterSessionId?: string;
|
|
2467
|
+
/**
|
|
2468
|
+
* Optional provider-native checkpoint message ID for the fork point.
|
|
2469
|
+
* Forwarded verbatim from the fork-mode startAgent request.
|
|
2470
|
+
*/
|
|
2471
|
+
forkPointMessageId?: string;
|
|
2472
|
+
/**
|
|
2473
|
+
* Optional working directory override for the forked session.
|
|
2474
|
+
* Forwarded verbatim from the fork-mode startAgent request.
|
|
2475
|
+
*/
|
|
2476
|
+
targetWorkingDirectory?: string;
|
|
2477
|
+
/**
|
|
2478
|
+
* Orchestrator-assembled session context carrying fork directives,
|
|
2479
|
+
* native-locality decisions, and other session-scoped metadata.
|
|
2480
|
+
*
|
|
2481
|
+
* Present when the session orchestrator attaches context to a startAgent
|
|
2482
|
+
* request (e.g. fork-mode locality evaluation).
|
|
2483
|
+
*/
|
|
2484
|
+
sessionContext?: SessionContext;
|
|
2485
|
+
/**
|
|
2486
|
+
* Provider-native fork directive assembled from the startAgent fork-mode fields.
|
|
2487
|
+
*
|
|
2488
|
+
* Present when the adapter is started in fork mode and a native fork is feasible.
|
|
2489
|
+
* When `mode` is 'fork', `buildNativeForkDirective()` constructs this from the
|
|
2490
|
+
* individual fork fields above. When pre-built (e.g. from rehydration), it is
|
|
2491
|
+
* passed through directly.
|
|
2492
|
+
*/
|
|
2493
|
+
nativeFork?: NativeForkDirective;
|
|
2361
2494
|
};
|
|
2362
2495
|
/**
|
|
2363
2496
|
* Cumulative usage totals tracked per agent.
|
|
@@ -2614,8 +2747,6 @@ interface AgentPayloadEmitterConfig {
|
|
|
2614
2747
|
getLastKnownAdapterSessionId: () => string | undefined;
|
|
2615
2748
|
/** Persist latest adapterSessionId after resolution. */
|
|
2616
2749
|
setLastKnownAdapterSessionId: (adapterSessionId: string | undefined) => void;
|
|
2617
|
-
/** Async fallback to wait for adapter session ID. */
|
|
2618
|
-
getAdapterSessionId: () => Promise<string>;
|
|
2619
2750
|
/** Live event metadata defaults resolved from current runtime state. */
|
|
2620
2751
|
getEventMetadataDefaults: () => AgentPayloadEventMetadata;
|
|
2621
2752
|
}
|
|
@@ -2629,6 +2760,33 @@ declare class AgentPayloadEmitter {
|
|
|
2629
2760
|
* @param config - Config controlling agent-context enrichment and global emissions
|
|
2630
2761
|
*/
|
|
2631
2762
|
constructor(config: AgentPayloadEmitterConfig);
|
|
2763
|
+
/**
|
|
2764
|
+
* Resolve the confirmed adapter session ID from synchronous sources.
|
|
2765
|
+
*
|
|
2766
|
+
* `getConnectorAdapterSessionId` delegates to `getConfirmedAdapterSessionId()`
|
|
2767
|
+
* which returns `undefined` for unconfirmed fork sessions — the provider has
|
|
2768
|
+
* not yet assigned the child session ID. For non-fork sessions (fresh, resume,
|
|
2769
|
+
* non-Claude adapters) the locally-determined ID is authoritative and returned
|
|
2770
|
+
* immediately.
|
|
2771
|
+
*
|
|
2772
|
+
* The `lastKnownAdapterSessionId` bridges connector swaps: when the old
|
|
2773
|
+
* connector is gone and the new one is not yet wired, the cached value carries
|
|
2774
|
+
* the confirmed ID from the previous connector.
|
|
2775
|
+
*
|
|
2776
|
+
* No async fallback is used. `connector.getAdapterSessionId()` may resolve
|
|
2777
|
+
* with a provisional placeholder for fork sessions. Enrichment must never
|
|
2778
|
+
* stamp unconfirmed IDs — omitting the field is safe since R8 schemas allow
|
|
2779
|
+
* it optional.
|
|
2780
|
+
* @returns Confirmed adapter session ID or `undefined`
|
|
2781
|
+
*/
|
|
2782
|
+
private resolveConfirmedAdapterSessionId;
|
|
2783
|
+
/**
|
|
2784
|
+
* Resolve event metadata fields, merging caller-provided values over live defaults.
|
|
2785
|
+
* @param payload - Payload fields that may carry metadata overrides
|
|
2786
|
+
* @param includeMetadata - Whether to include analytics metadata at all
|
|
2787
|
+
* @returns Resolved metadata fields
|
|
2788
|
+
*/
|
|
2789
|
+
private resolveEventMetadata;
|
|
2632
2790
|
/**
|
|
2633
2791
|
* Enrich payload with agent context fields.
|
|
2634
2792
|
* @param payload - Base payload to enrich
|
|
@@ -2636,7 +2794,7 @@ declare class AgentPayloadEmitter {
|
|
|
2636
2794
|
* @param options - Enrichment controls for optional analytics metadata defaults
|
|
2637
2795
|
* @returns Enriched payload with agent context
|
|
2638
2796
|
*/
|
|
2639
|
-
enrichPayload<T extends object>(payload: T, overrideMessageId?: string, options?: EmitGlobalOptions): Promise<T &
|
|
2797
|
+
enrichPayload<T extends object>(payload: T, overrideMessageId?: string, options?: EmitGlobalOptions): Promise<T & AgentIdentity & AgentPayloadEventFields>;
|
|
2640
2798
|
/**
|
|
2641
2799
|
* Emit enriched payload to global bus.
|
|
2642
2800
|
* @param subject - Subject definition to emit
|
|
@@ -2645,6 +2803,7 @@ declare class AgentPayloadEmitter {
|
|
|
2645
2803
|
*/
|
|
2646
2804
|
emitGlobal<S extends SubjectDefinition>(subject: S, payload: Omit<ExtractSubjectPayload<S>, keyof AgentContext> & {
|
|
2647
2805
|
messageId?: string;
|
|
2806
|
+
turnId?: string;
|
|
2648
2807
|
}, options?: EmitGlobalOptions): Promise<void>;
|
|
2649
2808
|
}
|
|
2650
2809
|
//#endregion
|
|
@@ -2971,18 +3130,16 @@ declare abstract class AIAdapter<TBus extends ScopedBus<string> = ScopedBus<stri
|
|
|
2971
3130
|
*/
|
|
2972
3131
|
private handleSessionClosedByService;
|
|
2973
3132
|
/**
|
|
2974
|
-
*
|
|
2975
|
-
* @param ctx - Event context with
|
|
3133
|
+
* Reconcile registry adapterSessionId on first confirmed agent.started (idle fork starts).
|
|
3134
|
+
* @param ctx - Event context with started payload
|
|
2976
3135
|
*/
|
|
2977
|
-
private
|
|
3136
|
+
private handleStartedReconcileRegistry;
|
|
2978
3137
|
/**
|
|
2979
|
-
*
|
|
2980
|
-
*
|
|
2981
|
-
* Safe to call multiple times - subsequent calls are no-ops.
|
|
2982
|
-
*
|
|
2983
|
-
* Note: Agents are NOT eagerly rehydrated on startup. They are rehydrated
|
|
2984
|
-
* on-demand when messages arrive (lazy rehydration via handleRehydrateAgent).
|
|
3138
|
+
* Handle agent.usage — aggregate and emit session totals.
|
|
3139
|
+
* @param ctx - Event context with usage payload
|
|
2985
3140
|
*/
|
|
3141
|
+
private handleUsage;
|
|
3142
|
+
/** Initialize adapter (idempotent). Creates scoped bus, sets up handlers, emits adapter.initialized. */
|
|
2986
3143
|
init(): Promise<void>;
|
|
2987
3144
|
/** Hook for subclass initialization. Override to perform async setup (connections, auth, etc.). */
|
|
2988
3145
|
protected onInit(): Promise<void>;
|
|
@@ -3351,6 +3508,28 @@ interface ConformanceTestConfig<TBus extends ScopedBus<string> = ScopedBus<strin
|
|
|
3351
3508
|
* **Free-Tier Adapters**: `false` (no usage tracking)
|
|
3352
3509
|
*/
|
|
3353
3510
|
supportsUsageMetrics?: boolean;
|
|
3511
|
+
/**
|
|
3512
|
+
* Supports provider-native session resume.
|
|
3513
|
+
*
|
|
3514
|
+
* When enabled, the adapter can resume a prior provider session by its
|
|
3515
|
+
* `adapterSessionId` without injecting the full message history. The SDK
|
|
3516
|
+
* manages conversation state natively.
|
|
3517
|
+
*
|
|
3518
|
+
* **Claude Code**: `true` (resumes via Claude Agent SDK session IDs)
|
|
3519
|
+
* **Stateless Adapters**: `false` (always replay history)
|
|
3520
|
+
*/
|
|
3521
|
+
nativeResume?: boolean;
|
|
3522
|
+
/**
|
|
3523
|
+
* Supports provider-native session fork.
|
|
3524
|
+
*
|
|
3525
|
+
* When enabled, the adapter can branch from an existing provider session
|
|
3526
|
+
* at an optional message checkpoint, creating a diverging conversation
|
|
3527
|
+
* without replaying history into a fresh session.
|
|
3528
|
+
*
|
|
3529
|
+
* **Claude Code**: `true` (forks via Claude Agent SDK branching API)
|
|
3530
|
+
* **Stateless Adapters**: `false` (always replay history for fork)
|
|
3531
|
+
*/
|
|
3532
|
+
nativeFork?: boolean;
|
|
3354
3533
|
};
|
|
3355
3534
|
/**
|
|
3356
3535
|
* Test configuration and environment options.
|