@cognipeer/agent-sdk 0.2.1 → 0.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +447 -163
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +58 -4
- package/dist/index.d.ts +58 -4
- package/dist/index.mjs +447 -163
- 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;
|
|
@@ -183,6 +194,10 @@ type SmartAgentOptions = {
|
|
|
183
194
|
summarization?: boolean | {
|
|
184
195
|
enable: boolean;
|
|
185
196
|
maxTokens: number;
|
|
197
|
+
/** Max tokens to include in the summarization prompt itself (to avoid sending huge context to summarizer). Default: 8000 */
|
|
198
|
+
summaryPromptMaxTokens?: number;
|
|
199
|
+
/** Optional prompt template. Use {{conversation}} and {{previousSummary}} placeholders. */
|
|
200
|
+
promptTemplate?: string;
|
|
186
201
|
};
|
|
187
202
|
systemPrompt?: string;
|
|
188
203
|
useTodoList?: boolean;
|
|
@@ -476,6 +491,23 @@ type MetadataEvent = {
|
|
|
476
491
|
limits?: SmartAgentLimits;
|
|
477
492
|
[key: string]: any;
|
|
478
493
|
};
|
|
494
|
+
type ProgressEvent = {
|
|
495
|
+
type: "progress";
|
|
496
|
+
stage?: string;
|
|
497
|
+
message?: string;
|
|
498
|
+
percent?: number;
|
|
499
|
+
detail?: any;
|
|
500
|
+
};
|
|
501
|
+
type StreamEvent = {
|
|
502
|
+
type: "stream";
|
|
503
|
+
text: string;
|
|
504
|
+
isFinal?: boolean;
|
|
505
|
+
};
|
|
506
|
+
type CancelledEvent = {
|
|
507
|
+
type: "cancelled";
|
|
508
|
+
stage?: string;
|
|
509
|
+
reason?: string;
|
|
510
|
+
};
|
|
479
511
|
type HandoffEvent = {
|
|
480
512
|
type: "handoff";
|
|
481
513
|
from?: string;
|
|
@@ -526,9 +558,31 @@ type GuardrailEvent = {
|
|
|
526
558
|
reason?: string;
|
|
527
559
|
details?: Record<string, any>;
|
|
528
560
|
};
|
|
529
|
-
type SmartAgentEvent = ToolCallEvent | ToolApprovalEvent | PlanEvent | SummarizationEvent | FinalAnswerEvent | MetadataEvent | HandoffEvent | GuardrailEvent;
|
|
561
|
+
type SmartAgentEvent = ToolCallEvent | ToolApprovalEvent | PlanEvent | SummarizationEvent | FinalAnswerEvent | MetadataEvent | HandoffEvent | GuardrailEvent | ProgressEvent | StreamEvent | CancelledEvent;
|
|
562
|
+
type CancellationTokenLike = {
|
|
563
|
+
readonly isCancellationRequested: boolean;
|
|
564
|
+
onCancellationRequested?: (listener: () => void) => {
|
|
565
|
+
dispose(): void;
|
|
566
|
+
} | void;
|
|
567
|
+
};
|
|
568
|
+
type ProgressUpdate = {
|
|
569
|
+
stage?: string;
|
|
570
|
+
message?: string;
|
|
571
|
+
percent?: number;
|
|
572
|
+
detail?: any;
|
|
573
|
+
};
|
|
574
|
+
type StreamChunk = {
|
|
575
|
+
text: string;
|
|
576
|
+
isFinal?: boolean;
|
|
577
|
+
};
|
|
530
578
|
type InvokeConfig = RunnableConfig & {
|
|
531
579
|
onEvent?: (event: SmartAgentEvent) => void;
|
|
580
|
+
onProgress?: (progress: ProgressUpdate) => void;
|
|
581
|
+
onStream?: (chunk: StreamChunk) => void;
|
|
582
|
+
stream?: boolean;
|
|
583
|
+
cancellationToken?: CancellationTokenLike | AbortSignal;
|
|
584
|
+
timeoutMs?: number;
|
|
585
|
+
limits?: Partial<AgentLimits>;
|
|
532
586
|
onStateChange?: (state: SmartState) => boolean;
|
|
533
587
|
checkpointReason?: string;
|
|
534
588
|
};
|
|
@@ -722,13 +776,13 @@ declare const guardianSchema: z.ZodObject<{
|
|
|
722
776
|
details: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
723
777
|
}, "strip", z.ZodTypeAny, {
|
|
724
778
|
allow: boolean;
|
|
725
|
-
disposition?: "block" | "warn" | "allow" | undefined;
|
|
726
779
|
reason?: string | undefined;
|
|
780
|
+
disposition?: "block" | "warn" | "allow" | undefined;
|
|
727
781
|
details?: Record<string, any> | undefined;
|
|
728
782
|
}, {
|
|
729
783
|
allow: boolean;
|
|
730
|
-
disposition?: "block" | "warn" | "allow" | undefined;
|
|
731
784
|
reason?: string | undefined;
|
|
785
|
+
disposition?: "block" | "warn" | "allow" | undefined;
|
|
732
786
|
details?: Record<string, any> | undefined;
|
|
733
787
|
}>;
|
|
734
788
|
type AgentRuleOptions = {
|
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;
|
|
@@ -183,6 +194,10 @@ type SmartAgentOptions = {
|
|
|
183
194
|
summarization?: boolean | {
|
|
184
195
|
enable: boolean;
|
|
185
196
|
maxTokens: number;
|
|
197
|
+
/** Max tokens to include in the summarization prompt itself (to avoid sending huge context to summarizer). Default: 8000 */
|
|
198
|
+
summaryPromptMaxTokens?: number;
|
|
199
|
+
/** Optional prompt template. Use {{conversation}} and {{previousSummary}} placeholders. */
|
|
200
|
+
promptTemplate?: string;
|
|
186
201
|
};
|
|
187
202
|
systemPrompt?: string;
|
|
188
203
|
useTodoList?: boolean;
|
|
@@ -476,6 +491,23 @@ type MetadataEvent = {
|
|
|
476
491
|
limits?: SmartAgentLimits;
|
|
477
492
|
[key: string]: any;
|
|
478
493
|
};
|
|
494
|
+
type ProgressEvent = {
|
|
495
|
+
type: "progress";
|
|
496
|
+
stage?: string;
|
|
497
|
+
message?: string;
|
|
498
|
+
percent?: number;
|
|
499
|
+
detail?: any;
|
|
500
|
+
};
|
|
501
|
+
type StreamEvent = {
|
|
502
|
+
type: "stream";
|
|
503
|
+
text: string;
|
|
504
|
+
isFinal?: boolean;
|
|
505
|
+
};
|
|
506
|
+
type CancelledEvent = {
|
|
507
|
+
type: "cancelled";
|
|
508
|
+
stage?: string;
|
|
509
|
+
reason?: string;
|
|
510
|
+
};
|
|
479
511
|
type HandoffEvent = {
|
|
480
512
|
type: "handoff";
|
|
481
513
|
from?: string;
|
|
@@ -526,9 +558,31 @@ type GuardrailEvent = {
|
|
|
526
558
|
reason?: string;
|
|
527
559
|
details?: Record<string, any>;
|
|
528
560
|
};
|
|
529
|
-
type SmartAgentEvent = ToolCallEvent | ToolApprovalEvent | PlanEvent | SummarizationEvent | FinalAnswerEvent | MetadataEvent | HandoffEvent | GuardrailEvent;
|
|
561
|
+
type SmartAgentEvent = ToolCallEvent | ToolApprovalEvent | PlanEvent | SummarizationEvent | FinalAnswerEvent | MetadataEvent | HandoffEvent | GuardrailEvent | ProgressEvent | StreamEvent | CancelledEvent;
|
|
562
|
+
type CancellationTokenLike = {
|
|
563
|
+
readonly isCancellationRequested: boolean;
|
|
564
|
+
onCancellationRequested?: (listener: () => void) => {
|
|
565
|
+
dispose(): void;
|
|
566
|
+
} | void;
|
|
567
|
+
};
|
|
568
|
+
type ProgressUpdate = {
|
|
569
|
+
stage?: string;
|
|
570
|
+
message?: string;
|
|
571
|
+
percent?: number;
|
|
572
|
+
detail?: any;
|
|
573
|
+
};
|
|
574
|
+
type StreamChunk = {
|
|
575
|
+
text: string;
|
|
576
|
+
isFinal?: boolean;
|
|
577
|
+
};
|
|
530
578
|
type InvokeConfig = RunnableConfig & {
|
|
531
579
|
onEvent?: (event: SmartAgentEvent) => void;
|
|
580
|
+
onProgress?: (progress: ProgressUpdate) => void;
|
|
581
|
+
onStream?: (chunk: StreamChunk) => void;
|
|
582
|
+
stream?: boolean;
|
|
583
|
+
cancellationToken?: CancellationTokenLike | AbortSignal;
|
|
584
|
+
timeoutMs?: number;
|
|
585
|
+
limits?: Partial<AgentLimits>;
|
|
532
586
|
onStateChange?: (state: SmartState) => boolean;
|
|
533
587
|
checkpointReason?: string;
|
|
534
588
|
};
|
|
@@ -722,13 +776,13 @@ declare const guardianSchema: z.ZodObject<{
|
|
|
722
776
|
details: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
723
777
|
}, "strip", z.ZodTypeAny, {
|
|
724
778
|
allow: boolean;
|
|
725
|
-
disposition?: "block" | "warn" | "allow" | undefined;
|
|
726
779
|
reason?: string | undefined;
|
|
780
|
+
disposition?: "block" | "warn" | "allow" | undefined;
|
|
727
781
|
details?: Record<string, any> | undefined;
|
|
728
782
|
}, {
|
|
729
783
|
allow: boolean;
|
|
730
|
-
disposition?: "block" | "warn" | "allow" | undefined;
|
|
731
784
|
reason?: string | undefined;
|
|
785
|
+
disposition?: "block" | "warn" | "allow" | undefined;
|
|
732
786
|
details?: Record<string, any> | undefined;
|
|
733
787
|
}>;
|
|
734
788
|
type AgentRuleOptions = {
|