@aifabrix/builder 2.54.1 → 2.55.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 (210) hide show
  1. package/README.md +8 -0
  2. package/lib/agent-kit/apply-ops.js +82 -0
  3. package/lib/agent-kit/checksums.js +28 -0
  4. package/lib/agent-kit/classify.js +113 -0
  5. package/lib/agent-kit/claude-shim.js +61 -0
  6. package/lib/agent-kit/constants.js +55 -0
  7. package/lib/agent-kit/file-list.js +103 -0
  8. package/lib/agent-kit/host-approve.js +130 -0
  9. package/lib/agent-kit/hosting/github.js +63 -0
  10. package/lib/agent-kit/hosts.js +71 -0
  11. package/lib/agent-kit/init.js +319 -0
  12. package/lib/agent-kit/kit-root.js +17 -0
  13. package/lib/agent-kit/managed-section.js +79 -0
  14. package/lib/agent-kit/package-load.js +45 -0
  15. package/lib/agent-kit/plan-ops.js +69 -0
  16. package/lib/agent-kit/remote-prompts.js +239 -0
  17. package/lib/agent-kit/render-host-markdown.js +40 -0
  18. package/lib/agent-kit/repo-guard.js +47 -0
  19. package/lib/agent-kit/report.js +107 -0
  20. package/lib/agent-kit/run.js +82 -0
  21. package/lib/agent-kit/scm/git.js +122 -0
  22. package/lib/agent-kit/state-file.js +83 -0
  23. package/lib/agent-kit/status.js +50 -0
  24. package/lib/agent-kit/v1-detect.js +81 -0
  25. package/lib/agent-kit/validate-kit.js +87 -0
  26. package/lib/agent-kit/workspace-name.js +40 -0
  27. package/lib/agent-kit/workspace-skeleton.js +103 -0
  28. package/lib/api/role-assistant-test-pack.api.js +86 -0
  29. package/lib/api/work-search.api.js +31 -4
  30. package/lib/api/work.api.js +19 -12
  31. package/lib/app/list-external-systems.js +2 -1
  32. package/lib/app/show-display.js +33 -6
  33. package/lib/app/show.js +25 -2
  34. package/lib/channels/add-channel.js +1 -0
  35. package/lib/channels/approval-guides/claude.js +2 -2
  36. package/lib/channels/channel-add-failure.js +1 -0
  37. package/lib/channels/channel-add-remaining.js +15 -9
  38. package/lib/channels/channel-definition-status.js +115 -0
  39. package/lib/channels/channel-description.js +2 -1
  40. package/lib/channels/channel-install-envelope.js +4 -2
  41. package/lib/channels/channel-integration-generator.js +2 -0
  42. package/lib/channels/channel-runtime-resolver.js +14 -0
  43. package/lib/channels/channel-targets.js +31 -5
  44. package/lib/channels/claude-setup-values.js +4 -1
  45. package/lib/channels/slack-channel-add.js +59 -6
  46. package/lib/channels/slack-mcp-callback.js +51 -0
  47. package/lib/channels/slack-mcp-runtime.js +156 -0
  48. package/lib/channels/slack-provisioning/install-cli.js +14 -2
  49. package/lib/channels/slack-provisioning/with-curl-on-path.js +6 -1
  50. package/lib/cli/index.js +4 -0
  51. package/lib/cli/setup-certification-commands.js +2 -2
  52. package/lib/cli/setup-certification.help.js +3 -1
  53. package/lib/commands/agent-kit-help.js +79 -0
  54. package/lib/commands/agent-kit.js +346 -0
  55. package/lib/commands/channel-add-help.js +5 -5
  56. package/lib/commands/datasource-capability-relate-cli.js +5 -4
  57. package/lib/commands/repair-auth-apply.js +1 -1
  58. package/lib/commands/repair-datasource-key-skip.js +39 -0
  59. package/lib/commands/repair-datasource-keys.js +24 -12
  60. package/lib/commands/repair-rbac.js +16 -10
  61. package/lib/commands/role-assistant-copy-output.js +61 -0
  62. package/lib/commands/role-assistant-copy.js +155 -0
  63. package/lib/commands/role-assistant-test-output.js +8 -9
  64. package/lib/commands/role-assistant-test-result-rows.js +42 -0
  65. package/lib/commands/role-assistant.js +117 -48
  66. package/lib/commands/search.js +143 -0
  67. package/lib/commands/test-trust-external.js +7 -5
  68. package/lib/commands/upload-sidecar-followups.js +4 -1
  69. package/lib/commands/verify-operations-skip-e2e.js +131 -0
  70. package/lib/commands/verify-operations-step-plan.js +6 -33
  71. package/lib/commands/verify-operations-steps.js +3 -1
  72. package/lib/datasource/capability/relate-operations.js +28 -10
  73. package/lib/datasource/capability/run-capability-relate.js +48 -25
  74. package/lib/datasource/datasource-identifier.js +13 -5
  75. package/lib/deployment/deployer-poll-run.js +117 -35
  76. package/lib/external-system/deploy-dataplane-published.js +70 -0
  77. package/lib/external-system/deploy.js +12 -2
  78. package/lib/external-system/download-role-assistant.js +41 -15
  79. package/lib/external-system/download.js +7 -1
  80. package/lib/generator/wizard-datasource-key.js +54 -0
  81. package/lib/generator/wizard.js +55 -54
  82. package/lib/integration-definition/apply-datasource-keys.js +75 -0
  83. package/lib/integration-definition/apply-relationships.js +195 -0
  84. package/lib/integration-definition/apply-static-enterprise.js +229 -0
  85. package/lib/integration-definition/apply-system-file.js +71 -0
  86. package/lib/integration-definition/apply-test-endpoint.js +89 -0
  87. package/lib/integration-definition/apply-viewpoint-defaults.js +157 -0
  88. package/lib/integration-definition/apply.js +78 -59
  89. package/lib/integration-definition/enrich-openapi-operations.js +36 -10
  90. package/lib/integration-definition/enrich-openapi-pick.js +87 -0
  91. package/lib/lifecycle/role-assistant-governance.js +56 -21
  92. package/lib/programmatic/capability-registry.js +1 -0
  93. package/lib/programmatic/index.js +2 -0
  94. package/lib/programmatic/openapi-apply-result-schemas.js +8 -0
  95. package/lib/programmatic/openapi-channel-install-schemas.js +4 -1
  96. package/lib/programmatic/openapi-component-schemas.js +1 -0
  97. package/lib/programmatic/openapi-descriptions.js +9 -3
  98. package/lib/programmatic/openapi-envelope-examples.js +7 -0
  99. package/lib/programmatic/openapi-operation-bindings.js +5 -0
  100. package/lib/programmatic/openapi-request-schemas.js +5 -0
  101. package/lib/programmatic/openapi-schema-descriptions-channel.js +8 -5
  102. package/lib/programmatic/openapi-schema-descriptions-operations.js +19 -0
  103. package/lib/programmatic/openapi-spec.js +1 -0
  104. package/lib/programmatic/request-timeout.js +3 -0
  105. package/lib/programmatic/route-handler-map.js +7 -0
  106. package/lib/programmatic/run-channel-catalog.js +50 -8
  107. package/lib/programmatic/run-channel-install-options.js +5 -1
  108. package/lib/programmatic/run-download.js +41 -0
  109. package/lib/protection/auth-context.js +3 -1
  110. package/lib/protection/protection-display.js +3 -2
  111. package/lib/protection/report-exit.js +50 -0
  112. package/lib/protection/run-commands.js +2 -0
  113. package/lib/role-assistant/package-validate.js +175 -0
  114. package/lib/role-assistant/test-case-assertion-row.js +36 -0
  115. package/lib/role-assistant/test-case-copy-bind.js +77 -0
  116. package/lib/role-assistant/test-case-copy-expected.js +127 -0
  117. package/lib/role-assistant/test-case-copy-from-work.js +90 -0
  118. package/lib/role-assistant/test-case-copy-interactions.js +67 -0
  119. package/lib/role-assistant/test-case-copy.js +119 -0
  120. package/lib/role-assistant/test-case-expected-catalog.js +135 -0
  121. package/lib/role-assistant/test-case-validate.js +88 -0
  122. package/lib/role-assistant/test-cases-bid.js +117 -4
  123. package/lib/role-assistant/test-cases-evaluate.js +137 -30
  124. package/lib/role-assistant/test-cases-honesty.js +155 -6
  125. package/lib/role-assistant/test-cases-lifecycle.js +291 -0
  126. package/lib/role-assistant/test-cases-search-graph.js +122 -0
  127. package/lib/role-assistant/test-cases-search.js +20 -2
  128. package/lib/role-assistant/test-cases.js +34 -168
  129. package/lib/role-assistant/test-pack-map.js +180 -0
  130. package/lib/role-assistant/test-pack-sync.js +187 -0
  131. package/lib/role-assistant/test-runner-debug.js +54 -0
  132. package/lib/role-assistant/test-runner-respond-body.js +36 -0
  133. package/lib/role-assistant/test-runner-search.js +20 -5
  134. package/lib/role-assistant/test-runner-start-payload.js +63 -10
  135. package/lib/role-assistant/test-runner-workhub-answers.js +45 -16
  136. package/lib/role-assistant/test-runner-workhub.js +45 -21
  137. package/lib/role-assistant/test-runner.js +50 -10
  138. package/lib/schema/external-datasource.schema.json +36 -5
  139. package/lib/schema/external-system.schema.json +20 -2
  140. package/lib/schema/role-assistant-test-case.schema.json +408 -0
  141. package/lib/search/dataplane-context.js +23 -0
  142. package/lib/search/search-args.js +211 -0
  143. package/lib/search/search-display.js +238 -0
  144. package/lib/search/search-errors.js +50 -0
  145. package/lib/search/search-prompts.js +119 -0
  146. package/lib/search/search-roles.js +85 -0
  147. package/lib/search/search-run.js +241 -0
  148. package/lib/search/search-skills.js +198 -0
  149. package/lib/utils/authentication-slot-show.js +153 -0
  150. package/lib/utils/credential-display.js +43 -1
  151. package/lib/utils/external-system-readiness-compact-blocks.js +5 -1
  152. package/lib/utils/external-system-readiness-compact-display.js +30 -1
  153. package/lib/utils/external-system-validators.js +2 -1
  154. package/lib/utils/help-builder.js +3 -1
  155. package/lib/utils/schema-loader.js +37 -0
  156. package/lib/validation/validate-external-file.js +5 -1
  157. package/lib/validation/validate.js +3 -2
  158. package/package.json +1 -1
  159. package/templates/agent-kit/adapters/claude/nested.CLAUDE.md +1 -0
  160. package/templates/agent-kit/adapters/claude/root.CLAUDE.md +5 -0
  161. package/templates/agent-kit/adapters/cursor/commands/cust-0-plan.md +5 -0
  162. package/templates/agent-kit/adapters/cursor/commands/cust-1-validate.md +5 -0
  163. package/templates/agent-kit/adapters/cursor/commands/cust-2-build.md +5 -0
  164. package/templates/agent-kit/adapters/cursor/commands/cust-3-push.md +5 -0
  165. package/templates/agent-kit/adapters/cursor/commands/cust-biz-1-validate.md +5 -0
  166. package/templates/agent-kit/adapters/cursor/commands/cust-biz-2-build.md +5 -0
  167. package/templates/agent-kit/adapters/cursor/commands/cust-biz-3-prove.md +5 -0
  168. package/templates/agent-kit/agent-kit.yaml +45 -0
  169. package/templates/agent-kit/instructions/AGENTKIT.md +83 -0
  170. package/templates/agent-kit/instructions/integration.AGENTS.md +25 -0
  171. package/templates/agent-kit/instructions/role-assistant.AGENTS.md +22 -0
  172. package/templates/agent-kit/instructions/root.AGENTS.md +37 -0
  173. package/templates/agent-kit/parity-inventory.yaml +188 -0
  174. package/templates/agent-kit/skills/aifabrix-connected-system/SKILL.md +58 -0
  175. package/templates/agent-kit/skills/aifabrix-connected-system/references/contract-checklist.md +40 -0
  176. package/templates/agent-kit/skills/aifabrix-connected-system/references/delivery-gates.md +54 -0
  177. package/templates/agent-kit/skills/aifabrix-connected-system/references/production-safety.md +35 -0
  178. package/templates/agent-kit/skills/aifabrix-connected-system/scripts/reserved-system-key.js +19 -0
  179. package/templates/agent-kit/skills/aifabrix-plan/SKILL.md +51 -0
  180. package/templates/agent-kit/skills/aifabrix-plan/references/challenge-checklist.md +108 -0
  181. package/templates/agent-kit/skills/aifabrix-plan/references/interaction.md +34 -0
  182. package/templates/agent-kit/skills/aifabrix-plan/references/plan-template.md +182 -0
  183. package/templates/agent-kit/skills/aifabrix-prove/SKILL.md +50 -0
  184. package/templates/agent-kit/skills/aifabrix-prove/references/demo-template.md +65 -0
  185. package/templates/agent-kit/skills/aifabrix-prove/references/evidence-lifecycle.md +68 -0
  186. package/templates/agent-kit/skills/aifabrix-prove/references/learning-template.md +66 -0
  187. package/templates/agent-kit/skills/aifabrix-role-assistant/SKILL.md +42 -0
  188. package/templates/agent-kit/skills/aifabrix-role-assistant/references/package-boundary.md +21 -0
  189. package/templates/agent-kit/skills/shared/hosts.md +78 -0
  190. package/templates/agent-kit/workspace/.cursor/plans/README.md +22 -0
  191. package/templates/agent-kit/workspace/LICENSE.mit +21 -0
  192. package/templates/agent-kit/workspace/README.md +89 -0
  193. package/templates/applications/builder-api/Dockerfile +3 -1
  194. package/templates/applications/dataplane/application.yaml +2 -2
  195. package/templates/applications/dataplane/env.template +1 -1
  196. package/templates/applications/dataplane/rbac.yaml +28 -0
  197. package/templates/applications/keycloak/env.template +3 -3
  198. package/templates/applications/miso-controller/application.yaml +1 -1
  199. package/templates/applications/miso-controller/env.template +8 -9
  200. package/templates/channels/claude/TROUBLESHOOTING.md +3 -0
  201. package/templates/channels/claude/channel.json +1 -1
  202. package/templates/channels/claude/install.template.md.hbs +1 -0
  203. package/templates/channels/claude/integration/claude-system.json +1 -1
  204. package/templates/channels/slack/channel.json +11 -0
  205. package/templates/channels/slack/install.template.md.hbs +9 -0
  206. package/templates/channels/slack/integration/slack-system.json +11 -0
  207. package/templates/channels/slack/manifest.template.json.hbs +6 -3
  208. package/templates/channels/teams-bot/channel.json +1 -0
  209. package/templates/python/docker-compose.hbs +14 -0
  210. package/templates/typescript/docker-compose.hbs +14 -0
@@ -0,0 +1,408 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-07/schema#",
3
+ "$id": "aifabrix://schema/role-assistant-test-case",
4
+ "title": "Role Assistant Test Case",
5
+ "description": "Nested Role Assistant YAML cases (caseId, input, answers, expected).",
6
+ "type": "object",
7
+ "required": ["caseId"],
8
+ "additionalProperties": false,
9
+ "properties": {
10
+ "caseId": {
11
+ "type": "string",
12
+ "minLength": 1
13
+ },
14
+ "input": { "$ref": "#/$defs/inputObject" },
15
+ "answers": {
16
+ "type": "array",
17
+ "items": { "$ref": "#/$defs/waitResponse" }
18
+ },
19
+ "approvals": {
20
+ "type": "array",
21
+ "items": { "$ref": "#/$defs/waitResponse" }
22
+ },
23
+ "preflight": {
24
+ "type": "object",
25
+ "additionalProperties": false,
26
+ "properties": {
27
+ "evidence": { "$ref": "#/$defs/evidenceObject" }
28
+ }
29
+ },
30
+ "expected": {
31
+ "type": "object",
32
+ "additionalProperties": false,
33
+ "properties": {
34
+ "soft": { "type": "boolean" },
35
+ "softNotes": {
36
+ "type": "array",
37
+ "items": {
38
+ "oneOf": [
39
+ { "type": "string" },
40
+ { "type": "object" }
41
+ ]
42
+ }
43
+ },
44
+ "honesty": { "$ref": "#/$defs/honestyObject" },
45
+ "lifecycleState": {
46
+ "type": "string",
47
+ "enum": [
48
+ "completed",
49
+ "question",
50
+ "approval-required",
51
+ "dependency",
52
+ "safe-stop",
53
+ "rejected",
54
+ "failed"
55
+ ]
56
+ },
57
+ "capabilities": {
58
+ "type": "object",
59
+ "additionalProperties": false,
60
+ "properties": {
61
+ "allowed": { "$ref": "#/$defs/stringList" },
62
+ "required": { "$ref": "#/$defs/stringList" },
63
+ "forbidden": { "$ref": "#/$defs/stringList" }
64
+ }
65
+ },
66
+ "search": { "$ref": "#/$defs/searchObject" },
67
+ "skills": { "$ref": "#/$defs/skillsObject" },
68
+ "evidence": { "$ref": "#/$defs/evidenceObject" },
69
+ "bid": { "$ref": "#/$defs/bidObject" },
70
+ "facts": { "$ref": "#/$defs/openObject" },
71
+ "prohibited": {
72
+ "type": "array"
73
+ }
74
+ }
75
+ },
76
+ "metadata": { "$ref": "#/$defs/openObject" }
77
+ },
78
+ "$defs": {
79
+ "openObject": {
80
+ "type": "object",
81
+ "additionalProperties": true
82
+ },
83
+ "stringList": {
84
+ "type": "array",
85
+ "items": { "type": "string" }
86
+ },
87
+ "waitWhen": {
88
+ "type": "object",
89
+ "additionalProperties": false,
90
+ "properties": {
91
+ "questionKey": { "type": "string" },
92
+ "requestKey": { "type": "string" },
93
+ "key": { "type": "string" },
94
+ "waitReason": { "type": "string" },
95
+ "capability": { "type": "string" }
96
+ }
97
+ },
98
+ "waitResponse": {
99
+ "type": "object",
100
+ "additionalProperties": false,
101
+ "required": ["when", "value"],
102
+ "properties": {
103
+ "when": { "$ref": "#/$defs/waitWhen" },
104
+ "value": {}
105
+ }
106
+ },
107
+ "inputObject": {
108
+ "type": "object",
109
+ "additionalProperties": false,
110
+ "properties": {
111
+ "executionPath": {
112
+ "type": "string",
113
+ "enum": ["workHub", "work", "work.start", "intent", "search", "skills"]
114
+ },
115
+ "businessRoleRef": { "type": "string" },
116
+ "roleRef": { "type": "string" },
117
+ "digitalWorkerKey": { "type": "string" },
118
+ "assistantName": { "type": "string" },
119
+ "sourceType": { "type": "string" },
120
+ "message": { "type": "string" },
121
+ "content": {},
122
+ "text": { "type": "string" },
123
+ "prompt": { "type": "string" },
124
+ "objective": { "type": "string" },
125
+ "attachments": {},
126
+ "openapiDir": { "type": "string" },
127
+ "openapiFiles": { "type": "array" },
128
+ "comVocabulary": {},
129
+ "comModelRef": { "type": "string" },
130
+ "comModelVersion": { "type": "string" },
131
+ "sourceLanguage": { "type": "string" },
132
+ "responseLanguage": { "type": "string" },
133
+ "sourceMetadata": { "type": "object" },
134
+ "submissionId": { "type": "string" },
135
+ "activationId": { "type": "string" },
136
+ "workerTaskId": { "type": "string" },
137
+ "principalRef": { "type": "string" },
138
+ "certifyPillar": { "type": "string" },
139
+ "pillar": { "type": "string" },
140
+ "systemKey": { "type": "string" },
141
+ "targetSystemKey": { "type": "string" },
142
+ "integrationSystemKey": { "type": "string" },
143
+ "stampSuiteBid": { "type": "boolean" },
144
+ "suiteRunId": { "type": "string" },
145
+ "emittedBidPath": { "type": "string" },
146
+ "bidPath": { "type": "string" },
147
+ "emitBidFromAnswers": { "type": "boolean" },
148
+ "connectionRefs": { "type": "object" },
149
+ "openapiSourceRefs": { "type": "object" },
150
+ "requestedDepth": { "type": "string" },
151
+ "format": { "type": "string" },
152
+ "resourceType": { "type": "string" },
153
+ "operation": { "type": "string" },
154
+ "filters": { "type": "object" },
155
+ "fields": { "type": "array" },
156
+ "page": { "type": "number" },
157
+ "pageSize": { "type": "number" },
158
+ "graph": { "$ref": "#/$defs/searchGraph" },
159
+ "query": { "type": "string", "minLength": 1 },
160
+ "knowledgeKeys": { "$ref": "#/$defs/stringList" }
161
+ },
162
+ "allOf": [
163
+ {
164
+ "if": {
165
+ "anyOf": [
166
+ { "not": { "required": ["executionPath"] } },
167
+ {
168
+ "required": ["executionPath"],
169
+ "properties": {
170
+ "executionPath": {
171
+ "enum": ["workHub", "work", "work.start", "intent"]
172
+ }
173
+ }
174
+ }
175
+ ]
176
+ },
177
+ "then": { "$ref": "#/$defs/inputWorkForbidsSearchKeys" }
178
+ },
179
+ {
180
+ "if": {
181
+ "required": ["executionPath"],
182
+ "properties": { "executionPath": { "const": "search" } }
183
+ },
184
+ "then": {
185
+ "allOf": [
186
+ { "$ref": "#/$defs/inputSearchForbidsWorkKeys" },
187
+ { "$ref": "#/$defs/inputSearchQueryRequiresGraph" }
188
+ ]
189
+ }
190
+ },
191
+ {
192
+ "if": {
193
+ "required": ["executionPath"],
194
+ "properties": { "executionPath": { "const": "skills" } }
195
+ },
196
+ "then": { "$ref": "#/$defs/inputSkillsForbidsWorkAndSearchKeys" }
197
+ }
198
+ ]
199
+ },
200
+ "inputWorkForbidsSearchKeys": {
201
+ "properties": {
202
+ "resourceType": false,
203
+ "operation": false,
204
+ "filters": false,
205
+ "fields": false,
206
+ "page": false,
207
+ "pageSize": false,
208
+ "graph": false,
209
+ "query": false,
210
+ "knowledgeKeys": false
211
+ }
212
+ },
213
+ "inputSearchForbidsWorkKeys": {
214
+ "properties": {
215
+ "message": false,
216
+ "content": false,
217
+ "text": false,
218
+ "prompt": false,
219
+ "objective": false,
220
+ "attachments": false,
221
+ "openapiDir": false,
222
+ "openapiFiles": false,
223
+ "comVocabulary": false,
224
+ "comModelRef": false,
225
+ "comModelVersion": false,
226
+ "sourceLanguage": false,
227
+ "responseLanguage": false,
228
+ "sourceMetadata": false,
229
+ "submissionId": false,
230
+ "activationId": false,
231
+ "workerTaskId": false,
232
+ "principalRef": false,
233
+ "certifyPillar": false,
234
+ "pillar": false,
235
+ "systemKey": false,
236
+ "targetSystemKey": false,
237
+ "integrationSystemKey": false,
238
+ "stampSuiteBid": false,
239
+ "suiteRunId": false,
240
+ "emittedBidPath": false,
241
+ "bidPath": false,
242
+ "emitBidFromAnswers": false,
243
+ "connectionRefs": false,
244
+ "openapiSourceRefs": false,
245
+ "requestedDepth": false,
246
+ "format": false
247
+ }
248
+ },
249
+ "inputSkillsForbidsWorkAndSearchKeys": {
250
+ "properties": {
251
+ "message": false,
252
+ "content": false,
253
+ "text": false,
254
+ "prompt": false,
255
+ "objective": false,
256
+ "attachments": false,
257
+ "openapiDir": false,
258
+ "openapiFiles": false,
259
+ "comVocabulary": false,
260
+ "comModelRef": false,
261
+ "comModelVersion": false,
262
+ "sourceLanguage": false,
263
+ "responseLanguage": false,
264
+ "sourceMetadata": false,
265
+ "submissionId": false,
266
+ "activationId": false,
267
+ "workerTaskId": false,
268
+ "principalRef": false,
269
+ "certifyPillar": false,
270
+ "pillar": false,
271
+ "systemKey": false,
272
+ "targetSystemKey": false,
273
+ "integrationSystemKey": false,
274
+ "stampSuiteBid": false,
275
+ "suiteRunId": false,
276
+ "emittedBidPath": false,
277
+ "bidPath": false,
278
+ "emitBidFromAnswers": false,
279
+ "connectionRefs": false,
280
+ "openapiSourceRefs": false,
281
+ "requestedDepth": false,
282
+ "format": false,
283
+ "operation": false,
284
+ "filters": false,
285
+ "fields": false,
286
+ "page": false,
287
+ "pageSize": false,
288
+ "graph": false,
289
+ "query": false,
290
+ "knowledgeKeys": false
291
+ }
292
+ },
293
+ "searchGraph": {
294
+ "oneOf": [
295
+ { "type": "boolean" },
296
+ {
297
+ "type": "object",
298
+ "additionalProperties": false,
299
+ "required": ["depth"],
300
+ "properties": {
301
+ "depth": { "type": "integer", "const": 1 }
302
+ }
303
+ }
304
+ ]
305
+ },
306
+ "inputSearchQueryRequiresGraph": {
307
+ "if": {
308
+ "anyOf": [
309
+ { "required": ["query"] },
310
+ {
311
+ "required": ["knowledgeKeys"],
312
+ "properties": {
313
+ "knowledgeKeys": { "minItems": 1 }
314
+ }
315
+ }
316
+ ]
317
+ },
318
+ "then": {
319
+ "required": ["graph"],
320
+ "properties": {
321
+ "graph": { "not": { "const": false } }
322
+ }
323
+ }
324
+ },
325
+ "honestyObject": {
326
+ "type": "object",
327
+ "additionalProperties": false,
328
+ "properties": {
329
+ "requireWorkResult": { "type": "boolean" },
330
+ "schemaVersion": { "type": "string" },
331
+ "requireCompletion": { "type": "boolean" },
332
+ "requireContributionObservation": { "type": "boolean" },
333
+ "minResourceChanges": { "type": "number" },
334
+ "softResourceChanges": { "type": "boolean" },
335
+ "forbidBuilderKeysInObjective": { "type": "boolean" }
336
+ }
337
+ },
338
+ "searchObject": {
339
+ "type": "object",
340
+ "additionalProperties": false,
341
+ "properties": {
342
+ "statusCode": { "type": "number" },
343
+ "operation": { "type": "string" },
344
+ "resultMode": { "type": "string" },
345
+ "minRows": { "type": "number" },
346
+ "errorContains": { "type": "string" },
347
+ "graphDepth": { "type": "number" },
348
+ "relatedTypes": { "$ref": "#/$defs/stringList" },
349
+ "related": { "$ref": "#/$defs/searchRelatedObject" }
350
+ }
351
+ },
352
+ "searchRelatedHop": {
353
+ "type": "object",
354
+ "additionalProperties": false,
355
+ "properties": {
356
+ "minRows": { "type": "number" },
357
+ "resultMode": { "type": "string" }
358
+ }
359
+ },
360
+ "searchRelatedObject": {
361
+ "type": "object",
362
+ "minProperties": 1,
363
+ "additionalProperties": { "$ref": "#/$defs/searchRelatedHop" }
364
+ },
365
+ "skillsObject": {
366
+ "type": "object",
367
+ "additionalProperties": false,
368
+ "properties": {
369
+ "resourceType": { "type": "string" },
370
+ "operations": { "$ref": "#/$defs/stringList" },
371
+ "filterFields": { "$ref": "#/$defs/stringList" },
372
+ "operationRequired": { "type": "boolean" }
373
+ }
374
+ },
375
+ "evidenceObject": {
376
+ "type": "object",
377
+ "additionalProperties": false,
378
+ "properties": {
379
+ "requiredKeys": { "$ref": "#/$defs/stringList" },
380
+ "roleKey": { "type": "string" },
381
+ "resourceType": { "type": "string" },
382
+ "requireStatus": { "type": "string" }
383
+ }
384
+ },
385
+ "bidCapability": {
386
+ "type": "object",
387
+ "additionalProperties": false,
388
+ "required": ["datasource", "key"],
389
+ "properties": {
390
+ "datasource": { "type": "string", "minLength": 1 },
391
+ "key": { "type": "string", "minLength": 1 }
392
+ }
393
+ },
394
+ "bidObject": {
395
+ "type": "object",
396
+ "additionalProperties": false,
397
+ "properties": {
398
+ "schemaName": { "type": "string" },
399
+ "schemaVersion": { "type": "string" },
400
+ "requireDefinitionHash": { "type": "boolean" },
401
+ "requireSuiteRunId": { "type": "boolean" },
402
+ "forbidGoldPaths": { "type": "boolean" },
403
+ "minDatasources": { "$ref": "#/$defs/stringList" },
404
+ "requireCapability": { "$ref": "#/$defs/bidCapability" }
405
+ }
406
+ }
407
+ }
408
+ }
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Dataplane auth/url resolution for search commands.
3
+ *
4
+ * @fileoverview Thin wrapper over protection dataplane context
5
+ * @author AI Fabrix Team
6
+ * @version 1.0.0
7
+ */
8
+
9
+ 'use strict';
10
+
11
+ const { resolveProtectionDataplaneContext } = require('../protection/auth-context');
12
+
13
+ /**
14
+ * @param {Object} [options]
15
+ * @returns {Promise<{ environment: string, controllerUrl: string, dataplaneUrl: string, authConfig: Object }>}
16
+ */
17
+ async function resolveSearchDataplaneContext(options = {}) {
18
+ return resolveProtectionDataplaneContext(options);
19
+ }
20
+
21
+ module.exports = {
22
+ resolveSearchDataplaneContext
23
+ };
@@ -0,0 +1,211 @@
1
+ /**
2
+ * Map CLI flags onto the published work.search request body.
3
+ *
4
+ * @fileoverview Flag parse/merge for aifabrix search (fail closed)
5
+ * @author AI Fabrix Team
6
+ * @version 1.0.0
7
+ */
8
+
9
+ 'use strict';
10
+
11
+ const { SearchCliError } = require('./search-errors');
12
+
13
+ /**
14
+ * @param {...*} values
15
+ * @returns {string}
16
+ */
17
+ function firstTrimmed(...values) {
18
+ for (const value of values) {
19
+ if (typeof value === 'string' && value.trim()) {
20
+ return value.trim();
21
+ }
22
+ }
23
+ return '';
24
+ }
25
+
26
+ /**
27
+ * @param {Object} options
28
+ * @returns {string}
29
+ */
30
+ function roleRefFromOptions(options) {
31
+ return firstTrimmed(options && options.role, options && options.roleRef);
32
+ }
33
+
34
+ /**
35
+ * @param {Object} options
36
+ * @returns {string}
37
+ */
38
+ function resourceTypeFromOptions(options) {
39
+ return firstTrimmed(options && options.resourceType, options && options.type);
40
+ }
41
+
42
+ /**
43
+ * @param {string} raw
44
+ * @param {string} label
45
+ * @returns {Object}
46
+ */
47
+ function parseJsonObject(raw, label) {
48
+ let parsed;
49
+ try {
50
+ parsed = JSON.parse(raw);
51
+ } catch {
52
+ throw new SearchCliError(`${label} must be a JSON object.`);
53
+ }
54
+ if (!parsed || typeof parsed !== 'object' || Array.isArray(parsed)) {
55
+ throw new SearchCliError(`${label} must be a JSON object.`);
56
+ }
57
+ return parsed;
58
+ }
59
+
60
+ /**
61
+ * @param {string} filePath
62
+ * @param {string} label
63
+ * @param {{ readFileSync: Function }} fsApi
64
+ * @returns {Object}
65
+ */
66
+ function readJsonObjectFile(filePath, label, fsApi) {
67
+ let raw;
68
+ try {
69
+ raw = fsApi.readFileSync(filePath, 'utf8');
70
+ } catch {
71
+ throw new SearchCliError(`Cannot read ${label}: ${filePath}`);
72
+ }
73
+ return parseJsonObject(String(raw), label);
74
+ }
75
+
76
+ /**
77
+ * @param {Object} options
78
+ * @param {{ readFileSync: Function }} fsApi
79
+ * @returns {Object|undefined}
80
+ */
81
+ function resolveFilters(options, fsApi) {
82
+ const inline = options && options.filters;
83
+ const filePath = options && options.filtersFile;
84
+ if (inline && filePath) {
85
+ throw new SearchCliError('Use either --filters or --filters-file, not both.');
86
+ }
87
+ if (inline) {
88
+ return parseJsonObject(String(inline), '--filters');
89
+ }
90
+ if (filePath) {
91
+ return readJsonObjectFile(filePath, '--filters-file', fsApi);
92
+ }
93
+ return undefined;
94
+ }
95
+
96
+ /**
97
+ * @param {*} value
98
+ * @param {string} label
99
+ * @param {number} min
100
+ * @param {number} [max]
101
+ * @returns {number|undefined}
102
+ */
103
+ function parseBoundedInt(value, label, min, max) {
104
+ if (value === undefined || value === null || value === '') {
105
+ return undefined;
106
+ }
107
+ const n = Number(value);
108
+ const inMax = max === undefined || n <= max;
109
+ if (!Number.isInteger(n) || n < min || !inMax) {
110
+ const range = max === undefined ? `≥ ${min}` : `${min}–${max}`;
111
+ throw new SearchCliError(`${label} must be an integer ${range}.`);
112
+ }
113
+ return n;
114
+ }
115
+
116
+ /**
117
+ * @param {*} csv
118
+ * @returns {string[]|undefined}
119
+ */
120
+ function parseFieldsCsv(csv) {
121
+ if (csv === undefined || csv === null || csv === '') {
122
+ return undefined;
123
+ }
124
+ const fields = String(csv)
125
+ .split(',')
126
+ .map((part) => part.trim())
127
+ .filter(Boolean);
128
+ return fields.length ? fields : undefined;
129
+ }
130
+
131
+ /**
132
+ * @param {*} value
133
+ * @returns {string[]|undefined}
134
+ */
135
+ function parseKnowledgeKeys(value) {
136
+ const raw = Array.isArray(value) ? value : value ? [value] : [];
137
+ const keys = raw.map((item) => String(item || '').trim()).filter(Boolean);
138
+ return keys.length ? keys : undefined;
139
+ }
140
+
141
+ /**
142
+ * @param {Object} body
143
+ * @param {Object} options
144
+ * @param {{ readFileSync: Function }} fsApi
145
+ */
146
+ function assignFlagFields(body, options, fsApi) {
147
+ const roleRef = roleRefFromOptions(options);
148
+ const resourceType = resourceTypeFromOptions(options);
149
+ const operation = firstTrimmed(options && options.operation);
150
+ if (roleRef) body.roleRef = roleRef;
151
+ if (resourceType) body.resourceType = resourceType;
152
+ if (operation) body.operation = operation;
153
+ const filters = resolveFilters(options, fsApi);
154
+ if (filters) body.filters = filters;
155
+ const page = parseBoundedInt(options && options.page, '--page', 1);
156
+ if (page !== undefined) body.page = page;
157
+ const pageSize = parseBoundedInt(options && options.pageSize, '--page-size', 1, 100);
158
+ if (pageSize !== undefined) body.pageSize = pageSize;
159
+ if (typeof (options && options.sort) === 'string' && options.sort.trim()) {
160
+ body.sort = options.sort.trim();
161
+ }
162
+ }
163
+
164
+ /**
165
+ * @param {Object} body
166
+ * @param {Object} options
167
+ */
168
+ function assignOptionalSearchFields(body, options) {
169
+ const fields = parseFieldsCsv(options && options.fields);
170
+ if (fields) body.fields = fields;
171
+ if (options && options.graph === true) {
172
+ body.graph = { depth: 1 };
173
+ }
174
+ if (typeof (options && options.query) === 'string' && options.query.trim()) {
175
+ body.query = options.query.trim();
176
+ }
177
+ const knowledgeKeys = parseKnowledgeKeys(options && options.knowledgeKey);
178
+ if (knowledgeKeys) body.knowledgeKeys = knowledgeKeys;
179
+ }
180
+
181
+ /**
182
+ * Flags first, then --body file (file wins on conflict). Local-only; no HTTP.
183
+ *
184
+ * @param {Object} options
185
+ * @param {{ readFileSync: Function }} fsApi
186
+ * @returns {Object}
187
+ */
188
+ function buildSearchBody(options, fsApi) {
189
+ const body = {};
190
+ assignFlagFields(body, options, fsApi);
191
+ assignOptionalSearchFields(body, options);
192
+ const bodyFile = options && options.body;
193
+ if (bodyFile) {
194
+ const fromFile = readJsonObjectFile(bodyFile, '--body', fsApi);
195
+ Object.assign(body, fromFile);
196
+ }
197
+ return body;
198
+ }
199
+
200
+ module.exports = {
201
+ firstTrimmed,
202
+ roleRefFromOptions,
203
+ resourceTypeFromOptions,
204
+ parseJsonObject,
205
+ readJsonObjectFile,
206
+ resolveFilters,
207
+ parseBoundedInt,
208
+ parseFieldsCsv,
209
+ parseKnowledgeKeys,
210
+ buildSearchBody
211
+ };