@uru-intelligence/app 1.0.0 → 2.1.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/README.md +167 -13
- package/dist/dampers.d.ts +7 -74
- package/dist/dampers.js +36 -131
- package/dist/dataset-boundary.d.ts +31 -0
- package/dist/dataset-boundary.js +292 -0
- package/dist/datasets.d.ts +4 -4
- package/dist/datasets.js +111 -80
- package/dist/{errorResponse.d.ts → error-response.d.ts} +1 -1
- package/dist/error-response.js +11 -0
- package/dist/errors.js +1 -1
- package/dist/files.d.ts +2 -0
- package/dist/files.js +149 -0
- package/dist/index.d.ts +28 -12
- package/dist/index.js +96 -53
- package/dist/invocations.d.ts +7 -0
- package/dist/invocations.js +27 -0
- package/dist/jobs.d.ts +4 -0
- package/dist/jobs.js +35 -0
- package/dist/runtime.d.ts +5 -5
- package/dist/runtime.js +23 -23
- package/dist/transport-json.d.ts +9 -0
- package/dist/transport-json.js +101 -0
- package/dist/transport.d.ts +14 -13
- package/dist/transport.js +496 -443
- package/dist/types.d.ts +188 -42
- package/dist/types.js +2 -2
- package/dist/uploads.d.ts +32 -0
- package/dist/uploads.js +228 -0
- package/package.json +61 -59
- package/dist/errorResponse.js +0 -11
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
/** Keep later JSON.stringify calls below the JavaScript stack limit. */
|
|
2
|
+
export const RUNTIME_JSON_NESTING_DEPTH_MAX = 64;
|
|
3
|
+
const isJsonPrimitive = (value) => value === null ||
|
|
4
|
+
typeof value === "string" ||
|
|
5
|
+
typeof value === "boolean" ||
|
|
6
|
+
(typeof value === "number" && Number.isFinite(value));
|
|
7
|
+
const isArrayIndex = (key, length) => {
|
|
8
|
+
const index = Number(key);
|
|
9
|
+
return (Number.isInteger(index) &&
|
|
10
|
+
index >= 0 &&
|
|
11
|
+
index < length &&
|
|
12
|
+
String(index) === key);
|
|
13
|
+
};
|
|
14
|
+
const jsonProperties = (value) => {
|
|
15
|
+
const prototype = Object.getPrototypeOf(value);
|
|
16
|
+
const validPrototype = Array.isArray(value)
|
|
17
|
+
? prototype === Array.prototype
|
|
18
|
+
: prototype === null || prototype === Object.prototype;
|
|
19
|
+
if (!validPrototype) {
|
|
20
|
+
return undefined;
|
|
21
|
+
}
|
|
22
|
+
const arrayLength = Array.isArray(value) ? value.length : undefined;
|
|
23
|
+
const keys = Reflect.ownKeys(value);
|
|
24
|
+
if (arrayLength !== undefined && keys.length !== arrayLength + 1) {
|
|
25
|
+
return undefined;
|
|
26
|
+
}
|
|
27
|
+
const properties = [];
|
|
28
|
+
for (const key of keys) {
|
|
29
|
+
if (typeof key !== "string") {
|
|
30
|
+
return undefined;
|
|
31
|
+
}
|
|
32
|
+
if (arrayLength !== undefined && key === "length") {
|
|
33
|
+
continue;
|
|
34
|
+
}
|
|
35
|
+
if (arrayLength !== undefined && !isArrayIndex(key, arrayLength)) {
|
|
36
|
+
return undefined;
|
|
37
|
+
}
|
|
38
|
+
const descriptor = Object.getOwnPropertyDescriptor(value, key);
|
|
39
|
+
if (descriptor === undefined ||
|
|
40
|
+
descriptor.enumerable !== true ||
|
|
41
|
+
descriptor.get !== undefined ||
|
|
42
|
+
descriptor.set !== undefined) {
|
|
43
|
+
return undefined;
|
|
44
|
+
}
|
|
45
|
+
properties.push(descriptor);
|
|
46
|
+
}
|
|
47
|
+
return properties;
|
|
48
|
+
};
|
|
49
|
+
const inspectRuntimeJsonObject = (value) => {
|
|
50
|
+
if (value === null || typeof value !== "object" || Array.isArray(value)) {
|
|
51
|
+
return false;
|
|
52
|
+
}
|
|
53
|
+
const ancestors = new WeakSet();
|
|
54
|
+
const frames = [{ phase: "enter", value, depth: 0 }];
|
|
55
|
+
while (frames.length > 0) {
|
|
56
|
+
const frame = frames.pop();
|
|
57
|
+
if (frame === undefined) {
|
|
58
|
+
break;
|
|
59
|
+
}
|
|
60
|
+
if (frame.phase === "leave") {
|
|
61
|
+
ancestors.delete(frame.value);
|
|
62
|
+
continue;
|
|
63
|
+
}
|
|
64
|
+
const candidate = frame.value;
|
|
65
|
+
if (frame.depth > RUNTIME_JSON_NESTING_DEPTH_MAX) {
|
|
66
|
+
return false;
|
|
67
|
+
}
|
|
68
|
+
if (isJsonPrimitive(candidate)) {
|
|
69
|
+
continue;
|
|
70
|
+
}
|
|
71
|
+
if (candidate === null ||
|
|
72
|
+
typeof candidate !== "object" ||
|
|
73
|
+
ancestors.has(candidate)) {
|
|
74
|
+
return false;
|
|
75
|
+
}
|
|
76
|
+
const properties = jsonProperties(candidate);
|
|
77
|
+
if (properties === undefined) {
|
|
78
|
+
return false;
|
|
79
|
+
}
|
|
80
|
+
ancestors.add(candidate);
|
|
81
|
+
frames.push({ phase: "leave", value: candidate });
|
|
82
|
+
for (const property of properties) {
|
|
83
|
+
frames.push({
|
|
84
|
+
phase: "enter",
|
|
85
|
+
value: property.value,
|
|
86
|
+
depth: frame.depth + 1,
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
return true;
|
|
91
|
+
};
|
|
92
|
+
/** Validate without invoking getters or recursing on the JavaScript call stack. */
|
|
93
|
+
export const isRuntimeJsonObject = (value) => {
|
|
94
|
+
try {
|
|
95
|
+
return inspectRuntimeJsonObject(value);
|
|
96
|
+
}
|
|
97
|
+
catch {
|
|
98
|
+
// A revoked proxy or a throwing reflection trap is not inspectable JSON.
|
|
99
|
+
return false;
|
|
100
|
+
}
|
|
101
|
+
};
|
package/dist/transport.d.ts
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* neither exceeds the repo's 1000-line clean-code budget).
|
|
7
7
|
*
|
|
8
8
|
* The P2 runaway dampers (default idempotency key, 429 backoff, forceRefresh
|
|
9
|
-
* throttle —
|
|
9
|
+
* throttle — the 2026-08 Gem runtime cost-safety audit) live inline in
|
|
10
10
|
* `invokeAppRuntime` here, composing the pure helpers from `./dampers`.
|
|
11
11
|
*
|
|
12
12
|
* Imports the shared URL/error primitives from `./runtime.js` and the
|
|
@@ -15,29 +15,30 @@
|
|
|
15
15
|
* for by exporting four internal helpers from it. Every edge here points at a
|
|
16
16
|
* module that imports nothing back.
|
|
17
17
|
*/
|
|
18
|
-
import {
|
|
19
|
-
import type {
|
|
18
|
+
import type { ForceRefreshThrottle, ResolvedDamperConfig } from "./dampers.js";
|
|
19
|
+
import type { RuntimeJsonObject } from "./transport-json.js";
|
|
20
|
+
import type { CreateUruAppRuntimeClientOptions, UruAppRuntimeCapabilityType, UruAppRuntimeExecutionStatus, UruAppRuntimeInvocationOptions, UruAppRuntimeInvocationResponse, UruResultDecoder } from "./types.js";
|
|
20
21
|
/** Per-client damper state: the resolved config plus the forceRefresh throttle. */
|
|
21
22
|
export interface DamperRuntime {
|
|
22
23
|
readonly config: ResolvedDamperConfig;
|
|
23
24
|
readonly throttle: ForceRefreshThrottle;
|
|
24
25
|
}
|
|
25
|
-
interface AppRuntimeInvocationHttpResponse
|
|
26
|
+
interface AppRuntimeInvocationHttpResponse {
|
|
26
27
|
ok: boolean;
|
|
27
28
|
status: string;
|
|
28
29
|
state: string;
|
|
29
30
|
deploymentId: string;
|
|
30
31
|
capabilityType: string;
|
|
31
32
|
capabilityName: string;
|
|
32
|
-
result?:
|
|
33
|
+
result?: unknown;
|
|
33
34
|
executionId?: string | null;
|
|
34
35
|
pending: boolean;
|
|
35
|
-
diagnostics?:
|
|
36
|
+
diagnostics?: RuntimeJsonObject;
|
|
36
37
|
}
|
|
37
|
-
interface AppRuntimeExecutionHttpResponse
|
|
38
|
+
interface AppRuntimeExecutionHttpResponse {
|
|
38
39
|
success?: boolean;
|
|
39
40
|
pending?: boolean;
|
|
40
|
-
result?:
|
|
41
|
+
result?: unknown;
|
|
41
42
|
error?: string | null;
|
|
42
43
|
state?: string;
|
|
43
44
|
status?: string | null;
|
|
@@ -49,10 +50,10 @@ interface AppRuntimeExecutionHttpResponse<TResult> {
|
|
|
49
50
|
executorKind?: string | null;
|
|
50
51
|
}
|
|
51
52
|
/** Map the owned camelCase HTTP envelope without copying unknown fields. */
|
|
52
|
-
export declare
|
|
53
|
+
export declare const appRuntimeInvocationResponseFromHttp: (value: unknown, decodeResult?: UruResultDecoder<unknown>) => AppRuntimeInvocationHttpResponse;
|
|
53
54
|
/** Map the owned camelCase job-status envelope without copying unknown fields. */
|
|
54
|
-
export declare
|
|
55
|
-
export declare
|
|
56
|
-
export declare
|
|
57
|
-
export declare
|
|
55
|
+
export declare const appRuntimeExecutionStatusFromHttp: (value: unknown, decodeResult?: UruResultDecoder<unknown>) => AppRuntimeExecutionHttpResponse;
|
|
56
|
+
export declare const invokeAppRuntime: (options: CreateUruAppRuntimeClientOptions, damper: DamperRuntime, capabilityType: UruAppRuntimeCapabilityType, name: string, input?: unknown, invocationOptions?: UruAppRuntimeInvocationOptions) => Promise<UruAppRuntimeInvocationResponse>;
|
|
57
|
+
export declare const getAppRuntimeJobStatus: (options: CreateUruAppRuntimeClientOptions, executionId: string, invocationOptions?: UruAppRuntimeInvocationOptions) => Promise<UruAppRuntimeExecutionStatus>;
|
|
58
|
+
export declare const cancelAppRuntimeJob: (options: CreateUruAppRuntimeClientOptions, executionId: string, invocationOptions?: UruAppRuntimeInvocationOptions) => Promise<UruAppRuntimeInvocationResponse>;
|
|
58
59
|
export {};
|