@arbidocs/sdk 0.4.76 → 0.4.78
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-DbhZr6hC.d.cts → browser-CK4WQdVH.d.cts} +6291 -5631
- package/dist/{browser-DbhZr6hC.d.ts → browser-CK4WQdVH.d.ts} +6291 -5631
- package/dist/browser.cjs +549 -30
- 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 +549 -30
- package/dist/browser.js.map +1 -1
- package/dist/index.cjs +549 -30
- 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 +549 -30
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -3494,9 +3494,16 @@ var ArbiSessionExpiredError = class extends ArbiError {
|
|
|
3494
3494
|
}
|
|
3495
3495
|
};
|
|
3496
3496
|
function detailText(detail) {
|
|
3497
|
-
if (
|
|
3498
|
-
|
|
3499
|
-
|
|
3497
|
+
if (typeof detail === "string") return detail || void 0;
|
|
3498
|
+
if (Array.isArray(detail)) {
|
|
3499
|
+
const messages = detail.map((d2) => d2?.msg).filter((m2) => Boolean(m2));
|
|
3500
|
+
return messages.length ? messages.join("; ") : void 0;
|
|
3501
|
+
}
|
|
3502
|
+
if (!detail || typeof detail !== "object") return void 0;
|
|
3503
|
+
const message = typeof detail.message === "string" ? detail.message : void 0;
|
|
3504
|
+
const fields = detail.fields && typeof detail.fields === "object" && !Array.isArray(detail.fields) ? Object.entries(detail.fields).map(([name, problem]) => `${name}: ${String(problem)}`).join("; ") : "";
|
|
3505
|
+
if (message) return fields ? `${message} (${fields})` : message;
|
|
3506
|
+
return fields || void 0;
|
|
3500
3507
|
}
|
|
3501
3508
|
function apiErrorDetail(apiError) {
|
|
3502
3509
|
if (typeof apiError === "string") return apiError || void 0;
|
|
@@ -4461,6 +4468,12 @@ async function streamSSE(response, callbacks = {}) {
|
|
|
4461
4468
|
const { events, remaining } = parseSSEEvents(decoder.decode(value, { stream: true }), sseBuffer);
|
|
4462
4469
|
sseBuffer = remaining;
|
|
4463
4470
|
processEvents(events);
|
|
4471
|
+
if (completed) {
|
|
4472
|
+
sseBuffer = "";
|
|
4473
|
+
void reader.cancel().catch(() => {
|
|
4474
|
+
});
|
|
4475
|
+
break;
|
|
4476
|
+
}
|
|
4464
4477
|
}
|
|
4465
4478
|
if (sseBuffer.trim()) {
|
|
4466
4479
|
const { events } = parseSSEEvents(sseBuffer + "\n\n", "");
|
|
@@ -5692,11 +5705,25 @@ function extractResponseText(response) {
|
|
|
5692
5705
|
// src/operations/tags.ts
|
|
5693
5706
|
var tags_exports = {};
|
|
5694
5707
|
__export(tags_exports, {
|
|
5708
|
+
TAG_FIELD_TYPES: () => TAG_FIELD_TYPES,
|
|
5695
5709
|
createTag: () => createTag,
|
|
5696
5710
|
deleteTag: () => deleteTag,
|
|
5711
|
+
getTagMatrix: () => getTagMatrix,
|
|
5697
5712
|
listTags: () => listTags,
|
|
5698
|
-
|
|
5713
|
+
mergeTagFieldDefinitions: () => mergeTagFieldDefinitions,
|
|
5714
|
+
ownTagFields: () => ownTagFields,
|
|
5715
|
+
tagMatrixColumns: () => tagMatrixColumns,
|
|
5716
|
+
updateTag: () => updateTag,
|
|
5717
|
+
updateTagFields: () => updateTagFields
|
|
5699
5718
|
});
|
|
5719
|
+
var TAG_FIELD_TYPES = [
|
|
5720
|
+
"text",
|
|
5721
|
+
"number",
|
|
5722
|
+
"date",
|
|
5723
|
+
"checkbox",
|
|
5724
|
+
"select",
|
|
5725
|
+
"person"
|
|
5726
|
+
];
|
|
5700
5727
|
async function listTags(arbi) {
|
|
5701
5728
|
return requireData(await arbi.fetch.GET("/v1/tag/list"), "Failed to fetch tags");
|
|
5702
5729
|
}
|
|
@@ -5707,7 +5734,10 @@ async function createTag(arbi, options) {
|
|
|
5707
5734
|
name: options.name,
|
|
5708
5735
|
tag_type: options.tagType ?? { type: "checkbox", options: [] },
|
|
5709
5736
|
instruction: options.instruction ?? null,
|
|
5710
|
-
shared: options.shared ?? false
|
|
5737
|
+
shared: options.shared ?? false,
|
|
5738
|
+
...options.parentId ? { parent_ext_id: options.parentId } : {},
|
|
5739
|
+
...options.fields ? { fields: options.fields } : {},
|
|
5740
|
+
...options.fieldValues ? { field_values: options.fieldValues } : {}
|
|
5711
5741
|
}
|
|
5712
5742
|
}),
|
|
5713
5743
|
"Failed to create tag"
|
|
@@ -5730,6 +5760,46 @@ async function updateTag(arbi, tagId, body) {
|
|
|
5730
5760
|
"Failed to update tag"
|
|
5731
5761
|
);
|
|
5732
5762
|
}
|
|
5763
|
+
async function updateTagFields(arbi, tagId, change) {
|
|
5764
|
+
const body = {};
|
|
5765
|
+
if (change.fields) body.fields = change.fields;
|
|
5766
|
+
if (change.values) body.field_values = change.values;
|
|
5767
|
+
return updateTag(arbi, tagId, body);
|
|
5768
|
+
}
|
|
5769
|
+
async function getTagMatrix(arbi, selection, linksLimit) {
|
|
5770
|
+
const query = "parentId" in selection ? { parent_ext_id: selection.parentId } : { tag_ext_id: selection.tagIds };
|
|
5771
|
+
if (linksLimit !== void 0) query.links_limit = linksLimit;
|
|
5772
|
+
return requireData(
|
|
5773
|
+
await arbi.fetch.GET("/v1/tag/matrix", { params: { query } }),
|
|
5774
|
+
"Failed to fetch the tag matrix"
|
|
5775
|
+
);
|
|
5776
|
+
}
|
|
5777
|
+
function tagMatrixColumns(matrix) {
|
|
5778
|
+
const columns = [];
|
|
5779
|
+
const add = (f2) => {
|
|
5780
|
+
if (!columns.some((c2) => c2.id === f2.id)) columns.push(f2);
|
|
5781
|
+
};
|
|
5782
|
+
for (const f2 of matrix.parent?.fields ?? []) add(f2);
|
|
5783
|
+
for (const row of matrix.rows ?? []) for (const f2 of row.tag.fields ?? []) add(f2);
|
|
5784
|
+
return columns;
|
|
5785
|
+
}
|
|
5786
|
+
function ownTagFields(tag) {
|
|
5787
|
+
return (tag.fields ?? []).filter((f2) => f2.tag_ext_id === tag.external_id);
|
|
5788
|
+
}
|
|
5789
|
+
function mergeTagFieldDefinitions(tag, wanted, { keepOthers = false } = {}) {
|
|
5790
|
+
const own = ownTagFields(tag);
|
|
5791
|
+
const byName = new Map(own.map((f2) => [f2.name.toLowerCase(), f2]));
|
|
5792
|
+
const out = wanted.map((w2) => {
|
|
5793
|
+
const old = w2.id ? void 0 : byName.get(w2.name.trim().toLowerCase());
|
|
5794
|
+
return old ? { ...w2, id: old.id } : w2;
|
|
5795
|
+
});
|
|
5796
|
+
if (keepOthers) {
|
|
5797
|
+
for (const f2 of own)
|
|
5798
|
+
if (!out.some((w2) => w2.id === f2.id))
|
|
5799
|
+
out.push({ id: f2.id, name: f2.name, type: f2.type, options: f2.options ?? null });
|
|
5800
|
+
}
|
|
5801
|
+
return out;
|
|
5802
|
+
}
|
|
5733
5803
|
|
|
5734
5804
|
// src/operations/contacts.ts
|
|
5735
5805
|
var contacts_exports = {};
|
|
@@ -6545,25 +6615,88 @@ var projects_exports = {};
|
|
|
6545
6615
|
__export(projects_exports, {
|
|
6546
6616
|
createProject: () => createProject,
|
|
6547
6617
|
deleteProject: () => deleteProject,
|
|
6618
|
+
formatBudget: () => formatBudget,
|
|
6619
|
+
getProjectConversationUsage: () => getProjectConversationUsage,
|
|
6548
6620
|
getProjectInvoices: () => getProjectInvoices,
|
|
6549
6621
|
getProjectUsage: () => getProjectUsage,
|
|
6550
6622
|
getUserUsageToday: () => getUserUsageToday,
|
|
6623
|
+
listProjectEvents: () => listProjectEvents,
|
|
6551
6624
|
listProjects: () => listProjects,
|
|
6625
|
+
parseBudget: () => parseBudget,
|
|
6552
6626
|
refreshProject: () => refreshProject,
|
|
6553
6627
|
renameProject: () => renameProject,
|
|
6554
6628
|
updateProject: () => updateProject
|
|
6555
6629
|
});
|
|
6556
|
-
async function listProjects(arbi) {
|
|
6557
|
-
|
|
6630
|
+
async function listProjects(arbi, filters = {}) {
|
|
6631
|
+
const query = {};
|
|
6632
|
+
if (filters.stage) query.stage = filters.stage;
|
|
6633
|
+
if (filters.leadUser) query.lead_user = filters.leadUser;
|
|
6634
|
+
return requireData(
|
|
6635
|
+
await arbi.fetch.GET(
|
|
6636
|
+
"/v1/user/projects/",
|
|
6637
|
+
Object.keys(query).length ? { params: { query } } : void 0
|
|
6638
|
+
),
|
|
6639
|
+
"Failed to fetch projects"
|
|
6640
|
+
);
|
|
6558
6641
|
}
|
|
6559
|
-
async function createProject(arbi, name, plan = "free") {
|
|
6642
|
+
async function createProject(arbi, name, plan = "free", details = {}) {
|
|
6560
6643
|
return requireData(
|
|
6561
6644
|
await arbi.fetch.POST("/v1/user/projects/", {
|
|
6562
|
-
body: { name, plan }
|
|
6645
|
+
body: { ...details, name, plan }
|
|
6563
6646
|
}),
|
|
6564
6647
|
"Failed to create project"
|
|
6565
6648
|
);
|
|
6566
6649
|
}
|
|
6650
|
+
async function listProjectEvents(arbi, projectExtId, options = {}) {
|
|
6651
|
+
const query = {};
|
|
6652
|
+
if (options.kind) query.kind = options.kind;
|
|
6653
|
+
if (options.limit !== void 0) query.limit = options.limit;
|
|
6654
|
+
return requireData(
|
|
6655
|
+
await arbi.fetch.GET("/v1/user/projects/{project_ext_id}/events", {
|
|
6656
|
+
params: { path: { project_ext_id: projectExtId }, query }
|
|
6657
|
+
}),
|
|
6658
|
+
"Failed to fetch project events"
|
|
6659
|
+
);
|
|
6660
|
+
}
|
|
6661
|
+
async function getProjectConversationUsage(arbi, projectExtId, monthsBack) {
|
|
6662
|
+
return requireData(
|
|
6663
|
+
await arbi.fetch.GET("/v1/user/projects/{project_ext_id}/usage/conversations", {
|
|
6664
|
+
params: {
|
|
6665
|
+
path: { project_ext_id: projectExtId },
|
|
6666
|
+
query: monthsBack === void 0 ? void 0 : { months_back: monthsBack }
|
|
6667
|
+
}
|
|
6668
|
+
}),
|
|
6669
|
+
"Failed to fetch project usage by conversation"
|
|
6670
|
+
);
|
|
6671
|
+
}
|
|
6672
|
+
function minorDigits(currency) {
|
|
6673
|
+
try {
|
|
6674
|
+
return new Intl.NumberFormat("en", { style: "currency", currency }).resolvedOptions().maximumFractionDigits ?? 2;
|
|
6675
|
+
} catch {
|
|
6676
|
+
throw new Error(`Unknown currency "${currency}": use an ISO 4217 code such as GBP or USD`);
|
|
6677
|
+
}
|
|
6678
|
+
}
|
|
6679
|
+
function parseBudget(text) {
|
|
6680
|
+
const t2 = text.trim();
|
|
6681
|
+
const after = /^([0-9][0-9,_]*(?:\.[0-9]+)?)\s*([A-Za-z]{3})$/.exec(t2);
|
|
6682
|
+
const before = /^([A-Za-z]{3})\s*([0-9][0-9,_]*(?:\.[0-9]+)?)$/.exec(t2);
|
|
6683
|
+
const [amountText, code] = after ? [after[1], after[2]] : before ? [before[2], before[1]] : [];
|
|
6684
|
+
if (!amountText || !code)
|
|
6685
|
+
throw new Error(`Invalid budget "${text}": use an amount and a currency, e.g. 6000GBP`);
|
|
6686
|
+
const currency = code.toUpperCase();
|
|
6687
|
+
const digits = minorDigits(currency);
|
|
6688
|
+
const major = Number(amountText.replace(/[,_]/g, ""));
|
|
6689
|
+
const amount = Math.round(major * 10 ** digits);
|
|
6690
|
+
if (!Number.isFinite(major) || Math.abs(major * 10 ** digits - amount) > 1e-6)
|
|
6691
|
+
throw new Error(`Invalid budget "${text}": ${currency} has ${digits} decimal places`);
|
|
6692
|
+
return { amount, currency };
|
|
6693
|
+
}
|
|
6694
|
+
function formatBudget(budget) {
|
|
6695
|
+
if (!budget) return "";
|
|
6696
|
+
const digits = minorDigits(budget.currency);
|
|
6697
|
+
const major = budget.amount / 10 ** digits;
|
|
6698
|
+
return `${budget.currency} ${major.toLocaleString("en", { minimumFractionDigits: digits, maximumFractionDigits: digits })}`;
|
|
6699
|
+
}
|
|
6567
6700
|
async function updateProject(arbi, projectExtId, body) {
|
|
6568
6701
|
return requireData(
|
|
6569
6702
|
await arbi.fetch.PATCH("/v1/user/projects/{project_ext_id}", {
|
|
@@ -6619,15 +6752,19 @@ async function getUserUsageToday(arbi) {
|
|
|
6619
6752
|
var work_exports = {};
|
|
6620
6753
|
__export(work_exports, {
|
|
6621
6754
|
actOnStep: () => actOnStep,
|
|
6755
|
+
completeStep: () => completeStep,
|
|
6622
6756
|
createWork: () => createWork,
|
|
6623
6757
|
getActivity: () => getActivity,
|
|
6624
6758
|
getConversation: () => getConversation,
|
|
6759
|
+
getConversationUsage: () => getConversationUsage,
|
|
6625
6760
|
getPendingAuth: () => getPendingAuth,
|
|
6626
6761
|
getRunProgress: () => getRunProgress,
|
|
6627
6762
|
getStepAnswers: () => getStepAnswers,
|
|
6628
6763
|
notifyConversation: () => notifyConversation,
|
|
6629
6764
|
planWork: () => planWork,
|
|
6630
6765
|
runConversation: () => runConversation,
|
|
6766
|
+
sendBackStep: () => sendBackStep,
|
|
6767
|
+
skipStep: () => skipStep,
|
|
6631
6768
|
updateConversation: () => updateConversation
|
|
6632
6769
|
});
|
|
6633
6770
|
|
|
@@ -6636,14 +6773,23 @@ var workflow_steps_exports = {};
|
|
|
6636
6773
|
__export(workflow_steps_exports, {
|
|
6637
6774
|
PERSON_STEP_KINDS: () => PERSON_STEP_KINDS,
|
|
6638
6775
|
PlanStepsError: () => PlanStepsError,
|
|
6776
|
+
SIGNAL_NAME_PATTERN: () => SIGNAL_NAME_PATTERN,
|
|
6777
|
+
STEP_FIELD_TYPES: () => STEP_FIELD_TYPES,
|
|
6639
6778
|
STEP_ID_PATTERN: () => STEP_ID_PATTERN,
|
|
6640
6779
|
STEP_KINDS: () => STEP_KINDS,
|
|
6780
|
+
checkStepInputs: () => checkStepInputs,
|
|
6781
|
+
describeAssignee: () => describeAssignee,
|
|
6782
|
+
describeInputProblems: () => describeInputProblems,
|
|
6641
6783
|
isPersonStep: () => isPersonStep,
|
|
6784
|
+
linkedRuns: () => linkedRuns,
|
|
6785
|
+
messageWorkflowStep: () => messageWorkflowStep,
|
|
6642
6786
|
missingRequiredFields: () => missingRequiredFields,
|
|
6643
6787
|
parseInputPairs: () => parseInputPairs,
|
|
6644
6788
|
parsePlanSteps: () => parsePlanSteps,
|
|
6789
|
+
raisedSignals: () => raisedSignals,
|
|
6645
6790
|
runSteps: () => runSteps,
|
|
6646
6791
|
runWaitingOn: () => runWaitingOn,
|
|
6792
|
+
sendBacks: () => sendBacks,
|
|
6647
6793
|
stepDependencies: () => stepDependencies,
|
|
6648
6794
|
stepFields: () => stepFields,
|
|
6649
6795
|
stepPhase: () => stepPhase,
|
|
@@ -6659,6 +6805,15 @@ var STEP_EVENTS = {
|
|
|
6659
6805
|
step_skipped: "skipped",
|
|
6660
6806
|
step_failed: "failed"
|
|
6661
6807
|
};
|
|
6808
|
+
var EMPTY_STATE = {
|
|
6809
|
+
status: "pending",
|
|
6810
|
+
responseId: null,
|
|
6811
|
+
error: null,
|
|
6812
|
+
sentBack: false,
|
|
6813
|
+
hasNote: false,
|
|
6814
|
+
announcedTo: null
|
|
6815
|
+
};
|
|
6816
|
+
var str = (v2) => typeof v2 === "string" ? v2 : null;
|
|
6662
6817
|
var isFinished = (state) => state?.status === "done" || state?.status === "skipped";
|
|
6663
6818
|
var isPersonStep = (step) => PERSON_STEP_KINDS.includes(step.kind);
|
|
6664
6819
|
function stepDependencies(steps, id) {
|
|
@@ -6680,18 +6835,80 @@ function dependsOn(steps, a2, b2) {
|
|
|
6680
6835
|
}
|
|
6681
6836
|
return false;
|
|
6682
6837
|
}
|
|
6838
|
+
function reopenedBy(detail) {
|
|
6839
|
+
const to = str(detail.to);
|
|
6840
|
+
const listed = Array.isArray(detail.reopened) ? detail.reopened : to ? [to] : [];
|
|
6841
|
+
return listed.filter((id) => typeof id === "string");
|
|
6842
|
+
}
|
|
6683
6843
|
function stepStatesFromActivity(events) {
|
|
6684
6844
|
const states = {};
|
|
6685
6845
|
for (const e of events) {
|
|
6846
|
+
const detail = e.detail ?? {};
|
|
6847
|
+
const step = str(detail.step);
|
|
6848
|
+
if (!step) continue;
|
|
6849
|
+
if (e.kind === "step_sent_back") {
|
|
6850
|
+
const to = str(detail.to);
|
|
6851
|
+
for (const id of reopenedBy(detail))
|
|
6852
|
+
states[id] = {
|
|
6853
|
+
...EMPTY_STATE,
|
|
6854
|
+
sentBack: id === to,
|
|
6855
|
+
hasNote: id === to && typeof detail.note_encrypted === "string"
|
|
6856
|
+
};
|
|
6857
|
+
continue;
|
|
6858
|
+
}
|
|
6859
|
+
if (e.kind === "step_ready") {
|
|
6860
|
+
states[step] = { ...states[step] ?? EMPTY_STATE, announcedTo: str(detail.to) };
|
|
6861
|
+
continue;
|
|
6862
|
+
}
|
|
6686
6863
|
const status = STEP_EVENTS[e.kind];
|
|
6687
|
-
|
|
6688
|
-
|
|
6689
|
-
|
|
6690
|
-
|
|
6691
|
-
|
|
6864
|
+
if (!status) continue;
|
|
6865
|
+
states[step] = {
|
|
6866
|
+
...EMPTY_STATE,
|
|
6867
|
+
status,
|
|
6868
|
+
responseId: str(detail.response_id) ?? states[step]?.responseId ?? null,
|
|
6869
|
+
error: str(detail.error)
|
|
6870
|
+
};
|
|
6692
6871
|
}
|
|
6693
6872
|
return states;
|
|
6694
6873
|
}
|
|
6874
|
+
function raisedSignals(events) {
|
|
6875
|
+
return events.flatMap((e) => {
|
|
6876
|
+
const step = str(e.detail?.step);
|
|
6877
|
+
const signal = str(e.detail?.signal);
|
|
6878
|
+
return e.kind === "step_signal" && step && signal ? [{ step, signal, at: e.created_at ?? null }] : [];
|
|
6879
|
+
});
|
|
6880
|
+
}
|
|
6881
|
+
function linkedRuns(events) {
|
|
6882
|
+
return events.flatMap((e) => {
|
|
6883
|
+
const conversationId = str(e.detail?.conversation_ext_id);
|
|
6884
|
+
return e.kind === "linked_run" && conversationId ? [
|
|
6885
|
+
{
|
|
6886
|
+
step: str(e.detail?.step),
|
|
6887
|
+
signal: str(e.detail?.signal),
|
|
6888
|
+
conversationId,
|
|
6889
|
+
workflowId: str(e.detail?.workflow_ext_id),
|
|
6890
|
+
at: e.created_at ?? null
|
|
6891
|
+
}
|
|
6892
|
+
] : [];
|
|
6893
|
+
});
|
|
6894
|
+
}
|
|
6895
|
+
function sendBacks(events) {
|
|
6896
|
+
return events.flatMap((e) => {
|
|
6897
|
+
const detail = e.detail ?? {};
|
|
6898
|
+
const step = str(detail.step);
|
|
6899
|
+
const to = str(detail.to);
|
|
6900
|
+
return e.kind === "step_sent_back" && step && to ? [
|
|
6901
|
+
{
|
|
6902
|
+
step,
|
|
6903
|
+
to,
|
|
6904
|
+
reopened: reopenedBy(detail),
|
|
6905
|
+
hasNote: typeof detail.note_encrypted === "string",
|
|
6906
|
+
by: e.actor_ext_id ?? null,
|
|
6907
|
+
at: e.created_at ?? null
|
|
6908
|
+
}
|
|
6909
|
+
] : [];
|
|
6910
|
+
});
|
|
6911
|
+
}
|
|
6695
6912
|
function stepPhase(steps, states, id) {
|
|
6696
6913
|
const state = states[id];
|
|
6697
6914
|
if (state && state.status !== "pending") return state.status;
|
|
@@ -6699,15 +6916,40 @@ function stepPhase(steps, states, id) {
|
|
|
6699
6916
|
}
|
|
6700
6917
|
function runSteps(steps, events) {
|
|
6701
6918
|
const states = stepStatesFromActivity(events);
|
|
6702
|
-
|
|
6703
|
-
|
|
6704
|
-
|
|
6705
|
-
|
|
6706
|
-
|
|
6707
|
-
|
|
6708
|
-
|
|
6709
|
-
|
|
6710
|
-
|
|
6919
|
+
const signals = raisedSignals(events);
|
|
6920
|
+
const links = linkedRuns(events);
|
|
6921
|
+
const backs = sendBacks(events);
|
|
6922
|
+
return steps.map((s2) => {
|
|
6923
|
+
const state = states[s2.id] ?? EMPTY_STATE;
|
|
6924
|
+
return {
|
|
6925
|
+
id: s2.id,
|
|
6926
|
+
title: s2.title,
|
|
6927
|
+
kind: s2.kind,
|
|
6928
|
+
phase: stepPhase(steps, states, s2.id),
|
|
6929
|
+
after: stepDependencies(steps, s2.id),
|
|
6930
|
+
responseId: state.responseId,
|
|
6931
|
+
error: state.error,
|
|
6932
|
+
assignee: s2.assignee ?? null,
|
|
6933
|
+
announcedTo: state.announcedTo,
|
|
6934
|
+
sentBack: state.sentBack,
|
|
6935
|
+
hasNote: state.hasNote,
|
|
6936
|
+
timesSentBack: backs.filter((b2) => b2.to === s2.id).length,
|
|
6937
|
+
signals: [...new Set(signals.filter((x2) => x2.step === s2.id).map((x2) => x2.signal))],
|
|
6938
|
+
linkedRuns: links.filter((l2) => l2.step === s2.id)
|
|
6939
|
+
};
|
|
6940
|
+
});
|
|
6941
|
+
}
|
|
6942
|
+
function describeAssignee(assignee) {
|
|
6943
|
+
if (!assignee) return "";
|
|
6944
|
+
if (assignee.user) return assignee.user;
|
|
6945
|
+
if (assignee.run_owner) return "run owner";
|
|
6946
|
+
if (assignee.project_lead) return "project lead";
|
|
6947
|
+
if (assignee.input) return `input:${assignee.input}`;
|
|
6948
|
+
return "";
|
|
6949
|
+
}
|
|
6950
|
+
function messageWorkflowStep(message) {
|
|
6951
|
+
const tool = message.tools?.workflow_step;
|
|
6952
|
+
return str(tool?.workflow_step);
|
|
6711
6953
|
}
|
|
6712
6954
|
function runWaitingOn(run) {
|
|
6713
6955
|
if (run.length > 0 && run.every((s2) => s2.phase === "done" || s2.phase === "skipped"))
|
|
@@ -6717,15 +6959,97 @@ function runWaitingOn(run) {
|
|
|
6717
6959
|
if (run.some((s2) => s2.kind !== "agent" && s2.phase === "ready")) return "person";
|
|
6718
6960
|
return "stuck";
|
|
6719
6961
|
}
|
|
6962
|
+
var STEP_FIELD_TYPES = [
|
|
6963
|
+
"text",
|
|
6964
|
+
"longtext",
|
|
6965
|
+
"boolean",
|
|
6966
|
+
"select",
|
|
6967
|
+
"number",
|
|
6968
|
+
"date",
|
|
6969
|
+
"scope",
|
|
6970
|
+
"documents",
|
|
6971
|
+
"person"
|
|
6972
|
+
];
|
|
6720
6973
|
function stepFields(step) {
|
|
6974
|
+
if (step.kind === "agent") return [];
|
|
6975
|
+
if (Array.isArray(step.fields)) return step.fields;
|
|
6721
6976
|
if (step.kind !== "form") return [];
|
|
6722
6977
|
const fields = step.ui?.fields;
|
|
6723
6978
|
return Array.isArray(fields) ? fields : [];
|
|
6724
6979
|
}
|
|
6725
|
-
var blank = (value) =>
|
|
6980
|
+
var blank = (value) => {
|
|
6981
|
+
if (value === void 0 || value === null) return true;
|
|
6982
|
+
if (typeof value === "string") return value.trim() === "";
|
|
6983
|
+
if (Array.isArray(value)) return value.length === 0;
|
|
6984
|
+
if (isRecord(value)) return !["documents", "folders", "labels"].some((k2) => !blank(value[k2]));
|
|
6985
|
+
return false;
|
|
6986
|
+
};
|
|
6726
6987
|
function missingRequiredFields(step, inputs) {
|
|
6727
6988
|
return stepFields(step).filter((f2) => f2.required && blank(inputs[f2.name])).map((f2) => f2.name);
|
|
6728
6989
|
}
|
|
6990
|
+
var PERSON_ID = /^(?:usr|agt)-[a-zA-Z0-9]{8}$/;
|
|
6991
|
+
function fieldProblem(field, value) {
|
|
6992
|
+
if (blank(value)) return field.required ? "required" : null;
|
|
6993
|
+
switch (field.type ?? "text") {
|
|
6994
|
+
case "number": {
|
|
6995
|
+
const n2 = typeof value === "number" ? value : typeof value === "string" ? Number(value) : NaN;
|
|
6996
|
+
if (Number.isNaN(n2)) return "number";
|
|
6997
|
+
if (field.min !== null && field.min !== void 0 && n2 < field.min) return "min";
|
|
6998
|
+
if (field.max !== null && field.max !== void 0 && n2 > field.max) return "max";
|
|
6999
|
+
return null;
|
|
7000
|
+
}
|
|
7001
|
+
case "boolean":
|
|
7002
|
+
return typeof value === "boolean" ? null : "type";
|
|
7003
|
+
case "select": {
|
|
7004
|
+
if (typeof value !== "string") return "type";
|
|
7005
|
+
const options = (field.options ?? []).map((o2) => o2.value);
|
|
7006
|
+
return options.length === 0 || options.includes(value) ? null : "option";
|
|
7007
|
+
}
|
|
7008
|
+
case "date":
|
|
7009
|
+
return typeof value === "string" && !Number.isNaN(Date.parse(value)) ? null : "type";
|
|
7010
|
+
case "scope":
|
|
7011
|
+
case "documents":
|
|
7012
|
+
return typeof value === "object" ? null : "type";
|
|
7013
|
+
case "person":
|
|
7014
|
+
return typeof value === "string" && PERSON_ID.test(value) ? null : "type";
|
|
7015
|
+
default:
|
|
7016
|
+
return typeof value === "string" || typeof value === "number" ? null : "type";
|
|
7017
|
+
}
|
|
7018
|
+
}
|
|
7019
|
+
function checkStepInputs(step, inputs) {
|
|
7020
|
+
if (!Array.isArray(step.fields)) return {};
|
|
7021
|
+
const given = inputs ?? {};
|
|
7022
|
+
const byName = new Map(step.fields.map((f2) => [f2.name, f2]));
|
|
7023
|
+
const problems = {};
|
|
7024
|
+
for (const name of Object.keys(given)) if (!byName.has(name)) problems[name] = "unknown";
|
|
7025
|
+
for (const [name, field] of byName) {
|
|
7026
|
+
const problem = fieldProblem(field, given[name]);
|
|
7027
|
+
if (problem) problems[name] = problem;
|
|
7028
|
+
}
|
|
7029
|
+
return problems;
|
|
7030
|
+
}
|
|
7031
|
+
function describeInputProblems(step, problems) {
|
|
7032
|
+
const fields = new Map((step.fields ?? []).map((f2) => [f2.name, f2]));
|
|
7033
|
+
return Object.entries(problems).map(([name, problem]) => {
|
|
7034
|
+
const f2 = fields.get(name);
|
|
7035
|
+
switch (problem) {
|
|
7036
|
+
case "unknown":
|
|
7037
|
+
return `${name}: this step does not ask for it (it asks for ${[...fields.keys()].join(", ") || "nothing"})`;
|
|
7038
|
+
case "option":
|
|
7039
|
+
return `${name}: must be one of ${(f2?.options ?? []).map((o2) => o2.value).join(", ")}`;
|
|
7040
|
+
case "min":
|
|
7041
|
+
return `${name}: must be at least ${f2?.min}`;
|
|
7042
|
+
case "max":
|
|
7043
|
+
return `${name}: must be at most ${f2?.max}`;
|
|
7044
|
+
case "number":
|
|
7045
|
+
return `${name}: must be a number`;
|
|
7046
|
+
case "type":
|
|
7047
|
+
return `${name}: must be a ${f2?.type === "person" ? "person id (usr-\u2026 or agt-\u2026)" : f2?.type ?? "value"}`;
|
|
7048
|
+
default:
|
|
7049
|
+
return `${name}: ${problem}`;
|
|
7050
|
+
}
|
|
7051
|
+
}).join("; ");
|
|
7052
|
+
}
|
|
6729
7053
|
function parseInputPairs(pairs, fields = []) {
|
|
6730
7054
|
const types = new Map(fields.map((f2) => [f2.name, f2.type]));
|
|
6731
7055
|
const out = {};
|
|
@@ -6758,8 +7082,16 @@ var STEP_KEYS = /* @__PURE__ */ new Set([
|
|
|
6758
7082
|
"inputs",
|
|
6759
7083
|
"branch",
|
|
6760
7084
|
"requires_files",
|
|
6761
|
-
"ui"
|
|
7085
|
+
"ui",
|
|
7086
|
+
"signals",
|
|
7087
|
+
"assignee",
|
|
7088
|
+
"remind_after_hours",
|
|
7089
|
+
"fields"
|
|
6762
7090
|
]);
|
|
7091
|
+
var SIGNAL_NAME_PATTERN = /^[a-z0-9][a-z0-9_.-]{0,63}$/;
|
|
7092
|
+
var FIELD_NAME_PATTERN = /^[a-zA-Z][a-zA-Z0-9_]{0,63}$/;
|
|
7093
|
+
var WHEN_KEYS = ["field", "equals", "contains", "matches", "approved"];
|
|
7094
|
+
var ASSIGNEE_KEYS = ["user", "run_owner", "input", "project_lead"];
|
|
6763
7095
|
var isRecord = (v2) => typeof v2 === "object" && v2 !== null && !Array.isArray(v2);
|
|
6764
7096
|
var PlanStepsError = class extends Error {
|
|
6765
7097
|
constructor(problems) {
|
|
@@ -6770,6 +7102,123 @@ ${problems.map((p2) => ` - ${p2}`).join("\n")}`);
|
|
|
6770
7102
|
}
|
|
6771
7103
|
problems;
|
|
6772
7104
|
};
|
|
7105
|
+
var isSet = (v2) => v2 !== void 0 && v2 !== null;
|
|
7106
|
+
function checkSignals(value, at2, problems) {
|
|
7107
|
+
if (!Array.isArray(value)) {
|
|
7108
|
+
problems.push(
|
|
7109
|
+
`${at2}: must be a list of signals, e.g. [{name: risk-high, when: {contains: High}}]`
|
|
7110
|
+
);
|
|
7111
|
+
return;
|
|
7112
|
+
}
|
|
7113
|
+
if (value.length > 10) problems.push(`${at2}: at most 10 signals per step`);
|
|
7114
|
+
value.forEach((signal, j2) => {
|
|
7115
|
+
const here = `${at2}[${j2}]`;
|
|
7116
|
+
if (!isRecord(signal)) {
|
|
7117
|
+
problems.push(`${here}: must be an object with a name`);
|
|
7118
|
+
return;
|
|
7119
|
+
}
|
|
7120
|
+
for (const key of Object.keys(signal))
|
|
7121
|
+
if (key !== "name" && key !== "when")
|
|
7122
|
+
problems.push(`${here}.${key}: unknown field (allowed: name, when)`);
|
|
7123
|
+
if (typeof signal.name !== "string" || !SIGNAL_NAME_PATTERN.test(signal.name))
|
|
7124
|
+
problems.push(
|
|
7125
|
+
`${here}.name: lowercase letters, digits, ".", "_" or "-", starting with a letter or digit (got ${JSON.stringify(signal.name)})`
|
|
7126
|
+
);
|
|
7127
|
+
const when = signal.when;
|
|
7128
|
+
if (!isSet(when)) return;
|
|
7129
|
+
if (!isRecord(when)) {
|
|
7130
|
+
problems.push(`${here}.when: must be an object`);
|
|
7131
|
+
return;
|
|
7132
|
+
}
|
|
7133
|
+
for (const key of Object.keys(when))
|
|
7134
|
+
if (!WHEN_KEYS.includes(key))
|
|
7135
|
+
problems.push(`${here}.when.${key}: unknown field (allowed: ${WHEN_KEYS.join(", ")})`);
|
|
7136
|
+
const shapes = [
|
|
7137
|
+
isSet(when.field) || isSet(when.equals),
|
|
7138
|
+
isSet(when.contains),
|
|
7139
|
+
isSet(when.matches),
|
|
7140
|
+
isSet(when.approved)
|
|
7141
|
+
].filter(Boolean).length;
|
|
7142
|
+
if (shapes !== 1)
|
|
7143
|
+
problems.push(
|
|
7144
|
+
`${here}.when: exactly one of field+equals (a form value), contains or matches (an agent's answer), or approved (a review)`
|
|
7145
|
+
);
|
|
7146
|
+
if (isSet(when.field) !== isSet(when.equals))
|
|
7147
|
+
problems.push(`${here}.when: a field condition needs both field and equals`);
|
|
7148
|
+
if (isSet(when.field) && typeof when.field !== "string")
|
|
7149
|
+
problems.push(`${here}.when.field: must be a field name`);
|
|
7150
|
+
if (isSet(when.equals) && !["string", "number", "boolean"].includes(typeof when.equals))
|
|
7151
|
+
problems.push(`${here}.when.equals: must be text, a number or true/false`);
|
|
7152
|
+
for (const key of ["contains", "matches"])
|
|
7153
|
+
if (isSet(when[key]) && (typeof when[key] !== "string" || !when[key].trim()))
|
|
7154
|
+
problems.push(`${here}.when.${key}: must be text`);
|
|
7155
|
+
if (typeof when.matches === "string")
|
|
7156
|
+
try {
|
|
7157
|
+
new RegExp(when.matches);
|
|
7158
|
+
} catch (err) {
|
|
7159
|
+
problems.push(
|
|
7160
|
+
`${here}.when.matches: not a valid regular expression (${err.message})`
|
|
7161
|
+
);
|
|
7162
|
+
}
|
|
7163
|
+
if (isSet(when.approved) && typeof when.approved !== "boolean")
|
|
7164
|
+
problems.push(`${here}.when.approved: true or false`);
|
|
7165
|
+
});
|
|
7166
|
+
}
|
|
7167
|
+
function checkAssignee(value, at2, problems) {
|
|
7168
|
+
const hint = `one of {user: usr-\u2026}, {run_owner: true}, {input: <person field>} or {project_lead: true}`;
|
|
7169
|
+
if (!isRecord(value)) {
|
|
7170
|
+
problems.push(`${at2}: must be ${hint}`);
|
|
7171
|
+
return;
|
|
7172
|
+
}
|
|
7173
|
+
for (const key of Object.keys(value))
|
|
7174
|
+
if (!ASSIGNEE_KEYS.includes(key)) problems.push(`${at2}.${key}: unknown field (${hint})`);
|
|
7175
|
+
const set = ASSIGNEE_KEYS.filter((k2) => isSet(value[k2]));
|
|
7176
|
+
if (set.length !== 1) problems.push(`${at2}: exactly ${hint}`);
|
|
7177
|
+
if (isSet(value.user) && (typeof value.user !== "string" || !PERSON_ID.test(value.user)))
|
|
7178
|
+
problems.push(`${at2}.user: a person or agent id (usr-\u2026 or agt-\u2026)`);
|
|
7179
|
+
for (const key of ["run_owner", "project_lead"])
|
|
7180
|
+
if (isSet(value[key]) && value[key] !== true) problems.push(`${at2}.${key}: must be true`);
|
|
7181
|
+
if (isSet(value.input) && (typeof value.input !== "string" || !FIELD_NAME_PATTERN.test(value.input)))
|
|
7182
|
+
problems.push(`${at2}.input: the name of a person field, e.g. "reviewer"`);
|
|
7183
|
+
}
|
|
7184
|
+
function checkFields(value, at2, problems) {
|
|
7185
|
+
if (!Array.isArray(value)) {
|
|
7186
|
+
problems.push(`${at2}: must be a list of fields, e.g. [{name: rating, type: select}]`);
|
|
7187
|
+
return;
|
|
7188
|
+
}
|
|
7189
|
+
if (value.length > 50) problems.push(`${at2}: at most 50 fields`);
|
|
7190
|
+
const names = /* @__PURE__ */ new Set();
|
|
7191
|
+
value.forEach((f2, j2) => {
|
|
7192
|
+
const here = `${at2}[${j2}]`;
|
|
7193
|
+
if (!isRecord(f2)) {
|
|
7194
|
+
problems.push(`${here}: must be an object with a name`);
|
|
7195
|
+
return;
|
|
7196
|
+
}
|
|
7197
|
+
if (typeof f2.name !== "string" || !FIELD_NAME_PATTERN.test(f2.name))
|
|
7198
|
+
problems.push(`${here}.name: a field needs a name like "rating" (letters, digits, "_")`);
|
|
7199
|
+
else if (names.has(f2.name)) problems.push(`${here}.name: "${f2.name}" is used twice`);
|
|
7200
|
+
else names.add(f2.name);
|
|
7201
|
+
if (isSet(f2.type) && !STEP_FIELD_TYPES.includes(f2.type))
|
|
7202
|
+
problems.push(
|
|
7203
|
+
`${here}.type: must be one of ${STEP_FIELD_TYPES.join(", ")} (got ${JSON.stringify(f2.type)})`
|
|
7204
|
+
);
|
|
7205
|
+
if (isSet(f2.label) && typeof f2.label !== "string") problems.push(`${here}.label: must be text`);
|
|
7206
|
+
if (isSet(f2.required) && typeof f2.required !== "boolean")
|
|
7207
|
+
problems.push(`${here}.required: true or false`);
|
|
7208
|
+
for (const key of ["min", "max"])
|
|
7209
|
+
if (isSet(f2[key]) && typeof f2[key] !== "number") problems.push(`${here}.${key}: a number`);
|
|
7210
|
+
if (isSet(f2.options)) {
|
|
7211
|
+
if (!Array.isArray(f2.options) || f2.options.some((o2) => !isRecord(o2) || typeof o2.value !== "string"))
|
|
7212
|
+
problems.push(`${here}.options: a list of {value, label}, e.g. [{value: high}]`);
|
|
7213
|
+
}
|
|
7214
|
+
});
|
|
7215
|
+
}
|
|
7216
|
+
var normalFields = (fields) => fields.map((f2) => ({
|
|
7217
|
+
...f2,
|
|
7218
|
+
name: f2.name,
|
|
7219
|
+
type: f2.type ?? "text",
|
|
7220
|
+
required: !!f2.required
|
|
7221
|
+
}));
|
|
6773
7222
|
function checkStep(raw, at2, problems) {
|
|
6774
7223
|
if (!isRecord(raw)) {
|
|
6775
7224
|
problems.push(`${at2}: must be an object with id, title and kind`);
|
|
@@ -6824,6 +7273,20 @@ function checkStep(raw, at2, problems) {
|
|
|
6824
7273
|
problems.push(`${at2}.${key}: only agent steps have a ${key} (this is a ${kind} step)`);
|
|
6825
7274
|
if (branch) problems.push(`${at2}.branch: only agent steps can branch`);
|
|
6826
7275
|
}
|
|
7276
|
+
const { signals, assignee, remind_after_hours: remind, fields: stepFieldsRaw } = raw;
|
|
7277
|
+
if (isSet(signals)) checkSignals(signals, `${at2}.signals`, problems);
|
|
7278
|
+
if (isSet(assignee)) checkAssignee(assignee, `${at2}.assignee`, problems);
|
|
7279
|
+
if (isSet(remind)) {
|
|
7280
|
+
if (typeof remind !== "number" || !(remind > 0) || remind > 24 * 365)
|
|
7281
|
+
problems.push(`${at2}.remind_after_hours: a number of hours above 0 (at most a year: 8760)`);
|
|
7282
|
+
else if (kind === "agent")
|
|
7283
|
+
problems.push(`${at2}.remind_after_hours: only a step that waits for a person can remind them`);
|
|
7284
|
+
}
|
|
7285
|
+
if (isSet(stepFieldsRaw)) {
|
|
7286
|
+
if (kind === "agent")
|
|
7287
|
+
problems.push(`${at2}.fields: an agent step has no fields: a person step asks for them`);
|
|
7288
|
+
else checkFields(stepFieldsRaw, `${at2}.fields`, problems);
|
|
7289
|
+
}
|
|
6827
7290
|
if (kind === "form" && isRecord(ui) && ui.fields !== void 0) {
|
|
6828
7291
|
if (!Array.isArray(ui.fields)) problems.push(`${at2}.ui.fields: must be a list of fields`);
|
|
6829
7292
|
else
|
|
@@ -6848,7 +7311,11 @@ function checkStep(raw, at2, problems) {
|
|
|
6848
7311
|
inputs: inputs ?? null,
|
|
6849
7312
|
branch: !!branch,
|
|
6850
7313
|
requires_files: !!raw.requires_files,
|
|
6851
|
-
ui: isRecord(ui) ? { ...ui, ...fields ? { fields } : {} } : null
|
|
7314
|
+
ui: isRecord(ui) ? { ...ui, ...fields ? { fields } : {} } : null,
|
|
7315
|
+
...isSet(signals) ? { signals } : {},
|
|
7316
|
+
...isSet(assignee) ? { assignee } : {},
|
|
7317
|
+
...isSet(remind) ? { remind_after_hours: remind } : {},
|
|
7318
|
+
...isSet(stepFieldsRaw) ? { fields: normalFields(stepFieldsRaw) } : {}
|
|
6852
7319
|
};
|
|
6853
7320
|
}
|
|
6854
7321
|
function parsePlanSteps(value) {
|
|
@@ -6924,6 +7391,30 @@ async function actOnStep(arbi, conversationId, body) {
|
|
|
6924
7391
|
"Failed to update the workflow step"
|
|
6925
7392
|
);
|
|
6926
7393
|
}
|
|
7394
|
+
async function completeStep(arbi, conversationId, step, inputs) {
|
|
7395
|
+
return actOnStep(arbi, conversationId, {
|
|
7396
|
+
step,
|
|
7397
|
+
action: "complete",
|
|
7398
|
+
...inputs && Object.keys(inputs).length ? { inputs } : {}
|
|
7399
|
+
});
|
|
7400
|
+
}
|
|
7401
|
+
async function skipStep(arbi, conversationId, step) {
|
|
7402
|
+
return actOnStep(arbi, conversationId, { step, action: "skip" });
|
|
7403
|
+
}
|
|
7404
|
+
async function sendBackStep(arbi, conversationId, step, options = {}) {
|
|
7405
|
+
return actOnStep(arbi, conversationId, {
|
|
7406
|
+
step,
|
|
7407
|
+
action: "send_back",
|
|
7408
|
+
...options.to ? { to: options.to } : {},
|
|
7409
|
+
...options.note?.trim() ? { note: options.note.trim() } : {}
|
|
7410
|
+
});
|
|
7411
|
+
}
|
|
7412
|
+
async function getConversationUsage(arbi, conversationId) {
|
|
7413
|
+
return requireData(
|
|
7414
|
+
await arbi.fetch.GET("/v1/conversation/{conversation_ext_id}/usage", byId(conversationId)),
|
|
7415
|
+
"Failed to fetch the conversation usage"
|
|
7416
|
+
);
|
|
7417
|
+
}
|
|
6927
7418
|
async function notifyConversation(arbi, conversationId, userIds) {
|
|
6928
7419
|
return requireData(
|
|
6929
7420
|
await arbi.fetch.POST("/v1/conversation/{conversation_ext_id}/notify", {
|
|
@@ -6963,7 +7454,14 @@ async function getRunProgress(arbi, conversationId) {
|
|
|
6963
7454
|
if (!plan.length)
|
|
6964
7455
|
throw new Error(`${conversationId} is not a stepped workflow run (its plan has no steps)`);
|
|
6965
7456
|
const steps = runSteps(plan, activity);
|
|
6966
|
-
return {
|
|
7457
|
+
return {
|
|
7458
|
+
conversation,
|
|
7459
|
+
steps,
|
|
7460
|
+
waitingOn: runWaitingOn(steps),
|
|
7461
|
+
signals: raisedSignals(activity),
|
|
7462
|
+
linkedRuns: linkedRuns(activity),
|
|
7463
|
+
sendBacks: sendBacks(activity)
|
|
7464
|
+
};
|
|
6967
7465
|
}
|
|
6968
7466
|
async function getStepAnswers(arbi, conversationId, responseIds) {
|
|
6969
7467
|
if (!responseIds.length) return {};
|
|
@@ -7342,8 +7840,15 @@ var Arbi = class {
|
|
|
7342
7840
|
}
|
|
7343
7841
|
// ── Projects ──────────────────────────────────────────────────────────
|
|
7344
7842
|
projects = {
|
|
7345
|
-
|
|
7346
|
-
|
|
7843
|
+
/** The caller's projects; only those at `stage` and/or led by `leadUser` when given. */
|
|
7844
|
+
list: (filters) => listProjects(this.requireClient(), filters),
|
|
7845
|
+
create: (name, plan, details) => createProject(this.requireClient(), name, plan, details),
|
|
7846
|
+
/** Patch a project: name, daily cap, budget, client, stage, lead, fields (merged key by key). */
|
|
7847
|
+
update: (projectExtId, body) => updateProject(this.requireClient(), projectExtId, body),
|
|
7848
|
+
/** The project's stage and budget changes, newest first. */
|
|
7849
|
+
events: (projectExtId, options) => listProjectEvents(this.requireClient(), projectExtId, options),
|
|
7850
|
+
/** The project's spend by conversation in a billing period (credits). */
|
|
7851
|
+
usageByConversation: (projectExtId, monthsBack) => getProjectConversationUsage(this.requireClient(), projectExtId, monthsBack),
|
|
7347
7852
|
refresh: (projectExtId) => refreshProject(this.requireClient(), projectExtId),
|
|
7348
7853
|
/** AI usage + spend breakdown for a project's billing period. */
|
|
7349
7854
|
usage: (projectExtId, monthsBack) => getProjectUsage(this.requireClient(), projectExtId, monthsBack),
|
|
@@ -7620,6 +8125,16 @@ var Arbi = class {
|
|
|
7620
8125
|
activity: (conversationId) => getActivity(this.requireClient(), conversationId),
|
|
7621
8126
|
/** Complete or skip a step of a workflow run; the run goes on to its next agent step. */
|
|
7622
8127
|
actOnStep: (conversationId, body) => actOnStep(this.requireClient(), conversationId, body),
|
|
8128
|
+
/** Complete a person step (with its inputs, checked against the step's `fields`). */
|
|
8129
|
+
completeStep: (conversationId, step, inputs) => completeStep(this.requireClient(), conversationId, step, inputs),
|
|
8130
|
+
/** Skip a step so what waits for it can go on. */
|
|
8131
|
+
skipStep: (conversationId, step) => skipStep(this.requireClient(), conversationId, step),
|
|
8132
|
+
/** Send the work back from a person step to an earlier one (`to`), with an optional note. */
|
|
8133
|
+
sendBackStep: (conversationId, step, options) => sendBackStep(this.requireClient(), conversationId, step, options),
|
|
8134
|
+
/** A stepped run's steps, signals, linked runs and send-backs, and what it waits for. */
|
|
8135
|
+
runProgress: (conversationId) => getRunProgress(this.requireClient(), conversationId),
|
|
8136
|
+
/** What the conversation's AI work cost: by step, run, model, agent and feature (credits). */
|
|
8137
|
+
usage: (conversationId) => getConversationUsage(this.requireClient(), conversationId),
|
|
7623
8138
|
/** Notify people about a conversation (each gets a notification); resolves with who was. */
|
|
7624
8139
|
notify: (conversationId, userIds) => notifyConversation(this.requireClient(), conversationId, userIds),
|
|
7625
8140
|
/** Draft an editable plan from an objective. */
|
|
@@ -7763,7 +8278,11 @@ var Arbi = class {
|
|
|
7763
8278
|
workspaceId: options.workspaceId ?? this.requireWorkspace()
|
|
7764
8279
|
}),
|
|
7765
8280
|
delete: (tagId) => deleteTag(this.requireClient(), tagId),
|
|
7766
|
-
update: (tagId, body) => updateTag(this.requireClient(), tagId, body)
|
|
8281
|
+
update: (tagId, body) => updateTag(this.requireClient(), tagId, body),
|
|
8282
|
+
/** Replace a tag's own field definitions and/or merge-patch its values (`null` clears one). */
|
|
8283
|
+
updateFields: (tagId, change) => updateTagFields(this.requireClient(), tagId, change),
|
|
8284
|
+
/** Tags as rows (a parent's children, or the given tags) with field values, docs and facts. */
|
|
8285
|
+
matrix: (selection, linksLimit) => getTagMatrix(this.requireClient(), selection, linksLimit)
|
|
7767
8286
|
};
|
|
7768
8287
|
// ── Document Tags ─────────────────────────────────────────────────────
|
|
7769
8288
|
doctags = {
|