ax 0.2.2 → 0.7.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.js ADDED
@@ -0,0 +1,563 @@
1
+ // src/contract/version.ts
2
+ var BUILT_AGAINST = "1.23.0";
3
+
4
+ // src/contract/index.ts
5
+ function minor(version) {
6
+ const [major = 0, min = 0] = version.split(".").map((n) => Number.parseInt(n, 10));
7
+ return [major, min];
8
+ }
9
+ function isNewerContract(payloadVersion) {
10
+ if (!payloadVersion || !/^\d+\.\d+\.\d+$/.test(payloadVersion)) return false;
11
+ const [serverMajor, serverMinor] = minor(payloadVersion);
12
+ const [builtMajor, builtMinor] = minor(BUILT_AGAINST);
13
+ return serverMajor > builtMajor || serverMajor === builtMajor && serverMinor > builtMinor;
14
+ }
15
+ var warned = false;
16
+ function warnOnNewerContract(payloadVersion) {
17
+ if (warned || !isNewerContract(payloadVersion)) return;
18
+ warned = true;
19
+ process.stderr.write(
20
+ `ora reports contract ${payloadVersion}; this CLI was built against ${BUILT_AGAINST}. Newer fields may be missing from the output - upgrade with: npm i -g ax@latest
21
+ `
22
+ );
23
+ }
24
+
25
+ // src/api/shared.ts
26
+ function watchdog(ms) {
27
+ const controller = new AbortController();
28
+ let fired = false;
29
+ let timer;
30
+ const poke = () => {
31
+ clearTimeout(timer);
32
+ timer = setTimeout(() => {
33
+ fired = true;
34
+ controller.abort();
35
+ }, ms);
36
+ };
37
+ poke();
38
+ return {
39
+ signal: controller.signal,
40
+ poke,
41
+ disarm: () => clearTimeout(timer),
42
+ tripped: () => fired
43
+ };
44
+ }
45
+ async function errorBodyText(res) {
46
+ try {
47
+ const payload = await res.json();
48
+ return payload.message || payload.error || `HTTP ${res.status}`;
49
+ } catch {
50
+ return `HTTP ${res.status}`;
51
+ }
52
+ }
53
+ var pause = (ms) => new Promise((r) => setTimeout(r, ms));
54
+
55
+ // src/api/audit.ts
56
+ var PUBLIC_BASE = "https://ora.ai";
57
+ var STREAM_IDLE_MS = 6e4;
58
+ var POLL_EVERY_MS = 2e3;
59
+ var POLL_LIMIT = 45;
60
+ var BAR_CELLS = 14;
61
+ var AuditApiError = class extends Error {
62
+ };
63
+ function authHeaders(apiKey) {
64
+ return apiKey ? { authorization: `Bearer ${apiKey}` } : {};
65
+ }
66
+ async function performAudit(target, options = {}) {
67
+ const base = (options.baseUrl ?? process.env.ORA_API_URL ?? PUBLIC_BASE).replace(/\/+$/, "");
68
+ options = { ...options, apiKey: options.apiKey || process.env.ORA_SCAN_API_KEY || void 0 };
69
+ options.progress?.(`Auditing ${target} with ora`);
70
+ const streamed = await consumeScanStream(base, target, options);
71
+ warnOnNewerContract(streamed.result.contractVersion);
72
+ let result = streamed.result;
73
+ if (stillAnalyzing(result)) result = await awaitDeepAnalysis(base, result, options);
74
+ return { result, verdict: streamed.verdict };
75
+ }
76
+ function streamUrl(base, target, options) {
77
+ const params = new URLSearchParams({ domain: target, format: "audit" });
78
+ if (options.force) params.set("force", "1");
79
+ if (options.ephemeral) params.set("ephemeral", "1");
80
+ if (options.maxAgeSeconds !== void 0)
81
+ params.set("maxAgeSeconds", String(options.maxAgeSeconds));
82
+ return `${base}/api/scan/stream?${params}`;
83
+ }
84
+ async function consumeScanStream(base, target, options) {
85
+ const idleMs = options.idleMs ?? STREAM_IDLE_MS;
86
+ const dog = watchdog(idleMs);
87
+ const timeoutError = () => new AuditApiError(`ora audit timed out \u2014 no progress for ${Math.round(idleMs / 1e3)}s`);
88
+ let res;
89
+ try {
90
+ res = await fetch(streamUrl(base, target, options), {
91
+ headers: { accept: "text/event-stream", ...authHeaders(options.apiKey) },
92
+ signal: dog.signal
93
+ });
94
+ } catch (cause) {
95
+ dog.disarm();
96
+ if (dog.tripped()) throw timeoutError();
97
+ const detail = cause instanceof Error ? cause.message : String(cause);
98
+ throw new AuditApiError(`ora audit request failed: ${detail}`);
99
+ }
100
+ if (res.status === 429) {
101
+ dog.disarm();
102
+ const wait = res.headers.get("retry-after");
103
+ throw new AuditApiError(
104
+ `ora rate limit exceeded${wait ? ` \u2014 retry after ${wait}s` : ""} (burst: 10 scans/min/IP; daily: 30 scans + 6 force per 24h). An ora-issued scan API key lifts these limits: set ORA_SCAN_API_KEY or pass --api-key.`
105
+ );
106
+ }
107
+ if (!res.ok || !res.body) {
108
+ dog.disarm();
109
+ throw new AuditApiError(`ora audit failed: ${await errorBodyText(res)}`);
110
+ }
111
+ const narrate = progressNarrator();
112
+ const utf8 = new TextDecoder();
113
+ let pending = "";
114
+ let result;
115
+ let verdict;
116
+ try {
117
+ streaming: for await (const chunk of res.body) {
118
+ dog.poke();
119
+ pending = `${pending}${utf8.decode(chunk, { stream: true })}`.replace(
120
+ /\r\n?/g,
121
+ "\n"
122
+ );
123
+ let cut = pending.indexOf("\n\n");
124
+ while (cut !== -1) {
125
+ const packet = joinDataLines(pending.slice(0, cut));
126
+ pending = pending.slice(cut + 2);
127
+ cut = pending.indexOf("\n\n");
128
+ if (!packet) continue;
129
+ let event;
130
+ try {
131
+ event = JSON.parse(packet);
132
+ } catch {
133
+ continue;
134
+ }
135
+ const line = narrate(event);
136
+ if (line) options.progress?.(line);
137
+ if (event.type === "error") {
138
+ throw new AuditApiError(
139
+ `ora audit failed: ${typeof event.message === "string" ? event.message : "scan error"}`
140
+ );
141
+ }
142
+ if (event.type === "scan_complete" && event.result) {
143
+ result = event.result;
144
+ } else if (event.type === "summary_ready" && typeof event.agenticSummary === "string") {
145
+ verdict = event.agenticSummary;
146
+ }
147
+ if (result && verdict) break streaming;
148
+ }
149
+ }
150
+ } catch (cause) {
151
+ if (dog.tripped()) throw timeoutError();
152
+ if (cause instanceof AuditApiError) throw cause;
153
+ const detail = cause instanceof Error ? cause.message : String(cause);
154
+ throw new AuditApiError(`ora audit stream error: ${detail}`);
155
+ } finally {
156
+ dog.disarm();
157
+ res.body.cancel().catch(() => {
158
+ });
159
+ }
160
+ if (!result) throw new AuditApiError("ora audit stream ended before completing");
161
+ return { result, verdict };
162
+ }
163
+ function joinDataLines(block) {
164
+ const collected = [];
165
+ for (const row of block.split("\n")) {
166
+ if (row.startsWith("data:")) collected.push(row.slice(5).replace(/^ /, ""));
167
+ }
168
+ return collected.join("\n");
169
+ }
170
+ function progressNarrator() {
171
+ let expected = 0;
172
+ let finished = 0;
173
+ let checkName = "";
174
+ return (event) => {
175
+ switch (event.type) {
176
+ case "kind_detecting":
177
+ return "Detecting URL kind\u2026";
178
+ case "kind_detected":
179
+ return typeof event.kind === "string" ? `Detected ${event.kind}, scanning\u2026` : void 0;
180
+ case "scan_init":
181
+ if (Array.isArray(event.checkRoster)) expected = event.checkRoster.length;
182
+ return void 0;
183
+ case "discovery_phase":
184
+ return typeof event.label === "string" ? event.label : void 0;
185
+ case "check_complete": {
186
+ finished += 1;
187
+ if (typeof event.checkName === "string") checkName = event.checkName;
188
+ if (expected <= 0) return `Running checks\u2026 (${finished})`;
189
+ const capped = Math.min(finished, expected);
190
+ const cells = Math.min(BAR_CELLS, Math.max(0, Math.round(capped / expected * BAR_CELLS)));
191
+ const bar = `${"\u2588".repeat(cells)}${"\u2591".repeat(BAR_CELLS - cells)}`;
192
+ return `${bar} ${capped}/${expected}${checkName ? ` \xB7 ${checkName}` : ""}`;
193
+ }
194
+ case "scan_complete":
195
+ return "Finishing up\u2026";
196
+ default:
197
+ return void 0;
198
+ }
199
+ };
200
+ }
201
+ function stillAnalyzing(result) {
202
+ if (result.analysisStatus === "complete" || result.analysisStatus === "stuck") return false;
203
+ if (result.analysisStatus === "partial") return true;
204
+ return (result.pendingChecks?.length ?? 0) > 0;
205
+ }
206
+ async function awaitDeepAnalysis(base, first, options) {
207
+ const scoreUrl = `${base}/api/score/${encodeURIComponent(first.domain)}?format=audit`;
208
+ const every = options.pollEveryMs ?? POLL_EVERY_MS;
209
+ const limit = options.pollLimit ?? POLL_LIMIT;
210
+ let latest = first;
211
+ for (let round = 0; round < limit && stillAnalyzing(latest); round++) {
212
+ const left = latest.pendingChecks?.length ?? 0;
213
+ options.progress?.(
214
+ left ? `Analyzing\u2026 ${left} check${left === 1 ? "" : "s"} pending` : "Analyzing\u2026"
215
+ );
216
+ await pause(every);
217
+ try {
218
+ const res = await fetch(scoreUrl, {
219
+ headers: { accept: "application/json", ...authHeaders(options.apiKey) },
220
+ signal: AbortSignal.timeout(15e3)
221
+ });
222
+ if (res.ok) latest = await res.json();
223
+ } catch {
224
+ }
225
+ }
226
+ return latest;
227
+ }
228
+
229
+ // src/api/platform.ts
230
+ function decodeEventBlock(block) {
231
+ let event = "message";
232
+ const payload = [];
233
+ for (const row of block.split("\n")) {
234
+ if (row.startsWith(":")) continue;
235
+ if (row.startsWith("event:")) event = row.slice(6).trim();
236
+ else if (row.startsWith("data:")) payload.push(row.slice(5).replace(/^ /, ""));
237
+ }
238
+ return payload.length ? { event, data: payload.join("\n") } : null;
239
+ }
240
+
241
+ // src/api/deep-journey.ts
242
+ var PUBLIC_BASE2 = "https://ora.ai";
243
+ var STREAM_IDLE_MS2 = 12e4;
244
+ var POLL_EVERY_MS2 = 5e3;
245
+ var POLL_LIMIT2 = 180;
246
+ var DeepJourneyApiError = class extends Error {
247
+ };
248
+ function apiBase(baseUrl) {
249
+ return (baseUrl ?? process.env.ORA_API_URL ?? PUBLIC_BASE2).replace(/\/+$/, "");
250
+ }
251
+ async function getJson(url) {
252
+ let res;
253
+ try {
254
+ res = await fetch(url, {
255
+ headers: { accept: "application/json" },
256
+ signal: AbortSignal.timeout(15e3)
257
+ });
258
+ } catch (cause) {
259
+ const detail = cause instanceof Error ? cause.message : String(cause);
260
+ throw new DeepJourneyApiError(`ora request failed: ${detail}`);
261
+ }
262
+ if (!res.ok) throw new DeepJourneyApiError(`ora request failed: ${await errorBodyText(res)}`);
263
+ return await res.json();
264
+ }
265
+ function fetchJourneyIntents(baseUrl) {
266
+ return getJson(`${apiBase(baseUrl)}/api/journey/intents`);
267
+ }
268
+ function fetchJourneyAgents(baseUrl) {
269
+ return getJson(`${apiBase(baseUrl)}/api/journey/agents`);
270
+ }
271
+ function allowanceFrom(res) {
272
+ const num = (name) => {
273
+ const raw = res.headers.get(name);
274
+ if (raw === null) return void 0;
275
+ const parsed = Number.parseInt(raw, 10);
276
+ return Number.isFinite(parsed) ? parsed : void 0;
277
+ };
278
+ const resetSeconds = num("x-ratelimit-reset");
279
+ return {
280
+ limit: num("x-ratelimit-limit"),
281
+ remaining: num("x-ratelimit-remaining"),
282
+ resetAtMs: resetSeconds !== void 0 ? resetSeconds * 1e3 : void 0
283
+ };
284
+ }
285
+ async function triggerRun(base, target, options) {
286
+ const body = {
287
+ intent: options.task ? { custom: options.task, domain: target } : {
288
+ ...options.intentId ? { intent_id: options.intentId } : {},
289
+ domain: target
290
+ },
291
+ harness: options.harness,
292
+ model: options.model
293
+ };
294
+ let res;
295
+ try {
296
+ res = await fetch(`${base}/api/journey/runs`, {
297
+ method: "POST",
298
+ headers: {
299
+ "content-type": "application/json",
300
+ accept: "application/json",
301
+ ...options.apiKey ? { authorization: `Bearer ${options.apiKey}` } : {}
302
+ },
303
+ body: JSON.stringify(body),
304
+ signal: AbortSignal.timeout(3e4)
305
+ });
306
+ } catch (cause) {
307
+ const detail = cause instanceof Error ? cause.message : String(cause);
308
+ throw new DeepJourneyApiError(`ora journey request failed: ${detail}`);
309
+ }
310
+ if (res.status === 401) {
311
+ throw new DeepJourneyApiError(
312
+ "free-text tasks need an ora partner API key \u2014 set ORA_PARTNER_API_KEY or pass --api-key (keys are issued by ora on request)"
313
+ );
314
+ }
315
+ if (res.status === 429) {
316
+ const wait = res.headers.get("retry-after");
317
+ const caps = options.apiKey ? "keyed allowance: 1000 runs per 24h per key" : "burst: 20/min/IP; daily: 200 runs per 24h per IP \u2014 an ora partner API key raises this to 1000/24h per key: set ORA_PARTNER_API_KEY or pass --api-key";
318
+ throw new DeepJourneyApiError(
319
+ `ora journey caller limit exceeded${wait ? ` \u2014 retry after ${formatWait(Number(wait) * 1e3)}` : ""} (${caps})`
320
+ );
321
+ }
322
+ if (res.status === 503) {
323
+ throw new DeepJourneyApiError("ora's run engine is unavailable right now \u2014 try again shortly");
324
+ }
325
+ if (!res.ok) {
326
+ throw new DeepJourneyApiError(`ora journey request failed: ${await errorBodyText(res)}`);
327
+ }
328
+ const record = await res.json();
329
+ warnOnNewerContract(record.contractVersion);
330
+ return { record, cached: record.rate_limited === true, allowance: allowanceFrom(res) };
331
+ }
332
+ function formatWait(ms) {
333
+ if (!Number.isFinite(ms) || ms <= 0) return "soon";
334
+ const hours = ms / 36e5;
335
+ if (hours >= 1) return `${Math.ceil(hours)}h`;
336
+ const minutes = ms / 6e4;
337
+ if (minutes >= 1) return `${Math.ceil(minutes)}m`;
338
+ return `${Math.ceil(ms / 1e3)}s`;
339
+ }
340
+ function activityLabel(step) {
341
+ if (!step) return "starting\u2026";
342
+ if (step.type === "text") return "thinking\u2026";
343
+ if (step.action === "search") {
344
+ return step.search_query ? `searching \u201C${clip(step.search_query, 40)}\u201D` : "searching\u2026";
345
+ }
346
+ const where = step.label ?? `${step.url_host ?? ""}${step.url_path ?? ""}`;
347
+ const doing = step.completed === false ? "fetching" : "fetched";
348
+ return where ? `${doing} ${clip(where, 48)}` : `${doing}\u2026`;
349
+ }
350
+ function clip(text, max) {
351
+ return text.length > max ? `${text.slice(0, max - 1)}\u2026` : text;
352
+ }
353
+ async function followJourneyStream(base, streamPath, options) {
354
+ const target = streamPath.startsWith("http") ? streamPath : `${base}${streamPath}`;
355
+ const idleMs = options.idleMs ?? STREAM_IDLE_MS2;
356
+ const dog = watchdog(idleMs);
357
+ const timeoutError = () => new DeepJourneyApiError(
358
+ `ora journey stream timed out \u2014 no frames for ${Math.round(idleMs / 1e3)}s`
359
+ );
360
+ let res;
361
+ try {
362
+ res = await fetch(target, {
363
+ headers: { accept: "text/event-stream" },
364
+ signal: dog.signal
365
+ });
366
+ } catch (cause) {
367
+ dog.disarm();
368
+ if (dog.tripped()) throw timeoutError();
369
+ const detail = cause instanceof Error ? cause.message : String(cause);
370
+ throw new DeepJourneyApiError(`ora journey stream failed: ${detail}`);
371
+ }
372
+ if (!res.ok || !res.body) {
373
+ dog.disarm();
374
+ throw new DeepJourneyApiError(`ora journey stream failed: ${await errorBodyText(res)}`);
375
+ }
376
+ const utf8 = new TextDecoder();
377
+ const collected = {};
378
+ let pending = "";
379
+ try {
380
+ streaming: for await (const chunk of res.body) {
381
+ dog.poke();
382
+ pending = `${pending}${utf8.decode(chunk, { stream: true })}`.replace(
383
+ /\r\n?/g,
384
+ "\n"
385
+ );
386
+ let cut = pending.indexOf("\n\n");
387
+ while (cut !== -1) {
388
+ const decoded = decodeEventBlock(pending.slice(0, cut));
389
+ pending = pending.slice(cut + 2);
390
+ cut = pending.indexOf("\n\n");
391
+ if (!decoded) continue;
392
+ let payload;
393
+ try {
394
+ payload = JSON.parse(decoded.data);
395
+ } catch {
396
+ continue;
397
+ }
398
+ if (decoded.event === "trajectory") {
399
+ const steps = payload.steps ?? [];
400
+ const active = steps.filter((s) => s.type === "tool_call").at(-1);
401
+ options.progress?.(`step ${steps.length} \xB7 ${activityLabel(active ?? steps.at(-1))}`);
402
+ } else if (decoded.event === "processing") {
403
+ options.progress?.(
404
+ typeof payload.message === "string" ? payload.message : "generating insights\u2026"
405
+ );
406
+ } else if (decoded.event === "result") {
407
+ collected.result = payload;
408
+ break streaming;
409
+ } else if (decoded.event === "error") {
410
+ collected.errorMessage = typeof payload.message === "string" ? payload.message : "unknown engine error";
411
+ break streaming;
412
+ }
413
+ }
414
+ }
415
+ } catch (cause) {
416
+ if (dog.tripped()) throw timeoutError();
417
+ if (cause instanceof DeepJourneyApiError) throw cause;
418
+ const detail = cause instanceof Error ? cause.message : String(cause);
419
+ throw new DeepJourneyApiError(`ora journey stream error: ${detail}`);
420
+ } finally {
421
+ dog.disarm();
422
+ res.body.cancel().catch(() => {
423
+ });
424
+ }
425
+ return collected;
426
+ }
427
+ function fetchRunDetail(base, runId) {
428
+ return getJson(`${base}/api/journey/runs/${encodeURIComponent(runId)}`);
429
+ }
430
+ async function awaitByPolling(base, runId, options) {
431
+ const every = options.pollEveryMs ?? POLL_EVERY_MS2;
432
+ const limit = options.pollLimit ?? POLL_LIMIT2;
433
+ let latest = await fetchRunDetail(base, runId);
434
+ for (let round = 0; round < limit && latest.status === "running"; round++) {
435
+ options.progress?.("agent working\u2026 (polling)");
436
+ await pause(every);
437
+ try {
438
+ latest = await fetchRunDetail(base, runId);
439
+ } catch {
440
+ }
441
+ }
442
+ return latest;
443
+ }
444
+ async function performDeepJourney(target, options) {
445
+ const base = apiBase(options.baseUrl);
446
+ options = {
447
+ ...options,
448
+ apiKey: options.apiKey || process.env.ORA_PARTNER_API_KEY || process.env.ORA_SCAN_API_KEY || void 0
449
+ };
450
+ const triggered = await triggerRun(base, target, options);
451
+ const { record } = triggered;
452
+ if (triggered.cached) {
453
+ options.progress?.("target at its 24h cap \u2014 fetching the most recent stored run");
454
+ }
455
+ let engineError;
456
+ if (!options.noStream && record.status === "running") {
457
+ try {
458
+ const streamed = await followJourneyStream(base, record.stream_url, options);
459
+ engineError = streamed.errorMessage;
460
+ } catch {
461
+ options.progress?.("stream went quiet \u2014 switching to polling");
462
+ await awaitByPolling(base, record.id, options);
463
+ }
464
+ } else if (options.noStream && record.status === "running") {
465
+ await awaitByPolling(base, record.id, options);
466
+ }
467
+ const detail = await awaitDetailSettled(base, record.id, options);
468
+ if (detail.status === "running") {
469
+ if (engineError) {
470
+ throw new DeepJourneyApiError(`ora journey run failed: ${engineError}`);
471
+ }
472
+ throw new DeepJourneyApiError(
473
+ `run ${record.id} is still executing \u2014 the ${options.noStream ? "poll budget ran out" : "stream ended"} before a terminal result. Check ${base}/api/journey/runs/${record.id} shortly`
474
+ );
475
+ }
476
+ warnOnNewerContract(detail.contractVersion);
477
+ return {
478
+ record,
479
+ cached: triggered.cached,
480
+ retryAfterMs: triggered.record.retry_after_ms,
481
+ allowance: triggered.allowance,
482
+ detail,
483
+ engineError
484
+ };
485
+ }
486
+ async function awaitDetailSettled(base, runId, options) {
487
+ let detail = await fetchRunDetail(base, runId);
488
+ for (let round = 0; round < 3 && detail.status === "running"; round++) {
489
+ options.progress?.("finalizing\u2026");
490
+ await pause(1500);
491
+ detail = await fetchRunDetail(base, runId);
492
+ }
493
+ return detail;
494
+ }
495
+
496
+ // src/api/skills.ts
497
+ import { createHash } from "crypto";
498
+ var PUBLIC_BASE3 = "https://ora.ai";
499
+ var SkillApiError = class extends Error {
500
+ };
501
+ function resolveBase(baseUrl) {
502
+ return (baseUrl ?? process.env.ORA_API_URL ?? PUBLIC_BASE3).replace(/\/+$/, "");
503
+ }
504
+ async function fetchSkillIndex(baseUrl) {
505
+ const base = resolveBase(baseUrl);
506
+ let res;
507
+ try {
508
+ res = await fetch(`${base}/.well-known/agent-skills/index.json`, {
509
+ headers: { accept: "application/json" },
510
+ signal: AbortSignal.timeout(15e3)
511
+ });
512
+ } catch (cause) {
513
+ throw new SkillApiError(
514
+ `could not reach the skill registry at ${base}: ${cause instanceof Error ? cause.message : String(cause)}`
515
+ );
516
+ }
517
+ if (!res.ok) throw new SkillApiError(`skill registry answered HTTP ${res.status}`);
518
+ const body = await res.json();
519
+ if (!Array.isArray(body.skills)) throw new SkillApiError("skill registry index has no skills[]");
520
+ return body.skills;
521
+ }
522
+ function digestOf(bytes) {
523
+ return `sha256:${createHash("sha256").update(bytes).digest("hex")}`;
524
+ }
525
+ async function fetchSkill(name, baseUrl) {
526
+ const base = resolveBase(baseUrl);
527
+ const index = await fetchSkillIndex(base);
528
+ const entry = index.find((s) => s.name === name);
529
+ if (!entry) {
530
+ const known = index.map((s) => s.name).join(", ");
531
+ throw new SkillApiError(`unknown skill ${JSON.stringify(name)} - the registry has: ${known}`);
532
+ }
533
+ const url = entry.url.startsWith("http") ? entry.url : `${base}${entry.url}`;
534
+ let res;
535
+ try {
536
+ res = await fetch(url, { signal: AbortSignal.timeout(15e3) });
537
+ } catch (cause) {
538
+ throw new SkillApiError(
539
+ `could not fetch ${url}: ${cause instanceof Error ? cause.message : String(cause)}`
540
+ );
541
+ }
542
+ if (!res.ok) throw new SkillApiError(`skill fetch answered HTTP ${res.status} for ${url}`);
543
+ const bytes = new Uint8Array(await res.arrayBuffer());
544
+ if (entry.digest && digestOf(bytes) !== entry.digest) {
545
+ throw new SkillApiError(
546
+ `digest mismatch for ${name}: index says ${entry.digest}, served bytes hash to ${digestOf(bytes)} - refusing to use them`
547
+ );
548
+ }
549
+ return { entry, bytes };
550
+ }
551
+ export {
552
+ AuditApiError,
553
+ BUILT_AGAINST,
554
+ DeepJourneyApiError,
555
+ SkillApiError,
556
+ performAudit as audit,
557
+ performDeepJourney as deepJourney,
558
+ fetchJourneyAgents,
559
+ fetchJourneyIntents,
560
+ fetchSkill,
561
+ fetchSkillIndex,
562
+ isNewerContract
563
+ };