@inkeep/agents-api 0.0.0-dev-20260122003353 → 0.0.0-dev-20260122004923

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.
@@ -12,6 +12,36 @@ interface StreamHelper {
12
12
  writeData(type: string, data: any): Promise<void>;
13
13
  writeOperation(operation: OperationEvent): Promise<void>;
14
14
  writeSummary(summary: SummaryEvent): Promise<void>;
15
+ writeToolInputStart(params: {
16
+ toolCallId: string;
17
+ toolName: string;
18
+ }): Promise<void>;
19
+ writeToolInputDelta(params: {
20
+ toolCallId: string;
21
+ inputTextDelta: string;
22
+ }): Promise<void>;
23
+ writeToolInputAvailable(params: {
24
+ toolCallId: string;
25
+ toolName: string;
26
+ input: any;
27
+ providerMetadata?: any;
28
+ }): Promise<void>;
29
+ writeToolOutputAvailable(params: {
30
+ toolCallId: string;
31
+ output: any;
32
+ }): Promise<void>;
33
+ writeToolOutputError(params: {
34
+ toolCallId: string;
35
+ error: string;
36
+ output?: any;
37
+ }): Promise<void>;
38
+ writeToolApprovalRequest(params: {
39
+ approvalId: string;
40
+ toolCallId: string;
41
+ }): Promise<void>;
42
+ writeToolOutputDenied(params: {
43
+ toolCallId: string;
44
+ }): Promise<void>;
15
45
  }
16
46
  interface HonoSSEStream {
17
47
  writeSSE(message: {
@@ -31,6 +61,15 @@ interface ChatCompletionChunk {
31
61
  delta: {
32
62
  role?: string;
33
63
  content?: string;
64
+ tool_calls?: Array<{
65
+ index: number;
66
+ id: string | null;
67
+ type: 'function' | null;
68
+ function: {
69
+ name: string | null;
70
+ arguments: string;
71
+ };
72
+ }>;
34
73
  };
35
74
  finish_reason: string | null;
36
75
  }>;
@@ -41,6 +80,7 @@ declare class SSEStreamHelper implements StreamHelper {
41
80
  private timestamp;
42
81
  private isTextStreaming;
43
82
  private queuedEvents;
83
+ private toolCallIndexById;
44
84
  constructor(stream: HonoSSEStream, requestId: string, timestamp: number);
45
85
  /**
46
86
  * Write the initial role message
@@ -50,6 +90,8 @@ declare class SSEStreamHelper implements StreamHelper {
50
90
  * Write content chunk
51
91
  */
52
92
  writeContent(content: string): Promise<void>;
93
+ private getToolIndex;
94
+ private writeToolCallsDelta;
53
95
  /**
54
96
  * Stream text word by word with optional delay
55
97
  */
@@ -64,6 +106,36 @@ declare class SSEStreamHelper implements StreamHelper {
64
106
  */
65
107
  writeCompletion(finishReason?: string): Promise<void>;
66
108
  writeData(type: string, data: any): Promise<void>;
109
+ writeToolInputStart(params: {
110
+ toolCallId: string;
111
+ toolName: string;
112
+ }): Promise<void>;
113
+ writeToolInputDelta(params: {
114
+ toolCallId: string;
115
+ inputTextDelta: string;
116
+ }): Promise<void>;
117
+ writeToolInputAvailable(params: {
118
+ toolCallId: string;
119
+ toolName: string;
120
+ input: any;
121
+ providerMetadata?: any;
122
+ }): Promise<void>;
123
+ writeToolOutputAvailable(params: {
124
+ toolCallId: string;
125
+ output: any;
126
+ }): Promise<void>;
127
+ writeToolOutputError(params: {
128
+ toolCallId: string;
129
+ error: string;
130
+ output?: any;
131
+ }): Promise<void>;
132
+ writeToolApprovalRequest(params: {
133
+ approvalId: string;
134
+ toolCallId: string;
135
+ }): Promise<void>;
136
+ writeToolOutputDenied(params: {
137
+ toolCallId: string;
138
+ }): Promise<void>;
67
139
  writeSummary(summary: SummaryEvent): Promise<void>;
68
140
  writeOperation(operation: OperationEvent): Promise<void>;
69
141
  /**
@@ -101,11 +173,42 @@ declare class VercelDataStreamHelper implements StreamHelper {
101
173
  private lastTextEndTimestamp;
102
174
  private connectionDropTimer?;
103
175
  constructor(writer: VercelUIWriter);
176
+ setSessionId(_sessionId: string): void;
104
177
  writeRole(_?: string): Promise<void>;
105
178
  writeContent(content: string): Promise<void>;
106
179
  streamText(text: string, delayMs?: number): Promise<void>;
107
180
  writeData(type: string, data: any): Promise<void>;
108
181
  writeError(error: string | ErrorEvent): Promise<void>;
182
+ writeToolInputStart(params: {
183
+ toolCallId: string;
184
+ toolName: string;
185
+ }): Promise<void>;
186
+ writeToolInputDelta(params: {
187
+ toolCallId: string;
188
+ inputTextDelta: string;
189
+ }): Promise<void>;
190
+ writeToolInputAvailable(params: {
191
+ toolCallId: string;
192
+ toolName: string;
193
+ input: any;
194
+ providerMetadata?: any;
195
+ }): Promise<void>;
196
+ writeToolOutputAvailable(params: {
197
+ toolCallId: string;
198
+ output: any;
199
+ }): Promise<void>;
200
+ writeToolOutputError(params: {
201
+ toolCallId: string;
202
+ error: string;
203
+ output?: any;
204
+ }): Promise<void>;
205
+ writeToolApprovalRequest(params: {
206
+ approvalId: string;
207
+ toolCallId: string;
208
+ }): Promise<void>;
209
+ writeToolOutputDenied(params: {
210
+ toolCallId: string;
211
+ }): Promise<void>;
109
212
  streamData(data: any): Promise<void>;
110
213
  mergeStream(stream: any): Promise<void>;
111
214
  /**
@@ -164,6 +267,7 @@ declare class BufferingStreamHelper implements StreamHelper {
164
267
  private capturedSummaries;
165
268
  private hasError;
166
269
  private errorMessage;
270
+ setSessionId(_sessionId: string): void;
167
271
  writeRole(_role?: string): Promise<void>;
168
272
  writeContent(content: string): Promise<void>;
169
273
  streamText(text: string, _delayMs?: number): Promise<void>;
@@ -174,6 +278,36 @@ declare class BufferingStreamHelper implements StreamHelper {
174
278
  writeSummary(summary: SummaryEvent): Promise<void>;
175
279
  writeOperation(operation: OperationEvent): Promise<void>;
176
280
  writeError(error: string | ErrorEvent): Promise<void>;
281
+ writeToolInputStart(params: {
282
+ toolCallId: string;
283
+ toolName: string;
284
+ }): Promise<void>;
285
+ writeToolInputDelta(params: {
286
+ toolCallId: string;
287
+ inputTextDelta: string;
288
+ }): Promise<void>;
289
+ writeToolInputAvailable(params: {
290
+ toolCallId: string;
291
+ toolName: string;
292
+ input: any;
293
+ providerMetadata?: any;
294
+ }): Promise<void>;
295
+ writeToolOutputAvailable(params: {
296
+ toolCallId: string;
297
+ output: any;
298
+ }): Promise<void>;
299
+ writeToolOutputError(params: {
300
+ toolCallId: string;
301
+ error: string;
302
+ output?: any;
303
+ }): Promise<void>;
304
+ writeToolApprovalRequest(params: {
305
+ approvalId: string;
306
+ toolCallId: string;
307
+ }): Promise<void>;
308
+ writeToolOutputDenied(params: {
309
+ toolCallId: string;
310
+ }): Promise<void>;
177
311
  complete(): Promise<void>;
178
312
  /**
179
313
  * Get the captured response for non-streaming output
@@ -5,6 +5,7 @@ import { parsePartialJson } from "ai";
5
5
  var SSEStreamHelper = class {
6
6
  isTextStreaming = false;
7
7
  queuedEvents = [];
8
+ toolCallIndexById = /* @__PURE__ */ new Map();
8
9
  constructor(stream, requestId, timestamp) {
9
10
  this.stream = stream;
10
11
  this.requestId = requestId;
@@ -40,6 +41,25 @@ var SSEStreamHelper = class {
40
41
  }]
41
42
  }) });
42
43
  }
44
+ getToolIndex(toolCallId) {
45
+ const existing = this.toolCallIndexById.get(toolCallId);
46
+ if (existing !== void 0) return existing;
47
+ const next = this.toolCallIndexById.size;
48
+ this.toolCallIndexById.set(toolCallId, next);
49
+ return next;
50
+ }
51
+ async writeToolCallsDelta(toolCalls) {
52
+ await this.stream.writeSSE({ data: JSON.stringify({
53
+ id: this.requestId,
54
+ object: "chat.completion.chunk",
55
+ created: this.timestamp,
56
+ choices: [{
57
+ index: 0,
58
+ delta: { tool_calls: toolCalls },
59
+ finish_reason: null
60
+ }]
61
+ }) });
62
+ }
43
63
  /**
44
64
  * Stream text word by word with optional delay
45
65
  */
@@ -97,6 +117,65 @@ var SSEStreamHelper = class {
97
117
  }]
98
118
  }) });
99
119
  }
120
+ async writeToolInputStart(params) {
121
+ const index = this.getToolIndex(params.toolCallId);
122
+ await this.writeToolCallsDelta([{
123
+ index,
124
+ id: params.toolCallId,
125
+ type: "function",
126
+ function: {
127
+ name: params.toolName,
128
+ arguments: ""
129
+ }
130
+ }]);
131
+ }
132
+ async writeToolInputDelta(params) {
133
+ const index = this.getToolIndex(params.toolCallId);
134
+ await this.writeToolCallsDelta([{
135
+ index,
136
+ id: null,
137
+ type: null,
138
+ function: {
139
+ name: null,
140
+ arguments: params.inputTextDelta
141
+ }
142
+ }]);
143
+ }
144
+ async writeToolInputAvailable(params) {
145
+ const fullArgs = JSON.stringify(params.input ?? {});
146
+ if (fullArgs) await this.writeToolInputDelta({
147
+ toolCallId: params.toolCallId,
148
+ inputTextDelta: fullArgs
149
+ });
150
+ }
151
+ async writeToolOutputAvailable(params) {
152
+ await this.writeContent(JSON.stringify({
153
+ type: "tool-output-available",
154
+ toolCallId: params.toolCallId,
155
+ output: params.output
156
+ }));
157
+ }
158
+ async writeToolOutputError(params) {
159
+ await this.writeContent(JSON.stringify({
160
+ type: "tool-output-error",
161
+ toolCallId: params.toolCallId,
162
+ error: params.error,
163
+ output: params.output ?? null
164
+ }));
165
+ }
166
+ async writeToolApprovalRequest(params) {
167
+ await this.writeContent(JSON.stringify({
168
+ type: "tool-approval-request",
169
+ approvalId: params.approvalId,
170
+ toolCallId: params.toolCallId
171
+ }));
172
+ }
173
+ async writeToolOutputDenied(params) {
174
+ await this.writeContent(JSON.stringify({
175
+ type: "tool-output-denied",
176
+ toolCallId: params.toolCallId
177
+ }));
178
+ }
100
179
  async writeSummary(summary) {
101
180
  if (this.isTextStreaming) {
102
181
  this.queuedEvents.push({
@@ -166,6 +245,7 @@ var VercelDataStreamHelper = class VercelDataStreamHelper {
166
245
  this.forceCleanup("Connection lifetime exceeded");
167
246
  }, STREAM_MAX_LIFETIME_MS);
168
247
  }
248
+ setSessionId(_sessionId) {}
169
249
  async writeRole(_ = "assistant") {}
170
250
  async writeContent(content) {
171
251
  if (this.isCompleted) {
@@ -272,6 +352,64 @@ var VercelDataStreamHelper = class VercelDataStreamHelper {
272
352
  type: "error"
273
353
  });
274
354
  }
355
+ async writeToolInputStart(params) {
356
+ if (this.isCompleted) return;
357
+ this.writer.write({
358
+ type: "tool-input-start",
359
+ toolCallId: params.toolCallId,
360
+ toolName: params.toolName
361
+ });
362
+ }
363
+ async writeToolInputDelta(params) {
364
+ if (this.isCompleted) return;
365
+ this.writer.write({
366
+ type: "tool-input-delta",
367
+ toolCallId: params.toolCallId,
368
+ inputTextDelta: params.inputTextDelta
369
+ });
370
+ }
371
+ async writeToolInputAvailable(params) {
372
+ if (this.isCompleted) return;
373
+ this.writer.write({
374
+ type: "tool-input-available",
375
+ toolCallId: params.toolCallId,
376
+ toolName: params.toolName,
377
+ input: params.input,
378
+ ...params.providerMetadata ? { providerMetadata: params.providerMetadata } : {}
379
+ });
380
+ }
381
+ async writeToolOutputAvailable(params) {
382
+ if (this.isCompleted) return;
383
+ this.writer.write({
384
+ type: "tool-output-available",
385
+ toolCallId: params.toolCallId,
386
+ output: params.output
387
+ });
388
+ }
389
+ async writeToolOutputError(params) {
390
+ if (this.isCompleted) return;
391
+ this.writer.write({
392
+ type: "tool-output-error",
393
+ toolCallId: params.toolCallId,
394
+ error: params.error,
395
+ output: params.output ?? null
396
+ });
397
+ }
398
+ async writeToolApprovalRequest(params) {
399
+ if (this.isCompleted) return;
400
+ this.writer.write({
401
+ type: "tool-approval-request",
402
+ approvalId: params.approvalId,
403
+ toolCallId: params.toolCallId
404
+ });
405
+ }
406
+ async writeToolOutputDenied(params) {
407
+ if (this.isCompleted) return;
408
+ this.writer.write({
409
+ type: "tool-output-denied",
410
+ toolCallId: params.toolCallId
411
+ });
412
+ }
275
413
  async streamData(data) {
276
414
  await this.writeContent(JSON.stringify(data));
277
415
  }
@@ -458,6 +596,7 @@ var BufferingStreamHelper = class {
458
596
  capturedSummaries = [];
459
597
  hasError = false;
460
598
  errorMessage = "";
599
+ setSessionId(_sessionId) {}
461
600
  async writeRole(_role) {}
462
601
  async writeContent(content) {
463
602
  this.capturedText += content;
@@ -487,6 +626,49 @@ var BufferingStreamHelper = class {
487
626
  this.hasError = true;
488
627
  this.errorMessage = typeof error === "string" ? error : error.message;
489
628
  }
629
+ async writeToolInputStart(params) {
630
+ this.capturedData.push({
631
+ type: "tool-input-start",
632
+ ...params
633
+ });
634
+ }
635
+ async writeToolInputDelta(params) {
636
+ this.capturedData.push({
637
+ type: "tool-input-delta",
638
+ ...params
639
+ });
640
+ }
641
+ async writeToolInputAvailable(params) {
642
+ this.capturedData.push({
643
+ type: "tool-input-available",
644
+ ...params
645
+ });
646
+ }
647
+ async writeToolOutputAvailable(params) {
648
+ this.capturedData.push({
649
+ type: "tool-output-available",
650
+ ...params
651
+ });
652
+ }
653
+ async writeToolOutputError(params) {
654
+ this.capturedData.push({
655
+ type: "tool-output-error",
656
+ ...params,
657
+ output: params.output ?? null
658
+ });
659
+ }
660
+ async writeToolApprovalRequest(params) {
661
+ this.capturedData.push({
662
+ type: "tool-approval-request",
663
+ ...params
664
+ });
665
+ }
666
+ async writeToolOutputDenied(params) {
667
+ this.capturedData.push({
668
+ type: "tool-output-denied",
669
+ ...params
670
+ });
671
+ }
490
672
  async complete() {}
491
673
  /**
492
674
  * Get the captured response for non-streaming output
package/dist/env.d.ts CHANGED
@@ -14,11 +14,11 @@ declare const envSchema: z.ZodObject<{
14
14
  pentest: "pentest";
15
15
  }>>;
16
16
  LOG_LEVEL: z.ZodDefault<z.ZodEnum<{
17
- error: "error";
18
17
  trace: "trace";
19
18
  debug: "debug";
20
19
  info: "info";
21
20
  warn: "warn";
21
+ error: "error";
22
22
  }>>;
23
23
  INKEEP_AGENTS_MANAGE_DATABASE_URL: z.ZodString;
24
24
  INKEEP_AGENTS_RUN_DATABASE_URL: z.ZodString;
@@ -53,7 +53,7 @@ declare const envSchema: z.ZodObject<{
53
53
  declare const env: {
54
54
  NODE_ENV: "development" | "production" | "test";
55
55
  ENVIRONMENT: "development" | "production" | "test" | "pentest";
56
- LOG_LEVEL: "error" | "trace" | "debug" | "info" | "warn";
56
+ LOG_LEVEL: "trace" | "debug" | "info" | "warn" | "error";
57
57
  INKEEP_AGENTS_MANAGE_DATABASE_URL: string;
58
58
  INKEEP_AGENTS_RUN_DATABASE_URL: string;
59
59
  INKEEP_AGENTS_API_URL: string;