@arbidocs/sdk 0.4.74 → 0.4.76

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.
@@ -1,2 +1,2 @@
1
- export { A as ActivityKind, a as ActivityResponse, b as AgentControlStateEvent, c as AgentStepDeltaEvent, d as AgentStepEvent, e as Arbi, f as ArbiApiError, g as ArbiError, h as ArbiErrorEvent, i as ArbiOptions, k as ArtifactEvent, l as AuthContext, m as AuthHeaders, n as AuthMode, o as AuthenticatedClient, C as ChatSession, p as CitationSummary, q as CliConfig, r as CliCredentials, s as CommandDescriptor, t as ConfigStore, u as ConnectOptions, v as ConversationResponse, w as CreateFactRequest, x as CreateFactsRequest, y as CreateWorkRequest, z as CreateWorkflowRequest, B as DecryptedDmNotification, E as DeferredInterjectionEvent, F as DmAttachmentFile, G as DmAttachmentInput, J as DocumentAutomationAction, M as DocumentSelector, P as FactResponse, Q as FactSearchRequest, R as FactSearchResponse, T as IdentityErrorCode, U as IdentityPurchase, V as IdentityState, W as IdentityStatus, Y as ListFactsOptions, a0 as MessageMetadataPayload, a1 as MessageQueuedEvent, a2 as OutputTokensDetails, a3 as ParsedSlashCommand, a4 as PendingAuthResponse, a5 as PlanWorkRequest, a6 as ProbeAnswerEvent, a7 as ProjectInvoicesResponse, a8 as ProjectUsageResponse, a9 as QueryOptions, aa as ReconnectOptions, ab as ReconnectableWsConnection, ac as ResolvedCitation, ae as ResponseCompletedEvent, af as ResponseContentPartAddedEvent, ag as ResponseCreatedEvent, ah as ResponseFailedEvent, ai as ResponseOutputItemAddedEvent, aj as ResponseOutputItemDoneEvent, ak as ResponseOutputTextDeltaEvent, al as ResponseOutputTextDoneEvent, am as ResponseUsage, an as SSEEvent, ao as SSEStreamCallbacks, ap as SSEStreamResult, aq as SSEStreamStartData, as as SkillSummary, au as StepActionRequest, av as SubmitBackgroundQueryOptions, aw as TaskPlan, ax as TokenBudgetContext, ay as UpdateConversationRequest, az as UpdateFactRequest, aA as UpdateWorkflowRequest, aG as UserDailyUsageResponse, aH as UserInfo, aI as UserInputRequestEvent, aJ as UserMessageEvent, aK as WebSocketAuthError, aL as WorkStatus, aM as WorkflowAuthMode, aN as WorkflowResponse, aO as WorkflowRunHistoryResponse, aP as WorkflowRunResponse, aQ as WorkspaceContext, aR as WsConnection, aS as account, aT as agentconfig, aV as assistant, aW as authenticatedFetch, aY as buildFactsContextTool, aZ as buildRetrievalChunkTool, a_ as buildRetrievalFullContextTool, a$ as buildRetrievalTocTool, b0 as connectWebSocket, b1 as connectWithReconnect, b2 as consumeSSEStream, b3 as contacts, b4 as conversations, b5 as countCitations, b6 as createAuthenticatedClient, b8 as dm, b9 as doctags, ba as documents, bb as facts, bc as files, bd as filterSkills, be as formatAgentStepLabel, bf as formatFileSize, bg as formatItemLabel, bi as formatUserName, bj as formatWorkspaceChoices, bo as getErrorMessage, bp as getRawWorkspaceKey, bq as health, bs as identityErrorCode, br as identityVerification, bt as mail, bu as parseSSEEvents, bv as parseSlashCommand, bw as parseSlashTokenInProgress, bx as performPasswordLogin, bA as profile, bB as projects, bC as requireData, bD as requireOk, bE as resolveAuth, bF as resolveCitations, bG as resolveWorkspace, bH as responses, bI as selectWorkspace, bJ as selectWorkspaceById, bK as sessions, bL as settings, bM as streamSSE, bN as stripCitationMarkdown, bO as summarizeCitations, bP as tags, bQ as work, bR as workflows, bS as workspaces } from './browser-BBYaJCyB.cjs';
1
+ export { A as ActivityKind, a as ActivityResponse, b as AgentControlStateEvent, c as AgentStepDeltaEvent, d as AgentStepEvent, e as Arbi, f as ArbiApiError, g as ArbiError, h as ArbiErrorEvent, i as ArbiOptions, k as ArtifactEvent, l as AuthContext, m as AuthHeaders, n as AuthMode, o as AuthenticatedClient, C as ChatSession, p as CitationSummary, q as CliConfig, r as CliCredentials, s as CommandDescriptor, t as ConfigStore, u as ConnectOptions, v as ConversationResponse, w as CreateFactRequest, x as CreateFactsRequest, y as CreateWorkRequest, z as CreateWorkflowRequest, B as DecryptedDmNotification, E as DeferredInterjectionEvent, F as DmAttachmentFile, G as DmAttachmentInput, J as DocumentAutomationAction, M as DocumentSelector, P as FactResponse, Q as FactSearchRequest, R as FactSearchResponse, T as IdentityErrorCode, U as IdentityPurchase, V as IdentityState, W as IdentityStatus, Y as ListFactsOptions, a0 as MessageMetadataPayload, a1 as MessageQueuedEvent, a2 as OutputTokensDetails, a3 as ParsedSlashCommand, a4 as PendingAuthResponse, a5 as PlanStepsError, a6 as PlanWorkRequest, a7 as ProbeAnswerEvent, a8 as ProjectInvoicesResponse, a9 as ProjectUsageResponse, aa as QueryOptions, ab as ReconnectOptions, ac as ReconnectableWsConnection, ad as ResolvedCitation, af as ResponseCompletedEvent, ag as ResponseContentPartAddedEvent, ah as ResponseCreatedEvent, ai as ResponseFailedEvent, aj as ResponseOutputItemAddedEvent, ak as ResponseOutputItemDoneEvent, al as ResponseOutputTextDeltaEvent, am as ResponseOutputTextDoneEvent, an as ResponseUsage, ao as RunProgress, ap as RunStep, aq as RunWaitingOn, ar as SSEEvent, as as SSEStreamCallbacks, at as SSEStreamResult, au as SSEStreamStartData, aw as SkillSummary, ay as StepActionRequest, az as StepActivityEvent, aA as StepField, aB as StepKind, aC as StepPhase, aD as StepState, aE as StepStatus, aF as SubmitBackgroundQueryOptions, aG as TaskPlan, aH as TaskPlanStep, aI as TokenBudgetContext, aJ as UpdateConversationRequest, aK as UpdateFactRequest, aL as UpdateWorkflowRequest, aR as UserDailyUsageResponse, aS as UserInfo, aT as UserInputRequestEvent, aU as UserMessageEvent, aV as WebSocketAuthError, aW as WorkStatus, aX as WorkflowAuthMode, aY as WorkflowResponse, aZ as WorkflowRunHistoryResponse, a_ as WorkflowRunResponse, a$ as WorkspaceContext, b0 as WsConnection, b1 as account, b2 as agentconfig, b4 as assistant, b5 as authenticatedFetch, b7 as buildFactsContextTool, b8 as buildRetrievalChunkTool, b9 as buildRetrievalFullContextTool, ba as buildRetrievalTocTool, bb as connectWebSocket, bc as connectWithReconnect, bd as consumeSSEStream, be as contacts, bf as conversations, bg as countCitations, bh as createAuthenticatedClient, bj as dm, bk as doctags, bl as documents, bm as facts, bn as files, bo as filterSkills, bp as formatAgentStepLabel, bq as formatFileSize, br as formatItemLabel, bt as formatUserName, bu as formatWorkspaceChoices, bz as getErrorMessage, bA as getRawWorkspaceKey, bB as health, bD as identityErrorCode, bC as identityVerification, bE as mail, bF as parseSSEEvents, bG as parseSlashCommand, bH as parseSlashTokenInProgress, bI as performPasswordLogin, bL as profile, bM as projects, bN as requireData, bO as requireOk, bP as resolveAuth, bQ as resolveCitations, bR as resolveWorkspace, bS as responses, bT as selectWorkspace, bU as selectWorkspaceById, bV as sessions, bW as settings, bX as streamSSE, bY as stripCitationMarkdown, bZ as summarizeCitations, b_ as tags, b$ as work, c0 as workflowSteps, c1 as workflows, c2 as workspaces } from './browser-DbhZr6hC.cjs';
2
2
  export { LoginProfile } from '@arbidocs/client';
package/dist/browser.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export { A as ActivityKind, a as ActivityResponse, b as AgentControlStateEvent, c as AgentStepDeltaEvent, d as AgentStepEvent, e as Arbi, f as ArbiApiError, g as ArbiError, h as ArbiErrorEvent, i as ArbiOptions, k as ArtifactEvent, l as AuthContext, m as AuthHeaders, n as AuthMode, o as AuthenticatedClient, C as ChatSession, p as CitationSummary, q as CliConfig, r as CliCredentials, s as CommandDescriptor, t as ConfigStore, u as ConnectOptions, v as ConversationResponse, w as CreateFactRequest, x as CreateFactsRequest, y as CreateWorkRequest, z as CreateWorkflowRequest, B as DecryptedDmNotification, E as DeferredInterjectionEvent, F as DmAttachmentFile, G as DmAttachmentInput, J as DocumentAutomationAction, M as DocumentSelector, P as FactResponse, Q as FactSearchRequest, R as FactSearchResponse, T as IdentityErrorCode, U as IdentityPurchase, V as IdentityState, W as IdentityStatus, Y as ListFactsOptions, a0 as MessageMetadataPayload, a1 as MessageQueuedEvent, a2 as OutputTokensDetails, a3 as ParsedSlashCommand, a4 as PendingAuthResponse, a5 as PlanWorkRequest, a6 as ProbeAnswerEvent, a7 as ProjectInvoicesResponse, a8 as ProjectUsageResponse, a9 as QueryOptions, aa as ReconnectOptions, ab as ReconnectableWsConnection, ac as ResolvedCitation, ae as ResponseCompletedEvent, af as ResponseContentPartAddedEvent, ag as ResponseCreatedEvent, ah as ResponseFailedEvent, ai as ResponseOutputItemAddedEvent, aj as ResponseOutputItemDoneEvent, ak as ResponseOutputTextDeltaEvent, al as ResponseOutputTextDoneEvent, am as ResponseUsage, an as SSEEvent, ao as SSEStreamCallbacks, ap as SSEStreamResult, aq as SSEStreamStartData, as as SkillSummary, au as StepActionRequest, av as SubmitBackgroundQueryOptions, aw as TaskPlan, ax as TokenBudgetContext, ay as UpdateConversationRequest, az as UpdateFactRequest, aA as UpdateWorkflowRequest, aG as UserDailyUsageResponse, aH as UserInfo, aI as UserInputRequestEvent, aJ as UserMessageEvent, aK as WebSocketAuthError, aL as WorkStatus, aM as WorkflowAuthMode, aN as WorkflowResponse, aO as WorkflowRunHistoryResponse, aP as WorkflowRunResponse, aQ as WorkspaceContext, aR as WsConnection, aS as account, aT as agentconfig, aV as assistant, aW as authenticatedFetch, aY as buildFactsContextTool, aZ as buildRetrievalChunkTool, a_ as buildRetrievalFullContextTool, a$ as buildRetrievalTocTool, b0 as connectWebSocket, b1 as connectWithReconnect, b2 as consumeSSEStream, b3 as contacts, b4 as conversations, b5 as countCitations, b6 as createAuthenticatedClient, b8 as dm, b9 as doctags, ba as documents, bb as facts, bc as files, bd as filterSkills, be as formatAgentStepLabel, bf as formatFileSize, bg as formatItemLabel, bi as formatUserName, bj as formatWorkspaceChoices, bo as getErrorMessage, bp as getRawWorkspaceKey, bq as health, bs as identityErrorCode, br as identityVerification, bt as mail, bu as parseSSEEvents, bv as parseSlashCommand, bw as parseSlashTokenInProgress, bx as performPasswordLogin, bA as profile, bB as projects, bC as requireData, bD as requireOk, bE as resolveAuth, bF as resolveCitations, bG as resolveWorkspace, bH as responses, bI as selectWorkspace, bJ as selectWorkspaceById, bK as sessions, bL as settings, bM as streamSSE, bN as stripCitationMarkdown, bO as summarizeCitations, bP as tags, bQ as work, bR as workflows, bS as workspaces } from './browser-BBYaJCyB.js';
1
+ export { A as ActivityKind, a as ActivityResponse, b as AgentControlStateEvent, c as AgentStepDeltaEvent, d as AgentStepEvent, e as Arbi, f as ArbiApiError, g as ArbiError, h as ArbiErrorEvent, i as ArbiOptions, k as ArtifactEvent, l as AuthContext, m as AuthHeaders, n as AuthMode, o as AuthenticatedClient, C as ChatSession, p as CitationSummary, q as CliConfig, r as CliCredentials, s as CommandDescriptor, t as ConfigStore, u as ConnectOptions, v as ConversationResponse, w as CreateFactRequest, x as CreateFactsRequest, y as CreateWorkRequest, z as CreateWorkflowRequest, B as DecryptedDmNotification, E as DeferredInterjectionEvent, F as DmAttachmentFile, G as DmAttachmentInput, J as DocumentAutomationAction, M as DocumentSelector, P as FactResponse, Q as FactSearchRequest, R as FactSearchResponse, T as IdentityErrorCode, U as IdentityPurchase, V as IdentityState, W as IdentityStatus, Y as ListFactsOptions, a0 as MessageMetadataPayload, a1 as MessageQueuedEvent, a2 as OutputTokensDetails, a3 as ParsedSlashCommand, a4 as PendingAuthResponse, a5 as PlanStepsError, a6 as PlanWorkRequest, a7 as ProbeAnswerEvent, a8 as ProjectInvoicesResponse, a9 as ProjectUsageResponse, aa as QueryOptions, ab as ReconnectOptions, ac as ReconnectableWsConnection, ad as ResolvedCitation, af as ResponseCompletedEvent, ag as ResponseContentPartAddedEvent, ah as ResponseCreatedEvent, ai as ResponseFailedEvent, aj as ResponseOutputItemAddedEvent, ak as ResponseOutputItemDoneEvent, al as ResponseOutputTextDeltaEvent, am as ResponseOutputTextDoneEvent, an as ResponseUsage, ao as RunProgress, ap as RunStep, aq as RunWaitingOn, ar as SSEEvent, as as SSEStreamCallbacks, at as SSEStreamResult, au as SSEStreamStartData, aw as SkillSummary, ay as StepActionRequest, az as StepActivityEvent, aA as StepField, aB as StepKind, aC as StepPhase, aD as StepState, aE as StepStatus, aF as SubmitBackgroundQueryOptions, aG as TaskPlan, aH as TaskPlanStep, aI as TokenBudgetContext, aJ as UpdateConversationRequest, aK as UpdateFactRequest, aL as UpdateWorkflowRequest, aR as UserDailyUsageResponse, aS as UserInfo, aT as UserInputRequestEvent, aU as UserMessageEvent, aV as WebSocketAuthError, aW as WorkStatus, aX as WorkflowAuthMode, aY as WorkflowResponse, aZ as WorkflowRunHistoryResponse, a_ as WorkflowRunResponse, a$ as WorkspaceContext, b0 as WsConnection, b1 as account, b2 as agentconfig, b4 as assistant, b5 as authenticatedFetch, b7 as buildFactsContextTool, b8 as buildRetrievalChunkTool, b9 as buildRetrievalFullContextTool, ba as buildRetrievalTocTool, bb as connectWebSocket, bc as connectWithReconnect, bd as consumeSSEStream, be as contacts, bf as conversations, bg as countCitations, bh as createAuthenticatedClient, bj as dm, bk as doctags, bl as documents, bm as facts, bn as files, bo as filterSkills, bp as formatAgentStepLabel, bq as formatFileSize, br as formatItemLabel, bt as formatUserName, bu as formatWorkspaceChoices, bz as getErrorMessage, bA as getRawWorkspaceKey, bB as health, bD as identityErrorCode, bC as identityVerification, bE as mail, bF as parseSSEEvents, bG as parseSlashCommand, bH as parseSlashTokenInProgress, bI as performPasswordLogin, bL as profile, bM as projects, bN as requireData, bO as requireOk, bP as resolveAuth, bQ as resolveCitations, bR as resolveWorkspace, bS as responses, bT as selectWorkspace, bU as selectWorkspaceById, bV as sessions, bW as settings, bX as streamSSE, bY as stripCitationMarkdown, bZ as summarizeCitations, b_ as tags, b$ as work, c0 as workflowSteps, c1 as workflows, c2 as workspaces } from './browser-DbhZr6hC.js';
2
2
  export { LoginProfile } from '@arbidocs/client';
package/dist/browser.js CHANGED
@@ -6063,12 +6063,267 @@ __export(work_exports, {
6063
6063
  actOnStep: () => actOnStep,
6064
6064
  createWork: () => createWork,
6065
6065
  getActivity: () => getActivity,
6066
+ getConversation: () => getConversation,
6066
6067
  getPendingAuth: () => getPendingAuth,
6068
+ getRunProgress: () => getRunProgress,
6069
+ getStepAnswers: () => getStepAnswers,
6067
6070
  notifyConversation: () => notifyConversation,
6068
6071
  planWork: () => planWork,
6069
6072
  runConversation: () => runConversation,
6070
6073
  updateConversation: () => updateConversation
6071
6074
  });
6075
+
6076
+ // src/workflow-steps.ts
6077
+ var workflow_steps_exports = {};
6078
+ __export(workflow_steps_exports, {
6079
+ PERSON_STEP_KINDS: () => PERSON_STEP_KINDS,
6080
+ PlanStepsError: () => PlanStepsError,
6081
+ STEP_ID_PATTERN: () => STEP_ID_PATTERN,
6082
+ STEP_KINDS: () => STEP_KINDS,
6083
+ isPersonStep: () => isPersonStep,
6084
+ missingRequiredFields: () => missingRequiredFields,
6085
+ parseInputPairs: () => parseInputPairs,
6086
+ parsePlanSteps: () => parsePlanSteps,
6087
+ runSteps: () => runSteps,
6088
+ runWaitingOn: () => runWaitingOn,
6089
+ stepDependencies: () => stepDependencies,
6090
+ stepFields: () => stepFields,
6091
+ stepPhase: () => stepPhase,
6092
+ stepStatesFromActivity: () => stepStatesFromActivity,
6093
+ stepsPlan: () => stepsPlan
6094
+ });
6095
+ var STEP_KINDS = ["form", "upload", "agent", "review"];
6096
+ var PERSON_STEP_KINDS = ["form", "upload", "review"];
6097
+ var STEP_ID_PATTERN = /^[a-z][a-z0-9_-]{0,63}$/;
6098
+ var STEP_EVENTS = {
6099
+ step_started: "running",
6100
+ step_done: "done",
6101
+ step_skipped: "skipped",
6102
+ step_failed: "failed"
6103
+ };
6104
+ var isFinished = (state) => state?.status === "done" || state?.status === "skipped";
6105
+ var isPersonStep = (step) => PERSON_STEP_KINDS.includes(step.kind);
6106
+ function stepDependencies(steps, id) {
6107
+ const i2 = steps.findIndex((s2) => s2.id === id);
6108
+ if (i2 < 0) return [];
6109
+ const after = steps[i2].after;
6110
+ if (after !== null && after !== void 0) return [...after];
6111
+ return i2 > 0 ? [steps[i2 - 1].id] : [];
6112
+ }
6113
+ function dependsOn(steps, a2, b2) {
6114
+ const seen = /* @__PURE__ */ new Set();
6115
+ const stack = stepDependencies(steps, a2);
6116
+ while (stack.length) {
6117
+ const id = stack.pop();
6118
+ if (id === b2) return true;
6119
+ if (seen.has(id)) continue;
6120
+ seen.add(id);
6121
+ stack.push(...stepDependencies(steps, id));
6122
+ }
6123
+ return false;
6124
+ }
6125
+ function stepStatesFromActivity(events) {
6126
+ const states = {};
6127
+ for (const e of events) {
6128
+ const status = STEP_EVENTS[e.kind];
6129
+ const step = e.detail?.step;
6130
+ if (!status || typeof step !== "string") continue;
6131
+ const responseId = typeof e.detail?.response_id === "string" ? e.detail.response_id : null;
6132
+ const error = typeof e.detail?.error === "string" ? e.detail.error : null;
6133
+ states[step] = { status, responseId: responseId ?? states[step]?.responseId ?? null, error };
6134
+ }
6135
+ return states;
6136
+ }
6137
+ function stepPhase(steps, states, id) {
6138
+ const state = states[id];
6139
+ if (state && state.status !== "pending") return state.status;
6140
+ return stepDependencies(steps, id).every((d2) => isFinished(states[d2])) ? "ready" : "pending";
6141
+ }
6142
+ function runSteps(steps, events) {
6143
+ const states = stepStatesFromActivity(events);
6144
+ return steps.map((s2) => ({
6145
+ id: s2.id,
6146
+ title: s2.title,
6147
+ kind: s2.kind,
6148
+ phase: stepPhase(steps, states, s2.id),
6149
+ after: stepDependencies(steps, s2.id),
6150
+ responseId: states[s2.id]?.responseId ?? null,
6151
+ error: states[s2.id]?.error ?? null
6152
+ }));
6153
+ }
6154
+ function runWaitingOn(run) {
6155
+ if (run.length > 0 && run.every((s2) => s2.phase === "done" || s2.phase === "skipped"))
6156
+ return "finished";
6157
+ if (run.some((s2) => s2.phase === "running" || s2.kind === "agent" && s2.phase === "ready"))
6158
+ return "agent";
6159
+ if (run.some((s2) => s2.kind !== "agent" && s2.phase === "ready")) return "person";
6160
+ return "stuck";
6161
+ }
6162
+ function stepFields(step) {
6163
+ if (step.kind !== "form") return [];
6164
+ const fields = step.ui?.fields;
6165
+ return Array.isArray(fields) ? fields : [];
6166
+ }
6167
+ var blank = (value) => value === void 0 || value === null || typeof value === "string" && value.trim() === "";
6168
+ function missingRequiredFields(step, inputs) {
6169
+ return stepFields(step).filter((f2) => f2.required && blank(inputs[f2.name])).map((f2) => f2.name);
6170
+ }
6171
+ function parseInputPairs(pairs, fields = []) {
6172
+ const types = new Map(fields.map((f2) => [f2.name, f2.type]));
6173
+ const out = {};
6174
+ for (const pair of pairs) {
6175
+ const eq = pair.indexOf("=");
6176
+ if (eq <= 0) throw new Error(`Invalid input "${pair}": use name=value`);
6177
+ const name = pair.slice(0, eq).trim();
6178
+ const raw = pair.slice(eq + 1);
6179
+ const type = types.get(name);
6180
+ if (type === "number") {
6181
+ const n2 = Number(raw);
6182
+ if (raw.trim() === "" || Number.isNaN(n2))
6183
+ throw new Error(`Input "${name}" must be a number, got "${raw}"`);
6184
+ out[name] = n2;
6185
+ } else if (type === "boolean") {
6186
+ if (!["true", "false"].includes(raw.toLowerCase()))
6187
+ throw new Error(`Input "${name}" must be true or false, got "${raw}"`);
6188
+ out[name] = raw.toLowerCase() === "true";
6189
+ } else out[name] = raw;
6190
+ }
6191
+ return out;
6192
+ }
6193
+ var STEP_KEYS = /* @__PURE__ */ new Set([
6194
+ "id",
6195
+ "title",
6196
+ "kind",
6197
+ "after",
6198
+ "skill",
6199
+ "prompt",
6200
+ "inputs",
6201
+ "branch",
6202
+ "requires_files",
6203
+ "ui"
6204
+ ]);
6205
+ var isRecord = (v2) => typeof v2 === "object" && v2 !== null && !Array.isArray(v2);
6206
+ var PlanStepsError = class extends Error {
6207
+ constructor(problems) {
6208
+ super(`Invalid workflow steps:
6209
+ ${problems.map((p2) => ` - ${p2}`).join("\n")}`);
6210
+ this.problems = problems;
6211
+ this.name = "PlanStepsError";
6212
+ }
6213
+ problems;
6214
+ };
6215
+ function checkStep(raw, at2, problems) {
6216
+ if (!isRecord(raw)) {
6217
+ problems.push(`${at2}: must be an object with id, title and kind`);
6218
+ return null;
6219
+ }
6220
+ const before = problems.length;
6221
+ for (const key of Object.keys(raw))
6222
+ if (!STEP_KEYS.has(key))
6223
+ problems.push(`${at2}.${key}: unknown field (allowed: ${[...STEP_KEYS].join(", ")})`);
6224
+ const { id, title, kind, after, skill, prompt, inputs, branch, ui } = raw;
6225
+ if (typeof id !== "string" || !STEP_ID_PATTERN.test(id))
6226
+ problems.push(
6227
+ `${at2}.id: must be lowercase letters, digits, "_" or "-", starting with a letter (got ${JSON.stringify(id)})`
6228
+ );
6229
+ if (typeof title !== "string" || !title.trim()) problems.push(`${at2}.title: required text`);
6230
+ if (typeof kind !== "string" || !STEP_KINDS.includes(kind))
6231
+ problems.push(
6232
+ `${at2}.kind: must be one of ${STEP_KINDS.join(", ")} (got ${JSON.stringify(kind)})`
6233
+ );
6234
+ if (after !== void 0 && after !== null) {
6235
+ if (!Array.isArray(after) || after.some((d2) => typeof d2 !== "string"))
6236
+ problems.push(`${at2}.after: must be a list of step ids`);
6237
+ }
6238
+ for (const [key, value] of [
6239
+ ["skill", skill],
6240
+ ["prompt", prompt]
6241
+ ])
6242
+ if (value !== void 0 && value !== null && typeof value !== "string")
6243
+ problems.push(`${at2}.${key}: must be text`);
6244
+ if (inputs !== void 0 && inputs !== null) {
6245
+ if (!isRecord(inputs) || Object.values(inputs).some((v2) => typeof v2 !== "string"))
6246
+ problems.push(
6247
+ `${at2}.inputs: must map each skill input to a text template, e.g. {"q": "{{topic}}"}`
6248
+ );
6249
+ }
6250
+ if (branch !== void 0 && typeof branch !== "boolean")
6251
+ problems.push(`${at2}.branch: true or false`);
6252
+ if (ui !== void 0 && ui !== null && !isRecord(ui)) problems.push(`${at2}.ui: must be an object`);
6253
+ if (kind === "agent") {
6254
+ const hasSkill = typeof skill === "string" && skill.trim() !== "";
6255
+ const hasPrompt = typeof prompt === "string" && prompt.trim() !== "";
6256
+ if (!hasSkill && !hasPrompt) problems.push(`${at2}: an agent step needs a prompt or a skill`);
6257
+ if (hasSkill && hasPrompt)
6258
+ problems.push(`${at2}: an agent step runs a prompt or a skill, not both`);
6259
+ } else if (typeof kind === "string" && STEP_KINDS.includes(kind)) {
6260
+ for (const [key, value] of [
6261
+ ["skill", skill],
6262
+ ["prompt", prompt],
6263
+ ["inputs", inputs]
6264
+ ])
6265
+ if (value !== void 0 && value !== null)
6266
+ problems.push(`${at2}.${key}: only agent steps have a ${key} (this is a ${kind} step)`);
6267
+ if (branch) problems.push(`${at2}.branch: only agent steps can branch`);
6268
+ }
6269
+ if (kind === "form" && isRecord(ui) && ui.fields !== void 0) {
6270
+ if (!Array.isArray(ui.fields)) problems.push(`${at2}.ui.fields: must be a list of fields`);
6271
+ else
6272
+ ui.fields.forEach((f2, j2) => {
6273
+ if (!isRecord(f2) || typeof f2.name !== "string" || !/^[a-z][a-z0-9_]*$/i.test(f2.name))
6274
+ problems.push(`${at2}.ui.fields[${j2}].name: a field needs a name like "client_name"`);
6275
+ });
6276
+ }
6277
+ if (problems.length > before) return null;
6278
+ const fields = kind === "form" && isRecord(ui) && Array.isArray(ui.fields) ? ui.fields.map((f2) => ({
6279
+ ...f2,
6280
+ type: typeof f2.type === "string" ? f2.type : "text",
6281
+ label: typeof f2.label === "string" ? f2.label : f2.name
6282
+ })) : void 0;
6283
+ return {
6284
+ id,
6285
+ title: title.trim(),
6286
+ kind,
6287
+ after: after ?? null,
6288
+ skill: skill ?? null,
6289
+ prompt: prompt ?? null,
6290
+ inputs: inputs ?? null,
6291
+ branch: !!branch,
6292
+ requires_files: !!raw.requires_files,
6293
+ ui: isRecord(ui) ? { ...ui, ...fields ? { fields } : {} } : null
6294
+ };
6295
+ }
6296
+ function parsePlanSteps(value) {
6297
+ const list = isRecord(value) ? value.steps : value;
6298
+ if (!Array.isArray(list))
6299
+ throw new PlanStepsError(['expected a list of steps, or an object with a "steps" list']);
6300
+ if (list.length === 0) throw new PlanStepsError(["a workflow needs at least one step"]);
6301
+ const problems = [];
6302
+ const steps = list.map((raw, i2) => checkStep(raw, `steps[${i2}]`, problems));
6303
+ if (problems.length) throw new PlanStepsError(problems);
6304
+ const valid = steps;
6305
+ const ids = /* @__PURE__ */ new Set();
6306
+ valid.forEach((s2, i2) => {
6307
+ if (ids.has(s2.id)) problems.push(`steps[${i2}].id: "${s2.id}" is used twice`);
6308
+ ids.add(s2.id);
6309
+ });
6310
+ valid.forEach((s2, i2) => {
6311
+ for (const d2 of stepDependencies(valid, s2.id)) {
6312
+ if (!ids.has(d2)) problems.push(`steps[${i2}].after: no step "${d2}"`);
6313
+ else if (d2 === s2.id || dependsOn(valid, d2, s2.id))
6314
+ problems.push(`steps[${i2}].after: "${s2.id}" and "${d2}" wait for each other`);
6315
+ else if (valid.findIndex((x2) => x2.id === d2) > i2)
6316
+ problems.push(`steps[${i2}].after: "${d2}" must come before "${s2.id}" in the list`);
6317
+ }
6318
+ });
6319
+ if (problems.length) throw new PlanStepsError(problems);
6320
+ return valid;
6321
+ }
6322
+ function stepsPlan(steps) {
6323
+ return { goal: "", criteria: [], max_passes: 3, documents: [], steps };
6324
+ }
6325
+
6326
+ // src/operations/work.ts
6072
6327
  var byId = (conversationId) => ({
6073
6328
  params: { path: { conversation_ext_id: conversationId } }
6074
6329
  });
@@ -6132,6 +6387,39 @@ async function planWork(arbi, body) {
6132
6387
  "Failed to draft a plan"
6133
6388
  );
6134
6389
  }
6390
+ async function getConversation(arbi, conversationId) {
6391
+ const all = requireData(
6392
+ await arbi.fetch.GET("/v1/conversation/list"),
6393
+ "Failed to fetch conversations"
6394
+ );
6395
+ const found = all.find((c2) => c2.external_id === conversationId);
6396
+ if (!found) throw new Error(`No conversation ${conversationId} in this workspace`);
6397
+ return found;
6398
+ }
6399
+ async function getRunProgress(arbi, conversationId) {
6400
+ const [conversation, activity] = await Promise.all([
6401
+ getConversation(arbi, conversationId),
6402
+ getActivity(arbi, conversationId)
6403
+ ]);
6404
+ const plan = conversation.plan?.steps ?? [];
6405
+ if (!plan.length)
6406
+ throw new Error(`${conversationId} is not a stepped workflow run (its plan has no steps)`);
6407
+ const steps = runSteps(plan, activity);
6408
+ return { conversation, steps, waitingOn: runWaitingOn(steps) };
6409
+ }
6410
+ async function getStepAnswers(arbi, conversationId, responseIds) {
6411
+ if (!responseIds.length) return {};
6412
+ const data = requireData(
6413
+ await arbi.fetch.GET("/v1/conversation/{conversation_ext_id}/threads", byId(conversationId)),
6414
+ "Failed to fetch the thread"
6415
+ );
6416
+ const wanted = new Set(responseIds);
6417
+ const out = {};
6418
+ for (const thread of data.threads ?? [])
6419
+ for (const m2 of thread.history ?? [])
6420
+ if (wanted.has(m2.external_id) && typeof m2.content === "string") out[m2.external_id] = m2.content;
6421
+ return out;
6422
+ }
6135
6423
 
6136
6424
  // src/operations/workflows.ts
6137
6425
  var workflows_exports = {};
@@ -7272,6 +7560,6 @@ function bytesToBase642(bytes) {
7272
7560
  return btoa(binary);
7273
7561
  }
7274
7562
 
7275
- export { Arbi, ArbiApiError, ArbiError, WebSocketAuthError, account_exports as account, agentconfig_exports as agentconfig, assistant_exports as assistant, authenticatedFetch, buildFactsContextTool, buildRetrievalChunkTool, buildRetrievalFullContextTool, buildRetrievalTocTool, connectWebSocket, connectWithReconnect, consumeSSEStream, contacts_exports as contacts, conversations_exports as conversations, countCitations, createAuthenticatedClient, dm_exports as dm, doctags_exports as doctags, documents_exports as documents, facts_exports as facts, files_exports as files, filterSkills, formatAgentStepLabel, formatFileSize, formatItemLabel, formatUserName, formatWorkspaceChoices, getErrorMessage, getRawWorkspaceKey, health_exports as health, identityErrorCode, identity_exports as identityVerification, mail_exports as mail, parseSSEEvents, parseSlashCommand, parseSlashTokenInProgress, performPasswordLogin, profile_exports as profile, projects_exports as projects, requireData, requireOk, resolveAuth, resolveCitations, resolveWorkspace, responses_exports as responses, selectWorkspace, selectWorkspaceById, sessions_exports as sessions, settings_exports as settings, streamSSE, stripCitationMarkdown, summarizeCitations, tags_exports as tags, work_exports as work, workflows_exports as workflows, workspaces_exports as workspaces };
7563
+ export { Arbi, ArbiApiError, ArbiError, PlanStepsError, WebSocketAuthError, account_exports as account, agentconfig_exports as agentconfig, assistant_exports as assistant, authenticatedFetch, buildFactsContextTool, buildRetrievalChunkTool, buildRetrievalFullContextTool, buildRetrievalTocTool, connectWebSocket, connectWithReconnect, consumeSSEStream, contacts_exports as contacts, conversations_exports as conversations, countCitations, createAuthenticatedClient, dm_exports as dm, doctags_exports as doctags, documents_exports as documents, facts_exports as facts, files_exports as files, filterSkills, formatAgentStepLabel, formatFileSize, formatItemLabel, formatUserName, formatWorkspaceChoices, getErrorMessage, getRawWorkspaceKey, health_exports as health, identityErrorCode, identity_exports as identityVerification, mail_exports as mail, parseSSEEvents, parseSlashCommand, parseSlashTokenInProgress, performPasswordLogin, profile_exports as profile, projects_exports as projects, requireData, requireOk, resolveAuth, resolveCitations, resolveWorkspace, responses_exports as responses, selectWorkspace, selectWorkspaceById, sessions_exports as sessions, settings_exports as settings, streamSSE, stripCitationMarkdown, summarizeCitations, tags_exports as tags, work_exports as work, workflow_steps_exports as workflowSteps, workflows_exports as workflows, workspaces_exports as workspaces };
7276
7564
  //# sourceMappingURL=browser.js.map
7277
7565
  //# sourceMappingURL=browser.js.map