@inferencesh/app 0.1.9 → 0.1.11

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/README.md CHANGED
@@ -229,7 +229,7 @@ export class App {
229
229
  - [documentation](https://inference.sh/docs) — getting started guides
230
230
  - [app development guide](https://inference.sh/docs/extend/app-code) — writing app logic
231
231
  - [client sdk](https://www.npmjs.com/package/@inferencesh/sdk) — calling apps from your code
232
- - [discord](https://discord.gg/RM77SWSbyT) — community support
232
+ - [discord](https://discord.gg/inference) — community support
233
233
 
234
234
  ## license
235
235
 
package/dist/file.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { createHash } from "node:crypto";
2
- import { createWriteStream, existsSync, mkdirSync, statSync, renameSync, unlinkSync, writeFileSync } from "node:fs";
2
+ import { createWriteStream, existsSync, mkdirSync, readdirSync, statSync, renameSync, unlinkSync, writeFileSync } from "node:fs";
3
3
  import { basename, resolve, join } from "node:path";
4
4
  import { homedir } from "node:os";
5
5
  import { get as httpsGet } from "node:https";
@@ -243,7 +243,7 @@ export class File {
243
243
  const cacheDir = join(File.getCacheDir(), "data_uri", hash);
244
244
  // Check for existing cached file
245
245
  if (existsSync(cacheDir)) {
246
- const files = require("node:fs").readdirSync(cacheDir);
246
+ const files = readdirSync(cacheDir);
247
247
  if (files.length > 0) {
248
248
  this._path = join(cacheDir, files[0]);
249
249
  this._populateMetadata();
@@ -362,14 +362,17 @@ const EXTENSION_MAP = {
362
362
  function getExtensionForMimeType(mimeType) {
363
363
  return EXTENSION_MAP[mimeType] || "";
364
364
  }
365
- function downloadToFile(url, destPath) {
365
+ function downloadToFile(url, destPath, maxRedirects = 10) {
366
+ if (maxRedirects < 0) {
367
+ return Promise.reject(new Error(`Too many redirects downloading ${url}`));
368
+ }
366
369
  return new Promise((resolve, reject) => {
367
370
  const parsed = new URL(url);
368
371
  const getter = parsed.protocol === "https:" ? httpsGet : httpGet;
369
372
  const request = getter(url, (response) => {
370
373
  // Follow redirects
371
374
  if (response.statusCode && response.statusCode >= 300 && response.statusCode < 400 && response.headers.location) {
372
- downloadToFile(response.headers.location, destPath).then(resolve, reject);
375
+ downloadToFile(response.headers.location, destPath, maxRedirects - 1).then(resolve, reject);
373
376
  return;
374
377
  }
375
378
  if (response.statusCode && response.statusCode >= 400) {
package/dist/index.d.ts CHANGED
@@ -4,4 +4,5 @@ export { createFileSchema, isFileSchema, FILE_SCHEMA_MARKER } from "./schema.js"
4
4
  export { StorageDir, ensureDir } from "./storage.js";
5
5
  export type { StorageDirValue } from "./storage.js";
6
6
  export { download } from "./download.js";
7
+ export type { RequestMetadata, RequestMetadata as Metadata } from "./types.js";
7
8
  export * from "./output-meta.js";
package/dist/types.d.ts CHANGED
@@ -1,60 +1,35 @@
1
- export interface AppSDKTypes {
2
- }
3
- /**
4
- * MetaItemType is the type discriminator for MetaItem
5
- */
6
- export type MetaItemType = string;
7
- export declare const MetaItemTypeText: MetaItemType;
8
- export declare const MetaItemTypeImage: MetaItemType;
9
- export declare const MetaItemTypeVideo: MetaItemType;
10
- export declare const MetaItemTypeAudio: MetaItemType;
11
- export declare const MetaItemTypeRaw: MetaItemType;
12
1
  /**
13
- * VideoResolution represents standard video resolution presets
2
+ * RequestMetadata is the metadata envelope carried in both directions:
3
+ * engine -> worker on /setup and /run, and worker -> engine API on callbacks.
14
4
  */
15
- export type VideoResolution = string;
16
- export declare const VideoRes480P: VideoResolution;
17
- export declare const VideoRes720P: VideoResolution;
18
- export declare const VideoRes1080P: VideoResolution;
19
- export declare const VideoRes1440P: VideoResolution;
20
- export declare const VideoRes4K: VideoResolution;
5
+ export interface RequestMetadata {
6
+ worker_id: string;
7
+ app_id: string;
8
+ app_version_id: string;
9
+ app_variant: string;
10
+ gpu_ids: string[];
11
+ task_id: string;
12
+ team_id: string;
13
+ user_id: string;
14
+ }
15
+ export interface AppSDKTypes {
16
+ }
21
17
  /**
22
18
  * MetaItem represents metadata about an input or output item
23
19
  */
24
20
  export interface MetaItem {
25
21
  type: MetaItemType;
26
- /**
27
- * Text fields
28
- */
29
22
  tokens?: number;
30
- /**
31
- * Image/Video shared fields
32
- */
33
23
  width?: number;
34
24
  height?: number;
35
25
  resolution_mp?: number;
36
- /**
37
- * Image specific fields
38
- */
39
26
  steps?: number;
40
27
  count?: number;
41
- /**
42
- * Video specific fields
43
- */
44
28
  resolution?: VideoResolution;
45
29
  seconds?: number;
46
30
  fps?: number;
47
- /**
48
- * Audio specific fields
49
- */
50
31
  sample_rate?: number;
51
- /**
52
- * Raw specific fields
53
- */
54
32
  cost?: number;
55
- /**
56
- * App-specific key-value pairs for custom pricing factors
57
- */
58
33
  extra?: {
59
34
  [key: string]: any;
60
35
  };
@@ -66,3 +41,21 @@ export interface OutputMeta {
66
41
  inputs: MetaItem[];
67
42
  outputs: MetaItem[];
68
43
  }
44
+ /**
45
+ * MetaItemType is the type discriminator for MetaItem
46
+ */
47
+ export type MetaItemType = string;
48
+ export declare const MetaItemTypeText: MetaItemType;
49
+ export declare const MetaItemTypeImage: MetaItemType;
50
+ export declare const MetaItemTypeVideo: MetaItemType;
51
+ export declare const MetaItemTypeAudio: MetaItemType;
52
+ export declare const MetaItemTypeRaw: MetaItemType;
53
+ /**
54
+ * VideoResolution represents standard video resolution presets
55
+ */
56
+ export type VideoResolution = string;
57
+ export declare const VideoRes480P: VideoResolution;
58
+ export declare const VideoRes720P: VideoResolution;
59
+ export declare const VideoRes1080P: VideoResolution;
60
+ export declare const VideoRes1440P: VideoResolution;
61
+ export declare const VideoRes4K: VideoResolution;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inferencesh/app",
3
- "version": "0.1.9",
3
+ "version": "0.1.11",
4
4
  "description": "App framework for building inference.sh apps — File handling, output metadata, storage utilities",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -42,7 +42,7 @@
42
42
  "devDependencies": {
43
43
  "@types/node": "^22.0.0",
44
44
  "rimraf": "^6.0.1",
45
- "typescript": "^5.8.3",
45
+ "typescript": "~6.0.3",
46
46
  "zod": "^4.3.6"
47
47
  },
48
48
  "files": [