@arbidocs/sdk 0.3.78 → 0.3.80
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/dist/{browser-CgUpQbyw.d.cts → browser-DIO4_N2g.d.cts} +25 -20
- package/dist/{browser-CgUpQbyw.d.ts → browser-DIO4_N2g.d.ts} +25 -20
- package/dist/browser.cjs +60 -10
- package/dist/browser.cjs.map +1 -1
- package/dist/browser.d.cts +1 -1
- package/dist/browser.d.ts +1 -1
- package/dist/browser.js +60 -10
- package/dist/browser.js.map +1 -1
- package/dist/index.cjs +60 -10
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +60 -10
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -4188,26 +4188,66 @@ async function resolveWorkspace(store, workspaceOpt) {
|
|
|
4188
4188
|
|
|
4189
4189
|
// src/sse.ts
|
|
4190
4190
|
var LIFECYCLE_LABELS_FALLBACK = {
|
|
4191
|
+
goal: "Thinking\u2026",
|
|
4191
4192
|
evaluation: "Evaluating results",
|
|
4192
|
-
answering: "
|
|
4193
|
+
answering: "Answered",
|
|
4193
4194
|
reviewing: "Reviewing answer",
|
|
4194
4195
|
planning: "Planning",
|
|
4195
4196
|
tool_progress: "Working"
|
|
4196
4197
|
};
|
|
4197
|
-
function
|
|
4198
|
-
if (
|
|
4199
|
-
|
|
4198
|
+
function resolveDocRefs(text, docNames) {
|
|
4199
|
+
if (!docNames) return text;
|
|
4200
|
+
return text.replace(/\{(doc-[^}]+)\}/g, (_match, id) => docNames[id] ?? id);
|
|
4201
|
+
}
|
|
4202
|
+
function resolveStepDocName(step, docNames) {
|
|
4203
|
+
if (!docNames) return void 0;
|
|
4204
|
+
const detail = step.detail;
|
|
4205
|
+
if (!detail || detail.length === 0) return void 0;
|
|
4206
|
+
for (const d2 of detail) {
|
|
4207
|
+
const id = d2.doc_ext_id ?? d2.document_ext_id;
|
|
4208
|
+
if (typeof id === "string") return docNames[id] ?? id;
|
|
4209
|
+
}
|
|
4210
|
+
return void 0;
|
|
4211
|
+
}
|
|
4212
|
+
function extractPageRange(step) {
|
|
4213
|
+
const detail = step.detail;
|
|
4214
|
+
if (!detail || detail.length === 0) return void 0;
|
|
4215
|
+
for (const d2 of detail) {
|
|
4216
|
+
const summary = typeof d2.summary === "string" ? d2.summary : void 0;
|
|
4217
|
+
if (!summary) continue;
|
|
4218
|
+
const match = summary.match(/\bpp?\.\s*(\d[\d.,\s–—-]*)/);
|
|
4219
|
+
if (!match) continue;
|
|
4220
|
+
const floored = match[1].replace(/\d+(?:\.\d+)?/g, (n2) => String(Math.floor(parseFloat(n2)))).replace(/(\d+)\s*[–—-]\s*\1(?!\d)/g, "$1");
|
|
4221
|
+
const items = [];
|
|
4222
|
+
for (const raw of floored.split(",")) {
|
|
4223
|
+
const item = raw.trim();
|
|
4224
|
+
if (item && !items.includes(item)) items.push(item);
|
|
4225
|
+
}
|
|
4226
|
+
if (items.length > 0) return `pp. ${items.join(", ")}`;
|
|
4227
|
+
}
|
|
4228
|
+
return void 0;
|
|
4229
|
+
}
|
|
4230
|
+
function formatAgentStepLabel(step, docNames) {
|
|
4231
|
+
if (step.step === "goal") {
|
|
4232
|
+
return step.label && step.label !== "Goal" ? step.label : "Thinking\u2026";
|
|
4233
|
+
}
|
|
4234
|
+
if (step.focus) return resolveDocRefs(step.focus, docNames);
|
|
4235
|
+
const docName = resolveStepDocName(step, docNames);
|
|
4236
|
+
const pages = docName ? extractPageRange(step) : void 0;
|
|
4237
|
+
const suffix = docName ? ` \u2014 ${docName}${pages ? ` \xB7 ${pages}` : ""}` : "";
|
|
4238
|
+
if (step.label) return `${step.label}${suffix}`;
|
|
4200
4239
|
const detail = step.detail;
|
|
4201
4240
|
if (step.step === "tool_progress" && detail && detail.length > 0) {
|
|
4202
4241
|
const label = detail[0].label || LIFECYCLE_LABELS_FALLBACK.tool_progress;
|
|
4242
|
+
if (suffix) return `${label}${suffix}`;
|
|
4203
4243
|
const message = detail[0].message;
|
|
4204
|
-
return message ? `${label}: ${message}` : label;
|
|
4244
|
+
return message ? `${label}: ${resolveDocRefs(message, docNames)}` : label;
|
|
4205
4245
|
}
|
|
4206
4246
|
if (step.step) {
|
|
4207
4247
|
return LIFECYCLE_LABELS_FALLBACK[step.step] || step.step;
|
|
4208
4248
|
}
|
|
4209
4249
|
if (detail && detail.length > 0) {
|
|
4210
|
-
if (detail[0].label) return detail[0].label
|
|
4250
|
+
if (detail[0].label) return `${detail[0].label}${suffix}`;
|
|
4211
4251
|
if (detail[0].tool) return detail[0].tool;
|
|
4212
4252
|
}
|
|
4213
4253
|
return "";
|
|
@@ -4321,6 +4361,11 @@ async function streamSSE(response, callbacks = {}) {
|
|
|
4321
4361
|
callbacks.onAgentStep?.(data);
|
|
4322
4362
|
if (data.t != null) callbacks.onElapsedTime?.(data.t);
|
|
4323
4363
|
},
|
|
4364
|
+
"arbi.agent_step_delta": (raw) => {
|
|
4365
|
+
const data = JSON.parse(raw);
|
|
4366
|
+
callbacks.onAgentStepDelta?.(data);
|
|
4367
|
+
if (data.t != null) callbacks.onElapsedTime?.(data.t);
|
|
4368
|
+
},
|
|
4324
4369
|
"arbi.user_message": (raw) => {
|
|
4325
4370
|
const data = JSON.parse(raw);
|
|
4326
4371
|
userMessage = data;
|
|
@@ -4346,16 +4391,21 @@ async function streamSSE(response, callbacks = {}) {
|
|
|
4346
4391
|
errors.push(message);
|
|
4347
4392
|
callbacks.onArbiError?.(data);
|
|
4348
4393
|
callbacks.onError?.(message);
|
|
4349
|
-
},
|
|
4350
|
-
"response.complete": () => {
|
|
4351
|
-
callbacks.onComplete?.();
|
|
4352
4394
|
}
|
|
4353
4395
|
};
|
|
4354
4396
|
const processEvents = (events) => {
|
|
4355
4397
|
for (const { event, data } of events) {
|
|
4356
4398
|
try {
|
|
4399
|
+
if (event === "reasoning") {
|
|
4400
|
+
callbacks.onReasoningDelta?.(data);
|
|
4401
|
+
continue;
|
|
4402
|
+
}
|
|
4357
4403
|
const handler = eventHandlers[event];
|
|
4358
|
-
if (handler)
|
|
4404
|
+
if (handler) {
|
|
4405
|
+
handler(data);
|
|
4406
|
+
} else {
|
|
4407
|
+
console.warn(`[arbi-sse] unhandled SSE event: ${event}`);
|
|
4408
|
+
}
|
|
4359
4409
|
} catch {
|
|
4360
4410
|
}
|
|
4361
4411
|
}
|