@illuma-ai/agents 1.4.0-alpha.3 → 1.4.0-alpha.5

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 (30) hide show
  1. package/dist/cjs/providers/tools-server/ToolsServerCapabilityProvider.cjs +8 -1
  2. package/dist/cjs/providers/tools-server/ToolsServerCapabilityProvider.cjs.map +1 -1
  3. package/dist/cjs/providers/types.cjs.map +1 -1
  4. package/dist/cjs/tools/artifacts/schema.cjs +30 -7
  5. package/dist/cjs/tools/artifacts/schema.cjs.map +1 -1
  6. package/dist/cjs/tools/artifacts/tool.cjs +8 -2
  7. package/dist/cjs/tools/artifacts/tool.cjs.map +1 -1
  8. package/dist/cjs/tools/proxyTool.cjs +7 -5
  9. package/dist/cjs/tools/proxyTool.cjs.map +1 -1
  10. package/dist/esm/providers/tools-server/ToolsServerCapabilityProvider.mjs +8 -1
  11. package/dist/esm/providers/tools-server/ToolsServerCapabilityProvider.mjs.map +1 -1
  12. package/dist/esm/providers/types.mjs.map +1 -1
  13. package/dist/esm/tools/artifacts/schema.mjs +30 -7
  14. package/dist/esm/tools/artifacts/schema.mjs.map +1 -1
  15. package/dist/esm/tools/artifacts/tool.mjs +8 -2
  16. package/dist/esm/tools/artifacts/tool.mjs.map +1 -1
  17. package/dist/esm/tools/proxyTool.mjs +7 -5
  18. package/dist/esm/tools/proxyTool.mjs.map +1 -1
  19. package/dist/types/providers/tools-server/ToolsServerCapabilityProvider.d.ts +14 -0
  20. package/dist/types/providers/types.d.ts +14 -0
  21. package/dist/types/tools/proxyTool.d.ts +7 -0
  22. package/package.json +1 -1
  23. package/src/providers/__tests__/ToolsServerCapabilityProvider.test.ts +63 -0
  24. package/src/providers/tools-server/ToolsServerCapabilityProvider.ts +28 -0
  25. package/src/providers/types.ts +17 -0
  26. package/src/tools/artifacts/__tests__/tool.test.ts +31 -15
  27. package/src/tools/artifacts/schema.ts +36 -13
  28. package/src/tools/artifacts/tool.ts +28 -16
  29. package/src/tools/artifacts/types.ts +18 -5
  30. package/src/tools/proxyTool.ts +25 -5
@@ -62,14 +62,14 @@ async function resolveContentIdIfPresent(
62
62
  resolver: ContentIdResolver | undefined,
63
63
  id: string | undefined,
64
64
  scope: ArtifactToolScope,
65
- logger?: { debug: (msg: string) => void },
65
+ logger?: { debug: (msg: string) => void }
66
66
  ): Promise<string | undefined> {
67
67
  if (!resolver || !id) return id;
68
68
  const out = await resolver.resolve(id, scope);
69
69
  if (!out) return id;
70
70
  if (out.resolvedId !== id) {
71
71
  logger?.debug(
72
- `[artifact] resolved "${id}" → "${out.resolvedId}"${out.resolvedName ? ` ("${out.resolvedName}")` : ''}`,
72
+ `[artifact] resolved "${id}" → "${out.resolvedId}"${out.resolvedName ? ` ("${out.resolvedName}")` : ''}`
73
73
  );
74
74
  }
75
75
  return out.resolvedId;
@@ -78,7 +78,7 @@ async function resolveContentIdIfPresent(
78
78
  // ─── Writer tool (artifact_tool) ─────────────────────────────────────────
79
79
 
80
80
  export function createArtifactTool(
81
- config: ArtifactToolConfig,
81
+ config: ArtifactToolConfig
82
82
  ): DynamicStructuredTool {
83
83
  const { handlers, getScope, resolver, logger, descriptionOverride } = config;
84
84
 
@@ -104,7 +104,7 @@ export function createArtifactTool(
104
104
  resolver,
105
105
  input.content_id,
106
106
  scope,
107
- logger,
107
+ logger
108
108
  );
109
109
 
110
110
  const started = Date.now();
@@ -121,7 +121,8 @@ export function createArtifactTool(
121
121
  return await handlers.write(args, scope);
122
122
  }
123
123
  case 'edit': {
124
- if (!resolvedContentId) return ['Error: edit requires content_id', {}];
124
+ if (!resolvedContentId)
125
+ return ['Error: edit requires content_id', {}];
125
126
  const args: EditArgs = {
126
127
  action: 'edit',
127
128
  content_id: resolvedContentId,
@@ -133,7 +134,8 @@ export function createArtifactTool(
133
134
  return await handlers.edit(args, scope);
134
135
  }
135
136
  case 'verify': {
136
- if (!resolvedContentId) return ['Error: verify requires content_id', {}];
137
+ if (!resolvedContentId)
138
+ return ['Error: verify requires content_id', {}];
137
139
  const args: VerifyArgs = {
138
140
  action: 'verify',
139
141
  content_id: resolvedContentId,
@@ -141,7 +143,8 @@ export function createArtifactTool(
141
143
  return await handlers.verify(args, scope);
142
144
  }
143
145
  case 'delete': {
144
- if (!resolvedContentId) return ['Error: delete requires content_id', {}];
146
+ if (!resolvedContentId)
147
+ return ['Error: delete requires content_id', {}];
145
148
  const args: DeleteArgs = {
146
149
  action: 'delete',
147
150
  content_id: resolvedContentId,
@@ -149,7 +152,10 @@ export function createArtifactTool(
149
152
  return await handlers.delete(args, scope);
150
153
  }
151
154
  default:
152
- return [`Unknown action: ${(input as { action: string }).action}`, {}];
155
+ return [
156
+ `Unknown action: ${(input as { action: string }).action}`,
157
+ {},
158
+ ];
153
159
  }
154
160
  } catch (err) {
155
161
  const e = err instanceof Error ? err : new Error(String(err));
@@ -167,14 +173,14 @@ export function createArtifactTool(
167
173
  responseFormat: 'content_and_artifact',
168
174
  description: descriptionOverride ?? DEFAULT_ARTIFACT_DESCRIPTION,
169
175
  schema: artifactToolSchema,
170
- },
176
+ }
171
177
  );
172
178
  }
173
179
 
174
180
  // ─── Reader tool (content_reader) ────────────────────────────────────────
175
181
 
176
182
  export function createContentReaderTool(
177
- config: ContentReaderToolConfig,
183
+ config: ContentReaderToolConfig
178
184
  ): DynamicStructuredTool {
179
185
  const { handlers, getScope, resolver, logger, descriptionOverride } = config;
180
186
 
@@ -202,14 +208,15 @@ export function createContentReaderTool(
202
208
  resolver,
203
209
  input.content_id,
204
210
  scope,
205
- logger,
211
+ logger
206
212
  );
207
213
 
208
214
  const started = Date.now();
209
215
  try {
210
216
  switch (input.action) {
211
217
  case 'read': {
212
- if (!resolvedContentId) return ['Error: read requires content_id', {}];
218
+ if (!resolvedContentId)
219
+ return ['Error: read requires content_id', {}];
213
220
  const args: ReadArgs = {
214
221
  action: 'read',
215
222
  content_id: resolvedContentId,
@@ -221,7 +228,8 @@ export function createContentReaderTool(
221
228
  return await handlers.read(args, scope);
222
229
  }
223
230
  case 'search': {
224
- if (!resolvedContentId) return ['Error: search requires content_id', {}];
231
+ if (!resolvedContentId)
232
+ return ['Error: search requires content_id', {}];
225
233
  if (!input.pattern) return ['Error: search requires pattern', {}];
226
234
  const args: SearchArgs = {
227
235
  action: 'search',
@@ -239,7 +247,8 @@ export function createContentReaderTool(
239
247
  return await handlers.list(args, scope);
240
248
  }
241
249
  case 'info': {
242
- if (!resolvedContentId) return ['Error: info requires content_id', {}];
250
+ if (!resolvedContentId)
251
+ return ['Error: info requires content_id', {}];
243
252
  const args: InfoArgs = {
244
253
  action: 'info',
245
254
  content_id: resolvedContentId,
@@ -247,7 +256,10 @@ export function createContentReaderTool(
247
256
  return await handlers.info(args, scope);
248
257
  }
249
258
  default:
250
- return [`Unknown action: ${(input as { action: string }).action}`, {}];
259
+ return [
260
+ `Unknown action: ${(input as { action: string }).action}`,
261
+ {},
262
+ ];
251
263
  }
252
264
  } catch (err) {
253
265
  const e = err instanceof Error ? err : new Error(String(err));
@@ -265,7 +277,7 @@ export function createContentReaderTool(
265
277
  responseFormat: 'content_and_artifact',
266
278
  description: descriptionOverride ?? DEFAULT_CONTENT_READER_DESCRIPTION,
267
279
  schema: contentReaderSchema,
268
- },
280
+ }
269
281
  );
270
282
  }
271
283
 
@@ -83,7 +83,11 @@ export interface InfoArgs {
83
83
  content_id: string;
84
84
  }
85
85
 
86
- export type ArtifactWriteAction = WriteArgs | EditArgs | VerifyArgs | DeleteArgs;
86
+ export type ArtifactWriteAction =
87
+ | WriteArgs
88
+ | EditArgs
89
+ | VerifyArgs
90
+ | DeleteArgs;
87
91
  export type ArtifactReadAction = ReadArgs | SearchArgs | ListArgs | InfoArgs;
88
92
 
89
93
  // ─── Handler bundles ──────────────────────────────────────────────────────
@@ -92,14 +96,23 @@ export type ArtifactReadAction = ReadArgs | SearchArgs | ListArgs | InfoArgs;
92
96
  export interface ArtifactWriteHandlers {
93
97
  write(args: WriteArgs, scope: ArtifactToolScope): Promise<ArtifactToolResult>;
94
98
  edit(args: EditArgs, scope: ArtifactToolScope): Promise<ArtifactToolResult>;
95
- verify(args: VerifyArgs, scope: ArtifactToolScope): Promise<ArtifactToolResult>;
96
- delete(args: DeleteArgs, scope: ArtifactToolScope): Promise<ArtifactToolResult>;
99
+ verify(
100
+ args: VerifyArgs,
101
+ scope: ArtifactToolScope
102
+ ): Promise<ArtifactToolResult>;
103
+ delete(
104
+ args: DeleteArgs,
105
+ scope: ArtifactToolScope
106
+ ): Promise<ArtifactToolResult>;
97
107
  }
98
108
 
99
109
  /** Reader-surface handlers — invoked by `content_reader`. */
100
110
  export interface ContentReadHandlers {
101
111
  read(args: ReadArgs, scope: ArtifactToolScope): Promise<ArtifactToolResult>;
102
- search(args: SearchArgs, scope: ArtifactToolScope): Promise<ArtifactToolResult>;
112
+ search(
113
+ args: SearchArgs,
114
+ scope: ArtifactToolScope
115
+ ): Promise<ArtifactToolResult>;
103
116
  list(args: ListArgs, scope: ArtifactToolScope): Promise<ArtifactToolResult>;
104
117
  info(args: InfoArgs, scope: ArtifactToolScope): Promise<ArtifactToolResult>;
105
118
  }
@@ -112,7 +125,7 @@ export interface ContentReadHandlers {
112
125
  export interface ContentIdResolver {
113
126
  resolve(
114
127
  id: string,
115
- scope: ArtifactToolScope,
128
+ scope: ArtifactToolScope
116
129
  ): Promise<{ resolvedId: string; resolvedName?: string } | null>;
117
130
  }
118
131
 
@@ -40,6 +40,15 @@ export interface ProxyToolOptions {
40
40
  * telemetry, debug logging. Errors in the hook are swallowed.
41
41
  */
42
42
  onExecute?: (ctx: ExecuteCallbackContext) => void;
43
+ /**
44
+ * Optional per-invocation auth header builder. Called on every tool
45
+ * invocation before POSTing; returned headers are merged into the
46
+ * request alongside the base client's headers. Typical use: pass a
47
+ * freshly minted per-user JWT for admin-gated tools.
48
+ */
49
+ getAuthHeaders?: () =>
50
+ | Record<string, string>
51
+ | Promise<Record<string, string>>;
43
52
  }
44
53
 
45
54
  export interface ExecuteCallbackContext {
@@ -61,7 +70,12 @@ export function buildProxyTool(
61
70
  credentials: CredentialMap,
62
71
  options: ProxyToolOptions
63
72
  ): StructuredToolInterface {
64
- const { client, executePath = '/execute/:name', onExecute } = options;
73
+ const {
74
+ client,
75
+ executePath = '/execute/:name',
76
+ onExecute,
77
+ getAuthHeaders,
78
+ } = options;
65
79
  const url = executePath.replace(':name', encodeURIComponent(capability.name));
66
80
 
67
81
  return tool(
@@ -76,10 +90,16 @@ export function buildProxyTool(
76
90
  `${debugPrefix} invoking — inputKeys=${input && typeof input === 'object' ? Object.keys(input as object).length : 0}`
77
91
  );
78
92
 
79
- const res = await client.post<ExecuteResponse>(url, {
80
- input,
81
- credentials,
82
- });
93
+ const extraHeaders = getAuthHeaders
94
+ ? await getAuthHeaders()
95
+ : undefined;
96
+ const res = await client.post<ExecuteResponse>(
97
+ url,
98
+ { input, credentials },
99
+ extraHeaders && Object.keys(extraHeaders).length > 0
100
+ ? { headers: extraHeaders }
101
+ : undefined,
102
+ );
83
103
 
84
104
  const durationMs = Date.now() - startMs;
85
105