@noodleseed/one 0.164.0 → 0.166.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.
Files changed (116) hide show
  1. package/dist/commands/deploy-status-ops.d.ts +2 -0
  2. package/dist/commands/deploy-status-ops.d.ts.map +1 -1
  3. package/dist/commands/deploy-status-ops.js +11 -0
  4. package/dist/commands/deploy-status-ops.js.map +1 -1
  5. package/dist/commands/solutions-coordination.d.ts +5 -0
  6. package/dist/commands/solutions-coordination.d.ts.map +1 -0
  7. package/dist/commands/solutions-coordination.js +94 -0
  8. package/dist/commands/solutions-coordination.js.map +1 -0
  9. package/dist/commands/solutions-ops.d.ts.map +1 -1
  10. package/dist/commands/solutions-ops.js +8 -4
  11. package/dist/commands/solutions-ops.js.map +1 -1
  12. package/node_modules/@noodle-borg/agent-kit/dist/curated/error-fixes.js +2 -0
  13. package/node_modules/@noodle-borg/agent-kit/dist/generated/example-files.js +3 -3
  14. package/node_modules/@noodle-borg/agent-kit/dist/generated/surface.js +2 -0
  15. package/node_modules/@noodle-borg/agent-kit/dist/skill-authoring-refs.js +4 -1
  16. package/node_modules/@noodle-borg/agent-kit/package.json +1 -1
  17. package/node_modules/@noodle-borg/assistant-gateway/dist/embed-store.d.ts +4 -0
  18. package/node_modules/@noodle-borg/assistant-gateway/dist/in-memory-embed-store.d.ts +4 -0
  19. package/node_modules/@noodle-borg/assistant-gateway/dist/in-memory-embed-store.js +6 -2
  20. package/node_modules/@noodle-borg/authoring/dist/config.d.ts +8 -2
  21. package/node_modules/@noodle-borg/authoring/dist/config.js +28 -1
  22. package/node_modules/@noodle-borg/authoring/dist/connectors.d.ts +37 -0
  23. package/node_modules/@noodle-borg/authoring/dist/connectors.js +4 -0
  24. package/node_modules/@noodle-borg/authoring/dist/index.d.ts +1 -1
  25. package/node_modules/@noodle-borg/authoring/dist/server.js +1 -0
  26. package/node_modules/@noodle-borg/cli-catalog/dist/catalog-data-solution-flags.js +83 -0
  27. package/node_modules/@noodle-borg/cli-catalog/dist/catalog-data-solutions.js +70 -92
  28. package/node_modules/@noodle-borg/compiler/dist/artifact/operation-ref.d.ts +2 -0
  29. package/node_modules/@noodle-borg/compiler/dist/artifact/version.d.ts +4 -1
  30. package/node_modules/@noodle-borg/compiler/dist/artifact/version.js +4 -1
  31. package/node_modules/@noodle-borg/compiler/dist/catalog/types.d.ts +7 -0
  32. package/node_modules/@noodle-borg/compiler/dist/errors.d.ts +1 -1
  33. package/node_modules/@noodle-borg/compiler/dist/fulfilment-emit.js +15 -2
  34. package/node_modules/@noodle-borg/compiler/dist/nested-operations.js +71 -0
  35. package/node_modules/@noodle-borg/compute/dist/code-connector.js +14 -2
  36. package/node_modules/@noodle-borg/compute/dist/deterministic-helpers.js +138 -0
  37. package/node_modules/@noodle-borg/compute/dist/quickjs-engine.js +48 -0
  38. package/node_modules/@noodle-borg/compute/dist/sandbox-eval.js +39 -5
  39. package/node_modules/@noodle-borg/compute/dist/worker-entry.js +7 -0
  40. package/node_modules/@noodle-borg/compute/dist/worker-pool.js +14 -3
  41. package/node_modules/@noodle-borg/connector-defs/dist/compile-http.js +31 -2
  42. package/node_modules/@noodle-borg/connector-defs/dist/compile.d.ts +1 -1
  43. package/node_modules/@noodle-borg/connector-defs/dist/compile.js +20 -0
  44. package/node_modules/@noodle-borg/connector-defs/dist/schema.d.ts +84 -0
  45. package/node_modules/@noodle-borg/connector-defs/dist/schema.js +44 -1
  46. package/node_modules/@noodle-borg/connector-http/dist/http-connector.d.ts +7 -0
  47. package/node_modules/@noodle-borg/connector-http/dist/http-connector.js +34 -6
  48. package/node_modules/@noodle-borg/connector-http/dist/http-response.d.ts +8 -1
  49. package/node_modules/@noodle-borg/connector-http/dist/http-response.js +19 -10
  50. package/node_modules/@noodle-borg/connector-http/dist/index.d.ts +1 -1
  51. package/node_modules/@noodle-borg/module/dist/customer-auth-access.d.ts +7 -0
  52. package/node_modules/@noodle-borg/module/dist/customer-auth-access.js +6 -0
  53. package/node_modules/@noodle-borg/module/dist/index.d.ts +1 -0
  54. package/node_modules/@noodle-borg/module/dist/index.js +1 -0
  55. package/node_modules/@noodle-borg/runtime/dist/connector/types.d.ts +7 -1
  56. package/node_modules/@noodle-borg/runtime/dist/connector-snapshot.js +8 -0
  57. package/node_modules/@noodle-borg/runtime/dist/execute.d.ts +2 -0
  58. package/node_modules/@noodle-borg/runtime/dist/index.d.ts +1 -0
  59. package/node_modules/@noodle-borg/runtime/dist/nested-operation-host.js +25 -0
  60. package/node_modules/@noodle-borg/runtime/dist/operation-coordination-execution.js +50 -0
  61. package/node_modules/@noodle-borg/runtime/dist/operation-coordination.d.ts +34 -0
  62. package/node_modules/@noodle-borg/runtime/dist/operation-evidence.d.ts +4 -0
  63. package/node_modules/@noodle-borg/runtime/dist/operation-execution.js +173 -94
  64. package/node_modules/@noodle-borg/service/dist/application-activity.js +152 -18
  65. package/node_modules/@noodle-borg/service/dist/application-runtime-target.js +15 -2
  66. package/node_modules/@noodle-borg/service/dist/business-information/definition-resolver.js +19 -0
  67. package/node_modules/@noodle-borg/service/dist/business-information/in-memory-store.js +1 -1
  68. package/node_modules/@noodle-borg/service/dist/business-information/managed-solution-blueprints.js +7 -0
  69. package/node_modules/@noodle-borg/service/dist/business-information/managed-solution-executable.js +11 -1
  70. package/node_modules/@noodle-borg/service/dist/business-information/model.js +2 -2
  71. package/node_modules/@noodle-borg/service/dist/business-information/portable.js +1 -1
  72. package/node_modules/@noodle-borg/service/dist/business-information/profiles.js +37 -1
  73. package/node_modules/@noodle-borg/service/dist/credential-binding-index.js +19 -1
  74. package/node_modules/@noodle-borg/service/dist/customer-auth-audience-binding.js +16 -5
  75. package/node_modules/@noodle-borg/service/dist/deployment-authentication.js +19 -0
  76. package/node_modules/@noodle-borg/service/dist/deployment-execution.js +1 -1
  77. package/node_modules/@noodle-borg/service/dist/deployment-record-version.js +31 -0
  78. package/node_modules/@noodle-borg/service/dist/developer-mcp/inspection.js +15 -1
  79. package/node_modules/@noodle-borg/service/dist/operation-coordination.js +185 -0
  80. package/node_modules/@noodle-borg/service/dist/operation-evidence.js +3 -1
  81. package/node_modules/@noodle-borg/service/dist/registry-access.js +18 -3
  82. package/node_modules/@noodle-borg/service/dist/registry-compile.js +42 -1
  83. package/node_modules/@noodle-borg/service/dist/registry-deploy-transaction.js +15 -0
  84. package/node_modules/@noodle-borg/service/dist/registry-rollback.js +2 -0
  85. package/node_modules/@noodle-borg/service/dist/registry-state.d.ts +1 -0
  86. package/node_modules/@noodle-borg/service/dist/registry-state.js +12 -5
  87. package/node_modules/@noodle-borg/service/dist/registry-status.js +3 -0
  88. package/node_modules/@noodle-borg/service/dist/registry-targets.js +8 -0
  89. package/node_modules/@noodle-borg/service/dist/registry-types.d.ts +1 -1
  90. package/node_modules/@noodle-borg/service/dist/registry.js +31 -36
  91. package/node_modules/@noodle-borg/service/dist/routes/access.js +5 -0
  92. package/node_modules/@noodle-borg/service/dist/routes/business-information-activity.js +48 -53
  93. package/node_modules/@noodle-borg/service/dist/routes/business-information-dispatch.js +2 -1
  94. package/node_modules/@noodle-borg/service/dist/routes/business-information-installation.js +51 -17
  95. package/node_modules/@noodle-borg/service/dist/routes/business-information-paths.js +6 -4
  96. package/node_modules/@noodle-borg/service/dist/routes/business-information-staff.js +4 -3
  97. package/node_modules/@noodle-borg/service/dist/routes/business-information.js +11 -6
  98. package/node_modules/@noodle-borg/service/dist/routes/deploy-public-embed.js +7 -2
  99. package/node_modules/@noodle-borg/service/dist/service.js +2 -1
  100. package/node_modules/@noodle-borg/service/dist/solution-installation-activation.js +58 -3
  101. package/node_modules/@noodle-borg/service/dist/store/in-memory.d.ts +1 -0
  102. package/node_modules/@noodle-borg/service/dist/store/in-memory.js +10 -3
  103. package/node_modules/@noodle-borg/service/dist/store/json-file.d.ts +1 -0
  104. package/node_modules/@noodle-borg/service/dist/store/json-file.js +10 -3
  105. package/node_modules/@noodle-borg/service/dist/store/records.js +4 -2
  106. package/node_modules/@noodle-borg/service/dist/store.d.ts +5 -1
  107. package/node_modules/@noodle-borg/service/package.json +1 -1
  108. package/node_modules/@noodle-borg/wire-contracts/dist/business-information.d.ts +52 -0
  109. package/node_modules/@noodle-borg/wire-contracts/dist/business-information.js +6 -0
  110. package/node_modules/@noodle-borg/wire-contracts/dist/control-plane.d.ts +23 -0
  111. package/node_modules/@noodle-borg/wire-contracts/dist/control-plane.js +34 -4
  112. package/node_modules/@noodle-borg/wire-contracts/dist/index.d.ts +1 -0
  113. package/node_modules/@noodle-borg/wire-contracts/dist/index.js +1 -0
  114. package/node_modules/@noodle-borg/wire-contracts/dist/operation-coordination.d.ts +59 -0
  115. package/node_modules/@noodle-borg/wire-contracts/dist/operation-coordination.js +51 -0
  116. package/package.json +2 -2
@@ -49,6 +49,12 @@ export interface HttpOperationFake {
49
49
  readonly response?: unknown;
50
50
  readonly pages?: readonly unknown[];
51
51
  }
52
+ /** Explicit application outcomes for selected provider rejections, never transport/auth failures. */
53
+ export interface HttpStatusResponse {
54
+ readonly responseType?: 'json' | 'text' | 'empty';
55
+ readonly mapResponse: (body: unknown, args: Readonly<Record<string, unknown>>) => Record<string, unknown>;
56
+ readonly evidence?: (body: unknown) => OperationEvidence;
57
+ }
52
58
  /**
53
59
  * A single HTTP operation. `GET`, `POST`, `PUT`, `PATCH`, and `DELETE` are supported. The `path` template is
54
60
  * filled from validated args
@@ -57,6 +63,7 @@ export interface HttpOperationFake {
57
63
  * declared output fields.
58
64
  */
59
65
  export interface HttpOperation {
66
+ readonly responses?: Readonly<Record<string, HttpStatusResponse>>;
60
67
  readonly evidence?: (json: unknown) => OperationEvidence;
61
68
  /** Compiler-derived requirement for mappings that consume the trusted operation identity. */
62
69
  readonly requiresExecution?: boolean;
@@ -1,7 +1,7 @@
1
1
  import { isCustomerEndpointRef, } from '@noodle-borg/compiler';
2
2
  import { ConnectorInvocationError, } from '@noodle-borg/runtime';
3
3
  import { customerRouteUnavailable, frozenCustomerEndpointRef, isWithinCustomerBase, resolveCustomerBase, sanitizedCustomerRouteError, } from './customer-route.js';
4
- import { fetchResponseWithResilience } from './http-response.js';
4
+ import { fetchResponseWithResilience, } from './http-response.js';
5
5
  import { applyProjection } from './projection.js';
6
6
  import { requestPayload, setOwnedHeader } from './request-encoding.js';
7
7
  import { assertPublicResolution, needsGuard } from './ssrf.js';
@@ -32,6 +32,8 @@ export class HttpConnector {
32
32
  this.id = config.id;
33
33
  this.version = config.version;
34
34
  this.#config = config;
35
+ for (const operation of Object.values(config.operations))
36
+ validateStatusResponses(operation);
35
37
  const customerRouted = isCustomerEndpointRef(config.baseUrl);
36
38
  this.#customerBase = customerRouted ? frozenCustomerEndpointRef(config.baseUrl) : undefined;
37
39
  const origins = customerRouted
@@ -115,9 +117,23 @@ export class HttpConnector {
115
117
  ...(call.signal === undefined ? {} : { signal: call.signal }),
116
118
  ...(payload !== undefined ? { body: payload } : {}),
117
119
  };
118
- const json = op.pagination === undefined
119
- ? await this.#fetchJsonWithResilience(url, op, init)
120
- : await this.#fetchPaginatedJson(op, call.args, base, init, customerBase, allowed);
120
+ const response = op.pagination === undefined
121
+ ? await this.#fetchResponseWithResilience(url, op, init)
122
+ : {
123
+ status: 200,
124
+ body: await this.#fetchPaginatedJson(op, call.args, base, init, customerBase, allowed),
125
+ };
126
+ const json = response.body;
127
+ const statusResponse = op.responses?.[String(response.status)];
128
+ if (statusResponse !== undefined) {
129
+ // Do not inherit a successful-response mapping or completion evidence for a provider rejection.
130
+ const output = this.#mapOutput({ ...op, mapResponse: statusResponse.mapResponse }, json, call.args);
131
+ const evidence = statusResponse.evidence?.(json) ?? { outcome: 'unknown' };
132
+ call.reportOutcome?.(evidence.outcome === 'rejected' || evidence.outcome === 'unknown'
133
+ ? evidence
134
+ : { outcome: 'unknown' });
135
+ return output;
136
+ }
121
137
  if (op.evidence)
122
138
  call.reportOutcome?.(op.evidence(json));
123
139
  return this.#mapOutput(op, json, call.args);
@@ -218,7 +234,7 @@ export class HttpConnector {
218
234
  return this.#collectPaginatedJson(op, args, async (_pageIndex, query) => {
219
235
  const url = this.#buildUrl(op, args, base, query);
220
236
  await this.#validateUrl(url, customerBase, allowed);
221
- return this.#fetchJsonWithResilience(url, op, init);
237
+ return (await this.#fetchResponseWithResilience(url, op, init)).body;
222
238
  });
223
239
  }
224
240
  #fakeJson(operation, op) {
@@ -301,7 +317,7 @@ export class HttpConnector {
301
317
  }
302
318
  return aggregate(pages, items, true, 'max_pages');
303
319
  }
304
- #fetchJsonWithResilience(url, op, init) {
320
+ #fetchResponseWithResilience(url, op, init) {
305
321
  return fetchResponseWithResilience(url, op, init, {
306
322
  ...(this.#config.maxBytes === undefined ? {} : { maxBytes: this.#config.maxBytes }),
307
323
  ...(this.#config.timeoutMs === undefined ? {} : { timeoutMs: this.#config.timeoutMs }),
@@ -309,6 +325,18 @@ export class HttpConnector {
309
325
  });
310
326
  }
311
327
  }
328
+ function validateStatusResponses(operation) {
329
+ if (operation.responses === undefined)
330
+ return;
331
+ if (operation.pagination !== undefined)
332
+ throw new Error('HTTP response status mappings cannot be combined with pagination');
333
+ for (const [status, response] of Object.entries(operation.responses)) {
334
+ if (!/^4\d\d$/u.test(status) || ['401', '403', '429'].includes(status))
335
+ throw new Error('HTTP response status must be an explicit 4xx other than 401, 403, or 429');
336
+ if (typeof response.mapResponse !== 'function')
337
+ throw new Error('HTTP response status requires an explicit response mapping');
338
+ }
339
+ }
312
340
  function isManagedOrigin(url, resolved) {
313
341
  if (url.origin !== resolved || url.username !== '' || url.password !== '')
314
342
  return false;
@@ -17,12 +17,19 @@ export interface ResponseOperation {
17
17
  readonly retry?: HttpRetryPolicy;
18
18
  };
19
19
  readonly maxResponseBytes?: number;
20
+ readonly responses?: Readonly<Record<string, {
21
+ readonly responseType?: 'json' | 'text' | 'empty';
22
+ }>>;
23
+ }
24
+ export interface HttpResponse {
25
+ readonly status: number;
26
+ readonly body: unknown;
20
27
  }
21
28
  export interface ResponseFetchOptions {
22
29
  readonly maxBytes?: number;
23
30
  readonly timeoutMs?: number;
24
31
  readonly lookup?: DnsLookup;
25
32
  }
26
- export declare function fetchResponseWithResilience(url: URL, op: ResponseOperation, init: RequestInit, options: ResponseFetchOptions): Promise<unknown>;
33
+ export declare function fetchResponseWithResilience(url: URL, op: ResponseOperation, init: RequestInit, options: ResponseFetchOptions): Promise<HttpResponse>;
27
34
  export {};
28
35
  //# sourceMappingURL=http-response.d.ts.map
@@ -42,14 +42,23 @@ export async function fetchResponseWithResilience(url, op, init, options) {
42
42
  retryable: false,
43
43
  });
44
44
  }
45
- if (op.responseType === 'text') {
46
- return await readResponseText(response, max, attempt, retry !== undefined);
45
+ const declared = op.responses?.[String(response.status)];
46
+ const responseType = declared?.responseType ?? op.responseType;
47
+ const acceptedStatus = declared !== undefined;
48
+ if (responseType === 'text') {
49
+ return {
50
+ status: response.status,
51
+ body: await readResponseText(response, max, attempt, retry !== undefined, acceptedStatus),
52
+ };
47
53
  }
48
- if (op.responseType === 'empty') {
49
- await readResponseText(response, max, attempt, retry !== undefined);
50
- return {};
54
+ if (responseType === 'empty') {
55
+ await readResponseText(response, max, attempt, retry !== undefined, acceptedStatus);
56
+ return { status: response.status, body: {} };
51
57
  }
52
- return await readJsonResponse(response, max, attempt, retry !== undefined);
58
+ return {
59
+ status: response.status,
60
+ body: await readJsonResponse(response, max, attempt, retry !== undefined, acceptedStatus),
61
+ };
53
62
  }
54
63
  catch (error) {
55
64
  const normalized = normalizeAttemptError(error, attempt, retry, op.signature.type === 'read', signal.aborted);
@@ -112,8 +121,8 @@ async function readTextWithLimit(response, max) {
112
121
  * guards shared by JSON and text response modes. Non-2xx responses and oversized bodies raise a
113
122
  * `ConnectorInvocationError`; the raw decoded string is returned otherwise.
114
123
  */
115
- async function readResponseText(response, max, attempt, hasRetryPolicy) {
116
- if (!response.ok) {
124
+ async function readResponseText(response, max, attempt, hasRetryPolicy, acceptedStatus = false) {
125
+ if (!response.ok && !acceptedStatus) {
117
126
  const category = categoryForStatus(response.status);
118
127
  const retryAfterMs = response.status === 429 ? parseRetryAfterMs(response.headers.get('retry-after')) : undefined;
119
128
  throw new ConnectorInvocationError(`backend responded ${response.status}`, {
@@ -149,8 +158,8 @@ async function readResponseText(response, max, attempt, hasRetryPolicy) {
149
158
  throw error;
150
159
  }
151
160
  }
152
- async function readJsonResponse(response, max, attempt, hasRetryPolicy) {
153
- const text = await readResponseText(response, max, attempt, hasRetryPolicy);
161
+ async function readJsonResponse(response, max, attempt, hasRetryPolicy, acceptedStatus = false) {
162
+ const text = await readResponseText(response, max, attempt, hasRetryPolicy, acceptedStatus);
154
163
  try {
155
164
  return JSON.parse(text);
156
165
  }
@@ -1,4 +1,4 @@
1
- export { type HttpAuthScheme, HttpConnector, type HttpConnectorConfig, type HttpOperation, type HttpOperationFake, type HttpOperationPagination, type HttpPaginationAggregate, type HttpPaginationStopReason, } from './http-connector.js';
1
+ export { type HttpAuthScheme, HttpConnector, type HttpConnectorConfig, type HttpOperation, type HttpOperationFake, type HttpOperationPagination, type HttpPaginationAggregate, type HttpPaginationStopReason, type HttpStatusResponse, } from './http-connector.js';
2
2
  export * from './mcp/index.js';
3
3
  export type { HttpOperationProjection } from './projection.js';
4
4
  export type { GuardedFetchOptions } from './ssrf.js';
@@ -0,0 +1,7 @@
1
+ import type { AccessMode } from './contract.js';
2
+ export declare function usesCustomerAuthentication(input: {
3
+ readonly schemaVersion: number;
4
+ readonly accessMode: AccessMode | undefined;
5
+ readonly hasServerAuth: boolean;
6
+ }): boolean;
7
+ //# sourceMappingURL=customer-auth-access.d.ts.map
@@ -0,0 +1,6 @@
1
+ export function usesCustomerAuthentication(input) {
2
+ if (input.accessMode === 'customers')
3
+ return true;
4
+ return input.accessMode === 'mixed' && input.schemaVersion === 2 && input.hasServerAuth;
5
+ }
6
+ //# sourceMappingURL=customer-auth-access.js.map
@@ -1,5 +1,6 @@
1
1
  export * from './asset-store.js';
2
2
  export * from './contract.js';
3
+ export * from './customer-auth-access.js';
3
4
  export * from './deployment-activation.js';
4
5
  export * from './deployment-automation.js';
5
6
  export * from './endpoint-url.js';
@@ -1,5 +1,6 @@
1
1
  export * from './asset-store.js';
2
2
  export * from './contract.js';
3
+ export * from './customer-auth-access.js';
3
4
  export * from './deployment-activation.js';
4
5
  export * from './deployment-automation.js';
5
6
  export * from './endpoint-url.js';
@@ -1,6 +1,7 @@
1
1
  import type { CredentialProfile, OperationSignature, ResolvedOperationRef } from '@noodle-borg/compiler';
2
2
  import type { DownstreamCredential } from '../broker/types.js';
3
3
  import type { CustomerConnectorRoute } from '../customer-routing.js';
4
+ import type { OperationCoordinationDeclaration, OperationCoordinationSnapshot } from '../operation-coordination.js';
4
5
  import type { OperationEvidence } from '../operation-evidence.js';
5
6
  /** Verified caller claims that may be threaded into first-party connector operations. */
6
7
  export interface CallerIdentity {
@@ -74,7 +75,9 @@ export declare function connectorInvocationErrorMessage(value: unknown): string
74
75
  * drift checks, policy, broker credentials, connector invocation, redaction, and output validation.
75
76
  */
76
77
  export interface ConnectorCallHost {
77
- callOperation(ref: ResolvedOperationRef, args: Readonly<Record<string, unknown>>, path: string): Promise<unknown>;
78
+ callOperation(ref: ResolvedOperationRef, args: Readonly<Record<string, unknown>>, path: string,
79
+ /** Internal inherited execution deadline; never a sandbox-controlled value. */
80
+ parentSignal?: AbortSignal): Promise<unknown>;
78
81
  }
79
82
  /** A single connector-operation invocation, fully resolved and credentialed by the runtime. */
80
83
  export interface ConnectorCall {
@@ -85,6 +88,8 @@ export interface ConnectorCall {
85
88
  }>;
86
89
  /** Connector/application-classified evidence; never infer completion from a transport status alone. */
87
90
  readonly reportOutcome?: (evidence: OperationEvidence) => void;
91
+ readonly coordination?: OperationCoordinationSnapshot;
92
+ readonly resolveCoordination?: () => Promise<void>;
88
93
  /** Trusted request attribution for native public writes; never an argument or expression value. */
89
94
  readonly publicAdmission?: {
90
95
  readonly network: string;
@@ -130,6 +135,7 @@ export interface Connector {
130
135
  signature(operation: string): OperationSignature | undefined;
131
136
  /** Maximum action execution duration owned by this connector; excludes confirmation/model time. */
132
137
  executionBoundMs?(operation: string): number | undefined;
138
+ coordination?(operation: string): OperationCoordinationDeclaration | undefined;
133
139
  /** Invoke the operation. May reject; the runtime normalizes the failure (no secret leakage). */
134
140
  invoke(call: ConnectorCall): Promise<unknown>;
135
141
  }
@@ -22,6 +22,7 @@ export function withConnectorSnapshot(deps) {
22
22
  }
23
23
  const signatures = new Map();
24
24
  const executionBounds = new Map();
25
+ const coordinations = new Map();
25
26
  const snapshot = {
26
27
  id: connector.id,
27
28
  version: connector.version,
@@ -38,6 +39,13 @@ export function withConnectorSnapshot(deps) {
38
39
  executionBounds.set(operation, connector.executionBoundMs?.(operation));
39
40
  return executionBounds.get(operation);
40
41
  },
42
+ coordination(operation) {
43
+ if (!coordinations.has(operation)) {
44
+ const live = connector.coordination?.(operation);
45
+ coordinations.set(operation, live === undefined ? undefined : deepFreeze(structuredClone(live)));
46
+ }
47
+ return coordinations.get(operation);
48
+ },
41
49
  invoke(call) {
42
50
  return connector.invoke(call);
43
51
  },
@@ -4,6 +4,7 @@ import type { CallerIdentity, ConnectorRegistry, ExecutionTraceSink } from './co
4
4
  import type { FrozenCustomerRoutes } from './customer-routing.js';
5
5
  import { type EvalScope } from './eval/evaluate.js';
6
6
  import type { InvocationContext } from './invocation-context.js';
7
+ import type { OperationCoordinationPort } from './operation-coordination.js';
7
8
  import type { OperationEvidencePort } from './operation-evidence.js';
8
9
  import type { PolicyGate } from './policy/types.js';
9
10
  import type { ExecutionResult } from './result.js';
@@ -36,6 +37,7 @@ export interface ExecuteDeps {
36
37
  /** Trusted adapter invocation/confirmation identity; never read from tool input or expression scope. */
37
38
  readonly invocationId?: string;
38
39
  readonly operationEvidence?: OperationEvidencePort;
40
+ readonly operationCoordination?: OperationCoordinationPort;
39
41
  /** Hosting snapshot: operator configuration and original connected-account generations. */
40
42
  readonly executionBinding?: {
41
43
  readonly revision: string;
@@ -15,6 +15,7 @@ export { type ExecuteDeps, type ExecuteToolDeps, executePrompt, executeResource,
15
15
  export { executeToolInteractive, resumeTool } from './interactive.js';
16
16
  export type { InvocationContext, InvocationContextPreferenceSource, InvocationLocationContext, InvocationTemporalContext, } from './invocation-context.js';
17
17
  export { type ManagedOriginResolutionResult, resolveManagedOrigins, } from './managed-origins.js';
18
+ export type { OperationCoordinationDeclaration, OperationCoordinationIntent, OperationCoordinationLease, OperationCoordinationPort, OperationCoordinationSnapshot, } from './operation-coordination.js';
18
19
  export type { OperationEvidence, OperationEvidenceIntent, OperationEvidencePort, } from './operation-evidence.js';
19
20
  export { AllowAllPolicy } from './policy/allow-all.js';
20
21
  export type { PolicyContext, PolicyDecision, PolicyGate } from './policy/types.js';
@@ -0,0 +1,25 @@
1
+ import { ConnectorInvocationError } from './connector/types.js';
2
+ /** Bind only exact declared children, retaining the original host's execution/coordination identity. */
3
+ export function nestedOperationHost(ref, host, parentSignal) {
4
+ const calls = ref.calls;
5
+ if (calls === undefined && parentSignal === undefined)
6
+ return host;
7
+ // Legacy artifacts retain their declaration contract while inheriting the parent's deadline.
8
+ return {
9
+ callOperation(target, args, path) {
10
+ const declared = calls?.find((child) => child.connectorId === target.connectorId &&
11
+ child.connectorVersion === target.connectorVersion &&
12
+ child.operation === target.operation &&
13
+ child.signatureHash === target.signatureHash);
14
+ if (calls !== undefined && declared === undefined)
15
+ throw new ConnectorInvocationError('Undeclared nested connector operation', {
16
+ category: 'invalid_response',
17
+ retryable: false,
18
+ });
19
+ // Invoke as a method on the original host: WeakMap custody frames and private symbol state
20
+ // must never migrate to this projection. Caller-supplied binding metadata has no authority.
21
+ return host.callOperation(declared ?? target, args, path, parentSignal);
22
+ },
23
+ };
24
+ }
25
+ //# sourceMappingURL=nested-operation-host.js.map
@@ -0,0 +1,50 @@
1
+ import { evaluateValue } from './eval/evaluate.js';
2
+ const frames = new WeakMap();
3
+ /** Parent evidence is runtime-owned. Child receipts remain durable but are not duplicate business rows. */
4
+ export function coordinatedParentId(host) {
5
+ return frames.get(host)?.at(-1)?.executionId;
6
+ }
7
+ /** Every nested action traverses this guard before credentials or provider I/O. */
8
+ export function admitCoordinatedAction(host) {
9
+ const frame = frames.get(host)?.at(-1);
10
+ if (!frame)
11
+ return true;
12
+ if (!frame.lease.acquired || frame.writeStarted)
13
+ return false;
14
+ frame.writeStarted = true;
15
+ return true;
16
+ }
17
+ export async function beginOperationCoordination(input) {
18
+ if (!input.deps.operationCoordination ||
19
+ !input.executionBoundMs ||
20
+ frames.get(input.host)?.length)
21
+ throw new Error('Coordination authority unavailable');
22
+ const scope = { args: input.args, env: input.env, execution: { id: input.executionId } };
23
+ const key = evaluateValue(input.declaration.key, scope);
24
+ const reference = evaluateValue(input.declaration.reference, scope);
25
+ if (typeof key !== 'string' || typeof reference !== 'string')
26
+ throw new Error('Coordination identity invalid');
27
+ const lease = await input.deps.operationCoordination.acquire({
28
+ id: input.executionId,
29
+ connectionId: input.declaration.connectionId,
30
+ namespace: input.declaration.namespace,
31
+ key,
32
+ reference,
33
+ executionBoundMs: input.executionBoundMs,
34
+ });
35
+ const stack = frames.get(input.host) ?? [];
36
+ const frame = { lease, executionId: input.executionId, writeStarted: false };
37
+ stack.push(frame);
38
+ frames.set(input.host, stack);
39
+ return {
40
+ lease,
41
+ didAdmitAction: () => frame.writeStarted,
42
+ dispose() {
43
+ if (stack.at(-1) === frame)
44
+ stack.pop();
45
+ if (stack.length === 0)
46
+ frames.delete(input.host);
47
+ },
48
+ };
49
+ }
50
+ //# sourceMappingURL=operation-coordination-execution.js.map
@@ -0,0 +1,34 @@
1
+ import type { ExprNode } from '@noodle-borg/compiler';
2
+ import type { OperationEvidence } from './operation-evidence.js';
3
+ /** Application-authored resource identity; values resolve before executing the guarded operation. */
4
+ export interface OperationCoordinationDeclaration {
5
+ readonly connectionId: string;
6
+ readonly namespace: string;
7
+ readonly key: ExprNode;
8
+ readonly reference: ExprNode;
9
+ }
10
+ export interface OperationCoordinationIntent {
11
+ readonly id: string;
12
+ readonly connectionId: string;
13
+ readonly namespace: string;
14
+ readonly key: string;
15
+ readonly reference: string;
16
+ readonly executionBoundMs: number;
17
+ }
18
+ export interface OperationCoordinationSnapshot {
19
+ readonly acquired: boolean;
20
+ readonly previous?: {
21
+ readonly reference: string;
22
+ readonly operationDigest: string;
23
+ };
24
+ }
25
+ /** A token-bound lease: resolving a prior uncertain effect never admits a write in this invocation. */
26
+ export interface OperationCoordinationLease extends OperationCoordinationSnapshot {
27
+ finish(evidence: OperationEvidence): Promise<void>;
28
+ resolvePrevious(): Promise<void>;
29
+ }
30
+ /** Production implementations share durable authority across service instances. */
31
+ export interface OperationCoordinationPort {
32
+ acquire(intent: OperationCoordinationIntent): Promise<OperationCoordinationLease>;
33
+ }
34
+ //# sourceMappingURL=operation-coordination.d.ts.map
@@ -9,6 +9,10 @@ export interface OperationEvidence {
9
9
  }
10
10
  export interface OperationEvidenceIntent {
11
11
  readonly id: string;
12
+ /** Trusted coordinated-parent identity; never supplied by application arguments. */
13
+ readonly parentId?: string;
14
+ /** Coordination-selected connection for an outer compute action without a direct credential binding. */
15
+ readonly connectionId?: string;
12
16
  readonly tool: string;
13
17
  readonly operation: ResolvedOperationRef;
14
18
  readonly arguments: Readonly<Record<string, unknown>>;