@n8n/agents 0.6.0 → 0.8.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.
Files changed (148) hide show
  1. package/dist/build.tsbuildinfo +1 -1
  2. package/dist/index.d.ts +18 -11
  3. package/dist/index.js +37 -10
  4. package/dist/index.js.map +1 -1
  5. package/dist/integrations/langsmith.d.ts +2 -0
  6. package/dist/integrations/langsmith.js +117 -2
  7. package/dist/integrations/langsmith.js.map +1 -1
  8. package/dist/runtime/agent-runtime.d.ts +30 -19
  9. package/dist/runtime/agent-runtime.js +616 -280
  10. package/dist/runtime/agent-runtime.js.map +1 -1
  11. package/dist/runtime/background-task-tracker.d.ts +6 -0
  12. package/dist/runtime/background-task-tracker.js +26 -0
  13. package/dist/runtime/background-task-tracker.js.map +1 -0
  14. package/dist/runtime/deferred-tool-manager.d.ts +28 -0
  15. package/dist/runtime/deferred-tool-manager.js +205 -0
  16. package/dist/runtime/deferred-tool-manager.js.map +1 -0
  17. package/dist/runtime/event-bus.d.ts +1 -0
  18. package/dist/runtime/event-bus.js +3 -0
  19. package/dist/runtime/event-bus.js.map +1 -1
  20. package/dist/runtime/json-value.d.ts +2 -0
  21. package/dist/runtime/json-value.js +43 -0
  22. package/dist/runtime/json-value.js.map +1 -0
  23. package/dist/runtime/memory-store.d.ts +34 -11
  24. package/dist/runtime/memory-store.js +210 -8
  25. package/dist/runtime/memory-store.js.map +1 -1
  26. package/dist/runtime/message-list.d.ts +6 -7
  27. package/dist/runtime/message-list.js +50 -6
  28. package/dist/runtime/message-list.js.map +1 -1
  29. package/dist/runtime/messages.d.ts +0 -2
  30. package/dist/runtime/messages.js +127 -101
  31. package/dist/runtime/messages.js.map +1 -1
  32. package/dist/runtime/model-factory.js +117 -34
  33. package/dist/runtime/model-factory.js.map +1 -1
  34. package/dist/runtime/observation-log-defaults.d.ts +20 -0
  35. package/dist/runtime/observation-log-defaults.js +523 -0
  36. package/dist/runtime/observation-log-defaults.js.map +1 -0
  37. package/dist/runtime/observation-log-observer.d.ts +64 -0
  38. package/dist/runtime/observation-log-observer.js +235 -0
  39. package/dist/runtime/observation-log-observer.js.map +1 -0
  40. package/dist/runtime/observation-log-reflector.d.ts +36 -0
  41. package/dist/runtime/observation-log-reflector.js +292 -0
  42. package/dist/runtime/observation-log-reflector.js.map +1 -0
  43. package/dist/runtime/observation-log-renderer.d.ts +6 -0
  44. package/dist/runtime/observation-log-renderer.js +73 -0
  45. package/dist/runtime/observation-log-renderer.js.map +1 -0
  46. package/dist/runtime/observation-log-store.d.ts +3 -0
  47. package/dist/runtime/observation-log-store.js +26 -0
  48. package/dist/runtime/observation-log-store.js.map +1 -0
  49. package/dist/runtime/provider-credentials.d.ts +167 -0
  50. package/dist/runtime/provider-credentials.js +34 -0
  51. package/dist/runtime/provider-credentials.js.map +1 -0
  52. package/dist/runtime/runtime-helpers.d.ts +3 -4
  53. package/dist/runtime/runtime-helpers.js +6 -32
  54. package/dist/runtime/runtime-helpers.js.map +1 -1
  55. package/dist/runtime/scoped-memory-task-runner.d.ts +79 -0
  56. package/dist/runtime/scoped-memory-task-runner.js +134 -0
  57. package/dist/runtime/scoped-memory-task-runner.js.map +1 -0
  58. package/dist/runtime/stream.js +25 -43
  59. package/dist/runtime/stream.js.map +1 -1
  60. package/dist/runtime/strip-orphaned-tool-messages.js +1 -25
  61. package/dist/runtime/strip-orphaned-tool-messages.js.map +1 -1
  62. package/dist/runtime/title-generation.d.ts +12 -3
  63. package/dist/runtime/title-generation.js +72 -3
  64. package/dist/runtime/title-generation.js.map +1 -1
  65. package/dist/runtime/tool-adapter.d.ts +1 -1
  66. package/dist/runtime/tool-adapter.js +3 -2
  67. package/dist/runtime/tool-adapter.js.map +1 -1
  68. package/dist/sdk/agent.d.ts +35 -22
  69. package/dist/sdk/agent.js +106 -331
  70. package/dist/sdk/agent.js.map +1 -1
  71. package/dist/sdk/catalog.d.ts +1 -0
  72. package/dist/sdk/catalog.js +1 -0
  73. package/dist/sdk/catalog.js.map +1 -1
  74. package/dist/sdk/eval.d.ts +0 -3
  75. package/dist/sdk/eval.js +4 -9
  76. package/dist/sdk/eval.js.map +1 -1
  77. package/dist/sdk/memory.d.ts +12 -12
  78. package/dist/sdk/memory.js +71 -51
  79. package/dist/sdk/memory.js.map +1 -1
  80. package/dist/sdk/provider-capabilities.js +4 -2
  81. package/dist/sdk/provider-capabilities.js.map +1 -1
  82. package/dist/sdk/provider-tools.d.ts +17 -2
  83. package/dist/sdk/provider-tools.js +19 -0
  84. package/dist/sdk/provider-tools.js.map +1 -1
  85. package/dist/sdk/telemetry.d.ts +2 -0
  86. package/dist/sdk/telemetry.js +6 -0
  87. package/dist/sdk/telemetry.js.map +1 -1
  88. package/dist/sdk/tool.d.ts +17 -10
  89. package/dist/sdk/tool.js +34 -0
  90. package/dist/sdk/tool.js.map +1 -1
  91. package/dist/sdk/verify.js +1 -4
  92. package/dist/sdk/verify.js.map +1 -1
  93. package/dist/storage/base-memory.d.ts +54 -0
  94. package/dist/storage/base-memory.js +48 -0
  95. package/dist/storage/base-memory.js.map +1 -0
  96. package/dist/types/index.d.ts +6 -3
  97. package/dist/types/index.js +7 -1
  98. package/dist/types/index.js.map +1 -1
  99. package/dist/types/runtime/event.d.ts +4 -9
  100. package/dist/types/runtime/event.js.map +1 -1
  101. package/dist/types/sdk/agent-builder.d.ts +5 -3
  102. package/dist/types/sdk/agent.d.ts +70 -27
  103. package/dist/types/sdk/credential-provider.d.ts +2 -3
  104. package/dist/types/sdk/memory.d.ts +33 -20
  105. package/dist/types/sdk/message.d.ts +11 -10
  106. package/dist/types/sdk/observation-log.d.ts +99 -0
  107. package/dist/types/sdk/observation-log.js +17 -0
  108. package/dist/types/sdk/observation-log.js.map +1 -0
  109. package/dist/types/sdk/observation.d.ts +9 -0
  110. package/dist/types/sdk/{schema.js → observation.js} +1 -1
  111. package/dist/types/sdk/observation.js.map +1 -0
  112. package/dist/types/sdk/provider.d.ts +5 -2
  113. package/dist/types/sdk/tool-descriptor.d.ts +13 -0
  114. package/dist/types/sdk/tool-descriptor.js +3 -0
  115. package/dist/types/sdk/tool-descriptor.js.map +1 -0
  116. package/dist/types/sdk/tool.d.ts +8 -3
  117. package/dist/types/telemetry.d.ts +1 -0
  118. package/dist/utils/parse.d.ts +10 -0
  119. package/dist/utils/parse.js +26 -0
  120. package/dist/utils/parse.js.map +1 -0
  121. package/dist/utils/zod.d.ts +1 -1
  122. package/dist/utils/zod.js.map +1 -1
  123. package/dist/workspace/tools/batch-str-replace-file.d.ts +3 -0
  124. package/dist/workspace/tools/batch-str-replace-file.js +67 -0
  125. package/dist/workspace/tools/batch-str-replace-file.js.map +1 -0
  126. package/dist/workspace/tools/str-replace-file.d.ts +3 -0
  127. package/dist/workspace/tools/str-replace-file.js +51 -0
  128. package/dist/workspace/tools/str-replace-file.js.map +1 -0
  129. package/dist/workspace/tools/workspace-tools.js +4 -0
  130. package/dist/workspace/tools/workspace-tools.js.map +1 -1
  131. package/package.json +16 -11
  132. package/dist/codegen/generate-agent-code.d.ts +0 -2
  133. package/dist/codegen/generate-agent-code.js +0 -197
  134. package/dist/codegen/generate-agent-code.js.map +0 -1
  135. package/dist/runtime/working-memory.d.ts +0 -14
  136. package/dist/runtime/working-memory.js +0 -69
  137. package/dist/runtime/working-memory.js.map +0 -1
  138. package/dist/sdk/from-schema.d.ts +0 -15
  139. package/dist/sdk/from-schema.js +0 -218
  140. package/dist/sdk/from-schema.js.map +0 -1
  141. package/dist/storage/postgres-memory.d.ts +0 -79
  142. package/dist/storage/postgres-memory.js +0 -410
  143. package/dist/storage/postgres-memory.js.map +0 -1
  144. package/dist/storage/sqlite-memory.d.ts +0 -60
  145. package/dist/storage/sqlite-memory.js +0 -348
  146. package/dist/storage/sqlite-memory.js.map +0 -1
  147. package/dist/types/sdk/schema.d.ts +0 -99
  148. package/dist/types/sdk/schema.js.map +0 -1
package/dist/sdk/tool.js CHANGED
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Tool = void 0;
4
4
  exports.wrapToolForApproval = wrapToolForApproval;
5
5
  const zod_1 = require("zod");
6
+ const zod_2 = require("../utils/zod");
6
7
  const APPROVAL_SUSPEND_SCHEMA = zod_1.z.object({
7
8
  type: zod_1.z.literal('approval'),
8
9
  toolName: zod_1.z.string(),
@@ -50,6 +51,10 @@ class Tool {
50
51
  this.desc = desc;
51
52
  return this;
52
53
  }
54
+ systemInstruction(text) {
55
+ this.systemInstructionText = text;
56
+ return this;
57
+ }
53
58
  input(schema) {
54
59
  const self = this;
55
60
  self.inputSchema = schema;
@@ -122,6 +127,7 @@ class Tool {
122
127
  const built = {
123
128
  name: this.name,
124
129
  description: this.desc,
130
+ systemInstruction: this.systemInstructionText,
125
131
  suspendSchema: this.suspendSchemaValue,
126
132
  resumeSchema: this.resumeSchemaValue,
127
133
  toMessage: this.toMessageFn,
@@ -139,6 +145,34 @@ class Tool {
139
145
  }
140
146
  return built;
141
147
  }
148
+ describe() {
149
+ if (!this.name)
150
+ throw new Error('Tool name is required');
151
+ if (!this.desc)
152
+ throw new Error(`Tool "${this.name}" requires a description`);
153
+ if (!this.inputSchema)
154
+ throw new Error(`Tool "${this.name}" requires an input schema`);
155
+ const inputSchema = (0, zod_2.isZodSchema)(this.inputSchema)
156
+ ? (0, zod_2.zodToJsonSchema)(this.inputSchema)
157
+ : this.inputSchema;
158
+ const outputSchema = this.outputSchema
159
+ ? (0, zod_2.isZodSchema)(this.outputSchema)
160
+ ? (0, zod_2.zodToJsonSchema)(this.outputSchema)
161
+ : this.outputSchema
162
+ : null;
163
+ return {
164
+ name: this.name,
165
+ description: this.desc,
166
+ systemInstruction: this.systemInstructionText ?? null,
167
+ inputSchema: inputSchema,
168
+ outputSchema: outputSchema,
169
+ hasSuspend: this.suspendSchemaValue !== undefined,
170
+ hasResume: this.resumeSchemaValue !== undefined,
171
+ hasToMessage: this.toMessageFn !== undefined,
172
+ requireApproval: this.requireApprovalValue ?? false,
173
+ providerOptions: this.providerOptionsValue ?? null,
174
+ };
175
+ }
142
176
  }
143
177
  exports.Tool = Tool;
144
178
  //# sourceMappingURL=tool.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"tool.js","sourceRoot":"","sources":["../../src/sdk/tool.ts"],"names":[],"mappings":";;;AA+BA,kDAkCC;AAjED,6BAAwB;AAMxB,MAAM,uBAAuB,GAAG,OAAC,CAAC,MAAM,CAAC;IACxC,IAAI,EAAE,OAAC,CAAC,OAAO,CAAC,UAAU,CAAC;IAC3B,QAAQ,EAAE,OAAC,CAAC,MAAM,EAAE;IACpB,IAAI,EAAE,OAAC,CAAC,OAAO,EAAE;CACjB,CAAC,CAAC;AAEH,MAAM,sBAAsB,GAAG,OAAC,CAAC,MAAM,CAAC;IACvC,QAAQ,EAAE,OAAC,CAAC,OAAO,EAAE;CACrB,CAAC,CAAC;AAiBH,SAAgB,mBAAmB,CAAC,IAAe,EAAE,MAAsB;IAC1E,MAAM,eAAe,GAAG,IAAI,CAAC,OAAQ,CAAC;IAEtC,OAAO;QACN,GAAG,IAAI;QACP,mBAAmB,EAAE,IAAI;QACzB,aAAa,EAAE,uBAAuB;QACtC,YAAY,EAAE,sBAAsB;QACpC,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE,EAAE;YAG7B,MAAM,YAAY,GAAG,GAA+B,CAAC;YACrD,IAAI,YAAY,CAAC,UAAU,KAAK,SAAS,EAAE,CAAC;gBAC3C,IAAI,KAAK,GAAG,MAAM,CAAC,eAAe,IAAI,KAAK,CAAC;gBAC5C,IAAI,CAAC,KAAK,IAAI,MAAM,CAAC,eAAe,EAAE,CAAC;oBACtC,KAAK,GAAG,MAAM,MAAM,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC;gBAC7C,CAAC;gBACD,IAAI,KAAK,EAAE,CAAC;oBACX,OAAO,MAAM,YAAY,CAAC,OAAO,CAAC,EAAE,IAAI,EAAE,UAAU,EAAE,QAAQ,EAAE,IAAI,CAAC,IAAI,EAAE,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E,IAAI,CAAC,iBAAiB,KAAK,SAAS;YAC/C,YAAY,EAAE,IAAI,CAAC,WAAW,KAAK,SAAS;YAC5C,eAAe,EAAE,IAAI,CAAC,oBAAoB,IAAI,KAAK;YACnD,eAAe,EAAE,IAAI,CAAC,oBAAoB,IAAI,IAAI;SAClD,CAAC;IACH,CAAC;CACD;AA7OD,oBA6OC"}
@@ -16,10 +16,7 @@ function verify(source) {
16
16
  errors.push("Scorer is deprecated. Use the Eval system instead: new Eval('name').check(...) or evals.correctness()");
17
17
  }
18
18
  if (/process\.env\b/.test(source)) {
19
- errors.push('process.env is not available. Use .credential() for API keys, or const variables for configuration.');
20
- }
21
- if (!/\.credential\s*\(/.test(source)) {
22
- errors.push("No .credential() found. Every agent must declare a credential (e.g. .credential('anthropic')).");
19
+ errors.push('process.env is not available. Use const variables for configuration.');
23
20
  }
24
21
  return { ok: errors.length === 0, errors };
25
22
  }
@@ -1 +1 @@
1
- {"version":3,"file":"verify.js","sourceRoot":"","sources":["../../src/sdk/verify.ts"],"names":[],"mappings":";;AAuBA,wBAoCC;AApCD,SAAgB,MAAM,CAAC,MAAc;IACpC,MAAM,MAAM,GAAa,EAAE,CAAC;IAE5B,IAAI,CAAC,MAAM,EAAE,IAAI,EAAE,EAAE,CAAC;QACrB,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,yBAAyB,CAAC,EAAE,CAAC;IAC3D,CAAC;IAED,IAAI,cAAc,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC;QACjC,MAAM,CAAC,IAAI,CACV,0FAA0F,CAC1F,CAAC;IACH,CAAC;IAED,IAAI,CAAC,oBAAoB,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC;QACxC,MAAM,CAAC,IAAI,CAAC,gFAAgF,CAAC,CAAC;IAC/F,CAAC;IAED,IAAI,YAAY,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC;QAC/B,MAAM,CAAC,IAAI,CACV,uG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AK,CAAC,EAAE,MAAM,EAAE,CAAC;AAC5C,CAAC"}
@@ -0,0 +1,54 @@
1
+ import type { BuiltMemory, MemoryDescriptor, Thread } from '../types/sdk/memory';
2
+ import type { AgentDbMessage } from '../types/sdk/message';
3
+ import type { JSONObject } from '../types/utils/json';
4
+ export declare abstract class BaseMemory<TConstructorOptions extends JSONObject = JSONObject> implements BuiltMemory {
5
+ protected readonly name: string;
6
+ protected readonly constructorOptions: TConstructorOptions;
7
+ constructor(name: string, constructorOptions: TConstructorOptions);
8
+ getThread(_threadId: string): Promise<Thread | null>;
9
+ saveThread(_thread: Omit<Thread, 'createdAt' | 'updatedAt'>): Promise<Thread>;
10
+ deleteThread(_threadId: string): Promise<void>;
11
+ getMessages(_threadId: string, _opts?: {
12
+ limit?: number;
13
+ before?: Date;
14
+ }): Promise<AgentDbMessage[]>;
15
+ saveMessages(_args: {
16
+ threadId: string;
17
+ resourceId: string;
18
+ messages: AgentDbMessage[];
19
+ }): Promise<void>;
20
+ deleteMessages(_messageIds: string[]): Promise<void>;
21
+ search?(_query: string, _opts?: {
22
+ scope?: 'thread' | 'resource';
23
+ threadId?: string;
24
+ resourceId?: string;
25
+ topK?: number;
26
+ messageRange?: {
27
+ before: number;
28
+ after: number;
29
+ };
30
+ }): Promise<AgentDbMessage[]>;
31
+ saveEmbeddings?(_opts: {
32
+ scope?: 'thread' | 'resource';
33
+ threadId?: string;
34
+ resourceId?: string;
35
+ entries: Array<{
36
+ id: string;
37
+ vector: number[];
38
+ text: string;
39
+ model: string;
40
+ }>;
41
+ }): Promise<void>;
42
+ queryEmbeddings?(_opts: {
43
+ scope?: 'thread' | 'resource';
44
+ threadId?: string;
45
+ resourceId?: string;
46
+ vector: number[];
47
+ topK: number;
48
+ }): Promise<Array<{
49
+ id: string;
50
+ score: number;
51
+ }>>;
52
+ close?(): Promise<void>;
53
+ describe(): MemoryDescriptor<TConstructorOptions>;
54
+ }
@@ -0,0 +1,48 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BaseMemory = void 0;
4
+ class BaseMemory {
5
+ constructor(name, constructorOptions) {
6
+ this.name = name;
7
+ this.constructorOptions = constructorOptions;
8
+ }
9
+ getThread(_threadId) {
10
+ throw new Error('Method not implemented.');
11
+ }
12
+ saveThread(_thread) {
13
+ throw new Error('Method not implemented.');
14
+ }
15
+ deleteThread(_threadId) {
16
+ throw new Error('Method not implemented.');
17
+ }
18
+ getMessages(_threadId, _opts) {
19
+ throw new Error('Method not implemented.');
20
+ }
21
+ saveMessages(_args) {
22
+ throw new Error('Method not implemented.');
23
+ }
24
+ deleteMessages(_messageIds) {
25
+ throw new Error('Method not implemented.');
26
+ }
27
+ search(_query, _opts) {
28
+ throw new Error('Method not implemented.');
29
+ }
30
+ saveEmbeddings(_opts) {
31
+ throw new Error('Method not implemented.');
32
+ }
33
+ queryEmbeddings(_opts) {
34
+ throw new Error('Method not implemented.');
35
+ }
36
+ close() {
37
+ throw new Error('Method not implemented.');
38
+ }
39
+ describe() {
40
+ return {
41
+ name: this.name,
42
+ constructorName: this.constructor.name,
43
+ connectionParams: this.constructorOptions,
44
+ };
45
+ }
46
+ }
47
+ exports.BaseMemory = BaseMemory;
48
+ //# sourceMappingURL=base-memory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"base-memory.js","sourceRoot":"","sources":["../../src/storage/base-memory.ts"],"names":[],"mappings":";;;AAKA,MAAsB,UAAU;IAG/B,YACoB,IAAY,EACZ,kBAAuC;QADvC,SAAI,GAAJ,IAAI,CAAQ;QACZ,uBAAkB,GAAlB,kBAAkB,CAAqB;IACxD,CAAC;IAEJ,SAAS,CAAC,SAAiB;QAC1B,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;IAC5C,CAAC;IACD,UAAU,CAAC,OAAgD;QAC1D,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;IAC5C,CAAC;IACD,YAAY,CAAC,SAAiB;QAC7B,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;IAC5C,CAAC;IACD,WAAW,CACV,SAAiB,EACjB,KAAyC;QAEzC,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;IAC5C,CAAC;IACD,YAAY,CAAC,KAIZ;QACA,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;IAC5C,CAAC;IACD,cAAc,CAAC,WAAqB;QACnC,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;IAC5C,CAAC;IACD,MAAM,CACL,MAAc,EACd,KAMC;QAED,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;IAC5C,CAAC;IACD,cAAc,CAAE,KAKf;QACA,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;IAC5C,CAAC;IACD,eAAe,CAAE,KAMhB;QACA,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;IAC5C,CAAC;IAED,KAAK;QACJ,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;IAC5C,CAAC;IAED,QAAQ;QACP,OAAO;YACN,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,eAAe,EAAE,IAAI,CAAC,WAAW,CAAC,IAAI;YACtC,gBAAgB,EAAE,IAAI,CAAC,kBAAkB;SACzC,CAAC;IACH,CAAC;CACD;AA1ED,gCA0EC"}
@@ -1,10 +1,13 @@
1
1
  export type { JSONValue, JSONObject, JSONArray } from './utils/json';
2
- export type { MessageRole, MessageContent, ContentMetadata, ContentCitation, ContentText, ContentReasoning, ContentFile, ContentToolCall, ContentToolResult, ContentInvalidToolCall, ContentProvider, Message, AgentMessageBase, CustomAgentMessages, AgentMessage, AgentDbMessage, } from './sdk/message';
2
+ export type { MessageRole, MessageContent, ContentMetadata, ContentCitation, ContentText, ContentReasoning, ContentFile, ContentToolCall, ContentInvalidToolCall, ContentProvider, Message, AgentMessageBase, CustomAgentMessages, AgentMessage, AgentDbMessage, } from './sdk/message';
3
3
  export type { Provider, AnthropicThinkingConfig, OpenAIThinkingConfig, GoogleThinkingConfig, XaiThinkingConfig, ThinkingConfigFor, ThinkingConfig, } from './sdk/provider';
4
- export type { AgentResult, StreamChunk, FinishReason, TokenUsage, ModelConfig, RunOptions, ExecutionOptions, PersistedExecutionOptions, ResumeOptions, GenerateResult, StreamResult, SubAgentUsage, BuiltAgent, AgentRunState, AgentResumeData, PendingToolCall, SerializableAgentState, } from './sdk/agent';
4
+ export type { AgentResult, StreamChunk, FinishReason, TokenUsage, ModelConfig, RunOptions, ExecutionOptions, AgentExecutionCounter, PersistedExecutionOptions, ResumeOptions, GenerateResult, StreamResult, SubAgentUsage, BuiltAgent, AgentRunState, AgentResumeData, PendingToolCall, SerializableAgentState, } from './sdk/agent';
5
5
  export type { SerializedMessageList } from './runtime/message-list';
6
6
  export type { ToolContext, InterruptibleToolContext, BuiltTool, BuiltProviderTool, } from './sdk/tool';
7
- export type { Thread, BuiltMemory, SemanticRecallConfig, MemoryConfig, CheckpointStore, TitleGenerationConfig, } from './sdk/memory';
7
+ export type { Thread, BuiltMemory, ObservationCapableMemory, MemoryDescriptor, SemanticRecallConfig, MemoryConfig, ObservationLogMemoryConfig, ObservationalMemoryConfig, CheckpointStore, TitleGenerationConfig, } from './sdk/memory';
8
+ export type { ObservationCursor, ScopeKind, } from './sdk/observation';
9
+ export type { BuiltObservationLogStore, BuiltObservationLogTaskLockStore, NewObservationLogEntry, ObservationLogEntry, ObservationLogMarker, ObservationLogMerge, ObservationLogObserveFn, ObservationLogObserverInput, ObservationLogReadOptions, ObservationLogReflectFn, ObservationLogReflectorInput, ObservationLogReflection, ObservationLogReflectionResult, ObservationLogScope, ObservationLogScopeKind, ObservationLogStatus, ObservationLogTaskKind, ObservationLogTaskLockHandle, TokenCounter, } from './sdk/observation-log';
10
+ export { createObservationLogThreadScopeId, createObservationLogThreadScopePrefix, estimateObservationTokens, OBSERVATION_LOG_MARKERS, OBSERVATION_LOG_STATUSES, } from './sdk/observation-log';
8
11
  export type { EvalInput, EvalScore, JudgeFn, JudgeInput, CheckFn, JudgeHandlerFn, BuiltEval, EvalRunResult, EvalResults, } from './sdk/eval';
9
12
  export type { GuardrailType, GuardrailStrategy, PiiDetectionType, BuiltGuardrail, } from './sdk/guardrail';
10
13
  export type { BuiltTelemetry, AttributeValue, OpaqueTracer, OpaqueTracerProvider, } from './telemetry';
@@ -1,6 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.AgentEvent = void 0;
3
+ exports.AgentEvent = exports.OBSERVATION_LOG_STATUSES = exports.OBSERVATION_LOG_MARKERS = exports.estimateObservationTokens = exports.createObservationLogThreadScopePrefix = exports.createObservationLogThreadScopeId = void 0;
4
+ var observation_log_1 = require("./sdk/observation-log");
5
+ Object.defineProperty(exports, "createObservationLogThreadScopeId", { enumerable: true, get: function () { return observation_log_1.createObservationLogThreadScopeId; } });
6
+ Object.defineProperty(exports, "createObservationLogThreadScopePrefix", { enumerable: true, get: function () { return observation_log_1.createObservationLogThreadScopePrefix; } });
7
+ Object.defineProperty(exports, "estimateObservationTokens", { enumerable: true, get: function () { return observation_log_1.estimateObservationTokens; } });
8
+ Object.defineProperty(exports, "OBSERVATION_LOG_MARKERS", { enumerable: true, get: function () { return observation_log_1.OBSERVATION_LOG_MARKERS; } });
9
+ Object.defineProperty(exports, "OBSERVATION_LOG_STATUSES", { enumerable: true, get: function () { return observation_log_1.OBSERVATION_LOG_STATUSES; } });
4
10
  var event_1 = require("./runtime/event");
5
11
  Object.defineProperty(exports, "AgentEvent", { enumerable: true, get: function () { return event_1.AgentEvent; } });
6
12
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":";;;AA+FA,yCAA6C;AAApC,mGAAA,UAAU,OAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":";;;AAmGA,yDAM+B;AAL9B,oIAAA,iCAAiC,OAAA;AACjC,wIAAA,qCAAqC,OAAA;AACrC,4HAAA,yBAAyB,OAAA;AACzB,0HAAA,uBAAuB,OAAA;AACvB,2HAAA,wBAAwB,OAAA;AA6BzB,yCAA6C;AAApC,mGAAA,UAAU,OAAA"}
@@ -1,5 +1,4 @@
1
- import type { AgentPersistenceOptions } from '../sdk/agent';
2
- import type { AgentMessage, ContentToolResult } from '../sdk/message';
1
+ import type { AgentMessage, ContentToolCall } from '../sdk/message';
3
2
  export declare const enum AgentEvent {
4
3
  AgentStart = "agent_start",
5
4
  AgentEnd = "agent_end",
@@ -9,11 +8,7 @@ export declare const enum AgentEvent {
9
8
  ToolExecutionEnd = "tool_execution_end",
10
9
  Error = "error"
11
10
  }
12
- export type SharedAgentEventData = {
13
- runId: string;
14
- persistence?: AgentPersistenceOptions;
15
- };
16
- export type AgentEventSpecificData = {
11
+ export type AgentEventData = {
17
12
  type: AgentEvent.AgentStart;
18
13
  } | {
19
14
  type: AgentEvent.AgentEnd;
@@ -23,7 +18,7 @@ export type AgentEventSpecificData = {
23
18
  } | {
24
19
  type: AgentEvent.TurnEnd;
25
20
  message: AgentMessage;
26
- toolResults: ContentToolResult[];
21
+ toolResults: ContentToolCall[];
27
22
  } | {
28
23
  type: AgentEvent.ToolExecutionStart;
29
24
  toolCallId: string;
@@ -39,8 +34,8 @@ export type AgentEventSpecificData = {
39
34
  type: AgentEvent.Error;
40
35
  message: string;
41
36
  error: unknown;
37
+ source?: 'observer' | 'reflector';
42
38
  };
43
- export type AgentEventData = SharedAgentEventData & AgentEventSpecificData;
44
39
  export type AgentEventHandler = (data: AgentEventData) => void;
45
40
  export interface AgentMiddleware {
46
41
  on: (event: AgentEvent, handler: AgentEventHandler) => void;
@@ -1 +1 @@
1
- {"version":3,"file":"event.js","sourceRoot":"","sources":["../../../src/types/runtime/event.ts"],"names":[],"mappings":";;;AAGA,IAAkB,UAQjB;AARD,WAAkB,UAAU;IAC3B,wCAA0B,CAAA;IAC1B,oCAAsB,CAAA;IACtB,sCAAwB,CAAA;IACxB,kCAAoB,CAAA;IACpB,yDAA2C,CAAA;IAC3C,qDAAuC,CAAA;IACvC,6BAAe,CAAA;AAChB,CAAC,EARiB,UAAU,0BAAV,UAAU,QAQ3B"}
1
+ {"version":3,"file":"event.js","sourceRoot":"","sources":["../../../src/types/runtime/event.ts"],"names":[],"mappings":";;;AAEA,IAAkB,UAQjB;AARD,WAAkB,UAAU;IAC3B,wCAA0B,CAAA;IAC1B,oCAAsB,CAAA;IACtB,sCAAwB,CAAA;IACxB,kCAAoB,CAAA;IACpB,yDAA2C,CAAA;IAC3C,qDAAuC,CAAA;IACvC,6BAAe,CAAA;AAChB,CAAC,EARiB,UAAU,0BAAV,UAAU,QAQ3B"}
@@ -1,21 +1,23 @@
1
1
  import type { ModelConfig } from './agent';
2
- import type { CredentialProvider } from './credential-provider';
3
2
  import type { BuiltEval } from './eval';
4
3
  import type { BuiltGuardrail } from './guardrail';
5
4
  import type { CheckpointStore } from './memory';
6
5
  import type { BuiltProviderTool, BuiltTool } from './tool';
7
6
  export interface AgentBuilder {
8
7
  model(providerOrIdOrConfig: string | ModelConfig, modelName?: string): this;
9
- credential(name: string): this;
10
8
  instructions(text: string): this;
11
9
  tool(t: BuiltTool | BuiltTool[]): this;
10
+ deferredTool(t: BuiltTool | BuiltTool[], options?: {
11
+ search?: {
12
+ topK?: number;
13
+ };
14
+ }): this;
12
15
  providerTool(t: BuiltProviderTool): this;
13
16
  thinking(provider: string, config?: Record<string, unknown>): this;
14
17
  toolCallConcurrency(n: number): this;
15
18
  requireToolApproval(): this;
16
19
  memory(m: unknown): this;
17
20
  checkpoint(storage: 'memory' | CheckpointStore): this;
18
- credentialProvider(p: CredentialProvider): this;
19
21
  inputGuardrail(g: BuiltGuardrail): this;
20
22
  outputGuardrail(g: BuiltGuardrail): this;
21
23
  eval(e: BuiltEval): this;
@@ -3,6 +3,7 @@ import type { LanguageModel } from 'ai';
3
3
  import type { JsonSchema7Type } from 'zod-to-json-schema';
4
4
  import type { AgentMessage, ContentMetadata } from './message';
5
5
  import type { BuiltTool } from './tool';
6
+ import type { ProviderId, ProviderCredentials } from '../../runtime/provider-credentials';
6
7
  import type { AgentEvent, AgentEventHandler } from '../runtime/event';
7
8
  import type { SerializedMessageList } from '../runtime/message-list';
8
9
  import type { BuiltTelemetry } from '../telemetry';
@@ -22,11 +23,14 @@ export type TokenUsage<T extends Record<string, unknown> = Record<string, unknow
22
23
  };
23
24
  additionalMetadata?: T;
24
25
  };
25
- export type ModelConfig = string | {
26
+ export type TypedModelConfig = {
27
+ [P in ProviderId]: {
28
+ id: `${P}/${string}`;
29
+ } & ProviderCredentials<P>;
30
+ }[ProviderId];
31
+ export type ModelConfig = string | TypedModelConfig | {
26
32
  id: string;
27
- apiKey?: string;
28
- url?: string;
29
- headers?: Record<string, string>;
33
+ [k: string]: unknown;
30
34
  } | LanguageModel;
31
35
  export interface AgentResult {
32
36
  id?: string;
@@ -38,50 +42,89 @@ export interface AgentResult {
38
42
  output?: unknown;
39
43
  }
40
44
  export type StreamChunk = ContentMetadata & ({
41
- type: 'finish';
42
- finishReason: FinishReason;
43
- usage?: TokenUsage;
44
- model?: string;
45
- structuredOutput?: unknown;
46
- subAgentUsage?: SubAgentUsage[];
47
- totalCost?: number;
45
+ type: 'start-step';
46
+ } | {
47
+ type: 'finish-step';
48
+ } | {
49
+ type: 'text-start';
50
+ id: string;
48
51
  } | {
49
52
  type: 'text-delta';
50
- id?: string;
53
+ id: string;
51
54
  delta: string;
55
+ } | {
56
+ type: 'text-end';
57
+ id: string;
58
+ } | {
59
+ type: 'reasoning-start';
60
+ id: string;
52
61
  } | {
53
62
  type: 'reasoning-delta';
54
- id?: string;
63
+ id: string;
55
64
  delta: string;
56
65
  } | {
57
- type: 'tool-call-delta';
58
- id?: string;
59
- name?: string;
60
- argumentsDelta?: string;
66
+ type: 'reasoning-end';
67
+ id: string;
61
68
  } | {
62
- type: 'error';
63
- error: unknown;
69
+ type: 'tool-input-start';
70
+ toolCallId: string;
71
+ toolName: string;
64
72
  } | {
65
- type: 'message';
66
- message: AgentMessage;
67
- id?: string;
73
+ type: 'tool-input-delta';
74
+ toolCallId: string;
75
+ delta: string;
76
+ } | {
77
+ type: 'tool-call';
78
+ toolCallId: string;
79
+ toolName: string;
80
+ input: unknown;
81
+ } | {
82
+ type: 'tool-execution-start';
83
+ toolCallId: string;
84
+ toolName: string;
85
+ } | {
86
+ type: 'tool-result';
87
+ toolCallId: string;
88
+ toolName: string;
89
+ output: unknown;
90
+ isError?: boolean;
68
91
  } | {
69
92
  type: 'tool-call-suspended';
70
- runId?: string;
71
- toolCallId?: string;
72
- toolName?: string;
93
+ runId: string;
94
+ toolCallId: string;
95
+ toolName: string;
73
96
  input?: unknown;
74
97
  suspendPayload?: unknown;
75
98
  resumeSchema?: JsonSchema7Type;
99
+ } | {
100
+ type: 'message';
101
+ message: AgentMessage;
102
+ } | {
103
+ type: 'finish';
104
+ finishReason: FinishReason;
105
+ usage?: TokenUsage;
106
+ model?: string;
107
+ structuredOutput?: unknown;
108
+ subAgentUsage?: SubAgentUsage[];
109
+ totalCost?: number;
110
+ } | {
111
+ type: 'error';
112
+ error: unknown;
76
113
  });
77
114
  export interface RunOptions {
78
115
  persistence?: AgentPersistenceOptions;
79
116
  }
117
+ export interface AgentExecutionCounter {
118
+ incrementMessageCount(): void;
119
+ incrementToolCallCount(): void;
120
+ incrementTokenCount(tokenCount: number): void;
121
+ }
80
122
  export interface ExecutionOptions {
81
123
  maxIterations?: number;
82
124
  abortSignal?: AbortSignal;
83
125
  providerOptions?: ProviderOptions;
84
126
  telemetry?: BuiltTelemetry;
127
+ executionCounter?: AgentExecutionCounter;
85
128
  }
86
129
  export interface PersistedExecutionOptions {
87
130
  maxIterations?: number;
@@ -117,12 +160,10 @@ export interface GenerateResult {
117
160
  resumeSchema?: JsonSchema7Type;
118
161
  }>;
119
162
  error?: unknown;
120
- getState(): SerializableAgentState;
121
163
  }
122
164
  export interface StreamResult {
123
165
  runId: string;
124
166
  stream: ReadableStream<StreamChunk>;
125
- getState(): SerializableAgentState;
126
167
  }
127
168
  export interface ResumeOptions {
128
169
  runId: string;
@@ -134,6 +175,7 @@ export interface BuiltAgent {
134
175
  stream(input: AgentMessage[] | string, options?: RunOptions & ExecutionOptions): Promise<StreamResult>;
135
176
  on(event: AgentEvent, handler: AgentEventHandler): void;
136
177
  asTool(description: string): BuiltTool;
178
+ getState(): SerializableAgentState;
137
179
  abort(): void;
138
180
  resume(method: 'generate', data: unknown, options: ResumeOptions & ExecutionOptions): Promise<GenerateResult>;
139
181
  resume(method: 'stream', data: unknown, options: ResumeOptions & ExecutionOptions): Promise<StreamResult>;
@@ -157,6 +199,7 @@ export type PendingToolCall = {
157
199
  suspended: true;
158
200
  suspendPayload: unknown;
159
201
  resumeSchema: JsonSchema7Type;
202
+ runId: string;
160
203
  } | {
161
204
  suspended: false;
162
205
  });
@@ -1,7 +1,6 @@
1
- export interface ResolvedCredential {
2
- apiKey: string;
1
+ export type ResolvedCredential = {
3
2
  [key: string]: unknown;
4
- }
3
+ };
5
4
  export interface CredentialListItem {
6
5
  id: string;
7
6
  name: string;
@@ -1,6 +1,12 @@
1
- import type { z } from 'zod';
2
1
  import type { ModelConfig, SerializableAgentState } from './agent';
3
2
  import type { AgentDbMessage } from './message';
3
+ import type { BuiltObservationLogStore, ObservationLogObserveFn, ObservationLogReflectFn } from './observation-log';
4
+ import type { JSONObject } from '../utils/json';
5
+ export interface MemoryDescriptor<TParams extends JSONObject = JSONObject> {
6
+ name: string;
7
+ constructorName: string;
8
+ connectionParams: TParams | null;
9
+ }
4
10
  export interface Thread {
5
11
  id: string;
6
12
  resourceId: string;
@@ -16,6 +22,7 @@ export interface BuiltMemory {
16
22
  getMessages(threadId: string, opts?: {
17
23
  limit?: number;
18
24
  before?: Date;
25
+ resourceId?: string;
19
26
  }): Promise<AgentDbMessage[]>;
20
27
  saveMessages(args: {
21
28
  threadId: string;
@@ -33,16 +40,6 @@ export interface BuiltMemory {
33
40
  after: number;
34
41
  };
35
42
  }): Promise<AgentDbMessage[]>;
36
- getWorkingMemory?(params: {
37
- threadId: string;
38
- resourceId: string;
39
- scope: 'resource' | 'thread';
40
- }): Promise<string | null>;
41
- saveWorkingMemory?(params: {
42
- threadId: string;
43
- resourceId: string;
44
- scope: 'resource' | 'thread';
45
- }, content: string): Promise<void>;
46
43
  saveEmbeddings?(opts: {
47
44
  scope?: 'thread' | 'resource';
48
45
  threadId?: string;
@@ -65,6 +62,7 @@ export interface BuiltMemory {
65
62
  score: number;
66
63
  }>>;
67
64
  close?(): Promise<void>;
65
+ describe(): MemoryDescriptor;
68
66
  }
69
67
  export interface SemanticRecallConfig {
70
68
  scope?: 'thread' | 'resource';
@@ -79,22 +77,37 @@ export interface SemanticRecallConfig {
79
77
  export interface TitleGenerationConfig {
80
78
  model?: ModelConfig;
81
79
  instructions?: string;
80
+ sync?: boolean;
82
81
  }
83
- export interface MemoryConfig {
84
- memory: BuiltMemory;
82
+ export type ObservationCapableMemory = BuiltMemory & BuiltObservationLogStore;
83
+ export interface ObservationLogMemoryConfig {
84
+ renderTokenBudget?: number;
85
+ }
86
+ export interface ObservationalMemoryConfig {
87
+ observerThresholdTokens?: number;
88
+ reflectorThresholdTokens?: number;
89
+ renderTokenBudget?: number;
90
+ observationLogTailLimit?: number;
91
+ lockTtlMs?: number;
92
+ observe?: ObservationLogObserveFn;
93
+ reflect?: ObservationLogReflectFn;
94
+ }
95
+ interface MemoryConfigBase {
85
96
  lastMessages: number;
86
- workingMemory?: {
87
- template: string;
88
- structured: boolean;
89
- schema?: z.ZodObject<z.ZodRawShape>;
90
- scope: 'resource' | 'thread';
91
- instruction?: string;
92
- };
97
+ observationLog?: ObservationLogMemoryConfig;
93
98
  semanticRecall?: SemanticRecallConfig;
94
99
  titleGeneration?: TitleGenerationConfig;
95
100
  }
101
+ export type MemoryConfig = (MemoryConfigBase & {
102
+ memory: BuiltMemory;
103
+ observationalMemory?: undefined;
104
+ }) | (MemoryConfigBase & {
105
+ memory: ObservationCapableMemory;
106
+ observationalMemory: ObservationalMemoryConfig;
107
+ });
96
108
  export interface CheckpointStore {
97
109
  save(key: string, state: SerializableAgentState): Promise<void>;
98
110
  load(key: string): Promise<SerializableAgentState | undefined>;
99
111
  delete(key: string): Promise<void>;
100
112
  }
113
+ export {};
@@ -1,7 +1,7 @@
1
1
  import type { ProviderOptions } from '@ai-sdk/provider-utils';
2
2
  import type { JSONValue } from '../utils/json';
3
3
  export type MessageRole = 'system' | 'user' | 'assistant' | 'tool';
4
- export type MessageContent = ContentText | ContentToolCall | ContentInvalidToolCall | ContentToolResult | ContentReasoning | ContentFile | ContentCitation | ContentProvider;
4
+ export type MessageContent = ContentText | ContentToolCall | ContentInvalidToolCall | ContentReasoning | ContentFile | ContentCitation | ContentProvider;
5
5
  export interface ContentMetadata {
6
6
  providerMetadata?: Record<string, unknown>;
7
7
  providerOptions?: ProviderOptions;
@@ -30,18 +30,19 @@ export type ContentFile = ContentMetadata & {
30
30
  };
31
31
  export type ContentToolCall = ContentMetadata & {
32
32
  type: 'tool-call';
33
- toolCallId?: string;
33
+ toolCallId: string;
34
34
  toolName: string;
35
35
  input: JSONValue;
36
36
  providerExecuted?: boolean;
37
- };
38
- export type ContentToolResult = ContentMetadata & {
39
- type: 'tool-result';
40
- toolName: string;
41
- toolCallId: string;
42
- result: JSONValue;
43
- isError?: boolean;
44
- };
37
+ } & ({
38
+ state: 'pending';
39
+ } | {
40
+ state: 'resolved';
41
+ output: JSONValue;
42
+ } | {
43
+ state: 'rejected';
44
+ error: string;
45
+ });
45
46
  export type ContentInvalidToolCall = ContentMetadata & {
46
47
  type: 'invalid-tool-call';
47
48
  toolCallId?: string;