@alquimia-ai/tools 2.5.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 +527 -23
- package/dist/actions/index.d.mts +1 -1
- package/dist/actions/index.d.ts +1 -1
- package/dist/hooks/index.d.mts +3 -3
- package/dist/hooks/index.d.ts +3 -3
- package/dist/hooks/index.js +62 -6
- package/dist/hooks/index.js.map +1 -1
- package/dist/hooks/index.mjs +62 -6
- package/dist/hooks/index.mjs.map +1 -1
- package/dist/next/index.js +4 -1
- package/dist/next/index.js.map +1 -1
- package/dist/next/index.mjs +4 -1
- package/dist/next/index.mjs.map +1 -1
- package/dist/providers/index.d.mts +3 -3
- package/dist/providers/index.d.ts +3 -3
- package/dist/{providers-DiR9cgyo.d.mts → providers-B4IOiGfr.d.mts} +1 -1
- package/dist/{providers-b5_yMyMo.d.ts → providers-mx21gNgZ.d.ts} +1 -1
- package/dist/proxy.js +4 -1
- package/dist/proxy.js.map +1 -1
- package/dist/proxy.mjs +4 -1
- package/dist/proxy.mjs.map +1 -1
- package/dist/sdk/index.d.mts +37 -4
- package/dist/sdk/index.d.ts +37 -4
- package/dist/sdk/index.js +43 -6
- package/dist/sdk/index.js.map +1 -1
- package/dist/sdk/index.mjs +43 -6
- package/dist/sdk/index.mjs.map +1 -1
- package/dist/services/index.d.mts +1 -1
- package/dist/services/index.d.ts +1 -1
- package/dist/{type-DqX3-9QS.d.mts → type-61gaZga-.d.mts} +45 -1
- package/dist/{type-xksRnBUW.d.ts → type-D-JaSMkV.d.ts} +45 -1
- package/dist/types/index.d.mts +6 -4
- package/dist/types/index.d.ts +6 -4
- package/dist/types/index.js.map +1 -1
- package/dist/types/index.mjs.map +1 -1
- package/dist/{types-C-6fgK1_.d.mts → types-lOliroPw.d.mts} +1 -1
- package/dist/{types-C-6fgK1_.d.ts → types-lOliroPw.d.ts} +1 -1
- package/dist/utils/index.d.mts +1 -1
- package/dist/utils/index.d.ts +1 -1
- package/dist/worklog/index.d.mts +2 -2
- package/dist/worklog/index.d.ts +2 -2
- package/dist/worklog/index.js +19 -0
- package/dist/worklog/index.js.map +1 -1
- package/dist/worklog/index.mjs +19 -0
- package/dist/worklog/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/hooks/index.mjs
CHANGED
|
@@ -11,6 +11,9 @@ var AlquimiaSDK = class {
|
|
|
11
11
|
this.streamId = null;
|
|
12
12
|
// W3C traceparent for the current turn, so infer and stream share one trace.
|
|
13
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;
|
|
14
17
|
this.tools = [];
|
|
15
18
|
this.extraInstructions = null;
|
|
16
19
|
this.assistantConfig = null;
|
|
@@ -91,6 +94,19 @@ var AlquimiaSDK = class {
|
|
|
91
94
|
this.userId = userId;
|
|
92
95
|
return this;
|
|
93
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
|
+
}
|
|
94
110
|
getEnforceCharacterization() {
|
|
95
111
|
return this.enforceCharacterization ?? true;
|
|
96
112
|
}
|
|
@@ -106,19 +122,29 @@ var AlquimiaSDK = class {
|
|
|
106
122
|
}
|
|
107
123
|
return this.whisperProvider.speechToText(audio);
|
|
108
124
|
}
|
|
109
|
-
async sendMessage(query,
|
|
125
|
+
async sendMessage(query, options = {}) {
|
|
110
126
|
if (!this.conversationId) {
|
|
111
127
|
throw new Error(
|
|
112
128
|
"Conversation not initialized. Call withConversationId() before sendMessage()"
|
|
113
129
|
);
|
|
114
130
|
}
|
|
115
|
-
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;
|
|
116
139
|
const adapterHeaders = this.adapter.getHeaders?.() ?? {};
|
|
117
140
|
const hasClientTools = Array.isArray(this.tools) && this.tools.length > 0;
|
|
118
141
|
const initMessage = {
|
|
119
|
-
query,
|
|
142
|
+
...query !== void 0 && { query },
|
|
120
143
|
session_id: this.conversationId,
|
|
121
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 },
|
|
122
148
|
...this.extraInstructions && { extra_instructions: this.extraInstructions },
|
|
123
149
|
...this.assistantConfig && { config: this.assistantConfig },
|
|
124
150
|
...hasClientTools && {
|
|
@@ -131,13 +157,14 @@ var AlquimiaSDK = class {
|
|
|
131
157
|
const result = (await this.axiosInstance.post(inferUrl, initMessage, {
|
|
132
158
|
headers: {
|
|
133
159
|
"Content-Type": "application/json",
|
|
134
|
-
...traceParent && { "x-trace-parent": traceParent },
|
|
160
|
+
...opts.traceParent && { "x-trace-parent": opts.traceParent },
|
|
135
161
|
...adapterHeaders,
|
|
136
162
|
...this.buildIdentityHeaders()
|
|
137
163
|
}
|
|
138
164
|
})).data;
|
|
139
|
-
this.traceParent = traceParent ?? null;
|
|
165
|
+
this.traceParent = opts.traceParent ?? null;
|
|
140
166
|
this.streamId = result.taskid ?? null;
|
|
167
|
+
this.versionTag = result.versiontag ?? this.versionTag;
|
|
141
168
|
this.attachmentResponses = result.attachments ?? [];
|
|
142
169
|
this.attachments = [];
|
|
143
170
|
return this;
|
|
@@ -164,6 +191,7 @@ var AlquimiaSDK = class {
|
|
|
164
191
|
...this.streamId && { taskid: this.streamId },
|
|
165
192
|
...this.conversationId && { sessionid: this.conversationId },
|
|
166
193
|
...this.userId && { userid: this.userId },
|
|
194
|
+
...this.versionTag && { versiontag: this.versionTag },
|
|
167
195
|
...adapterHeaders
|
|
168
196
|
};
|
|
169
197
|
await this.axiosInstance.post(url, response, { headers });
|
|
@@ -206,18 +234,23 @@ var AlquimiaSDK = class {
|
|
|
206
234
|
getAttachmentResponses() {
|
|
207
235
|
return this.attachmentResponses;
|
|
208
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
|
+
*/
|
|
209
241
|
async uploadAttachment(file, _attachmentId) {
|
|
210
242
|
const url = this.adapter.resolveBlobUploadUrl();
|
|
211
243
|
const adapterHeaders = this.adapter.getHeaders?.() ?? {};
|
|
212
244
|
const formData = new FormData();
|
|
213
245
|
formData.append("file", file);
|
|
214
|
-
await this.axiosInstance.post(url, formData, {
|
|
246
|
+
const response = await this.axiosInstance.post(url, formData, {
|
|
215
247
|
headers: {
|
|
216
248
|
"Content-Type": "multipart/form-data",
|
|
217
249
|
...adapterHeaders,
|
|
218
250
|
...this.buildIdentityHeaders()
|
|
219
251
|
}
|
|
220
252
|
});
|
|
253
|
+
return response.data;
|
|
221
254
|
}
|
|
222
255
|
/**
|
|
223
256
|
* Identity headers (kebab-case) required by `/context/blob/upload` and
|
|
@@ -248,6 +281,10 @@ var AlquimiaSDK = class {
|
|
|
248
281
|
getTaskId() {
|
|
249
282
|
return this.streamId;
|
|
250
283
|
}
|
|
284
|
+
/** Registry version tag resolved by the runtime for the current task, if any. */
|
|
285
|
+
getVersionTag() {
|
|
286
|
+
return this.versionTag;
|
|
287
|
+
}
|
|
251
288
|
};
|
|
252
289
|
var alquimia_sdk_default = AlquimiaSDK;
|
|
253
290
|
|
|
@@ -352,6 +389,14 @@ var agentTitle = (r) => {
|
|
|
352
389
|
return typeof name === "string" && name.length > 0 ? `Agent: ${name}` : "Agent-to-agent";
|
|
353
390
|
};
|
|
354
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
|
+
};
|
|
355
400
|
var EVENT_REGISTRY = {
|
|
356
401
|
// Run envelope
|
|
357
402
|
AssistantInference: { kind: "answer", role: "run-open", title: constTitle("Inference started") },
|
|
@@ -359,6 +404,9 @@ var EVENT_REGISTRY = {
|
|
|
359
404
|
// Safeguard
|
|
360
405
|
ShieldInference: { kind: "safeguard", role: "open", title: constTitle("Safeguard") },
|
|
361
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 },
|
|
362
410
|
// Reasoning
|
|
363
411
|
ResponseInference: { kind: "reasoning", role: "open", title: constTitle("Reasoning") },
|
|
364
412
|
ResponseInferenceResponse: { kind: "reasoning", role: "close", title: constTitle("Reasoning") },
|
|
@@ -376,6 +424,14 @@ var EVENT_REGISTRY = {
|
|
|
376
424
|
A2AInference: { kind: "a2a", role: "open", title: agentTitle },
|
|
377
425
|
AgentDiscovery: { kind: "a2a", role: "open", title: constTitle("Agent discovery") },
|
|
378
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") },
|
|
379
435
|
// Memory / persistence
|
|
380
436
|
ContextPersistence: { kind: "memory", role: "open", title: constTitle("Memory persistence") },
|
|
381
437
|
ContextFlush: { kind: "memory", role: "open", title: constTitle("Memory flush") },
|