@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.
package/dist/index.d.cts CHANGED
@@ -1,5 +1,5 @@
1
- import { t as ConfigStore, q as CliConfig, r as CliCredentials, C as ChatSession, at as SkippedFile, aF as UploadResult, m as AuthHeaders, aB as UploadBatchResult, aE as UploadOptions, aC as UploadDirectOptions, aD as UploadDirectResult, ar as SUPPORTED_EXTENSIONS, _ as MailAttachment, H as DmCryptoContext } from './browser-BBYaJCyB.cjs';
2
- export { A as ActivityKind, a as ActivityResponse, d as AgentStepEvent, e as Arbi, f as ArbiApiError, g as ArbiError, i as ArbiOptions, j as ArbiSessionExpiredError, k as ArtifactEvent, l as AuthContext, n as AuthMode, o as AuthenticatedClient, p as CitationSummary, s as CommandDescriptor, u as ConnectOptions, v as ConversationResponse, y as CreateWorkRequest, z as CreateWorkflowRequest, D as DOC_TERMINAL_STATUSES, B as DecryptedDmNotification, F as DmAttachmentFile, G as DmAttachmentInput, I as DocNameMap, J as DocumentAutomationAction, K as DocumentListFields, L as DocumentListOrder, M as DocumentSelector, N as DocumentWaiter, O as DocumentWaiterOptions, S as FormattedWsMessage, T as IdentityErrorCode, U as IdentityPurchase, V as IdentityState, W as IdentityStatus, X as ListAllOptions, Z as ListPaginatedOptions, $ as MessageLevel, a0 as MessageMetadataPayload, a1 as MessageQueuedEvent, a2 as OutputTokensDetails, a3 as ParsedSlashCommand, a4 as PendingAuthResponse, a5 as PlanWorkRequest, a7 as ProjectInvoicesResponse, a8 as ProjectUsageResponse, a9 as QueryOptions, aa as ReconnectOptions, ab as ReconnectableWsConnection, ac as ResolvedCitation, ad as ResolvedRecipient, 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, 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, aU as agents, aV as assistant, aW as authenticatedFetch, aX as buildDocNameMap, 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, b7 as createDocumentWaiter, 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, bh as formatStreamSummary, bi as formatUserName, bj as formatWorkspaceChoices, bk as formatWsMessage, bl as generateEncryptedWorkspaceKey, bm as generateNewWorkspaceKey, bn as getErrorCode, 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, by as performSigningKeyLogin, bz as performSsoDeviceFlowLogin, 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
+ import { t as ConfigStore, q as CliConfig, r as CliCredentials, C as ChatSession, ax as SkippedFile, aQ as UploadResult, m as AuthHeaders, aM as UploadBatchResult, aP as UploadOptions, aN as UploadDirectOptions, aO as UploadDirectResult, av as SUPPORTED_EXTENSIONS, _ as MailAttachment, H as DmCryptoContext } from './browser-DbhZr6hC.cjs';
2
+ export { A as ActivityKind, a as ActivityResponse, d as AgentStepEvent, e as Arbi, f as ArbiApiError, g as ArbiError, i as ArbiOptions, j as ArbiSessionExpiredError, k as ArtifactEvent, l as AuthContext, n as AuthMode, o as AuthenticatedClient, p as CitationSummary, s as CommandDescriptor, u as ConnectOptions, v as ConversationResponse, y as CreateWorkRequest, z as CreateWorkflowRequest, D as DOC_TERMINAL_STATUSES, B as DecryptedDmNotification, F as DmAttachmentFile, G as DmAttachmentInput, I as DocNameMap, J as DocumentAutomationAction, K as DocumentListFields, L as DocumentListOrder, M as DocumentSelector, N as DocumentWaiter, O as DocumentWaiterOptions, S as FormattedWsMessage, T as IdentityErrorCode, U as IdentityPurchase, V as IdentityState, W as IdentityStatus, X as ListAllOptions, Z as ListPaginatedOptions, $ as MessageLevel, a0 as MessageMetadataPayload, a1 as MessageQueuedEvent, a2 as OutputTokensDetails, a3 as ParsedSlashCommand, a4 as PendingAuthResponse, a5 as PlanStepsError, a6 as PlanWorkRequest, a8 as ProjectInvoicesResponse, a9 as ProjectUsageResponse, aa as QueryOptions, ab as ReconnectOptions, ac as ReconnectableWsConnection, ad as ResolvedCitation, ae as ResolvedRecipient, 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, 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, b3 as agents, b4 as assistant, b5 as authenticatedFetch, b6 as buildDocNameMap, 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, bi as createDocumentWaiter, 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, bs as formatStreamSummary, bt as formatUserName, bu as formatWorkspaceChoices, bv as formatWsMessage, bw as generateEncryptedWorkspaceKey, bx as generateNewWorkspaceKey, by as getErrorCode, 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, bJ as performSigningKeyLogin, bK as performSsoDeviceFlowLogin, 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';
3
3
  import { SessionStorageProvider, ArbiClient } from '@arbidocs/client';
4
4
  export { LoginProfile } from '@arbidocs/client';
5
5
 
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { t as ConfigStore, q as CliConfig, r as CliCredentials, C as ChatSession, at as SkippedFile, aF as UploadResult, m as AuthHeaders, aB as UploadBatchResult, aE as UploadOptions, aC as UploadDirectOptions, aD as UploadDirectResult, ar as SUPPORTED_EXTENSIONS, _ as MailAttachment, H as DmCryptoContext } from './browser-BBYaJCyB.js';
2
- export { A as ActivityKind, a as ActivityResponse, d as AgentStepEvent, e as Arbi, f as ArbiApiError, g as ArbiError, i as ArbiOptions, j as ArbiSessionExpiredError, k as ArtifactEvent, l as AuthContext, n as AuthMode, o as AuthenticatedClient, p as CitationSummary, s as CommandDescriptor, u as ConnectOptions, v as ConversationResponse, y as CreateWorkRequest, z as CreateWorkflowRequest, D as DOC_TERMINAL_STATUSES, B as DecryptedDmNotification, F as DmAttachmentFile, G as DmAttachmentInput, I as DocNameMap, J as DocumentAutomationAction, K as DocumentListFields, L as DocumentListOrder, M as DocumentSelector, N as DocumentWaiter, O as DocumentWaiterOptions, S as FormattedWsMessage, T as IdentityErrorCode, U as IdentityPurchase, V as IdentityState, W as IdentityStatus, X as ListAllOptions, Z as ListPaginatedOptions, $ as MessageLevel, a0 as MessageMetadataPayload, a1 as MessageQueuedEvent, a2 as OutputTokensDetails, a3 as ParsedSlashCommand, a4 as PendingAuthResponse, a5 as PlanWorkRequest, a7 as ProjectInvoicesResponse, a8 as ProjectUsageResponse, a9 as QueryOptions, aa as ReconnectOptions, ab as ReconnectableWsConnection, ac as ResolvedCitation, ad as ResolvedRecipient, 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, 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, aU as agents, aV as assistant, aW as authenticatedFetch, aX as buildDocNameMap, 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, b7 as createDocumentWaiter, 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, bh as formatStreamSummary, bi as formatUserName, bj as formatWorkspaceChoices, bk as formatWsMessage, bl as generateEncryptedWorkspaceKey, bm as generateNewWorkspaceKey, bn as getErrorCode, 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, by as performSigningKeyLogin, bz as performSsoDeviceFlowLogin, 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
+ import { t as ConfigStore, q as CliConfig, r as CliCredentials, C as ChatSession, ax as SkippedFile, aQ as UploadResult, m as AuthHeaders, aM as UploadBatchResult, aP as UploadOptions, aN as UploadDirectOptions, aO as UploadDirectResult, av as SUPPORTED_EXTENSIONS, _ as MailAttachment, H as DmCryptoContext } from './browser-DbhZr6hC.js';
2
+ export { A as ActivityKind, a as ActivityResponse, d as AgentStepEvent, e as Arbi, f as ArbiApiError, g as ArbiError, i as ArbiOptions, j as ArbiSessionExpiredError, k as ArtifactEvent, l as AuthContext, n as AuthMode, o as AuthenticatedClient, p as CitationSummary, s as CommandDescriptor, u as ConnectOptions, v as ConversationResponse, y as CreateWorkRequest, z as CreateWorkflowRequest, D as DOC_TERMINAL_STATUSES, B as DecryptedDmNotification, F as DmAttachmentFile, G as DmAttachmentInput, I as DocNameMap, J as DocumentAutomationAction, K as DocumentListFields, L as DocumentListOrder, M as DocumentSelector, N as DocumentWaiter, O as DocumentWaiterOptions, S as FormattedWsMessage, T as IdentityErrorCode, U as IdentityPurchase, V as IdentityState, W as IdentityStatus, X as ListAllOptions, Z as ListPaginatedOptions, $ as MessageLevel, a0 as MessageMetadataPayload, a1 as MessageQueuedEvent, a2 as OutputTokensDetails, a3 as ParsedSlashCommand, a4 as PendingAuthResponse, a5 as PlanStepsError, a6 as PlanWorkRequest, a8 as ProjectInvoicesResponse, a9 as ProjectUsageResponse, aa as QueryOptions, ab as ReconnectOptions, ac as ReconnectableWsConnection, ad as ResolvedCitation, ae as ResolvedRecipient, 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, 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, b3 as agents, b4 as assistant, b5 as authenticatedFetch, b6 as buildDocNameMap, 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, bi as createDocumentWaiter, 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, bs as formatStreamSummary, bt as formatUserName, bu as formatWorkspaceChoices, bv as formatWsMessage, bw as generateEncryptedWorkspaceKey, bx as generateNewWorkspaceKey, by as getErrorCode, 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, bJ as performSigningKeyLogin, bK as performSsoDeviceFlowLogin, 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';
3
3
  import { SessionStorageProvider, ArbiClient } from '@arbidocs/client';
4
4
  export { LoginProfile } from '@arbidocs/client';
5
5
 
package/dist/index.js CHANGED
@@ -6621,12 +6621,267 @@ __export(work_exports, {
6621
6621
  actOnStep: () => actOnStep,
6622
6622
  createWork: () => createWork,
6623
6623
  getActivity: () => getActivity,
6624
+ getConversation: () => getConversation,
6624
6625
  getPendingAuth: () => getPendingAuth,
6626
+ getRunProgress: () => getRunProgress,
6627
+ getStepAnswers: () => getStepAnswers,
6625
6628
  notifyConversation: () => notifyConversation,
6626
6629
  planWork: () => planWork,
6627
6630
  runConversation: () => runConversation,
6628
6631
  updateConversation: () => updateConversation
6629
6632
  });
6633
+
6634
+ // src/workflow-steps.ts
6635
+ var workflow_steps_exports = {};
6636
+ __export(workflow_steps_exports, {
6637
+ PERSON_STEP_KINDS: () => PERSON_STEP_KINDS,
6638
+ PlanStepsError: () => PlanStepsError,
6639
+ STEP_ID_PATTERN: () => STEP_ID_PATTERN,
6640
+ STEP_KINDS: () => STEP_KINDS,
6641
+ isPersonStep: () => isPersonStep,
6642
+ missingRequiredFields: () => missingRequiredFields,
6643
+ parseInputPairs: () => parseInputPairs,
6644
+ parsePlanSteps: () => parsePlanSteps,
6645
+ runSteps: () => runSteps,
6646
+ runWaitingOn: () => runWaitingOn,
6647
+ stepDependencies: () => stepDependencies,
6648
+ stepFields: () => stepFields,
6649
+ stepPhase: () => stepPhase,
6650
+ stepStatesFromActivity: () => stepStatesFromActivity,
6651
+ stepsPlan: () => stepsPlan
6652
+ });
6653
+ var STEP_KINDS = ["form", "upload", "agent", "review"];
6654
+ var PERSON_STEP_KINDS = ["form", "upload", "review"];
6655
+ var STEP_ID_PATTERN = /^[a-z][a-z0-9_-]{0,63}$/;
6656
+ var STEP_EVENTS = {
6657
+ step_started: "running",
6658
+ step_done: "done",
6659
+ step_skipped: "skipped",
6660
+ step_failed: "failed"
6661
+ };
6662
+ var isFinished = (state) => state?.status === "done" || state?.status === "skipped";
6663
+ var isPersonStep = (step) => PERSON_STEP_KINDS.includes(step.kind);
6664
+ function stepDependencies(steps, id) {
6665
+ const i2 = steps.findIndex((s2) => s2.id === id);
6666
+ if (i2 < 0) return [];
6667
+ const after = steps[i2].after;
6668
+ if (after !== null && after !== void 0) return [...after];
6669
+ return i2 > 0 ? [steps[i2 - 1].id] : [];
6670
+ }
6671
+ function dependsOn(steps, a2, b2) {
6672
+ const seen = /* @__PURE__ */ new Set();
6673
+ const stack = stepDependencies(steps, a2);
6674
+ while (stack.length) {
6675
+ const id = stack.pop();
6676
+ if (id === b2) return true;
6677
+ if (seen.has(id)) continue;
6678
+ seen.add(id);
6679
+ stack.push(...stepDependencies(steps, id));
6680
+ }
6681
+ return false;
6682
+ }
6683
+ function stepStatesFromActivity(events) {
6684
+ const states = {};
6685
+ for (const e of events) {
6686
+ const status = STEP_EVENTS[e.kind];
6687
+ const step = e.detail?.step;
6688
+ if (!status || typeof step !== "string") continue;
6689
+ const responseId = typeof e.detail?.response_id === "string" ? e.detail.response_id : null;
6690
+ const error = typeof e.detail?.error === "string" ? e.detail.error : null;
6691
+ states[step] = { status, responseId: responseId ?? states[step]?.responseId ?? null, error };
6692
+ }
6693
+ return states;
6694
+ }
6695
+ function stepPhase(steps, states, id) {
6696
+ const state = states[id];
6697
+ if (state && state.status !== "pending") return state.status;
6698
+ return stepDependencies(steps, id).every((d2) => isFinished(states[d2])) ? "ready" : "pending";
6699
+ }
6700
+ function runSteps(steps, events) {
6701
+ const states = stepStatesFromActivity(events);
6702
+ return steps.map((s2) => ({
6703
+ id: s2.id,
6704
+ title: s2.title,
6705
+ kind: s2.kind,
6706
+ phase: stepPhase(steps, states, s2.id),
6707
+ after: stepDependencies(steps, s2.id),
6708
+ responseId: states[s2.id]?.responseId ?? null,
6709
+ error: states[s2.id]?.error ?? null
6710
+ }));
6711
+ }
6712
+ function runWaitingOn(run) {
6713
+ if (run.length > 0 && run.every((s2) => s2.phase === "done" || s2.phase === "skipped"))
6714
+ return "finished";
6715
+ if (run.some((s2) => s2.phase === "running" || s2.kind === "agent" && s2.phase === "ready"))
6716
+ return "agent";
6717
+ if (run.some((s2) => s2.kind !== "agent" && s2.phase === "ready")) return "person";
6718
+ return "stuck";
6719
+ }
6720
+ function stepFields(step) {
6721
+ if (step.kind !== "form") return [];
6722
+ const fields = step.ui?.fields;
6723
+ return Array.isArray(fields) ? fields : [];
6724
+ }
6725
+ var blank = (value) => value === void 0 || value === null || typeof value === "string" && value.trim() === "";
6726
+ function missingRequiredFields(step, inputs) {
6727
+ return stepFields(step).filter((f2) => f2.required && blank(inputs[f2.name])).map((f2) => f2.name);
6728
+ }
6729
+ function parseInputPairs(pairs, fields = []) {
6730
+ const types = new Map(fields.map((f2) => [f2.name, f2.type]));
6731
+ const out = {};
6732
+ for (const pair of pairs) {
6733
+ const eq = pair.indexOf("=");
6734
+ if (eq <= 0) throw new Error(`Invalid input "${pair}": use name=value`);
6735
+ const name = pair.slice(0, eq).trim();
6736
+ const raw = pair.slice(eq + 1);
6737
+ const type = types.get(name);
6738
+ if (type === "number") {
6739
+ const n2 = Number(raw);
6740
+ if (raw.trim() === "" || Number.isNaN(n2))
6741
+ throw new Error(`Input "${name}" must be a number, got "${raw}"`);
6742
+ out[name] = n2;
6743
+ } else if (type === "boolean") {
6744
+ if (!["true", "false"].includes(raw.toLowerCase()))
6745
+ throw new Error(`Input "${name}" must be true or false, got "${raw}"`);
6746
+ out[name] = raw.toLowerCase() === "true";
6747
+ } else out[name] = raw;
6748
+ }
6749
+ return out;
6750
+ }
6751
+ var STEP_KEYS = /* @__PURE__ */ new Set([
6752
+ "id",
6753
+ "title",
6754
+ "kind",
6755
+ "after",
6756
+ "skill",
6757
+ "prompt",
6758
+ "inputs",
6759
+ "branch",
6760
+ "requires_files",
6761
+ "ui"
6762
+ ]);
6763
+ var isRecord = (v2) => typeof v2 === "object" && v2 !== null && !Array.isArray(v2);
6764
+ var PlanStepsError = class extends Error {
6765
+ constructor(problems) {
6766
+ super(`Invalid workflow steps:
6767
+ ${problems.map((p2) => ` - ${p2}`).join("\n")}`);
6768
+ this.problems = problems;
6769
+ this.name = "PlanStepsError";
6770
+ }
6771
+ problems;
6772
+ };
6773
+ function checkStep(raw, at2, problems) {
6774
+ if (!isRecord(raw)) {
6775
+ problems.push(`${at2}: must be an object with id, title and kind`);
6776
+ return null;
6777
+ }
6778
+ const before = problems.length;
6779
+ for (const key of Object.keys(raw))
6780
+ if (!STEP_KEYS.has(key))
6781
+ problems.push(`${at2}.${key}: unknown field (allowed: ${[...STEP_KEYS].join(", ")})`);
6782
+ const { id, title, kind, after, skill, prompt, inputs, branch, ui } = raw;
6783
+ if (typeof id !== "string" || !STEP_ID_PATTERN.test(id))
6784
+ problems.push(
6785
+ `${at2}.id: must be lowercase letters, digits, "_" or "-", starting with a letter (got ${JSON.stringify(id)})`
6786
+ );
6787
+ if (typeof title !== "string" || !title.trim()) problems.push(`${at2}.title: required text`);
6788
+ if (typeof kind !== "string" || !STEP_KINDS.includes(kind))
6789
+ problems.push(
6790
+ `${at2}.kind: must be one of ${STEP_KINDS.join(", ")} (got ${JSON.stringify(kind)})`
6791
+ );
6792
+ if (after !== void 0 && after !== null) {
6793
+ if (!Array.isArray(after) || after.some((d2) => typeof d2 !== "string"))
6794
+ problems.push(`${at2}.after: must be a list of step ids`);
6795
+ }
6796
+ for (const [key, value] of [
6797
+ ["skill", skill],
6798
+ ["prompt", prompt]
6799
+ ])
6800
+ if (value !== void 0 && value !== null && typeof value !== "string")
6801
+ problems.push(`${at2}.${key}: must be text`);
6802
+ if (inputs !== void 0 && inputs !== null) {
6803
+ if (!isRecord(inputs) || Object.values(inputs).some((v2) => typeof v2 !== "string"))
6804
+ problems.push(
6805
+ `${at2}.inputs: must map each skill input to a text template, e.g. {"q": "{{topic}}"}`
6806
+ );
6807
+ }
6808
+ if (branch !== void 0 && typeof branch !== "boolean")
6809
+ problems.push(`${at2}.branch: true or false`);
6810
+ if (ui !== void 0 && ui !== null && !isRecord(ui)) problems.push(`${at2}.ui: must be an object`);
6811
+ if (kind === "agent") {
6812
+ const hasSkill = typeof skill === "string" && skill.trim() !== "";
6813
+ const hasPrompt = typeof prompt === "string" && prompt.trim() !== "";
6814
+ if (!hasSkill && !hasPrompt) problems.push(`${at2}: an agent step needs a prompt or a skill`);
6815
+ if (hasSkill && hasPrompt)
6816
+ problems.push(`${at2}: an agent step runs a prompt or a skill, not both`);
6817
+ } else if (typeof kind === "string" && STEP_KINDS.includes(kind)) {
6818
+ for (const [key, value] of [
6819
+ ["skill", skill],
6820
+ ["prompt", prompt],
6821
+ ["inputs", inputs]
6822
+ ])
6823
+ if (value !== void 0 && value !== null)
6824
+ problems.push(`${at2}.${key}: only agent steps have a ${key} (this is a ${kind} step)`);
6825
+ if (branch) problems.push(`${at2}.branch: only agent steps can branch`);
6826
+ }
6827
+ if (kind === "form" && isRecord(ui) && ui.fields !== void 0) {
6828
+ if (!Array.isArray(ui.fields)) problems.push(`${at2}.ui.fields: must be a list of fields`);
6829
+ else
6830
+ ui.fields.forEach((f2, j2) => {
6831
+ if (!isRecord(f2) || typeof f2.name !== "string" || !/^[a-z][a-z0-9_]*$/i.test(f2.name))
6832
+ problems.push(`${at2}.ui.fields[${j2}].name: a field needs a name like "client_name"`);
6833
+ });
6834
+ }
6835
+ if (problems.length > before) return null;
6836
+ const fields = kind === "form" && isRecord(ui) && Array.isArray(ui.fields) ? ui.fields.map((f2) => ({
6837
+ ...f2,
6838
+ type: typeof f2.type === "string" ? f2.type : "text",
6839
+ label: typeof f2.label === "string" ? f2.label : f2.name
6840
+ })) : void 0;
6841
+ return {
6842
+ id,
6843
+ title: title.trim(),
6844
+ kind,
6845
+ after: after ?? null,
6846
+ skill: skill ?? null,
6847
+ prompt: prompt ?? null,
6848
+ inputs: inputs ?? null,
6849
+ branch: !!branch,
6850
+ requires_files: !!raw.requires_files,
6851
+ ui: isRecord(ui) ? { ...ui, ...fields ? { fields } : {} } : null
6852
+ };
6853
+ }
6854
+ function parsePlanSteps(value) {
6855
+ const list = isRecord(value) ? value.steps : value;
6856
+ if (!Array.isArray(list))
6857
+ throw new PlanStepsError(['expected a list of steps, or an object with a "steps" list']);
6858
+ if (list.length === 0) throw new PlanStepsError(["a workflow needs at least one step"]);
6859
+ const problems = [];
6860
+ const steps = list.map((raw, i2) => checkStep(raw, `steps[${i2}]`, problems));
6861
+ if (problems.length) throw new PlanStepsError(problems);
6862
+ const valid = steps;
6863
+ const ids = /* @__PURE__ */ new Set();
6864
+ valid.forEach((s2, i2) => {
6865
+ if (ids.has(s2.id)) problems.push(`steps[${i2}].id: "${s2.id}" is used twice`);
6866
+ ids.add(s2.id);
6867
+ });
6868
+ valid.forEach((s2, i2) => {
6869
+ for (const d2 of stepDependencies(valid, s2.id)) {
6870
+ if (!ids.has(d2)) problems.push(`steps[${i2}].after: no step "${d2}"`);
6871
+ else if (d2 === s2.id || dependsOn(valid, d2, s2.id))
6872
+ problems.push(`steps[${i2}].after: "${s2.id}" and "${d2}" wait for each other`);
6873
+ else if (valid.findIndex((x2) => x2.id === d2) > i2)
6874
+ problems.push(`steps[${i2}].after: "${d2}" must come before "${s2.id}" in the list`);
6875
+ }
6876
+ });
6877
+ if (problems.length) throw new PlanStepsError(problems);
6878
+ return valid;
6879
+ }
6880
+ function stepsPlan(steps) {
6881
+ return { goal: "", criteria: [], max_passes: 3, documents: [], steps };
6882
+ }
6883
+
6884
+ // src/operations/work.ts
6630
6885
  var byId = (conversationId) => ({
6631
6886
  params: { path: { conversation_ext_id: conversationId } }
6632
6887
  });
@@ -6690,6 +6945,39 @@ async function planWork(arbi, body) {
6690
6945
  "Failed to draft a plan"
6691
6946
  );
6692
6947
  }
6948
+ async function getConversation(arbi, conversationId) {
6949
+ const all = requireData(
6950
+ await arbi.fetch.GET("/v1/conversation/list"),
6951
+ "Failed to fetch conversations"
6952
+ );
6953
+ const found = all.find((c2) => c2.external_id === conversationId);
6954
+ if (!found) throw new Error(`No conversation ${conversationId} in this workspace`);
6955
+ return found;
6956
+ }
6957
+ async function getRunProgress(arbi, conversationId) {
6958
+ const [conversation, activity] = await Promise.all([
6959
+ getConversation(arbi, conversationId),
6960
+ getActivity(arbi, conversationId)
6961
+ ]);
6962
+ const plan = conversation.plan?.steps ?? [];
6963
+ if (!plan.length)
6964
+ throw new Error(`${conversationId} is not a stepped workflow run (its plan has no steps)`);
6965
+ const steps = runSteps(plan, activity);
6966
+ return { conversation, steps, waitingOn: runWaitingOn(steps) };
6967
+ }
6968
+ async function getStepAnswers(arbi, conversationId, responseIds) {
6969
+ if (!responseIds.length) return {};
6970
+ const data = requireData(
6971
+ await arbi.fetch.GET("/v1/conversation/{conversation_ext_id}/threads", byId(conversationId)),
6972
+ "Failed to fetch the thread"
6973
+ );
6974
+ const wanted = new Set(responseIds);
6975
+ const out = {};
6976
+ for (const thread of data.threads ?? [])
6977
+ for (const m2 of thread.history ?? [])
6978
+ if (wanted.has(m2.external_id) && typeof m2.content === "string") out[m2.external_id] = m2.content;
6979
+ return out;
6980
+ }
6693
6981
 
6694
6982
  // src/operations/workflows.ts
6695
6983
  var workflows_exports = {};
@@ -8892,6 +9180,6 @@ async function startDmListener(options) {
8892
9180
  };
8893
9181
  }
8894
9182
 
8895
- export { Arbi, ArbiApiError, ArbiError, ArbiSessionExpiredError, ClaudeOrchestrator, DOC_TERMINAL_STATUSES, FileConfigStore, OpenClawOrchestrator, WebSocketAuthError, account_exports as account, agentconfig_exports as agentconfig, agents_exports as agents, assistant_exports as assistant, authenticatedFetch, buildDocNameMap, buildFactsContextTool, buildRetrievalChunkTool, buildRetrievalFullContextTool, buildRetrievalTocTool, connectWebSocket, connectWithReconnect, consumeSSEStream, contacts_exports as contacts, conversations_exports as conversations, countCitations, createAuthenticatedClient, createDocumentWaiter, device_flow_exports as deviceFlow, dm_exports as dm, doctags_exports as doctags, documents_exports as documents, documents_node_exports as documentsNode, facts_exports as facts, files_exports as files, filterSkills, formatAgentStepLabel, formatFileSize, formatItemLabel, formatStreamSummary, formatUserName, formatWorkspaceChoices, formatWsMessage, generateEncryptedWorkspaceKey, generateNewWorkspaceKey, getErrorCode, getErrorMessage, getRawWorkspaceKey, health_exports as health, identityErrorCode, identity_exports as identityVerification, listen_exports as listen, mail_exports as mail, mail_node_exports as mailNode, parseSSEEvents, parseSlashCommand, parseSlashTokenInProgress, performPasswordLogin, performSigningKeyLogin, performSsoDeviceFlowLogin, 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, startDmListener, streamSSE, stripCitationMarkdown, summarizeCitations, tags_exports as tags, work_exports as work, workflows_exports as workflows, workspaces_exports as workspaces };
9183
+ export { Arbi, ArbiApiError, ArbiError, ArbiSessionExpiredError, ClaudeOrchestrator, DOC_TERMINAL_STATUSES, FileConfigStore, OpenClawOrchestrator, PlanStepsError, WebSocketAuthError, account_exports as account, agentconfig_exports as agentconfig, agents_exports as agents, assistant_exports as assistant, authenticatedFetch, buildDocNameMap, buildFactsContextTool, buildRetrievalChunkTool, buildRetrievalFullContextTool, buildRetrievalTocTool, connectWebSocket, connectWithReconnect, consumeSSEStream, contacts_exports as contacts, conversations_exports as conversations, countCitations, createAuthenticatedClient, createDocumentWaiter, device_flow_exports as deviceFlow, dm_exports as dm, doctags_exports as doctags, documents_exports as documents, documents_node_exports as documentsNode, facts_exports as facts, files_exports as files, filterSkills, formatAgentStepLabel, formatFileSize, formatItemLabel, formatStreamSummary, formatUserName, formatWorkspaceChoices, formatWsMessage, generateEncryptedWorkspaceKey, generateNewWorkspaceKey, getErrorCode, getErrorMessage, getRawWorkspaceKey, health_exports as health, identityErrorCode, identity_exports as identityVerification, listen_exports as listen, mail_exports as mail, mail_node_exports as mailNode, parseSSEEvents, parseSlashCommand, parseSlashTokenInProgress, performPasswordLogin, performSigningKeyLogin, performSsoDeviceFlowLogin, 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, startDmListener, streamSSE, stripCitationMarkdown, summarizeCitations, tags_exports as tags, work_exports as work, workflow_steps_exports as workflowSteps, workflows_exports as workflows, workspaces_exports as workspaces };
8896
9184
  //# sourceMappingURL=index.js.map
8897
9185
  //# sourceMappingURL=index.js.map