@aifabrix/builder 2.46.0 → 2.47.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 (175) hide show
  1. package/.npmrc.token +1 -0
  2. package/.temp/jest-protection-convert/run-IFN2nv/.protection/hubspot-companies.json +1 -0
  3. package/.temp/jest-protection-convert/run-IvmKLO/.protection/hubspot-companies.yaml +17 -0
  4. package/.temp/jest-protection-convert/run-SdvblF/.protection/hubspot-companies.json +1 -0
  5. package/.temp/jest-protection-convert/run-b51TsW/.protection/hubspot-companies.json +1 -0
  6. package/.temp/jest-protection-convert/run-fiLmb1/.protection/hubspot-companies.json +1 -0
  7. package/.temp/jest-protection-convert/run-qYGHMU/.protection/hubspot-companies.yaml +17 -0
  8. package/.temp/jest-protection-fixtures/hubspot-Mq5re8/hubspot-companies.yaml +17 -0
  9. package/.temp/jest-protection-fixtures/hubspot-f3u4YL/hubspot-companies.yaml +17 -0
  10. package/.temp/jest-protection-fixtures/hubspot-iQtd1O/hubspot-companies.yaml +17 -0
  11. package/.temp/jest-protection-fixtures/hubspot-mdmz5M/hubspot-companies.yaml +17 -0
  12. package/.temp/jest-protection-fixtures/hubspot-qbKYxQ/hubspot-companies.yaml +17 -0
  13. package/.temp/jest-protection-fixtures/hubspot-yzlJy6/hubspot-companies.yaml +17 -0
  14. package/.temp/validation/summary.txt +5 -0
  15. package/jest.isolated-projects.js +18 -2
  16. package/jest.projects.js +24 -0
  17. package/lib/api/dataplane-health.api.js +19 -7
  18. package/lib/api/lifecycle.api.js +22 -1
  19. package/lib/api/resource-types.api.js +107 -0
  20. package/lib/api/runtime-configuration.api.js +72 -0
  21. package/lib/api/types/resource-types.types.js +45 -0
  22. package/lib/api/user-groups.api.js +9 -9
  23. package/lib/api/users.api.js +8 -8
  24. package/lib/api/wizard.api.js +10 -2
  25. package/lib/app/down.js +58 -26
  26. package/lib/app/index.js +2 -2
  27. package/lib/app/run-resolve-image.js +2 -1
  28. package/lib/app/run-stop-containers.js +113 -0
  29. package/lib/app/run.js +1 -31
  30. package/lib/app/show-display.js +35 -0
  31. package/lib/app/show.js +32 -1
  32. package/lib/build/index.js +17 -5
  33. package/lib/build/miso-controller-npm-sdk-guard.js +25 -0
  34. package/lib/channels/add-channel.js +348 -0
  35. package/lib/channels/channel-artifact-generator.js +141 -0
  36. package/lib/channels/channel-audit.js +101 -0
  37. package/lib/channels/channel-auth-context.js +37 -0
  38. package/lib/channels/channel-credential.js +200 -0
  39. package/lib/channels/channel-display-name.js +64 -0
  40. package/lib/channels/channel-external-system.js +106 -0
  41. package/lib/channels/channel-integration-generator.js +274 -0
  42. package/lib/channels/channel-probe.js +89 -0
  43. package/lib/channels/channel-runtime-resolver.js +152 -0
  44. package/lib/channels/channel-status-display.js +141 -0
  45. package/lib/channels/channel-targets.js +115 -0
  46. package/lib/cli/index.js +16 -4
  47. package/lib/cli/setup-app.js +54 -3
  48. package/lib/cli/setup-infra-up-dataplane-action.js +2 -2
  49. package/lib/cli/setup-infra-up-platform-action.js +2 -1
  50. package/lib/cli/setup-platform.js +1 -1
  51. package/lib/cli/setup-utility-help-after.js +4 -1
  52. package/lib/cli/setup-utility-resolve.js +8 -5
  53. package/lib/commands/app-logs.js +54 -26
  54. package/lib/commands/app.js +41 -0
  55. package/lib/commands/auth-status-dataplane-version.js +97 -61
  56. package/lib/commands/auth-status.js +2 -7
  57. package/lib/commands/channel.js +58 -0
  58. package/lib/commands/datasource.js +1 -1
  59. package/lib/commands/identity-apply-sync.js +49 -8
  60. package/lib/commands/identity-group-cli.js +66 -26
  61. package/lib/commands/identity-membership-role-cache.js +58 -37
  62. package/lib/commands/identity-shared.js +22 -1
  63. package/lib/commands/identity-user-cli.js +80 -34
  64. package/lib/commands/repair-auth-apply.js +30 -4
  65. package/lib/commands/repair-auth-config.js +8 -13
  66. package/lib/commands/repair-datasource-com-v2.js +15 -0
  67. package/lib/commands/repair-datasource-service-contract.js +206 -0
  68. package/lib/commands/repair-datasource.js +53 -18
  69. package/lib/commands/repair-env-template.js +12 -12
  70. package/lib/commands/repair-openapi-sync.js +26 -4
  71. package/lib/commands/repair-steps.js +28 -13
  72. package/lib/commands/repair-system-alignment.js +7 -4
  73. package/lib/commands/resource-type.js +371 -0
  74. package/lib/commands/setup-modes.js +1 -1
  75. package/lib/commands/setup-prompts-platform-mode.js +24 -21
  76. package/lib/commands/test-trust-external.js +39 -90
  77. package/lib/commands/up-common.js +33 -1
  78. package/lib/commands/up-dataplane.js +8 -4
  79. package/lib/commands/upload.js +24 -3
  80. package/lib/commands/verify-trust-command-action.js +4 -1
  81. package/lib/commands/verify-trust-external.js +12 -20
  82. package/lib/core/config-setup-platform-mode.js +3 -3
  83. package/lib/core/setup-platform-mode.js +41 -6
  84. package/lib/datasource/capability/capability-diff-slice.js +2 -2
  85. package/lib/datasource/capability/capability-manifest.js +254 -0
  86. package/lib/datasource/capability/capability-resolve.js +3 -4
  87. package/lib/datasource/capability/copy-operations.js +5 -3
  88. package/lib/datasource/capability/remove-operations.js +2 -1
  89. package/lib/datasource/capability/run-capability-copy.js +32 -4
  90. package/lib/datasource/capability/run-capability-diff.js +3 -3
  91. package/lib/datasource/capability/run-capability-dimension.js +2 -4
  92. package/lib/datasource/capability/run-capability-edit.js +4 -7
  93. package/lib/datasource/capability/run-capability-relate.js +2 -4
  94. package/lib/datasource/capability/run-capability-remove.js +2 -4
  95. package/lib/datasource/capability/validate-capability-slice.js +2 -1
  96. package/lib/datasource/datasource-identifier.js +2 -1
  97. package/lib/datasource/datasource-validate-display.js +1 -1
  98. package/lib/datasource/field-reference-validator.js +24 -3
  99. package/lib/datasource/orphan-profiles-validator.js +98 -0
  100. package/lib/datasource/validate.js +41 -23
  101. package/lib/external-system/download-helpers.js +87 -0
  102. package/lib/external-system/download.js +61 -122
  103. package/lib/external-system/generator.js +1 -59
  104. package/lib/external-system/test.js +10 -15
  105. package/lib/generator/builders.js +11 -1
  106. package/lib/generator/external-controller-manifest.js +5 -2
  107. package/lib/generator/split.js +3 -1
  108. package/lib/generator/wizard.js +1 -28
  109. package/lib/identity/fk-reference.js +65 -0
  110. package/lib/identity/identity-apply-core.js +13 -58
  111. package/lib/identity/identity-apply-phases.js +5 -1
  112. package/lib/identity/identity-display.js +243 -0
  113. package/lib/identity/identity-response-helpers.js +52 -0
  114. package/lib/identity/identity-sync-errors.js +62 -0
  115. package/lib/identity/resolve-user-id.js +129 -0
  116. package/lib/identity/username-default.js +31 -0
  117. package/lib/lifecycle/certification-progress.js +2 -2
  118. package/lib/lifecycle/report-display-trust.js +70 -0
  119. package/lib/lifecycle/report-display.js +14 -13
  120. package/lib/resolvers/datasource-resolver.js +2 -3
  121. package/lib/resolvers/resource-type-file.js +159 -0
  122. package/lib/schema/application-schema.json +16 -0
  123. package/lib/schema/deployment-rules.yaml +2 -1
  124. package/lib/schema/external-datasource.schema.json +372 -58
  125. package/lib/schema/external-system.schema.json +331 -2
  126. package/lib/schema/type/document-storage.json +9 -5
  127. package/lib/utils/app-run-containers.js +25 -2
  128. package/lib/utils/authentication-shape.js +224 -0
  129. package/lib/utils/build-copy.js +36 -5
  130. package/lib/utils/build-resolve-image.js +66 -12
  131. package/lib/utils/celery-companion-apps.js +53 -0
  132. package/lib/utils/cli-utils.js +4 -0
  133. package/lib/utils/compose-celery-worker.js +23 -0
  134. package/lib/utils/compose-generate-docker-compose.js +9 -1
  135. package/lib/utils/configuration-env-resolver.js +36 -0
  136. package/lib/utils/credential-secrets-env-kv.js +216 -0
  137. package/lib/utils/credential-secrets-env.js +52 -262
  138. package/lib/utils/dataplane-resolver.js +4 -115
  139. package/lib/utils/declarative-url-ports.js +24 -1
  140. package/lib/utils/docker-build.js +1 -4
  141. package/lib/utils/external-env-template.js +10 -3
  142. package/lib/utils/external-system-validators.js +8 -2
  143. package/lib/utils/help-builder.js +2 -0
  144. package/lib/utils/paths.js +25 -0
  145. package/lib/utils/platform-controller-url.js +2 -1
  146. package/lib/utils/platform-kv-ref.js +57 -0
  147. package/lib/utils/runtime-configuration-download.js +189 -0
  148. package/lib/utils/runtime-configuration-values.js +119 -0
  149. package/lib/utils/schema-loader.js +19 -4
  150. package/lib/utils/worker-sidecars.js +142 -0
  151. package/lib/validation/external-manifest-validator.js +2 -0
  152. package/lib/validation/runtime-configuration-rules.js +98 -0
  153. package/lib/validation/validate-display-dimensions.js +154 -0
  154. package/lib/validation/validate-display-sections.js +276 -0
  155. package/lib/validation/validate-display-steps.js +67 -0
  156. package/lib/validation/validate-display.js +24 -402
  157. package/package.json +1 -1
  158. package/templates/applications/dataplane/application.yaml +5 -0
  159. package/templates/applications/dataplane/env.template +26 -13
  160. package/templates/applications/dataplane/rbac.yaml +108 -1
  161. package/templates/applications/miso-controller/application.yaml +2 -2
  162. package/templates/applications/miso-controller/env.template +37 -122
  163. package/templates/applications/miso-controller/rbac.yaml +28 -13
  164. package/templates/channels/chatgpt/install.template.md.hbs +49 -0
  165. package/templates/channels/chatgpt/manifest.template.json.hbs +9 -0
  166. package/templates/channels/microsoft-copilot/install.template.md.hbs +49 -0
  167. package/templates/channels/microsoft-copilot/manifest.template.json.hbs +8 -0
  168. package/templates/channels/slack/install.template.md.hbs +49 -0
  169. package/templates/channels/slack/manifest.template.json.hbs +66 -0
  170. package/templates/channels/teams-bot/install.template.md.hbs +49 -0
  171. package/templates/channels/teams-bot/manifest.template.json.hbs +13 -0
  172. package/templates/channels/web-embed/install.template.md.hbs +49 -0
  173. package/templates/channels/web-embed/manifest.template.json.hbs +8 -0
  174. package/templates/python/docker-compose.hbs +56 -0
  175. package/templates/typescript/docker-compose.hbs +52 -0
@@ -0,0 +1,206 @@
1
+ /**
2
+ * serviceContract repair helpers — migrate deprecated none+llm manifests (439.1).
3
+ *
4
+ * @fileoverview repair-datasource-service-contract
5
+ * @author AI Fabrix Team
6
+ * @version 1.0.0
7
+ */
8
+
9
+ 'use strict';
10
+
11
+ const LLM_CANONICAL_METADATA_SCHEMA = {
12
+ type: 'object',
13
+ properties: {
14
+ successContent: { type: 'string', nullable: true },
15
+ successEmbedding: {
16
+ type: 'array',
17
+ items: { type: 'number' },
18
+ nullable: true
19
+ },
20
+ successRole: { type: 'string', nullable: true },
21
+ successModel: { type: 'string', nullable: true },
22
+ successFinishReason: { type: 'string', nullable: true },
23
+ errorCode: { type: 'string', nullable: true },
24
+ errorMessage: { type: 'string', nullable: true },
25
+ errorType: { type: 'string', nullable: true },
26
+ usagePromptTokens: { type: 'integer', nullable: true },
27
+ usageCompletionTokens: { type: 'integer', nullable: true },
28
+ usageTotalTokens: { type: 'integer', nullable: true },
29
+ metadataProvider: { type: 'string', nullable: true },
30
+ metadataOperation: { type: 'string', nullable: true }
31
+ }
32
+ };
33
+
34
+ const LLM_CANONICAL_EXPOSED_SCHEMA = {
35
+ success: {
36
+ content: 'metadata.successContent',
37
+ embedding: 'metadata.successEmbedding',
38
+ role: 'metadata.successRole',
39
+ model: 'metadata.successModel',
40
+ finishReason: 'metadata.successFinishReason'
41
+ },
42
+ error: {
43
+ code: 'metadata.errorCode',
44
+ message: 'metadata.errorMessage',
45
+ type: 'metadata.errorType'
46
+ },
47
+ usage: {
48
+ promptTokens: 'metadata.usagePromptTokens',
49
+ completionTokens: 'metadata.usageCompletionTokens',
50
+ totalTokens: 'metadata.usageTotalTokens'
51
+ },
52
+ metadata: {
53
+ provider: 'metadata.metadataProvider',
54
+ operation: 'metadata.metadataOperation'
55
+ }
56
+ };
57
+
58
+ const LLM_STUB_FIELD_MAPPINGS = {
59
+ successContent: { expression: '{{raw}}' },
60
+ metadataProvider: { expression: '{{inline.metadataProvider}}' },
61
+ metadataOperation: { expression: '{{inline.metadataOperation}}' }
62
+ };
63
+
64
+ /**
65
+ * @param {Object} parsed - Parsed datasource manifest
66
+ * @returns {boolean}
67
+ */
68
+ function isDeprecatedNoneLlmManifest(parsed) {
69
+ return parsed?.entityType === 'none' && parsed?.resourceType === 'llm';
70
+ }
71
+
72
+ /**
73
+ * @param {Object} parsed
74
+ * @param {string[]} changes
75
+ * @returns {boolean}
76
+ */
77
+ function stripStorageKeysForServiceContract(parsed, changes) {
78
+ let updated = false;
79
+ for (const key of ['primaryKey', 'labelKey', 'sync']) {
80
+ if (parsed[key] !== undefined) {
81
+ delete parsed[key];
82
+ changes.push(`Removed ${key} (not allowed on serviceContract)`);
83
+ updated = true;
84
+ }
85
+ }
86
+ return updated;
87
+ }
88
+
89
+ /**
90
+ * @param {Object} parsed
91
+ * @param {string} systemKey
92
+ * @param {string[]} changes
93
+ * @returns {boolean}
94
+ */
95
+ function ensureLlmCipMapSteps(parsed, systemKey, changes) {
96
+ const operations = parsed?.execution?.cip?.operations;
97
+ if (!operations || typeof operations !== 'object') return false;
98
+ let updated = false;
99
+ for (const opKey of ['call', 'embed']) {
100
+ const op = operations[opKey];
101
+ if (!op || !Array.isArray(op.steps)) continue;
102
+ if (op.steps.some((step) => step && step.map)) continue;
103
+ const fetchIdx = op.steps.findIndex((step) => step && step.fetch);
104
+ if (fetchIdx < 0) continue;
105
+ const mapStep = {
106
+ map: {
107
+ useFieldMappings: true,
108
+ inputPath: '$',
109
+ inline: {
110
+ metadataProvider: systemKey || parsed.systemKey || 'provider',
111
+ metadataOperation: opKey
112
+ }
113
+ }
114
+ };
115
+ op.steps.splice(fetchIdx + 1, 0, mapStep);
116
+ if (!op.steps.some((step) => step && step.output)) {
117
+ op.steps.push({ output: { mode: 'records' } });
118
+ }
119
+ changes.push(`Inserted map+output steps for CIP operation "${opKey}"`);
120
+ updated = true;
121
+ }
122
+ return updated;
123
+ }
124
+
125
+ /**
126
+ * @param {Object} parsed
127
+ * @param {string[]} changes
128
+ * @returns {boolean}
129
+ */
130
+ function stripDeprecatedServiceCategory(parsed, changes) {
131
+ if (parsed?.serviceCategory === undefined) return false;
132
+ delete parsed.serviceCategory;
133
+ changes.push('Removed deprecated serviceCategory (use resourceType for classification)');
134
+ return true;
135
+ }
136
+
137
+ /**
138
+ * @param {*} value
139
+ * @returns {*}
140
+ */
141
+ function deepClone(value) {
142
+ return JSON.parse(JSON.stringify(value));
143
+ }
144
+
145
+ /**
146
+ * @param {Object} parsed
147
+ * @param {string[]} changes
148
+ * @returns {boolean}
149
+ */
150
+ function applyCanonicalLlmSchemaStubs(parsed, changes) {
151
+ parsed.entityType = 'serviceContract';
152
+ changes.push('Migrated entityType none → serviceContract');
153
+
154
+ parsed.metadataSchema = deepClone(LLM_CANONICAL_METADATA_SCHEMA);
155
+ changes.push('Set canonical LLM metadataSchema stub');
156
+
157
+ if (!parsed.exposed) parsed.exposed = {};
158
+ parsed.exposed.schema = deepClone(LLM_CANONICAL_EXPOSED_SCHEMA);
159
+ if (parsed.exposed.attributes !== undefined) {
160
+ delete parsed.exposed.attributes;
161
+ }
162
+ changes.push('Set canonical LLM exposed.schema envelope');
163
+ return true;
164
+ }
165
+
166
+ /**
167
+ * @param {Object} parsed
168
+ * @param {string[]} changes
169
+ * @returns {boolean}
170
+ */
171
+ function applyStubFieldMappingsIfMissing(parsed, changes) {
172
+ const attrs = parsed.fieldMappings?.attributes;
173
+ if (attrs && typeof attrs === 'object' && Object.keys(attrs).length > 0) {
174
+ return false;
175
+ }
176
+ if (!parsed.fieldMappings) parsed.fieldMappings = {};
177
+ parsed.fieldMappings.attributes = deepClone(LLM_STUB_FIELD_MAPPINGS);
178
+ changes.push(
179
+ 'Added stub fieldMappings.attributes — customize provider raw.* expressions'
180
+ );
181
+ return true;
182
+ }
183
+
184
+ /**
185
+ * Migrate deprecated none+llm manifest to serviceContract canonical stub.
186
+ *
187
+ * @param {Object} parsed - Parsed datasource (mutated)
188
+ * @param {string[]} changes - Change log
189
+ * @returns {boolean}
190
+ */
191
+ function repairNoneLlmToServiceContract(parsed, changes) {
192
+ if (!isDeprecatedNoneLlmManifest(parsed)) return false;
193
+ let updated = applyCanonicalLlmSchemaStubs(parsed, changes);
194
+ updated = applyStubFieldMappingsIfMissing(parsed, changes) || updated;
195
+ updated = stripStorageKeysForServiceContract(parsed, changes) || updated;
196
+ updated = ensureLlmCipMapSteps(parsed, parsed.systemKey, changes) || updated;
197
+ return updated;
198
+ }
199
+
200
+ module.exports = {
201
+ LLM_CANONICAL_METADATA_SCHEMA,
202
+ LLM_CANONICAL_EXPOSED_SCHEMA,
203
+ isDeprecatedNoneLlmManifest,
204
+ stripDeprecatedServiceCategory,
205
+ repairNoneLlmToServiceContract
206
+ };
@@ -12,6 +12,12 @@
12
12
  const { repairOpenapiSection } = require('./repair-datasource-openapi');
13
13
  const { normalizeAutoRbacOperationKeys } = require('./repair-datasource-auto-rbac');
14
14
  const { repairTestPayload } = require('./repair-datasource-test-payload');
15
+ const { repairComV2Manifest } = require('./repair-datasource-com-v2');
16
+ const {
17
+ isDeprecatedNoneLlmManifest,
18
+ repairNoneLlmToServiceContract,
19
+ stripDeprecatedServiceCategory
20
+ } = require('./repair-datasource-service-contract');
15
21
 
16
22
  const DEFAULT_SYNC = {
17
23
  mode: 'pull',
@@ -380,6 +386,41 @@ function sanitizeTestPayloadTopLevel(parsed, changes) {
380
386
  return true;
381
387
  }
382
388
 
389
+ /**
390
+ * @param {Object} parsed
391
+ * @param {Object} options
392
+ * @returns {boolean}
393
+ */
394
+ function shouldApplyServiceContractRepair(parsed, options) {
395
+ return (
396
+ isDeprecatedNoneLlmManifest(parsed) ||
397
+ (options.serviceContract && parsed?.resourceType === 'llm')
398
+ );
399
+ }
400
+
401
+ /**
402
+ * @param {Object} parsed
403
+ * @param {Object} options
404
+ * @param {boolean} none
405
+ * @param {string[]} changes
406
+ * @returns {boolean}
407
+ */
408
+ function applyOptionalDatasourceRepairs(parsed, options, none, changes) {
409
+ let updated = false;
410
+ if (options.expose) {
411
+ updated = repairExposeFromAttributes(parsed, changes) || updated;
412
+ }
413
+ if (!none && options.sync) {
414
+ updated = repairSyncSection(parsed, changes) || updated;
415
+ }
416
+ if (options.test) {
417
+ sanitizeTestPayloadTopLevel(parsed, changes);
418
+ updated = repairTestPayload(parsed, changes) || updated;
419
+ updated = sanitizeTestPayloadTopLevel(parsed, changes) || updated;
420
+ }
421
+ return updated;
422
+ }
423
+
383
424
  /**
384
425
  * Runs all requested datasource repairs.
385
426
  *
@@ -390,32 +431,24 @@ function sanitizeTestPayloadTopLevel(parsed, changes) {
390
431
  */
391
432
  function repairDatasourceFile(parsed, options = {}, changes = []) {
392
433
  const out = Array.isArray(changes) ? changes : [];
393
- let updated = false;
394
- const none = isNoneEntityType(parsed?.entityType);
434
+ let updated = stripDeprecatedServiceCategory(parsed, out);
395
435
 
396
- updated = applyBaseDatasourceRepairs(parsed, none, out) || updated;
397
- updated = applyOpenapiDatasourceRepairs(parsed, out) || updated;
398
-
399
- if (options.expose) {
400
- updated = repairExposeFromAttributes(parsed, out) || updated;
436
+ if (shouldApplyServiceContractRepair(parsed, options)) {
437
+ updated = repairNoneLlmToServiceContract(parsed, out) || updated;
401
438
  }
402
439
 
403
- if (!none && options.sync) {
404
- updated = repairSyncSection(parsed, out) || updated;
405
- }
440
+ const none = isNoneEntityType(parsed?.entityType);
406
441
 
407
- if (options.test) {
408
- sanitizeTestPayloadTopLevel(parsed, out);
409
- updated = repairTestPayload(parsed, out) || updated;
410
- updated = sanitizeTestPayloadTopLevel(parsed, out) || updated;
411
- }
442
+ updated = applyBaseDatasourceRepairs(parsed, none, out) || updated;
443
+ updated = applyOpenapiDatasourceRepairs(parsed, out) || updated;
444
+ updated = applyOptionalDatasourceRepairs(parsed, options, none, out) || updated;
412
445
 
413
446
  return { updated, changes: out };
414
447
  }
415
448
 
416
449
  function applyBaseDatasourceRepairs(parsed, none, changes) {
417
- if (none) return false;
418
- let updated = false;
450
+ let updated = repairComV2Manifest(parsed, changes);
451
+ if (none) return updated;
419
452
  updated = repairDimensionBindingShape(parsed, changes) || updated;
420
453
  updated = repairRootDimensionsFromAttributes(parsed, changes) || updated;
421
454
  updated = repairMetadataSchemaFromAttributes(parsed, changes) || updated;
@@ -444,5 +477,7 @@ module.exports = {
444
477
  DEFAULT_SYNC,
445
478
  MINIMAL_METADATA_SCHEMA,
446
479
  TEST_PAYLOAD_TOP_LEVEL_ALLOW,
447
- isNoneEntityType
480
+ isNoneEntityType,
481
+ isDeprecatedNoneLlmManifest,
482
+ repairNoneLlmToServiceContract
448
483
  };
@@ -77,9 +77,16 @@ function addFromConfiguration(effective, config, prefix, seenNames, systemKey) {
77
77
  * @param {string} systemKey - System key for path namespace
78
78
  */
79
79
  function addFromAuthSecurity(effective, systemParsed, prefix, seenNames, systemKey) {
80
- const security = systemParsed.authentication?.security;
80
+ const { getAuthCredentialTemplate } = require('../utils/authentication-shape');
81
+ const { isPlatformCatalogKvRef } = require('../utils/platform-kv-ref');
82
+ const credential = getAuthCredentialTemplate(systemParsed.authentication);
83
+ const security = credential?.security ?? systemParsed.authentication?.security;
81
84
  if (!security || typeof security !== 'object') return;
82
85
  for (const key of Object.keys(security)) {
86
+ const securityVal = security[key];
87
+ if (typeof securityVal === 'string' && isPlatformCatalogKvRef(securityVal)) {
88
+ continue;
89
+ }
83
90
  const envName = `KV_${prefix}_${securityKeyToVar(key)}`;
84
91
  if (seenNames.has(envName)) continue;
85
92
  const pathVal = kvEnvKeyToPath(envName, systemKey);
@@ -316,16 +323,7 @@ function repairEnvTemplate(appPath, systemParsed, systemKey, dryRun, changes, ba
316
323
  return true;
317
324
  }
318
325
 
319
- /**
320
- * Returns true if a kv value looks like legacy format (KeyVault suffix or no path segments).
321
- * @param {string} val - Value from authentication.security or configuration
322
- * @returns {boolean}
323
- */
324
- function isLegacyKvValue(val) {
325
- if (typeof val !== 'string' || !val.trim().toLowerCase().startsWith('kv://')) return false;
326
- const after = val.trim().slice(5); // after 'kv://'
327
- return after.includes('KeyVault') || !after.includes('/');
328
- }
326
+ const { isLegacyKvValue } = require('../utils/platform-kv-ref');
329
327
 
330
328
  /**
331
329
  * Normalizes authentication.security values to path-style kv:// (kv://systemKey/variable).
@@ -392,7 +390,9 @@ function normalizeConfigurationSection(config, prefix, systemKey, changes) {
392
390
  function normalizeSystemFileAuthAndConfig(systemParsed, systemKey, changes) {
393
391
  const prefix = systemKeyToKvPrefix(systemKey);
394
392
  if (!prefix) return false;
395
- const security = systemParsed.authentication?.security;
393
+ const { getAuthCredentialTemplate } = require('../utils/authentication-shape');
394
+ const credential = getAuthCredentialTemplate(systemParsed.authentication);
395
+ const security = credential?.security ?? systemParsed.authentication?.security;
396
396
  let updated = (security && typeof security === 'object' && normalizeSecuritySection(security, prefix, systemKey, changes));
397
397
  const config = systemParsed.configuration;
398
398
  if (Array.isArray(config)) {
@@ -15,10 +15,15 @@ const path = require('path');
15
15
  const fs = require('fs');
16
16
 
17
17
  const { resolveControllerUrl } = require('../utils/controller-url');
18
- const { getDeploymentAuth, requireBearerForDataplanePipeline } = require('../utils/token-manager');
18
+ const {
19
+ getDeploymentAuth,
20
+ requireBearerForDataplanePipeline,
21
+ applyLabDataplaneApiKeyBearer
22
+ } = require('../utils/token-manager');
19
23
  const { resolveDataplaneUrl } = require('../utils/dataplane-resolver');
20
24
  const { uploadFileAs } = require('../utils/file-upload');
21
25
  const { listOpenAPIFiles } = require('../api/external-systems.api');
26
+ const { resolveLabDataplaneApiKey } = require('../utils/credential-secrets-env');
22
27
 
23
28
  async function fileExistsAsync(filePath) {
24
29
  try {
@@ -29,11 +34,25 @@ async function fileExistsAsync(filePath) {
29
34
  }
30
35
  }
31
36
 
32
- async function resolveDataplaneAndAuth(systemKey) {
37
+ function authForJwtOnlyDataplaneRoutes(authConfig) {
38
+ const copy = { ...(authConfig || {}) };
39
+ if (copy.type === 'client-token' && resolveLabDataplaneApiKey()) {
40
+ return applyLabDataplaneApiKeyBearer(copy);
41
+ }
42
+ return copy;
43
+ }
44
+
45
+ async function resolveDataplaneAndAuth(systemKey, preResolved = {}) {
46
+ if (preResolved.dataplaneUrl && preResolved.authConfig) {
47
+ const authConfig = authForJwtOnlyDataplaneRoutes(preResolved.authConfig);
48
+ return { dataplaneUrl: preResolved.dataplaneUrl, authConfig };
49
+ }
33
50
  const { resolveEnvironment } = require('../core/config');
34
51
  const environment = await resolveEnvironment();
35
52
  const controllerUrl = await resolveControllerUrl();
36
- const authConfig = await getDeploymentAuth(controllerUrl, environment, systemKey);
53
+ const authConfig = authForJwtOnlyDataplaneRoutes(
54
+ await getDeploymentAuth(controllerUrl, environment, systemKey)
55
+ );
37
56
  requireBearerForDataplanePipeline(authConfig);
38
57
  const dataplaneUrl = await resolveDataplaneUrl(controllerUrl, environment, authConfig, { silent: true });
39
58
  return { dataplaneUrl, authConfig };
@@ -115,7 +134,10 @@ async function syncOpenApiFilesForMcp(opts) {
115
134
  const openapiDir = path.join(appPath, 'openapi');
116
135
  if (!(await fileExistsAsync(openapiDir))) return { uploaded: 0, skipped: 0 };
117
136
 
118
- const { dataplaneUrl, authConfig } = await resolveDataplaneAndAuth(systemKey);
137
+ const { dataplaneUrl, authConfig } = await resolveDataplaneAndAuth(systemKey, {
138
+ dataplaneUrl: opts.dataplaneUrl,
139
+ authConfig: opts.authConfig
140
+ });
119
141
  const existingKeys = await getExistingOpenApiKeys(dataplaneUrl, systemKey, authConfig);
120
142
  const uploadedKeys = new Set(existingKeys);
121
143
  let uploaded = 0;
@@ -26,7 +26,9 @@ const {
26
26
  buildAuthenticationForRepair,
27
27
  mergePreservedAuthVariables,
28
28
  repairAuthChangeLabel,
29
- auditRepairAuthenticationWarnings
29
+ auditRepairAuthenticationWarnings,
30
+ normalizeAuthenticationSchemaShape,
31
+ getAuthCredentialTemplate
30
32
  } = require('./repair-auth-apply');
31
33
 
32
34
  /**
@@ -45,19 +47,24 @@ function applyAuthMethod(ctx) {
45
47
  }
46
48
  const existingAuth = ctx.systemParsed.authentication || ctx.systemParsed.auth || {};
47
49
  const newAuth = buildAuthenticationForRepair(ctx.systemKey, authOption);
48
- const existingVars =
49
- existingAuth.variables && typeof existingAuth.variables === 'object'
50
- ? existingAuth.variables
51
- : {};
52
- const mergedVariables = { ...newAuth.variables };
53
- mergePreservedAuthVariables(mergedVariables, existingVars);
54
- ctx.systemParsed.authentication = {
55
- ...newAuth,
56
- variables: mergedVariables
57
- };
58
- if (existingAuth.displayName !== undefined) {
59
- ctx.systemParsed.authentication.displayName = existingAuth.displayName;
50
+ const existingCredential = getAuthCredentialTemplate(existingAuth) || {};
51
+ const mergedVariables = { ...(newAuth.credential?.variables || {}) };
52
+ mergePreservedAuthVariables(
53
+ mergedVariables,
54
+ existingCredential.variables && typeof existingCredential.variables === 'object'
55
+ ? existingCredential.variables
56
+ : existingAuth.variables
57
+ );
58
+ if (newAuth.authType === 'credential' && newAuth.credential) {
59
+ newAuth.credential.variables = mergedVariables;
60
+ if (existingCredential.displayName !== undefined) {
61
+ newAuth.credential.displayName = existingCredential.displayName;
62
+ } else if (existingAuth.displayName !== undefined) {
63
+ newAuth.credential.displayName = existingAuth.displayName;
64
+ }
60
65
  }
66
+ ctx.systemParsed.authentication = newAuth;
67
+ delete ctx.systemParsed.auth;
61
68
  ctx.changes.push(`Set authentication method to ${repairAuthChangeLabel(authOption)}`);
62
69
  return true;
63
70
  }
@@ -70,6 +77,7 @@ function applyAuthMethod(ctx) {
70
77
  function persistSystemFileRepair(ctx, flags) {
71
78
  const systemFileUpdated =
72
79
  flags.authReplaced ||
80
+ flags.authShapeNormalized ||
73
81
  flags.systemAuthConfigNormalized ||
74
82
  flags.systemDataSourcesAligned ||
75
83
  flags.authVarsRemoved;
@@ -95,6 +103,12 @@ function runRepairSteps(ctx) {
95
103
  );
96
104
  const authReplaced = applyAuthMethod(ctx);
97
105
  updated = updated || authReplaced;
106
+ const authShapeNormalized = normalizeAuthenticationSchemaShape(
107
+ ctx.systemParsed,
108
+ ctx.systemKey,
109
+ ctx.changes
110
+ );
111
+ updated = updated || authShapeNormalized;
98
112
  const systemAuthConfigNormalized = normalizeSystemFileAuthAndConfig(
99
113
  ctx.systemParsed, ctx.systemKey, ctx.changes
100
114
  );
@@ -106,6 +120,7 @@ function runRepairSteps(ctx) {
106
120
  );
107
121
  const systemFileUpdated = persistSystemFileRepair(ctx, {
108
122
  authReplaced,
123
+ authShapeNormalized,
109
124
  systemAuthConfigNormalized,
110
125
  systemDataSourcesAligned,
111
126
  authVarsRemoved
@@ -177,13 +177,16 @@ function alignSystemFileDataSources(appPath, systemParsed, datasourceFiles, syst
177
177
  function buildAuthVarNames(systemParsed, _systemKey) {
178
178
  const names = new Set();
179
179
  const auth = systemParsed.authentication;
180
- if (auth && typeof auth.variables === 'object') {
181
- for (const k of Object.keys(auth.variables)) {
180
+ if (!auth || typeof auth !== 'object') return names;
181
+ const credential =
182
+ auth.credential && typeof auth.credential === 'object' ? auth.credential : auth;
183
+ if (typeof credential.variables === 'object') {
184
+ for (const k of Object.keys(credential.variables)) {
182
185
  names.add(String(k).toUpperCase().replace(/_/g, ''));
183
186
  }
184
187
  }
185
- if (auth && typeof auth.security === 'object') {
186
- for (const k of Object.keys(auth.security)) {
188
+ if (typeof credential.security === 'object') {
189
+ for (const k of Object.keys(credential.security)) {
187
190
  names.add(securityKeyToVar(k));
188
191
  }
189
192
  }