@uru-intelligence/app 2.1.3 → 2.1.5

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 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
  *
@@ -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,110 @@ 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
+ "job_provider_gateway_unavailable",
66
+ "job_machine_admission_invalid",
67
+ "job_runtime_image_base_unavailable",
68
+ "job_runtime_image_pin_unavailable",
69
+ "job_runtime_image_pin_mismatch",
70
+ "job_machine_image_mismatch",
71
+ "job_machine_capacity_unavailable",
72
+ "job_machine_app_unavailable",
73
+ "job_machine_network_unavailable",
74
+ "job_machine_proxy_unavailable",
75
+ "job_machine_revocation_state_unavailable",
76
+ "job_runtime_image_delivery_failed",
77
+ "job_machine_isolation_unavailable",
78
+ "job_secret_environment_invalid",
79
+ "job_secret_environment_incomplete",
80
+ "job_machine_lease_expired",
81
+ "job_machine_request_failed",
82
+ "job_machine_list_invalid",
83
+ "job_machine_identity_ambiguous",
84
+ "job_machine_identity_mismatch",
85
+ "job_machine_launch_fence_lost",
86
+ "execution_failed",
87
+ "execution_outcome_unknown",
88
+ "historical_result_unavailable",
89
+ "job_canceled",
90
+ "job_cleanup_failed",
91
+ "job_completion_not_accepted",
92
+ "job_handler_failed",
93
+ "job_hard_deadline",
94
+ "job_machine_start_failed",
95
+ "job_machine_stopped",
96
+ "job_output_invalid",
97
+ "job_prepare_failed",
98
+ "job_report_failed",
99
+ "job_revoked",
100
+ "job_runtime_failed",
101
+ "legacy_tool_contract_disabled",
102
+ "program_job_attach_rejected",
103
+ "program_job_capacity_exceeded",
104
+ "program_job_owner_missing",
105
+ "program_job_spending_check_failed",
106
+ "program_job_spending_limit",
107
+ "provider_credential_rejected",
108
+ "provider_failed",
109
+ "provider_invalid",
110
+ "provider_not_connected",
111
+ "provider_rate_limited",
112
+ "provider_rejected",
113
+ "provider_required",
114
+ "provider_timeout",
115
+ "provider_transport_failed",
116
+ "provider_unavailable",
117
+ "public_tool_budget_limited",
118
+ "public_tool_budget_unavailable",
119
+ "runtime_capability_unsupported",
120
+ "runtime_unavailable",
121
+ "tool_execution_failed",
122
+ "tool_timeout",
123
+ "tool_transport_failed",
124
+ "usage_limit_reached",
125
+ "usage_limit_unavailable",
126
+ ]);
127
+ 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
128
  const isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
25
129
  const httpRecord = (value, label) => {
26
130
  if (!isRecord(value)) {
@@ -55,6 +159,64 @@ const optionalNullableNumber = (value) => value === null || (typeof value === "n
55
159
  ? value
56
160
  : undefined;
57
161
  const optionalBoolean = (value) => typeof value === "boolean" ? value : undefined;
162
+ const safeRecordValue = (record, field) => {
163
+ if (record === null)
164
+ return undefined;
165
+ try {
166
+ return record[field];
167
+ }
168
+ catch {
169
+ return undefined;
170
+ }
171
+ };
172
+ const optionalApprovedFailureCode = (value) => {
173
+ if (value === null)
174
+ return null;
175
+ return typeof value === "string" && SAFE_RUNTIME_FAILURE_CODES.has(value)
176
+ ? value
177
+ : undefined;
178
+ };
179
+ const optionalRuntimeUuid = (value) => {
180
+ if (typeof value !== "string")
181
+ return undefined;
182
+ const normalized = value.trim();
183
+ return RUNTIME_UUID.test(normalized) ? normalized : undefined;
184
+ };
185
+ const safeExecutionDiagnostics = (value) => {
186
+ if (!isRecord(value))
187
+ return undefined;
188
+ const childRuntimeRunId = optionalRuntimeUuid(safeRecordValue(value, "childRuntimeRunId"));
189
+ const platformCode = optionalApprovedFailureCode(safeRecordValue(value, "platformCode")) ??
190
+ optionalApprovedFailureCode(safeRecordValue(value, "code")) ?? undefined;
191
+ if (childRuntimeRunId === undefined && platformCode === undefined) {
192
+ return undefined;
193
+ }
194
+ return {
195
+ ...(childRuntimeRunId === undefined ? {} : { childRuntimeRunId }),
196
+ ...(platformCode === undefined ? {} : { platformCode }),
197
+ };
198
+ };
199
+ const safeExecutionDiagnosticsFromHttp = (body) => {
200
+ const details = safeRecordValue(body, "details");
201
+ const nested = safeExecutionDiagnostics(safeRecordValue(isRecord(details) ? details : null, "diagnostics")) ?? safeExecutionDiagnostics(details);
202
+ const direct = safeExecutionDiagnostics(safeRecordValue(body, "diagnostics"));
203
+ if (nested === undefined)
204
+ return direct;
205
+ if (direct === undefined)
206
+ return nested;
207
+ return {
208
+ ...(nested.childRuntimeRunId === undefined
209
+ ? direct.childRuntimeRunId === undefined
210
+ ? {}
211
+ : { childRuntimeRunId: direct.childRuntimeRunId }
212
+ : { childRuntimeRunId: nested.childRuntimeRunId }),
213
+ ...(nested.platformCode === undefined
214
+ ? direct.platformCode === undefined
215
+ ? {}
216
+ : { platformCode: direct.platformCode }
217
+ : { platformCode: nested.platformCode }),
218
+ };
219
+ };
58
220
  /** Map the owned camelCase HTTP envelope without copying unknown fields. */
59
221
  export const appRuntimeInvocationResponseFromHttp = (value, decodeResult) => {
60
222
  const label = "app runtime invocation";
@@ -141,6 +303,14 @@ export const appRuntimeExecutionStatusFromHttp = (value, decodeResult) => {
141
303
  if (executorKind !== undefined) {
142
304
  output.executorKind = executorKind;
143
305
  }
306
+ const code = optionalApprovedFailureCode(body.code);
307
+ if (code !== undefined) {
308
+ output.code = code;
309
+ }
310
+ const diagnostics = safeExecutionDiagnosticsFromHttp(body);
311
+ if (diagnostics !== undefined) {
312
+ output.diagnostics = diagnostics;
313
+ }
144
314
  return output;
145
315
  };
146
316
  const routeSegmentForCapabilityType = (capabilityType) => {
@@ -505,6 +675,10 @@ const normalizedExecutionStatus = (status, state) => ({
505
675
  ...(status.executorKind === undefined
506
676
  ? {}
507
677
  : { executorKind: status.executorKind }),
678
+ ...(status.code === undefined ? {} : { code: status.code }),
679
+ ...(status.diagnostics === undefined
680
+ ? {}
681
+ : { diagnostics: status.diagnostics }),
508
682
  ...(status.pending === undefined ? {} : { pending: status.pending }),
509
683
  ...(Object.hasOwn(status, "result") ? { result: status.result } : {}),
510
684
  ...(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 {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uru-intelligence/app",
3
- "version": "2.1.3",
3
+ "version": "2.1.5",
4
4
  "private": false,
5
5
  "description": "Runtime client for Uru Gems: capability calls, Datasets, jobs and secrets",
6
6
  "keywords": [