@compose-market/sdk 0.8.2 → 0.8.3

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.
Files changed (128) hide show
  1. package/.speakeasy/a2a.arazzo.yaml +1 -1
  2. package/.speakeasy/memory.arazzo.yaml +1 -1
  3. package/.speakeasy/tests.arazzo.yaml +1 -1
  4. package/dist/errors.d.ts +2 -0
  5. package/dist/errors.d.ts.map +1 -0
  6. package/dist/errors.js +2 -0
  7. package/dist/errors.js.map +1 -0
  8. package/dist/events.d.ts +202 -0
  9. package/dist/events.d.ts.map +1 -0
  10. package/dist/events.js +70 -0
  11. package/dist/events.js.map +1 -0
  12. package/dist/index.d.ts +277 -0
  13. package/dist/index.d.ts.map +1 -0
  14. package/dist/index.js +551 -0
  15. package/dist/index.js.map +1 -0
  16. package/dist/resources/accounts.d.ts +32 -0
  17. package/dist/resources/accounts.d.ts.map +1 -0
  18. package/dist/resources/accounts.js +128 -0
  19. package/dist/resources/accounts.js.map +1 -0
  20. package/dist/resources/agent.d.ts +58 -0
  21. package/dist/resources/agent.d.ts.map +1 -0
  22. package/dist/resources/agent.js +787 -0
  23. package/dist/resources/agent.js.map +1 -0
  24. package/dist/resources/channels.d.ts +24 -0
  25. package/dist/resources/channels.d.ts.map +1 -0
  26. package/dist/resources/channels.js +74 -0
  27. package/dist/resources/channels.js.map +1 -0
  28. package/dist/resources/directory.d.ts +43 -0
  29. package/dist/resources/directory.d.ts.map +1 -0
  30. package/dist/resources/directory.js +97 -0
  31. package/dist/resources/directory.js.map +1 -0
  32. package/dist/resources/dispenser.d.ts +25 -0
  33. package/dist/resources/dispenser.d.ts.map +1 -0
  34. package/dist/resources/dispenser.js +56 -0
  35. package/dist/resources/dispenser.js.map +1 -0
  36. package/dist/resources/feedback.d.ts +35 -0
  37. package/dist/resources/feedback.d.ts.map +1 -0
  38. package/dist/resources/feedback.js +127 -0
  39. package/dist/resources/feedback.js.map +1 -0
  40. package/dist/resources/inference.d.ts +206 -0
  41. package/dist/resources/inference.d.ts.map +1 -0
  42. package/dist/resources/inference.js +1049 -0
  43. package/dist/resources/inference.js.map +1 -0
  44. package/dist/resources/instrumentation.d.ts +29 -0
  45. package/dist/resources/instrumentation.d.ts.map +1 -0
  46. package/dist/resources/instrumentation.js +43 -0
  47. package/dist/resources/instrumentation.js.map +1 -0
  48. package/dist/resources/keys.d.ts +56 -0
  49. package/dist/resources/keys.d.ts.map +1 -0
  50. package/dist/resources/keys.js +186 -0
  51. package/dist/resources/keys.js.map +1 -0
  52. package/dist/resources/local.d.ts +56 -0
  53. package/dist/resources/local.d.ts.map +1 -0
  54. package/dist/resources/local.js +163 -0
  55. package/dist/resources/local.js.map +1 -0
  56. package/dist/resources/memory.d.ts +249 -0
  57. package/dist/resources/memory.d.ts.map +1 -0
  58. package/dist/resources/memory.js +217 -0
  59. package/dist/resources/memory.js.map +1 -0
  60. package/dist/resources/models.d.ts +45 -0
  61. package/dist/resources/models.d.ts.map +1 -0
  62. package/dist/resources/models.js +101 -0
  63. package/dist/resources/models.js.map +1 -0
  64. package/dist/resources/permissions.d.ts +23 -0
  65. package/dist/resources/permissions.d.ts.map +1 -0
  66. package/dist/resources/permissions.js +69 -0
  67. package/dist/resources/permissions.js.map +1 -0
  68. package/dist/resources/receipts.d.ts +23 -0
  69. package/dist/resources/receipts.d.ts.map +1 -0
  70. package/dist/resources/receipts.js +48 -0
  71. package/dist/resources/receipts.js.map +1 -0
  72. package/dist/resources/session-events.d.ts +51 -0
  73. package/dist/resources/session-events.d.ts.map +1 -0
  74. package/dist/resources/session-events.js +404 -0
  75. package/dist/resources/session-events.js.map +1 -0
  76. package/dist/resources/settlement.d.ts +21 -0
  77. package/dist/resources/settlement.d.ts.map +1 -0
  78. package/dist/resources/settlement.js +30 -0
  79. package/dist/resources/settlement.js.map +1 -0
  80. package/dist/resources/system.d.ts +9 -0
  81. package/dist/resources/system.d.ts.map +1 -0
  82. package/dist/resources/system.js +19 -0
  83. package/dist/resources/system.js.map +1 -0
  84. package/dist/resources/webhooks.d.ts +27 -0
  85. package/dist/resources/webhooks.d.ts.map +1 -0
  86. package/dist/resources/webhooks.js +78 -0
  87. package/dist/resources/webhooks.js.map +1 -0
  88. package/dist/resources/workflow.d.ts +49 -0
  89. package/dist/resources/workflow.d.ts.map +1 -0
  90. package/dist/resources/workflow.js +364 -0
  91. package/dist/resources/workflow.js.map +1 -0
  92. package/dist/resources/x402.d.ts +113 -0
  93. package/dist/resources/x402.d.ts.map +1 -0
  94. package/dist/resources/x402.js +231 -0
  95. package/dist/resources/x402.js.map +1 -0
  96. package/dist/tools/index.d.ts +55 -0
  97. package/dist/tools/index.d.ts.map +1 -0
  98. package/dist/tools/index.js +51 -0
  99. package/dist/tools/index.js.map +1 -0
  100. package/dist/types/index.d.ts +1859 -0
  101. package/dist/types/index.d.ts.map +1 -0
  102. package/dist/types/index.js +14 -0
  103. package/dist/types/index.js.map +1 -0
  104. package/dist/version.d.ts +9 -0
  105. package/dist/version.d.ts.map +1 -0
  106. package/dist/version.js +9 -0
  107. package/dist/version.js.map +1 -0
  108. package/generated/inference/esm/lib/config.d.ts +3 -3
  109. package/generated/inference/esm/lib/config.js +3 -3
  110. package/generated/inference/package.json +1 -1
  111. package/generated/inference/src/lib/config.ts +3 -3
  112. package/generated/manowar/esm/lib/config.d.ts +3 -3
  113. package/generated/manowar/esm/lib/config.js +3 -3
  114. package/generated/manowar/package.json +1 -1
  115. package/generated/manowar/src/lib/config.ts +3 -3
  116. package/generated/memory/esm/lib/config.d.ts +3 -3
  117. package/generated/memory/esm/lib/config.js +3 -3
  118. package/generated/memory/package.json +1 -1
  119. package/generated/memory/src/lib/config.ts +3 -3
  120. package/generated/x402/esm/lib/config.d.ts +3 -3
  121. package/generated/x402/esm/lib/config.js +3 -3
  122. package/generated/x402/package.json +1 -1
  123. package/generated/x402/src/lib/config.ts +3 -3
  124. package/package.json +2 -2
  125. package/specs/inference.openapi.yaml +1 -1
  126. package/specs/manowar.openapi.yaml +1 -1
  127. package/specs/memory.openapi.yaml +1 -1
  128. package/specs/x402.openapi.yaml +1 -1
@@ -1,7 +1,7 @@
1
1
  arazzo: 1.0.1
2
2
  info:
3
3
  title: Compose A2A — Agent-to-Agent x402 Payment & Stream
4
- version: 0.8.2
4
+ version: 0.8.3
5
5
  summary: |
6
6
  Complete recipe for calling any Compose agent from another agent, a shell
7
7
  script, or any HTTP client using x402 v2 payments. Covers all three EVM
@@ -1,7 +1,7 @@
1
1
  arazzo: 1.0.1
2
2
  info:
3
3
  title: Compose Memory — agent-first contracts
4
- version: 0.8.2
4
+ version: 0.8.3
5
5
  summary: |
6
6
  You are an agent. You have memory. Three calls cover 99% of turns.
7
7
 
@@ -2,7 +2,7 @@ arazzo: 1.0.1
2
2
  info:
3
3
  title: Compose SDK Agent-First Workflows
4
4
  summary: E2E workflow contracts for the Compose SDK, inference, x402, and manowar loops.
5
- version: 0.8.2
5
+ version: 0.8.3
6
6
  sourceDescriptions:
7
7
  - name: x402
8
8
  url: ../specs/x402.openapi.yaml
@@ -0,0 +1,2 @@
1
+ export * from "@compose-market/core/errors";
2
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,cAAc,6BAA6B,CAAC"}
package/dist/errors.js ADDED
@@ -0,0 +1,2 @@
1
+ export * from "@compose-market/core/errors";
2
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,cAAc,6BAA6B,CAAC"}
@@ -0,0 +1,202 @@
1
+ /**
2
+ * Typed event bus emitted by `ComposeSDK`.
3
+ *
4
+ * The event bus is the canonical way for application code to react to
5
+ * out-of-band signals from the Compose backend that arrive as a side effect
6
+ * of HTTP calls or SSE subscriptions:
7
+ *
8
+ * - `budget` — session-budget snapshot parsed from response headers
9
+ * on every billable call.
10
+ * - `sessionInvalid` — `x-session-invalid` header was set, the
11
+ * session must be torn down.
12
+ * - `sessionExpired` — SSE `session-expired` frame arrived from
13
+ * `/api/session/events`.
14
+ * - `sessionActive` — SSE `session-active` heartbeat frame arrived.
15
+ * - `receipt` — settlement receipt parsed from `X-Receipt`
16
+ * (or the SSE `event: receipt` frame).
17
+ * - `alert` — typed operational/client alert emitted by Compose
18
+ * services, for example session-stream lease rotation.
19
+ *
20
+ * Listeners are registered with `.on(event, listener)`. The bus is in-memory,
21
+ * single-process, unordered across listeners, and never blocks the caller —
22
+ * listener exceptions are logged via the SDK logger and discarded.
23
+ */
24
+ import type { AgentArtifactKind, Alert, Receipt, AgentEventDisplay, PlanDecision, SessionActiveEvent, SessionBudgetSnapshot, SessionExpiredEvent, SessionInvalidReason } from "./types/index.js";
25
+ export interface BudgetEvent {
26
+ userAddress: string | null;
27
+ chainId: number | null;
28
+ snapshot: SessionBudgetSnapshot;
29
+ /** Request that produced this snapshot. Matches `X-Request-Id`. */
30
+ requestId: string | null;
31
+ }
32
+ export interface SessionInvalidEvent {
33
+ userAddress: string | null;
34
+ chainId: number | null;
35
+ reason: SessionInvalidReason;
36
+ requestId: string | null;
37
+ }
38
+ export interface ReceiptEvent {
39
+ userAddress: string | null;
40
+ chainId: number | null;
41
+ receipt: Receipt;
42
+ requestId: string | null;
43
+ /**
44
+ * Which code path produced the receipt:
45
+ * - "response-header" — decoded from `X-Receipt` on a normal
46
+ * JSON response.
47
+ * - "stream" — parsed from the `event: receipt` SSE
48
+ * frame on a streaming inference call.
49
+ * - "body" — mirrored from the `receipt` field on
50
+ * the JSON body (fallback).
51
+ */
52
+ source: "response-header" | "stream" | "body";
53
+ }
54
+ export interface ToolCallLifecycleEvent {
55
+ userAddress: string | null;
56
+ chainId: number | null;
57
+ requestId: string | null;
58
+ /** Source stream kind — which resource produced this tool-call event. */
59
+ source: "chat" | "responses" | "agent" | "workflow";
60
+ /** Opaque id grouping start → end. Derived from the source event if present. */
61
+ toolCallId: string;
62
+ toolName: string;
63
+ /** Optional presentation label. `toolName` remains the stable raw tool id. */
64
+ displayName?: string;
65
+ /** Structured target metadata from the runtime, when available. */
66
+ display?: AgentEventDisplay;
67
+ targetKind?: AgentEventDisplay["kind"];
68
+ target?: string;
69
+ /** Human summary of what the tool is about to do / did. */
70
+ summary?: string;
71
+ /** `arguments` payload when the source stream includes it. */
72
+ arguments?: string;
73
+ /** Only present on `toolCallEnd`. */
74
+ failed?: boolean;
75
+ /** Only present on `toolCallEnd`, when the tool errored. */
76
+ error?: string;
77
+ }
78
+ export interface AgentStreamLifecycleEvent {
79
+ userAddress: string | null;
80
+ chainId: number | null;
81
+ requestId: string | null;
82
+ agentWallet: string;
83
+ threadId: string;
84
+ runId?: string;
85
+ }
86
+ export interface ChildAgentLifecycleEvent {
87
+ userAddress: string | null;
88
+ chainId: number | null;
89
+ requestId: string | null;
90
+ source: "agent";
91
+ event: "start" | "tool-start" | "tool-end" | "done" | "error";
92
+ rootRunId?: string;
93
+ parentRunId?: string;
94
+ subId?: string;
95
+ depth?: number;
96
+ agentWallet?: string;
97
+ runKey?: string;
98
+ runKeyChain?: string[];
99
+ toolName?: string;
100
+ input?: unknown;
101
+ output?: unknown;
102
+ failed?: boolean;
103
+ error?: string;
104
+ usage?: Record<string, unknown>;
105
+ toolBatches?: number;
106
+ stopReason?: string;
107
+ wallMs?: number;
108
+ display?: AgentEventDisplay;
109
+ ts?: number;
110
+ }
111
+ export interface PlanProposalEvent {
112
+ type: "plan.proposed" | "approval.requested" | "approval.decided" | "plan.feedback_requested";
113
+ proposalId: string;
114
+ version: number;
115
+ approvalId?: string;
116
+ state: string;
117
+ decision?: PlanDecision;
118
+ rootRunId?: string;
119
+ runId?: string;
120
+ requestedBy?: string;
121
+ proposal?: unknown;
122
+ markdown?: string;
123
+ ts?: number;
124
+ updatedAt?: number;
125
+ approver?: string;
126
+ reason?: string;
127
+ feedback?: string;
128
+ display?: AgentEventDisplay;
129
+ details?: Record<string, unknown>;
130
+ userAddress: string | null;
131
+ chainId: number | null;
132
+ requestId: string | null;
133
+ source: "agent";
134
+ }
135
+ export interface AgentArtifactEvent {
136
+ type: "artifact";
137
+ artifactType: AgentArtifactKind;
138
+ url?: string;
139
+ inline?: boolean;
140
+ mimeType?: string;
141
+ bytes?: number;
142
+ responseId?: string;
143
+ status?: string;
144
+ jobId?: string;
145
+ sourceTool?: string;
146
+ runKey?: string;
147
+ parentRunId?: string;
148
+ raw?: Record<string, unknown>;
149
+ userAddress: string | null;
150
+ chainId: number | null;
151
+ requestId: string | null;
152
+ source: "agent" | "child";
153
+ }
154
+ export interface WorkflowStreamLifecycleEvent {
155
+ userAddress: string | null;
156
+ chainId: number | null;
157
+ requestId: string | null;
158
+ workflowWallet: string;
159
+ threadId: string;
160
+ runId?: string;
161
+ }
162
+ export interface EventMap {
163
+ budget: BudgetEvent;
164
+ sessionInvalid: SessionInvalidEvent;
165
+ sessionActive: SessionActiveEvent;
166
+ sessionExpired: SessionExpiredEvent;
167
+ receipt: ReceiptEvent;
168
+ alert: Alert;
169
+ toolCallStart: ToolCallLifecycleEvent;
170
+ toolCallEnd: ToolCallLifecycleEvent;
171
+ childAgentStart: ChildAgentLifecycleEvent;
172
+ childAgentToolStart: ChildAgentLifecycleEvent;
173
+ childAgentToolEnd: ChildAgentLifecycleEvent;
174
+ childAgentDone: ChildAgentLifecycleEvent;
175
+ childAgentError: ChildAgentLifecycleEvent;
176
+ planProposed: PlanProposalEvent;
177
+ approvalRequested: PlanProposalEvent;
178
+ approvalDecided: PlanProposalEvent;
179
+ planFeedbackRequested: PlanProposalEvent;
180
+ agentArtifact: AgentArtifactEvent;
181
+ agentStreamStart: AgentStreamLifecycleEvent;
182
+ agentStreamEnd: AgentStreamLifecycleEvent;
183
+ workflowStreamStart: WorkflowStreamLifecycleEvent;
184
+ workflowStreamEnd: WorkflowStreamLifecycleEvent;
185
+ }
186
+ export type EventName = keyof EventMap;
187
+ export type EventListener<E extends EventName> = (event: EventMap[E]) => void | Promise<void>;
188
+ export interface EventBus {
189
+ on<E extends EventName>(event: E, listener: EventListener<E>): () => void;
190
+ once<E extends EventName>(event: E, listener: EventListener<E>): () => void;
191
+ off<E extends EventName>(event: E, listener: EventListener<E>): void;
192
+ emit<E extends EventName>(event: E, payload: EventMap[E]): void;
193
+ }
194
+ interface InternalBusOptions {
195
+ logger?: {
196
+ warn?: (msg: string, meta?: Record<string, unknown>) => void;
197
+ error?: (msg: string, meta?: Record<string, unknown>) => void;
198
+ };
199
+ }
200
+ export declare function createEventBus(options?: InternalBusOptions): EventBus;
201
+ export {};
202
+ //# sourceMappingURL=events.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../src/events.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,KAAK,EACR,iBAAiB,EACjB,KAAK,EACL,OAAO,EACP,iBAAiB,EACjB,YAAY,EACZ,kBAAkB,EAClB,qBAAqB,EACrB,mBAAmB,EACnB,oBAAoB,EACvB,MAAM,kBAAkB,CAAC;AAE1B,MAAM,WAAW,WAAW;IACxB,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,QAAQ,EAAE,qBAAqB,CAAC;IAChC,mEAAmE;IACnE,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;CAC5B;AAED,MAAM,WAAW,mBAAmB;IAChC,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,MAAM,EAAE,oBAAoB,CAAC;IAC7B,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;CAC5B;AAED,MAAM,WAAW,YAAY;IACzB,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,OAAO,EAAE,OAAO,CAAC;IACjB,S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E,CAAC,EAAE,QAAQ,EAAE,aAAa,CAAC,CAAC,CAAC,GAAG,MAAM,IAAI,CAAC;IAC1E,IAAI,CAAC,CAAC,SAAS,SAAS,EAAE,KAAK,EAAE,CAAC,EAAE,QAAQ,EAAE,aAAa,CAAC,CAAC,CAAC,GAAG,MAAM,IAAI,CAAC;IAC5E,GAAG,CAAC,CAAC,SAAS,SAAS,EAAE,KAAK,EAAE,CAAC,EAAE,QAAQ,EAAE,aAAa,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC;IACrE,IAAI,CAAC,CAAC,SAAS,SAAS,EAAE,KAAK,EAAE,CAAC,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC;CACnE;AAED,UAAU,kBAAkB;IACxB,MAAM,CAAC,EAAE;QACL,IAAI,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,IAAI,CAAC;QAC7D,KAAK,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,IAAI,CAAC;KACjE,CAAC;CACL;AAED,wBAAgB,cAAc,CAAC,OAAO,GAAE,kBAAuB,GAAG,QAAQ,CA8CzE"}
package/dist/events.js ADDED
@@ -0,0 +1,70 @@
1
+ /**
2
+ * Typed event bus emitted by `ComposeSDK`.
3
+ *
4
+ * The event bus is the canonical way for application code to react to
5
+ * out-of-band signals from the Compose backend that arrive as a side effect
6
+ * of HTTP calls or SSE subscriptions:
7
+ *
8
+ * - `budget` — session-budget snapshot parsed from response headers
9
+ * on every billable call.
10
+ * - `sessionInvalid` — `x-session-invalid` header was set, the
11
+ * session must be torn down.
12
+ * - `sessionExpired` — SSE `session-expired` frame arrived from
13
+ * `/api/session/events`.
14
+ * - `sessionActive` — SSE `session-active` heartbeat frame arrived.
15
+ * - `receipt` — settlement receipt parsed from `X-Receipt`
16
+ * (or the SSE `event: receipt` frame).
17
+ * - `alert` — typed operational/client alert emitted by Compose
18
+ * services, for example session-stream lease rotation.
19
+ *
20
+ * Listeners are registered with `.on(event, listener)`. The bus is in-memory,
21
+ * single-process, unordered across listeners, and never blocks the caller —
22
+ * listener exceptions are logged via the SDK logger and discarded.
23
+ */
24
+ export function createEventBus(options = {}) {
25
+ const listeners = new Map();
26
+ const logger = options.logger;
27
+ const register = (event, listener) => {
28
+ const existing = listeners.get(event) ?? new Set();
29
+ existing.add(listener);
30
+ listeners.set(event, existing);
31
+ return () => off(event, listener);
32
+ };
33
+ const off = (event, listener) => {
34
+ const set = listeners.get(event);
35
+ if (!set)
36
+ return;
37
+ set.delete(listener);
38
+ if (set.size === 0)
39
+ listeners.delete(event);
40
+ };
41
+ const emit = (event, payload) => {
42
+ const set = listeners.get(event);
43
+ if (!set || set.size === 0)
44
+ return;
45
+ // Iterate a snapshot so listeners that unsubscribe inside their own
46
+ // handler do not mutate the iteration order.
47
+ for (const listener of Array.from(set)) {
48
+ try {
49
+ const result = listener(payload);
50
+ if (result && typeof result.catch === "function") {
51
+ result.catch((err) => {
52
+ logger?.error?.(`[events] async listener for ${event} threw`, { err });
53
+ });
54
+ }
55
+ }
56
+ catch (err) {
57
+ logger?.error?.(`[events] listener for ${event} threw`, { err });
58
+ }
59
+ }
60
+ };
61
+ const once = (event, listener) => {
62
+ const wrapped = (payload) => {
63
+ off(event, wrapped);
64
+ return listener(payload);
65
+ };
66
+ return register(event, wrapped);
67
+ };
68
+ return { on: register, once, off, emit };
69
+ }
70
+ //# sourceMappingURL=events.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"events.js","sourceRoot":"","sources":["../src/events.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AA6MH,MAAM,UAAU,cAAc,CAAC,UAA8B,EAAE;IAC3D,MAAM,SAAS,GAAG,IAAI,GAAG,EAA4C,CAAC;IACtE,MAAM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,EAAE,EAAE;wBACpC,MAAM,EAAE,KAAK,EAAE,CAAC,+BAA+B,KAAK,QAAQ,EAAE,EAAE,GAAG,EAAE,CAAC,CAAC;oBAC3E,CAAC,CAAC,CAAC;gBACP,CAAC;YACL,CAAC;YAAC,OAAO,GAAG,EAAE,CAAC;gBACX,MAAM,EAAE,KAAK,EAAE,CAAC,yBAAyB,KAAK,QAAQ,EAAE,EAAE,GAAG,EAAE,CAAC,CAAC;YACrE,CAAC;QACL,CAAC;IACL,CAAC,CAAC;IAEF,MAAM,IAAI,GAAG,CAAsB,KAAQ,EAAE,QAA0B,EAAgB,EAAE;QACrF,MAAM,OAAO,GAAqB,CAAC,OAAO,EAAE,EAAE;YAC1C,GAAG,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;YACpB,OAAO,QAAQ,CAAC,OAAO,CAAC,CAAC;QAC7B,CAAC,CAAC;QACF,OAAO,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;IACpC,CAAC,CAAC;IAEF,OAAO,EAAE,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI,EAAE,CAAC;AAC7C,CAAC"}
@@ -0,0 +1,277 @@
1
+ /**
2
+ * `@compose-market/sdk` — Official SDK for Compose Market.
3
+ *
4
+ * Exposes the canonical header contract (`Authorization: Bearer compose-<jwt>`,
5
+ * `x-session-user-address`, `x-chain-id`) that powers Compose's first-party
6
+ * apps (web/, mesh/) and lets any third-party integrator embed:
7
+ *
8
+ * - Compose Key lifecycle (create / list / get / revoke, session metadata)
9
+ * - Multi-provider model catalog (list / listAll / search / get / getParams)
10
+ * - Native inference (chat.completions, responses, embeddings, images,
11
+ * audio.speech, audio.transcriptions, videos) with SSE streaming,
12
+ * typed tool-call deltas and reasoning deltas, typed cost receipts, and
13
+ * live session-budget updates emitted on every response.
14
+ * - x402 facilitator access (supported / chains / verify / settle) and typed
15
+ * decoders for PAYMENT-REQUIRED, PAYMENT-RESPONSE, X-Receipt.
16
+ * - Agent-first runtime memory loop (`sdk.memory.context`,
17
+ * `sdk.memory.recordTurn`, `sdk.memory.remember`, `sdk.memory.loop`) for
18
+ * compact pre-turn recall, post-turn persistence, and durable facts.
19
+ * - SSE session events (`sdk.session.events`) for budget depletion and
20
+ * expiry notifications, dispatched on the typed event bus as well.
21
+ * - Webhook signature verification (HMAC-SHA256, Stripe-style header).
22
+ * - Feedback/reputation submission and summaries for x402 flows, endpoints,
23
+ * models, agents, and workflows without coupling feedback to settlement.
24
+ *
25
+ * Design:
26
+ * - The orchestration client uses platform `fetch`, WebCrypto, TextDecoder,
27
+ * and ReadableStream. Generated OpenAPI subpath clients use Speakeasy's
28
+ * Zod-backed runtime validation.
29
+ * - Identity is whatever the integrator already has. The SDK does NOT call a
30
+ * wallet, does NOT request signatures, does NOT run KYC. The end-user's
31
+ * wallet address — produced by whatever auth stack the integrator already
32
+ * uses — is trusted in the same exact way our first-party apps trust it —
33
+ * via the `x-session-user-address` header. The Compose Key JWT returned by
34
+ * `keys.create(...)` is the real cryptographic identity from that point on.
35
+ * - Every billable call returns a `Completion<T>` carrying the parsed
36
+ * body, the settlement receipt (if any), the request id, the live session
37
+ * budget snapshot, the session-invalid reason (if any), and the raw
38
+ * Response so integrators can read non-standard headers without parsing.
39
+ * - Persisted session tokens survive page reloads when a storage adapter is
40
+ * provided (browser `localStorage` is auto-detected).
41
+ */
42
+ import { type FetchLike, type HttpClientOptions, type RetryPolicy } from "@compose-market/core/http";
43
+ import { KeysResource } from "./resources/keys.js";
44
+ import { ModelsResource } from "./resources/models.js";
45
+ import { InferenceResource } from "./resources/inference.js";
46
+ import { X402Resource } from "./resources/x402.js";
47
+ import { WebhooksResource } from "./resources/webhooks.js";
48
+ import { SessionEventsResource, type SessionEventsOptions } from "./resources/session-events.js";
49
+ import { AgentResource } from "./resources/agent.js";
50
+ import { WorkflowResource } from "./resources/workflow.js";
51
+ import { MemoryResource } from "./resources/memory.js";
52
+ import { FeedbackResource } from "./resources/feedback.js";
53
+ import { DirectoryResource } from "./resources/directory.js";
54
+ import { SystemResource } from "./resources/system.js";
55
+ import { LocalResource } from "./resources/local.js";
56
+ import { DispenserResource } from "./resources/dispenser.js";
57
+ import { SettlementResource } from "./resources/settlement.js";
58
+ import { PermissionsResource } from "./resources/permissions.js";
59
+ import { AccountsResource } from "./resources/accounts.js";
60
+ import { ChannelsResource } from "./resources/channels.js";
61
+ import { ReceiptsResource } from "./resources/receipts.js";
62
+ import { type EventBus, type EventListener } from "./events.js";
63
+ import { type Storage } from "@compose-market/core/storage";
64
+ import type { X402PaymentSigner } from "./types/index.js";
65
+ import type { CallOptions } from "./resources/inference.js";
66
+ export * from "./types/index.js";
67
+ export * from "./errors.js";
68
+ export type { APIPromise, HeaderBagInput, HttpClientOptions, RequestOptions, RetryPolicy, } from "@compose-market/core/http";
69
+ export type { CallOptions, Completion, ChatCompletionFinalResult, ResponsesStreamFinalResult, StreamIterator, InferenceContext, } from "./resources/inference.js";
70
+ export type { WebhookEvent, VerifyWebhookInput, } from "./resources/webhooks.js";
71
+ export type { BudgetEvent, EventBus, EventListener, EventMap, EventName, ReceiptEvent, SessionInvalidEvent, ToolCallLifecycleEvent, ChildAgentLifecycleEvent, AgentArtifactEvent, PlanProposalEvent, AgentStreamLifecycleEvent, WorkflowStreamLifecycleEvent, } from "./events.js";
72
+ export type { Storage } from "@compose-market/core/storage";
73
+ export type { SessionEventsOptions } from "./resources/session-events.js";
74
+ export type { AgentResource, RunEvent } from "./resources/agent.js";
75
+ export type { WorkflowEvent, WorkflowResource } from "./resources/workflow.js";
76
+ export type { MemoryResource } from "./resources/memory.js";
77
+ export type { FeedbackResource } from "./resources/feedback.js";
78
+ export type { DirectoryResource } from "./resources/directory.js";
79
+ export type { SystemResource } from "./resources/system.js";
80
+ export type { LocalResource } from "./resources/local.js";
81
+ export type { DispenserResource } from "./resources/dispenser.js";
82
+ export type { SettlementResource } from "./resources/settlement.js";
83
+ export type { PermissionsResource } from "./resources/permissions.js";
84
+ export type { AccountsResource } from "./resources/accounts.js";
85
+ export type { ChannelsResource } from "./resources/channels.js";
86
+ export type { ReceiptsResource, ReceiptListOptions } from "./resources/receipts.js";
87
+ export { decodeReceiptHeader, extractReceiptFromResponse, parseReceiptEvent } from "@compose-market/core/sse/receipt";
88
+ export { extractSessionBudgetFromResponse } from "@compose-market/core/sse/budget";
89
+ export { parseSSEStream, parse, format, named, done } from "@compose-market/core/transport";
90
+ export type { Frame, SSEFrame } from "@compose-market/core/transport";
91
+ export { create as createModelState, decode as decodeModelEvent, reduce as reduceModelState, } from "@compose-market/core/model";
92
+ export type { AssetKind, ModelAsset, ModelEvent, ModelState, ModelStatus, } from "@compose-market/core/model";
93
+ export { create as createActivityState, decode as decodeActivityEvent, reduce as reduceActivityState, } from "@compose-market/core/activity";
94
+ export type { ActivityEvent, ActivityKind, ActivityNode, ActivityState, ActivityStatus, ActivityTarget, } from "@compose-market/core/activity";
95
+ export { createPrivateKeyX402EvmSigner, createPrivateKeyX402EvmWallet, createX402EvmSigner, encodePaymentPayload, encodePaymentSignature, } from "./resources/x402.js";
96
+ export { createMemoryStorage } from "@compose-market/core/storage";
97
+ export * as tools from "./tools/index.js";
98
+ export type { ToolEvent, ToolEventKind, ToolEventDisplay, ModelToolEvent, ConnectorToolEvent, AgentToolEvent, SearchToolEvent, CatalogToolEvent } from "./tools/index.js";
99
+ export { parseToolEvent } from "./tools/index.js";
100
+ export { commands, msm } from "@compose-market/core";
101
+ export type { Command, ActionSource, NativeAction, ActionScope, GoalState, GoalStatus, GoalRunState, PlanState, PlanStatus, TaskRecord, TaskStatus, PlanRunState, ActionEvent, TaskObservation, GoalObservation, ActionResult } from "@compose-market/core/commands";
102
+ export type { Mode, Scope, Stage, Source, Signal, ActionKind, ObservationStatus, ToolState, RouteState, FlagState, Route, Classification, Budget, AgentStreamControls, Action, Transition, Observation, Entry, Snapshot } from "@compose-market/core/msm";
103
+ /**
104
+ * Constructor options for `ComposeSDK`.
105
+ */
106
+ export interface ComposeSDKOptions {
107
+ /** API base URL. Defaults to `https://api.compose.market`. */
108
+ baseUrl?: string;
109
+ /** Channels service URL. Defaults to `https://services.compose.market`. */
110
+ channelsUrl?: string;
111
+ /** Custom fetch implementation. Defaults to the global `fetch`. */
112
+ fetch?: FetchLike;
113
+ /**
114
+ * End-user wallet address. Whatever identity stack you already use produced
115
+ * this address — pass it through. The SDK relays it exactly as our
116
+ * first-party apps do, and does not care how you obtained it.
117
+ */
118
+ userAddress?: string;
119
+ /**
120
+ * Chain id. Must be one of the facilitator-configured chains. Call
121
+ * `sdk.x402.facilitator.chains()` to enumerate supported chains + USDC
122
+ * contracts at runtime.
123
+ */
124
+ chainId?: number;
125
+ /**
126
+ * A previously-issued Compose Key JWT. The SDK stores this in-memory and
127
+ * attaches it as `Authorization: Bearer compose-<jwt>` on every call.
128
+ *
129
+ * When a `storage` adapter is present, the token is also persisted under
130
+ * the scoped key `<tokenScope>:<address>:<chainId>` so that it survives
131
+ * page reloads. If `key` is omitted at construction, the SDK
132
+ * attempts to hydrate from storage.
133
+ */
134
+ key?: string;
135
+ /** Default timeout for each HTTP call, in milliseconds. Default 60_000. */
136
+ timeoutMs?: number;
137
+ /** Retry policy applied to transient errors (5xx, 429, network). */
138
+ retry?: Partial<RetryPolicy>;
139
+ /** Headers merged into every request. */
140
+ defaultHeaders?: Record<string, string>;
141
+ /**
142
+ * `User-Agent` suffix so Compose analytics can distinguish integrators.
143
+ * The base string is `@compose-market/sdk/<version>`.
144
+ */
145
+ userAgent?: string;
146
+ /** Optional debug/logging hooks. */
147
+ logger?: HttpClientOptions["logger"];
148
+ /**
149
+ * Pluggable persistent storage. Auto-detects `globalThis.localStorage` on
150
+ * browsers/Workers. Pass an explicit adapter on Node/server runtimes if
151
+ * you want the session token to survive process restarts.
152
+ */
153
+ storage?: Storage;
154
+ /**
155
+ * Namespace prefix for persisted tokens. The full key shape is
156
+ * `<tokenScope>:<lower-address>:<chainId>`. Defaults to
157
+ * `compose.sdk.token`. Bump this only if you need to invalidate every
158
+ * persisted token at once (e.g. after a breaking server auth change).
159
+ */
160
+ tokenScope?: string;
161
+ /**
162
+ * Provider-agnostic x402 signer. The SDK calls this only after receiving a
163
+ * real PAYMENT-REQUIRED challenge, then retries the request with the
164
+ * returned PAYMENT-SIGNATURE. Integrators can back this with Thirdweb,
165
+ * Privy, Dynamic, a browser wallet, a server wallet, or any other signer.
166
+ */
167
+ x402Signer?: X402PaymentSigner;
168
+ }
169
+ export declare class ComposeSDK {
170
+ /** The SDK version, sourced from package.json at build time. */
171
+ readonly version: string;
172
+ /** Resolved API base URL, trimmed of trailing slashes. */
173
+ readonly baseUrl: string;
174
+ /** Resolved channels service URL, trimmed of trailing slashes. */
175
+ readonly channelsUrl: string;
176
+ readonly keys: KeysResource;
177
+ readonly models: ModelsResource;
178
+ readonly inference: InferenceResource;
179
+ readonly x402: X402Resource;
180
+ readonly webhooks: WebhooksResource;
181
+ readonly session: SessionEventsNamespace;
182
+ readonly agent: AgentResource;
183
+ readonly workflow: WorkflowResource;
184
+ readonly memory: MemoryResource;
185
+ readonly feedback: FeedbackResource;
186
+ readonly directory: DirectoryResource;
187
+ readonly system: SystemResource;
188
+ readonly local: LocalResource;
189
+ readonly dispenser: DispenserResource;
190
+ readonly settlement: SettlementResource;
191
+ readonly permissions: PermissionsResource;
192
+ readonly accounts: AccountsResource;
193
+ readonly channels: ChannelsResource;
194
+ readonly receipts: ReceiptsResource;
195
+ readonly wallets: {
196
+ attach: (input: {
197
+ address: string;
198
+ chainId: number;
199
+ }) => void;
200
+ current: () => {
201
+ address: string | null;
202
+ chainId: number | null;
203
+ };
204
+ clear: () => void;
205
+ };
206
+ /**
207
+ * Typed, in-memory event bus. Listeners registered here receive:
208
+ * - `budget` — live `x-session-budget-*` snapshot on every billable call.
209
+ * - `sessionInvalid` — `x-session-invalid` header set by the server.
210
+ * - `sessionActive` — SSE `session-active` heartbeat from `/api/session/events`.
211
+ * - `sessionExpired` — SSE `session-expired` frame from `/api/session/events`.
212
+ * - `receipt` — settlement receipt on every billable response / stream.
213
+ */
214
+ readonly events: EventBus;
215
+ private readonly http;
216
+ private readonly storage;
217
+ private readonly tokenScope;
218
+ private userAddress;
219
+ private chainId;
220
+ private key;
221
+ private readonly x402Signer;
222
+ private readonly rawFetch;
223
+ private readonly userAgent;
224
+ constructor(options?: ComposeSDKOptions);
225
+ private persistToken;
226
+ private deletePersistedToken;
227
+ /**
228
+ * Drop-in `fetch` wrapper that attaches the canonical Compose header
229
+ * contract (`Authorization`, `x-session-user-address`, `x-chain-id`,
230
+ * SDK client headers) on every request and emits `budget` / `sessionInvalid` /
231
+ * `receipt` events on every response via the SDK event bus.
232
+ *
233
+ * Use this when you need to hit a Compose endpoint that isn't covered
234
+ * by a typed resource yet (agent/workflow runtime endpoints, workspace
235
+ * indexing, custom api/ routes). The URL may be absolute or relative to
236
+ * the SDK's `baseUrl`.
237
+ *
238
+ * Non-Compose URLs (absolute URLs whose host differs from `baseUrl`) are
239
+ * still passed through so this method is safe as a general-purpose fetch
240
+ * replacement; the budget event extraction is a no-op when the response
241
+ * doesn't carry `x-session-budget-*` headers.
242
+ */
243
+ fetch(input: RequestInfo | URL, init?: RequestInit & CallOptions): Promise<Response>;
244
+ }
245
+ /**
246
+ * Thin ergonomic wrapper around `SessionEventsResource` so callers write
247
+ * `sdk.session.events({ ... })` with wallet defaults inferred from the SDK
248
+ * instance.
249
+ */
250
+ declare class SessionEventsNamespace {
251
+ private readonly resource;
252
+ private readonly getWalletMaybe;
253
+ constructor(resource: SessionEventsResource, getWalletMaybe: () => {
254
+ address: string | null;
255
+ chainId: number | null;
256
+ });
257
+ /**
258
+ * Subscribe to `/api/session/events`. Yields `SessionActiveEvent` and
259
+ * `SessionExpiredEvent` until the signal aborts or the server ends the
260
+ * stream. The same events are also emitted on `sdk.events`.
261
+ *
262
+ * When `userAddress` / `chainId` are omitted, the SDK's currently attached
263
+ * wallet context is used. Abort via an `AbortController.signal`.
264
+ */
265
+ subscribe(opts?: Partial<SessionEventsOptions>): AsyncIterable<import("@compose-market/core").SessionEvent>;
266
+ /**
267
+ * Shortcut: register a listener on the `sessionActive` + `sessionExpired`
268
+ * events produced by a subscription. Returns a disposer that aborts the
269
+ * underlying stream AND removes the listeners.
270
+ */
271
+ on(handlers: {
272
+ active?: EventListener<"sessionActive">;
273
+ expired?: EventListener<"sessionExpired">;
274
+ }, opts?: Partial<SessionEventsOptions>): () => void;
275
+ }
276
+ export default ComposeSDK;
277
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AAEH,OAAO,EAKH,KAAK,SAAS,EACd,KAAK,iBAAiB,EACtB,KAAK,WAAW,EACnB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,qBAAqB,EAAE,KAAK,oBAAoB,EAAE,MAAM,+BAA+B,CAAC;AACjG,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,aAAa,EAAE,MAAM,sB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