@arbidocs/sdk 0.5.165 → 0.5.166
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-BfISdiFI.d.ts → browser-CCrsY0_5.d.ts} +101 -10
- package/dist/{browser-D8qk7Dud.d.cts → browser-ELa3ogbW.d.cts} +101 -10
- package/dist/browser.cjs +124 -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 +120 -11
- package/dist/browser.js.map +1 -1
- package/dist/index.cjs +124 -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 +120 -11
- package/dist/index.js.map +1 -1
- package/examples/human-review/package.json +1 -1
- package/examples/react-chat/package.json +2 -2
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -3489,6 +3489,75 @@ var init_libsodium_wrappers = __esm({
|
|
|
3489
3489
|
}
|
|
3490
3490
|
});
|
|
3491
3491
|
|
|
3492
|
+
// src/media-transcript.ts
|
|
3493
|
+
var record = (value) => !!value && typeof value === "object";
|
|
3494
|
+
var validTime = (value) => typeof value === "number" && Number.isFinite(value) && value >= 0;
|
|
3495
|
+
function parseTimestampedTranscript(text2) {
|
|
3496
|
+
const segments = [];
|
|
3497
|
+
for (const line of text2.split("\n")) {
|
|
3498
|
+
const match = /^\s*`?(\d+:\d{2}(?::\d{2})?(?:\.\d+)?)`?\s+(?:\*\*([^*]+)\*\*:\s*)?(.*)$/.exec(
|
|
3499
|
+
line
|
|
3500
|
+
);
|
|
3501
|
+
if (match) {
|
|
3502
|
+
const parts = match[1].split(":").map(Number);
|
|
3503
|
+
if (parts.slice(1).some((part) => part >= 60)) continue;
|
|
3504
|
+
const start = parts.reduce((total, part) => total * 60 + part, 0);
|
|
3505
|
+
if (!validTime(start)) continue;
|
|
3506
|
+
segments.push({ start, end: null, speaker: match[2] || null, text: match[3].trim() });
|
|
3507
|
+
} else if (segments.length && line.trim()) {
|
|
3508
|
+
segments[segments.length - 1].text += "\n" + line.trim();
|
|
3509
|
+
}
|
|
3510
|
+
}
|
|
3511
|
+
return segments.filter((segment) => segment.text).sort((a2, b2) => a2.start - b2.start);
|
|
3512
|
+
}
|
|
3513
|
+
function documentTranscript(document) {
|
|
3514
|
+
if (!record(document) || !Array.isArray(document.chunks)) return [];
|
|
3515
|
+
const passages = document.chunks.flatMap((chunk2) => {
|
|
3516
|
+
if (!record(chunk2)) return [];
|
|
3517
|
+
const timing = record(chunk2.metadata) ? chunk2.metadata.transcript : null;
|
|
3518
|
+
if (record(timing) && validTime(timing.start) && typeof chunk2.content === "string" && (timing.end == null || validTime(timing.end) && timing.end >= timing.start)) {
|
|
3519
|
+
const prose = parseTimestampedTranscript(chunk2.content)[0];
|
|
3520
|
+
return [
|
|
3521
|
+
{
|
|
3522
|
+
start: timing.start,
|
|
3523
|
+
end: timing.end ?? null,
|
|
3524
|
+
speaker: prose?.speaker ?? null,
|
|
3525
|
+
text: prose?.text ?? chunk2.content
|
|
3526
|
+
}
|
|
3527
|
+
];
|
|
3528
|
+
}
|
|
3529
|
+
return typeof chunk2.content === "string" ? parseTimestampedTranscript(chunk2.content) : [];
|
|
3530
|
+
}).sort((a2, b2) => a2.start - b2.start);
|
|
3531
|
+
const merged = [];
|
|
3532
|
+
for (const passage of passages) {
|
|
3533
|
+
const previous = merged[merged.length - 1];
|
|
3534
|
+
if (previous && previous.start === passage.start && previous.end === passage.end && (passage.speaker == null || passage.speaker === previous.speaker)) {
|
|
3535
|
+
previous.text += "\n" + passage.text;
|
|
3536
|
+
} else merged.push({ ...passage });
|
|
3537
|
+
}
|
|
3538
|
+
return merged;
|
|
3539
|
+
}
|
|
3540
|
+
function transcriptEnd(segments, index, duration) {
|
|
3541
|
+
return segments[index].end ?? segments[index + 1]?.start ?? (validTime(duration) ? duration : null);
|
|
3542
|
+
}
|
|
3543
|
+
var vttTime = (seconds) => {
|
|
3544
|
+
const ms = Math.round(seconds * 1e3);
|
|
3545
|
+
return `${String(Math.floor(ms / 36e5)).padStart(2, "0")}:${String(Math.floor(ms / 6e4) % 60).padStart(2, "0")}:${String(Math.floor(ms / 1e3) % 60).padStart(2, "0")}.${String(ms % 1e3).padStart(3, "0")}`;
|
|
3546
|
+
};
|
|
3547
|
+
function transcriptToWebVtt(segments, duration) {
|
|
3548
|
+
const escape2 = (text2) => text2.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
|
3549
|
+
return "WEBVTT\n\n" + segments.flatMap((segment, index) => {
|
|
3550
|
+
const end = transcriptEnd(segments, index, duration);
|
|
3551
|
+
if (end == null || end <= segment.start) return [];
|
|
3552
|
+
return [
|
|
3553
|
+
`${index + 1}
|
|
3554
|
+
${vttTime(segment.start)} --> ${vttTime(end)}
|
|
3555
|
+
${escape2(segment.speaker ? `${segment.speaker}: ${segment.text}` : segment.text)}
|
|
3556
|
+
`
|
|
3557
|
+
];
|
|
3558
|
+
}).join("\n");
|
|
3559
|
+
}
|
|
3560
|
+
|
|
3492
3561
|
// src/errors.ts
|
|
3493
3562
|
var ArbiError = class extends Error {
|
|
3494
3563
|
code;
|
|
@@ -5241,16 +5310,41 @@ async function createSupportTicket(arbi, input) {
|
|
|
5241
5310
|
if (input.screenshot && (input.screenshot.type !== "image/png" || input.screenshot.size > 2 * 1024 * 1024))
|
|
5242
5311
|
throw new ArbiError("The screenshot must be a PNG image no larger than 2 MB.");
|
|
5243
5312
|
const screenshot = input.screenshot ? bytesToBase64(new Uint8Array(await input.screenshot.arrayBuffer())) : void 0;
|
|
5244
|
-
|
|
5313
|
+
if (input.video && (!["video/webm", "video/mp4"].includes(input.video.type.split(";")[0]) || !input.video.size || input.video.size > 200 * 1024 * 1024))
|
|
5314
|
+
throw new ArbiError("Choose a WebM or MP4 video no larger than 200 MB.");
|
|
5315
|
+
if ((input.videoTranscript?.length ?? 0) > 1e4)
|
|
5316
|
+
throw new ArbiError("The video transcript is too long.");
|
|
5317
|
+
const receipt = requireData(
|
|
5245
5318
|
await arbi.fetch.POST("/v1/support/tickets", {
|
|
5246
5319
|
body: {
|
|
5247
5320
|
description: input.description.trim(),
|
|
5248
5321
|
idempotency_key: input.idempotencyKey ?? crypto.randomUUID(),
|
|
5249
|
-
...screenshot ? { screenshot_png: screenshot } : {}
|
|
5322
|
+
...screenshot ? { screenshot_png: screenshot } : {},
|
|
5323
|
+
...input.context ? { client_context: input.context } : {}
|
|
5250
5324
|
}
|
|
5251
5325
|
}),
|
|
5252
5326
|
"Could not send your support request."
|
|
5253
5327
|
);
|
|
5328
|
+
if (input.video) {
|
|
5329
|
+
requireData(
|
|
5330
|
+
await arbi.fetch.POST("/v1/support/tickets/{ticket_id}/video", {
|
|
5331
|
+
params: { path: { ticket_id: receipt.ticket_id } },
|
|
5332
|
+
body: { video: input.video, transcript: input.videoTranscript ?? "" },
|
|
5333
|
+
bodySerializer: (body) => {
|
|
5334
|
+
const form = new FormData();
|
|
5335
|
+
form.append(
|
|
5336
|
+
"video",
|
|
5337
|
+
body.video,
|
|
5338
|
+
input.video.type.startsWith("video/mp4") ? "support.mp4" : "support.webm"
|
|
5339
|
+
);
|
|
5340
|
+
form.append("transcript", body.transcript ?? "");
|
|
5341
|
+
return form;
|
|
5342
|
+
}
|
|
5343
|
+
}),
|
|
5344
|
+
"Your request was received, but its video could not be attached. Retry to attach it to the same request."
|
|
5345
|
+
);
|
|
5346
|
+
}
|
|
5347
|
+
return receipt;
|
|
5254
5348
|
}
|
|
5255
5349
|
async function listSupportTickets(arbi) {
|
|
5256
5350
|
return requireData(
|
|
@@ -7461,6 +7555,7 @@ __export(assistant_exports, {
|
|
|
7461
7555
|
WORKSPACE_CONFLICT_MESSAGES: () => WORKSPACE_CONFLICT_MESSAGES,
|
|
7462
7556
|
cancelRun: () => cancelRun,
|
|
7463
7557
|
filterSkills: () => filterSkills,
|
|
7558
|
+
getPlatformActions: () => getPlatformActions,
|
|
7464
7559
|
interject: () => interject,
|
|
7465
7560
|
isSharedSkill: () => isSharedSkill,
|
|
7466
7561
|
listCommands: () => listCommands,
|
|
@@ -7809,15 +7904,24 @@ async function listCommands(arbi) {
|
|
|
7809
7904
|
);
|
|
7810
7905
|
return result.commands;
|
|
7811
7906
|
}
|
|
7812
|
-
async function
|
|
7907
|
+
async function getPlatformActions(arbi, options) {
|
|
7908
|
+
return requireData(
|
|
7909
|
+
await arbi.fetch.GET("/v1/assistant/platform-actions", {
|
|
7910
|
+
params: { query: options }
|
|
7911
|
+
}),
|
|
7912
|
+
"Failed to discover platform actions"
|
|
7913
|
+
);
|
|
7914
|
+
}
|
|
7915
|
+
async function transcribe(arbi, audio, options = {}) {
|
|
7813
7916
|
const result = requireData(
|
|
7814
7917
|
await arbi.fetch.POST("/v1/assistant/transcribe", {
|
|
7815
7918
|
// The generated type of a multipart binary field is `string`; the value is the Blob, sent as
|
|
7816
7919
|
// real form data (openapi-fetch would JSON-encode a plain object).
|
|
7817
|
-
body: { audio },
|
|
7920
|
+
body: { audio, diarize: options.diarize ?? false },
|
|
7818
7921
|
bodySerializer: (body) => {
|
|
7819
7922
|
const form = new FormData();
|
|
7820
7923
|
form.append("audio", body.audio, "voice-input.webm");
|
|
7924
|
+
if (options.diarize) form.append("diarize", "true");
|
|
7821
7925
|
return form;
|
|
7822
7926
|
}
|
|
7823
7927
|
}),
|
|
@@ -14030,8 +14134,10 @@ var Arbi = class {
|
|
|
14030
14134
|
cancel: (responseId) => this.recovering(() => cancelRun(this.getAuthHeaders(), responseId)),
|
|
14031
14135
|
/** The backend's built-in slash commands (`/compact`, `/goal`, …), for a slash menu. */
|
|
14032
14136
|
commands: () => listCommands(this.requireClient()),
|
|
14137
|
+
/** Live domain operations and input schemas shared with tools, slash commands and the CLI. */
|
|
14138
|
+
platformActions: (options) => getPlatformActions(this.requireClient(), options),
|
|
14033
14139
|
/** Transcribe a voice recording to text (empty when no speech was found). */
|
|
14034
|
-
transcribe: (audio) => transcribe(this.requireClient(), audio),
|
|
14140
|
+
transcribe: (audio, options) => transcribe(this.requireClient(), audio, options),
|
|
14035
14141
|
/** Start a durable background turn; task options make its thread a work item. */
|
|
14036
14142
|
submit: (question, options) => {
|
|
14037
14143
|
const workspaceId = options.workspaceId ?? this.requireWorkspace();
|
|
@@ -14779,9 +14885,9 @@ var Arbi = class {
|
|
|
14779
14885
|
*/
|
|
14780
14886
|
get: async (workflowId) => {
|
|
14781
14887
|
const client = this.requireClient();
|
|
14782
|
-
const
|
|
14783
|
-
if (!
|
|
14784
|
-
await this.primeOrFail(
|
|
14888
|
+
const record2 = await getWorkflow(client, workflowId);
|
|
14889
|
+
if (!record2.workspace_ext_id || record2.plan || record2.source_workflow_ext_id) return record2;
|
|
14890
|
+
await this.primeOrFail(record2.workspace_ext_id);
|
|
14785
14891
|
return getWorkflow(client, workflowId);
|
|
14786
14892
|
},
|
|
14787
14893
|
/**
|
|
@@ -14793,8 +14899,8 @@ var Arbi = class {
|
|
|
14793
14899
|
*/
|
|
14794
14900
|
start: async (workflowId, options = {}) => {
|
|
14795
14901
|
const client = this.requireClient();
|
|
14796
|
-
const
|
|
14797
|
-
if (
|
|
14902
|
+
const record2 = await getWorkflow(client, workflowId);
|
|
14903
|
+
if (record2.workspace_ext_id) await this.primeOrFail(record2.workspace_ext_id);
|
|
14798
14904
|
const target = await this.requireTargetWorkspace(options.workspaceId);
|
|
14799
14905
|
return this.recovering(
|
|
14800
14906
|
() => createWork(
|
|
@@ -16335,6 +16441,9 @@ function hydrateAgentSteps(message) {
|
|
|
16335
16441
|
const streamEvents = tools["stream_events"];
|
|
16336
16442
|
if (!streamEvents || !("events" in streamEvents)) return void 0;
|
|
16337
16443
|
const events = streamEvents.events;
|
|
16444
|
+
return hydrateAgentEvents(events);
|
|
16445
|
+
}
|
|
16446
|
+
function hydrateAgentEvents(events) {
|
|
16338
16447
|
if (!Array.isArray(events) || events.length === 0) return void 0;
|
|
16339
16448
|
const hasV3 = events.some(
|
|
16340
16449
|
(e) => typeof e === "object" && e !== null && e.type === "response.output_item.done"
|
|
@@ -16892,6 +17001,7 @@ exports.deviceFlow = device_flow_exports;
|
|
|
16892
17001
|
exports.diagnoseSetup = diagnoseSetup;
|
|
16893
17002
|
exports.doctags = doctags_exports;
|
|
16894
17003
|
exports.documentTools = documentTools;
|
|
17004
|
+
exports.documentTranscript = documentTranscript;
|
|
16895
17005
|
exports.documents = documents_exports;
|
|
16896
17006
|
exports.documentsNode = documents_node_exports;
|
|
16897
17007
|
exports.estimateDraftTokens = estimateDraftTokens;
|
|
@@ -16941,6 +17051,7 @@ exports.getSubagentBranchRecord = getSubagentBranchRecord;
|
|
|
16941
17051
|
exports.getTagDescendantIds = getTagDescendantIds;
|
|
16942
17052
|
exports.health = health_exports;
|
|
16943
17053
|
exports.houseTemplates = house_template_exports;
|
|
17054
|
+
exports.hydrateAgentEvents = hydrateAgentEvents;
|
|
16944
17055
|
exports.hydrateAgentSteps = hydrateAgentSteps;
|
|
16945
17056
|
exports.identityErrorCode = identityErrorCode;
|
|
16946
17057
|
exports.identityVerification = identity_exports;
|
|
@@ -16969,6 +17080,7 @@ exports.parseSSEEvents = parseSSEEvents;
|
|
|
16969
17080
|
exports.parseSlashCommand = parseSlashCommand;
|
|
16970
17081
|
exports.parseSlashTokenInProgress = parseSlashTokenInProgress;
|
|
16971
17082
|
exports.parseStructuredResponse = parseStructuredResponse;
|
|
17083
|
+
exports.parseTimestampedTranscript = parseTimestampedTranscript;
|
|
16972
17084
|
exports.performPasswordLogin = performPasswordLogin;
|
|
16973
17085
|
exports.performSigningKeyLogin = performSigningKeyLogin;
|
|
16974
17086
|
exports.performSsoDeviceFlowLogin = performSsoDeviceFlowLogin;
|
|
@@ -17007,6 +17119,8 @@ exports.tags = tags_exports;
|
|
|
17007
17119
|
exports.tagsForScope = tagsForScope;
|
|
17008
17120
|
exports.tagsOfGroup = tagsOfGroup;
|
|
17009
17121
|
exports.topLevelAgentSteps = topLevelAgentSteps;
|
|
17122
|
+
exports.transcriptEnd = transcriptEnd;
|
|
17123
|
+
exports.transcriptToWebVtt = transcriptToWebVtt;
|
|
17010
17124
|
exports.uploadSkill = uploadSkill;
|
|
17011
17125
|
exports.usdToGbp = usdToGbp;
|
|
17012
17126
|
exports.views = views_exports;
|