wauldo 0.10.0 → 0.12.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,4 +919,112 @@ declare class AgentsClient {
833
919
  streamTask(taskId: string): AsyncGenerator<StateTransition>;
834
920
  }
835
921
 
836
- 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, 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 TaskStatus, type TaskVerification, TimeoutError, type ToolContent, type ToolDefinition, ToolNotFoundError, type UpdateAgentPatch, ValidationError, type Verdict, WauldoError, chatContent, guardIsBlocked, guardIsSafe, isTerminalStatus, supportScore };
922
+ /**
923
+ * History API client — Wauldo Funnel #1 audit log.
924
+ *
925
+ * Read-only access to a tenant's task history (every completed task is
926
+ * persisted to a tenant-scoped DynamoDB audit log on the server side,
927
+ * exposed via /v1/history). Mirrors {@link MemoryClient} shape so a
928
+ * caller already familiar with the Memory API has zero ramp-up.
929
+ *
930
+ * Three formats:
931
+ *
932
+ * - {@link HistoryClient.list} — paginated JSON, suitable for dashboards.
933
+ * - {@link HistoryClient.export} with `format="csv"` — single CSV blob
934
+ * (compliance evidence, header + footer metadata).
935
+ * - {@link HistoryClient.export} with `format="jsonl"` — newline-
936
+ * delimited JSON for log pipelines.
937
+ *
938
+ * Right To Be Forgotten (GDPR Art. 17) is supported via
939
+ * {@link HistoryClient.deleteTask}, which removes every audit row for a
940
+ * specific task id within the caller's tenant.
941
+ *
942
+ * @example
943
+ * ```ts
944
+ * import { HistoryClient } from "wauldo/history";
945
+ * const hist = new HistoryClient({
946
+ * baseUrl: "https://api.wauldo.com",
947
+ * apiKey: "tig_live_...",
948
+ * tenant: "my-org",
949
+ * });
950
+ * const page = await hist.list({ verdict: "CONFLICT", limit: 20 });
951
+ * for (const item of page.items) console.log(item.task_id, item.verdict);
952
+ * const blob = await hist.export({ format: "csv" });
953
+ * await hist.deleteTask("a69b8612-0c47-43f3-93f2-c00c8a4ac1f8");
954
+ * ```
955
+ */
956
+ interface HistoryClientConfig {
957
+ baseUrl: string;
958
+ apiKey?: string;
959
+ tenant?: string;
960
+ timeoutMs?: number;
961
+ }
962
+ interface TaskHistoryEntry {
963
+ task_id: string;
964
+ tenant_id: string;
965
+ agent_id?: string | null;
966
+ verdict: string;
967
+ support_score: number;
968
+ halluc_rate: number;
969
+ latency_ms: number;
970
+ cost_micro_usd: number;
971
+ claims_count: number;
972
+ model?: string | null;
973
+ created_at: number;
974
+ }
975
+ interface HistoryListResponse {
976
+ items: TaskHistoryEntry[];
977
+ next_cursor: string | null;
978
+ /**
979
+ * `false` when the server hasn't wired its DynamoDB store (self-host
980
+ * without IAM perm). UI should show "audit log not enabled" rather
981
+ * than "no events yet" in that case.
982
+ */
983
+ enabled: boolean;
984
+ }
985
+ interface ListOptions {
986
+ verdict?: string;
987
+ agentId?: string;
988
+ fromMs?: number;
989
+ toMs?: number;
990
+ limit?: number;
991
+ cursor?: string;
992
+ }
993
+ interface ExportOptions extends Omit<ListOptions, "limit" | "cursor"> {
994
+ format: "csv" | "jsonl" | "json";
995
+ }
996
+ declare class HistoryClient {
997
+ private readonly config;
998
+ constructor(config: HistoryClientConfig);
999
+ private headers;
1000
+ private buildQs;
1001
+ private fetchRaw;
1002
+ /**
1003
+ * GET /v1/history — paginated audit log page. Pass `cursor` from a
1004
+ * previous response's `next_cursor` to paginate. Filters compose
1005
+ * with AND.
1006
+ */
1007
+ list(opts?: ListOptions): Promise<HistoryListResponse>;
1008
+ /**
1009
+ * Async generator over all pages within a window, yielding each page
1010
+ * as the server returns it. Stops when `next_cursor` is null.
1011
+ */
1012
+ iterPages(opts?: ListOptions): AsyncIterableIterator<HistoryListResponse>;
1013
+ /**
1014
+ * GET /v1/history?format=csv|jsonl — single-blob export. Returns
1015
+ * the body as a string (`format=csv|jsonl`) or a parsed object
1016
+ * (`format=json`). Server auto-paginates up to 10000 rows; the body
1017
+ * footer (CSV `# wauldo-history-export ...` line / JSONL `_export`
1018
+ * object) signals truncation. Rate-limited per tenant to 5 / 60s —
1019
+ * a non-2xx response throws.
1020
+ */
1021
+ export(opts: ExportOptions): Promise<string | HistoryListResponse>;
1022
+ /**
1023
+ * DELETE /v1/history/:task_id — RTBF (GDPR Art. 17). Removes every
1024
+ * audit row for `taskId` within the caller's tenant. Idempotent.
1025
+ * Returns the number of rows deleted.
1026
+ */
1027
+ deleteTask(taskId: string): Promise<number>;
1028
+ }
1029
+
1030
+ 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 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 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 };
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,4 +919,112 @@ declare class AgentsClient {
833
919
  streamTask(taskId: string): AsyncGenerator<StateTransition>;
834
920
  }
835
921
 
836
- 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, 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 TaskStatus, type TaskVerification, TimeoutError, type ToolContent, type ToolDefinition, ToolNotFoundError, type UpdateAgentPatch, ValidationError, type Verdict, WauldoError, chatContent, guardIsBlocked, guardIsSafe, isTerminalStatus, supportScore };
922
+ /**
923
+ * History API client — Wauldo Funnel #1 audit log.
924
+ *
925
+ * Read-only access to a tenant's task history (every completed task is
926
+ * persisted to a tenant-scoped DynamoDB audit log on the server side,
927
+ * exposed via /v1/history). Mirrors {@link MemoryClient} shape so a
928
+ * caller already familiar with the Memory API has zero ramp-up.
929
+ *
930
+ * Three formats:
931
+ *
932
+ * - {@link HistoryClient.list} — paginated JSON, suitable for dashboards.
933
+ * - {@link HistoryClient.export} with `format="csv"` — single CSV blob
934
+ * (compliance evidence, header + footer metadata).
935
+ * - {@link HistoryClient.export} with `format="jsonl"` — newline-
936
+ * delimited JSON for log pipelines.
937
+ *
938
+ * Right To Be Forgotten (GDPR Art. 17) is supported via
939
+ * {@link HistoryClient.deleteTask}, which removes every audit row for a
940
+ * specific task id within the caller's tenant.
941
+ *
942
+ * @example
943
+ * ```ts
944
+ * import { HistoryClient } from "wauldo/history";
945
+ * const hist = new HistoryClient({
946
+ * baseUrl: "https://api.wauldo.com",
947
+ * apiKey: "tig_live_...",
948
+ * tenant: "my-org",
949
+ * });
950
+ * const page = await hist.list({ verdict: "CONFLICT", limit: 20 });
951
+ * for (const item of page.items) console.log(item.task_id, item.verdict);
952
+ * const blob = await hist.export({ format: "csv" });
953
+ * await hist.deleteTask("a69b8612-0c47-43f3-93f2-c00c8a4ac1f8");
954
+ * ```
955
+ */
956
+ interface HistoryClientConfig {
957
+ baseUrl: string;
958
+ apiKey?: string;
959
+ tenant?: string;
960
+ timeoutMs?: number;
961
+ }
962
+ interface TaskHistoryEntry {
963
+ task_id: string;
964
+ tenant_id: string;
965
+ agent_id?: string | null;
966
+ verdict: string;
967
+ support_score: number;
968
+ halluc_rate: number;
969
+ latency_ms: number;
970
+ cost_micro_usd: number;
971
+ claims_count: number;
972
+ model?: string | null;
973
+ created_at: number;
974
+ }
975
+ interface HistoryListResponse {
976
+ items: TaskHistoryEntry[];
977
+ next_cursor: string | null;
978
+ /**
979
+ * `false` when the server hasn't wired its DynamoDB store (self-host
980
+ * without IAM perm). UI should show "audit log not enabled" rather
981
+ * than "no events yet" in that case.
982
+ */
983
+ enabled: boolean;
984
+ }
985
+ interface ListOptions {
986
+ verdict?: string;
987
+ agentId?: string;
988
+ fromMs?: number;
989
+ toMs?: number;
990
+ limit?: number;
991
+ cursor?: string;
992
+ }
993
+ interface ExportOptions extends Omit<ListOptions, "limit" | "cursor"> {
994
+ format: "csv" | "jsonl" | "json";
995
+ }
996
+ declare class HistoryClient {
997
+ private readonly config;
998
+ constructor(config: HistoryClientConfig);
999
+ private headers;
1000
+ private buildQs;
1001
+ private fetchRaw;
1002
+ /**
1003
+ * GET /v1/history — paginated audit log page. Pass `cursor` from a
1004
+ * previous response's `next_cursor` to paginate. Filters compose
1005
+ * with AND.
1006
+ */
1007
+ list(opts?: ListOptions): Promise<HistoryListResponse>;
1008
+ /**
1009
+ * Async generator over all pages within a window, yielding each page
1010
+ * as the server returns it. Stops when `next_cursor` is null.
1011
+ */
1012
+ iterPages(opts?: ListOptions): AsyncIterableIterator<HistoryListResponse>;
1013
+ /**
1014
+ * GET /v1/history?format=csv|jsonl — single-blob export. Returns
1015
+ * the body as a string (`format=csv|jsonl`) or a parsed object
1016
+ * (`format=json`). Server auto-paginates up to 10000 rows; the body
1017
+ * footer (CSV `# wauldo-history-export ...` line / JSONL `_export`
1018
+ * object) signals truncation. Rate-limited per tenant to 5 / 60s —
1019
+ * a non-2xx response throws.
1020
+ */
1021
+ export(opts: ExportOptions): Promise<string | HistoryListResponse>;
1022
+ /**
1023
+ * DELETE /v1/history/:task_id — RTBF (GDPR Art. 17). Removes every
1024
+ * audit row for `taskId` within the caller's tenant. Idempotent.
1025
+ * Returns the number of rows deleted.
1026
+ */
1027
+ deleteTask(taskId: string): Promise<number>;
1028
+ }
1029
+
1030
+ 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 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 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 };
package/dist/index.js CHANGED
@@ -24,6 +24,7 @@ __export(index_exports, {
24
24
  AgentsClient: () => AgentsClient,
25
25
  ConnectionError: () => ConnectionError,
26
26
  Conversation: () => Conversation,
27
+ HistoryClient: () => HistoryClient,
27
28
  HttpClient: () => HttpClient,
28
29
  HttpError: () => HttpError,
29
30
  MockHttpClient: () => MockHttpClient,
@@ -1406,6 +1407,55 @@ var AgentsClient = class {
1406
1407
  async delete(agentId) {
1407
1408
  await this.request("DELETE", `/v1/agents/${agentId}`);
1408
1409
  }
1410
+ // ── Revisions (ECS-style versioning) ────────────────────────────
1411
+ /**
1412
+ * `POST /v1/agents/:id/revisions` — mint an immutable revision.
1413
+ *
1414
+ * The server validates `customPreset` (size, depth, states, cycle, tools,
1415
+ * quota) and stores an immutable snapshot keyed by SHA-256. When
1416
+ * `setActive` is `true` (default) the new revision becomes the agent's
1417
+ * live revision; `false` stages it for review.
1418
+ */
1419
+ async createRevision(agentId, input) {
1420
+ const body = {
1421
+ custom_preset: input.customPreset,
1422
+ set_active: input.setActive ?? true
1423
+ };
1424
+ if (input.message !== void 0) body.message = input.message;
1425
+ return await this.request(
1426
+ "POST",
1427
+ `/v1/agents/${agentId}/revisions`,
1428
+ body
1429
+ );
1430
+ }
1431
+ /** `GET /v1/agents/:id/revisions` — list revisions newest-first. */
1432
+ async listRevisions(agentId) {
1433
+ return await this.request(
1434
+ "GET",
1435
+ `/v1/agents/${agentId}/revisions`
1436
+ );
1437
+ }
1438
+ /** `GET /v1/agents/:id/revisions/:rev` — fetch one revision verbatim. */
1439
+ async getRevision(agentId, rev) {
1440
+ return await this.request(
1441
+ "GET",
1442
+ `/v1/agents/${agentId}/revisions/${rev}`
1443
+ );
1444
+ }
1445
+ /**
1446
+ * `PATCH /v1/agents/:id/active-revision` — O(1) rollback / promotion.
1447
+ *
1448
+ * No LLM cost — the revision is already validated and stored. Use this
1449
+ * to roll back to a previous good revision when the current one breaks
1450
+ * in production.
1451
+ */
1452
+ async setActiveRevision(agentId, rev) {
1453
+ return await this.request(
1454
+ "PATCH",
1455
+ `/v1/agents/${agentId}/active-revision`,
1456
+ { rev }
1457
+ );
1458
+ }
1409
1459
  // ── Runs ────────────────────────────────────────────────────────
1410
1460
  async run(agentId, input, verificationMode, factCheckMode) {
1411
1461
  if (!input) throw new Error("input is required");
@@ -1441,6 +1491,36 @@ var AgentsClient = class {
1441
1491
  async cancelTask(taskId) {
1442
1492
  await this.request("DELETE", `/v1/tasks/${taskId}`);
1443
1493
  }
1494
+ // ── Shareable runs ──────────────────────────────────────────────
1495
+ /**
1496
+ * `POST /v1/tasks/:id/share` — publish a run as a public URL.
1497
+ *
1498
+ * Idempotent : calling on an already-shared task returns the existing
1499
+ * `ShareResponse` without bumping the per-tenant cap. The returned
1500
+ * `url` (form `https://wauldo.com/r/<id>`) can be pasted anywhere —
1501
+ * anyone with the link sees the verdict + claims + sources + timeline
1502
+ * through a strict-whitelist projection (no `custom_preset` /
1503
+ * `wauldo_toml` / system prompt / tool args ever leave the tenant).
1504
+ *
1505
+ * Free-tier tenants get a 30-day TTL ; paid tenants get
1506
+ * `expires_at = null` (no expiration).
1507
+ */
1508
+ async shareTask(taskId) {
1509
+ return await this.request(
1510
+ "POST",
1511
+ `/v1/tasks/${taskId}/share`,
1512
+ {}
1513
+ );
1514
+ }
1515
+ /**
1516
+ * `DELETE /v1/tasks/:id/share` — make a published run private again.
1517
+ *
1518
+ * Idempotent : calling on a never-published task returns 204.
1519
+ * Subsequent `GET /v1/runs/<shareId>` for the cleared id returns 404.
1520
+ */
1521
+ async unshareTask(taskId) {
1522
+ await this.request("DELETE", `/v1/tasks/${taskId}/share`);
1523
+ }
1444
1524
  /**
1445
1525
  * Poll `getTask` until the task reaches a terminal status. Resolves
1446
1526
  * with the final Task snapshot. Rejects with `Error("timeout")` if
@@ -1518,12 +1598,122 @@ var AgentsClient = class {
1518
1598
  }
1519
1599
  }
1520
1600
  };
1601
+
1602
+ // src/history.ts
1603
+ var HistoryClient = class {
1604
+ constructor(config) {
1605
+ this.config = config;
1606
+ if (!config.baseUrl) throw new Error("baseUrl is required");
1607
+ }
1608
+ headers() {
1609
+ const h = { "Content-Type": "application/json" };
1610
+ if (this.config.apiKey) h["Authorization"] = `Bearer ${this.config.apiKey}`;
1611
+ if (this.config.tenant) h["x-rapidapi-user"] = this.config.tenant;
1612
+ return h;
1613
+ }
1614
+ buildQs(params) {
1615
+ const entries = Object.entries(params).filter(([, v]) => v !== void 0 && v !== null);
1616
+ if (entries.length === 0) return "";
1617
+ const usp = new URLSearchParams();
1618
+ for (const [k, v] of entries) usp.set(k, String(v));
1619
+ return "?" + usp.toString();
1620
+ }
1621
+ async fetchRaw(method, path) {
1622
+ const url = this.config.baseUrl.replace(/\/$/, "") + path;
1623
+ const controller = new AbortController();
1624
+ const timeout = setTimeout(() => controller.abort(), this.config.timeoutMs ?? 6e4);
1625
+ try {
1626
+ const resp = await fetch(url, {
1627
+ method,
1628
+ headers: this.headers(),
1629
+ signal: controller.signal
1630
+ });
1631
+ if (!resp.ok) {
1632
+ const body = await resp.text().catch(() => "");
1633
+ throw new Error(`HTTP ${resp.status} ${resp.statusText}: ${body.slice(0, 200)}`);
1634
+ }
1635
+ return resp;
1636
+ } finally {
1637
+ clearTimeout(timeout);
1638
+ }
1639
+ }
1640
+ /**
1641
+ * GET /v1/history — paginated audit log page. Pass `cursor` from a
1642
+ * previous response's `next_cursor` to paginate. Filters compose
1643
+ * with AND.
1644
+ */
1645
+ async list(opts = {}) {
1646
+ const qs = this.buildQs({
1647
+ verdict: opts.verdict,
1648
+ agent_id: opts.agentId,
1649
+ from: opts.fromMs,
1650
+ to: opts.toMs,
1651
+ limit: opts.limit,
1652
+ cursor: opts.cursor
1653
+ });
1654
+ const resp = await this.fetchRaw("GET", `/v1/history${qs}`);
1655
+ return await resp.json();
1656
+ }
1657
+ /**
1658
+ * Async generator over all pages within a window, yielding each page
1659
+ * as the server returns it. Stops when `next_cursor` is null.
1660
+ */
1661
+ async *iterPages(opts = {}) {
1662
+ let cursor = opts.cursor;
1663
+ const pageSize = opts.limit ?? 50;
1664
+ while (true) {
1665
+ const next = { ...opts, limit: pageSize };
1666
+ if (cursor !== void 0) next.cursor = cursor;
1667
+ const page = await this.list(next);
1668
+ yield page;
1669
+ if (!page.next_cursor) break;
1670
+ cursor = page.next_cursor;
1671
+ }
1672
+ }
1673
+ /**
1674
+ * GET /v1/history?format=csv|jsonl — single-blob export. Returns
1675
+ * the body as a string (`format=csv|jsonl`) or a parsed object
1676
+ * (`format=json`). Server auto-paginates up to 10000 rows; the body
1677
+ * footer (CSV `# wauldo-history-export ...` line / JSONL `_export`
1678
+ * object) signals truncation. Rate-limited per tenant to 5 / 60s —
1679
+ * a non-2xx response throws.
1680
+ */
1681
+ async export(opts) {
1682
+ if (!["csv", "jsonl", "json"].includes(opts.format)) {
1683
+ throw new Error(`unsupported format '${opts.format}' \u2014 use csv|jsonl|json`);
1684
+ }
1685
+ const qs = this.buildQs({
1686
+ format: opts.format,
1687
+ verdict: opts.verdict,
1688
+ agent_id: opts.agentId,
1689
+ from: opts.fromMs,
1690
+ to: opts.toMs
1691
+ });
1692
+ const resp = await this.fetchRaw("GET", `/v1/history${qs}`);
1693
+ if (opts.format === "json") {
1694
+ return await resp.json();
1695
+ }
1696
+ return await resp.text();
1697
+ }
1698
+ /**
1699
+ * DELETE /v1/history/:task_id — RTBF (GDPR Art. 17). Removes every
1700
+ * audit row for `taskId` within the caller's tenant. Idempotent.
1701
+ * Returns the number of rows deleted.
1702
+ */
1703
+ async deleteTask(taskId) {
1704
+ if (!taskId) throw new Error("taskId required");
1705
+ const resp = await this.fetchRaw("DELETE", `/v1/history/${encodeURIComponent(taskId)}`);
1706
+ const body = await resp.json();
1707
+ return Number(body?.deleted ?? 0);
1708
+ }
1709
+ };
1521
1710
  // Annotate the CommonJS export names for ESM import in node:
1522
1711
  0 && (module.exports = {
1523
1712
  AgentClient,
1524
1713
  AgentsClient,
1525
1714
  ConnectionError,
1526
1715
  Conversation,
1716
+ HistoryClient,
1527
1717
  HttpClient,
1528
1718
  HttpError,
1529
1719
  MockHttpClient,
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
@@ -1476,11 +1555,121 @@ var AgentsClient = class {
1476
1555
  }
1477
1556
  }
1478
1557
  };
1558
+
1559
+ // src/history.ts
1560
+ var HistoryClient = class {
1561
+ constructor(config) {
1562
+ this.config = config;
1563
+ if (!config.baseUrl) throw new Error("baseUrl is required");
1564
+ }
1565
+ headers() {
1566
+ const h = { "Content-Type": "application/json" };
1567
+ if (this.config.apiKey) h["Authorization"] = `Bearer ${this.config.apiKey}`;
1568
+ if (this.config.tenant) h["x-rapidapi-user"] = this.config.tenant;
1569
+ return h;
1570
+ }
1571
+ buildQs(params) {
1572
+ const entries = Object.entries(params).filter(([, v]) => v !== void 0 && v !== null);
1573
+ if (entries.length === 0) return "";
1574
+ const usp = new URLSearchParams();
1575
+ for (const [k, v] of entries) usp.set(k, String(v));
1576
+ return "?" + usp.toString();
1577
+ }
1578
+ async fetchRaw(method, path) {
1579
+ const url = this.config.baseUrl.replace(/\/$/, "") + path;
1580
+ const controller = new AbortController();
1581
+ const timeout = setTimeout(() => controller.abort(), this.config.timeoutMs ?? 6e4);
1582
+ try {
1583
+ const resp = await fetch(url, {
1584
+ method,
1585
+ headers: this.headers(),
1586
+ signal: controller.signal
1587
+ });
1588
+ if (!resp.ok) {
1589
+ const body = await resp.text().catch(() => "");
1590
+ throw new Error(`HTTP ${resp.status} ${resp.statusText}: ${body.slice(0, 200)}`);
1591
+ }
1592
+ return resp;
1593
+ } finally {
1594
+ clearTimeout(timeout);
1595
+ }
1596
+ }
1597
+ /**
1598
+ * GET /v1/history — paginated audit log page. Pass `cursor` from a
1599
+ * previous response's `next_cursor` to paginate. Filters compose
1600
+ * with AND.
1601
+ */
1602
+ async list(opts = {}) {
1603
+ const qs = this.buildQs({
1604
+ verdict: opts.verdict,
1605
+ agent_id: opts.agentId,
1606
+ from: opts.fromMs,
1607
+ to: opts.toMs,
1608
+ limit: opts.limit,
1609
+ cursor: opts.cursor
1610
+ });
1611
+ const resp = await this.fetchRaw("GET", `/v1/history${qs}`);
1612
+ return await resp.json();
1613
+ }
1614
+ /**
1615
+ * Async generator over all pages within a window, yielding each page
1616
+ * as the server returns it. Stops when `next_cursor` is null.
1617
+ */
1618
+ async *iterPages(opts = {}) {
1619
+ let cursor = opts.cursor;
1620
+ const pageSize = opts.limit ?? 50;
1621
+ while (true) {
1622
+ const next = { ...opts, limit: pageSize };
1623
+ if (cursor !== void 0) next.cursor = cursor;
1624
+ const page = await this.list(next);
1625
+ yield page;
1626
+ if (!page.next_cursor) break;
1627
+ cursor = page.next_cursor;
1628
+ }
1629
+ }
1630
+ /**
1631
+ * GET /v1/history?format=csv|jsonl — single-blob export. Returns
1632
+ * the body as a string (`format=csv|jsonl`) or a parsed object
1633
+ * (`format=json`). Server auto-paginates up to 10000 rows; the body
1634
+ * footer (CSV `# wauldo-history-export ...` line / JSONL `_export`
1635
+ * object) signals truncation. Rate-limited per tenant to 5 / 60s —
1636
+ * a non-2xx response throws.
1637
+ */
1638
+ async export(opts) {
1639
+ if (!["csv", "jsonl", "json"].includes(opts.format)) {
1640
+ throw new Error(`unsupported format '${opts.format}' \u2014 use csv|jsonl|json`);
1641
+ }
1642
+ const qs = this.buildQs({
1643
+ format: opts.format,
1644
+ verdict: opts.verdict,
1645
+ agent_id: opts.agentId,
1646
+ from: opts.fromMs,
1647
+ to: opts.toMs
1648
+ });
1649
+ const resp = await this.fetchRaw("GET", `/v1/history${qs}`);
1650
+ if (opts.format === "json") {
1651
+ return await resp.json();
1652
+ }
1653
+ return await resp.text();
1654
+ }
1655
+ /**
1656
+ * DELETE /v1/history/:task_id — RTBF (GDPR Art. 17). Removes every
1657
+ * audit row for `taskId` within the caller's tenant. Idempotent.
1658
+ * Returns the number of rows deleted.
1659
+ */
1660
+ async deleteTask(taskId) {
1661
+ if (!taskId) throw new Error("taskId required");
1662
+ const resp = await this.fetchRaw("DELETE", `/v1/history/${encodeURIComponent(taskId)}`);
1663
+ const body = await resp.json();
1664
+ return Number(body?.deleted ?? 0);
1665
+ }
1666
+ };
1479
1667
  export {
1480
1668
  AgentClient,
1481
1669
  AgentsClient,
1482
1670
  ConnectionError,
1483
1671
  Conversation,
1672
+ HistoryClient,
1484
1673
  HttpClient,
1485
1674
  HttpError,
1486
1675
  MockHttpClient,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wauldo",
3
- "version": "0.10.0",
3
+ "version": "0.12.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",