@aifabrix/builder 2.55.0 → 2.56.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 (101) hide show
  1. package/lib/agent-kit/host-approve.js +48 -6
  2. package/lib/agent-kit/init.js +2 -2
  3. package/lib/agent-kit/remote-prompts.js +46 -13
  4. package/lib/agent-kit/run.js +1 -1
  5. package/lib/agent-kit/start.js +310 -0
  6. package/lib/api/pipeline.api.js +32 -3
  7. package/lib/app/deploy.js +13 -9
  8. package/lib/app/offer-create-from-template.js +184 -0
  9. package/lib/cli/setup-app.js +15 -7
  10. package/lib/cli/setup-auth.js +11 -2
  11. package/lib/cli/setup-external-system-help.js +15 -3
  12. package/lib/cli/setup-external-system.js +21 -3
  13. package/lib/commands/agent-kit-help.js +74 -4
  14. package/lib/commands/agent-kit.js +83 -12
  15. package/lib/commands/auth-status-user.js +99 -0
  16. package/lib/commands/auth-status.js +14 -4
  17. package/lib/commands/datasource-load-export-cli.js +7 -2
  18. package/lib/commands/datasource-test-trust-cli.js +5 -1
  19. package/lib/commands/governance-command-action.js +5 -4
  20. package/lib/commands/identity-membership-role-cache.js +6 -1
  21. package/lib/commands/lifecycle-command-action.js +16 -15
  22. package/lib/commands/login-credentials.js +8 -3
  23. package/lib/commands/login-device.js +14 -5
  24. package/lib/commands/login.js +14 -1
  25. package/lib/commands/logout.js +50 -15
  26. package/lib/commands/repair-datasource-auto-rbac.js +4 -9
  27. package/lib/commands/role-assistant.js +24 -12
  28. package/lib/commands/upload-openapi-sync-followup.js +59 -0
  29. package/lib/commands/upload-qualification-client.js +131 -0
  30. package/lib/commands/upload-qualification-followups.js +104 -0
  31. package/lib/commands/upload-qualification-poll.js +143 -0
  32. package/lib/commands/upload.js +37 -156
  33. package/lib/commands/verify-governance-command-action.js +9 -7
  34. package/lib/commands/verify-operations-command-action.js +9 -8
  35. package/lib/commands/verify-trust-command-action.js +6 -5
  36. package/lib/deployment/deploy-poll-ui.js +14 -10
  37. package/lib/deployment/deployer-status.js +4 -4
  38. package/lib/external-system/deploy.js +46 -51
  39. package/lib/external-system/download.js +1 -2
  40. package/lib/generator/helpers.js +14 -46
  41. package/lib/generator/index.js +0 -4
  42. package/lib/integration-definition/apply-static-enterprise.js +5 -2
  43. package/lib/programmatic/builder-api-request.js +8 -4
  44. package/lib/programmatic/capability-registry.js +2 -0
  45. package/lib/programmatic/get-deploy-status.js +45 -0
  46. package/lib/programmatic/get-upload-status.js +45 -0
  47. package/lib/programmatic/http-accepted-response.js +31 -0
  48. package/lib/programmatic/openapi-descriptions.js +14 -4
  49. package/lib/programmatic/request-timeout.js +21 -15
  50. package/lib/programmatic/route-handler-map.js +6 -0
  51. package/lib/programmatic/run-deploy.js +7 -3
  52. package/lib/programmatic/run-upload.js +11 -7
  53. package/lib/role-assistant/knowledge-sync-settings-push.js +172 -0
  54. package/lib/role-assistant/knowledge-sync.js +9 -126
  55. package/lib/role-assistant/test-cases-evaluate.js +12 -1
  56. package/lib/role-assistant/test-cases-evidence.js +44 -5
  57. package/lib/role-assistant/test-cases-lifecycle.js +9 -3
  58. package/lib/role-assistant/test-runner.js +3 -0
  59. package/lib/schema/infra-parameter.schema.json +51 -3
  60. package/lib/schema/infra.parameter.yaml +482 -47
  61. package/lib/schema/type/document-storage.json +1 -1
  62. package/lib/utils/api-required-permissions.js +271 -0
  63. package/lib/utils/api.js +16 -13
  64. package/lib/utils/cli-json-exit.js +41 -0
  65. package/lib/utils/cli-utils.js +26 -7
  66. package/lib/utils/controller-url.js +78 -4
  67. package/lib/utils/deployment-errors.js +15 -0
  68. package/lib/utils/deployment-validation-helpers.js +4 -1
  69. package/lib/utils/device-code.js +31 -10
  70. package/lib/utils/error-formatters/error-parser.js +16 -1
  71. package/lib/utils/error-formatters/permission-errors.js +19 -5
  72. package/lib/utils/keycloak-realm-ready.js +5 -2
  73. package/lib/utils/logger.js +1 -0
  74. package/lib/utils/paths.js +26 -5
  75. package/lib/utils/qualification-poll-ui.js +136 -0
  76. package/lib/utils/secrets-helpers.js +2 -2
  77. package/lib/utils/write-stream-and-wait.js +63 -0
  78. package/package.json +22 -7
  79. package/templates/agent-kit/agent-kit.yaml +1 -1
  80. package/templates/agent-kit/instructions/AGENTKIT.md +25 -4
  81. package/templates/agent-kit/instructions/root.AGENTS.md +1 -1
  82. package/templates/agent-kit/skills/aifabrix-connected-system/SKILL.md +2 -1
  83. package/templates/agent-kit/skills/aifabrix-connected-system/references/delivery-gates.md +1 -1
  84. package/templates/agent-kit/skills/aifabrix-plan/SKILL.md +2 -1
  85. package/templates/agent-kit/skills/aifabrix-prove/SKILL.md +1 -0
  86. package/templates/agent-kit/skills/aifabrix-role-assistant/SKILL.md +1 -0
  87. package/templates/agent-kit/skills/shared/hosts.md +13 -26
  88. package/templates/agent-kit/skills/shared/login.md +16 -0
  89. package/templates/agent-kit/workspace/README.md +1 -1
  90. package/templates/applications/builder-api/env.template +4 -0
  91. package/templates/applications/dataplane/application.yaml +1 -2
  92. package/templates/applications/dataplane/env.template +5 -5
  93. package/templates/applications/keycloak/Dockerfile +12 -5
  94. package/templates/applications/keycloak/application.yaml +2 -2
  95. package/templates/applications/keycloak/cimd-lenient-parse/AbstractClientIdMetadataDocumentExecutor.java +3 -3
  96. package/templates/applications/keycloak/cimd-lenient-parse/SOURCE.md +6 -6
  97. package/templates/applications/keycloak/env.template +13 -1
  98. package/templates/applications/miso-controller/application.yaml +21 -2
  99. package/templates/applications/miso-controller/env.template +97 -28
  100. package/templates/applications/miso-controller/rbac.yaml +5 -0
  101. package/lib/generator/deploy-manifest-azure-kv.js +0 -81
@@ -11,7 +11,6 @@
11
11
  const fs = require('fs');
12
12
  const path = require('path');
13
13
  const { loadConfigFile } = require('../utils/config-format');
14
- const { urlTokenToKeyVaultSecretName } = require('./deploy-manifest-azure-kv');
15
14
 
16
15
  /**
17
16
  * Loads application config file (application.yaml, application.json, or legacy path) via converter.
@@ -223,9 +222,6 @@ function determineVariableLocation(value, key) {
223
222
  if (value.startsWith('kv://')) {
224
223
  location = 'keyvault';
225
224
  required = true;
226
- } else if (value.startsWith('url://')) {
227
- location = 'keyvault';
228
- required = true;
229
225
  }
230
226
 
231
227
  // Check if it's a sensitive variable
@@ -234,32 +230,19 @@ function determineVariableLocation(value, key) {
234
230
  required = true;
235
231
  }
236
232
 
237
- return { location, required };
238
- }
239
-
240
- /**
241
- * Maps env.template url:// value(s) to Key Vault secret name(s) for deploy JSON.
242
- * Comma-separated lists are supported (e.g. CORS ALLOWED_ORIGINS): each segment
243
- * starting with url:// is mapped; other segments are left unchanged (e.g. http://localhost:*).
244
- *
245
- * @param {string} appKey - application.yaml app.key
246
- * @param {string} value - Full value after KEY= (must start with url:// for caller)
247
- * @returns {string} Comma-joined secret names / literals
248
- */
249
- function mapUrlTemplateValueToKeyVaultNames(appKey, value) {
250
- const segments = value
251
- .split(',')
252
- .map((s) => s.trim())
253
- .filter((s) => s.length > 0);
254
- return segments
255
- .map((seg) => {
256
- if (seg.startsWith('url://')) {
257
- const token = seg.slice('url://'.length).trim();
258
- return urlTokenToKeyVaultSecretName(appKey, token);
233
+ if (location === 'keyvault' && value.startsWith('kv://')) {
234
+ try {
235
+ const { getInfraParameterCatalog } = require('../parameters/infra-parameter-catalog');
236
+ const catalog = getInfraParameterCatalog();
237
+ if (catalog.isKeyAllowedEmpty(value.slice('kv://'.length))) {
238
+ required = false;
259
239
  }
260
- return seg;
261
- })
262
- .join(',');
240
+ } catch {
241
+ // Keep the conservative required=true default when the catalog is unavailable.
242
+ }
243
+ }
244
+
245
+ return { location, required };
263
246
  }
264
247
 
265
248
  /**
@@ -270,21 +253,13 @@ function mapUrlTemplateValueToKeyVaultNames(appKey, value) {
270
253
  * @param {string} location - Variable location
271
254
  * @param {boolean} required - Whether variable is required
272
255
  * @param {Map} portalInputMap - Map of portalInput configurations
273
- * @param {string|null} appKey - application.yaml app.key (required when value uses url://)
274
256
  * @returns {Object} Configuration item
275
257
  */
276
- function createConfigItem(key, value, location, required, portalInputMap, appKey) {
258
+ function createConfigItem(key, value, location, required, portalInputMap) {
277
259
  let storedValue = value;
278
260
  if (location === 'keyvault') {
279
261
  if (value.startsWith('kv://')) {
280
262
  storedValue = value.replace('kv://', '');
281
- } else if (value.startsWith('url://')) {
282
- if (!appKey) {
283
- throw new Error(
284
- `Cannot resolve ${key}=${value}: application app.key is required to map url:// to a Key Vault secret name`
285
- );
286
- }
287
- storedValue = mapUrlTemplateValueToKeyVaultNames(appKey, value);
288
263
  }
289
264
  }
290
265
 
@@ -311,11 +286,6 @@ function parseEnvironmentVariables(envTemplate, variablesConfig = null) {
311
286
  const configuration = [];
312
287
  const lines = envTemplate.split('\n');
313
288
  const portalInputMap = createPortalInputMap(variablesConfig);
314
- const appKey =
315
- variablesConfig && variablesConfig.app && variablesConfig.app.key
316
- ? String(variablesConfig.app.key).trim()
317
- : null;
318
-
319
289
  for (const line of lines) {
320
290
  const parsed = parseEnvironmentVariableLine(line);
321
291
  if (!parsed) {
@@ -328,8 +298,7 @@ function parseEnvironmentVariables(envTemplate, variablesConfig = null) {
328
298
  parsed.value,
329
299
  location,
330
300
  required,
331
- portalInputMap,
332
- appKey
301
+ portalInputMap
333
302
  );
334
303
  configuration.push(configItem);
335
304
  }
@@ -344,4 +313,3 @@ module.exports = {
344
313
  validatePortalInput,
345
314
  parseEnvironmentVariables
346
315
  };
347
-
@@ -22,7 +22,6 @@ const { generateControllerManifest } = require('./external-controller-manifest')
22
22
  const { resolveVersionForApp } = require('../utils/image-version');
23
23
  const { getContainerPort } = require('../utils/port-resolver');
24
24
  const { buildEnvVarMap } = require('../utils/env-map');
25
- const { rewriteFrontDoorHostForAzureDeploy } = require('./deploy-manifest-azure-kv');
26
25
 
27
26
  /**
28
27
  * Generates deployment JSON from application configuration files
@@ -192,8 +191,6 @@ function buildAndValidateDeployment(appName, variables, envTemplate, rbac, optio
192
191
  substituteEnvVarsInDeployment(deployment, envVarMap);
193
192
  }
194
193
 
195
- rewriteFrontDoorHostForAzureDeploy(deployment);
196
-
197
194
  // Ensure no other ${...} placeholders remain in manifest
198
195
  _validator.validateNoUnresolvedVariablesInDeployment(deployment);
199
196
 
@@ -239,7 +236,6 @@ async function buildDeploymentManifestInMemory(appName, options = {}) {
239
236
  }
240
237
  const envVarMap = await buildEnvVarMap('docker', null, null, { appPort: effectivePort });
241
238
  substituteEnvVarsInDeployment(deployment, envVarMap);
242
- rewriteFrontDoorHostForAzureDeploy(deployment);
243
239
  _validator.validateNoUnresolvedVariablesInDeployment(deployment);
244
240
  return { deployment, appPath };
245
241
  }
@@ -52,12 +52,12 @@ function setRecordFetch(op) {
52
52
  let found = false;
53
53
  for (const step of steps) {
54
54
  if (step && step.fetch && typeof step.fetch === 'object') {
55
- step.fetch.source = 'record';
55
+ step.fetch = { source: 'record' };
56
56
  found = true;
57
57
  }
58
58
  }
59
59
  if (!found) {
60
- steps.unshift({ fetch: { source: 'record', query: {} } });
60
+ steps.unshift({ fetch: { source: 'record' } });
61
61
  if (!steps.some((row) => row && row.output)) {
62
62
  steps.push({ output: { mode: 'records' } });
63
63
  }
@@ -87,6 +87,9 @@ function ensureRecordCapability(body, capKey) {
87
87
  if (!ops[capKey] || typeof ops[capKey] !== 'object') {
88
88
  ops[capKey] = { enabled: true, description: `Local ${capKey}`, steps: [] };
89
89
  }
90
+ if (capKey === 'create' || capKey === 'update') {
91
+ ops[capKey].shape = capKey;
92
+ }
90
93
  setRecordFetch(/** @type {Record<string, unknown>} */ (ops[capKey]));
91
94
  }
92
95
 
@@ -14,6 +14,7 @@ const { withWorkspaceLock } = require('./workspace-lock');
14
14
  const { getIdempotentResult, setIdempotentResult } = require('./idempotency-cache');
15
15
  const { withRequestTimeout } = require('./request-timeout');
16
16
  const { isHttpRawResult } = require('./http-raw-response');
17
+ const { isHttpAcceptedResult } = require('./http-accepted-response');
17
18
  const { publicOriginFromRequest } = require('../channels/vendor-dataplane-url');
18
19
 
19
20
  /**
@@ -103,10 +104,11 @@ async function runHandler(auth, capability, params, body, query) {
103
104
  * @param {Object} options.body
104
105
  * @param {string} options.requestId
105
106
  * @param {Object} options.result
107
+ * @param {number} [options.httpStatus=200] - 202 for accepted-async operations (upload/deploy); idempotency replay preserves it.
106
108
  * @returns {{ httpStatus: number, body: Object, requestId: string, userId: string }}
107
109
  */
108
110
  function buildSuccessResponse(options) {
109
- const { auth, idempotencyKey, capability, routeKey, params, body, requestId, result } = options;
111
+ const { auth, idempotencyKey, capability, routeKey, params, body, requestId, result, httpStatus = 200 } = options;
110
112
  const responseBody = { success: true, data: result, correlationId: requestId };
111
113
  if (idempotencyKey && isMutating(capability)) {
112
114
  setIdempotentResult(
@@ -116,10 +118,10 @@ function buildSuccessResponse(options) {
116
118
  route: routeKey,
117
119
  systemKey: resolveIdempotencySystemKey(params, body)
118
120
  },
119
- { httpStatus: 200, body: responseBody, correlationId: requestId }
121
+ { httpStatus, body: responseBody, correlationId: requestId }
120
122
  );
121
123
  }
122
- return { httpStatus: 200, body: responseBody, requestId, userId: auth.userId };
124
+ return { httpStatus, body: responseBody, requestId, userId: auth.userId };
123
125
  }
124
126
 
125
127
  /**
@@ -163,6 +165,7 @@ async function executeCapabilityRequest(options) {
163
165
  if (isHttpRawResult(result)) {
164
166
  return { httpStatus: 200, raw: result, requestId, userId: auth.userId };
165
167
  }
168
+ const accepted = isHttpAcceptedResult(result);
166
169
  return buildSuccessResponse({
167
170
  auth,
168
171
  idempotencyKey: req.headers['idempotency-key'],
@@ -171,7 +174,8 @@ async function executeCapabilityRequest(options) {
171
174
  params,
172
175
  body,
173
176
  requestId,
174
- result
177
+ result: accepted ? result.data : result,
178
+ httpStatus: accepted ? 202 : 200
175
179
  });
176
180
  }
177
181
 
@@ -48,7 +48,9 @@ const CAPABILITIES = Object.freeze([
48
48
  { method: 'POST', route: '/systems/:systemKey/certify/:pillar', handlerId: 'runCertifyPillar', operationType: 'certify', mutating: true },
49
49
  { method: 'GET', route: '/systems/:systemKey/lifecycle', handlerId: 'getLifecycleReport', operationType: 'certify.read', mutating: false },
50
50
  { method: 'POST', route: '/systems/:systemKey/upload', handlerId: 'runUpload', operationType: 'apply.dev', mutating: true },
51
+ { method: 'GET', route: '/systems/:systemKey/upload/:jobId/status', handlerId: 'getUploadStatus', operationType: 'apply.dev.read', mutating: false },
51
52
  { method: 'POST', route: '/systems/:systemKey/deploy', handlerId: 'runDeploySystem', operationType: 'apply.prod', mutating: true },
53
+ { method: 'GET', route: '/systems/:systemKey/deploy/:deploymentId/status', handlerId: 'getDeployStatus', operationType: 'apply.prod.read', mutating: false },
52
54
  { method: 'POST', route: '/systems/:systemKey/download', handlerId: 'runDownload', operationType: 'workspace.write', mutating: true },
53
55
  {
54
56
  method: 'POST',
@@ -0,0 +1,45 @@
1
+ /**
2
+ * Builder-api status read for an async external system deploy (plan 191.0 task 3).
3
+ * Thin proxy over Miso's own pipeline deployment status — Builder never invents deployment state.
4
+ *
5
+ * @fileoverview GET /systems/:systemKey/deploy/:deploymentId/status
6
+ * @author AI Fabrix Team
7
+ * @version 1.0.0
8
+ */
9
+
10
+ 'use strict';
11
+
12
+ const { runWithWorkspaceContext } = require('./workspace-context');
13
+ const { buildBearerAuthConfig } = require('./auth-config');
14
+ const { getPipelineDeployment } = require('../api/pipeline.api');
15
+ const { formatApiError } = require('../utils/api-error-handler');
16
+
17
+ /**
18
+ * @param {Object} res
19
+ * @param {string} controllerUrl
20
+ * @returns {Error & { statusCode: number }}
21
+ */
22
+ function toDeployStatusError(res, controllerUrl) {
23
+ const err = new Error(formatApiError(res, controllerUrl));
24
+ const status = Number(res.status || res.statusCode);
25
+ err.statusCode = status >= 400 && status < 600 ? status : 502;
26
+ return err;
27
+ }
28
+
29
+ /**
30
+ * @param {import('./workspace-context').WorkspaceContext} ctx
31
+ * @param {string} deploymentId
32
+ * @returns {Promise<Object>} Miso deployment status (id, status, progress, updatedAt, qualification, ...)
33
+ */
34
+ async function getDeployStatus(ctx, deploymentId) {
35
+ return runWithWorkspaceContext(ctx, async() => {
36
+ const authConfig = buildBearerAuthConfig(ctx.bearerToken);
37
+ const res = await getPipelineDeployment(ctx.controllerUrl, ctx.environment, deploymentId, authConfig);
38
+ if (res?.success === false) {
39
+ throw toDeployStatusError(res, ctx.controllerUrl);
40
+ }
41
+ return res.data ?? res;
42
+ });
43
+ }
44
+
45
+ module.exports = { getDeployStatus };
@@ -0,0 +1,45 @@
1
+ /**
2
+ * Builder-api status read for an async qualification upload job (plan 191.0 task 3).
3
+ * Thin proxy over Dataplane's own publish-job status — Builder never invents job state.
4
+ *
5
+ * @fileoverview GET /systems/:systemKey/upload/:jobId/status
6
+ * @author AI Fabrix Team
7
+ * @version 1.0.0
8
+ */
9
+
10
+ 'use strict';
11
+
12
+ const { runWithWorkspaceContext } = require('./workspace-context');
13
+ const { buildProgrammaticAuthContext } = require('./auth-config');
14
+ const { getPublishJobStatus } = require('../api/pipeline.api');
15
+ const { formatApiError } = require('../utils/api-error-handler');
16
+
17
+ /**
18
+ * @param {Object} res
19
+ * @param {string} dataplaneUrl
20
+ * @returns {Error & { statusCode: number }}
21
+ */
22
+ function toJobStatusError(res, dataplaneUrl) {
23
+ const err = new Error(formatApiError(res, dataplaneUrl));
24
+ const status = Number(res.status || res.statusCode);
25
+ err.statusCode = status >= 400 && status < 600 ? status : 502;
26
+ return err;
27
+ }
28
+
29
+ /**
30
+ * @param {import('./workspace-context').WorkspaceContext} ctx
31
+ * @param {string} jobId
32
+ * @returns {Promise<Object>} Dataplane PublishJobStatusResponse (jobId, state, steps, error, result)
33
+ */
34
+ async function getUploadStatus(ctx, jobId) {
35
+ return runWithWorkspaceContext(ctx, async() => {
36
+ const { authConfig, dataplaneUrl } = buildProgrammaticAuthContext(ctx);
37
+ const res = await getPublishJobStatus(dataplaneUrl, authConfig, jobId);
38
+ if (res?.success === false) {
39
+ throw toJobStatusError(res, dataplaneUrl);
40
+ }
41
+ return res.data;
42
+ });
43
+ }
44
+
45
+ module.exports = { getUploadStatus };
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Marker for builder-api handlers that accepted a durable async operation (202), instead of
3
+ * completing synchronously (200). Mirrors http-raw-response.js's escape-hatch pattern so
4
+ * executeCapabilityRequest can special-case the response status without every other handler
5
+ * needing to know about it (plan 191.0 task 3: replace 5-minute sync upload/deploy web requests
6
+ * with accepted operation responses).
7
+ *
8
+ * @fileoverview 202-accepted result marker for upload/deploy web handlers
9
+ * @author AI Fabrix Team
10
+ * @version 1.0.0
11
+ */
12
+
13
+ 'use strict';
14
+
15
+ /**
16
+ * @param {Object} data - Operation identity/state to return in the response body (e.g. {jobId, candidateFingerprint} or {deploymentId, status}).
17
+ * @returns {{ __httpAccepted: true, data: Object }}
18
+ */
19
+ function createHttpAcceptedResult(data) {
20
+ return { __httpAccepted: true, data };
21
+ }
22
+
23
+ /**
24
+ * @param {unknown} result
25
+ * @returns {boolean}
26
+ */
27
+ function isHttpAcceptedResult(result) {
28
+ return Boolean(result && typeof result === 'object' && result.__httpAccepted === true);
29
+ }
30
+
31
+ module.exports = { createHttpAcceptedResult, isHttpAcceptedResult };
@@ -129,15 +129,25 @@ const OPERATION_DESCRIPTIONS = Object.freeze({
129
129
  tags: ['certify']
130
130
  },
131
131
  runUpload: {
132
- summary: 'Upload integration to dev Dataplane',
132
+ summary: 'Submit integration for durable Dataplane qualification (async)',
133
133
  description:
134
- 'Full dev publish: validate, sync deploy JSON, push credentials, pipeline upload. Requires external-system:publish in dev. Mutating; use Idempotency-Key; may take up to MAX_UPLOAD_TIMEOUT_MS.',
134
+ 'Validates, syncs deploy JSON, pushes credentials, then durably submits the candidate for Dataplane qualification (plan 191.0). Returns 202 immediately with {jobId, candidateFingerprint} — never blocks on the qualification ladder. Poll GET .../upload/{jobId}/status for terminal state. Requires external-system:publish in dev. Mutating; use Idempotency-Key.',
135
+ tags: ['apply']
136
+ },
137
+ getUploadStatus: {
138
+ summary: 'Read qualification job status',
139
+ description: 'Poll the durable Dataplane qualification job accepted by runUpload. Read-only proxy; terminal states are completed/failed.',
135
140
  tags: ['apply']
136
141
  },
137
142
  runDeploySystem: {
138
- summary: 'Deploy integration via controller (promote)',
143
+ summary: 'Deploy integration via controller (promote, async)',
139
144
  description:
140
- 'Controller deploy for external systems (CLI aifabrix deploy parity). Optional body.gate matches CLI --gate (operations,trust,governance,full). Certificate seal is a platform side-effect of published Deploy — not a separate certificates issue call. Mutating; use Idempotency-Key.',
145
+ 'Controller deploy for external systems (CLI aifabrix deploy parity). Optional body.gate is a no-op notice — qualification gates now run once during upload, not at deploy time. Returns 202 immediately with {deploymentId} — never blocks on the outer Miso deployment (fast when the candidate is already qualified, slower on the legacy ladder otherwise). Poll GET .../deploy/{deploymentId}/status for terminal state. Mutating; use Idempotency-Key.',
146
+ tags: ['apply']
147
+ },
148
+ getDeployStatus: {
149
+ summary: 'Read deployment status',
150
+ description: 'Poll the durable Miso deployment accepted by runDeploySystem. Read-only proxy; includes heartbeat (updatedAt) and, for qualified Connected Systems, a nested qualification/promotion summary.',
141
151
  tags: ['apply']
142
152
  },
143
153
  runDownload: {
@@ -8,27 +8,33 @@
8
8
 
9
9
  'use strict';
10
10
 
11
+ /**
12
+ * Per-handler {envVar, defaultMs}. Plan 191.0 task 3: runUpload/runDeploySystem are accept-only
13
+ * (202) — local validation + manifest build + one accept HTTP call, never the qualification
14
+ * ladder or outer deployment — so their budget shrunk from 300000 (the old
15
+ * blocking-on-the-full-ladder value). Their status-read siblings are short, single-proxy reads.
16
+ * @type {Readonly<Record<string, { envVar: string, defaultMs: number }>>}
17
+ */
18
+ const HANDLER_TIMEOUT_CONFIG = Object.freeze({
19
+ runUpload: { envVar: 'MAX_UPLOAD_TIMEOUT_MS', defaultMs: 45000 },
20
+ getUploadStatus: { envVar: 'MAX_UPLOAD_STATUS_TIMEOUT_MS', defaultMs: 15000 },
21
+ runDeploySystem: { envVar: 'MAX_DEPLOY_TIMEOUT_MS', defaultMs: 45000 },
22
+ getDeployStatus: { envVar: 'MAX_DEPLOY_STATUS_TIMEOUT_MS', defaultMs: 15000 },
23
+ runDownload: { envVar: 'MAX_DOWNLOAD_TIMEOUT_MS', defaultMs: 300000 },
24
+ runTest: { envVar: 'MAX_TEST_E2E_TIMEOUT_MS', defaultMs: 120000 },
25
+ runCertifyPillar: { envVar: 'MAX_CERTIFY_TIMEOUT_MS', defaultMs: 120000 }
26
+ });
27
+
11
28
  /**
12
29
  * @param {string} handlerId
13
30
  * @returns {number}
14
31
  */
15
32
  function getTimeoutMsForHandler(handlerId) {
16
- if (handlerId === 'runUpload') {
17
- return Number(process.env.MAX_UPLOAD_TIMEOUT_MS || 300000);
18
- }
19
- if (handlerId === 'runDeploySystem') {
20
- return Number(process.env.MAX_DEPLOY_TIMEOUT_MS || 300000);
21
- }
22
- if (handlerId === 'runDownload') {
23
- return Number(process.env.MAX_DOWNLOAD_TIMEOUT_MS || 300000);
24
- }
25
- if (handlerId === 'runTest') {
26
- return Number(process.env.MAX_TEST_E2E_TIMEOUT_MS || 120000);
27
- }
28
- if (handlerId === 'runCertifyPillar') {
29
- return Number(process.env.MAX_CERTIFY_TIMEOUT_MS || 120000);
33
+ const config = HANDLER_TIMEOUT_CONFIG[handlerId];
34
+ if (!config) {
35
+ return Number(process.env.MAX_REQUEST_TIMEOUT_MS || 120000);
30
36
  }
31
- return Number(process.env.MAX_REQUEST_TIMEOUT_MS || 120000);
37
+ return Number(process.env[config.envVar] || config.defaultMs);
32
38
  }
33
39
 
34
40
  /**
@@ -19,6 +19,8 @@ const { runRepair } = require('./run-repair');
19
19
  const { runValidate } = require('./run-validate');
20
20
  const { runPreviewUpload, runUpload } = require('./run-upload');
21
21
  const { runDeploySystem } = require('./run-deploy');
22
+ const { getUploadStatus } = require('./get-upload-status');
23
+ const { getDeployStatus } = require('./get-deploy-status');
22
24
  const { runDownload } = require('./run-download');
23
25
  const { runProtectionUpload, runProtectionCreate } = require('./run-protection');
24
26
  const { runTest } = require('./run-test');
@@ -157,6 +159,8 @@ const HANDLER_MAP = {
157
159
  probe: body.probe === true,
158
160
  minimal: true
159
161
  }),
162
+ getUploadStatus: (params, auth) =>
163
+ getUploadStatus(buildContext(auth, params.systemKey), params.jobId),
160
164
  runDeploySystem: (params, auth, body) =>
161
165
  runDeploySystem(buildContext(auth, params.systemKey), {
162
166
  gate: body.gate,
@@ -165,6 +169,8 @@ const HANDLER_MAP = {
165
169
  sync: body.sync === true,
166
170
  verbose: body.verbose === true
167
171
  }),
172
+ getDeployStatus: (params, auth) =>
173
+ getDeployStatus(buildContext(auth, params.systemKey), params.deploymentId),
168
174
  runDownload: (params, auth, body = {}) =>
169
175
  runDownload(buildContext(auth, params.systemKey), {
170
176
  force: body.force === true,
@@ -12,6 +12,7 @@ const { deployExternalSystem } = require('../external-system/deploy');
12
12
  const { runWithWorkspaceContext } = require('./workspace-context');
13
13
  const { mergeProgrammaticOptions } = require('./command-options');
14
14
  const { touchWorkspaceMeta } = require('./workspace-meta');
15
+ const { createHttpAcceptedResult } = require('./http-accepted-response');
15
16
 
16
17
  /**
17
18
  * @param {unknown} gate
@@ -39,9 +40,11 @@ function attachDeployStatus(err) {
39
40
  }
40
41
 
41
42
  /**
43
+ * Builder-api web callers never block on the outer Miso deployment (plan 191.0 task 3) — accept
44
+ * only, return 202 with the deployment id immediately; poll via getDeployStatus.
42
45
  * @param {import('./workspace-context').WorkspaceContext} ctx
43
46
  * @param {Object} [options]
44
- * @param {string} [options.gate] - Same as CLI --gate (operations,trust,governance,full)
47
+ * @param {string} [options.gate] - Same as CLI --gate (operations,trust,governance,full); now a no-op notice, kept for compatibility.
45
48
  * @param {string} [options.subjectEmail]
46
49
  * @param {boolean} [options.probe]
47
50
  * @param {boolean} [options.sync]
@@ -55,13 +58,14 @@ async function runDeploySystem(ctx, options = {}) {
55
58
  subjectEmail: options.subjectEmail,
56
59
  probe: options.probe === true,
57
60
  sync: options.sync === true,
58
- verbose: options.verbose === true
61
+ verbose: options.verbose === true,
62
+ poll: false
59
63
  });
60
64
  return runWithWorkspaceContext(ctx, async() => {
61
65
  try {
62
66
  const result = await deployExternalSystem(ctx.systemKey, merged);
63
67
  touchWorkspaceMeta(ctx, { lastOperation: 'deploy' });
64
- return result && typeof result === 'object' ? result : { deployed: true };
68
+ return createHttpAcceptedResult(result && typeof result === 'object' ? result : { deployed: true });
65
69
  } catch (err) {
66
70
  throw attachDeployStatus(err);
67
71
  }
@@ -12,8 +12,11 @@ const { uploadExternalSystem } = require('../commands/upload');
12
12
  const { runWithWorkspaceContext } = require('./workspace-context');
13
13
  const { mergeProgrammaticOptions } = require('./command-options');
14
14
  const { touchWorkspaceMeta } = require('./workspace-meta');
15
+ const { createHttpAcceptedResult } = require('./http-accepted-response');
15
16
 
16
17
  /**
18
+ * Builder-api web callers never block on the qualification ladder (plan 191.0 task 3) — always
19
+ * submit async and return 202 with the resumable job id immediately; poll via getUploadStatus.
17
20
  * @param {import('./workspace-context').WorkspaceContext} ctx
18
21
  * @param {Object} [options]
19
22
  * @param {boolean} [options.force]
@@ -24,16 +27,17 @@ const { touchWorkspaceMeta } = require('./workspace-meta');
24
27
  * @returns {Promise<Object|void>}
25
28
  */
26
29
  async function runUpload(ctx, options = {}) {
27
- const merged = mergeProgrammaticOptions(ctx, options);
30
+ const merged = mergeProgrammaticOptions(ctx, { ...options, wait: false });
28
31
  return runWithWorkspaceContext(ctx, async() => {
29
32
  const result = await uploadExternalSystem(ctx.systemKey, merged);
30
- if (!options.dryRun) {
31
- touchWorkspaceMeta(ctx, {
32
- lastOperation: 'upload',
33
- lastUploadId: result?.uploadId || null
34
- });
33
+ if (options.dryRun) {
34
+ return result;
35
35
  }
36
- return result;
36
+ touchWorkspaceMeta(ctx, {
37
+ lastOperation: 'upload',
38
+ lastUploadId: result?.jobId || null
39
+ });
40
+ return createHttpAcceptedResult(result);
37
41
  });
38
42
  }
39
43