wauldo 0.11.0 → 0.13.0

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.mts CHANGED
@@ -695,6 +695,50 @@ interface AgentRunResponse {
695
695
  status: string;
696
696
  created_at: number;
697
697
  }
698
+ /**
699
+ * Immutable snapshot of an agent's `AgentContractV2` payload, content-addressed
700
+ * via SHA-256 and identified by a monotone `rev` integer. Mirrors AWS ECS
701
+ * task-definition revisions: append-only, O(1) rollback via `setActiveRevision`.
702
+ */
703
+ interface AgentRevision {
704
+ rev: number;
705
+ sha256: string;
706
+ contract_json: string;
707
+ created_at: number;
708
+ message?: string;
709
+ created_by?: string;
710
+ }
711
+ interface CreateRevisionInput {
712
+ /** Full `AgentContractV2` JSON payload (same shape as `custom_preset` on POST /v1/agents). */
713
+ customPreset: Record<string, unknown>;
714
+ /** Optional commit-message-style note (≤256 chars). */
715
+ message?: string;
716
+ /** When `true` (default) the new revision becomes active immediately. */
717
+ setActive?: boolean;
718
+ }
719
+ interface CreateRevisionResponse {
720
+ rev: number;
721
+ sha256: string;
722
+ active_rev: number;
723
+ }
724
+ interface ListRevisionsResponse {
725
+ revisions: AgentRevision[];
726
+ active_rev: number;
727
+ head_rev: number;
728
+ count: number;
729
+ }
730
+ /**
731
+ * Result of `shareTask` / `unshareTask`.
732
+ *
733
+ * `expiresAt` is epoch milliseconds, or `null` for paid tenants
734
+ * (no expiration). Free-tier shares default to a 30-day TTL ; once
735
+ * elapsed, the public `GET /v1/runs/<shareId>` returns 404.
736
+ */
737
+ interface ShareResponse {
738
+ share_id: string;
739
+ url: string;
740
+ expires_at: number | null;
741
+ }
698
742
  interface A2aResponse {
699
743
  task_id: string;
700
744
  agent_id: string;
@@ -801,12 +845,54 @@ declare class AgentsClient {
801
845
  get(agentId: string): Promise<DeployedAgent>;
802
846
  update(agentId: string, patch: UpdateAgentPatch): Promise<DeployedAgent>;
803
847
  delete(agentId: string): Promise<void>;
848
+ /**
849
+ * `POST /v1/agents/:id/revisions` — mint an immutable revision.
850
+ *
851
+ * The server validates `customPreset` (size, depth, states, cycle, tools,
852
+ * quota) and stores an immutable snapshot keyed by SHA-256. When
853
+ * `setActive` is `true` (default) the new revision becomes the agent's
854
+ * live revision; `false` stages it for review.
855
+ */
856
+ createRevision(agentId: string, input: CreateRevisionInput): Promise<CreateRevisionResponse>;
857
+ /** `GET /v1/agents/:id/revisions` — list revisions newest-first. */
858
+ listRevisions(agentId: string): Promise<ListRevisionsResponse>;
859
+ /** `GET /v1/agents/:id/revisions/:rev` — fetch one revision verbatim. */
860
+ getRevision(agentId: string, rev: number): Promise<AgentRevision>;
861
+ /**
862
+ * `PATCH /v1/agents/:id/active-revision` — O(1) rollback / promotion.
863
+ *
864
+ * No LLM cost — the revision is already validated and stored. Use this
865
+ * to roll back to a previous good revision when the current one breaks
866
+ * in production.
867
+ */
868
+ setActiveRevision(agentId: string, rev: number): Promise<DeployedAgent>;
804
869
  run(agentId: string, input: string, verificationMode?: "strict" | "balanced" | "permissive", factCheckMode?: "lexical" | "hybrid" | "semantic"): Promise<AgentRunResponse>;
805
870
  a2aInvoke(agentId: string, input: string, trace?: string[], verificationMode?: "strict" | "balanced" | "permissive", factCheckMode?: "lexical" | "hybrid" | "semantic"): Promise<A2aResponse>;
806
871
  /** `GET /v1/tasks/:id` — fetch the current state of a task. */
807
872
  getTask(taskId: string): Promise<Task>;
808
873
  /** `DELETE /v1/tasks/:id` — cancel a queued or running task. */
809
874
  cancelTask(taskId: string): Promise<void>;
875
+ /**
876
+ * `POST /v1/tasks/:id/share` — publish a run as a public URL.
877
+ *
878
+ * Idempotent : calling on an already-shared task returns the existing
879
+ * `ShareResponse` without bumping the per-tenant cap. The returned
880
+ * `url` (form `https://wauldo.com/r/<id>`) can be pasted anywhere —
881
+ * anyone with the link sees the verdict + claims + sources + timeline
882
+ * through a strict-whitelist projection (no `custom_preset` /
883
+ * `wauldo_toml` / system prompt / tool args ever leave the tenant).
884
+ *
885
+ * Free-tier tenants get a 30-day TTL ; paid tenants get
886
+ * `expires_at = null` (no expiration).
887
+ */
888
+ shareTask(taskId: string): Promise<ShareResponse>;
889
+ /**
890
+ * `DELETE /v1/tasks/:id/share` — make a published run private again.
891
+ *
892
+ * Idempotent : calling on a never-published task returns 204.
893
+ * Subsequent `GET /v1/runs/<shareId>` for the cleared id returns 404.
894
+ */
895
+ unshareTask(taskId: string): Promise<void>;
810
896
  /**
811
897
  * Poll `getTask` until the task reaches a terminal status. Resolves
812
898
  * with the final Task snapshot. Rejects with `Error("timeout")` if
@@ -833,6 +919,125 @@ declare class AgentsClient {
833
919
  streamTask(taskId: string): AsyncGenerator<StateTransition>;
834
920
  }
835
921
 
922
+ /**
923
+ * Workflows API client — Wauldo Workflow Runtime (Step Functions style).
924
+ *
925
+ * State-machine workflows authored as `Task` / `Choice` / `Wait` / `Pass` /
926
+ * `Fail` / `Succeed` states. Runs are async: `startRun` returns an
927
+ * `execution_id`, then poll `getRun` (or use `waitForRun`) until a terminal
928
+ * status.
929
+ *
930
+ * @example
931
+ * ```ts
932
+ * import { WorkflowsClient } from "wauldo/workflows";
933
+ * const wf = new WorkflowsClient({ baseUrl: "https://api.wauldo.com", apiKey: "..." });
934
+ * const created = await wf.create({
935
+ * name: "triage",
936
+ * startAt: "Compute",
937
+ * states: {
938
+ * Compute: { type: "Task", resource: "tool:calculator", next: "Done" },
939
+ * Done: { type: "Succeed" },
940
+ * },
941
+ * });
942
+ * const run = await wf.startRun(created.id, { operation: "add", a: 21, b: 21 });
943
+ * const final = await wf.waitForRun(created.id, run.execution_id);
944
+ * console.log(final.status, final.output);
945
+ * ```
946
+ */
947
+ interface WorkflowsClientConfig {
948
+ baseUrl: string;
949
+ apiKey?: string;
950
+ /** Tenant identifier forwarded via x-rapidapi-user header. */
951
+ tenant?: string;
952
+ /** Per-request timeout in ms. Default 120_000. */
953
+ timeoutMs?: number;
954
+ }
955
+ /** A workflow definition. */
956
+ interface Workflow {
957
+ id: string;
958
+ tenant_id: string;
959
+ name: string;
960
+ description?: string;
961
+ start_at: string;
962
+ states: Record<string, unknown>;
963
+ version: string;
964
+ created_at: number;
965
+ updated_at: number;
966
+ }
967
+ interface CreateWorkflowInput {
968
+ name: string;
969
+ startAt: string;
970
+ states: Record<string, unknown>;
971
+ description?: string;
972
+ }
973
+ interface WorkflowListResponse {
974
+ workflows: Workflow[];
975
+ }
976
+ /** 202 response from `POST /v1/workflows/:id/runs`. */
977
+ interface StartRunResponse {
978
+ execution_id: string;
979
+ workflow_id: string;
980
+ status: string;
981
+ }
982
+ /**
983
+ * A workflow execution record. `status` is one of `running`, `succeeded`,
984
+ * `failed`, `timed_out`. `output` is populated on success; `error` on
985
+ * terminal failure.
986
+ */
987
+ interface WorkflowExecution {
988
+ id: string;
989
+ workflow_id: string;
990
+ tenant_id: string;
991
+ status: string;
992
+ current_state?: string | null;
993
+ input: unknown;
994
+ output?: unknown;
995
+ started_at: number;
996
+ ended_at?: number | null;
997
+ error?: string | null;
998
+ }
999
+ declare const TERMINAL_WORKFLOW_STATUSES: readonly ["succeeded", "failed", "timed_out"];
1000
+ declare function isWorkflowRunTerminal(status: string): boolean;
1001
+ declare class WorkflowsClient {
1002
+ private readonly config;
1003
+ constructor(config: WorkflowsClientConfig);
1004
+ private headers;
1005
+ private request;
1006
+ /**
1007
+ * `POST /v1/workflows` — create a workflow definition.
1008
+ *
1009
+ * The server validates cycles, transition targets, choice operators,
1010
+ * and the per-tenant cap (100) before returning 201.
1011
+ */
1012
+ create(input: CreateWorkflowInput): Promise<Workflow>;
1013
+ /** `GET /v1/workflows` — list workflows for the calling tenant. */
1014
+ list(): Promise<WorkflowListResponse>;
1015
+ /** `GET /v1/workflows/:id` */
1016
+ get(workflowId: string): Promise<Workflow>;
1017
+ /** `DELETE /v1/workflows/:id` */
1018
+ delete(workflowId: string): Promise<void>;
1019
+ /**
1020
+ * `POST /v1/workflows/:id/runs` — start an async execution.
1021
+ *
1022
+ * Returns 202 with an `execution_id` immediately. Poll {@link getRun}
1023
+ * or use {@link waitForRun} to await completion.
1024
+ */
1025
+ startRun(workflowId: string, input?: unknown): Promise<StartRunResponse>;
1026
+ /** `GET /v1/workflows/:id/runs/:execution_id` — fetch one execution. */
1027
+ getRun(workflowId: string, executionId: string): Promise<WorkflowExecution>;
1028
+ /**
1029
+ * Poll {@link getRun} until the run reaches a terminal status.
1030
+ *
1031
+ * Rejects with an error if the run hasn't terminated within
1032
+ * `timeoutMs`. The server enforces its own 60s wall-clock cap per run,
1033
+ * so a timeout larger than ~75_000 is just slack for polling overhead.
1034
+ */
1035
+ waitForRun(workflowId: string, executionId: string, opts?: {
1036
+ timeoutMs?: number;
1037
+ pollIntervalMs?: number;
1038
+ }): Promise<WorkflowExecution>;
1039
+ }
1040
+
836
1041
  /**
837
1042
  * History API client — Wauldo Funnel #1 audit log.
838
1043
  *
@@ -941,4 +1146,4 @@ declare class HistoryClient {
941
1146
  deleteTask(taskId: string): Promise<number>;
942
1147
  }
943
1148
 
944
- export { type A2aResponse, AgentClient, type AgentListResponse, type AgentRunResponse, AgentsClient, type AgentsClientConfig, type CallToolResponse, type ChatChoice, type ChatClientLike, type ChatMessage, type ChatRequest, type ChatResponse, type ChatUsage, type Chunk, type ChunkResult, type ClientOptions, type Concept, type ConceptResult, ConnectionError, Conversation, type CreateAgentInput, type DeployedAgent, type DetailLevel, type EmbeddingData, type EmbeddingResponse, type EmbeddingUsage, type GraphNode, type GuardClaim, type GuardMode, type GuardResponse, HistoryClient, type HistoryClientConfig, type ExportOptions as HistoryExportOptions, type ListOptions as HistoryListOptions, type HistoryListResponse, HttpClient, type HttpClientConfig, HttpError, type KnowledgeGraphResult, type LogLevel, MockHttpClient, type ModelInfo, type ModelList, type OrchestratorResponse, type PlanOptions, type PlanResult, type PlanStep, type RagAuditInfo, type RagQueryResponse, type RagSource, type RagUploadResponse, type ReasoningOptions, type ReasoningResult, type RequestOptions, type RetrievalResult, ServerError, type SourceType, type StateTransition, type Task, type TaskClaim, type TaskHistoryEntry, type TaskStatus, type TaskVerification, TimeoutError, type ToolContent, type ToolDefinition, ToolNotFoundError, type UpdateAgentPatch, ValidationError, type Verdict, WauldoError, chatContent, guardIsBlocked, guardIsSafe, isTerminalStatus, supportScore };
1149
+ export { type A2aResponse, AgentClient, type AgentListResponse, type AgentRevision, type AgentRunResponse, AgentsClient, type AgentsClientConfig, type CallToolResponse, type ChatChoice, type ChatClientLike, type ChatMessage, type ChatRequest, type ChatResponse, type ChatUsage, type Chunk, type ChunkResult, type ClientOptions, type Concept, type ConceptResult, ConnectionError, Conversation, type CreateAgentInput, type CreateRevisionInput, type CreateRevisionResponse, type CreateWorkflowInput, type DeployedAgent, type DetailLevel, type EmbeddingData, type EmbeddingResponse, type EmbeddingUsage, type GraphNode, type GuardClaim, type GuardMode, type GuardResponse, HistoryClient, type HistoryClientConfig, type ExportOptions as HistoryExportOptions, type ListOptions as HistoryListOptions, type HistoryListResponse, HttpClient, type HttpClientConfig, HttpError, type KnowledgeGraphResult, type ListRevisionsResponse, type LogLevel, MockHttpClient, type ModelInfo, type ModelList, type OrchestratorResponse, type PlanOptions, type PlanResult, type PlanStep, type RagAuditInfo, type RagQueryResponse, type RagSource, type RagUploadResponse, type ReasoningOptions, type ReasoningResult, type RequestOptions, type RetrievalResult, ServerError, type SourceType, type StartRunResponse, type StateTransition, TERMINAL_WORKFLOW_STATUSES, type Task, type TaskClaim, type TaskHistoryEntry, type TaskStatus, type TaskVerification, TimeoutError, type ToolContent, type ToolDefinition, ToolNotFoundError, type UpdateAgentPatch, ValidationError, type Verdict, WauldoError, type Workflow, type WorkflowExecution, type WorkflowListResponse, WorkflowsClient, type WorkflowsClientConfig, chatContent, guardIsBlocked, guardIsSafe, isTerminalStatus, isWorkflowRunTerminal, supportScore };
package/dist/index.d.ts CHANGED
@@ -695,6 +695,50 @@ interface AgentRunResponse {
695
695
  status: string;
696
696
  created_at: number;
697
697
  }
698
+ /**
699
+ * Immutable snapshot of an agent's `AgentContractV2` payload, content-addressed
700
+ * via SHA-256 and identified by a monotone `rev` integer. Mirrors AWS ECS
701
+ * task-definition revisions: append-only, O(1) rollback via `setActiveRevision`.
702
+ */
703
+ interface AgentRevision {
704
+ rev: number;
705
+ sha256: string;
706
+ contract_json: string;
707
+ created_at: number;
708
+ message?: string;
709
+ created_by?: string;
710
+ }
711
+ interface CreateRevisionInput {
712
+ /** Full `AgentContractV2` JSON payload (same shape as `custom_preset` on POST /v1/agents). */
713
+ customPreset: Record<string, unknown>;
714
+ /** Optional commit-message-style note (≤256 chars). */
715
+ message?: string;
716
+ /** When `true` (default) the new revision becomes active immediately. */
717
+ setActive?: boolean;
718
+ }
719
+ interface CreateRevisionResponse {
720
+ rev: number;
721
+ sha256: string;
722
+ active_rev: number;
723
+ }
724
+ interface ListRevisionsResponse {
725
+ revisions: AgentRevision[];
726
+ active_rev: number;
727
+ head_rev: number;
728
+ count: number;
729
+ }
730
+ /**
731
+ * Result of `shareTask` / `unshareTask`.
732
+ *
733
+ * `expiresAt` is epoch milliseconds, or `null` for paid tenants
734
+ * (no expiration). Free-tier shares default to a 30-day TTL ; once
735
+ * elapsed, the public `GET /v1/runs/<shareId>` returns 404.
736
+ */
737
+ interface ShareResponse {
738
+ share_id: string;
739
+ url: string;
740
+ expires_at: number | null;
741
+ }
698
742
  interface A2aResponse {
699
743
  task_id: string;
700
744
  agent_id: string;
@@ -801,12 +845,54 @@ declare class AgentsClient {
801
845
  get(agentId: string): Promise<DeployedAgent>;
802
846
  update(agentId: string, patch: UpdateAgentPatch): Promise<DeployedAgent>;
803
847
  delete(agentId: string): Promise<void>;
848
+ /**
849
+ * `POST /v1/agents/:id/revisions` — mint an immutable revision.
850
+ *
851
+ * The server validates `customPreset` (size, depth, states, cycle, tools,
852
+ * quota) and stores an immutable snapshot keyed by SHA-256. When
853
+ * `setActive` is `true` (default) the new revision becomes the agent's
854
+ * live revision; `false` stages it for review.
855
+ */
856
+ createRevision(agentId: string, input: CreateRevisionInput): Promise<CreateRevisionResponse>;
857
+ /** `GET /v1/agents/:id/revisions` — list revisions newest-first. */
858
+ listRevisions(agentId: string): Promise<ListRevisionsResponse>;
859
+ /** `GET /v1/agents/:id/revisions/:rev` — fetch one revision verbatim. */
860
+ getRevision(agentId: string, rev: number): Promise<AgentRevision>;
861
+ /**
862
+ * `PATCH /v1/agents/:id/active-revision` — O(1) rollback / promotion.
863
+ *
864
+ * No LLM cost — the revision is already validated and stored. Use this
865
+ * to roll back to a previous good revision when the current one breaks
866
+ * in production.
867
+ */
868
+ setActiveRevision(agentId: string, rev: number): Promise<DeployedAgent>;
804
869
  run(agentId: string, input: string, verificationMode?: "strict" | "balanced" | "permissive", factCheckMode?: "lexical" | "hybrid" | "semantic"): Promise<AgentRunResponse>;
805
870
  a2aInvoke(agentId: string, input: string, trace?: string[], verificationMode?: "strict" | "balanced" | "permissive", factCheckMode?: "lexical" | "hybrid" | "semantic"): Promise<A2aResponse>;
806
871
  /** `GET /v1/tasks/:id` — fetch the current state of a task. */
807
872
  getTask(taskId: string): Promise<Task>;
808
873
  /** `DELETE /v1/tasks/:id` — cancel a queued or running task. */
809
874
  cancelTask(taskId: string): Promise<void>;
875
+ /**
876
+ * `POST /v1/tasks/:id/share` — publish a run as a public URL.
877
+ *
878
+ * Idempotent : calling on an already-shared task returns the existing
879
+ * `ShareResponse` without bumping the per-tenant cap. The returned
880
+ * `url` (form `https://wauldo.com/r/<id>`) can be pasted anywhere —
881
+ * anyone with the link sees the verdict + claims + sources + timeline
882
+ * through a strict-whitelist projection (no `custom_preset` /
883
+ * `wauldo_toml` / system prompt / tool args ever leave the tenant).
884
+ *
885
+ * Free-tier tenants get a 30-day TTL ; paid tenants get
886
+ * `expires_at = null` (no expiration).
887
+ */
888
+ shareTask(taskId: string): Promise<ShareResponse>;
889
+ /**
890
+ * `DELETE /v1/tasks/:id/share` — make a published run private again.
891
+ *
892
+ * Idempotent : calling on a never-published task returns 204.
893
+ * Subsequent `GET /v1/runs/<shareId>` for the cleared id returns 404.
894
+ */
895
+ unshareTask(taskId: string): Promise<void>;
810
896
  /**
811
897
  * Poll `getTask` until the task reaches a terminal status. Resolves
812
898
  * with the final Task snapshot. Rejects with `Error("timeout")` if
@@ -833,6 +919,125 @@ declare class AgentsClient {
833
919
  streamTask(taskId: string): AsyncGenerator<StateTransition>;
834
920
  }
835
921
 
922
+ /**
923
+ * Workflows API client — Wauldo Workflow Runtime (Step Functions style).
924
+ *
925
+ * State-machine workflows authored as `Task` / `Choice` / `Wait` / `Pass` /
926
+ * `Fail` / `Succeed` states. Runs are async: `startRun` returns an
927
+ * `execution_id`, then poll `getRun` (or use `waitForRun`) until a terminal
928
+ * status.
929
+ *
930
+ * @example
931
+ * ```ts
932
+ * import { WorkflowsClient } from "wauldo/workflows";
933
+ * const wf = new WorkflowsClient({ baseUrl: "https://api.wauldo.com", apiKey: "..." });
934
+ * const created = await wf.create({
935
+ * name: "triage",
936
+ * startAt: "Compute",
937
+ * states: {
938
+ * Compute: { type: "Task", resource: "tool:calculator", next: "Done" },
939
+ * Done: { type: "Succeed" },
940
+ * },
941
+ * });
942
+ * const run = await wf.startRun(created.id, { operation: "add", a: 21, b: 21 });
943
+ * const final = await wf.waitForRun(created.id, run.execution_id);
944
+ * console.log(final.status, final.output);
945
+ * ```
946
+ */
947
+ interface WorkflowsClientConfig {
948
+ baseUrl: string;
949
+ apiKey?: string;
950
+ /** Tenant identifier forwarded via x-rapidapi-user header. */
951
+ tenant?: string;
952
+ /** Per-request timeout in ms. Default 120_000. */
953
+ timeoutMs?: number;
954
+ }
955
+ /** A workflow definition. */
956
+ interface Workflow {
957
+ id: string;
958
+ tenant_id: string;
959
+ name: string;
960
+ description?: string;
961
+ start_at: string;
962
+ states: Record<string, unknown>;
963
+ version: string;
964
+ created_at: number;
965
+ updated_at: number;
966
+ }
967
+ interface CreateWorkflowInput {
968
+ name: string;
969
+ startAt: string;
970
+ states: Record<string, unknown>;
971
+ description?: string;
972
+ }
973
+ interface WorkflowListResponse {
974
+ workflows: Workflow[];
975
+ }
976
+ /** 202 response from `POST /v1/workflows/:id/runs`. */
977
+ interface StartRunResponse {
978
+ execution_id: string;
979
+ workflow_id: string;
980
+ status: string;
981
+ }
982
+ /**
983
+ * A workflow execution record. `status` is one of `running`, `succeeded`,
984
+ * `failed`, `timed_out`. `output` is populated on success; `error` on
985
+ * terminal failure.
986
+ */
987
+ interface WorkflowExecution {
988
+ id: string;
989
+ workflow_id: string;
990
+ tenant_id: string;
991
+ status: string;
992
+ current_state?: string | null;
993
+ input: unknown;
994
+ output?: unknown;
995
+ started_at: number;
996
+ ended_at?: number | null;
997
+ error?: string | null;
998
+ }
999
+ declare const TERMINAL_WORKFLOW_STATUSES: readonly ["succeeded", "failed", "timed_out"];
1000
+ declare function isWorkflowRunTerminal(status: string): boolean;
1001
+ declare class WorkflowsClient {
1002
+ private readonly config;
1003
+ constructor(config: WorkflowsClientConfig);
1004
+ private headers;
1005
+ private request;
1006
+ /**
1007
+ * `POST /v1/workflows` — create a workflow definition.
1008
+ *
1009
+ * The server validates cycles, transition targets, choice operators,
1010
+ * and the per-tenant cap (100) before returning 201.
1011
+ */
1012
+ create(input: CreateWorkflowInput): Promise<Workflow>;
1013
+ /** `GET /v1/workflows` — list workflows for the calling tenant. */
1014
+ list(): Promise<WorkflowListResponse>;
1015
+ /** `GET /v1/workflows/:id` */
1016
+ get(workflowId: string): Promise<Workflow>;
1017
+ /** `DELETE /v1/workflows/:id` */
1018
+ delete(workflowId: string): Promise<void>;
1019
+ /**
1020
+ * `POST /v1/workflows/:id/runs` — start an async execution.
1021
+ *
1022
+ * Returns 202 with an `execution_id` immediately. Poll {@link getRun}
1023
+ * or use {@link waitForRun} to await completion.
1024
+ */
1025
+ startRun(workflowId: string, input?: unknown): Promise<StartRunResponse>;
1026
+ /** `GET /v1/workflows/:id/runs/:execution_id` — fetch one execution. */
1027
+ getRun(workflowId: string, executionId: string): Promise<WorkflowExecution>;
1028
+ /**
1029
+ * Poll {@link getRun} until the run reaches a terminal status.
1030
+ *
1031
+ * Rejects with an error if the run hasn't terminated within
1032
+ * `timeoutMs`. The server enforces its own 60s wall-clock cap per run,
1033
+ * so a timeout larger than ~75_000 is just slack for polling overhead.
1034
+ */
1035
+ waitForRun(workflowId: string, executionId: string, opts?: {
1036
+ timeoutMs?: number;
1037
+ pollIntervalMs?: number;
1038
+ }): Promise<WorkflowExecution>;
1039
+ }
1040
+
836
1041
  /**
837
1042
  * History API client — Wauldo Funnel #1 audit log.
838
1043
  *
@@ -941,4 +1146,4 @@ declare class HistoryClient {
941
1146
  deleteTask(taskId: string): Promise<number>;
942
1147
  }
943
1148
 
944
- export { type A2aResponse, AgentClient, type AgentListResponse, type AgentRunResponse, AgentsClient, type AgentsClientConfig, type CallToolResponse, type ChatChoice, type ChatClientLike, type ChatMessage, type ChatRequest, type ChatResponse, type ChatUsage, type Chunk, type ChunkResult, type ClientOptions, type Concept, type ConceptResult, ConnectionError, Conversation, type CreateAgentInput, type DeployedAgent, type DetailLevel, type EmbeddingData, type EmbeddingResponse, type EmbeddingUsage, type GraphNode, type GuardClaim, type GuardMode, type GuardResponse, HistoryClient, type HistoryClientConfig, type ExportOptions as HistoryExportOptions, type ListOptions as HistoryListOptions, type HistoryListResponse, HttpClient, type HttpClientConfig, HttpError, type KnowledgeGraphResult, type LogLevel, MockHttpClient, type ModelInfo, type ModelList, type OrchestratorResponse, type PlanOptions, type PlanResult, type PlanStep, type RagAuditInfo, type RagQueryResponse, type RagSource, type RagUploadResponse, type ReasoningOptions, type ReasoningResult, type RequestOptions, type RetrievalResult, ServerError, type SourceType, type StateTransition, type Task, type TaskClaim, type TaskHistoryEntry, type TaskStatus, type TaskVerification, TimeoutError, type ToolContent, type ToolDefinition, ToolNotFoundError, type UpdateAgentPatch, ValidationError, type Verdict, WauldoError, chatContent, guardIsBlocked, guardIsSafe, isTerminalStatus, supportScore };
1149
+ export { type A2aResponse, AgentClient, type AgentListResponse, type AgentRevision, type AgentRunResponse, AgentsClient, type AgentsClientConfig, type CallToolResponse, type ChatChoice, type ChatClientLike, type ChatMessage, type ChatRequest, type ChatResponse, type ChatUsage, type Chunk, type ChunkResult, type ClientOptions, type Concept, type ConceptResult, ConnectionError, Conversation, type CreateAgentInput, type CreateRevisionInput, type CreateRevisionResponse, type CreateWorkflowInput, type DeployedAgent, type DetailLevel, type EmbeddingData, type EmbeddingResponse, type EmbeddingUsage, type GraphNode, type GuardClaim, type GuardMode, type GuardResponse, HistoryClient, type HistoryClientConfig, type ExportOptions as HistoryExportOptions, type ListOptions as HistoryListOptions, type HistoryListResponse, HttpClient, type HttpClientConfig, HttpError, type KnowledgeGraphResult, type ListRevisionsResponse, type LogLevel, MockHttpClient, type ModelInfo, type ModelList, type OrchestratorResponse, type PlanOptions, type PlanResult, type PlanStep, type RagAuditInfo, type RagQueryResponse, type RagSource, type RagUploadResponse, type ReasoningOptions, type ReasoningResult, type RequestOptions, type RetrievalResult, ServerError, type SourceType, type StartRunResponse, type StateTransition, TERMINAL_WORKFLOW_STATUSES, type Task, type TaskClaim, type TaskHistoryEntry, type TaskStatus, type TaskVerification, TimeoutError, type ToolContent, type ToolDefinition, ToolNotFoundError, type UpdateAgentPatch, ValidationError, type Verdict, WauldoError, type Workflow, type WorkflowExecution, type WorkflowListResponse, WorkflowsClient, type WorkflowsClientConfig, chatContent, guardIsBlocked, guardIsSafe, isTerminalStatus, isWorkflowRunTerminal, supportScore };
package/dist/index.js CHANGED
@@ -29,14 +29,17 @@ __export(index_exports, {
29
29
  HttpError: () => HttpError,
30
30
  MockHttpClient: () => MockHttpClient,
31
31
  ServerError: () => ServerError,
32
+ TERMINAL_WORKFLOW_STATUSES: () => TERMINAL_WORKFLOW_STATUSES,
32
33
  TimeoutError: () => TimeoutError,
33
34
  ToolNotFoundError: () => ToolNotFoundError,
34
35
  ValidationError: () => ValidationError,
35
36
  WauldoError: () => WauldoError,
37
+ WorkflowsClient: () => WorkflowsClient,
36
38
  chatContent: () => chatContent,
37
39
  guardIsBlocked: () => guardIsBlocked,
38
40
  guardIsSafe: () => guardIsSafe,
39
41
  isTerminalStatus: () => isTerminalStatus,
42
+ isWorkflowRunTerminal: () => isWorkflowRunTerminal,
40
43
  supportScore: () => supportScore
41
44
  });
42
45
  module.exports = __toCommonJS(index_exports);
@@ -1407,6 +1410,55 @@ var AgentsClient = class {
1407
1410
  async delete(agentId) {
1408
1411
  await this.request("DELETE", `/v1/agents/${agentId}`);
1409
1412
  }
1413
+ // ── Revisions (ECS-style versioning) ────────────────────────────
1414
+ /**
1415
+ * `POST /v1/agents/:id/revisions` — mint an immutable revision.
1416
+ *
1417
+ * The server validates `customPreset` (size, depth, states, cycle, tools,
1418
+ * quota) and stores an immutable snapshot keyed by SHA-256. When
1419
+ * `setActive` is `true` (default) the new revision becomes the agent's
1420
+ * live revision; `false` stages it for review.
1421
+ */
1422
+ async createRevision(agentId, input) {
1423
+ const body = {
1424
+ custom_preset: input.customPreset,
1425
+ set_active: input.setActive ?? true
1426
+ };
1427
+ if (input.message !== void 0) body.message = input.message;
1428
+ return await this.request(
1429
+ "POST",
1430
+ `/v1/agents/${agentId}/revisions`,
1431
+ body
1432
+ );
1433
+ }
1434
+ /** `GET /v1/agents/:id/revisions` — list revisions newest-first. */
1435
+ async listRevisions(agentId) {
1436
+ return await this.request(
1437
+ "GET",
1438
+ `/v1/agents/${agentId}/revisions`
1439
+ );
1440
+ }
1441
+ /** `GET /v1/agents/:id/revisions/:rev` — fetch one revision verbatim. */
1442
+ async getRevision(agentId, rev) {
1443
+ return await this.request(
1444
+ "GET",
1445
+ `/v1/agents/${agentId}/revisions/${rev}`
1446
+ );
1447
+ }
1448
+ /**
1449
+ * `PATCH /v1/agents/:id/active-revision` — O(1) rollback / promotion.
1450
+ *
1451
+ * No LLM cost — the revision is already validated and stored. Use this
1452
+ * to roll back to a previous good revision when the current one breaks
1453
+ * in production.
1454
+ */
1455
+ async setActiveRevision(agentId, rev) {
1456
+ return await this.request(
1457
+ "PATCH",
1458
+ `/v1/agents/${agentId}/active-revision`,
1459
+ { rev }
1460
+ );
1461
+ }
1410
1462
  // ── Runs ────────────────────────────────────────────────────────
1411
1463
  async run(agentId, input, verificationMode, factCheckMode) {
1412
1464
  if (!input) throw new Error("input is required");
@@ -1442,6 +1494,36 @@ var AgentsClient = class {
1442
1494
  async cancelTask(taskId) {
1443
1495
  await this.request("DELETE", `/v1/tasks/${taskId}`);
1444
1496
  }
1497
+ // ── Shareable runs ──────────────────────────────────────────────
1498
+ /**
1499
+ * `POST /v1/tasks/:id/share` — publish a run as a public URL.
1500
+ *
1501
+ * Idempotent : calling on an already-shared task returns the existing
1502
+ * `ShareResponse` without bumping the per-tenant cap. The returned
1503
+ * `url` (form `https://wauldo.com/r/<id>`) can be pasted anywhere —
1504
+ * anyone with the link sees the verdict + claims + sources + timeline
1505
+ * through a strict-whitelist projection (no `custom_preset` /
1506
+ * `wauldo_toml` / system prompt / tool args ever leave the tenant).
1507
+ *
1508
+ * Free-tier tenants get a 30-day TTL ; paid tenants get
1509
+ * `expires_at = null` (no expiration).
1510
+ */
1511
+ async shareTask(taskId) {
1512
+ return await this.request(
1513
+ "POST",
1514
+ `/v1/tasks/${taskId}/share`,
1515
+ {}
1516
+ );
1517
+ }
1518
+ /**
1519
+ * `DELETE /v1/tasks/:id/share` — make a published run private again.
1520
+ *
1521
+ * Idempotent : calling on a never-published task returns 204.
1522
+ * Subsequent `GET /v1/runs/<shareId>` for the cleared id returns 404.
1523
+ */
1524
+ async unshareTask(taskId) {
1525
+ await this.request("DELETE", `/v1/tasks/${taskId}/share`);
1526
+ }
1445
1527
  /**
1446
1528
  * Poll `getTask` until the task reaches a terminal status. Resolves
1447
1529
  * with the final Task snapshot. Rejects with `Error("timeout")` if
@@ -1520,6 +1602,133 @@ var AgentsClient = class {
1520
1602
  }
1521
1603
  };
1522
1604
 
1605
+ // src/workflows.ts
1606
+ var TERMINAL_WORKFLOW_STATUSES = [
1607
+ "succeeded",
1608
+ "failed",
1609
+ "timed_out"
1610
+ ];
1611
+ function isWorkflowRunTerminal(status) {
1612
+ return TERMINAL_WORKFLOW_STATUSES.includes(status);
1613
+ }
1614
+ var WorkflowsClient = class {
1615
+ constructor(config) {
1616
+ this.config = config;
1617
+ if (!config.baseUrl) throw new Error("baseUrl is required");
1618
+ }
1619
+ headers() {
1620
+ const h = { "Content-Type": "application/json" };
1621
+ if (this.config.apiKey) h["Authorization"] = `Bearer ${this.config.apiKey}`;
1622
+ if (this.config.tenant) h["x-rapidapi-user"] = this.config.tenant;
1623
+ return h;
1624
+ }
1625
+ async request(method, path, body) {
1626
+ const url = this.config.baseUrl.replace(/\/$/, "") + path;
1627
+ const controller = new AbortController();
1628
+ const timeout = setTimeout(
1629
+ () => controller.abort(),
1630
+ this.config.timeoutMs ?? 12e4
1631
+ );
1632
+ try {
1633
+ const init = {
1634
+ method,
1635
+ headers: this.headers(),
1636
+ signal: controller.signal
1637
+ };
1638
+ if (body !== void 0) init.body = JSON.stringify(body);
1639
+ const resp = await fetch(url, init);
1640
+ if (resp.status === 204) return null;
1641
+ const bytes = await _boundedRead(resp, MAX_RESPONSE_SIZE);
1642
+ const text = new TextDecoder().decode(bytes);
1643
+ if (!resp.ok) {
1644
+ throw new HttpError(resp.status, resp.statusText, text);
1645
+ }
1646
+ return text ? JSON.parse(text) : null;
1647
+ } finally {
1648
+ clearTimeout(timeout);
1649
+ }
1650
+ }
1651
+ // ── CRUD ──────────────────────────────────────────────────────────
1652
+ /**
1653
+ * `POST /v1/workflows` — create a workflow definition.
1654
+ *
1655
+ * The server validates cycles, transition targets, choice operators,
1656
+ * and the per-tenant cap (100) before returning 201.
1657
+ */
1658
+ async create(input) {
1659
+ const body = {
1660
+ name: input.name,
1661
+ start_at: input.startAt,
1662
+ states: input.states
1663
+ };
1664
+ if (input.description !== void 0) body.description = input.description;
1665
+ const env = await this.request("POST", "/v1/workflows", body);
1666
+ return env.workflow;
1667
+ }
1668
+ /** `GET /v1/workflows` — list workflows for the calling tenant. */
1669
+ async list() {
1670
+ return await this.request("GET", "/v1/workflows");
1671
+ }
1672
+ /** `GET /v1/workflows/:id` */
1673
+ async get(workflowId) {
1674
+ const env = await this.request(
1675
+ "GET",
1676
+ `/v1/workflows/${workflowId}`
1677
+ );
1678
+ return env.workflow;
1679
+ }
1680
+ /** `DELETE /v1/workflows/:id` */
1681
+ async delete(workflowId) {
1682
+ await this.request("DELETE", `/v1/workflows/${workflowId}`);
1683
+ }
1684
+ // ── Runs ──────────────────────────────────────────────────────────
1685
+ /**
1686
+ * `POST /v1/workflows/:id/runs` — start an async execution.
1687
+ *
1688
+ * Returns 202 with an `execution_id` immediately. Poll {@link getRun}
1689
+ * or use {@link waitForRun} to await completion.
1690
+ */
1691
+ async startRun(workflowId, input) {
1692
+ const body = {};
1693
+ if (input !== void 0) body.input = input;
1694
+ return await this.request(
1695
+ "POST",
1696
+ `/v1/workflows/${workflowId}/runs`,
1697
+ body
1698
+ );
1699
+ }
1700
+ /** `GET /v1/workflows/:id/runs/:execution_id` — fetch one execution. */
1701
+ async getRun(workflowId, executionId) {
1702
+ const env = await this.request(
1703
+ "GET",
1704
+ `/v1/workflows/${workflowId}/runs/${executionId}`
1705
+ );
1706
+ return env.execution;
1707
+ }
1708
+ /**
1709
+ * Poll {@link getRun} until the run reaches a terminal status.
1710
+ *
1711
+ * Rejects with an error if the run hasn't terminated within
1712
+ * `timeoutMs`. The server enforces its own 60s wall-clock cap per run,
1713
+ * so a timeout larger than ~75_000 is just slack for polling overhead.
1714
+ */
1715
+ async waitForRun(workflowId, executionId, opts = {}) {
1716
+ const timeoutMs = opts.timeoutMs ?? 9e4;
1717
+ const pollIntervalMs = opts.pollIntervalMs ?? 1e3;
1718
+ const deadline = Date.now() + timeoutMs;
1719
+ while (true) {
1720
+ const execution = await this.getRun(workflowId, executionId);
1721
+ if (isWorkflowRunTerminal(execution.status)) return execution;
1722
+ if (Date.now() >= deadline) {
1723
+ throw new Error(
1724
+ `workflow run ${executionId} did not terminate within ${timeoutMs}ms (last status: ${execution.status})`
1725
+ );
1726
+ }
1727
+ await new Promise((r) => setTimeout(r, pollIntervalMs));
1728
+ }
1729
+ }
1730
+ };
1731
+
1523
1732
  // src/history.ts
1524
1733
  var HistoryClient = class {
1525
1734
  constructor(config) {
@@ -1639,13 +1848,16 @@ var HistoryClient = class {
1639
1848
  HttpError,
1640
1849
  MockHttpClient,
1641
1850
  ServerError,
1851
+ TERMINAL_WORKFLOW_STATUSES,
1642
1852
  TimeoutError,
1643
1853
  ToolNotFoundError,
1644
1854
  ValidationError,
1645
1855
  WauldoError,
1856
+ WorkflowsClient,
1646
1857
  chatContent,
1647
1858
  guardIsBlocked,
1648
1859
  guardIsSafe,
1649
1860
  isTerminalStatus,
1861
+ isWorkflowRunTerminal,
1650
1862
  supportScore
1651
1863
  });
package/dist/index.mjs CHANGED
@@ -1364,6 +1364,55 @@ var AgentsClient = class {
1364
1364
  async delete(agentId) {
1365
1365
  await this.request("DELETE", `/v1/agents/${agentId}`);
1366
1366
  }
1367
+ // ── Revisions (ECS-style versioning) ────────────────────────────
1368
+ /**
1369
+ * `POST /v1/agents/:id/revisions` — mint an immutable revision.
1370
+ *
1371
+ * The server validates `customPreset` (size, depth, states, cycle, tools,
1372
+ * quota) and stores an immutable snapshot keyed by SHA-256. When
1373
+ * `setActive` is `true` (default) the new revision becomes the agent's
1374
+ * live revision; `false` stages it for review.
1375
+ */
1376
+ async createRevision(agentId, input) {
1377
+ const body = {
1378
+ custom_preset: input.customPreset,
1379
+ set_active: input.setActive ?? true
1380
+ };
1381
+ if (input.message !== void 0) body.message = input.message;
1382
+ return await this.request(
1383
+ "POST",
1384
+ `/v1/agents/${agentId}/revisions`,
1385
+ body
1386
+ );
1387
+ }
1388
+ /** `GET /v1/agents/:id/revisions` — list revisions newest-first. */
1389
+ async listRevisions(agentId) {
1390
+ return await this.request(
1391
+ "GET",
1392
+ `/v1/agents/${agentId}/revisions`
1393
+ );
1394
+ }
1395
+ /** `GET /v1/agents/:id/revisions/:rev` — fetch one revision verbatim. */
1396
+ async getRevision(agentId, rev) {
1397
+ return await this.request(
1398
+ "GET",
1399
+ `/v1/agents/${agentId}/revisions/${rev}`
1400
+ );
1401
+ }
1402
+ /**
1403
+ * `PATCH /v1/agents/:id/active-revision` — O(1) rollback / promotion.
1404
+ *
1405
+ * No LLM cost — the revision is already validated and stored. Use this
1406
+ * to roll back to a previous good revision when the current one breaks
1407
+ * in production.
1408
+ */
1409
+ async setActiveRevision(agentId, rev) {
1410
+ return await this.request(
1411
+ "PATCH",
1412
+ `/v1/agents/${agentId}/active-revision`,
1413
+ { rev }
1414
+ );
1415
+ }
1367
1416
  // ── Runs ────────────────────────────────────────────────────────
1368
1417
  async run(agentId, input, verificationMode, factCheckMode) {
1369
1418
  if (!input) throw new Error("input is required");
@@ -1399,6 +1448,36 @@ var AgentsClient = class {
1399
1448
  async cancelTask(taskId) {
1400
1449
  await this.request("DELETE", `/v1/tasks/${taskId}`);
1401
1450
  }
1451
+ // ── Shareable runs ──────────────────────────────────────────────
1452
+ /**
1453
+ * `POST /v1/tasks/:id/share` — publish a run as a public URL.
1454
+ *
1455
+ * Idempotent : calling on an already-shared task returns the existing
1456
+ * `ShareResponse` without bumping the per-tenant cap. The returned
1457
+ * `url` (form `https://wauldo.com/r/<id>`) can be pasted anywhere —
1458
+ * anyone with the link sees the verdict + claims + sources + timeline
1459
+ * through a strict-whitelist projection (no `custom_preset` /
1460
+ * `wauldo_toml` / system prompt / tool args ever leave the tenant).
1461
+ *
1462
+ * Free-tier tenants get a 30-day TTL ; paid tenants get
1463
+ * `expires_at = null` (no expiration).
1464
+ */
1465
+ async shareTask(taskId) {
1466
+ return await this.request(
1467
+ "POST",
1468
+ `/v1/tasks/${taskId}/share`,
1469
+ {}
1470
+ );
1471
+ }
1472
+ /**
1473
+ * `DELETE /v1/tasks/:id/share` — make a published run private again.
1474
+ *
1475
+ * Idempotent : calling on a never-published task returns 204.
1476
+ * Subsequent `GET /v1/runs/<shareId>` for the cleared id returns 404.
1477
+ */
1478
+ async unshareTask(taskId) {
1479
+ await this.request("DELETE", `/v1/tasks/${taskId}/share`);
1480
+ }
1402
1481
  /**
1403
1482
  * Poll `getTask` until the task reaches a terminal status. Resolves
1404
1483
  * with the final Task snapshot. Rejects with `Error("timeout")` if
@@ -1477,6 +1556,133 @@ var AgentsClient = class {
1477
1556
  }
1478
1557
  };
1479
1558
 
1559
+ // src/workflows.ts
1560
+ var TERMINAL_WORKFLOW_STATUSES = [
1561
+ "succeeded",
1562
+ "failed",
1563
+ "timed_out"
1564
+ ];
1565
+ function isWorkflowRunTerminal(status) {
1566
+ return TERMINAL_WORKFLOW_STATUSES.includes(status);
1567
+ }
1568
+ var WorkflowsClient = class {
1569
+ constructor(config) {
1570
+ this.config = config;
1571
+ if (!config.baseUrl) throw new Error("baseUrl is required");
1572
+ }
1573
+ headers() {
1574
+ const h = { "Content-Type": "application/json" };
1575
+ if (this.config.apiKey) h["Authorization"] = `Bearer ${this.config.apiKey}`;
1576
+ if (this.config.tenant) h["x-rapidapi-user"] = this.config.tenant;
1577
+ return h;
1578
+ }
1579
+ async request(method, path, body) {
1580
+ const url = this.config.baseUrl.replace(/\/$/, "") + path;
1581
+ const controller = new AbortController();
1582
+ const timeout = setTimeout(
1583
+ () => controller.abort(),
1584
+ this.config.timeoutMs ?? 12e4
1585
+ );
1586
+ try {
1587
+ const init = {
1588
+ method,
1589
+ headers: this.headers(),
1590
+ signal: controller.signal
1591
+ };
1592
+ if (body !== void 0) init.body = JSON.stringify(body);
1593
+ const resp = await fetch(url, init);
1594
+ if (resp.status === 204) return null;
1595
+ const bytes = await _boundedRead(resp, MAX_RESPONSE_SIZE);
1596
+ const text = new TextDecoder().decode(bytes);
1597
+ if (!resp.ok) {
1598
+ throw new HttpError(resp.status, resp.statusText, text);
1599
+ }
1600
+ return text ? JSON.parse(text) : null;
1601
+ } finally {
1602
+ clearTimeout(timeout);
1603
+ }
1604
+ }
1605
+ // ── CRUD ──────────────────────────────────────────────────────────
1606
+ /**
1607
+ * `POST /v1/workflows` — create a workflow definition.
1608
+ *
1609
+ * The server validates cycles, transition targets, choice operators,
1610
+ * and the per-tenant cap (100) before returning 201.
1611
+ */
1612
+ async create(input) {
1613
+ const body = {
1614
+ name: input.name,
1615
+ start_at: input.startAt,
1616
+ states: input.states
1617
+ };
1618
+ if (input.description !== void 0) body.description = input.description;
1619
+ const env = await this.request("POST", "/v1/workflows", body);
1620
+ return env.workflow;
1621
+ }
1622
+ /** `GET /v1/workflows` — list workflows for the calling tenant. */
1623
+ async list() {
1624
+ return await this.request("GET", "/v1/workflows");
1625
+ }
1626
+ /** `GET /v1/workflows/:id` */
1627
+ async get(workflowId) {
1628
+ const env = await this.request(
1629
+ "GET",
1630
+ `/v1/workflows/${workflowId}`
1631
+ );
1632
+ return env.workflow;
1633
+ }
1634
+ /** `DELETE /v1/workflows/:id` */
1635
+ async delete(workflowId) {
1636
+ await this.request("DELETE", `/v1/workflows/${workflowId}`);
1637
+ }
1638
+ // ── Runs ──────────────────────────────────────────────────────────
1639
+ /**
1640
+ * `POST /v1/workflows/:id/runs` — start an async execution.
1641
+ *
1642
+ * Returns 202 with an `execution_id` immediately. Poll {@link getRun}
1643
+ * or use {@link waitForRun} to await completion.
1644
+ */
1645
+ async startRun(workflowId, input) {
1646
+ const body = {};
1647
+ if (input !== void 0) body.input = input;
1648
+ return await this.request(
1649
+ "POST",
1650
+ `/v1/workflows/${workflowId}/runs`,
1651
+ body
1652
+ );
1653
+ }
1654
+ /** `GET /v1/workflows/:id/runs/:execution_id` — fetch one execution. */
1655
+ async getRun(workflowId, executionId) {
1656
+ const env = await this.request(
1657
+ "GET",
1658
+ `/v1/workflows/${workflowId}/runs/${executionId}`
1659
+ );
1660
+ return env.execution;
1661
+ }
1662
+ /**
1663
+ * Poll {@link getRun} until the run reaches a terminal status.
1664
+ *
1665
+ * Rejects with an error if the run hasn't terminated within
1666
+ * `timeoutMs`. The server enforces its own 60s wall-clock cap per run,
1667
+ * so a timeout larger than ~75_000 is just slack for polling overhead.
1668
+ */
1669
+ async waitForRun(workflowId, executionId, opts = {}) {
1670
+ const timeoutMs = opts.timeoutMs ?? 9e4;
1671
+ const pollIntervalMs = opts.pollIntervalMs ?? 1e3;
1672
+ const deadline = Date.now() + timeoutMs;
1673
+ while (true) {
1674
+ const execution = await this.getRun(workflowId, executionId);
1675
+ if (isWorkflowRunTerminal(execution.status)) return execution;
1676
+ if (Date.now() >= deadline) {
1677
+ throw new Error(
1678
+ `workflow run ${executionId} did not terminate within ${timeoutMs}ms (last status: ${execution.status})`
1679
+ );
1680
+ }
1681
+ await new Promise((r) => setTimeout(r, pollIntervalMs));
1682
+ }
1683
+ }
1684
+ };
1685
+
1480
1686
  // src/history.ts
1481
1687
  var HistoryClient = class {
1482
1688
  constructor(config) {
@@ -1595,13 +1801,16 @@ export {
1595
1801
  HttpError,
1596
1802
  MockHttpClient,
1597
1803
  ServerError,
1804
+ TERMINAL_WORKFLOW_STATUSES,
1598
1805
  TimeoutError,
1599
1806
  ToolNotFoundError,
1600
1807
  ValidationError,
1601
1808
  WauldoError,
1809
+ WorkflowsClient,
1602
1810
  chatContent,
1603
1811
  guardIsBlocked,
1604
1812
  guardIsSafe,
1605
1813
  isTerminalStatus,
1814
+ isWorkflowRunTerminal,
1606
1815
  supportScore
1607
1816
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wauldo",
3
- "version": "0.11.0",
3
+ "version": "0.13.0",
4
4
  "description": "Official TypeScript SDK for Wauldo — Verified AI answers from your documents",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",