@alquimia-ai/tools 2.4.0 → 2.7.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 +529 -19
- package/dist/actions/index.d.mts +2 -2
- package/dist/actions/index.d.ts +2 -2
- package/dist/actions/index.js +1 -1
- package/dist/actions/index.js.map +1 -1
- package/dist/actions/index.mjs +1 -1
- package/dist/actions/index.mjs.map +1 -1
- package/dist/{actions-CZU_GRy5.d.mts → actions-BjDPJdyA.d.mts} +1 -1
- package/dist/{actions-B0hfoYRd.d.ts → actions-CP1d4Ye1.d.ts} +1 -1
- package/dist/adapters/index.d.mts +2 -2
- package/dist/adapters/index.d.ts +2 -2
- package/dist/adapters/index.js.map +1 -1
- package/dist/genui/index.d.mts +3 -3
- package/dist/genui/index.d.ts +3 -3
- package/dist/genui/index.js +9 -1
- package/dist/genui/index.js.map +1 -1
- package/dist/genui/index.mjs +9 -1
- package/dist/genui/index.mjs.map +1 -1
- package/dist/hooks/index.d.mts +10 -10
- package/dist/hooks/index.d.ts +10 -10
- package/dist/hooks/index.js +88 -12
- package/dist/hooks/index.js.map +1 -1
- package/dist/hooks/index.mjs +88 -12
- package/dist/hooks/index.mjs.map +1 -1
- package/dist/next/index.js +23 -6
- package/dist/next/index.js.map +1 -1
- package/dist/next/index.mjs +23 -6
- package/dist/next/index.mjs.map +1 -1
- package/dist/providers/index.d.mts +4 -4
- package/dist/providers/index.d.ts +4 -4
- package/dist/providers/index.js +111 -110
- package/dist/providers/index.js.map +1 -1
- package/dist/providers/index.mjs +111 -110
- package/dist/providers/index.mjs.map +1 -1
- package/dist/{providers-BJTXCtI3.d.ts → providers-B4IOiGfr.d.mts} +8 -8
- package/dist/{providers-0Gi78uNQ.d.mts → providers-mx21gNgZ.d.ts} +8 -8
- package/dist/proxy.d.mts +4 -4
- package/dist/proxy.d.ts +4 -4
- package/dist/proxy.js +23 -6
- package/dist/proxy.js.map +1 -1
- package/dist/proxy.mjs +23 -6
- package/dist/proxy.mjs.map +1 -1
- package/dist/sdk/index.d.mts +39 -5
- package/dist/sdk/index.d.ts +39 -5
- package/dist/sdk/index.js +49 -6
- package/dist/sdk/index.js.map +1 -1
- package/dist/sdk/index.mjs +49 -6
- package/dist/sdk/index.mjs.map +1 -1
- package/dist/services/index.d.mts +3 -3
- package/dist/services/index.d.ts +3 -3
- package/dist/services/index.js.map +1 -1
- package/dist/services/index.mjs.map +1 -1
- package/dist/type-61gaZga-.d.mts +356 -0
- package/dist/type-D-JaSMkV.d.ts +356 -0
- package/dist/types/index.d.mts +80 -304
- package/dist/types/index.d.ts +80 -304
- package/dist/types/index.js.map +1 -1
- package/dist/types/index.mjs.map +1 -1
- package/dist/{types-DnfWUE9V.d.mts → types-CMVbyEv8.d.mts} +3 -2
- package/dist/{types-DnfWUE9V.d.ts → types-CMVbyEv8.d.ts} +3 -2
- package/dist/types-lOliroPw.d.mts +111 -0
- package/dist/types-lOliroPw.d.ts +111 -0
- package/dist/utils/index.d.mts +2 -2
- package/dist/utils/index.d.ts +2 -2
- package/dist/utils/index.js +1 -1
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/index.mjs +1 -1
- package/dist/utils/index.mjs.map +1 -1
- package/dist/worklog/index.d.mts +5 -2
- package/dist/worklog/index.d.ts +5 -2
- package/dist/worklog/index.js +22 -1
- package/dist/worklog/index.js.map +1 -1
- package/dist/worklog/index.mjs +22 -1
- package/dist/worklog/index.mjs.map +1 -1
- package/package.json +1 -1
- package/dist/types-Dvu9y4WM.d.mts +0 -53
- package/dist/types-Dvu9y4WM.d.ts +0 -53
package/dist/hooks/index.mjs
CHANGED
|
@@ -9,6 +9,11 @@ var AlquimiaSDK = class {
|
|
|
9
9
|
this.sessionId = null;
|
|
10
10
|
// Internal subscription id from infer (`taskid` on the wire).
|
|
11
11
|
this.streamId = null;
|
|
12
|
+
// W3C traceparent for the current turn, so infer and stream share one trace.
|
|
13
|
+
this.traceParent = null;
|
|
14
|
+
// Registry version tag resolved by the runtime for this task (v0.5.1), so
|
|
15
|
+
// the tool-completion half of the turn lands on the same agentspace version.
|
|
16
|
+
this.versionTag = null;
|
|
12
17
|
this.tools = [];
|
|
13
18
|
this.extraInstructions = null;
|
|
14
19
|
this.assistantConfig = null;
|
|
@@ -89,6 +94,19 @@ var AlquimiaSDK = class {
|
|
|
89
94
|
this.userId = userId;
|
|
90
95
|
return this;
|
|
91
96
|
}
|
|
97
|
+
/**
|
|
98
|
+
* Pin inference to a cached registry version. Sent as the `version_tag`
|
|
99
|
+
* query parameter, which `POST /event/infer/{assistant_id}` accepts from
|
|
100
|
+
* **runtime v0.5.2** onward; older runtimes ignore it.
|
|
101
|
+
*
|
|
102
|
+
* Works on every version: pass a versioned assistant ref
|
|
103
|
+
* (`<agentspace>/<assistant>[:<tag>]`) as the `assistantId` instead — the
|
|
104
|
+
* runtime parses the tag out of the path itself.
|
|
105
|
+
*/
|
|
106
|
+
withVersionTag(versionTag) {
|
|
107
|
+
this.versionTag = versionTag;
|
|
108
|
+
return this;
|
|
109
|
+
}
|
|
92
110
|
getEnforceCharacterization() {
|
|
93
111
|
return this.enforceCharacterization ?? true;
|
|
94
112
|
}
|
|
@@ -104,19 +122,29 @@ var AlquimiaSDK = class {
|
|
|
104
122
|
}
|
|
105
123
|
return this.whisperProvider.speechToText(audio);
|
|
106
124
|
}
|
|
107
|
-
async sendMessage(query,
|
|
125
|
+
async sendMessage(query, options = {}) {
|
|
108
126
|
if (!this.conversationId) {
|
|
109
127
|
throw new Error(
|
|
110
128
|
"Conversation not initialized. Call withConversationId() before sendMessage()"
|
|
111
129
|
);
|
|
112
130
|
}
|
|
113
|
-
const
|
|
131
|
+
const opts = typeof options === "string" ? { traceParent: options } : options;
|
|
132
|
+
if (query === void 0 && !opts.inputAudio) {
|
|
133
|
+
throw new Error(
|
|
134
|
+
"AlquimiaSDK: sendMessage needs a query, an inputAudio blob, or both"
|
|
135
|
+
);
|
|
136
|
+
}
|
|
137
|
+
const baseInferUrl = this.adapter.resolveInferUrl(this.assistantId);
|
|
138
|
+
const inferUrl = this.versionTag ? `${baseInferUrl}${baseInferUrl.includes("?") ? "&" : "?"}version_tag=${encodeURIComponent(this.versionTag)}` : baseInferUrl;
|
|
114
139
|
const adapterHeaders = this.adapter.getHeaders?.() ?? {};
|
|
115
140
|
const hasClientTools = Array.isArray(this.tools) && this.tools.length > 0;
|
|
116
141
|
const initMessage = {
|
|
117
|
-
query,
|
|
142
|
+
...query !== void 0 && { query },
|
|
118
143
|
session_id: this.conversationId,
|
|
119
144
|
user_id: this.userId,
|
|
145
|
+
...opts.inputAudio && { input_audio: opts.inputAudio },
|
|
146
|
+
// Only sent when set: the runtime defaults `output_audio` to true.
|
|
147
|
+
...opts.outputAudio !== void 0 && { output_audio: opts.outputAudio },
|
|
120
148
|
...this.extraInstructions && { extra_instructions: this.extraInstructions },
|
|
121
149
|
...this.assistantConfig && { config: this.assistantConfig },
|
|
122
150
|
...hasClientTools && {
|
|
@@ -129,12 +157,14 @@ var AlquimiaSDK = class {
|
|
|
129
157
|
const result = (await this.axiosInstance.post(inferUrl, initMessage, {
|
|
130
158
|
headers: {
|
|
131
159
|
"Content-Type": "application/json",
|
|
132
|
-
"x-trace-parent": traceParent
|
|
160
|
+
...opts.traceParent && { "x-trace-parent": opts.traceParent },
|
|
133
161
|
...adapterHeaders,
|
|
134
162
|
...this.buildIdentityHeaders()
|
|
135
163
|
}
|
|
136
164
|
})).data;
|
|
165
|
+
this.traceParent = opts.traceParent ?? null;
|
|
137
166
|
this.streamId = result.taskid ?? null;
|
|
167
|
+
this.versionTag = result.versiontag ?? this.versionTag;
|
|
138
168
|
this.attachmentResponses = result.attachments ?? [];
|
|
139
169
|
this.attachments = [];
|
|
140
170
|
return this;
|
|
@@ -161,6 +191,7 @@ var AlquimiaSDK = class {
|
|
|
161
191
|
...this.streamId && { taskid: this.streamId },
|
|
162
192
|
...this.conversationId && { sessionid: this.conversationId },
|
|
163
193
|
...this.userId && { userid: this.userId },
|
|
194
|
+
...this.versionTag && { versiontag: this.versionTag },
|
|
164
195
|
...adapterHeaders
|
|
165
196
|
};
|
|
166
197
|
await this.axiosInstance.post(url, response, { headers });
|
|
@@ -203,18 +234,23 @@ var AlquimiaSDK = class {
|
|
|
203
234
|
getAttachmentResponses() {
|
|
204
235
|
return this.attachmentResponses;
|
|
205
236
|
}
|
|
237
|
+
/**
|
|
238
|
+
* Upload a file into the session context. Returns the runtime {@link RuntimeBlob},
|
|
239
|
+
* which is what `sendMessage`'s `inputAudio` expects for audio inference.
|
|
240
|
+
*/
|
|
206
241
|
async uploadAttachment(file, _attachmentId) {
|
|
207
242
|
const url = this.adapter.resolveBlobUploadUrl();
|
|
208
243
|
const adapterHeaders = this.adapter.getHeaders?.() ?? {};
|
|
209
244
|
const formData = new FormData();
|
|
210
245
|
formData.append("file", file);
|
|
211
|
-
await this.axiosInstance.post(url, formData, {
|
|
246
|
+
const response = await this.axiosInstance.post(url, formData, {
|
|
212
247
|
headers: {
|
|
213
248
|
"Content-Type": "multipart/form-data",
|
|
214
249
|
...adapterHeaders,
|
|
215
250
|
...this.buildIdentityHeaders()
|
|
216
251
|
}
|
|
217
252
|
});
|
|
253
|
+
return response.data;
|
|
218
254
|
}
|
|
219
255
|
/**
|
|
220
256
|
* Identity headers (kebab-case) required by `/context/blob/upload` and
|
|
@@ -233,7 +269,10 @@ var AlquimiaSDK = class {
|
|
|
233
269
|
if (!this.streamId) {
|
|
234
270
|
throw new Error("Stream ID not initialized. Call sendMessage() first");
|
|
235
271
|
}
|
|
236
|
-
|
|
272
|
+
const url = this.adapter.resolveStreamUrl(this.streamId);
|
|
273
|
+
if (!this.traceParent) return url;
|
|
274
|
+
const separator = url.includes("?") ? "&" : "?";
|
|
275
|
+
return `${url}${separator}trace_parent=${encodeURIComponent(this.traceParent)}`;
|
|
237
276
|
}
|
|
238
277
|
getStreamId() {
|
|
239
278
|
return this.streamId;
|
|
@@ -242,6 +281,10 @@ var AlquimiaSDK = class {
|
|
|
242
281
|
getTaskId() {
|
|
243
282
|
return this.streamId;
|
|
244
283
|
}
|
|
284
|
+
/** Registry version tag resolved by the runtime for the current task, if any. */
|
|
285
|
+
getVersionTag() {
|
|
286
|
+
return this.versionTag;
|
|
287
|
+
}
|
|
245
288
|
};
|
|
246
289
|
var alquimia_sdk_default = AlquimiaSDK;
|
|
247
290
|
|
|
@@ -346,6 +389,14 @@ var agentTitle = (r) => {
|
|
|
346
389
|
return typeof name === "string" && name.length > 0 ? `Agent: ${name}` : "Agent-to-agent";
|
|
347
390
|
};
|
|
348
391
|
var constTitle = (label) => () => label;
|
|
392
|
+
var shieldBlockTitle = (r) => {
|
|
393
|
+
const id = asRecord(r.data).shield_id;
|
|
394
|
+
return typeof id === "string" && id.length > 0 ? `Blocked by ${id}` : "Blocked by safeguard";
|
|
395
|
+
};
|
|
396
|
+
var knowledgeTitle = (r) => {
|
|
397
|
+
const query = asRecord(r.data).query;
|
|
398
|
+
return typeof query === "string" && query.length > 0 ? `Knowledge: ${query}` : "Knowledge retrieval";
|
|
399
|
+
};
|
|
349
400
|
var EVENT_REGISTRY = {
|
|
350
401
|
// Run envelope
|
|
351
402
|
AssistantInference: { kind: "answer", role: "run-open", title: constTitle("Inference started") },
|
|
@@ -353,6 +404,9 @@ var EVENT_REGISTRY = {
|
|
|
353
404
|
// Safeguard
|
|
354
405
|
ShieldInference: { kind: "safeguard", role: "open", title: constTitle("Safeguard") },
|
|
355
406
|
ShieldInferenceResponse: { kind: "safeguard", role: "close", title: constTitle("Safeguard") },
|
|
407
|
+
// Emitted when a shield enforcement decision blocks the request (core 0.5.x).
|
|
408
|
+
// Response-only: the reducer opens it already closed when no command matched.
|
|
409
|
+
ShieldBlockedResponse: { kind: "safeguard", role: "close", title: shieldBlockTitle },
|
|
356
410
|
// Reasoning
|
|
357
411
|
ResponseInference: { kind: "reasoning", role: "open", title: constTitle("Reasoning") },
|
|
358
412
|
ResponseInferenceResponse: { kind: "reasoning", role: "close", title: constTitle("Reasoning") },
|
|
@@ -370,6 +424,14 @@ var EVENT_REGISTRY = {
|
|
|
370
424
|
A2AInference: { kind: "a2a", role: "open", title: agentTitle },
|
|
371
425
|
AgentDiscovery: { kind: "a2a", role: "open", title: constTitle("Agent discovery") },
|
|
372
426
|
AgentDiscoveryResponse: { kind: "a2a", role: "close", title: constTitle("Agent discovery") },
|
|
427
|
+
// Knowledge retrieval (RAG) — core 0.5.x
|
|
428
|
+
KnowledgeRetrieval: { kind: "knowledge", role: "open", title: knowledgeTitle },
|
|
429
|
+
KnowledgeRetrievalResponse: { kind: "knowledge", role: "close", title: knowledgeTitle },
|
|
430
|
+
// Speech pipeline — core 0.5.x
|
|
431
|
+
SpeechTranscription: { kind: "speech", role: "open", title: constTitle("Speech-to-text") },
|
|
432
|
+
SpeechTranscriptionResponse: { kind: "speech", role: "close", title: constTitle("Speech-to-text") },
|
|
433
|
+
SpeechSynthesis: { kind: "speech", role: "open", title: constTitle("Text-to-speech") },
|
|
434
|
+
SpeechSynthesisResponse: { kind: "speech", role: "close", title: constTitle("Text-to-speech") },
|
|
373
435
|
// Memory / persistence
|
|
374
436
|
ContextPersistence: { kind: "memory", role: "open", title: constTitle("Memory persistence") },
|
|
375
437
|
ContextFlush: { kind: "memory", role: "open", title: constTitle("Memory flush") },
|
|
@@ -486,7 +548,9 @@ function frameToRecord(frame) {
|
|
|
486
548
|
control_id: frame.control_id ?? null,
|
|
487
549
|
data: frame.data,
|
|
488
550
|
status,
|
|
489
|
-
date_submitted: typeof frame.date_submitted === "string" ? frame.date_submitted : ""
|
|
551
|
+
date_submitted: typeof frame.date_submitted === "string" ? frame.date_submitted : "",
|
|
552
|
+
entry_hash: frame.entry_hash ?? null,
|
|
553
|
+
previous_hash: frame.previous_hash ?? null
|
|
490
554
|
};
|
|
491
555
|
}
|
|
492
556
|
|
|
@@ -695,7 +759,15 @@ var surfaceShape = z3.object({
|
|
|
695
759
|
});
|
|
696
760
|
var UAX31_ID = /^[\p{XID_Start}_][\p{XID_Continue}]*$/u;
|
|
697
761
|
function validateProps(node, def2) {
|
|
698
|
-
const {
|
|
762
|
+
const {
|
|
763
|
+
id,
|
|
764
|
+
component: _component,
|
|
765
|
+
children: _children,
|
|
766
|
+
child: _child,
|
|
767
|
+
binding: _binding,
|
|
768
|
+
action: _action,
|
|
769
|
+
...props
|
|
770
|
+
} = node;
|
|
699
771
|
const parsed = def2.schema.safeParse(props);
|
|
700
772
|
if (parsed.success) return { ok: true, value: parsed.data, errors: [] };
|
|
701
773
|
return {
|
|
@@ -1358,14 +1430,14 @@ function ratingReducer(state, action) {
|
|
|
1358
1430
|
return state;
|
|
1359
1431
|
}
|
|
1360
1432
|
}
|
|
1361
|
-
function useRatings({ assistantId, sendRating, topicId }) {
|
|
1433
|
+
function useRatings({ assistantId, sendRating, topicId, onError }) {
|
|
1362
1434
|
const [isLoading, setIsLoading] = useState2(false);
|
|
1363
1435
|
const [hasReviewed, setHasReviewed] = useState2(false);
|
|
1364
1436
|
const [state, dispatch] = useReducer2(ratingReducer, initialState);
|
|
1365
1437
|
const setRatingStars = (rating) => {
|
|
1366
1438
|
dispatch({ type: "SET_RATING_STARS", payload: rating });
|
|
1367
1439
|
};
|
|
1368
|
-
const
|
|
1440
|
+
const _setRatingThumbs = (rating) => {
|
|
1369
1441
|
dispatch({ type: "SET_RATING_THUMBS", payload: rating });
|
|
1370
1442
|
};
|
|
1371
1443
|
const setRatingComment = (comment) => {
|
|
@@ -1388,7 +1460,9 @@ function useRatings({ assistantId, sendRating, topicId }) {
|
|
|
1388
1460
|
const response = await sendRating(ratingObj);
|
|
1389
1461
|
if (!response.success) {
|
|
1390
1462
|
setIsLoading(false);
|
|
1391
|
-
|
|
1463
|
+
const error = new Error(response.error?.message ?? "Failed to send rating");
|
|
1464
|
+
onHandleRateSuccess(false, error.message);
|
|
1465
|
+
onError?.("useRatings", error);
|
|
1392
1466
|
return;
|
|
1393
1467
|
}
|
|
1394
1468
|
if (key === "score") {
|
|
@@ -1401,7 +1475,9 @@ function useRatings({ assistantId, sendRating, topicId }) {
|
|
|
1401
1475
|
onHandleRateSuccess(true);
|
|
1402
1476
|
} catch (err) {
|
|
1403
1477
|
setIsLoading(false);
|
|
1404
|
-
|
|
1478
|
+
const error = err instanceof Error ? err : new Error(String(err));
|
|
1479
|
+
onHandleRateSuccess(false, error.message);
|
|
1480
|
+
onError?.("useRatings", error);
|
|
1405
1481
|
}
|
|
1406
1482
|
};
|
|
1407
1483
|
return {
|