@once-agent/sdk 0.1.0 → 0.1.2

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.
@@ -0,0 +1,247 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Once = exports.OnceNetworkError = exports.OnceTimeoutError = exports.OnceError = void 0;
4
+ const node_buffer_1 = require("node:buffer");
5
+ const node_crypto_1 = require("node:crypto");
6
+ const DEFAULT_BASE_URL = "https://once-q18-cloud.pennywatch.workers.dev";
7
+ class OnceError extends Error {
8
+ status;
9
+ code;
10
+ body;
11
+ retryAfter;
12
+ constructor(message, options = {}) {
13
+ super(message, {
14
+ cause: options.cause
15
+ });
16
+ this.name = "OnceError";
17
+ this.status = options.status;
18
+ this.code = options.code;
19
+ this.body = options.body;
20
+ this.retryAfter = options.retryAfter;
21
+ }
22
+ }
23
+ exports.OnceError = OnceError;
24
+ class OnceTimeoutError extends OnceError {
25
+ constructor(message = "Once request timed out", cause) {
26
+ super(message, {
27
+ code: "timeout",
28
+ cause
29
+ });
30
+ this.name = "OnceTimeoutError";
31
+ }
32
+ }
33
+ exports.OnceTimeoutError = OnceTimeoutError;
34
+ class OnceNetworkError extends OnceError {
35
+ constructor(message = "Could not reach Once", cause) {
36
+ super(message, {
37
+ code: "network_error",
38
+ cause
39
+ });
40
+ this.name = "OnceNetworkError";
41
+ }
42
+ }
43
+ exports.OnceNetworkError = OnceNetworkError;
44
+ class Once {
45
+ apiKey;
46
+ baseUrl;
47
+ timeoutMs;
48
+ networkRetries;
49
+ constructor(options = {}) {
50
+ const apiKey = options.apiKey ??
51
+ process.env.ONCE_API_KEY;
52
+ if (!apiKey) {
53
+ throw new OnceError("Missing Once API key. Set ONCE_API_KEY or pass { apiKey }.", {
54
+ code: "missing_api_key"
55
+ });
56
+ }
57
+ this.apiKey = apiKey;
58
+ this.baseUrl = (options.baseUrl ??
59
+ process.env.ONCE_BASE_URL ??
60
+ DEFAULT_BASE_URL).replace(/\/+$/, "");
61
+ this.timeoutMs =
62
+ options.timeoutMs ?? 10_000;
63
+ this.networkRetries =
64
+ options.networkRetries ?? 2;
65
+ }
66
+ /**
67
+ * Generate a deterministic Once operation ID.
68
+ *
69
+ * Same inputs => same ID.
70
+ *
71
+ * Example:
72
+ * Once.id("refund", "order_123")
73
+ */
74
+ static id(...parts) {
75
+ if (parts.length === 0) {
76
+ throw new OnceError("Once.id() requires at least one value.", {
77
+ code: "invalid_operation_id"
78
+ });
79
+ }
80
+ const values = parts.map(part => {
81
+ if (typeof part === "string") {
82
+ return part;
83
+ }
84
+ if (typeof part === "number" &&
85
+ Number.isSafeInteger(part)) {
86
+ return String(part);
87
+ }
88
+ throw new OnceError("Once.id() parts must be strings or safe integers.", {
89
+ code: "invalid_operation_id"
90
+ });
91
+ });
92
+ /*
93
+ * Once operation-ID semantic encoding v1.
94
+ *
95
+ * Hash input:
96
+ * "once-id-v1\\0"
97
+ * uint32be(part count)
98
+ * repeated:
99
+ * uint32be(UTF-8 byte length)
100
+ * UTF-8 bytes
101
+ *
102
+ * Length-prefixing prevents different part
103
+ * boundaries from producing identical hash input.
104
+ */
105
+ const hashState = (0, node_crypto_1.createHash)("sha256");
106
+ hashState.update("once-id-v1\u0000", "utf8");
107
+ const partCount = node_buffer_1.Buffer.allocUnsafe(4);
108
+ partCount.writeUInt32BE(values.length, 0);
109
+ hashState.update(partCount);
110
+ for (const value of values) {
111
+ const bytes = node_buffer_1.Buffer.from(value, "utf8");
112
+ if (bytes.length >
113
+ 0xffffffff) {
114
+ throw new OnceError("Once.id() part is too large.", {
115
+ code: "invalid_operation_id"
116
+ });
117
+ }
118
+ const length = node_buffer_1.Buffer.allocUnsafe(4);
119
+ length.writeUInt32BE(bytes.length, 0);
120
+ hashState.update(length);
121
+ hashState.update(bytes);
122
+ }
123
+ const hash = hashState
124
+ .digest("hex")
125
+ .slice(0, 32);
126
+ const prefix = values[0]
127
+ .replace(/[A-Z]/g, character => character.toLowerCase())
128
+ .replace(/[^a-z0-9._:-]+/g, "-")
129
+ .replace(/^[^a-z0-9]+/, "")
130
+ .replace(/-+$/g, "")
131
+ .slice(0, 48) || "operation";
132
+ return `${prefix}:${hash}`;
133
+ }
134
+ id(...parts) {
135
+ return Once.id(...parts);
136
+ }
137
+ async execute(input) {
138
+ if (!input.operationId) {
139
+ throw new OnceError("operationId is required.", {
140
+ code: "invalid_operation_id"
141
+ });
142
+ }
143
+ if (!input.provider) {
144
+ throw new OnceError("provider is required.", {
145
+ code: "invalid_provider"
146
+ });
147
+ }
148
+ return this.request("/v1/execute", {
149
+ method: "POST",
150
+ body: JSON.stringify({
151
+ operation_id: input.operationId,
152
+ provider: input.provider,
153
+ action: input.action
154
+ })
155
+ });
156
+ }
157
+ async truth(operationId) {
158
+ if (!operationId) {
159
+ throw new OnceError("operationId is required.", {
160
+ code: "invalid_operation_id"
161
+ });
162
+ }
163
+ return this.request(`/v1/truth/${encodeURIComponent(operationId)}`, {
164
+ method: "GET"
165
+ });
166
+ }
167
+ async request(path, init) {
168
+ let lastError;
169
+ for (let attempt = 0; attempt <= this.networkRetries; attempt++) {
170
+ const controller = new AbortController();
171
+ const timeout = setTimeout(() => controller.abort(), this.timeoutMs);
172
+ try {
173
+ const response = await fetch(`${this.baseUrl}${path}`, {
174
+ ...init,
175
+ signal: controller.signal,
176
+ headers: {
177
+ authorization: `Bearer ${this.apiKey}`,
178
+ "content-type": "application/json",
179
+ ...init.headers
180
+ }
181
+ });
182
+ clearTimeout(timeout);
183
+ const raw = await response.text();
184
+ let body = null;
185
+ if (raw) {
186
+ try {
187
+ body = JSON.parse(raw);
188
+ }
189
+ catch {
190
+ body = {
191
+ message: raw
192
+ };
193
+ }
194
+ }
195
+ if (!response.ok) {
196
+ const retryAfterHeader = response.headers.get("retry-after");
197
+ const retryAfter = retryAfterHeader !== null
198
+ ? Number(retryAfterHeader)
199
+ : undefined;
200
+ const code = body?.error ??
201
+ body?.result ??
202
+ `http_${response.status}`;
203
+ const message = body?.message ??
204
+ body?.error ??
205
+ body?.result ??
206
+ `Once returned HTTP ${response.status}`;
207
+ throw new OnceError(String(message), {
208
+ status: response.status,
209
+ code: String(code),
210
+ body,
211
+ retryAfter: Number.isFinite(retryAfter)
212
+ ? retryAfter
213
+ : undefined
214
+ });
215
+ }
216
+ return body;
217
+ }
218
+ catch (error) {
219
+ clearTimeout(timeout);
220
+ // Once returned a real HTTP response.
221
+ // Do not hide or automatically transform it.
222
+ if (error instanceof OnceError) {
223
+ throw error;
224
+ }
225
+ lastError = error;
226
+ const aborted = error instanceof Error &&
227
+ error.name === "AbortError";
228
+ if (attempt <
229
+ this.networkRetries) {
230
+ await sleep(150 * Math.pow(2, attempt));
231
+ continue;
232
+ }
233
+ if (aborted) {
234
+ throw new OnceTimeoutError(`Once request timed out after ${this.timeoutMs}ms`, error);
235
+ }
236
+ throw new OnceNetworkError("Could not reach Once after safe network retries", error);
237
+ }
238
+ }
239
+ throw new OnceNetworkError("Could not reach Once", lastError);
240
+ }
241
+ }
242
+ exports.Once = Once;
243
+ function sleep(ms) {
244
+ return new Promise(resolve => setTimeout(resolve, ms));
245
+ }
246
+ exports.default = Once;
247
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,6CAAqC;AACpC,6CAAyC;AAE1C,MAAM,gBAAgB,GACpB,+CAA+C,CAAC;AA8ClD,MAAa,SAAU,SAAQ,KAAK;IACzB,MAAM,CAAU;IAChB,IAAI,CAAU;IACd,IAAI,CAAW;IACf,UAAU,CAAU;IAE7B,YACE,OAAe,EACf,UAMI,EAAE;QAEN,KAAK,CAAC,OAAO,EAAE;YACb,KAAK,EAAE,OAAO,CAAC,KAAK;SACrB,CAAC,CAAC;QAEH,IAAI,CAAC,IAAI,GAAG,WAAW,CAAC;QACxB,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;QAC7B,IAAI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;gBACf,YAAY,CAAC,OAAO,CAAC,CAAC;gBAEtB,sCAAsC;gBACtC,6CAA6C;gBAC7C,IAAI,KAAK,YAAY,SAAS,EAAE,CAAC;oBAC/B,MAAM,KAAK,CAAC;gBACd,CAAC;gBAED,SAAS,GAAG,KAAK,CAAC;gBAElB,MAAM,OAAO,GACX,KAAK,YAAY,KAAK;oBACtB,KAAK,CAAC,IAAI,KAAK,YAAY,CAAC;gBAE9B,IACE,OAAO;oBACP,IAAI,CAAC,cAAc,EACnB,CAAC;oBACD,MAAM,KAAK,CACT,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,OAAO,CAAC,CAC3B,CAAC;oBAEF,SAAS;gBACX,CAAC;gBAED,IAAI,OAAO,EAAE,CAAC;oBACZ,MAAM,IAAI,gBAAgB,CACxB,gCAAgC,IAAI,CAAC,SAAS,IAAI,EAClD,KAAK,CACN,CAAC;gBACJ,CAAC;gBAED,MAAM,IAAI,gBAAgB,CACxB,iDAAiD,EACjD,KAAK,CACN,CAAC;YACJ,CAAC;QACH,CAAC;QAED,MAAM,IAAI,gBAAgB,CACxB,sBAAsB,EACtB,SAAS,CACV,CAAC;IACJ,CAAC;CACF;AA3WD,oBA2WC;AAED,SAAS,KAAK,CAAC,EAAU;IACvB,OAAO,IAAI,OAAO,CAAC,OAAO,CAAC,EAAE,CAC3B,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC,CACxB,CAAC;AACJ,CAAC;AAED,kBAAe,IAAI,CAAC"}
@@ -0,0 +1,3 @@
1
+ {
2
+ "type": "commonjs"
3
+ }
package/package.json CHANGED
@@ -1,56 +1,61 @@
1
- {
2
- "name": "@once-agent/sdk",
3
- "version": "0.1.0",
4
- "description": "Execution safety for side-effecting AI agent tools.",
5
- "type": "module",
6
- "main": "./dist/index.js",
7
- "types": "./dist/index.d.ts",
8
- "exports": {
9
- ".": {
10
- "types": "./dist/index.d.ts",
11
- "import": "./dist/index.js"
12
- }
13
- },
14
- "files": [
15
- "dist",
16
- "README.md"
17
- ],
18
- "scripts": {
19
- "build": "tsc",
20
- "typecheck": "tsc --noEmit",
21
- "benchmark:scan": "npm run build && node ./scripts/scan-benchmark.mjs",
22
- "test:contract": "npm run build && tsc --noEmit --target ES2022 --module NodeNext --moduleResolution NodeNext --strict --types node ./scripts/sdk-contract-types.ts && node ./scripts/sdk-contract-runtime.mjs",
23
- "test:release": "npm run benchmark:scan && npm run test:scanner-declarations && npm run test:contract && npm run test:protect && npm run test:capabilities && npm run test:transformer && npm run test:binding && npm run test:patch-planner && npm run test:transformer-protect && npm run test:apply && npm run test:id-conformance && npm run test:consumer && npm run test:package",
24
- "test:protect": "npm run build && node ./scripts/protect-regression.mjs",
25
- "test:capabilities": "npm run build && node ./scripts/capability-regression.mjs",
26
- "test:transformer": "npm run build && node ./scripts/http-transformer-regression.mjs",
27
- "test:scanner-declarations": "npm run build && node ./scripts/scanner-declaration-regression.mjs",
28
- "test:transformer-protect": "npm run build && node ./scripts/transformer-protect-regression.mjs",
29
- "test:binding": "npm run build && node ./scripts/once-binding-regression.mjs",
30
- "test:patch-planner": "npm run build && node ./scripts/http-patch-planner-regression.mjs",
31
- "test:apply": "npm run build && node ./scripts/apply-engine-regression.mjs && node ./scripts/apply-regression.mjs",
32
- "test:package": "npm run build && node ./scripts/package-isolation-regression.mjs",
33
- "test:consumer": "npm run build && node ./scripts/consumer-package-regression.mjs",
34
- "test:id-conformance": "npm run build && node ./scripts/id-conformance-regression.mjs"
35
- },
36
- "keywords": [
37
- "ai",
38
- "agents",
39
- "idempotency",
40
- "reliability",
41
- "execution-safety"
42
- ],
43
- "license": "MIT",
44
- "engines": {
45
- "node": ">=18"
46
- },
47
- "devDependencies": {
48
- "@types/node": "^26.6.1"
49
- },
50
- "bin": {
51
- "once": "./dist/cli.js"
52
- },
53
- "dependencies": {
54
- "typescript": "^5.9.0"
55
- }
56
- }
1
+ {
2
+ "name": "@once-agent/sdk",
3
+ "version": "0.1.2",
4
+ "description": "Execution safety for side-effecting AI agent tools.",
5
+ "type": "module",
6
+ "main": "./dist/index.js",
7
+ "types": "./dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "import": "./dist/index.js",
12
+ "require": "./dist-cjs/index.js"
13
+ }
14
+ },
15
+ "files": [
16
+ "dist",
17
+ "README.md",
18
+ "dist-cjs"
19
+ ],
20
+ "scripts": {
21
+ "build": "npm run build:esm && npm run build:cjs",
22
+ "typecheck": "tsc --noEmit",
23
+ "benchmark:scan": "npm run build && node ./scripts/scan-benchmark.mjs",
24
+ "test:contract": "npm run build && tsc --noEmit --target ES2022 --module NodeNext --moduleResolution NodeNext --strict --types node ./scripts/sdk-contract-types.ts && node ./scripts/sdk-contract-runtime.mjs",
25
+ "test:release": "npm run benchmark:scan && npm run test:scanner-declarations && npm run test:contract && npm run test:protect && npm run test:capabilities && npm run test:transformer && npm run test:binding && npm run test:patch-planner && npm run test:transformer-protect && npm run test:apply && npm run test:id-conformance && npm run test:consumer && npm run test:activation && npm run test:package",
26
+ "test:protect": "npm run build && node ./scripts/protect-regression.mjs",
27
+ "test:capabilities": "npm run build && node ./scripts/capability-regression.mjs",
28
+ "test:transformer": "npm run build && node ./scripts/http-transformer-regression.mjs",
29
+ "test:scanner-declarations": "npm run build && node ./scripts/scanner-declaration-regression.mjs",
30
+ "test:transformer-protect": "npm run build && node ./scripts/transformer-protect-regression.mjs",
31
+ "test:binding": "npm run build && node ./scripts/once-binding-regression.mjs",
32
+ "test:patch-planner": "npm run build && node ./scripts/http-patch-planner-regression.mjs",
33
+ "test:apply": "npm run build && node ./scripts/apply-engine-regression.mjs && node ./scripts/apply-regression.mjs",
34
+ "test:package": "npm run build && node ./scripts/package-isolation-regression.mjs",
35
+ "test:consumer": "npm run build && node ./scripts/consumer-package-regression.mjs",
36
+ "test:id-conformance": "npm run build && node ./scripts/id-conformance-regression.mjs",
37
+ "build:esm": "tsc -p tsconfig.json",
38
+ "build:cjs": "tsc -p tsconfig.cjs.json && node ./scripts/write-cjs-package.mjs",
39
+ "test:activation": "npm run build && node ./scripts/activation-regression.mjs"
40
+ },
41
+ "keywords": [
42
+ "ai",
43
+ "agents",
44
+ "idempotency",
45
+ "reliability",
46
+ "execution-safety"
47
+ ],
48
+ "license": "MIT",
49
+ "engines": {
50
+ "node": ">=18"
51
+ },
52
+ "devDependencies": {
53
+ "@types/node": "^26.6.1"
54
+ },
55
+ "bin": {
56
+ "once": "./dist/cli.js"
57
+ },
58
+ "dependencies": {
59
+ "typescript": "^5.9.0"
60
+ }
61
+ }