@nodetool-ai/node-sdk 0.7.0-rc.23 → 0.8.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.
- package/README.md +34 -0
- package/dist/.nodetool-build-stamp +1 -0
- package/dist/base-node.d.ts +285 -14
- package/dist/base-node.d.ts.map +1 -1
- package/dist/base-node.js +359 -49
- package/dist/base-node.js.map +1 -1
- package/dist/class-name-to-title.d.ts +26 -0
- package/dist/class-name-to-title.d.ts.map +1 -0
- package/dist/class-name-to-title.js +59 -0
- package/dist/class-name-to-title.js.map +1 -0
- package/dist/code-analysis.d.ts +234 -0
- package/dist/code-analysis.d.ts.map +1 -0
- package/dist/code-analysis.js +919 -0
- package/dist/code-analysis.js.map +1 -0
- package/dist/code-body.d.ts +61 -0
- package/dist/code-body.d.ts.map +1 -0
- package/dist/code-body.js +288 -0
- package/dist/code-body.js.map +1 -0
- package/dist/code-node-validation.d.ts +67 -0
- package/dist/code-node-validation.d.ts.map +1 -0
- package/dist/code-node-validation.js +540 -0
- package/dist/code-node-validation.js.map +1 -0
- package/dist/content-card.d.ts +30 -0
- package/dist/content-card.d.ts.map +1 -0
- package/dist/content-card.js +68 -0
- package/dist/content-card.js.map +1 -0
- package/dist/correlation-validation.d.ts +19 -0
- package/dist/correlation-validation.d.ts.map +1 -0
- package/dist/correlation-validation.js +101 -0
- package/dist/correlation-validation.js.map +1 -0
- package/dist/cost-estimate.d.ts +244 -0
- package/dist/cost-estimate.d.ts.map +1 -0
- package/dist/cost-estimate.js +637 -0
- package/dist/cost-estimate.js.map +1 -0
- package/dist/decorators.d.ts.map +1 -1
- package/dist/decorators.js +4 -1
- package/dist/decorators.js.map +1 -1
- package/dist/docs/nodes.d.ts.map +1 -1
- package/dist/docs/nodes.js +3 -2
- package/dist/docs/nodes.js.map +1 -1
- package/dist/docs/overview.d.ts.map +1 -1
- package/dist/docs/overview.js +4 -3
- package/dist/docs/overview.js.map +1 -1
- package/dist/docs/workflows.d.ts.map +1 -1
- package/dist/docs/workflows.js +10 -9
- package/dist/docs/workflows.js.map +1 -1
- package/dist/field-classification.d.ts +31 -0
- package/dist/field-classification.d.ts.map +1 -0
- package/dist/field-classification.js +58 -0
- package/dist/field-classification.js.map +1 -0
- package/dist/graph-validation.d.ts +239 -0
- package/dist/graph-validation.d.ts.map +1 -0
- package/dist/graph-validation.js +1174 -0
- package/dist/graph-validation.js.map +1 -0
- package/dist/index.d.ts +27 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +29 -1
- package/dist/index.js.map +1 -1
- package/dist/js-script-link.d.ts +53 -0
- package/dist/js-script-link.d.ts.map +1 -0
- package/dist/js-script-link.js +58 -0
- package/dist/js-script-link.js.map +1 -0
- package/dist/js-script-materialize.d.ts +52 -0
- package/dist/js-script-materialize.d.ts.map +1 -0
- package/dist/js-script-materialize.js +24 -0
- package/dist/js-script-materialize.js.map +1 -0
- package/dist/manifest-node-values.d.ts +106 -0
- package/dist/manifest-node-values.d.ts.map +1 -0
- package/dist/manifest-node-values.js +195 -0
- package/dist/manifest-node-values.js.map +1 -0
- package/dist/metadata.d.ts +75 -3
- package/dist/metadata.d.ts.map +1 -1
- package/dist/metadata.js +132 -49
- package/dist/metadata.js.map +1 -1
- package/dist/node-metadata.d.ts.map +1 -1
- package/dist/node-metadata.js +61 -56
- package/dist/node-metadata.js.map +1 -1
- package/dist/node-type-inventory.d.ts +51 -0
- package/dist/node-type-inventory.d.ts.map +1 -0
- package/dist/node-type-inventory.js +121 -0
- package/dist/node-type-inventory.js.map +1 -0
- package/dist/nodes/test-nodes.d.ts +77 -30
- package/dist/nodes/test-nodes.d.ts.map +1 -1
- package/dist/nodes/test-nodes.js +2 -34
- package/dist/nodes/test-nodes.js.map +1 -1
- package/dist/pack-loader.d.ts +202 -0
- package/dist/pack-loader.d.ts.map +1 -0
- package/dist/pack-loader.js +529 -0
- package/dist/pack-loader.js.map +1 -0
- package/dist/port-types.d.ts +15 -0
- package/dist/port-types.d.ts.map +1 -0
- package/dist/port-types.js +72 -0
- package/dist/port-types.js.map +1 -0
- package/dist/pricing-bundle.d.ts +83 -0
- package/dist/pricing-bundle.d.ts.map +1 -0
- package/dist/pricing-bundle.js +82 -0
- package/dist/pricing-bundle.js.map +1 -0
- package/dist/pricing-params.d.ts +59 -0
- package/dist/pricing-params.d.ts.map +1 -0
- package/dist/pricing-params.js +282 -0
- package/dist/pricing-params.js.map +1 -0
- package/dist/python-package-scan.d.ts +8 -0
- package/dist/python-package-scan.d.ts.map +1 -1
- package/dist/python-package-scan.js +21 -8
- package/dist/python-package-scan.js.map +1 -1
- package/dist/registry.d.ts +105 -2
- package/dist/registry.d.ts.map +1 -1
- package/dist/registry.js +403 -30
- package/dist/registry.js.map +1 -1
- package/dist/sandbox-bridge-packs.d.ts +39 -0
- package/dist/sandbox-bridge-packs.d.ts.map +1 -0
- package/dist/sandbox-bridge-packs.js +249 -0
- package/dist/sandbox-bridge-packs.js.map +1 -0
- package/dist/sandbox-catalog-host.d.ts +31 -0
- package/dist/sandbox-catalog-host.d.ts.map +1 -0
- package/dist/sandbox-catalog-host.js +78 -0
- package/dist/sandbox-catalog-host.js.map +1 -0
- package/dist/sandbox-module-catalog.d.ts +14 -0
- package/dist/sandbox-module-catalog.d.ts.map +1 -0
- package/dist/sandbox-module-catalog.js +402 -0
- package/dist/sandbox-module-catalog.js.map +1 -0
- package/dist/sandbox-npm-artifacts.d.ts +56 -0
- package/dist/sandbox-npm-artifacts.d.ts.map +1 -0
- package/dist/sandbox-npm-artifacts.js +17 -0
- package/dist/sandbox-npm-artifacts.js.map +1 -0
- package/dist/sandbox-pack-discovery.d.ts +93 -0
- package/dist/sandbox-pack-discovery.d.ts.map +1 -0
- package/dist/sandbox-pack-discovery.js +807 -0
- package/dist/sandbox-pack-discovery.js.map +1 -0
- package/dist/search.d.ts +29 -1
- package/dist/search.d.ts.map +1 -1
- package/dist/search.js +136 -9
- package/dist/search.js.map +1 -1
- package/dist/type-compat.d.ts +36 -0
- package/dist/type-compat.d.ts.map +1 -0
- package/dist/type-compat.js +98 -0
- package/dist/type-compat.js.map +1 -0
- package/dist/type-predicates.d.ts +25 -0
- package/dist/type-predicates.d.ts.map +1 -0
- package/dist/type-predicates.js +31 -0
- package/dist/type-predicates.js.map +1 -0
- package/dist/validation.d.ts +18 -0
- package/dist/validation.d.ts.map +1 -1
- package/dist/validation.js +70 -11
- package/dist/validation.js.map +1 -1
- package/dist/workflow-document-tools.d.ts +35 -0
- package/dist/workflow-document-tools.d.ts.map +1 -0
- package/dist/workflow-document-tools.js +402 -0
- package/dist/workflow-document-tools.js.map +1 -0
- package/dist/workflow-interface.d.ts +62 -0
- package/dist/workflow-interface.d.ts.map +1 -0
- package/dist/workflow-interface.js +351 -0
- package/dist/workflow-interface.js.map +1 -0
- package/package.json +67 -10
- package/dist/package-registry-client.d.ts +0 -12
- package/dist/package-registry-client.d.ts.map +0 -1
- package/dist/package-registry-client.js +0 -40
- package/dist/package-registry-client.js.map +0 -1
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared types and helpers for writing per-provider pricing bundles during
|
|
3
|
+
* codegen.
|
|
4
|
+
*
|
|
5
|
+
* Each provider (FAL, Replicate, Kie, …) builds the same two JSON files
|
|
6
|
+
* alongside its node manifest:
|
|
7
|
+
*
|
|
8
|
+
* 1. `<provider>-node-type-pricing.json` — `byNodeType` map keyed by the
|
|
9
|
+
* runtime NodeTool `node_type`, used by the frontend to attach a
|
|
10
|
+
* `<provider>_unit_pricing` field onto each `NodeMetadata`.
|
|
11
|
+
* 2. `<provider>-unit-pricing.json` — raw price catalog keyed by the
|
|
12
|
+
* provider's own endpoint/model identifier. Mostly useful for diffing
|
|
13
|
+
* and showing "snapshot recorded at" in the UI.
|
|
14
|
+
*
|
|
15
|
+
* Per-provider codegen packages are expected to:
|
|
16
|
+
* - implement a small `<provider>-pricing-fetch.ts` that turns a list of
|
|
17
|
+
* endpoint IDs into `Record<endpointId, UnitPricing>` (provider APIs
|
|
18
|
+
* differ too much to share).
|
|
19
|
+
* - map their `NodeSpec` array to `PricingBundleSpec[]` (just `endpointId`
|
|
20
|
+
* + `nodeType`) and hand it to {@link buildPricingBundles}.
|
|
21
|
+
* - call {@link writePricingBundles} / {@link writeEmptyPricingBundles}
|
|
22
|
+
* with the two output paths.
|
|
23
|
+
*
|
|
24
|
+
* The `endpoint_id` field name is kept across providers even though it is
|
|
25
|
+
* FAL-flavored — the frontend already treats it as the canonical
|
|
26
|
+
* "provider-identifier" key, and renaming would ripple through every
|
|
27
|
+
* `attach*UnitPricing.ts` and `format*UnitPricing.ts` util.
|
|
28
|
+
*/
|
|
29
|
+
/** Stable on-disk schema version; bump when the JSON shape changes. */
|
|
30
|
+
export declare const NODE_TYPE_PRICING_SCHEMA_VERSION = 1;
|
|
31
|
+
/** Per-call price — provider-agnostic. */
|
|
32
|
+
export interface UnitPricing {
|
|
33
|
+
unit_price: number;
|
|
34
|
+
billing_unit: string;
|
|
35
|
+
currency: string;
|
|
36
|
+
}
|
|
37
|
+
/** A price entry tagged with its provider identifier. */
|
|
38
|
+
export interface UnitPricingEntry extends UnitPricing {
|
|
39
|
+
endpoint_id: string;
|
|
40
|
+
}
|
|
41
|
+
export interface NodeTypePricingBundle {
|
|
42
|
+
schemaVersion: number;
|
|
43
|
+
writtenAt: string;
|
|
44
|
+
byNodeType: Record<string, UnitPricingEntry>;
|
|
45
|
+
}
|
|
46
|
+
export interface UnitPricingCatalog {
|
|
47
|
+
schemaVersion: number;
|
|
48
|
+
writtenAt: string;
|
|
49
|
+
prices: Record<string, UnitPricing>;
|
|
50
|
+
}
|
|
51
|
+
/** Minimal info each provider supplies per node when building bundles. */
|
|
52
|
+
export interface PricingBundleSpec {
|
|
53
|
+
/** Provider identifier — `endpoint_id` for FAL, `owner/name:version` for Replicate, etc. */
|
|
54
|
+
endpointId: string;
|
|
55
|
+
/** Runtime NodeTool node type, e.g. `fal.image_to_image.FluxKontextPro`. */
|
|
56
|
+
nodeType: string;
|
|
57
|
+
}
|
|
58
|
+
export interface PricingOutputPaths {
|
|
59
|
+
byNodeTypePath: string;
|
|
60
|
+
catalogPath: string;
|
|
61
|
+
}
|
|
62
|
+
export declare function buildPricingBundles(specs: readonly PricingBundleSpec[], prices: Record<string, UnitPricing>, writtenAt: string): {
|
|
63
|
+
byNodeType: {
|
|
64
|
+
schemaVersion: number;
|
|
65
|
+
writtenAt: string;
|
|
66
|
+
byNodeType: Record<string, UnitPricingEntry>;
|
|
67
|
+
};
|
|
68
|
+
catalog: {
|
|
69
|
+
schemaVersion: number;
|
|
70
|
+
writtenAt: string;
|
|
71
|
+
prices: Record<string, UnitPricing>;
|
|
72
|
+
};
|
|
73
|
+
};
|
|
74
|
+
export declare function writePricingBundles(bundles: {
|
|
75
|
+
byNodeType: NodeTypePricingBundle;
|
|
76
|
+
catalog: UnitPricingCatalog;
|
|
77
|
+
}, paths: PricingOutputPaths): Promise<void>;
|
|
78
|
+
/**
|
|
79
|
+
* Write empty (stub) bundles for fresh checkouts that have no pricing files yet.
|
|
80
|
+
* Codegen must not call this when committed bundles already exist on disk.
|
|
81
|
+
*/
|
|
82
|
+
export declare function writeEmptyPricingBundles(paths: PricingOutputPaths): Promise<void>;
|
|
83
|
+
//# sourceMappingURL=pricing-bundle.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pricing-bundle.d.ts","sourceRoot":"","sources":["../src/pricing-bundle.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAKH,uEAAuE;AACvE,eAAO,MAAM,gCAAgC,IAAI,CAAC;AAElD,0CAA0C;AAC1C,MAAM,WAAW,WAAW;IAC1B,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,yDAAyD;AACzD,MAAM,WAAW,gBAAiB,SAAQ,WAAW;IACnD,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,qBAAqB;IACpC,aAAa,EAAE,MAAM,CAAC;IACtB,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC;CAC9C;AAED,MAAM,WAAW,kBAAkB;IACjC,aAAa,EAAE,MAAM,CAAC;IACtB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;CACrC;AAED,0EAA0E;AAC1E,MAAM,WAAW,iBAAiB;IAChC,4FAA4F;IAC5F,UAAU,EAAE,MAAM,CAAC;IACnB,4EAA4E;IAC5E,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,kBAAkB;IACjC,cAAc,EAAE,MAAM,CAAC;IACvB,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,wBAAgB,mBAAmB,CACjC,KAAK,EAAE,SAAS,iBAAiB,EAAE,EACnC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,EACnC,SAAS,EAAE,MAAM;;;;;;;;;;;EAwBlB;AAED,wBAAsB,mBAAmB,CACvC,OAAO,EAAE;IACP,UAAU,EAAE,qBAAqB,CAAC;IAClC,OAAO,EAAE,kBAAkB,CAAC;CAC7B,EACD,KAAK,EAAE,kBAAkB,GACxB,OAAO,CAAC,IAAI,CAAC,CAYf;AAED;;;GAGG;AACH,wBAAsB,wBAAwB,CAC5C,KAAK,EAAE,kBAAkB,GACxB,OAAO,CAAC,IAAI,CAAC,CAiBf"}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared types and helpers for writing per-provider pricing bundles during
|
|
3
|
+
* codegen.
|
|
4
|
+
*
|
|
5
|
+
* Each provider (FAL, Replicate, Kie, …) builds the same two JSON files
|
|
6
|
+
* alongside its node manifest:
|
|
7
|
+
*
|
|
8
|
+
* 1. `<provider>-node-type-pricing.json` — `byNodeType` map keyed by the
|
|
9
|
+
* runtime NodeTool `node_type`, used by the frontend to attach a
|
|
10
|
+
* `<provider>_unit_pricing` field onto each `NodeMetadata`.
|
|
11
|
+
* 2. `<provider>-unit-pricing.json` — raw price catalog keyed by the
|
|
12
|
+
* provider's own endpoint/model identifier. Mostly useful for diffing
|
|
13
|
+
* and showing "snapshot recorded at" in the UI.
|
|
14
|
+
*
|
|
15
|
+
* Per-provider codegen packages are expected to:
|
|
16
|
+
* - implement a small `<provider>-pricing-fetch.ts` that turns a list of
|
|
17
|
+
* endpoint IDs into `Record<endpointId, UnitPricing>` (provider APIs
|
|
18
|
+
* differ too much to share).
|
|
19
|
+
* - map their `NodeSpec` array to `PricingBundleSpec[]` (just `endpointId`
|
|
20
|
+
* + `nodeType`) and hand it to {@link buildPricingBundles}.
|
|
21
|
+
* - call {@link writePricingBundles} / {@link writeEmptyPricingBundles}
|
|
22
|
+
* with the two output paths.
|
|
23
|
+
*
|
|
24
|
+
* The `endpoint_id` field name is kept across providers even though it is
|
|
25
|
+
* FAL-flavored — the frontend already treats it as the canonical
|
|
26
|
+
* "provider-identifier" key, and renaming would ripple through every
|
|
27
|
+
* `attach*UnitPricing.ts` and `format*UnitPricing.ts` util.
|
|
28
|
+
*/
|
|
29
|
+
import { mkdir, writeFile } from "node:fs/promises";
|
|
30
|
+
import { dirname } from "node:path";
|
|
31
|
+
/** Stable on-disk schema version; bump when the JSON shape changes. */
|
|
32
|
+
export const NODE_TYPE_PRICING_SCHEMA_VERSION = 1;
|
|
33
|
+
export function buildPricingBundles(specs, prices, writtenAt) {
|
|
34
|
+
const byNodeType = {};
|
|
35
|
+
const catalog = {};
|
|
36
|
+
for (const spec of specs) {
|
|
37
|
+
const entry = prices[spec.endpointId];
|
|
38
|
+
if (!entry)
|
|
39
|
+
continue;
|
|
40
|
+
byNodeType[spec.nodeType] = { endpoint_id: spec.endpointId, ...entry };
|
|
41
|
+
catalog[spec.endpointId] = entry;
|
|
42
|
+
}
|
|
43
|
+
return {
|
|
44
|
+
byNodeType: {
|
|
45
|
+
schemaVersion: NODE_TYPE_PRICING_SCHEMA_VERSION,
|
|
46
|
+
writtenAt,
|
|
47
|
+
byNodeType
|
|
48
|
+
},
|
|
49
|
+
catalog: {
|
|
50
|
+
schemaVersion: NODE_TYPE_PRICING_SCHEMA_VERSION,
|
|
51
|
+
writtenAt,
|
|
52
|
+
prices: catalog
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
export async function writePricingBundles(bundles, paths) {
|
|
57
|
+
await mkdir(dirname(paths.byNodeTypePath), { recursive: true });
|
|
58
|
+
await Promise.all([
|
|
59
|
+
writeFile(paths.byNodeTypePath, JSON.stringify(bundles.byNodeType, null, 2) + "\n"),
|
|
60
|
+
writeFile(paths.catalogPath, JSON.stringify(bundles.catalog, null, 2) + "\n")
|
|
61
|
+
]);
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Write empty (stub) bundles for fresh checkouts that have no pricing files yet.
|
|
65
|
+
* Codegen must not call this when committed bundles already exist on disk.
|
|
66
|
+
*/
|
|
67
|
+
export async function writeEmptyPricingBundles(paths) {
|
|
68
|
+
const writtenAt = new Date(0).toISOString();
|
|
69
|
+
await writePricingBundles({
|
|
70
|
+
byNodeType: {
|
|
71
|
+
schemaVersion: NODE_TYPE_PRICING_SCHEMA_VERSION,
|
|
72
|
+
writtenAt,
|
|
73
|
+
byNodeType: {}
|
|
74
|
+
},
|
|
75
|
+
catalog: {
|
|
76
|
+
schemaVersion: NODE_TYPE_PRICING_SCHEMA_VERSION,
|
|
77
|
+
writtenAt,
|
|
78
|
+
prices: {}
|
|
79
|
+
}
|
|
80
|
+
}, paths);
|
|
81
|
+
}
|
|
82
|
+
//# sourceMappingURL=pricing-bundle.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pricing-bundle.js","sourceRoot":"","sources":["../src/pricing-bundle.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;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AAC,WAAW,EACjB,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC,GAAG,IAAI,CAChD;KACF,CAAC,CAAC;AACL,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,wBAAwB,CAC5C,KAAyB;IAEzB,MAAM,SAAS,GAAG,IAAI,IAAI,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC;IAC5C,MAAM,mBAAmB,CACvB;QACE,UAAU,EAAE;YACV,aAAa,EAAE,gCAAgC;YAC/C,SAAS;YACT,UAAU,EAAE,EAAE;SACf;QACD,OAAO,EAAE;YACP,aAAa,EAAE,gCAAgC;YAC/C,SAAS;YACT,MAAM,EAAE,EAAE;SACX;KACF,EACD,KAAK,CACN,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Read what a node states about the job it will run — duration, resolution,
|
|
3
|
+
* audio — off its property values, in the vocabulary the price catalogs bill
|
|
4
|
+
* in. The sibling of the fan-out property list: both turn node data into the
|
|
5
|
+
* numbers `estimateWorkflowCost` multiplies.
|
|
6
|
+
*
|
|
7
|
+
* Pure and lenient in, strict out: a property we do not recognize, or a value
|
|
8
|
+
* we cannot read, leaves the field unset. Unset is priced at the model's base
|
|
9
|
+
* spec with an assumption the user can see; a guessed tier would be an invented
|
|
10
|
+
* number nobody can audit.
|
|
11
|
+
*
|
|
12
|
+
* ## Property-name census (2026-08-12)
|
|
13
|
+
*
|
|
14
|
+
* Counted over the shipped generator manifests — `packages/fal-nodes`
|
|
15
|
+
* (`fal-manifest.json`), `packages/replicate-nodes` (`replicate-manifest.json`),
|
|
16
|
+
* `packages/kie-nodes` (`kie-manifest.json`) — as distinct `inputFields[].name`
|
|
17
|
+
* occurrences, plus the hand-written `@prop` declarations in
|
|
18
|
+
* `packages/video-nodes` and `packages/image-nodes`:
|
|
19
|
+
*
|
|
20
|
+
* | name | manifests | note |
|
|
21
|
+
* |---|---|---|
|
|
22
|
+
* | `duration` | 307 | also `nodetool.video.TextToVideo`/`ImageToVideo` (int seconds) |
|
|
23
|
+
* | `num_frames` | 183 | with `fps` (94) / `frames_per_second` (74) |
|
|
24
|
+
* | `duration_seconds` | 1 | the name the video nodes pass to providers |
|
|
25
|
+
* | `seconds` | 2 | |
|
|
26
|
+
* | `video_length` | 1 | |
|
|
27
|
+
* | `duration_sec`, `max_duration`, `music_duration` | 1 each | not read: not the billed output length |
|
|
28
|
+
* | `resolution` | 387 | also the video nodes (`720p`…`4K`) |
|
|
29
|
+
* | `image_size` | 316 | `square_hd`, `1024x1024`, `1K`, `auto`, … |
|
|
30
|
+
* | `size` | 26 | `1024x1024`, `1280*720`, `2K` |
|
|
31
|
+
* | `quality` | 23 | mostly `high`/`auto`; one node uses `540p` |
|
|
32
|
+
* | `width` / `height` | 79 / 79 | |
|
|
33
|
+
* | `video_size` | 49 | not read: an aspect-ratio name on every node carrying it |
|
|
34
|
+
* | `generate_audio` | 139 | plus `generate_audio_switch` (18), `audio_enabled` (1) |
|
|
35
|
+
* | `with_audio` | 1 | |
|
|
36
|
+
* | `audio` | 184 | **not read**: on all but a handful it is an audio *input* ref |
|
|
37
|
+
*
|
|
38
|
+
* A pixel size is read twice over, because it means two different things: with
|
|
39
|
+
* a duration present the node is producing a clip, so `width`/`height` or a
|
|
40
|
+
* `1280*720` value names the video rung its short side sits on (720p), and with
|
|
41
|
+
* no duration it is a still, so the same pair gives the image tier and the
|
|
42
|
+
* megapixel count image grids are laddered by.
|
|
43
|
+
*
|
|
44
|
+
* `video_duration` and `num_seconds` from the plan's draft list ship on **no**
|
|
45
|
+
* node and are omitted. `audio` is likewise omitted: 184 occurrences and nearly
|
|
46
|
+
* all of them are `audio: AudioRef` inputs, so reading it as a billing axis
|
|
47
|
+
* would flip models to their dearer audio rung on a property that means
|
|
48
|
+
* something else. `generate_audio` / `generate_audio_switch` / `audio_enabled` /
|
|
49
|
+
* `with_audio` are the booleans that really name the axis.
|
|
50
|
+
*/
|
|
51
|
+
import type { ModelPriceParams } from "./cost-estimate.js";
|
|
52
|
+
/**
|
|
53
|
+
* Read the pricing-relevant parameters off a node's property values. Pass the
|
|
54
|
+
* property bag (`node.data.properties` in the editor, `node.data` on the
|
|
55
|
+
* server's flat shape) — unknown keys are ignored.
|
|
56
|
+
*/
|
|
57
|
+
export declare function extractPricingParams(values: Record<string, unknown> | undefined | null): ModelPriceParams;
|
|
58
|
+
export default extractPricingParams;
|
|
59
|
+
//# sourceMappingURL=pricing-params.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pricing-params.d.ts","sourceRoot":"","sources":["../src/pricing-params.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiDG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AA8J3D;;;;GAIG;AACH,wBAAgB,oBAAoB,CAClC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,GAAG,IAAI,GACjD,gBAAgB,CAyFlB;eAEc,oBAAoB"}
|
|
@@ -0,0 +1,282 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Read what a node states about the job it will run — duration, resolution,
|
|
3
|
+
* audio — off its property values, in the vocabulary the price catalogs bill
|
|
4
|
+
* in. The sibling of the fan-out property list: both turn node data into the
|
|
5
|
+
* numbers `estimateWorkflowCost` multiplies.
|
|
6
|
+
*
|
|
7
|
+
* Pure and lenient in, strict out: a property we do not recognize, or a value
|
|
8
|
+
* we cannot read, leaves the field unset. Unset is priced at the model's base
|
|
9
|
+
* spec with an assumption the user can see; a guessed tier would be an invented
|
|
10
|
+
* number nobody can audit.
|
|
11
|
+
*
|
|
12
|
+
* ## Property-name census (2026-08-12)
|
|
13
|
+
*
|
|
14
|
+
* Counted over the shipped generator manifests — `packages/fal-nodes`
|
|
15
|
+
* (`fal-manifest.json`), `packages/replicate-nodes` (`replicate-manifest.json`),
|
|
16
|
+
* `packages/kie-nodes` (`kie-manifest.json`) — as distinct `inputFields[].name`
|
|
17
|
+
* occurrences, plus the hand-written `@prop` declarations in
|
|
18
|
+
* `packages/video-nodes` and `packages/image-nodes`:
|
|
19
|
+
*
|
|
20
|
+
* | name | manifests | note |
|
|
21
|
+
* |---|---|---|
|
|
22
|
+
* | `duration` | 307 | also `nodetool.video.TextToVideo`/`ImageToVideo` (int seconds) |
|
|
23
|
+
* | `num_frames` | 183 | with `fps` (94) / `frames_per_second` (74) |
|
|
24
|
+
* | `duration_seconds` | 1 | the name the video nodes pass to providers |
|
|
25
|
+
* | `seconds` | 2 | |
|
|
26
|
+
* | `video_length` | 1 | |
|
|
27
|
+
* | `duration_sec`, `max_duration`, `music_duration` | 1 each | not read: not the billed output length |
|
|
28
|
+
* | `resolution` | 387 | also the video nodes (`720p`…`4K`) |
|
|
29
|
+
* | `image_size` | 316 | `square_hd`, `1024x1024`, `1K`, `auto`, … |
|
|
30
|
+
* | `size` | 26 | `1024x1024`, `1280*720`, `2K` |
|
|
31
|
+
* | `quality` | 23 | mostly `high`/`auto`; one node uses `540p` |
|
|
32
|
+
* | `width` / `height` | 79 / 79 | |
|
|
33
|
+
* | `video_size` | 49 | not read: an aspect-ratio name on every node carrying it |
|
|
34
|
+
* | `generate_audio` | 139 | plus `generate_audio_switch` (18), `audio_enabled` (1) |
|
|
35
|
+
* | `with_audio` | 1 | |
|
|
36
|
+
* | `audio` | 184 | **not read**: on all but a handful it is an audio *input* ref |
|
|
37
|
+
*
|
|
38
|
+
* A pixel size is read twice over, because it means two different things: with
|
|
39
|
+
* a duration present the node is producing a clip, so `width`/`height` or a
|
|
40
|
+
* `1280*720` value names the video rung its short side sits on (720p), and with
|
|
41
|
+
* no duration it is a still, so the same pair gives the image tier and the
|
|
42
|
+
* megapixel count image grids are laddered by.
|
|
43
|
+
*
|
|
44
|
+
* `video_duration` and `num_seconds` from the plan's draft list ship on **no**
|
|
45
|
+
* node and are omitted. `audio` is likewise omitted: 184 occurrences and nearly
|
|
46
|
+
* all of them are `audio: AudioRef` inputs, so reading it as a billing axis
|
|
47
|
+
* would flip models to their dearer audio rung on a property that means
|
|
48
|
+
* something else. `generate_audio` / `generate_audio_switch` / `audio_enabled` /
|
|
49
|
+
* `with_audio` are the booleans that really name the axis.
|
|
50
|
+
*/
|
|
51
|
+
import { isBoolean, isNumber, isRecord, isString } from "./type-predicates.js";
|
|
52
|
+
/** Duration properties, most specific first. The first present value wins. */
|
|
53
|
+
const DURATION_PROPERTIES = [
|
|
54
|
+
"duration",
|
|
55
|
+
"duration_seconds",
|
|
56
|
+
"seconds",
|
|
57
|
+
"num_seconds",
|
|
58
|
+
"video_length",
|
|
59
|
+
"video_duration"
|
|
60
|
+
];
|
|
61
|
+
/** Resolution-ish properties, most specific first. */
|
|
62
|
+
const RESOLUTION_PROPERTIES = ["resolution", "image_size", "size", "quality"];
|
|
63
|
+
/** Booleans that name the audio billing axis (never `audio`, an input ref). */
|
|
64
|
+
const AUDIO_PROPERTIES = [
|
|
65
|
+
"generate_audio",
|
|
66
|
+
"generate_audio_switch",
|
|
67
|
+
"audio_enabled",
|
|
68
|
+
"with_audio"
|
|
69
|
+
];
|
|
70
|
+
/** Frame-rate properties paired with `num_frames`. */
|
|
71
|
+
const FPS_PROPERTIES = ["fps", "frames_per_second", "frame_rate"];
|
|
72
|
+
/** A finite positive number from a number or a string like `"5"` / `"5s"`. */
|
|
73
|
+
function readSeconds(value) {
|
|
74
|
+
if (isNumber(value)) {
|
|
75
|
+
return Number.isFinite(value) && value > 0 ? value : undefined;
|
|
76
|
+
}
|
|
77
|
+
if (!isString(value))
|
|
78
|
+
return undefined;
|
|
79
|
+
// Trim and collapse runs before matching: adjacent unbounded whitespace
|
|
80
|
+
// quantifiers around an optional group backtrack polynomially (CodeQL).
|
|
81
|
+
const compact = value.trim().replace(/\s+/g, " ");
|
|
82
|
+
const match = /^(\d+(?:\.\d+)?) ?(?:s|secs?|seconds)?$/i.exec(compact);
|
|
83
|
+
if (!match)
|
|
84
|
+
return undefined;
|
|
85
|
+
const parsed = Number(match[1]);
|
|
86
|
+
return Number.isFinite(parsed) && parsed > 0 ? parsed : undefined;
|
|
87
|
+
}
|
|
88
|
+
function readPositiveNumber(value) {
|
|
89
|
+
const parsed = isString(value) ? Number(value.trim()) : value;
|
|
90
|
+
return isNumber(parsed) && Number.isFinite(parsed) && parsed > 0
|
|
91
|
+
? parsed
|
|
92
|
+
: undefined;
|
|
93
|
+
}
|
|
94
|
+
/** A supplied media ref, including a byte count left by generation redaction. */
|
|
95
|
+
function hasImageSource(value) {
|
|
96
|
+
if (value instanceof Uint8Array)
|
|
97
|
+
return value.byteLength > 0;
|
|
98
|
+
if (isString(value))
|
|
99
|
+
return value.length > 0;
|
|
100
|
+
if (!isRecord(value))
|
|
101
|
+
return false;
|
|
102
|
+
return ((isString(value.uri) && value.uri.length > 0) ||
|
|
103
|
+
(isString(value.asset_id) && value.asset_id.length > 0) ||
|
|
104
|
+
(isString(value.data) && value.data.length > 0) ||
|
|
105
|
+
(value.data instanceof Uint8Array && value.data.byteLength > 0) ||
|
|
106
|
+
(isNumber(value.bytes) && Number.isFinite(value.bytes) && value.bytes > 0));
|
|
107
|
+
}
|
|
108
|
+
function countImages(value) {
|
|
109
|
+
return Array.isArray(value)
|
|
110
|
+
? value.filter(hasImageSource).length
|
|
111
|
+
: Number(hasImageSource(value));
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* The pixel tiers the catalogs price image models at. A `width × height` pair
|
|
115
|
+
* lands on the nearest one by total pixels, but only inside a 1.5× band —
|
|
116
|
+
* beyond that we would be naming a tier the provider never quoted.
|
|
117
|
+
*/
|
|
118
|
+
const PIXEL_TIERS = [
|
|
119
|
+
{ pixels: 512 * 512, tier: "512x512" },
|
|
120
|
+
{ pixels: 1024 * 1024, tier: "1024x1024" },
|
|
121
|
+
{ pixels: 2048 * 2048, tier: "2K" },
|
|
122
|
+
{ pixels: 4096 * 4096, tier: "4K" }
|
|
123
|
+
];
|
|
124
|
+
/**
|
|
125
|
+
* The video ladder, keyed by the frame's short side — the dimension the rung is
|
|
126
|
+
* named after, in portrait as in landscape (1080×1920 is 1080p too). A node
|
|
127
|
+
* that states a pixel pair and a duration is describing a clip, and clips are
|
|
128
|
+
* billed by rung, not by area: 1280×720 is the 720p rung, and pricing it as a
|
|
129
|
+
* 1MP image was how a real 720p clip came back unpriced.
|
|
130
|
+
*/
|
|
131
|
+
const VIDEO_SHORT_SIDE_TIERS = [360, 480, 540, 576, 720, 768, 1080, 1440, 2160];
|
|
132
|
+
/** The rung a frame sits on, within 10% of its short side — otherwise none. */
|
|
133
|
+
function tierForFrame(width, height) {
|
|
134
|
+
const shortSide = Math.min(width, height);
|
|
135
|
+
let best;
|
|
136
|
+
let bestRatio = Infinity;
|
|
137
|
+
for (const candidate of VIDEO_SHORT_SIDE_TIERS) {
|
|
138
|
+
const ratio = shortSide > candidate ? shortSide / candidate : candidate / shortSide;
|
|
139
|
+
if (ratio < bestRatio) {
|
|
140
|
+
bestRatio = ratio;
|
|
141
|
+
best = candidate;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
return best !== undefined && bestRatio <= 1.1 ? `${best}p` : undefined;
|
|
145
|
+
}
|
|
146
|
+
/** The tier a pixel count sits closest to, or undefined when it sits far off. */
|
|
147
|
+
function tierForPixels(pixels) {
|
|
148
|
+
let best = PIXEL_TIERS[0];
|
|
149
|
+
let bestRatio = Infinity;
|
|
150
|
+
for (const candidate of PIXEL_TIERS) {
|
|
151
|
+
const ratio = pixels > candidate.pixels ? pixels / candidate.pixels : candidate.pixels / pixels;
|
|
152
|
+
if (ratio < bestRatio) {
|
|
153
|
+
bestRatio = ratio;
|
|
154
|
+
best = candidate;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
return bestRatio <= 1.5 ? best.tier : undefined;
|
|
158
|
+
}
|
|
159
|
+
/** The width and height in a `1280*720` / `768x512` value, if it is one. */
|
|
160
|
+
function readPixelPair(value) {
|
|
161
|
+
if (!isString(value))
|
|
162
|
+
return undefined;
|
|
163
|
+
const pair = /^(\d+) ?[x*×] ?(\d+)$/i.exec(value.trim());
|
|
164
|
+
if (!pair)
|
|
165
|
+
return undefined;
|
|
166
|
+
const width = Number(pair[1]);
|
|
167
|
+
const height = Number(pair[2]);
|
|
168
|
+
return width > 0 && height > 0 ? { width, height } : undefined;
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* A stated resolution, passed through as the raw spelling for the calculator to
|
|
172
|
+
* normalize. Names that carry no resolution at all (`auto`, `square_hd`,
|
|
173
|
+
* `high`) return undefined, which prices at the base spec instead of guessing.
|
|
174
|
+
* A pixel pair maps to the video rung its height names when the node also
|
|
175
|
+
* states a duration, and to the nearest image tier otherwise.
|
|
176
|
+
*/
|
|
177
|
+
function readResolution(value, video) {
|
|
178
|
+
if (isNumber(value)) {
|
|
179
|
+
return Number.isFinite(value) && value > 0 ? String(value) : undefined;
|
|
180
|
+
}
|
|
181
|
+
if (!isString(value))
|
|
182
|
+
return undefined;
|
|
183
|
+
const text = value.trim();
|
|
184
|
+
if (!text)
|
|
185
|
+
return undefined;
|
|
186
|
+
const pair = readPixelPair(text);
|
|
187
|
+
if (pair) {
|
|
188
|
+
return video
|
|
189
|
+
? tierForFrame(pair.width, pair.height)
|
|
190
|
+
: tierForPixels(pair.width * pair.height);
|
|
191
|
+
}
|
|
192
|
+
// `720p`, `4K`, `1MP`, `1024` — spellings the calculator's tier table knows.
|
|
193
|
+
if (/^(\d+(\.\d+)?) ?(p|k|mp)?$/i.test(text))
|
|
194
|
+
return text;
|
|
195
|
+
return undefined;
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* Read the pricing-relevant parameters off a node's property values. Pass the
|
|
199
|
+
* property bag (`node.data.properties` in the editor, `node.data` on the
|
|
200
|
+
* server's flat shape) — unknown keys are ignored.
|
|
201
|
+
*/
|
|
202
|
+
export function extractPricingParams(values) {
|
|
203
|
+
const params = {};
|
|
204
|
+
if (!values)
|
|
205
|
+
return params;
|
|
206
|
+
for (const name of DURATION_PROPERTIES) {
|
|
207
|
+
const seconds = readSeconds(values[name]);
|
|
208
|
+
if (seconds !== undefined) {
|
|
209
|
+
params.seconds = seconds;
|
|
210
|
+
break;
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
if (params.seconds === undefined) {
|
|
214
|
+
const frames = readPositiveNumber(values.num_frames);
|
|
215
|
+
const fps = FPS_PROPERTIES.map((name) => readPositiveNumber(values[name])).find((value) => value !== undefined);
|
|
216
|
+
if (frames !== undefined && fps !== undefined) {
|
|
217
|
+
params.seconds = frames / fps;
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
// A duration means the node is producing a clip, which decides how a pixel
|
|
221
|
+
// pair is read: by rung for video, by area for a still.
|
|
222
|
+
const video = params.seconds !== undefined;
|
|
223
|
+
for (const name of RESOLUTION_PROPERTIES) {
|
|
224
|
+
const resolution = readResolution(values[name], video);
|
|
225
|
+
if (resolution !== undefined) {
|
|
226
|
+
params.resolution = resolution;
|
|
227
|
+
break;
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
// The pixel count the job states, wherever it states it: a `width`/`height`
|
|
231
|
+
// pair or a `1280*720` value. Both feed the video rung and, for a still, the
|
|
232
|
+
// megapixel rung an image grid is laddered by.
|
|
233
|
+
const width = readPositiveNumber(values.width);
|
|
234
|
+
const height = readPositiveNumber(values.height);
|
|
235
|
+
const pair = width !== undefined && height !== undefined
|
|
236
|
+
? { width, height }
|
|
237
|
+
: RESOLUTION_PROPERTIES.map((name) => readPixelPair(values[name])).find((found) => found !== undefined);
|
|
238
|
+
if (pair) {
|
|
239
|
+
if (params.resolution === undefined) {
|
|
240
|
+
const tier = video
|
|
241
|
+
? tierForFrame(pair.width, pair.height)
|
|
242
|
+
: tierForPixels(pair.width * pair.height);
|
|
243
|
+
if (tier !== undefined)
|
|
244
|
+
params.resolution = tier;
|
|
245
|
+
}
|
|
246
|
+
if (!video) {
|
|
247
|
+
params.megapixels =
|
|
248
|
+
Math.round(((pair.width * pair.height) / 1_000_000) * 100) / 100;
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
for (const name of AUDIO_PROPERTIES) {
|
|
252
|
+
const value = values[name];
|
|
253
|
+
if (isBoolean(value)) {
|
|
254
|
+
params.withAudio = value;
|
|
255
|
+
break;
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
const text = values.text;
|
|
259
|
+
if (isString(text) && text.length > 0) {
|
|
260
|
+
params.characters = text.length;
|
|
261
|
+
}
|
|
262
|
+
else if (isRecord(text)) {
|
|
263
|
+
if (text.truncated === true) {
|
|
264
|
+
params.characters = readPositiveNumber(text.length);
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
const inputImages = countImages(values.image ?? values.images);
|
|
268
|
+
const references = countImages(values.reference_images);
|
|
269
|
+
const entityImages = Array.isArray(values.entities)
|
|
270
|
+
? values.entities.reduce((count, entity) => {
|
|
271
|
+
if (!isRecord(entity))
|
|
272
|
+
return count;
|
|
273
|
+
return (count + countImages(entity.image) + countImages(entity.reference_images));
|
|
274
|
+
}, 0)
|
|
275
|
+
: 0;
|
|
276
|
+
const imageCount = inputImages + references + entityImages;
|
|
277
|
+
if (imageCount > 0)
|
|
278
|
+
params.referenceImages = imageCount;
|
|
279
|
+
return params;
|
|
280
|
+
}
|
|
281
|
+
export default extractPricingParams;
|
|
282
|
+
//# sourceMappingURL=pricing-params.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pricing-params.js","sourceRoot":"","sources":["../src/pricing-params.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiDG;AAGH,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAA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AED,MAAM,WAAW,GAAG,WAAW,CAAC,MAAM,CAAC,KAAK,IAAI,MAAM,CAAC,MAAM,CAAC,CAAC;IAC/D,MAAM,UAAU,GAAG,WAAW,CAAC,MAAM,CAAC,gBAAgB,CAAC,CAAC;IACxD,MAAM,YAAY,GAAG,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC;QACjD,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,KAAa,EAAE,MAAe,EAAE,EAAE;YACxD,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC;gBAAE,OAAO,KAAK,CAAC;YACpC,OAAO,CACL,KAAK,GAAG,WAAW,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,WAAW,CAAC,MAAM,CAAC,gBAAgB,CAAC,CACzE,CAAC;QACJ,CAAC,EAAE,CAAC,CAAC;QACP,CAAC,CAAC,CAAC,CAAC;IACN,MAAM,UAAU,GAAG,WAAW,GAAG,UAAU,GAAG,YAAY,CAAC;IAC3D,IAAI,UAAU,GAAG,CAAC;QAAE,MAAM,CAAC,eAAe,GAAG,UAAU,CAAC;IAExD,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,eAAe,oBAAoB,CAAC"}
|
|
@@ -37,6 +37,14 @@ export declare class PythonScanError extends Error {
|
|
|
37
37
|
* Requires `nodetool-core` to be installed in the target Python environment.
|
|
38
38
|
*/
|
|
39
39
|
export declare function scanPythonPackage(opts: PythonScanOptions): Promise<PythonScanResult>;
|
|
40
|
+
/**
|
|
41
|
+
* Parse "SCAN write path=<path>.json" and return the reported path.
|
|
42
|
+
*
|
|
43
|
+
* The path is used verbatim (it may use / or \ separators and any package
|
|
44
|
+
* layout — `src/nodetool/package_metadata` or the flat `nodetool/...`).
|
|
45
|
+
* Exported for testing.
|
|
46
|
+
*/
|
|
47
|
+
export declare function findWrittenMetadataPath(stderr: string): string | null;
|
|
40
48
|
/**
|
|
41
49
|
* Resolve a Python executable, matching the convention used by
|
|
42
50
|
* `PythonStdioBridge` in `@nodetool-ai/runtime`.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"python-package-scan.d.ts","sourceRoot":"","sources":["../src/python-package-scan.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAOH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAErD,MAAM,WAAW,iBAAiB;IAChC,gEAAgE;IAChE,UAAU,EAAE,MAAM,CAAC;IACnB,2EAA2E;IAC3E,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,6DAA6D;IAC7D,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,uEAAuE;IACvE,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,uCAAuC;IACvC,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,iDAAiD;IACjD,UAAU,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IACpC,6BAA6B;IAC7B,MAAM,CAAC,EAAE,WAAW,CAAC;CACtB;AAED,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,EAAE,eAAe,CAAC;IAC1B,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,qBAAa,eAAgB,SAAQ,KAAK;aAGtB,QAAQ,EAAE,MAAM,GAAG,IAAI;aACvB,MAAM,EAAE,MAAM;
|
|
1
|
+
{"version":3,"file":"python-package-scan.d.ts","sourceRoot":"","sources":["../src/python-package-scan.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAOH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAErD,MAAM,WAAW,iBAAiB;IAChC,gEAAgE;IAChE,UAAU,EAAE,MAAM,CAAC;IACnB,2EAA2E;IAC3E,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,6DAA6D;IAC7D,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,uEAAuE;IACvE,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,uCAAuC;IACvC,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,iDAAiD;IACjD,UAAU,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IACpC,6BAA6B;IAC7B,MAAM,CAAC,EAAE,WAAW,CAAC;CACtB;AAED,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,EAAE,eAAe,CAAC;IAC1B,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,qBAAa,eAAgB,SAAQ,KAAK;aAGtB,QAAQ,EAAE,MAAM,GAAG,IAAI;aACvB,MAAM,EAAE,MAAM;IAHhC,YACE,OAAO,EAAE,MAAM,EACC,QAAQ,EAAE,MAAM,GAAG,IAAI,EACvB,MAAM,EAAE,MAAM,EAI/B;CACF;AAED;;;;GAIG;AACH,wBAAsB,iBAAiB,CACrC,IAAI,EAAE,iBAAiB,GACtB,OAAO,CAAC,gBAAgB,CAAC,CAwG3B;AAED;;;;;;GAMG;AACH,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAGrE;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,IAAI,MAAM,CAkBzC"}
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
import { spawn } from "node:child_process";
|
|
9
9
|
import { homedir } from "node:os";
|
|
10
10
|
import { existsSync, readFileSync } from "node:fs";
|
|
11
|
-
import { basename, join } from "node:path";
|
|
11
|
+
import { basename, isAbsolute, join } from "node:path";
|
|
12
12
|
export class PythonScanError extends Error {
|
|
13
13
|
exitCode;
|
|
14
14
|
stderr;
|
|
@@ -68,6 +68,13 @@ export async function scanPythonPackage(opts) {
|
|
|
68
68
|
});
|
|
69
69
|
child.once("close", (code) => {
|
|
70
70
|
const stderr = Buffer.concat(stderrChunks).toString("utf8");
|
|
71
|
+
// Flush a final progress line that arrived without a trailing newline.
|
|
72
|
+
if (opts.onProgress && stderrBuffer) {
|
|
73
|
+
const line = stderrBuffer.trimEnd();
|
|
74
|
+
stderrBuffer = "";
|
|
75
|
+
if (line.startsWith("SCAN"))
|
|
76
|
+
opts.onProgress(line);
|
|
77
|
+
}
|
|
71
78
|
if (code !== 0) {
|
|
72
79
|
reject(new PythonScanError(`nodetool-pkg scan exited with code ${code}`, code, stderr));
|
|
73
80
|
return;
|
|
@@ -76,11 +83,13 @@ export async function scanPythonPackage(opts) {
|
|
|
76
83
|
let metadata;
|
|
77
84
|
if (opts.write) {
|
|
78
85
|
// --write: no JSON on stdout; read the file the scanner wrote.
|
|
79
|
-
const
|
|
80
|
-
if (!
|
|
86
|
+
const reported = findWrittenMetadataPath(stderr);
|
|
87
|
+
if (!reported) {
|
|
81
88
|
throw new Error("scanner did not report a SCAN write path line");
|
|
82
89
|
}
|
|
83
|
-
const metadataPath =
|
|
90
|
+
const metadataPath = isAbsolute(reported)
|
|
91
|
+
? reported
|
|
92
|
+
: join(opts.packageDir, reported);
|
|
84
93
|
metadata = JSON.parse(readFileSync(metadataPath, "utf8"));
|
|
85
94
|
}
|
|
86
95
|
else {
|
|
@@ -96,11 +105,15 @@ export async function scanPythonPackage(opts) {
|
|
|
96
105
|
});
|
|
97
106
|
}
|
|
98
107
|
/**
|
|
99
|
-
* Parse "SCAN write path
|
|
108
|
+
* Parse "SCAN write path=<path>.json" and return the reported path.
|
|
109
|
+
*
|
|
110
|
+
* The path is used verbatim (it may use / or \ separators and any package
|
|
111
|
+
* layout — `src/nodetool/package_metadata` or the flat `nodetool/...`).
|
|
112
|
+
* Exported for testing.
|
|
100
113
|
*/
|
|
101
|
-
function
|
|
102
|
-
const match = stderr.match(
|
|
103
|
-
return match?.[
|
|
114
|
+
export function findWrittenMetadataPath(stderr) {
|
|
115
|
+
const match = stderr.match(/^SCAN write path=(.+\.json)\s*$/m);
|
|
116
|
+
return match?.[1] ?? null;
|
|
104
117
|
}
|
|
105
118
|
/**
|
|
106
119
|
* Resolve a Python executable, matching the convention used by
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"python-package-scan.js","sourceRoot":"","sources":["../src/python-package-scan.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"python-package-scan.js","sourceRoot":"","sources":["../src/python-package-scan.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AA0BvD,MAAM,OAAO,eAAgB,SAAQ,KAAK;IAGtB,QAAQ;IACR,MAAM;IAHxB,YACE,OAAe,EACC,QAAuB,EACvB,MAAc;QAE9B,KAAK,CAAC,OAAO,CAAC,CAAC;wBAHC,QAAQ;sBACR,MAAM;QAGtB,IAAI,CAAC,IAAI,GAAG,iBAAiB,CAAC;IAChC,CAAC;CACF;AAED;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,iBAAiB,CACrC,IAAuB;IAEvB,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,IAAI,gBAAgB,EAAE,CAAC;IAEjD,MAAM,IAAI,GAAG;QACX,IAAI;QACJ,wBAAwB;QACxB,MAAM;QACN,eAAe;QACf,IAAI,CAAC,UAAU;KAChB,CAAC;IACF,IAAI,IAAI,CAAC,MAAM;QAAE,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;IACvC,IAAI,IAAI,CAAC,KAAK;QAAE,IAAI,CAAC,IAAI,CAAC,SAAS,C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