@hydracept/sdk 0.3.0 → 0.3.1

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/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.3.1 — 2026-08-26
4
+
5
+ - Job downloads compare receipt SHA-256 as hex (`sha256:<hex>` prefix is stripped)
6
+ - High-level submit omits stale `execution.quoteId` / `estimateId`
7
+ - Audio downloads add `.ogg` when the receipt has no filename
8
+
3
9
  ## 0.2.3 — 2026-08-13
4
10
 
5
11
  - Pinned Execution: `createPinnedInference`, `getPinnedReceipt`, `listPinnedReceipts`
package/dist/jobs.d.ts CHANGED
@@ -17,5 +17,6 @@ export type HydraceptJobRunner = {
17
17
  pollMs?: number;
18
18
  }): Promise<HydraceptJobRunResult>;
19
19
  };
20
+ export declare function normalizeSha256Digest(value: string | undefined | null): string;
20
21
  export declare function createHydraceptJobRunner(client: HydraceptClient, binding: HydraceptJobBinding): HydraceptJobRunner;
21
22
  //# sourceMappingURL=jobs.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"jobs.d.ts","sourceRoot":"","sources":["../src/jobs.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAElD,MAAM,MAAM,mBAAmB,GAAG;IAChC,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF,MAAM,MAAM,qBAAqB,GAAG;IAClC,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC7B,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;IACxC,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AA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AM,GAAG,SAAS,GAAG,IAAI,GAAG,MAAM,CAI9E;AAyBD,wBAAgB,wBAAwB,CACtC,MAAM,EAAE,eAAe,EACvB,OAAO,EAAE,mBAAmB,GAC3B,kBAAkB,CA+DpB"}
package/dist/jobs.js CHANGED
@@ -14,10 +14,51 @@ function nextActionForJob(job) {
14
14
  function sleep(ms) {
15
15
  return new Promise((resolve) => setTimeout(resolve, ms));
16
16
  }
17
+ const MEDIA_EXTENSIONS = {
18
+ 'audio/ogg': '.ogg',
19
+ 'application/ogg': '.ogg',
20
+ 'audio/wav': '.wav',
21
+ 'audio/mpeg': '.mp3',
22
+ 'image/png': '.png',
23
+ 'image/jpeg': '.jpg',
24
+ 'image/webp': '.webp',
25
+ 'model/gltf-binary': '.glb',
26
+ 'video/mp4': '.mp4',
27
+ 'application/json': '.json',
28
+ };
29
+ export function normalizeSha256Digest(value) {
30
+ let raw = String(value || '').trim().toLowerCase();
31
+ if (raw.startsWith('sha256:'))
32
+ raw = raw.slice(7);
33
+ return raw;
34
+ }
35
+ function filenameForDownload(item, artifactId) {
36
+ const media = String(item.mediaType || item.mimeType || '')
37
+ .split(';')[0]
38
+ .trim()
39
+ .toLowerCase();
40
+ let name = String(item.filename || item.label || artifactId || 'artifact')
41
+ .replace(/\\/g, '/')
42
+ .split('/')
43
+ .pop() || 'artifact';
44
+ const ext = MEDIA_EXTENSIONS[media];
45
+ if (ext && !name.toLowerCase().endsWith(ext))
46
+ name = `${name}${ext}`;
47
+ return name;
48
+ }
49
+ function omitStaleQuoteIds(body) {
50
+ const execution = body.execution;
51
+ if (!execution || typeof execution !== 'object')
52
+ return body;
53
+ const cleaned = { ...execution };
54
+ delete cleaned.quoteId;
55
+ delete cleaned.estimateId;
56
+ return { ...body, execution: cleaned };
57
+ }
17
58
  export function createHydraceptJobRunner(client, binding) {
18
59
  return {
19
60
  async run(capabilityKey, body, options = {}) {
20
- const payload = {
61
+ const payload = omitStaleQuoteIds({
21
62
  ...body,
22
63
  context: {
23
64
  productId: binding.projectId,
@@ -25,7 +66,7 @@ export function createHydraceptJobRunner(client, binding) {
25
66
  environment: binding.environment || 'development',
26
67
  ...(body.context ?? {}),
27
68
  },
28
- };
69
+ });
29
70
  const submitted = (await client.runtime.submitCapabilityJob(capabilityKey, payload));
30
71
  const jobId = String(submitted.jobId || submitted.id || '');
31
72
  if (!jobId)
@@ -53,12 +94,15 @@ export function createHydraceptJobRunner(client, binding) {
53
94
  continue;
54
95
  const buffer = await client.http.fetchBytes(`/jobs/${encodeURIComponent(jobId)}/artifacts/${encodeURIComponent(artifactId)}`);
55
96
  const bytes = new Uint8Array(buffer);
56
- const expected = String(item.sha256 || '').toLowerCase();
97
+ const nested = item.digest && typeof item.digest === 'object'
98
+ ? item.digest
99
+ : {};
100
+ const expected = normalizeSha256Digest(String(item.sha256 || nested.sha256 || ''));
57
101
  const actual = createHash('sha256').update(bytes).digest('hex');
58
102
  if (expected && expected !== actual) {
59
103
  throw new Error(`SHA-256 mismatch for ${artifactId}`);
60
104
  }
61
- const filename = String(item.filename || item.label || artifactId);
105
+ const filename = filenameForDownload(item, artifactId);
62
106
  const target = join(options.downloadDir, filename);
63
107
  mkdirSync(dirname(target), { recursive: true });
64
108
  writeFileSync(target, bytes);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hydracept/sdk",
3
- "version": "0.3.0",
3
+ "version": "0.3.1",
4
4
  "description": "TypeScript client for Hydracept — production-ready game assets, with a receipt for every run.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",