@uru-intelligence/app 2.1.3 → 2.1.4
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.d.ts +1 -1
- package/dist/transport.d.ts +3 -1
- package/dist/transport.js +153 -0
- package/dist/types.d.ts +9 -0
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -13,7 +13,7 @@ import type { CreateUruAppRuntimeClientOptions, CreateUruServerContextOptions, U
|
|
|
13
13
|
export { UruAppRuntimeError } from "./errors.js";
|
|
14
14
|
export { URU_UPLOAD_MAX_BYTES, createUploadsContext as createUruUploadsContext } from "./uploads.js";
|
|
15
15
|
export type { UruRunawayDamperOptions } from "./dampers.js";
|
|
16
|
-
export type { CreateUruAppRuntimeClientOptions, CreateUruServerContextOptions, UruAppRuntimeCapabilityType, UruAppRuntimeClient, UruAppRuntimeEvent, UruAppRuntimeEventType, UruAppRuntimeExecutionStatus, UruAppRuntimeInvocationOptions, UruAppRuntimeInvocationResponse, UruAppRuntimeState, UruDecodedInvocationOptions, UruResultDecoder, UruDatasetMutationResult, UruDatasetQuery, UruDatasetRow, UruDatasetRowsResult, UruDatasetSortClause, UruDatasetSqlWriteOptions, UruDatasetWhereClause, UruDatasetWhereOperator, UruDatasetsContext, UruFilesContext, UruFileMetadata, UruFileContent, UruFileOutput, UruFileOutputSummary, UruJobProgress, UruJobCheckpoint, UruProviderRuntimeEnvironment, UruServerContext, UruUploadGrant, UruUploadOutcome, UruUploadResult, UruUploadsContext, } from "./types.js";
|
|
16
|
+
export type { CreateUruAppRuntimeClientOptions, CreateUruServerContextOptions, UruAppRuntimeCapabilityType, UruAppRuntimeClient, UruAppRuntimeEvent, UruAppRuntimeEventType, UruAppRuntimeExecutionDiagnostics, UruAppRuntimeExecutionStatus, UruAppRuntimeInvocationOptions, UruAppRuntimeInvocationResponse, UruAppRuntimeState, UruDecodedInvocationOptions, UruResultDecoder, UruDatasetMutationResult, UruDatasetQuery, UruDatasetRow, UruDatasetRowsResult, UruDatasetSortClause, UruDatasetSqlWriteOptions, UruDatasetWhereClause, UruDatasetWhereOperator, UruDatasetsContext, UruFilesContext, UruFileMetadata, UruFileContent, UruFileOutput, UruFileOutputSummary, UruJobProgress, UruJobCheckpoint, UruProviderRuntimeEnvironment, UruServerContext, UruUploadGrant, UruUploadOutcome, UruUploadResult, UruUploadsContext, } from "./types.js";
|
|
17
17
|
/**
|
|
18
18
|
* Build a capability-invocation client against a Uru app runtime.
|
|
19
19
|
*
|
package/dist/transport.d.ts
CHANGED
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
*/
|
|
18
18
|
import type { ForceRefreshThrottle, ResolvedDamperConfig } from "./dampers.js";
|
|
19
19
|
import type { RuntimeJsonObject } from "./transport-json.js";
|
|
20
|
-
import type { CreateUruAppRuntimeClientOptions, UruAppRuntimeCapabilityType, UruAppRuntimeExecutionStatus, UruAppRuntimeInvocationOptions, UruAppRuntimeInvocationResponse, UruResultDecoder } from "./types.js";
|
|
20
|
+
import type { CreateUruAppRuntimeClientOptions, UruAppRuntimeCapabilityType, UruAppRuntimeExecutionDiagnostics, UruAppRuntimeExecutionStatus, UruAppRuntimeInvocationOptions, UruAppRuntimeInvocationResponse, UruResultDecoder } from "./types.js";
|
|
21
21
|
/** Per-client damper state: the resolved config plus the forceRefresh throttle. */
|
|
22
22
|
export interface DamperRuntime {
|
|
23
23
|
readonly config: ResolvedDamperConfig;
|
|
@@ -48,6 +48,8 @@ interface AppRuntimeExecutionHttpResponse {
|
|
|
48
48
|
cacheStatus?: string | null;
|
|
49
49
|
executor?: string | null;
|
|
50
50
|
executorKind?: string | null;
|
|
51
|
+
code?: string | null;
|
|
52
|
+
diagnostics?: UruAppRuntimeExecutionDiagnostics;
|
|
51
53
|
}
|
|
52
54
|
/** Map the owned camelCase HTTP envelope without copying unknown fields. */
|
|
53
55
|
export declare const appRuntimeInvocationResponseFromHttp: (value: unknown, decodeResult?: UruResultDecoder<unknown>) => AppRuntimeInvocationHttpResponse;
|
package/dist/transport.js
CHANGED
|
@@ -21,6 +21,89 @@ import { resolveHeaders, resolveRuntimeFetch, runtimeBasePath, trimTrailingSlash
|
|
|
21
21
|
import { abortReason, awaitWithAbort, readRuntimeResponseBody, validateRuntimeInvocationOptions, withRuntimeRequestSignal, } from "./transport-deadline.js";
|
|
22
22
|
import { fetchInvocation } from "./transport-invocation.js";
|
|
23
23
|
import { isRuntimeJsonObject } from "./transport-json.js";
|
|
24
|
+
/**
|
|
25
|
+
* Only platform failure codes from the public Gem failure contract may cross
|
|
26
|
+
* this boundary. Provider-defined details stay inside the HTTP response.
|
|
27
|
+
*/
|
|
28
|
+
const SAFE_RUNTIME_FAILURE_CODES = new Set([
|
|
29
|
+
"artifact_tool_caller_identity_required",
|
|
30
|
+
"invalid_wrapper_tool_name",
|
|
31
|
+
"runtime_identity_missing",
|
|
32
|
+
"policy_receipt_handoff_invalid",
|
|
33
|
+
"mcp_proxy_not_configured",
|
|
34
|
+
"missing_api_key",
|
|
35
|
+
"dataset_frozen_gem_release_unverified",
|
|
36
|
+
"dataset_frozen_gem_compatibility_disabled",
|
|
37
|
+
"timeout",
|
|
38
|
+
"transport_error",
|
|
39
|
+
"connection_unavailable",
|
|
40
|
+
"artifact_tool_receipt_unavailable",
|
|
41
|
+
"artifact_tool_attempt_unavailable",
|
|
42
|
+
"tool_result_content_unavailable",
|
|
43
|
+
"tool_parameters_content_unavailable",
|
|
44
|
+
"artifact_tool_refresh_failed",
|
|
45
|
+
"tool_admission_unavailable",
|
|
46
|
+
"tool_gateway_denied",
|
|
47
|
+
"app_runtime_failed",
|
|
48
|
+
"artifact_proxy_failed",
|
|
49
|
+
"artifact_rate_limited",
|
|
50
|
+
"artifact_tool_access_invalid",
|
|
51
|
+
"artifact_tool_admission_identity_invalid",
|
|
52
|
+
"artifact_tool_admission_limited",
|
|
53
|
+
"artifact_tool_admission_unavailable",
|
|
54
|
+
"artifact_tool_authority_identity_invalid",
|
|
55
|
+
"artifact_tool_binding_identity_mismatch",
|
|
56
|
+
"artifact_tool_binding_not_visible",
|
|
57
|
+
"artifact_tool_cache_refresh_in_progress",
|
|
58
|
+
"artifact_tool_circuit_open",
|
|
59
|
+
"artifact_tool_execution_cancelled",
|
|
60
|
+
"artifact_tool_execution_failed",
|
|
61
|
+
"artifact_tool_execution_pending",
|
|
62
|
+
"artifact_tool_pre_dispatch_failed",
|
|
63
|
+
"artifact_tool_provider_outcome_unknown",
|
|
64
|
+
"artifact_tool_terminalization_unavailable",
|
|
65
|
+
"execution_failed",
|
|
66
|
+
"execution_outcome_unknown",
|
|
67
|
+
"historical_result_unavailable",
|
|
68
|
+
"job_canceled",
|
|
69
|
+
"job_cleanup_failed",
|
|
70
|
+
"job_completion_not_accepted",
|
|
71
|
+
"job_handler_failed",
|
|
72
|
+
"job_hard_deadline",
|
|
73
|
+
"job_machine_start_failed",
|
|
74
|
+
"job_machine_stopped",
|
|
75
|
+
"job_output_invalid",
|
|
76
|
+
"job_prepare_failed",
|
|
77
|
+
"job_report_failed",
|
|
78
|
+
"job_revoked",
|
|
79
|
+
"job_runtime_failed",
|
|
80
|
+
"legacy_tool_contract_disabled",
|
|
81
|
+
"program_job_attach_rejected",
|
|
82
|
+
"program_job_capacity_exceeded",
|
|
83
|
+
"program_job_owner_missing",
|
|
84
|
+
"program_job_spending_check_failed",
|
|
85
|
+
"program_job_spending_limit",
|
|
86
|
+
"provider_credential_rejected",
|
|
87
|
+
"provider_failed",
|
|
88
|
+
"provider_invalid",
|
|
89
|
+
"provider_not_connected",
|
|
90
|
+
"provider_rate_limited",
|
|
91
|
+
"provider_rejected",
|
|
92
|
+
"provider_required",
|
|
93
|
+
"provider_timeout",
|
|
94
|
+
"provider_transport_failed",
|
|
95
|
+
"provider_unavailable",
|
|
96
|
+
"public_tool_budget_limited",
|
|
97
|
+
"public_tool_budget_unavailable",
|
|
98
|
+
"runtime_capability_unsupported",
|
|
99
|
+
"runtime_unavailable",
|
|
100
|
+
"tool_execution_failed",
|
|
101
|
+
"tool_timeout",
|
|
102
|
+
"tool_transport_failed",
|
|
103
|
+
"usage_limit_reached",
|
|
104
|
+
"usage_limit_unavailable",
|
|
105
|
+
]);
|
|
106
|
+
const RUNTIME_UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/iu;
|
|
24
107
|
const isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
25
108
|
const httpRecord = (value, label) => {
|
|
26
109
|
if (!isRecord(value)) {
|
|
@@ -55,6 +138,64 @@ const optionalNullableNumber = (value) => value === null || (typeof value === "n
|
|
|
55
138
|
? value
|
|
56
139
|
: undefined;
|
|
57
140
|
const optionalBoolean = (value) => typeof value === "boolean" ? value : undefined;
|
|
141
|
+
const safeRecordValue = (record, field) => {
|
|
142
|
+
if (record === null)
|
|
143
|
+
return undefined;
|
|
144
|
+
try {
|
|
145
|
+
return record[field];
|
|
146
|
+
}
|
|
147
|
+
catch {
|
|
148
|
+
return undefined;
|
|
149
|
+
}
|
|
150
|
+
};
|
|
151
|
+
const optionalApprovedFailureCode = (value) => {
|
|
152
|
+
if (value === null)
|
|
153
|
+
return null;
|
|
154
|
+
return typeof value === "string" && SAFE_RUNTIME_FAILURE_CODES.has(value)
|
|
155
|
+
? value
|
|
156
|
+
: undefined;
|
|
157
|
+
};
|
|
158
|
+
const optionalRuntimeUuid = (value) => {
|
|
159
|
+
if (typeof value !== "string")
|
|
160
|
+
return undefined;
|
|
161
|
+
const normalized = value.trim();
|
|
162
|
+
return RUNTIME_UUID.test(normalized) ? normalized : undefined;
|
|
163
|
+
};
|
|
164
|
+
const safeExecutionDiagnostics = (value) => {
|
|
165
|
+
if (!isRecord(value))
|
|
166
|
+
return undefined;
|
|
167
|
+
const childRuntimeRunId = optionalRuntimeUuid(safeRecordValue(value, "childRuntimeRunId"));
|
|
168
|
+
const platformCode = optionalApprovedFailureCode(safeRecordValue(value, "platformCode")) ??
|
|
169
|
+
optionalApprovedFailureCode(safeRecordValue(value, "code")) ?? undefined;
|
|
170
|
+
if (childRuntimeRunId === undefined && platformCode === undefined) {
|
|
171
|
+
return undefined;
|
|
172
|
+
}
|
|
173
|
+
return {
|
|
174
|
+
...(childRuntimeRunId === undefined ? {} : { childRuntimeRunId }),
|
|
175
|
+
...(platformCode === undefined ? {} : { platformCode }),
|
|
176
|
+
};
|
|
177
|
+
};
|
|
178
|
+
const safeExecutionDiagnosticsFromHttp = (body) => {
|
|
179
|
+
const details = safeRecordValue(body, "details");
|
|
180
|
+
const nested = safeExecutionDiagnostics(safeRecordValue(isRecord(details) ? details : null, "diagnostics")) ?? safeExecutionDiagnostics(details);
|
|
181
|
+
const direct = safeExecutionDiagnostics(safeRecordValue(body, "diagnostics"));
|
|
182
|
+
if (nested === undefined)
|
|
183
|
+
return direct;
|
|
184
|
+
if (direct === undefined)
|
|
185
|
+
return nested;
|
|
186
|
+
return {
|
|
187
|
+
...(nested.childRuntimeRunId === undefined
|
|
188
|
+
? direct.childRuntimeRunId === undefined
|
|
189
|
+
? {}
|
|
190
|
+
: { childRuntimeRunId: direct.childRuntimeRunId }
|
|
191
|
+
: { childRuntimeRunId: nested.childRuntimeRunId }),
|
|
192
|
+
...(nested.platformCode === undefined
|
|
193
|
+
? direct.platformCode === undefined
|
|
194
|
+
? {}
|
|
195
|
+
: { platformCode: direct.platformCode }
|
|
196
|
+
: { platformCode: nested.platformCode }),
|
|
197
|
+
};
|
|
198
|
+
};
|
|
58
199
|
/** Map the owned camelCase HTTP envelope without copying unknown fields. */
|
|
59
200
|
export const appRuntimeInvocationResponseFromHttp = (value, decodeResult) => {
|
|
60
201
|
const label = "app runtime invocation";
|
|
@@ -141,6 +282,14 @@ export const appRuntimeExecutionStatusFromHttp = (value, decodeResult) => {
|
|
|
141
282
|
if (executorKind !== undefined) {
|
|
142
283
|
output.executorKind = executorKind;
|
|
143
284
|
}
|
|
285
|
+
const code = optionalApprovedFailureCode(body.code);
|
|
286
|
+
if (code !== undefined) {
|
|
287
|
+
output.code = code;
|
|
288
|
+
}
|
|
289
|
+
const diagnostics = safeExecutionDiagnosticsFromHttp(body);
|
|
290
|
+
if (diagnostics !== undefined) {
|
|
291
|
+
output.diagnostics = diagnostics;
|
|
292
|
+
}
|
|
144
293
|
return output;
|
|
145
294
|
};
|
|
146
295
|
const routeSegmentForCapabilityType = (capabilityType) => {
|
|
@@ -505,6 +654,10 @@ const normalizedExecutionStatus = (status, state) => ({
|
|
|
505
654
|
...(status.executorKind === undefined
|
|
506
655
|
? {}
|
|
507
656
|
: { executorKind: status.executorKind }),
|
|
657
|
+
...(status.code === undefined ? {} : { code: status.code }),
|
|
658
|
+
...(status.diagnostics === undefined
|
|
659
|
+
? {}
|
|
660
|
+
: { diagnostics: status.diagnostics }),
|
|
508
661
|
...(status.pending === undefined ? {} : { pending: status.pending }),
|
|
509
662
|
...(Object.hasOwn(status, "result") ? { result: status.result } : {}),
|
|
510
663
|
...(status.retryAfterSeconds === undefined
|
package/dist/types.d.ts
CHANGED
|
@@ -74,6 +74,11 @@ export interface UruAppRuntimeInvocationResponse<TResult = unknown> {
|
|
|
74
74
|
pending: boolean;
|
|
75
75
|
diagnostics: RuntimeJsonObject;
|
|
76
76
|
}
|
|
77
|
+
/** Safe fields retained from a failed job's platform-owned diagnostics. */
|
|
78
|
+
export interface UruAppRuntimeExecutionDiagnostics {
|
|
79
|
+
childRuntimeRunId?: string;
|
|
80
|
+
platformCode?: string;
|
|
81
|
+
}
|
|
77
82
|
/** The normalized envelope a job-status poll resolves to. */
|
|
78
83
|
export interface UruAppRuntimeExecutionStatus<TResult = unknown> {
|
|
79
84
|
success?: boolean;
|
|
@@ -88,6 +93,10 @@ export interface UruAppRuntimeExecutionStatus<TResult = unknown> {
|
|
|
88
93
|
cacheStatus?: string | null;
|
|
89
94
|
executor?: string | null;
|
|
90
95
|
executorKind?: string | null;
|
|
96
|
+
/** A platform-owned failure code, when the server approved it. */
|
|
97
|
+
code?: string | null;
|
|
98
|
+
/** Safe child-run diagnostics; provider details are never copied here. */
|
|
99
|
+
diagnostics?: UruAppRuntimeExecutionDiagnostics;
|
|
91
100
|
}
|
|
92
101
|
/** Input is untrusted until the transport validates it as a JSON object. */
|
|
93
102
|
export interface UruCapabilityInvoker {
|