@cognipeer/agent-sdk 0.3.0 → 0.4.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/README.md +36 -9
- package/dist/index.cjs +1939 -290
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +341 -35
- package/dist/index.d.ts +341 -35
- package/dist/index.mjs +1927 -292
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -2
package/dist/index.d.cts
CHANGED
|
@@ -73,6 +73,7 @@ interface ToolInterface<TInput = any, TOutput = any, TCallOptions = any> {
|
|
|
73
73
|
needsApproval?: boolean;
|
|
74
74
|
approvalPrompt?: string;
|
|
75
75
|
approvalDefaults?: any;
|
|
76
|
+
maxExecutionsPerRun?: number | null;
|
|
76
77
|
[key: string]: any;
|
|
77
78
|
}
|
|
78
79
|
type RunnableConfig = {
|
|
@@ -143,6 +144,7 @@ type GuardrailOutcome = {
|
|
|
143
144
|
type AgentLimits = {
|
|
144
145
|
maxToolCalls?: number;
|
|
145
146
|
maxParallelTools?: number;
|
|
147
|
+
maxContextTokens?: number;
|
|
146
148
|
};
|
|
147
149
|
type SmartAgentLimits = AgentLimits;
|
|
148
150
|
type TraceSinkFileConfig = {
|
|
@@ -164,15 +166,19 @@ type TraceSinkHttpConfig = {
|
|
|
164
166
|
url: string;
|
|
165
167
|
headers?: Record<string, string>;
|
|
166
168
|
};
|
|
167
|
-
type
|
|
169
|
+
type TraceSinkOtlpConfig = {
|
|
170
|
+
type: "otlp";
|
|
171
|
+
endpoint: string;
|
|
172
|
+
headers?: Record<string, string>;
|
|
173
|
+
};
|
|
168
174
|
type TracingMode = "batched" | "streaming";
|
|
175
|
+
type TraceSinkConfig = TraceSinkFileConfig | TraceSinkCustomConfig | TraceSinkCognipeerConfig | TraceSinkHttpConfig | TraceSinkOtlpConfig;
|
|
169
176
|
type TracingConfig = {
|
|
170
177
|
enabled: boolean;
|
|
171
178
|
mode?: TracingMode;
|
|
172
|
-
/** Thread identifier; groups multiple sessions across agents into a single thread. */
|
|
173
|
-
threadId?: string;
|
|
174
179
|
logData?: boolean;
|
|
175
180
|
sink?: TraceSinkConfig;
|
|
181
|
+
threadId?: string;
|
|
176
182
|
};
|
|
177
183
|
type SmartAgentTracingConfig = TracingConfig;
|
|
178
184
|
type AgentOptions = {
|
|
@@ -183,10 +189,169 @@ type AgentOptions = {
|
|
|
183
189
|
guardrails?: ConversationGuardrail[];
|
|
184
190
|
handoffs?: HandoffDescriptor[];
|
|
185
191
|
limits?: AgentLimits;
|
|
192
|
+
todoListPrompt?: string;
|
|
186
193
|
usageConverter?: (finalMessage: AIMessage, fullState: SmartState, model: any) => any;
|
|
187
194
|
outputSchema?: ZodSchema<any>;
|
|
188
195
|
tracing?: TracingConfig;
|
|
189
196
|
};
|
|
197
|
+
type BuiltInRuntimeProfile = "fast" | "balanced" | "deep" | "research";
|
|
198
|
+
type RuntimeProfile = BuiltInRuntimeProfile | "custom";
|
|
199
|
+
type SummarizationMode = "incremental" | "full_rewrite";
|
|
200
|
+
type ContextPolicy = "raw" | "summary_only" | "hybrid";
|
|
201
|
+
type ToolResponseRetentionPolicy = "keep_full" | "keep_structured" | "summarize_archive" | "drop";
|
|
202
|
+
type ToolResponseClassification = "critical" | "informative" | "verbose" | "redundant";
|
|
203
|
+
type PlanningMode = "off" | "todo" | "planner_executor" | "reasoning_then_tools";
|
|
204
|
+
type ReplanPolicy = "never" | "on_failure" | "on_conflict" | "every_n_steps";
|
|
205
|
+
type DelegationMode = "off" | "role_based" | "automatic";
|
|
206
|
+
type ChildContextPolicy = "minimal" | "scoped" | "full";
|
|
207
|
+
type MemoryProviderKind = "inMemory" | "redis" | "postgres" | "mongo" | "s3";
|
|
208
|
+
type MemoryScope = "session" | "user" | "workspace" | "tenant";
|
|
209
|
+
type MemoryWritePolicy = "manual" | "auto_important" | "always";
|
|
210
|
+
type MemoryReadPolicy = "recent_only" | "semantic" | "hybrid";
|
|
211
|
+
type MemoryFact = {
|
|
212
|
+
key: string;
|
|
213
|
+
value: string;
|
|
214
|
+
sourceTurn: number;
|
|
215
|
+
confidence: number;
|
|
216
|
+
ttl?: number | null;
|
|
217
|
+
obsolete?: boolean;
|
|
218
|
+
lastUpdatedAt?: string;
|
|
219
|
+
scope?: MemoryScope;
|
|
220
|
+
tags?: string[];
|
|
221
|
+
};
|
|
222
|
+
interface MemoryStore {
|
|
223
|
+
get(scope: MemoryScope, options?: {
|
|
224
|
+
includeObsolete?: boolean;
|
|
225
|
+
limit?: number;
|
|
226
|
+
}): Promise<MemoryFact[]>;
|
|
227
|
+
upsert(scope: MemoryScope, facts: MemoryFact[]): Promise<void>;
|
|
228
|
+
markObsolete(scope: MemoryScope, keys: string[]): Promise<void>;
|
|
229
|
+
semanticSearch?(scope: MemoryScope, query: string, options?: {
|
|
230
|
+
limit?: number;
|
|
231
|
+
}): Promise<MemoryFact[]>;
|
|
232
|
+
}
|
|
233
|
+
type SummaryFactItem = {
|
|
234
|
+
key: string;
|
|
235
|
+
value: string;
|
|
236
|
+
confidence?: number;
|
|
237
|
+
source?: string;
|
|
238
|
+
};
|
|
239
|
+
type StructuredSummary = {
|
|
240
|
+
stable_facts: SummaryFactItem[];
|
|
241
|
+
active_goals: string[];
|
|
242
|
+
open_questions: string[];
|
|
243
|
+
discarded_obsolete: string[];
|
|
244
|
+
rawSummary?: string;
|
|
245
|
+
};
|
|
246
|
+
type SummaryIntegrityCheck = {
|
|
247
|
+
passed: boolean;
|
|
248
|
+
criticalFactLoss: boolean;
|
|
249
|
+
obsoleteFactRevived: boolean;
|
|
250
|
+
notes: string[];
|
|
251
|
+
};
|
|
252
|
+
type PlanStepRecord = {
|
|
253
|
+
id: number;
|
|
254
|
+
step: string;
|
|
255
|
+
owner: "agent" | "user" | "tool" | string;
|
|
256
|
+
exitCriteria: string;
|
|
257
|
+
evidence?: string;
|
|
258
|
+
status: "not-started" | "in-progress" | "completed" | "blocked";
|
|
259
|
+
title?: string;
|
|
260
|
+
description?: string;
|
|
261
|
+
};
|
|
262
|
+
type SmartAgentSummarizationConfig = {
|
|
263
|
+
enable?: boolean;
|
|
264
|
+
maxTokens?: number;
|
|
265
|
+
summaryTriggerTokens?: number;
|
|
266
|
+
summaryPromptMaxTokens?: number;
|
|
267
|
+
summaryCompressionRatioTarget?: number;
|
|
268
|
+
summaryMode?: SummarizationMode;
|
|
269
|
+
promptTemplate?: string;
|
|
270
|
+
toolFreeCall?: boolean;
|
|
271
|
+
integrityCheck?: boolean;
|
|
272
|
+
};
|
|
273
|
+
type SmartAgentBudgetConfig = {
|
|
274
|
+
systemReserveTokens?: number;
|
|
275
|
+
goalsReserveTokens?: number;
|
|
276
|
+
recentTurnsReserveTokens?: number;
|
|
277
|
+
toolResponseReserveTokens?: number;
|
|
278
|
+
};
|
|
279
|
+
type SmartAgentContextConfig = {
|
|
280
|
+
policy?: ContextPolicy;
|
|
281
|
+
lastTurnsToKeep?: number;
|
|
282
|
+
toolResponsePolicy?: ToolResponseRetentionPolicy;
|
|
283
|
+
archiveLargeToolResponses?: boolean;
|
|
284
|
+
retrieveArchivedToolResponseOnDemand?: boolean;
|
|
285
|
+
budget?: SmartAgentBudgetConfig;
|
|
286
|
+
};
|
|
287
|
+
type SmartAgentPlanningConfig = {
|
|
288
|
+
mode?: PlanningMode;
|
|
289
|
+
replanPolicy?: ReplanPolicy;
|
|
290
|
+
everyNSteps?: number;
|
|
291
|
+
};
|
|
292
|
+
type SmartAgentDelegationConfig = {
|
|
293
|
+
mode?: DelegationMode;
|
|
294
|
+
maxDelegationDepth?: number;
|
|
295
|
+
maxChildCalls?: number;
|
|
296
|
+
maxParallelChild?: number;
|
|
297
|
+
childContextPolicy?: ChildContextPolicy;
|
|
298
|
+
requireJsonOutputContract?: boolean;
|
|
299
|
+
};
|
|
300
|
+
type SmartAgentMemoryConfig = {
|
|
301
|
+
provider?: MemoryProviderKind;
|
|
302
|
+
store?: MemoryStore;
|
|
303
|
+
scope?: MemoryScope;
|
|
304
|
+
writePolicy?: MemoryWritePolicy;
|
|
305
|
+
readPolicy?: MemoryReadPolicy;
|
|
306
|
+
};
|
|
307
|
+
type SmartAgentToolResponseConfig = {
|
|
308
|
+
maxToolResponseChars?: number;
|
|
309
|
+
maxToolResponseTokens?: number;
|
|
310
|
+
defaultPolicy?: ToolResponseRetentionPolicy;
|
|
311
|
+
largeResponsePolicy?: ToolResponseRetentionPolicy;
|
|
312
|
+
toolResponseRetentionByTool?: Record<string, ToolResponseRetentionPolicy>;
|
|
313
|
+
criticalTools?: string[];
|
|
314
|
+
schemaValidation?: "strict" | "warn";
|
|
315
|
+
retryOnSchemaError?: boolean;
|
|
316
|
+
fallbackPolicy?: ToolResponseRetentionPolicy;
|
|
317
|
+
};
|
|
318
|
+
type SmartAgentWatchdogConfig = {
|
|
319
|
+
enabled?: boolean;
|
|
320
|
+
tokenDriftThreshold?: number;
|
|
321
|
+
overToolingSpikeThreshold?: number;
|
|
322
|
+
contextRotThreshold?: number;
|
|
323
|
+
autoCompaction?: boolean;
|
|
324
|
+
autoReplanOnFailure?: boolean;
|
|
325
|
+
};
|
|
326
|
+
type SmartAgentCustomProfileConfig = {
|
|
327
|
+
extends?: BuiltInRuntimeProfile;
|
|
328
|
+
limits?: AgentLimits;
|
|
329
|
+
summarization?: SmartAgentSummarizationConfig;
|
|
330
|
+
context?: SmartAgentContextConfig;
|
|
331
|
+
planning?: SmartAgentPlanningConfig;
|
|
332
|
+
memory?: SmartAgentMemoryConfig;
|
|
333
|
+
delegation?: SmartAgentDelegationConfig;
|
|
334
|
+
toolResponses?: SmartAgentToolResponseConfig;
|
|
335
|
+
watchdog?: SmartAgentWatchdogConfig;
|
|
336
|
+
};
|
|
337
|
+
type ProfileConfig = {
|
|
338
|
+
limits: Required<AgentLimits>;
|
|
339
|
+
summarization: Required<SmartAgentSummarizationConfig>;
|
|
340
|
+
context: Required<SmartAgentContextConfig> & {
|
|
341
|
+
budget: Required<SmartAgentBudgetConfig>;
|
|
342
|
+
};
|
|
343
|
+
planning: Required<SmartAgentPlanningConfig>;
|
|
344
|
+
memory: Required<Omit<SmartAgentMemoryConfig, "store">> & {
|
|
345
|
+
store?: MemoryStore;
|
|
346
|
+
};
|
|
347
|
+
delegation: Required<SmartAgentDelegationConfig>;
|
|
348
|
+
toolResponses: Required<SmartAgentToolResponseConfig>;
|
|
349
|
+
watchdog: Required<SmartAgentWatchdogConfig>;
|
|
350
|
+
};
|
|
351
|
+
type ResolvedSmartAgentConfig = ProfileConfig & {
|
|
352
|
+
runtimeProfile: RuntimeProfile;
|
|
353
|
+
baseProfile: BuiltInRuntimeProfile;
|
|
354
|
+
};
|
|
190
355
|
type SmartAgentOptions = {
|
|
191
356
|
name?: string;
|
|
192
357
|
version?: string;
|
|
@@ -195,15 +360,18 @@ type SmartAgentOptions = {
|
|
|
195
360
|
guardrails?: ConversationGuardrail[];
|
|
196
361
|
handoffs?: HandoffDescriptor[];
|
|
197
362
|
limits?: AgentLimits;
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
363
|
+
runtimeProfile?: RuntimeProfile;
|
|
364
|
+
customProfile?: SmartAgentCustomProfileConfig;
|
|
365
|
+
summarization?: boolean | SmartAgentSummarizationConfig;
|
|
366
|
+
context?: SmartAgentContextConfig;
|
|
367
|
+
memory?: SmartAgentMemoryConfig;
|
|
368
|
+
planning?: SmartAgentPlanningConfig;
|
|
369
|
+
delegation?: SmartAgentDelegationConfig;
|
|
370
|
+
toolResponses?: SmartAgentToolResponseConfig;
|
|
371
|
+
watchdog?: SmartAgentWatchdogConfig;
|
|
206
372
|
systemPrompt?: string;
|
|
373
|
+
todoListPrompt?: string;
|
|
374
|
+
/** @deprecated Use planning.mode="todo" */
|
|
207
375
|
useTodoList?: boolean;
|
|
208
376
|
usageConverter?: (finalMessage: AIMessage, fullState: SmartState, model: any) => any;
|
|
209
377
|
outputSchema?: ZodSchema<any>;
|
|
@@ -216,10 +384,13 @@ type AgentRuntimeConfig = {
|
|
|
216
384
|
tools: Array<ToolInterface<any, any, any>>;
|
|
217
385
|
guardrails?: ConversationGuardrail[];
|
|
218
386
|
systemPrompt?: string;
|
|
387
|
+
todoListPrompt?: string;
|
|
219
388
|
limits?: AgentLimits;
|
|
220
389
|
useTodoList?: boolean;
|
|
221
390
|
outputSchema?: ZodSchema<any>;
|
|
222
391
|
tracing?: TracingConfig;
|
|
392
|
+
runtimeProfile?: RuntimeProfile;
|
|
393
|
+
smart?: ResolvedSmartAgentConfig;
|
|
223
394
|
};
|
|
224
395
|
type TraceMessageSection = {
|
|
225
396
|
id?: string;
|
|
@@ -259,6 +430,8 @@ type TraceToolResponseSection = {
|
|
|
259
430
|
summary?: string;
|
|
260
431
|
items?: TraceToolResultItem[];
|
|
261
432
|
output?: any;
|
|
433
|
+
classification?: ToolResponseClassification;
|
|
434
|
+
retentionPolicy?: ToolResponseRetentionPolicy;
|
|
262
435
|
};
|
|
263
436
|
type TraceSummarySection = {
|
|
264
437
|
id?: string;
|
|
@@ -280,6 +453,9 @@ type TraceEventRecord = {
|
|
|
280
453
|
label: string;
|
|
281
454
|
sequence: number;
|
|
282
455
|
timestamp: string;
|
|
456
|
+
traceId?: string;
|
|
457
|
+
spanId?: string;
|
|
458
|
+
parentSpanId?: string;
|
|
283
459
|
actor?: {
|
|
284
460
|
scope?: string;
|
|
285
461
|
name?: string;
|
|
@@ -335,6 +511,9 @@ type TraceSinkSnapshot = {
|
|
|
335
511
|
} | {
|
|
336
512
|
type: "http";
|
|
337
513
|
url: string;
|
|
514
|
+
} | {
|
|
515
|
+
type: "otlp";
|
|
516
|
+
endpoint: string;
|
|
338
517
|
};
|
|
339
518
|
type TraceSessionConfigSnapshot = {
|
|
340
519
|
enabled: boolean;
|
|
@@ -343,6 +522,8 @@ type TraceSessionConfigSnapshot = {
|
|
|
343
522
|
};
|
|
344
523
|
type TraceSessionFile = {
|
|
345
524
|
sessionId: string;
|
|
525
|
+
traceId?: string;
|
|
526
|
+
rootSpanId?: string;
|
|
346
527
|
threadId?: string;
|
|
347
528
|
startedAt: string;
|
|
348
529
|
endedAt?: string;
|
|
@@ -374,6 +555,10 @@ type ResolvedTraceSink = {
|
|
|
374
555
|
type: "http";
|
|
375
556
|
url: string;
|
|
376
557
|
headers?: Record<string, string>;
|
|
558
|
+
} | {
|
|
559
|
+
type: "otlp";
|
|
560
|
+
endpoint: string;
|
|
561
|
+
headers?: Record<string, string>;
|
|
377
562
|
};
|
|
378
563
|
type ResolvedTraceConfig = {
|
|
379
564
|
enabled: boolean;
|
|
@@ -383,15 +568,11 @@ type ResolvedTraceConfig = {
|
|
|
383
568
|
};
|
|
384
569
|
type TraceSessionRuntime = {
|
|
385
570
|
sessionId: string;
|
|
386
|
-
threadId?: string;
|
|
387
571
|
startedAt: number;
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
errors: TraceErrorRecord[];
|
|
393
|
-
fileBaseDir?: string;
|
|
394
|
-
fileSessionDir?: string;
|
|
572
|
+
traceId?: string;
|
|
573
|
+
rootSpanId?: string;
|
|
574
|
+
currentIterationSpanId?: string;
|
|
575
|
+
threadId?: string;
|
|
395
576
|
sessionStarted?: boolean;
|
|
396
577
|
agentInfo?: {
|
|
397
578
|
name?: string;
|
|
@@ -399,6 +580,13 @@ type TraceSessionRuntime = {
|
|
|
399
580
|
model?: string;
|
|
400
581
|
provider?: string;
|
|
401
582
|
};
|
|
583
|
+
resolvedConfig: ResolvedTraceConfig;
|
|
584
|
+
events: TraceEventRecord[];
|
|
585
|
+
summary: TraceSessionSummary;
|
|
586
|
+
status: TraceSessionStatus;
|
|
587
|
+
errors: TraceErrorRecord[];
|
|
588
|
+
fileBaseDir?: string;
|
|
589
|
+
fileSessionDir?: string;
|
|
402
590
|
};
|
|
403
591
|
type HandoffDescriptor<TParsed = any> = {
|
|
404
592
|
type: "handoff";
|
|
@@ -424,6 +612,11 @@ type AgentState = {
|
|
|
424
612
|
messageId?: string;
|
|
425
613
|
tool_call_id?: string;
|
|
426
614
|
fromCache?: boolean;
|
|
615
|
+
classification?: ToolResponseClassification;
|
|
616
|
+
retentionPolicy?: ToolResponseRetentionPolicy;
|
|
617
|
+
archiveId?: string;
|
|
618
|
+
summary?: string;
|
|
619
|
+
status?: "success" | "error" | "rejected" | "handoff";
|
|
427
620
|
}>;
|
|
428
621
|
toolCache?: Record<string, any>;
|
|
429
622
|
toolCallCount?: number;
|
|
@@ -450,6 +643,11 @@ type AgentState = {
|
|
|
450
643
|
};
|
|
451
644
|
type SmartState = AgentState & {
|
|
452
645
|
summaries?: string[];
|
|
646
|
+
summaryRecords?: Array<StructuredSummary & {
|
|
647
|
+
integrity?: SummaryIntegrityCheck;
|
|
648
|
+
createdAt?: string;
|
|
649
|
+
}>;
|
|
650
|
+
memoryFacts?: MemoryFact[];
|
|
453
651
|
toolHistoryArchived?: Array<{
|
|
454
652
|
executionId: string;
|
|
455
653
|
toolName: string;
|
|
@@ -462,17 +660,26 @@ type SmartState = AgentState & {
|
|
|
462
660
|
messageId?: string;
|
|
463
661
|
tool_call_id?: string;
|
|
464
662
|
fromCache?: boolean;
|
|
663
|
+
classification?: ToolResponseClassification;
|
|
664
|
+
retentionPolicy?: ToolResponseRetentionPolicy;
|
|
665
|
+
archiveId?: string;
|
|
666
|
+
summary?: string;
|
|
667
|
+
status?: "success" | "error" | "rejected" | "handoff";
|
|
465
668
|
}>;
|
|
466
669
|
plan?: {
|
|
467
670
|
version: number;
|
|
468
|
-
steps:
|
|
469
|
-
index: number;
|
|
470
|
-
title: string;
|
|
471
|
-
status: string;
|
|
472
|
-
}>;
|
|
671
|
+
steps: PlanStepRecord[];
|
|
473
672
|
lastUpdated?: string;
|
|
673
|
+
adherenceScore?: number;
|
|
474
674
|
} | null;
|
|
475
675
|
planVersion?: number;
|
|
676
|
+
watchdog?: {
|
|
677
|
+
tokenDrift?: number;
|
|
678
|
+
contextRotScore?: number;
|
|
679
|
+
overToolingRate?: number;
|
|
680
|
+
compactions?: number;
|
|
681
|
+
lastAction?: string;
|
|
682
|
+
};
|
|
476
683
|
};
|
|
477
684
|
type ToolCallEvent = {
|
|
478
685
|
type: "tool_call";
|
|
@@ -489,15 +696,10 @@ type ToolCallEvent = {
|
|
|
489
696
|
type PlanEvent = {
|
|
490
697
|
type: "plan";
|
|
491
698
|
source: "manage_todo_list" | "system";
|
|
492
|
-
operation?: "write" | "read";
|
|
493
|
-
todoList?:
|
|
494
|
-
id: number;
|
|
495
|
-
title: string;
|
|
496
|
-
description: string;
|
|
497
|
-
status: string;
|
|
498
|
-
evidence?: string;
|
|
499
|
-
}>;
|
|
699
|
+
operation?: "write" | "read" | "update";
|
|
700
|
+
todoList?: PlanStepRecord[];
|
|
500
701
|
version?: number;
|
|
702
|
+
adherenceScore?: number;
|
|
501
703
|
};
|
|
502
704
|
type SummarizationEvent = {
|
|
503
705
|
type: "summarization";
|
|
@@ -522,6 +724,62 @@ type SummarizationEvent = {
|
|
|
522
724
|
tokenCountAfter?: number;
|
|
523
725
|
/** @deprecated Use messagesCompressed instead */
|
|
524
726
|
archivedCount?: number;
|
|
727
|
+
structuredSummary?: StructuredSummary;
|
|
728
|
+
integrity?: SummaryIntegrityCheck;
|
|
729
|
+
};
|
|
730
|
+
type EvalFamily = "recall" | "state_continuity" | "summarization_fidelity" | "context_rollover" | "query_focused_summary";
|
|
731
|
+
type EvalCase = {
|
|
732
|
+
id: string;
|
|
733
|
+
family: EvalFamily;
|
|
734
|
+
prompt: string;
|
|
735
|
+
expectedPhrases?: string[];
|
|
736
|
+
forbiddenPhrases?: string[];
|
|
737
|
+
expectedFacts?: Array<{
|
|
738
|
+
key: string;
|
|
739
|
+
value: string;
|
|
740
|
+
}>;
|
|
741
|
+
expectedToolNames?: string[];
|
|
742
|
+
};
|
|
743
|
+
type EvalProfileDescriptor = {
|
|
744
|
+
label: string;
|
|
745
|
+
runtimeProfile: RuntimeProfile;
|
|
746
|
+
baseProfile?: BuiltInRuntimeProfile;
|
|
747
|
+
customProfile?: SmartAgentCustomProfileConfig;
|
|
748
|
+
};
|
|
749
|
+
type EvalProfileTarget = RuntimeProfile | EvalProfileDescriptor;
|
|
750
|
+
type EvalCaseResult = {
|
|
751
|
+
id: string;
|
|
752
|
+
family: EvalFamily;
|
|
753
|
+
success: boolean;
|
|
754
|
+
recallAccuracy: number;
|
|
755
|
+
obsoleteDropAccuracy: number;
|
|
756
|
+
trajectoryScore: number;
|
|
757
|
+
recoveryRate: number;
|
|
758
|
+
overToolingRate: number;
|
|
759
|
+
latencyMs: number;
|
|
760
|
+
totalTokens?: number;
|
|
761
|
+
profile: RuntimeProfile;
|
|
762
|
+
profileLabel?: string;
|
|
763
|
+
baseProfile?: BuiltInRuntimeProfile;
|
|
764
|
+
notes: string[];
|
|
765
|
+
};
|
|
766
|
+
type EvalHarnessMetrics = {
|
|
767
|
+
taskSuccess: number;
|
|
768
|
+
recallAccuracy: number;
|
|
769
|
+
obsoleteDropAccuracy: number;
|
|
770
|
+
trajectoryScore: number;
|
|
771
|
+
recoveryRate: number;
|
|
772
|
+
overToolingRate: number;
|
|
773
|
+
latencyMs: number;
|
|
774
|
+
totalTokens: number;
|
|
775
|
+
score: number;
|
|
776
|
+
};
|
|
777
|
+
type EvalHarnessResult = {
|
|
778
|
+
profile: RuntimeProfile;
|
|
779
|
+
profileLabel: string;
|
|
780
|
+
baseProfile?: BuiltInRuntimeProfile;
|
|
781
|
+
metrics: EvalHarnessMetrics;
|
|
782
|
+
cases: EvalCaseResult[];
|
|
525
783
|
};
|
|
526
784
|
type FinalAnswerEvent = {
|
|
527
785
|
type: "finalAnswer";
|
|
@@ -689,7 +947,7 @@ type AgentInstance<TOutput = unknown> = {
|
|
|
689
947
|
type SmartAgentInstance<TOutput = unknown> = AgentInstance<TOutput>;
|
|
690
948
|
|
|
691
949
|
type SmartToolFn = (args: any) => Promise<any> | any;
|
|
692
|
-
declare function createTool({ name, description, schema, func, needsApproval, approvalPrompt, approvalDefaults, }: {
|
|
950
|
+
declare function createTool({ name, description, schema, func, needsApproval, approvalPrompt, approvalDefaults, maxExecutionsPerRun, }: {
|
|
693
951
|
name: string;
|
|
694
952
|
description?: string;
|
|
695
953
|
schema: ZodSchema;
|
|
@@ -697,9 +955,10 @@ declare function createTool({ name, description, schema, func, needsApproval, ap
|
|
|
697
955
|
needsApproval?: boolean;
|
|
698
956
|
approvalPrompt?: string;
|
|
699
957
|
approvalDefaults?: any;
|
|
958
|
+
maxExecutionsPerRun?: number | null;
|
|
700
959
|
}): ToolInterface;
|
|
701
960
|
|
|
702
|
-
declare function buildSystemPrompt(extra?: string, planning?: boolean, name?: string): string;
|
|
961
|
+
declare function buildSystemPrompt(extra?: string, planning?: boolean | PlanningMode, name?: string, todoListPrompt?: string): string;
|
|
703
962
|
|
|
704
963
|
declare function createAgent<TOutput = unknown>(opts: AgentOptions & {
|
|
705
964
|
outputSchema?: ZodSchema<TOutput>;
|
|
@@ -771,6 +1030,8 @@ declare function createContextTools(stateRef: {
|
|
|
771
1030
|
toolHistory?: any[];
|
|
772
1031
|
toolHistoryArchived?: any[];
|
|
773
1032
|
todoList?: any[];
|
|
1033
|
+
planVersion?: number;
|
|
1034
|
+
adherenceScore?: number;
|
|
774
1035
|
}, opts?: {
|
|
775
1036
|
planningEnabled?: boolean;
|
|
776
1037
|
outputSchema?: any;
|
|
@@ -780,6 +1041,36 @@ declare function createSmartAgent<TOutput = unknown>(opts: SmartAgentOptions & {
|
|
|
780
1041
|
outputSchema?: ZodSchema<TOutput>;
|
|
781
1042
|
}): SmartAgentInstance<TOutput>;
|
|
782
1043
|
|
|
1044
|
+
type EvalHarnessParams = {
|
|
1045
|
+
profiles: EvalProfileTarget[];
|
|
1046
|
+
cases: EvalCase[];
|
|
1047
|
+
createAgent: (profile: RuntimeProfile, descriptor: EvalProfileDescriptor) => SmartAgentInstance<any>;
|
|
1048
|
+
};
|
|
1049
|
+
declare function runSmartAgentEvalHarness(params: EvalHarnessParams): Promise<EvalHarnessResult[]>;
|
|
1050
|
+
|
|
1051
|
+
declare class InMemoryMemoryStore implements MemoryStore {
|
|
1052
|
+
private readonly buckets;
|
|
1053
|
+
get(scope: MemoryScope, options?: {
|
|
1054
|
+
includeObsolete?: boolean;
|
|
1055
|
+
limit?: number;
|
|
1056
|
+
}): Promise<MemoryFact[]>;
|
|
1057
|
+
upsert(scope: MemoryScope, facts: MemoryFact[]): Promise<void>;
|
|
1058
|
+
markObsolete(scope: MemoryScope, keys: string[]): Promise<void>;
|
|
1059
|
+
semanticSearch(scope: MemoryScope, query: string, options?: {
|
|
1060
|
+
limit?: number;
|
|
1061
|
+
}): Promise<MemoryFact[]>;
|
|
1062
|
+
}
|
|
1063
|
+
declare function resolveMemoryStore(config: ResolvedSmartAgentConfig): MemoryStore | undefined;
|
|
1064
|
+
declare function readMemoryFacts(store: MemoryStore | undefined, config: ResolvedSmartAgentConfig, query: string): Promise<MemoryFact[]>;
|
|
1065
|
+
declare function writeSummaryFactsToMemory(store: MemoryStore | undefined, config: ResolvedSmartAgentConfig, summary: StructuredSummary | undefined, sourceTurn: number): Promise<MemoryFact[]>;
|
|
1066
|
+
declare function renderMemoryFacts(facts: MemoryFact[]): string;
|
|
1067
|
+
|
|
1068
|
+
declare const DEFAULT_PROFILE_CONFIGS: Record<BuiltInRuntimeProfile, ProfileConfig>;
|
|
1069
|
+
declare function normalizeSmartAgentOptions(opts: SmartAgentOptions): ResolvedSmartAgentConfig;
|
|
1070
|
+
declare function getResolvedSmartConfig(opts: SmartAgentOptions, runtime?: {
|
|
1071
|
+
smart?: ResolvedSmartAgentConfig | undefined;
|
|
1072
|
+
}): ResolvedSmartAgentConfig;
|
|
1073
|
+
|
|
783
1074
|
type GuardrailEvaluationParams = {
|
|
784
1075
|
guardrails?: ConversationGuardrail[];
|
|
785
1076
|
phase: GuardrailPhase;
|
|
@@ -916,10 +1207,25 @@ declare function customSink(handler: CustomSinkArg): TraceSinkConfig;
|
|
|
916
1207
|
declare function cognipeerSink(apiKey: string): TraceSinkConfig;
|
|
917
1208
|
declare function cognipeerSink(url: string | undefined, apiKey: string): TraceSinkConfig;
|
|
918
1209
|
declare function httpSink(url: string, headers?: Record<string, string>): TraceSinkConfig;
|
|
1210
|
+
/**
|
|
1211
|
+
* Create an OTLP/HTTP JSON sink that exports traces in OpenTelemetry format.
|
|
1212
|
+
* @param endpoint OTLP endpoint URL (e.g. "https://console.cognipeer.com/api/client/v1/traces")
|
|
1213
|
+
* @param headers Optional headers (e.g. { Authorization: "Bearer ..." })
|
|
1214
|
+
*/
|
|
1215
|
+
declare function otlpSink(endpoint: string, headers?: Record<string, string>): TraceSinkConfig;
|
|
1216
|
+
/**
|
|
1217
|
+
* Convert a complete TraceSessionFile into an OTLP ExportTraceServiceRequest (JSON).
|
|
1218
|
+
* Produces a root span for the session and child spans for each event.
|
|
1219
|
+
*/
|
|
1220
|
+
declare function traceSessionToOtlp(session: TraceSessionFile): Record<string, unknown>;
|
|
1221
|
+
/** Generate a W3C-compatible trace ID (32 hex chars / 128-bit). */
|
|
1222
|
+
declare function generateTraceId(): string;
|
|
1223
|
+
/** Generate an OTel span ID (16 hex chars / 64-bit). */
|
|
1224
|
+
declare function generateSpanId(): string;
|
|
919
1225
|
/**
|
|
920
1226
|
* Start a streaming trace session. Should be called before recording events in streaming mode.
|
|
921
1227
|
* This sends the session start to the remote endpoint immediately.
|
|
922
1228
|
*/
|
|
923
1229
|
declare function startStreamingSession(session: TraceSessionRuntime | undefined, agentRuntime?: AgentRuntimeConfig): Promise<void>;
|
|
924
1230
|
|
|
925
|
-
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, countMessagesTokens, 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 };
|
|
1231
|
+
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 BuiltInRuntimeProfile, type CancellationTokenLike, type CancelledEvent, type ChildContextPolicy, type CodeDetectionRuleOptions, type CodeGuardrailOptions, type ContextPolicy, type ConversationGuardrail, type CustomRuleCallback, type CustomRuleOptions, DEFAULT_PROFILE_CONFIGS, type DelegationMode, type EvalCase, type EvalCaseResult, type EvalFamily, type EvalHarnessMetrics, type EvalHarnessParams, type EvalHarnessResult, type EvalProfileDescriptor, type EvalProfileTarget, type FinalAnswerEvent, type GuardrailContext, type GuardrailDisposition, type GuardrailEvent, type GuardrailIncident, type GuardrailOutcome, GuardrailPhase, type GuardrailRule, type HandoffDescriptor, type HandoffEvent, InMemoryMemoryStore, type InvokeConfig, type JsonGuardrailOptions, type JsonSchemaRuleOptions, type MemoryFact, type MemoryProviderKind, type MemoryReadPolicy, type MemoryScope, type MemoryStore, type MemoryWritePolicy, type Message, type MetadataEvent, type PendingToolApproval, type PlanEvent, type PlanStepRecord, type PlanningMode, type ProfileConfig, type ProgressEvent, type ProgressUpdate, type RegexGuardrailOptions, type RegexRuleOptions, type ReplanPolicy, type ResolvedSmartAgentConfig, type ResolvedTraceConfig, type ResolvedTraceSink, type RestoreSnapshotOptions, type RuntimeProfile, type SerializableSmartState, type SmartAgentBudgetConfig, type SmartAgentContextConfig, type SmartAgentCustomProfileConfig, type SmartAgentDelegationConfig, type SmartAgentEvent, type SmartAgentInstance, type SmartAgentLimits, type SmartAgentMemoryConfig, type SmartAgentOptions, type SmartAgentPlanningConfig, type SmartAgentSummarizationConfig, type SmartAgentToolResponseConfig, type SmartAgentTracingConfig, type SmartAgentWatchdogConfig, type SmartModel, type SmartState, type SmartToolFn, type SnapshotOptions, type SnapshotRuntimeHint, type StreamChunk, type StreamEvent, type StructuredSummary, type SummarizationEvent, type SummarizationMode, type SummaryFactItem, type SummaryIntegrityCheck, type TokenLimits, type ToolApprovalEvent, type ToolApprovalResolution, type ToolApprovalStatus, type ToolCallEvent, type ToolInterface, type ToolResponseClassification, type ToolResponseRetentionPolicy, 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 TraceSinkOtlpConfig, type TraceSinkSnapshot, type TraceSummarySection, type TraceToolCallSection, type TraceToolResultSection, type TracingConfig, type TracingMode, agentVerdictRule, applyTokenLimits, buildSystemPrompt, captureSnapshot, codePresenceRule, cognipeerSink, countApproxTokens, countMessagesTokens, createAgent, createAgentNode, createCodeGuardrail, createContextSummarizeNode, createContextTools, createGuardrail, createJsonGuardrail, createRegexGuardrail, createResolverNode, createSmartAgent, createTool, createToolLimitFinalizeNode, createToolsNode, customCallbackRule, customSink, evaluateGuardrails, fileSink, fromLangchainModel, fromLangchainTools, generateSpanId, generateTraceId, getResolvedSmartConfig, httpSink, isSmartModel, jsonSchemaRule, normalizeSmartAgentOptions, otlpSink, readMemoryFacts, regexRule, renderMemoryFacts, resolveMemoryStore, resolveToolApprovalState, restoreSnapshot, runSmartAgentEvalHarness, startStreamingSession, traceSessionToOtlp, withTools, writeSummaryFactsToMemory };
|