@cognipeer/agent-sdk 0.2.2 → 0.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +693 -164
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +108 -6
- package/dist/index.d.ts +108 -6
- package/dist/index.mjs +693 -165
- package/dist/index.mjs.map +1 -1
- package/package.json +13 -2
package/dist/index.d.cts
CHANGED
|
@@ -25,7 +25,18 @@ interface BaseChatMessage {
|
|
|
25
25
|
[key: string]: any;
|
|
26
26
|
}
|
|
27
27
|
interface BaseChatModel {
|
|
28
|
-
invoke(messages: BaseChatMessage[]
|
|
28
|
+
invoke(messages: BaseChatMessage[], options?: {
|
|
29
|
+
signal?: AbortSignal;
|
|
30
|
+
cancellationToken?: {
|
|
31
|
+
isCancellationRequested: boolean;
|
|
32
|
+
};
|
|
33
|
+
}): Promise<BaseChatMessage>;
|
|
34
|
+
stream?(messages: BaseChatMessage[], options?: {
|
|
35
|
+
signal?: AbortSignal;
|
|
36
|
+
cancellationToken?: {
|
|
37
|
+
isCancellationRequested: boolean;
|
|
38
|
+
};
|
|
39
|
+
}): AsyncIterable<BaseChatMessage | BaseChatMessagePart | string>;
|
|
29
40
|
bindTools?(tools: any[]): BaseChatModel;
|
|
30
41
|
modelName?: string;
|
|
31
42
|
[key: string]: any;
|
|
@@ -154,9 +165,15 @@ type TraceSinkHttpConfig = {
|
|
|
154
165
|
headers?: Record<string, string>;
|
|
155
166
|
};
|
|
156
167
|
type TraceSinkConfig = TraceSinkFileConfig | TraceSinkCustomConfig | TraceSinkCognipeerConfig | TraceSinkHttpConfig;
|
|
168
|
+
type TracingMode = "batched" | "streaming";
|
|
157
169
|
type TracingConfig = {
|
|
158
170
|
enabled: boolean;
|
|
159
171
|
logData?: boolean;
|
|
172
|
+
/** Tracing mode:
|
|
173
|
+
* - "batched" (default): Events are collected and sent together when session ends
|
|
174
|
+
* - "streaming": Session starts immediately, events are sent in real-time as they occur
|
|
175
|
+
*/
|
|
176
|
+
mode?: TracingMode;
|
|
160
177
|
sink?: TraceSinkConfig;
|
|
161
178
|
};
|
|
162
179
|
type SmartAgentTracingConfig = TracingConfig;
|
|
@@ -185,6 +202,8 @@ type SmartAgentOptions = {
|
|
|
185
202
|
maxTokens: number;
|
|
186
203
|
/** Max tokens to include in the summarization prompt itself (to avoid sending huge context to summarizer). Default: 8000 */
|
|
187
204
|
summaryPromptMaxTokens?: number;
|
|
205
|
+
/** Optional prompt template. Use {{conversation}} and {{previousSummary}} placeholders. */
|
|
206
|
+
promptTemplate?: string;
|
|
188
207
|
};
|
|
189
208
|
systemPrompt?: string;
|
|
190
209
|
useTodoList?: boolean;
|
|
@@ -359,10 +378,30 @@ type ResolvedTraceSink = {
|
|
|
359
378
|
};
|
|
360
379
|
type ResolvedTraceConfig = {
|
|
361
380
|
enabled: boolean;
|
|
362
|
-
mode:
|
|
381
|
+
mode: TracingMode;
|
|
363
382
|
logData: boolean;
|
|
364
383
|
sink: ResolvedTraceSink;
|
|
365
384
|
};
|
|
385
|
+
type TraceSessionRuntime = {
|
|
386
|
+
sessionId: string;
|
|
387
|
+
startedAt: number;
|
|
388
|
+
resolvedConfig: ResolvedTraceConfig;
|
|
389
|
+
events: TraceEventRecord[];
|
|
390
|
+
summary: TraceSessionSummary;
|
|
391
|
+
status: TraceSessionStatus;
|
|
392
|
+
errors: TraceErrorRecord[];
|
|
393
|
+
fileBaseDir?: string;
|
|
394
|
+
fileSessionDir?: string;
|
|
395
|
+
/** For streaming mode: whether session start has been sent to sink */
|
|
396
|
+
sessionStarted?: boolean;
|
|
397
|
+
/** Agent info for streaming mode session start */
|
|
398
|
+
agentInfo?: {
|
|
399
|
+
name?: string;
|
|
400
|
+
version?: string;
|
|
401
|
+
model?: string;
|
|
402
|
+
provider?: string;
|
|
403
|
+
};
|
|
404
|
+
};
|
|
366
405
|
type HandoffDescriptor<TParsed = any> = {
|
|
367
406
|
type: "handoff";
|
|
368
407
|
toolName: string;
|
|
@@ -465,6 +504,25 @@ type PlanEvent = {
|
|
|
465
504
|
type SummarizationEvent = {
|
|
466
505
|
type: "summarization";
|
|
467
506
|
summary: string;
|
|
507
|
+
/** Number of messages that were compressed/summarized */
|
|
508
|
+
messagesCompressed?: number;
|
|
509
|
+
/** Input tokens used for summarization prompt (from model response if available, otherwise estimated) */
|
|
510
|
+
inputTokens?: number;
|
|
511
|
+
/** Output tokens from summarization response (from model response if available, otherwise estimated) */
|
|
512
|
+
outputTokens?: number;
|
|
513
|
+
/** Cached input tokens from model response (prompt cache hit) */
|
|
514
|
+
cachedInputTokens?: number;
|
|
515
|
+
/** Total tokens (input + output) */
|
|
516
|
+
totalTokens?: number;
|
|
517
|
+
/** Duration of the summarization call in milliseconds */
|
|
518
|
+
durationMs?: number;
|
|
519
|
+
/** Previous summary content (if incremental summarization) */
|
|
520
|
+
previousSummary?: string;
|
|
521
|
+
/** Total token count before summarization */
|
|
522
|
+
tokenCountBefore?: number;
|
|
523
|
+
/** Total token count after summarization */
|
|
524
|
+
tokenCountAfter?: number;
|
|
525
|
+
/** @deprecated Use messagesCompressed instead */
|
|
468
526
|
archivedCount?: number;
|
|
469
527
|
};
|
|
470
528
|
type FinalAnswerEvent = {
|
|
@@ -478,6 +536,23 @@ type MetadataEvent = {
|
|
|
478
536
|
limits?: SmartAgentLimits;
|
|
479
537
|
[key: string]: any;
|
|
480
538
|
};
|
|
539
|
+
type ProgressEvent = {
|
|
540
|
+
type: "progress";
|
|
541
|
+
stage?: string;
|
|
542
|
+
message?: string;
|
|
543
|
+
percent?: number;
|
|
544
|
+
detail?: any;
|
|
545
|
+
};
|
|
546
|
+
type StreamEvent = {
|
|
547
|
+
type: "stream";
|
|
548
|
+
text: string;
|
|
549
|
+
isFinal?: boolean;
|
|
550
|
+
};
|
|
551
|
+
type CancelledEvent = {
|
|
552
|
+
type: "cancelled";
|
|
553
|
+
stage?: string;
|
|
554
|
+
reason?: string;
|
|
555
|
+
};
|
|
481
556
|
type HandoffEvent = {
|
|
482
557
|
type: "handoff";
|
|
483
558
|
from?: string;
|
|
@@ -528,9 +603,31 @@ type GuardrailEvent = {
|
|
|
528
603
|
reason?: string;
|
|
529
604
|
details?: Record<string, any>;
|
|
530
605
|
};
|
|
531
|
-
type SmartAgentEvent = ToolCallEvent | ToolApprovalEvent | PlanEvent | SummarizationEvent | FinalAnswerEvent | MetadataEvent | HandoffEvent | GuardrailEvent;
|
|
606
|
+
type SmartAgentEvent = ToolCallEvent | ToolApprovalEvent | PlanEvent | SummarizationEvent | FinalAnswerEvent | MetadataEvent | HandoffEvent | GuardrailEvent | ProgressEvent | StreamEvent | CancelledEvent;
|
|
607
|
+
type CancellationTokenLike = {
|
|
608
|
+
readonly isCancellationRequested: boolean;
|
|
609
|
+
onCancellationRequested?: (listener: () => void) => {
|
|
610
|
+
dispose(): void;
|
|
611
|
+
} | void;
|
|
612
|
+
};
|
|
613
|
+
type ProgressUpdate = {
|
|
614
|
+
stage?: string;
|
|
615
|
+
message?: string;
|
|
616
|
+
percent?: number;
|
|
617
|
+
detail?: any;
|
|
618
|
+
};
|
|
619
|
+
type StreamChunk = {
|
|
620
|
+
text: string;
|
|
621
|
+
isFinal?: boolean;
|
|
622
|
+
};
|
|
532
623
|
type InvokeConfig = RunnableConfig & {
|
|
533
624
|
onEvent?: (event: SmartAgentEvent) => void;
|
|
625
|
+
onProgress?: (progress: ProgressUpdate) => void;
|
|
626
|
+
onStream?: (chunk: StreamChunk) => void;
|
|
627
|
+
stream?: boolean;
|
|
628
|
+
cancellationToken?: CancellationTokenLike | AbortSignal;
|
|
629
|
+
timeoutMs?: number;
|
|
630
|
+
limits?: Partial<AgentLimits>;
|
|
534
631
|
onStateChange?: (state: SmartState) => boolean;
|
|
535
632
|
checkpointReason?: string;
|
|
536
633
|
};
|
|
@@ -724,13 +821,13 @@ declare const guardianSchema: z.ZodObject<{
|
|
|
724
821
|
details: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
725
822
|
}, "strip", z.ZodTypeAny, {
|
|
726
823
|
allow: boolean;
|
|
727
|
-
disposition?: "block" | "warn" | "allow" | undefined;
|
|
728
824
|
reason?: string | undefined;
|
|
825
|
+
disposition?: "block" | "warn" | "allow" | undefined;
|
|
729
826
|
details?: Record<string, any> | undefined;
|
|
730
827
|
}, {
|
|
731
828
|
allow: boolean;
|
|
732
|
-
disposition?: "block" | "warn" | "allow" | undefined;
|
|
733
829
|
reason?: string | undefined;
|
|
830
|
+
disposition?: "block" | "warn" | "allow" | undefined;
|
|
734
831
|
details?: Record<string, any> | undefined;
|
|
735
832
|
}>;
|
|
736
833
|
type AgentRuleOptions = {
|
|
@@ -801,5 +898,10 @@ declare function customSink(handler: CustomSinkArg): TraceSinkConfig;
|
|
|
801
898
|
declare function cognipeerSink(apiKey: string): TraceSinkConfig;
|
|
802
899
|
declare function cognipeerSink(url: string | undefined, apiKey: string): TraceSinkConfig;
|
|
803
900
|
declare function httpSink(url: string, headers?: Record<string, string>): TraceSinkConfig;
|
|
901
|
+
/**
|
|
902
|
+
* Start a streaming trace session. Should be called before recording events in streaming mode.
|
|
903
|
+
* This sends the session start to the remote endpoint immediately.
|
|
904
|
+
*/
|
|
905
|
+
declare function startStreamingSession(session: TraceSessionRuntime | undefined, agentRuntime?: AgentRuntimeConfig): Promise<void>;
|
|
804
906
|
|
|
805
|
-
export { type AIMessage, type AgentInstance, type AgentInvokeResult, type AgentLimits, type AgentOptions, type AgentRuleOptions, type AgentRuntimeConfig, type AgentSnapshot, type AgentSnapshotMetadata, type AgentState, type BaseChatMessage, type BaseChatMessagePart, type BaseChatModel, type BaseMessage, type CodeDetectionRuleOptions, type CodeGuardrailOptions, type ConversationGuardrail, type CustomRuleCallback, type CustomRuleOptions, type GuardrailContext, type GuardrailDisposition, type GuardrailEvent, type GuardrailIncident, type GuardrailOutcome, GuardrailPhase, type GuardrailRule, type HandoffDescriptor, type InvokeConfig, type JsonGuardrailOptions, type JsonSchemaRuleOptions, type Message, type PendingToolApproval, type RegexGuardrailOptions, type RegexRuleOptions, type ResolvedTraceConfig, type ResolvedTraceSink, type RestoreSnapshotOptions, type SerializableSmartState, type SmartAgentEvent, type SmartAgentInstance, type SmartAgentLimits, type SmartAgentOptions, type SmartAgentTracingConfig, type SmartModel, type SmartState, type SmartToolFn, type SnapshotOptions, type SnapshotRuntimeHint, type TokenLimits, type ToolApprovalEvent, type ToolApprovalResolution, type ToolInterface, type TraceDataSection, type TraceErrorRecord, type TraceEventRecord, type TraceMessageSection, type TraceMetadataSection, type TraceSessionConfigSnapshot, type TraceSessionFile, type TraceSessionStatus, type TraceSessionSummary, type TraceSinkCognipeerConfig, type TraceSinkConfig, type TraceSinkCustomConfig, type TraceSinkFileConfig, type TraceSinkHttpConfig, type TraceSinkSnapshot, type TraceSummarySection, type TraceToolCallSection, type TraceToolResultSection, type TracingConfig, agentVerdictRule, applyTokenLimits, buildSystemPrompt, captureSnapshot, codePresenceRule, cognipeerSink, countApproxTokens, createAgent, createAgentNode, createCodeGuardrail, createContextSummarizeNode, createContextTools, createGuardrail, createJsonGuardrail, createRegexGuardrail, createResolverNode, createSmartAgent, createTool, createToolLimitFinalizeNode, createToolsNode, customCallbackRule, customSink, evaluateGuardrails, fileSink, fromLangchainModel, fromLangchainTools, httpSink, isSmartModel, jsonSchemaRule, regexRule, resolveToolApprovalState, restoreSnapshot, withTools };
|
|
907
|
+
export { type AIMessage, type AgentInstance, type AgentInvokeResult, type AgentLimits, type AgentOptions, type AgentRuleOptions, type AgentRuntimeConfig, type AgentSnapshot, type AgentSnapshotMetadata, type AgentState, type BaseChatMessage, type BaseChatMessagePart, type BaseChatModel, type BaseMessage, type CodeDetectionRuleOptions, type CodeGuardrailOptions, type ConversationGuardrail, type CustomRuleCallback, type CustomRuleOptions, type GuardrailContext, type GuardrailDisposition, type GuardrailEvent, type GuardrailIncident, type GuardrailOutcome, GuardrailPhase, type GuardrailRule, type HandoffDescriptor, type InvokeConfig, type JsonGuardrailOptions, type JsonSchemaRuleOptions, type Message, type PendingToolApproval, type RegexGuardrailOptions, type RegexRuleOptions, type ResolvedTraceConfig, type ResolvedTraceSink, type RestoreSnapshotOptions, type SerializableSmartState, type SmartAgentEvent, type SmartAgentInstance, type SmartAgentLimits, type SmartAgentOptions, type SmartAgentTracingConfig, type SmartModel, type SmartState, type SmartToolFn, type SnapshotOptions, type SnapshotRuntimeHint, type TokenLimits, type ToolApprovalEvent, type ToolApprovalResolution, type ToolInterface, type TraceDataSection, type TraceErrorRecord, type TraceEventRecord, type TraceMessageSection, type TraceMetadataSection, type TraceSessionConfigSnapshot, type TraceSessionFile, type TraceSessionStatus, type TraceSessionSummary, type TraceSinkCognipeerConfig, type TraceSinkConfig, type TraceSinkCustomConfig, type TraceSinkFileConfig, type TraceSinkHttpConfig, type TraceSinkSnapshot, type TraceSummarySection, type TraceToolCallSection, type TraceToolResultSection, type TracingConfig, type TracingMode, agentVerdictRule, applyTokenLimits, buildSystemPrompt, captureSnapshot, codePresenceRule, cognipeerSink, countApproxTokens, createAgent, createAgentNode, createCodeGuardrail, createContextSummarizeNode, createContextTools, createGuardrail, createJsonGuardrail, createRegexGuardrail, createResolverNode, createSmartAgent, createTool, createToolLimitFinalizeNode, createToolsNode, customCallbackRule, customSink, evaluateGuardrails, fileSink, fromLangchainModel, fromLangchainTools, httpSink, isSmartModel, jsonSchemaRule, regexRule, resolveToolApprovalState, restoreSnapshot, startStreamingSession, withTools };
|
package/dist/index.d.ts
CHANGED
|
@@ -25,7 +25,18 @@ interface BaseChatMessage {
|
|
|
25
25
|
[key: string]: any;
|
|
26
26
|
}
|
|
27
27
|
interface BaseChatModel {
|
|
28
|
-
invoke(messages: BaseChatMessage[]
|
|
28
|
+
invoke(messages: BaseChatMessage[], options?: {
|
|
29
|
+
signal?: AbortSignal;
|
|
30
|
+
cancellationToken?: {
|
|
31
|
+
isCancellationRequested: boolean;
|
|
32
|
+
};
|
|
33
|
+
}): Promise<BaseChatMessage>;
|
|
34
|
+
stream?(messages: BaseChatMessage[], options?: {
|
|
35
|
+
signal?: AbortSignal;
|
|
36
|
+
cancellationToken?: {
|
|
37
|
+
isCancellationRequested: boolean;
|
|
38
|
+
};
|
|
39
|
+
}): AsyncIterable<BaseChatMessage | BaseChatMessagePart | string>;
|
|
29
40
|
bindTools?(tools: any[]): BaseChatModel;
|
|
30
41
|
modelName?: string;
|
|
31
42
|
[key: string]: any;
|
|
@@ -154,9 +165,15 @@ type TraceSinkHttpConfig = {
|
|
|
154
165
|
headers?: Record<string, string>;
|
|
155
166
|
};
|
|
156
167
|
type TraceSinkConfig = TraceSinkFileConfig | TraceSinkCustomConfig | TraceSinkCognipeerConfig | TraceSinkHttpConfig;
|
|
168
|
+
type TracingMode = "batched" | "streaming";
|
|
157
169
|
type TracingConfig = {
|
|
158
170
|
enabled: boolean;
|
|
159
171
|
logData?: boolean;
|
|
172
|
+
/** Tracing mode:
|
|
173
|
+
* - "batched" (default): Events are collected and sent together when session ends
|
|
174
|
+
* - "streaming": Session starts immediately, events are sent in real-time as they occur
|
|
175
|
+
*/
|
|
176
|
+
mode?: TracingMode;
|
|
160
177
|
sink?: TraceSinkConfig;
|
|
161
178
|
};
|
|
162
179
|
type SmartAgentTracingConfig = TracingConfig;
|
|
@@ -185,6 +202,8 @@ type SmartAgentOptions = {
|
|
|
185
202
|
maxTokens: number;
|
|
186
203
|
/** Max tokens to include in the summarization prompt itself (to avoid sending huge context to summarizer). Default: 8000 */
|
|
187
204
|
summaryPromptMaxTokens?: number;
|
|
205
|
+
/** Optional prompt template. Use {{conversation}} and {{previousSummary}} placeholders. */
|
|
206
|
+
promptTemplate?: string;
|
|
188
207
|
};
|
|
189
208
|
systemPrompt?: string;
|
|
190
209
|
useTodoList?: boolean;
|
|
@@ -359,10 +378,30 @@ type ResolvedTraceSink = {
|
|
|
359
378
|
};
|
|
360
379
|
type ResolvedTraceConfig = {
|
|
361
380
|
enabled: boolean;
|
|
362
|
-
mode:
|
|
381
|
+
mode: TracingMode;
|
|
363
382
|
logData: boolean;
|
|
364
383
|
sink: ResolvedTraceSink;
|
|
365
384
|
};
|
|
385
|
+
type TraceSessionRuntime = {
|
|
386
|
+
sessionId: string;
|
|
387
|
+
startedAt: number;
|
|
388
|
+
resolvedConfig: ResolvedTraceConfig;
|
|
389
|
+
events: TraceEventRecord[];
|
|
390
|
+
summary: TraceSessionSummary;
|
|
391
|
+
status: TraceSessionStatus;
|
|
392
|
+
errors: TraceErrorRecord[];
|
|
393
|
+
fileBaseDir?: string;
|
|
394
|
+
fileSessionDir?: string;
|
|
395
|
+
/** For streaming mode: whether session start has been sent to sink */
|
|
396
|
+
sessionStarted?: boolean;
|
|
397
|
+
/** Agent info for streaming mode session start */
|
|
398
|
+
agentInfo?: {
|
|
399
|
+
name?: string;
|
|
400
|
+
version?: string;
|
|
401
|
+
model?: string;
|
|
402
|
+
provider?: string;
|
|
403
|
+
};
|
|
404
|
+
};
|
|
366
405
|
type HandoffDescriptor<TParsed = any> = {
|
|
367
406
|
type: "handoff";
|
|
368
407
|
toolName: string;
|
|
@@ -465,6 +504,25 @@ type PlanEvent = {
|
|
|
465
504
|
type SummarizationEvent = {
|
|
466
505
|
type: "summarization";
|
|
467
506
|
summary: string;
|
|
507
|
+
/** Number of messages that were compressed/summarized */
|
|
508
|
+
messagesCompressed?: number;
|
|
509
|
+
/** Input tokens used for summarization prompt (from model response if available, otherwise estimated) */
|
|
510
|
+
inputTokens?: number;
|
|
511
|
+
/** Output tokens from summarization response (from model response if available, otherwise estimated) */
|
|
512
|
+
outputTokens?: number;
|
|
513
|
+
/** Cached input tokens from model response (prompt cache hit) */
|
|
514
|
+
cachedInputTokens?: number;
|
|
515
|
+
/** Total tokens (input + output) */
|
|
516
|
+
totalTokens?: number;
|
|
517
|
+
/** Duration of the summarization call in milliseconds */
|
|
518
|
+
durationMs?: number;
|
|
519
|
+
/** Previous summary content (if incremental summarization) */
|
|
520
|
+
previousSummary?: string;
|
|
521
|
+
/** Total token count before summarization */
|
|
522
|
+
tokenCountBefore?: number;
|
|
523
|
+
/** Total token count after summarization */
|
|
524
|
+
tokenCountAfter?: number;
|
|
525
|
+
/** @deprecated Use messagesCompressed instead */
|
|
468
526
|
archivedCount?: number;
|
|
469
527
|
};
|
|
470
528
|
type FinalAnswerEvent = {
|
|
@@ -478,6 +536,23 @@ type MetadataEvent = {
|
|
|
478
536
|
limits?: SmartAgentLimits;
|
|
479
537
|
[key: string]: any;
|
|
480
538
|
};
|
|
539
|
+
type ProgressEvent = {
|
|
540
|
+
type: "progress";
|
|
541
|
+
stage?: string;
|
|
542
|
+
message?: string;
|
|
543
|
+
percent?: number;
|
|
544
|
+
detail?: any;
|
|
545
|
+
};
|
|
546
|
+
type StreamEvent = {
|
|
547
|
+
type: "stream";
|
|
548
|
+
text: string;
|
|
549
|
+
isFinal?: boolean;
|
|
550
|
+
};
|
|
551
|
+
type CancelledEvent = {
|
|
552
|
+
type: "cancelled";
|
|
553
|
+
stage?: string;
|
|
554
|
+
reason?: string;
|
|
555
|
+
};
|
|
481
556
|
type HandoffEvent = {
|
|
482
557
|
type: "handoff";
|
|
483
558
|
from?: string;
|
|
@@ -528,9 +603,31 @@ type GuardrailEvent = {
|
|
|
528
603
|
reason?: string;
|
|
529
604
|
details?: Record<string, any>;
|
|
530
605
|
};
|
|
531
|
-
type SmartAgentEvent = ToolCallEvent | ToolApprovalEvent | PlanEvent | SummarizationEvent | FinalAnswerEvent | MetadataEvent | HandoffEvent | GuardrailEvent;
|
|
606
|
+
type SmartAgentEvent = ToolCallEvent | ToolApprovalEvent | PlanEvent | SummarizationEvent | FinalAnswerEvent | MetadataEvent | HandoffEvent | GuardrailEvent | ProgressEvent | StreamEvent | CancelledEvent;
|
|
607
|
+
type CancellationTokenLike = {
|
|
608
|
+
readonly isCancellationRequested: boolean;
|
|
609
|
+
onCancellationRequested?: (listener: () => void) => {
|
|
610
|
+
dispose(): void;
|
|
611
|
+
} | void;
|
|
612
|
+
};
|
|
613
|
+
type ProgressUpdate = {
|
|
614
|
+
stage?: string;
|
|
615
|
+
message?: string;
|
|
616
|
+
percent?: number;
|
|
617
|
+
detail?: any;
|
|
618
|
+
};
|
|
619
|
+
type StreamChunk = {
|
|
620
|
+
text: string;
|
|
621
|
+
isFinal?: boolean;
|
|
622
|
+
};
|
|
532
623
|
type InvokeConfig = RunnableConfig & {
|
|
533
624
|
onEvent?: (event: SmartAgentEvent) => void;
|
|
625
|
+
onProgress?: (progress: ProgressUpdate) => void;
|
|
626
|
+
onStream?: (chunk: StreamChunk) => void;
|
|
627
|
+
stream?: boolean;
|
|
628
|
+
cancellationToken?: CancellationTokenLike | AbortSignal;
|
|
629
|
+
timeoutMs?: number;
|
|
630
|
+
limits?: Partial<AgentLimits>;
|
|
534
631
|
onStateChange?: (state: SmartState) => boolean;
|
|
535
632
|
checkpointReason?: string;
|
|
536
633
|
};
|
|
@@ -724,13 +821,13 @@ declare const guardianSchema: z.ZodObject<{
|
|
|
724
821
|
details: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
725
822
|
}, "strip", z.ZodTypeAny, {
|
|
726
823
|
allow: boolean;
|
|
727
|
-
disposition?: "block" | "warn" | "allow" | undefined;
|
|
728
824
|
reason?: string | undefined;
|
|
825
|
+
disposition?: "block" | "warn" | "allow" | undefined;
|
|
729
826
|
details?: Record<string, any> | undefined;
|
|
730
827
|
}, {
|
|
731
828
|
allow: boolean;
|
|
732
|
-
disposition?: "block" | "warn" | "allow" | undefined;
|
|
733
829
|
reason?: string | undefined;
|
|
830
|
+
disposition?: "block" | "warn" | "allow" | undefined;
|
|
734
831
|
details?: Record<string, any> | undefined;
|
|
735
832
|
}>;
|
|
736
833
|
type AgentRuleOptions = {
|
|
@@ -801,5 +898,10 @@ declare function customSink(handler: CustomSinkArg): TraceSinkConfig;
|
|
|
801
898
|
declare function cognipeerSink(apiKey: string): TraceSinkConfig;
|
|
802
899
|
declare function cognipeerSink(url: string | undefined, apiKey: string): TraceSinkConfig;
|
|
803
900
|
declare function httpSink(url: string, headers?: Record<string, string>): TraceSinkConfig;
|
|
901
|
+
/**
|
|
902
|
+
* Start a streaming trace session. Should be called before recording events in streaming mode.
|
|
903
|
+
* This sends the session start to the remote endpoint immediately.
|
|
904
|
+
*/
|
|
905
|
+
declare function startStreamingSession(session: TraceSessionRuntime | undefined, agentRuntime?: AgentRuntimeConfig): Promise<void>;
|
|
804
906
|
|
|
805
|
-
export { type AIMessage, type AgentInstance, type AgentInvokeResult, type AgentLimits, type AgentOptions, type AgentRuleOptions, type AgentRuntimeConfig, type AgentSnapshot, type AgentSnapshotMetadata, type AgentState, type BaseChatMessage, type BaseChatMessagePart, type BaseChatModel, type BaseMessage, type CodeDetectionRuleOptions, type CodeGuardrailOptions, type ConversationGuardrail, type CustomRuleCallback, type CustomRuleOptions, type GuardrailContext, type GuardrailDisposition, type GuardrailEvent, type GuardrailIncident, type GuardrailOutcome, GuardrailPhase, type GuardrailRule, type HandoffDescriptor, type InvokeConfig, type JsonGuardrailOptions, type JsonSchemaRuleOptions, type Message, type PendingToolApproval, type RegexGuardrailOptions, type RegexRuleOptions, type ResolvedTraceConfig, type ResolvedTraceSink, type RestoreSnapshotOptions, type SerializableSmartState, type SmartAgentEvent, type SmartAgentInstance, type SmartAgentLimits, type SmartAgentOptions, type SmartAgentTracingConfig, type SmartModel, type SmartState, type SmartToolFn, type SnapshotOptions, type SnapshotRuntimeHint, type TokenLimits, type ToolApprovalEvent, type ToolApprovalResolution, type ToolInterface, type TraceDataSection, type TraceErrorRecord, type TraceEventRecord, type TraceMessageSection, type TraceMetadataSection, type TraceSessionConfigSnapshot, type TraceSessionFile, type TraceSessionStatus, type TraceSessionSummary, type TraceSinkCognipeerConfig, type TraceSinkConfig, type TraceSinkCustomConfig, type TraceSinkFileConfig, type TraceSinkHttpConfig, type TraceSinkSnapshot, type TraceSummarySection, type TraceToolCallSection, type TraceToolResultSection, type TracingConfig, agentVerdictRule, applyTokenLimits, buildSystemPrompt, captureSnapshot, codePresenceRule, cognipeerSink, countApproxTokens, createAgent, createAgentNode, createCodeGuardrail, createContextSummarizeNode, createContextTools, createGuardrail, createJsonGuardrail, createRegexGuardrail, createResolverNode, createSmartAgent, createTool, createToolLimitFinalizeNode, createToolsNode, customCallbackRule, customSink, evaluateGuardrails, fileSink, fromLangchainModel, fromLangchainTools, httpSink, isSmartModel, jsonSchemaRule, regexRule, resolveToolApprovalState, restoreSnapshot, withTools };
|
|
907
|
+
export { type AIMessage, type AgentInstance, type AgentInvokeResult, type AgentLimits, type AgentOptions, type AgentRuleOptions, type AgentRuntimeConfig, type AgentSnapshot, type AgentSnapshotMetadata, type AgentState, type BaseChatMessage, type BaseChatMessagePart, type BaseChatModel, type BaseMessage, type CodeDetectionRuleOptions, type CodeGuardrailOptions, type ConversationGuardrail, type CustomRuleCallback, type CustomRuleOptions, type GuardrailContext, type GuardrailDisposition, type GuardrailEvent, type GuardrailIncident, type GuardrailOutcome, GuardrailPhase, type GuardrailRule, type HandoffDescriptor, type InvokeConfig, type JsonGuardrailOptions, type JsonSchemaRuleOptions, type Message, type PendingToolApproval, type RegexGuardrailOptions, type RegexRuleOptions, type ResolvedTraceConfig, type ResolvedTraceSink, type RestoreSnapshotOptions, type SerializableSmartState, type SmartAgentEvent, type SmartAgentInstance, type SmartAgentLimits, type SmartAgentOptions, type SmartAgentTracingConfig, type SmartModel, type SmartState, type SmartToolFn, type SnapshotOptions, type SnapshotRuntimeHint, type TokenLimits, type ToolApprovalEvent, type ToolApprovalResolution, type ToolInterface, type TraceDataSection, type TraceErrorRecord, type TraceEventRecord, type TraceMessageSection, type TraceMetadataSection, type TraceSessionConfigSnapshot, type TraceSessionFile, type TraceSessionStatus, type TraceSessionSummary, type TraceSinkCognipeerConfig, type TraceSinkConfig, type TraceSinkCustomConfig, type TraceSinkFileConfig, type TraceSinkHttpConfig, type TraceSinkSnapshot, type TraceSummarySection, type TraceToolCallSection, type TraceToolResultSection, type TracingConfig, type TracingMode, agentVerdictRule, applyTokenLimits, buildSystemPrompt, captureSnapshot, codePresenceRule, cognipeerSink, countApproxTokens, createAgent, createAgentNode, createCodeGuardrail, createContextSummarizeNode, createContextTools, createGuardrail, createJsonGuardrail, createRegexGuardrail, createResolverNode, createSmartAgent, createTool, createToolLimitFinalizeNode, createToolsNode, customCallbackRule, customSink, evaluateGuardrails, fileSink, fromLangchainModel, fromLangchainTools, httpSink, isSmartModel, jsonSchemaRule, regexRule, resolveToolApprovalState, restoreSnapshot, startStreamingSession, withTools };
|