@aifabrix/builder 2.53.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.
- package/README.md +8 -0
- package/bin/aifabrix.js +2 -2
- package/lib/agent-kit/apply-ops.js +82 -0
- package/lib/agent-kit/checksums.js +28 -0
- package/lib/agent-kit/classify.js +113 -0
- package/lib/agent-kit/claude-shim.js +61 -0
- package/lib/agent-kit/constants.js +55 -0
- package/lib/agent-kit/file-list.js +103 -0
- package/lib/agent-kit/host-approve.js +130 -0
- package/lib/agent-kit/hosting/github.js +63 -0
- package/lib/agent-kit/hosts.js +71 -0
- package/lib/agent-kit/init.js +319 -0
- package/lib/agent-kit/kit-root.js +17 -0
- package/lib/agent-kit/managed-section.js +79 -0
- package/lib/agent-kit/package-load.js +45 -0
- package/lib/agent-kit/plan-ops.js +69 -0
- package/lib/agent-kit/remote-prompts.js +239 -0
- package/lib/agent-kit/render-host-markdown.js +40 -0
- package/lib/agent-kit/repo-guard.js +47 -0
- package/lib/agent-kit/report.js +107 -0
- package/lib/agent-kit/run.js +82 -0
- package/lib/agent-kit/scm/git.js +122 -0
- package/lib/agent-kit/state-file.js +83 -0
- package/lib/agent-kit/status.js +50 -0
- package/lib/agent-kit/v1-detect.js +81 -0
- package/lib/agent-kit/validate-kit.js +87 -0
- package/lib/agent-kit/workspace-name.js +40 -0
- package/lib/agent-kit/workspace-skeleton.js +103 -0
- package/lib/api/assistants.api.js +8 -5
- package/lib/api/channel-identity.api.js +41 -0
- package/lib/api/evidence-authoring.api.js +5 -1
- package/lib/api/evidence.api.js +2 -0
- package/lib/api/role-assistant-test-pack.api.js +86 -0
- package/lib/api/types/evidence.types.js +2 -0
- package/lib/api/work-search.api.js +163 -0
- package/lib/api/work.api.js +19 -12
- package/lib/app/list-external-systems.js +2 -1
- package/lib/app/show-display.js +33 -6
- package/lib/app/show.js +25 -2
- package/lib/channels/add-channel.js +164 -126
- package/lib/channels/approval-guides/chatgpt.js +14 -18
- package/lib/channels/approval-guides/claude.js +29 -0
- package/lib/channels/approval-guides/index.js +88 -22
- package/lib/channels/approval-guides/mcp-client.js +27 -0
- package/lib/channels/approval-guides/microsoft-copilot.js +52 -3
- package/lib/channels/approval-guides/slack.js +10 -10
- package/lib/channels/approval-guides/teams-bot.js +8 -12
- package/lib/channels/channel-add-continuations.js +91 -0
- package/lib/channels/channel-add-ensure.js +124 -27
- package/lib/channels/channel-add-existing.js +160 -28
- package/lib/channels/channel-add-failure.js +61 -0
- package/lib/channels/channel-add-remaining.js +492 -0
- package/lib/channels/channel-add-tty.js +190 -0
- package/lib/channels/channel-add-wizard-config.js +138 -0
- package/lib/channels/channel-add-wizard.js +250 -0
- package/lib/channels/channel-artifact-generator.js +27 -13
- package/lib/channels/channel-cardinality.js +83 -0
- package/lib/channels/channel-catalog-icon.js +45 -0
- package/lib/channels/channel-cli-instructions.js +75 -0
- package/lib/channels/channel-configuration-map.js +213 -0
- package/lib/channels/channel-credential.js +11 -14
- package/lib/channels/channel-definition-project.js +101 -0
- package/lib/channels/channel-definition-registry.js +154 -0
- package/lib/channels/channel-definition-status.js +115 -0
- package/lib/channels/channel-description.js +60 -2
- package/lib/channels/channel-discovery.js +16 -2
- package/lib/channels/channel-external-system.js +86 -9
- package/lib/channels/channel-install-envelope-actions.js +88 -0
- package/lib/channels/channel-install-envelope-microsoft.js +155 -0
- package/lib/channels/channel-install-envelope.js +358 -0
- package/lib/channels/channel-install-help-md.js +172 -0
- package/lib/channels/channel-install-http-payload.js +62 -0
- package/lib/channels/channel-install-inventory.js +115 -0
- package/lib/channels/channel-install-profiles.js +90 -0
- package/lib/channels/channel-instance-collision.js +118 -0
- package/lib/channels/channel-instance-key.js +100 -0
- package/lib/channels/channel-instance-materialize.js +240 -0
- package/lib/channels/channel-integration-generator.js +18 -9
- package/lib/channels/channel-integration-template.js +101 -22
- package/lib/channels/channel-inventory-fetch.js +79 -0
- package/lib/channels/channel-oauth-preflight.js +104 -0
- package/lib/channels/channel-package-version.js +76 -0
- package/lib/channels/channel-predefined-client.js +154 -0
- package/lib/channels/channel-probe.js +7 -2
- package/lib/channels/channel-runtime-resolver.js +194 -72
- package/lib/channels/channel-status-display.js +86 -16
- package/lib/channels/channel-targets.js +132 -92
- package/lib/channels/chatgpt-callback.js +318 -0
- package/lib/channels/chatgpt-channel-add.js +229 -0
- package/lib/channels/chatgpt-preflight.js +396 -0
- package/lib/channels/chatgpt-runtime-contract.js +17 -0
- package/lib/channels/chatgpt-setup-values.js +124 -0
- package/lib/channels/claude-callback.js +67 -0
- package/lib/channels/claude-channel-add.js +254 -0
- package/lib/channels/claude-runtime-contract.js +40 -0
- package/lib/channels/claude-runtime.js +58 -0
- package/lib/channels/claude-setup-values.js +92 -0
- package/lib/channels/mcp-client/config-merge.js +148 -0
- package/lib/channels/mcp-client/ensure-client.js +231 -0
- package/lib/channels/mcp-client/paths.js +53 -0
- package/lib/channels/mcp-client/profiles.js +122 -0
- package/lib/channels/mcp-client/redirect-uris.js +99 -0
- package/lib/channels/mcp-client/runtime.js +59 -0
- package/lib/channels/mcp-client-channel-add.js +186 -0
- package/lib/channels/microsoft-copilot-channel-add.js +117 -7
- package/lib/channels/microsoft-copilot-entra-identifier-uris.js +187 -0
- package/lib/channels/microsoft-copilot-entra-sso-form.js +106 -18
- package/lib/channels/microsoft-copilot-entra-sso.js +31 -2
- package/lib/channels/microsoft-copilot-package-prior.js +107 -0
- package/lib/channels/microsoft-copilot-package.js +29 -28
- package/lib/channels/microsoft-provisioning/a365.js +80 -0
- package/lib/channels/microsoft-provisioning/auth-config.js +240 -0
- package/lib/channels/microsoft-provisioning/auth.js +179 -0
- package/lib/channels/microsoft-provisioning/cli.js +71 -0
- package/lib/channels/microsoft-provisioning/constants.js +75 -0
- package/lib/channels/microsoft-provisioning/errors.js +117 -0
- package/lib/channels/microsoft-provisioning/index.js +55 -0
- package/lib/channels/microsoft-provisioning/install-atk.js +158 -0
- package/lib/channels/microsoft-provisioning/install-teams.js +115 -0
- package/lib/channels/microsoft-provisioning/login-portal-device.js +236 -0
- package/lib/channels/microsoft-provisioning/login-portal-parse.js +71 -0
- package/lib/channels/microsoft-provisioning/login-portal-teams.js +193 -0
- package/lib/channels/microsoft-provisioning/login-portal.js +230 -0
- package/lib/channels/microsoft-provisioning/persist.js +110 -0
- package/lib/channels/microsoft-provisioning/teams-bot-args.js +119 -0
- package/lib/channels/microsoft-provisioning/teams-bot-controller.js +123 -0
- package/lib/channels/microsoft-provisioning/teams-bot-parse.js +134 -0
- package/lib/channels/microsoft-provisioning/teams-bot-persist.js +113 -0
- package/lib/channels/microsoft-provisioning/teams-bot-provision.js +234 -0
- package/lib/channels/microsoft-provisioning/teams-bot-secrets.js +45 -0
- package/lib/channels/microsoft-provisioning/teams-cli.js +82 -0
- package/lib/channels/runtime-tool-catalog.js +5 -2
- package/lib/channels/slack-channel-add-portal.js +130 -0
- package/lib/channels/slack-channel-add-tty-auth.js +95 -0
- package/lib/channels/slack-channel-add.js +311 -0
- package/lib/channels/slack-mcp-callback.js +51 -0
- package/lib/channels/slack-mcp-runtime.js +156 -0
- package/lib/channels/slack-provisioning/apps.js +181 -0
- package/lib/channels/slack-provisioning/auth-store.js +110 -0
- package/lib/channels/slack-provisioning/auth-ticket.js +185 -0
- package/lib/channels/slack-provisioning/auth.js +115 -0
- package/lib/channels/slack-provisioning/callbacks.js +41 -0
- package/lib/channels/slack-provisioning/cli.js +226 -0
- package/lib/channels/slack-provisioning/constants.js +37 -0
- package/lib/channels/slack-provisioning/credentials.js +169 -0
- package/lib/channels/slack-provisioning/curl-shim.js +132 -0
- package/lib/channels/slack-provisioning/developer-install.js +118 -0
- package/lib/channels/slack-provisioning/env-file.js +120 -0
- package/lib/channels/slack-provisioning/errors.js +47 -0
- package/lib/channels/slack-provisioning/go-ca-bundle.js +137 -0
- package/lib/channels/slack-provisioning/index.js +250 -0
- package/lib/channels/slack-provisioning/install-cli.js +335 -0
- package/lib/channels/slack-provisioning/manifest.js +89 -0
- package/lib/channels/slack-provisioning/oauth-lock.js +33 -0
- package/lib/channels/slack-provisioning/offer-cli.js +113 -0
- package/lib/channels/slack-provisioning/onboard-members.js +122 -0
- package/lib/channels/slack-provisioning/onboard.js +89 -0
- package/lib/channels/slack-provisioning/persist.js +95 -0
- package/lib/channels/slack-provisioning/remaining-urls.js +158 -0
- package/lib/channels/slack-provisioning/with-curl-on-path.js +53 -0
- package/lib/channels/teams-bot-channel-add.js +94 -0
- package/lib/channels/vendor-dataplane-url.js +249 -0
- package/lib/cli/index.js +4 -0
- package/lib/cli/setup-certification-commands.js +2 -2
- package/lib/cli/setup-certification.help.js +5 -1
- package/lib/cli/setup-external-system-help.js +2 -0
- package/lib/cli/setup-external-system.js +1 -1
- package/lib/commands/agent-kit-help.js +79 -0
- package/lib/commands/agent-kit.js +346 -0
- package/lib/commands/channel-add-help.js +366 -0
- package/lib/commands/channel-add-setup.js +162 -80
- package/lib/commands/channel-configure.js +118 -0
- package/lib/commands/channel.js +10 -1
- package/lib/commands/datasource-capability-relate-cli.js +5 -4
- package/lib/commands/governance-upload-external.js +6 -3
- package/lib/commands/lifecycle-command-action.js +2 -5
- package/lib/commands/lifecycle-external.js +93 -21
- package/lib/commands/repair-auth-apply.js +1 -1
- package/lib/commands/repair-datasource-key-skip.js +39 -0
- package/lib/commands/repair-datasource-keys.js +24 -12
- package/lib/commands/repair-datasource-test-payload.js +4 -2
- package/lib/commands/repair-datasource-webhooks-sync-bridge.js +23 -2
- package/lib/commands/repair-datasource.js +3 -0
- package/lib/commands/repair-external-run.js +59 -25
- package/lib/commands/repair-openapi-rest-runtime.js +127 -0
- package/lib/commands/repair-orchestration-tag-merge.js +339 -0
- package/lib/commands/repair-rbac-catalog-defaults.js +96 -0
- package/lib/commands/repair-rbac-platform-preset.js +26 -15
- package/lib/commands/repair-rbac-reader-roles.js +8 -21
- package/lib/commands/repair-rbac.js +26 -44
- package/lib/commands/repair-system-permissions.js +24 -22
- package/lib/commands/role-assistant-copy-output.js +61 -0
- package/lib/commands/role-assistant-copy.js +155 -0
- package/lib/commands/role-assistant-test-output.js +22 -9
- package/lib/commands/role-assistant-test-result-rows.js +42 -0
- package/lib/commands/role-assistant.js +150 -43
- package/lib/commands/search.js +143 -0
- package/lib/commands/test-e2e-external.js +148 -21
- package/lib/commands/test-trust-external.js +7 -5
- package/lib/commands/upload-credential-push-log.js +2 -1
- package/lib/commands/upload-publish-context.js +1 -1
- package/lib/commands/upload-role-assistant-shell.js +124 -0
- package/lib/commands/upload-sidecar-followups.js +10 -4
- package/lib/commands/upload.js +18 -3
- package/lib/commands/verify-operations-skip-e2e.js +131 -0
- package/lib/commands/verify-operations-step-plan.js +6 -33
- package/lib/commands/verify-operations-steps.js +3 -1
- package/lib/core/secrets-docker-env.js +4 -1
- package/lib/core/secrets-env-content.js +17 -3
- package/lib/datasource/capability/capability-manifest.js +0 -3
- package/lib/datasource/capability/copy-test-payload.js +3 -0
- package/lib/datasource/capability/relate-operations.js +28 -10
- package/lib/datasource/capability/run-capability-relate.js +48 -25
- package/lib/datasource/datasource-identifier.js +13 -5
- package/lib/deployment/deployer-poll-run.js +117 -35
- package/lib/external-system/deploy-dataplane-published.js +70 -0
- package/lib/external-system/deploy-helpers.js +26 -1
- package/lib/external-system/deploy.js +22 -8
- package/lib/external-system/download-helpers.js +29 -2
- package/lib/external-system/download-role-assistant.js +109 -4
- package/lib/external-system/download.js +46 -30
- package/lib/external-system/sync-deploy-manifest.js +3 -2
- package/lib/external-system/upload-identity.js +42 -0
- package/lib/generator/index.js +19 -15
- package/lib/generator/split.js +13 -2
- package/lib/generator/wizard-datasource-key.js +54 -0
- package/lib/generator/wizard.js +55 -54
- package/lib/integration-definition/apply-datasource-keys.js +75 -0
- package/lib/integration-definition/apply-relationships.js +195 -0
- package/lib/integration-definition/apply-static-enterprise.js +229 -0
- package/lib/integration-definition/apply-system-file.js +71 -0
- package/lib/integration-definition/apply-test-endpoint.js +89 -0
- package/lib/integration-definition/apply-viewpoint-defaults.js +157 -0
- package/lib/integration-definition/apply.js +78 -59
- package/lib/integration-definition/enrich-openapi-operations.js +36 -10
- package/lib/integration-definition/enrich-openapi-pick.js +87 -0
- package/lib/lifecycle/role-assistant-governance.js +181 -0
- package/lib/lifecycle/scenario-upload.js +181 -30
- package/lib/programmatic/builder-api-cors.js +143 -0
- package/lib/programmatic/builder-api-request.js +6 -0
- package/lib/programmatic/builder-api-route-dispatch.js +56 -42
- package/lib/programmatic/builder-api-server.js +8 -1
- package/lib/programmatic/capability-registry.js +55 -0
- package/lib/programmatic/channel-install-help-resolve.js +359 -0
- package/lib/programmatic/channel-install-session.js +218 -0
- package/lib/programmatic/help-content/channel-onboarding.md +2 -0
- package/lib/programmatic/help-content/cip-overview.md +3 -1
- package/lib/programmatic/http-raw-response.js +62 -0
- package/lib/programmatic/index.js +2 -0
- package/lib/programmatic/openapi-apply-result-schemas.js +8 -0
- package/lib/programmatic/openapi-channel-install-bindings.js +179 -0
- package/lib/programmatic/openapi-channel-install-schemas.js +289 -0
- package/lib/programmatic/openapi-component-schemas.js +19 -1
- package/lib/programmatic/openapi-description-enricher.js +3 -1
- package/lib/programmatic/openapi-descriptions.js +80 -3
- package/lib/programmatic/openapi-envelope-examples.js +124 -0
- package/lib/programmatic/openapi-operation-bindings.js +9 -1
- package/lib/programmatic/openapi-request-schemas.js +5 -0
- package/lib/programmatic/openapi-schema-descriptions-channel.js +319 -0
- package/lib/programmatic/openapi-schema-descriptions-operations.js +19 -0
- package/lib/programmatic/openapi-spec.js +13 -8
- package/lib/programmatic/platform-rbac-catalog.js +36 -18
- package/lib/programmatic/request-timeout.js +3 -0
- package/lib/programmatic/route-handler-map.js +58 -1
- package/lib/programmatic/route-handlers-context.js +2 -1
- package/lib/programmatic/run-auth-permissions.js +54 -0
- package/lib/programmatic/run-channel-catalog.js +238 -0
- package/lib/programmatic/run-channel-install-artifacts.js +137 -0
- package/lib/programmatic/run-channel-install-copilot.js +353 -0
- package/lib/programmatic/run-channel-install-options.js +236 -0
- package/lib/programmatic/run-channel-install-teams-bot.js +204 -0
- package/lib/programmatic/run-channel-install.js +346 -0
- package/lib/programmatic/run-channel-package.js +87 -7
- package/lib/programmatic/run-download.js +41 -0
- package/lib/programmatic/workspace-context.js +2 -0
- package/lib/protection/auth-context.js +3 -1
- package/lib/protection/protection-display.js +3 -2
- package/lib/protection/report-exit.js +50 -0
- package/lib/protection/run-commands.js +2 -0
- package/lib/role-assistant/evidence-sync.js +4 -2
- package/lib/role-assistant/evidence-validation-issues.js +51 -0
- package/lib/role-assistant/knowledge-sync.js +10 -4
- package/lib/role-assistant/package-validate.js +175 -0
- package/lib/role-assistant/settings.js +49 -2
- package/lib/role-assistant/test-case-assertion-row.js +36 -0
- package/lib/role-assistant/test-case-copy-bind.js +77 -0
- package/lib/role-assistant/test-case-copy-expected.js +127 -0
- package/lib/role-assistant/test-case-copy-from-work.js +90 -0
- package/lib/role-assistant/test-case-copy-interactions.js +67 -0
- package/lib/role-assistant/test-case-copy.js +119 -0
- package/lib/role-assistant/test-case-expected-catalog.js +135 -0
- package/lib/role-assistant/test-case-validate.js +88 -0
- package/lib/role-assistant/test-cases-bid.js +117 -4
- package/lib/role-assistant/test-cases-evaluate.js +159 -24
- package/lib/role-assistant/test-cases-evidence.js +175 -0
- package/lib/role-assistant/test-cases-honesty.js +155 -6
- package/lib/role-assistant/test-cases-lifecycle.js +291 -0
- package/lib/role-assistant/test-cases-search-graph.js +122 -0
- package/lib/role-assistant/test-cases-search.js +247 -0
- package/lib/role-assistant/test-cases.js +71 -172
- package/lib/role-assistant/test-pack-map.js +180 -0
- package/lib/role-assistant/test-pack-sync.js +187 -0
- package/lib/role-assistant/test-runner-debug.js +54 -0
- package/lib/role-assistant/test-runner-respond-body.js +36 -0
- package/lib/role-assistant/test-runner-search.js +164 -0
- package/lib/role-assistant/test-runner-start-payload.js +63 -10
- package/lib/role-assistant/test-runner-workhub-answers.js +45 -16
- package/lib/role-assistant/test-runner-workhub-helpers.js +40 -2
- package/lib/role-assistant/test-runner-workhub-soft.js +9 -3
- package/lib/role-assistant/test-runner-workhub.js +74 -32
- package/lib/role-assistant/test-runner.js +66 -11
- package/lib/schema/external-datasource.schema.json +146 -21
- package/lib/schema/external-system.schema.json +177 -2
- package/lib/schema/mcp-client-profile.schema.json +103 -0
- package/lib/schema/role-assistant-test-case.schema.json +408 -0
- package/lib/search/dataplane-context.js +23 -0
- package/lib/search/search-args.js +211 -0
- package/lib/search/search-display.js +238 -0
- package/lib/search/search-errors.js +50 -0
- package/lib/search/search-prompts.js +119 -0
- package/lib/search/search-roles.js +85 -0
- package/lib/search/search-run.js +241 -0
- package/lib/search/search-skills.js +198 -0
- package/lib/utils/app-path-resolve.js +4 -0
- package/lib/utils/authentication-env-template.js +44 -6
- package/lib/utils/authentication-slot-show.js +153 -0
- package/lib/utils/credential-display.js +43 -1
- package/lib/utils/credential-secrets-env.js +6 -1
- package/lib/utils/env-copy.js +19 -7
- package/lib/utils/external-env-template.js +20 -2
- package/lib/utils/external-system-readiness-compact-blocks.js +5 -1
- package/lib/utils/external-system-readiness-compact-display.js +30 -1
- package/lib/utils/external-system-validators.js +2 -1
- package/lib/utils/help-builder.js +3 -1
- package/lib/utils/paths.js +18 -1
- package/lib/utils/platform-shell-package.js +69 -0
- package/lib/utils/port-resolver.js +50 -1
- package/lib/utils/rewrite-name-flag.js +20 -0
- package/lib/utils/role-assistant-paths.js +13 -10
- package/lib/utils/schema-loader.js +37 -0
- package/lib/utils/schema-resolver.js +11 -1
- package/lib/utils/secrets-helpers.js +12 -21
- package/lib/utils/token-manager.js +10 -5
- package/lib/validation/validate-external-file.js +5 -1
- package/lib/validation/validate.js +41 -0
- package/package.json +1 -1
- package/templates/README.md +1 -1
- package/templates/agent-kit/adapters/claude/nested.CLAUDE.md +1 -0
- package/templates/agent-kit/adapters/claude/root.CLAUDE.md +5 -0
- package/templates/agent-kit/adapters/cursor/commands/cust-0-plan.md +5 -0
- package/templates/agent-kit/adapters/cursor/commands/cust-1-validate.md +5 -0
- package/templates/agent-kit/adapters/cursor/commands/cust-2-build.md +5 -0
- package/templates/agent-kit/adapters/cursor/commands/cust-3-push.md +5 -0
- package/templates/agent-kit/adapters/cursor/commands/cust-biz-1-validate.md +5 -0
- package/templates/agent-kit/adapters/cursor/commands/cust-biz-2-build.md +5 -0
- package/templates/agent-kit/adapters/cursor/commands/cust-biz-3-prove.md +5 -0
- package/templates/agent-kit/agent-kit.yaml +45 -0
- package/templates/agent-kit/instructions/AGENTKIT.md +83 -0
- package/templates/agent-kit/instructions/integration.AGENTS.md +25 -0
- package/templates/agent-kit/instructions/role-assistant.AGENTS.md +22 -0
- package/templates/agent-kit/instructions/root.AGENTS.md +37 -0
- package/templates/agent-kit/parity-inventory.yaml +188 -0
- package/templates/agent-kit/skills/aifabrix-connected-system/SKILL.md +58 -0
- package/templates/agent-kit/skills/aifabrix-connected-system/references/contract-checklist.md +40 -0
- package/templates/agent-kit/skills/aifabrix-connected-system/references/delivery-gates.md +54 -0
- package/templates/agent-kit/skills/aifabrix-connected-system/references/production-safety.md +35 -0
- package/templates/agent-kit/skills/aifabrix-connected-system/scripts/reserved-system-key.js +19 -0
- package/templates/agent-kit/skills/aifabrix-plan/SKILL.md +51 -0
- package/templates/agent-kit/skills/aifabrix-plan/references/challenge-checklist.md +108 -0
- package/templates/agent-kit/skills/aifabrix-plan/references/interaction.md +34 -0
- package/templates/agent-kit/skills/aifabrix-plan/references/plan-template.md +182 -0
- package/templates/agent-kit/skills/aifabrix-prove/SKILL.md +50 -0
- package/templates/agent-kit/skills/aifabrix-prove/references/demo-template.md +65 -0
- package/templates/agent-kit/skills/aifabrix-prove/references/evidence-lifecycle.md +68 -0
- package/templates/agent-kit/skills/aifabrix-prove/references/learning-template.md +66 -0
- package/templates/agent-kit/skills/aifabrix-role-assistant/SKILL.md +42 -0
- package/templates/agent-kit/skills/aifabrix-role-assistant/references/package-boundary.md +21 -0
- package/templates/agent-kit/skills/shared/hosts.md +78 -0
- package/templates/agent-kit/workspace/.cursor/plans/README.md +22 -0
- package/templates/agent-kit/workspace/LICENSE.mit +21 -0
- package/templates/agent-kit/workspace/README.md +89 -0
- package/templates/applications/builder-api/Dockerfile +3 -1
- package/templates/applications/builder-api/env.template +7 -0
- package/templates/applications/dataplane/application.yaml +6 -5
- package/templates/applications/dataplane/env.template +2 -2
- package/templates/applications/dataplane/rbac.yaml +35 -2
- package/templates/applications/keycloak/Dockerfile +30 -4
- package/templates/applications/keycloak/application.yaml +2 -2
- package/templates/applications/keycloak/cimd-lenient-parse/AbstractClientIdMetadataDocumentExecutor.java +896 -0
- package/templates/applications/keycloak/cimd-lenient-parse/SOURCE.md +19 -0
- package/templates/applications/keycloak/env.template +3 -0
- package/templates/applications/miso-controller/application.yaml +1 -2
- package/templates/applications/miso-controller/env.template +10 -9
- package/templates/channels/README.md +5 -5
- package/templates/channels/chatgpt/TROUBLESHOOTING.md +51 -0
- package/templates/channels/chatgpt/channel.json +59 -0
- package/templates/channels/chatgpt/icon.svg +1 -0
- package/templates/channels/chatgpt/install.template.md.hbs +20 -95
- package/templates/channels/chatgpt/integration/README.md +1 -1
- package/templates/channels/chatgpt/integration/application.json +2 -2
- package/templates/channels/chatgpt/integration/chatgpt-system.json +49 -4
- package/templates/channels/chatgpt/integration/env.template +2 -4
- package/templates/channels/chatgpt/integration/rbac.json +13 -0
- package/templates/channels/claude/TROUBLESHOOTING.md +44 -0
- package/templates/channels/claude/channel.json +59 -0
- package/templates/channels/claude/icon.svg +1 -0
- package/templates/channels/claude/install.template.md.hbs +22 -0
- package/templates/channels/claude/integration/README.md +14 -0
- package/templates/channels/claude/integration/application.json +15 -0
- package/templates/channels/claude/integration/claude-system.json +59 -0
- package/templates/channels/claude/integration/env.template +2 -0
- package/templates/channels/claude/integration/rbac.json +13 -0
- package/templates/channels/claude/manifest.template.json.hbs +40 -0
- package/templates/channels/mcp-client/channel.json +72 -0
- package/templates/channels/mcp-client/icon.svg +1 -0
- package/templates/channels/mcp-client/install.template.md.hbs +24 -0
- package/templates/channels/mcp-client/integration/README.md +13 -0
- package/templates/channels/mcp-client/integration/application.json +15 -0
- package/templates/channels/mcp-client/integration/env.template +2 -0
- package/templates/channels/mcp-client/integration/mcp-client-system.json +72 -0
- package/templates/channels/mcp-client/integration/rbac.json +13 -0
- package/templates/channels/mcp-client/manifest.template.json.hbs +41 -0
- package/templates/channels/mcp-client/profiles/cursor.json +26 -0
- package/templates/channels/mcp-client/profiles/github-copilot.json +29 -0
- package/templates/channels/mcp-client/profiles/vscode.json +29 -0
- package/templates/channels/microsoft-copilot/channel.json +73 -0
- package/templates/channels/microsoft-copilot/declarative-agent.template.json.hbs +8 -4
- package/templates/channels/microsoft-copilot/entra-sso-registration.template.md.hbs +65 -5
- package/templates/channels/microsoft-copilot/icon.svg +1 -0
- package/templates/channels/microsoft-copilot/install.template.md.hbs +9 -9
- package/templates/channels/microsoft-copilot/integration/README.md +1 -1
- package/templates/channels/microsoft-copilot/integration/application.json +2 -2
- package/templates/channels/microsoft-copilot/integration/env.template +3 -6
- package/templates/channels/microsoft-copilot/integration/microsoft-copilot-system.json +63 -4
- package/templates/channels/microsoft-copilot/integration/rbac.json +13 -0
- package/templates/channels/microsoft-copilot/oauth-plugin-vault-required.template.md.hbs +5 -5
- package/templates/channels/slack/channel.json +234 -0
- package/templates/channels/slack/icon.svg +1 -0
- package/templates/channels/slack/install.template.md.hbs +45 -28
- package/templates/channels/slack/integration/README.md +245 -22
- package/templates/channels/slack/integration/application.json +44 -7
- package/templates/channels/slack/integration/env.template +15 -6
- package/templates/channels/slack/integration/openapi/openapi.json +126 -0
- package/templates/channels/slack/integration/rbac.json +84 -0
- package/templates/channels/slack/integration/slack-datasource-commands.json +154 -0
- package/templates/channels/slack/integration/slack-datasource-conversations.json +28 -3
- package/templates/channels/slack/integration/slack-datasource-events.json +154 -0
- package/templates/channels/slack/integration/slack-datasource-interactive.json +154 -0
- package/templates/channels/slack/integration/slack-datasource-messages.json +40 -2
- package/templates/channels/slack/integration/slack-system.json +161 -72
- package/templates/channels/slack/manifest.template.json.hbs +10 -4
- package/templates/channels/teams-bot/channel.json +162 -0
- package/templates/channels/teams-bot/icon.svg +1 -0
- package/templates/channels/teams-bot/install.template.md.hbs +12 -13
- package/templates/channels/teams-bot/integration/README.md +5 -4
- package/templates/channels/teams-bot/integration/application.json +6 -4
- package/templates/channels/teams-bot/integration/env.template +5 -4
- package/templates/channels/teams-bot/integration/openapi/openapi.json +68 -0
- package/templates/channels/teams-bot/integration/rbac.json +21 -0
- package/templates/channels/teams-bot/integration/teams-bot-datasource-activities.json +154 -0
- package/templates/channels/teams-bot/integration/teams-bot-system.json +128 -23
- package/templates/channels/web-embed/channel.json +60 -0
- package/templates/channels/web-embed/install.template.md.hbs +1 -1
- package/templates/channels/web-embed/integration/README.md +2 -2
- package/templates/channels/web-embed/integration/application.json +2 -2
- package/templates/channels/web-embed/integration/env.template +1 -1
- package/templates/channels/web-embed/integration/rbac.json +13 -0
- package/templates/channels/web-embed/integration/web-embed-system.json +50 -4
- package/templates/python/docker-compose.hbs +14 -0
- package/templates/typescript/docker-compose.hbs +14 -0
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Slack workspace identity from login store or `slack auth list`.
|
|
3
|
+
*
|
|
4
|
+
* @fileoverview Fail closed when multiple workspaces cannot be proven
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
'use strict';
|
|
8
|
+
|
|
9
|
+
const { promisify } = require('util');
|
|
10
|
+
const execFileDefault = promisify(require('child_process').execFile);
|
|
11
|
+
const { slackProvisioningError, wrapSlackCliError } = require('./errors');
|
|
12
|
+
const { resolveSlackBinary, runSlackApi, shouldSkipLiveSlackCli } = require('./cli');
|
|
13
|
+
const { withSlackCliPath } = require('./install-cli');
|
|
14
|
+
const {
|
|
15
|
+
readSlackCredentialEntries,
|
|
16
|
+
publicSlackAuths,
|
|
17
|
+
parseAuthListText
|
|
18
|
+
} = require('./auth-store');
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* @param {Object} [deps]
|
|
22
|
+
* @returns {Promise<Object[]>}
|
|
23
|
+
*/
|
|
24
|
+
async function listSlackAuthsFromCli(deps = {}) {
|
|
25
|
+
const bin = await resolveSlackBinary(deps);
|
|
26
|
+
if (!bin) {
|
|
27
|
+
return [];
|
|
28
|
+
}
|
|
29
|
+
const execFileImpl = deps.execFile || execFileDefault;
|
|
30
|
+
try {
|
|
31
|
+
const result = await execFileImpl(bin, ['auth', 'list', '--no-color', '-s'], {
|
|
32
|
+
timeout: 30000,
|
|
33
|
+
maxBuffer: 1024 * 1024,
|
|
34
|
+
env: withSlackCliPath(deps.env || process.env)
|
|
35
|
+
});
|
|
36
|
+
return parseAuthListText(result && result.stdout);
|
|
37
|
+
} catch (error) {
|
|
38
|
+
throw wrapSlackCliError(error);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* @param {Object} [deps]
|
|
44
|
+
* @returns {Promise<Object[]>}
|
|
45
|
+
*/
|
|
46
|
+
async function listSlackAuths(deps = {}) {
|
|
47
|
+
if (typeof deps.listAuths === 'function') {
|
|
48
|
+
const listed = await deps.listAuths();
|
|
49
|
+
return Array.isArray(listed) ? listed : [];
|
|
50
|
+
}
|
|
51
|
+
const fromFile = publicSlackAuths(readSlackCredentialEntries(deps));
|
|
52
|
+
if (fromFile.length > 0) {
|
|
53
|
+
return fromFile;
|
|
54
|
+
}
|
|
55
|
+
if (shouldSkipLiveSlackCli(deps) && typeof deps.execFile !== 'function') {
|
|
56
|
+
return [];
|
|
57
|
+
}
|
|
58
|
+
return listSlackAuthsFromCli(deps);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Prove workspace identity from a short-lived session token for this run only.
|
|
63
|
+
* @param {Object} [deps]
|
|
64
|
+
* @returns {Promise<Object|null>}
|
|
65
|
+
*/
|
|
66
|
+
async function workspaceFromSessionToken(deps = {}) {
|
|
67
|
+
const token = typeof deps.slackUserToken === 'string' ? deps.slackUserToken.trim() : '';
|
|
68
|
+
if (!token) {
|
|
69
|
+
return null;
|
|
70
|
+
}
|
|
71
|
+
if (typeof deps.authTest === 'function') {
|
|
72
|
+
const listed = await deps.authTest();
|
|
73
|
+
if (!listed || !(listed.team_id || listed.teamId)) {
|
|
74
|
+
throw slackProvisioningError('Session token was not accepted.', 'UNPROVEN_IDENTITY');
|
|
75
|
+
}
|
|
76
|
+
return listed;
|
|
77
|
+
}
|
|
78
|
+
const body = await runSlackApi('auth.test', {}, deps);
|
|
79
|
+
if (!body || body.ok !== true || !(body.team_id || body.teamId)) {
|
|
80
|
+
throw slackProvisioningError('Session token was not accepted.', 'UNPROVEN_IDENTITY');
|
|
81
|
+
}
|
|
82
|
+
return { team_id: body.team_id || body.teamId, team: body.team };
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* @param {Object[]} auths
|
|
87
|
+
* @param {string} [expectedTeamId]
|
|
88
|
+
* @returns {Object}
|
|
89
|
+
*/
|
|
90
|
+
function pickSlackWorkspace(auths, expectedTeamId) {
|
|
91
|
+
const rows = Array.isArray(auths) ? auths : [];
|
|
92
|
+
if (expectedTeamId) {
|
|
93
|
+
const match = rows.find((row) => String(row.team_id || row.teamId || '') === expectedTeamId);
|
|
94
|
+
if (!match) {
|
|
95
|
+
throw slackProvisioningError(
|
|
96
|
+
`Signed-in Slack workspace does not match expected team "${expectedTeamId}".`,
|
|
97
|
+
'UNPROVEN_IDENTITY'
|
|
98
|
+
);
|
|
99
|
+
}
|
|
100
|
+
return match;
|
|
101
|
+
}
|
|
102
|
+
if (rows.length > 1) {
|
|
103
|
+
throw slackProvisioningError(
|
|
104
|
+
'Multiple Slack workspaces are signed in. Pass the expected team id rather than guessing.',
|
|
105
|
+
'UNPROVEN_IDENTITY'
|
|
106
|
+
);
|
|
107
|
+
}
|
|
108
|
+
return rows[0] || null;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
module.exports = {
|
|
112
|
+
listSlackAuths,
|
|
113
|
+
pickSlackWorkspace,
|
|
114
|
+
workspaceFromSessionToken
|
|
115
|
+
};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Fail before Slack create when callback URLs are missing or not public HTTPS.
|
|
3
|
+
*
|
|
4
|
+
* @fileoverview Events / interactivity / commands Request URLs
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
'use strict';
|
|
8
|
+
|
|
9
|
+
const { REQUIRED_CALLBACK_KEYS } = require('./constants');
|
|
10
|
+
const { slackProvisioningError } = require('./errors');
|
|
11
|
+
const { isPublicHttpsUrl } = require('../vendor-dataplane-url');
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* @param {Object} runtimeValues
|
|
15
|
+
* @returns {void}
|
|
16
|
+
*/
|
|
17
|
+
function assertSlackCallbackUrls(runtimeValues) {
|
|
18
|
+
const missing = REQUIRED_CALLBACK_KEYS.filter((key) => {
|
|
19
|
+
const value = runtimeValues && runtimeValues[key];
|
|
20
|
+
return typeof value !== 'string' || !value.trim();
|
|
21
|
+
});
|
|
22
|
+
if (missing.length > 0) {
|
|
23
|
+
throw slackProvisioningError(
|
|
24
|
+
`Slack callback URLs are missing: ${missing.join(', ')}. ` +
|
|
25
|
+
'Generate the channel package against a public HTTPS dataplane before create.',
|
|
26
|
+
'CALLBACKS'
|
|
27
|
+
);
|
|
28
|
+
}
|
|
29
|
+
const unusable = REQUIRED_CALLBACK_KEYS.filter((key) => !isPublicHttpsUrl(runtimeValues[key]));
|
|
30
|
+
if (unusable.length > 0) {
|
|
31
|
+
throw slackProvisioningError(
|
|
32
|
+
`Slack callback URLs must be public HTTPS: ${unusable.join(', ')}.`,
|
|
33
|
+
'CALLBACKS'
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
module.exports = {
|
|
39
|
+
isPublicHttpsUrl,
|
|
40
|
+
assertSlackCallbackUrls
|
|
41
|
+
};
|
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Spawn Slack CLI (`slack api …`) without scattering argv.
|
|
3
|
+
*
|
|
4
|
+
* @fileoverview Documented CLI only; skipped under Jest unless deps allow it
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
'use strict';
|
|
8
|
+
|
|
9
|
+
const path = require('path');
|
|
10
|
+
const { promisify } = require('util');
|
|
11
|
+
const execFileDefault = promisify(require('child_process').execFile);
|
|
12
|
+
const { SLACK_BINARIES } = require('./constants');
|
|
13
|
+
const { slackProvisioningError, wrapSlackCliError } = require('./errors');
|
|
14
|
+
const { withSlackCliPath, slackCliLocalBinDir } = require('./install-cli');
|
|
15
|
+
const { readSlackCredentialEntries, slackUserTokenForTeam } = require('./auth-store');
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* @returns {boolean}
|
|
19
|
+
*/
|
|
20
|
+
function isJestWorker() {
|
|
21
|
+
return Boolean(process.env.JEST_WORKER_ID);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* @param {Object} [deps]
|
|
26
|
+
* @returns {boolean}
|
|
27
|
+
*/
|
|
28
|
+
function shouldSkipLiveSlackCli(deps = {}) {
|
|
29
|
+
if (deps.allowInTests === true) {
|
|
30
|
+
return false;
|
|
31
|
+
}
|
|
32
|
+
return isJestWorker();
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* @returns {string[]}
|
|
37
|
+
*/
|
|
38
|
+
function slackBinaryCandidates() {
|
|
39
|
+
const local = path.join(slackCliLocalBinDir(), 'slack');
|
|
40
|
+
return [local, ...SLACK_BINARIES];
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* @param {typeof execFileDefault} execFileImpl
|
|
45
|
+
* @param {string} bin
|
|
46
|
+
* @param {Object} [deps]
|
|
47
|
+
* @returns {Promise<boolean>}
|
|
48
|
+
*/
|
|
49
|
+
async function binaryResponds(execFileImpl, bin, deps = {}) {
|
|
50
|
+
try {
|
|
51
|
+
await execFileImpl(bin, ['--version'], {
|
|
52
|
+
timeout: 20000,
|
|
53
|
+
env: withSlackCliPath(deps.env || process.env)
|
|
54
|
+
});
|
|
55
|
+
return true;
|
|
56
|
+
} catch {
|
|
57
|
+
return false;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* @param {Object} [deps]
|
|
63
|
+
* @returns {Promise<string|null>}
|
|
64
|
+
*/
|
|
65
|
+
async function resolveSlackBinary(deps = {}) {
|
|
66
|
+
if (typeof deps.slackBinary === 'string' && deps.slackBinary.trim()) {
|
|
67
|
+
return deps.slackBinary.trim();
|
|
68
|
+
}
|
|
69
|
+
if (shouldSkipLiveSlackCli(deps)) {
|
|
70
|
+
return null;
|
|
71
|
+
}
|
|
72
|
+
const execFileImpl = deps.execFile || execFileDefault;
|
|
73
|
+
for (const bin of slackBinaryCandidates()) {
|
|
74
|
+
if (await binaryResponds(execFileImpl, bin, deps)) {
|
|
75
|
+
return bin;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
return null;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Slack CLI `api` does not load ~/.slack/credentials.json unless a token is set.
|
|
83
|
+
* @param {Object} [deps]
|
|
84
|
+
* @returns {NodeJS.ProcessEnv}
|
|
85
|
+
*/
|
|
86
|
+
function slackApiChildEnv(deps = {}) {
|
|
87
|
+
const env = withSlackCliPath(deps.env || process.env);
|
|
88
|
+
if (env.SLACK_USER_TOKEN || env.SLACK_BOT_TOKEN) {
|
|
89
|
+
return env;
|
|
90
|
+
}
|
|
91
|
+
if (typeof deps.slackUserToken === 'string' && deps.slackUserToken.trim()) {
|
|
92
|
+
return { ...env, SLACK_USER_TOKEN: deps.slackUserToken.trim() };
|
|
93
|
+
}
|
|
94
|
+
const token = slackUserTokenForTeam(readSlackCredentialEntries(deps), deps.teamId);
|
|
95
|
+
return token ? { ...env, SLACK_USER_TOKEN: token } : env;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Slack CLI 4.x: `slack api <method> --json '{...}' [-w team]`.
|
|
100
|
+
* @param {string} method
|
|
101
|
+
* @param {Object} [payload]
|
|
102
|
+
* @param {Object} [deps]
|
|
103
|
+
* @returns {string[]}
|
|
104
|
+
*/
|
|
105
|
+
function buildSlackApiArgs(method, payload = {}, deps = {}) {
|
|
106
|
+
const args = ['api', method, '--json', JSON.stringify(payload || {}), '--no-color', '-s'];
|
|
107
|
+
if (typeof deps.teamId === 'string' && deps.teamId.trim()) {
|
|
108
|
+
args.push('-w', deps.teamId.trim());
|
|
109
|
+
}
|
|
110
|
+
return args;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* @param {string} stdout
|
|
115
|
+
* @returns {Object}
|
|
116
|
+
*/
|
|
117
|
+
function parseJsonStdout(stdout) {
|
|
118
|
+
const text = String(stdout || '').trim();
|
|
119
|
+
if (!text) {
|
|
120
|
+
return {};
|
|
121
|
+
}
|
|
122
|
+
try {
|
|
123
|
+
return JSON.parse(text);
|
|
124
|
+
} catch {
|
|
125
|
+
const start = text.indexOf('{');
|
|
126
|
+
const end = text.lastIndexOf('}');
|
|
127
|
+
if (start >= 0 && end > start) {
|
|
128
|
+
return JSON.parse(text.slice(start, end + 1));
|
|
129
|
+
}
|
|
130
|
+
throw wrapSlackCliError(new Error('Slack CLI returned non-JSON output'));
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* @param {unknown} error
|
|
136
|
+
* @returns {Object|null}
|
|
137
|
+
*/
|
|
138
|
+
function jsonBodyFromCliError(error) {
|
|
139
|
+
const stdout = error && error.stdout;
|
|
140
|
+
if (!stdout) {
|
|
141
|
+
return null;
|
|
142
|
+
}
|
|
143
|
+
try {
|
|
144
|
+
const body = parseJsonStdout(stdout);
|
|
145
|
+
return body && typeof body === 'object' ? body : null;
|
|
146
|
+
} catch {
|
|
147
|
+
return null;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* Documented `slack api <method>` with a JSON payload.
|
|
153
|
+
* @param {string} method
|
|
154
|
+
* @param {Object} [payload]
|
|
155
|
+
* @param {Object} [deps]
|
|
156
|
+
* @returns {Promise<Object>}
|
|
157
|
+
*/
|
|
158
|
+
async function runSlackApi(method, payload = {}, deps = {}) {
|
|
159
|
+
if (typeof deps.slackApi === 'function') {
|
|
160
|
+
return deps.slackApi(method, payload);
|
|
161
|
+
}
|
|
162
|
+
const bin = await resolveSlackBinary(deps);
|
|
163
|
+
if (!bin) {
|
|
164
|
+
throw slackProvisioningError(
|
|
165
|
+
'Slack CLI (`slack`) is not installed or not on PATH.',
|
|
166
|
+
'SLACK_CLI_MISSING'
|
|
167
|
+
);
|
|
168
|
+
}
|
|
169
|
+
const execFileImpl = deps.execFile || execFileDefault;
|
|
170
|
+
try {
|
|
171
|
+
const result = await execFileImpl(bin, buildSlackApiArgs(method, payload, deps), {
|
|
172
|
+
cwd: deps.cwd,
|
|
173
|
+
env: slackApiChildEnv(deps),
|
|
174
|
+
timeout: deps.timeout || 180000,
|
|
175
|
+
maxBuffer: 2 * 1024 * 1024
|
|
176
|
+
});
|
|
177
|
+
return parseJsonStdout(result && result.stdout);
|
|
178
|
+
} catch (error) {
|
|
179
|
+
const body = jsonBodyFromCliError(error);
|
|
180
|
+
if (body) {
|
|
181
|
+
return body;
|
|
182
|
+
}
|
|
183
|
+
throw wrapSlackCliError(error);
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* Native Slack CLI install (project-based; may no-op without a Slack app project).
|
|
189
|
+
* @param {string} appId
|
|
190
|
+
* @param {Object} [deps]
|
|
191
|
+
* @returns {Promise<Object>}
|
|
192
|
+
*/
|
|
193
|
+
async function runNativeAppInstall(appId, deps = {}) {
|
|
194
|
+
const bin = await resolveSlackBinary(deps);
|
|
195
|
+
if (!bin || !appId) {
|
|
196
|
+
return {};
|
|
197
|
+
}
|
|
198
|
+
const execFileImpl = deps.execFile || execFileDefault;
|
|
199
|
+
const args = ['app', 'install', '-a', String(appId), '--no-color', '-s', '-f'];
|
|
200
|
+
if (typeof deps.teamId === 'string' && deps.teamId.trim()) {
|
|
201
|
+
args.push('-w', deps.teamId.trim());
|
|
202
|
+
}
|
|
203
|
+
try {
|
|
204
|
+
const result = await execFileImpl(bin, args, {
|
|
205
|
+
cwd: deps.cwd,
|
|
206
|
+
env: slackApiChildEnv(deps),
|
|
207
|
+
timeout: deps.timeout || 180000,
|
|
208
|
+
killSignal: 'SIGKILL',
|
|
209
|
+
maxBuffer: 2 * 1024 * 1024
|
|
210
|
+
});
|
|
211
|
+
return parseJsonStdout(result && result.stdout);
|
|
212
|
+
} catch {
|
|
213
|
+
return {};
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
module.exports = {
|
|
218
|
+
isJestWorker,
|
|
219
|
+
shouldSkipLiveSlackCli,
|
|
220
|
+
resolveSlackBinary,
|
|
221
|
+
runSlackApi,
|
|
222
|
+
runNativeAppInstall,
|
|
223
|
+
parseJsonStdout,
|
|
224
|
+
buildSlackApiArgs,
|
|
225
|
+
slackApiChildEnv
|
|
226
|
+
};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Slack channel provisioning constants.
|
|
3
|
+
*
|
|
4
|
+
* @fileoverview Shared keys — never persist Slack tokens
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
'use strict';
|
|
8
|
+
|
|
9
|
+
const STATE_KIND = 'slack-channel';
|
|
10
|
+
const STATE_FILE = 'provisioning-state.json';
|
|
11
|
+
const SLACK_BINARIES = ['slack'];
|
|
12
|
+
const SECRET_KEY_RE =
|
|
13
|
+
/^(accessToken|refreshToken|botToken|bot_token|signingSecret|signing_secret|client_secret|clientSecret|password)$/i;
|
|
14
|
+
const KV_SIGNING_SECRET = 'kv://slack/signingSecret';
|
|
15
|
+
const KV_BOT_TOKEN = 'kv://slack/botToken';
|
|
16
|
+
const KV_CLIENT_SECRET = 'kv://slack/clientSecret';
|
|
17
|
+
/** Slack create/install writes these into integration .env, then dataplane push. */
|
|
18
|
+
const SLACK_PROVISIONED_KV_KEYS = [KV_SIGNING_SECRET, KV_BOT_TOKEN, KV_CLIENT_SECRET];
|
|
19
|
+
const SLACK_APPS_URL = 'https://api.slack.com/apps';
|
|
20
|
+
const SLACK_CLI_DOCS_URL = 'https://docs.slack.dev/tools/slack-cli';
|
|
21
|
+
const SLACK_CLI_INSTALL_SCRIPT_URL = 'https://downloads.slack-edge.com/slack-cli/install.sh';
|
|
22
|
+
const REQUIRED_CALLBACK_KEYS = ['eventsUrl', 'interactionUrl', 'commandUrl'];
|
|
23
|
+
|
|
24
|
+
module.exports = {
|
|
25
|
+
STATE_KIND,
|
|
26
|
+
STATE_FILE,
|
|
27
|
+
SLACK_BINARIES,
|
|
28
|
+
SECRET_KEY_RE,
|
|
29
|
+
KV_SIGNING_SECRET,
|
|
30
|
+
KV_BOT_TOKEN,
|
|
31
|
+
KV_CLIENT_SECRET,
|
|
32
|
+
SLACK_PROVISIONED_KV_KEYS,
|
|
33
|
+
SLACK_APPS_URL,
|
|
34
|
+
SLACK_CLI_DOCS_URL,
|
|
35
|
+
SLACK_CLI_INSTALL_SCRIPT_URL,
|
|
36
|
+
REQUIRED_CALLBACK_KEYS
|
|
37
|
+
};
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Store Slack secrets locally (secret set) then publish to dataplane.
|
|
3
|
+
*
|
|
4
|
+
* @fileoverview Never log or persist secret values in dist /
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
'use strict';
|
|
8
|
+
|
|
9
|
+
const { storeCredentialSecrets } = require('../../api/credential.api');
|
|
10
|
+
const { KV_BOT_TOKEN, KV_CLIENT_SECRET, KV_SIGNING_SECRET } = require('./constants');
|
|
11
|
+
const { writeSlackSecretsEnvFiles } = require('./env-file');
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* @param {string} [value]
|
|
15
|
+
* @returns {boolean}
|
|
16
|
+
*/
|
|
17
|
+
function hasSecretValue(value) {
|
|
18
|
+
return typeof value === 'string' && Boolean(value.trim());
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* @param {string} kvPath
|
|
23
|
+
* @returns {string}
|
|
24
|
+
*/
|
|
25
|
+
function kvPathToSecretSetKey(kvPath) {
|
|
26
|
+
return String(kvPath || '').replace(/^kv:\/\//, '');
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* @param {Object} captured
|
|
31
|
+
* @param {Object} credentials
|
|
32
|
+
* @param {string[]} names
|
|
33
|
+
* @returns {string|undefined}
|
|
34
|
+
*/
|
|
35
|
+
function pickNamedSecret(captured, credentials, names) {
|
|
36
|
+
for (const name of names) {
|
|
37
|
+
if (hasSecretValue(captured[name])) return captured[name];
|
|
38
|
+
if (hasSecretValue(credentials[name])) return credentials[name];
|
|
39
|
+
}
|
|
40
|
+
return undefined;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* @param {unknown} value
|
|
45
|
+
* @returns {Object}
|
|
46
|
+
*/
|
|
47
|
+
function asSecretMap(value) {
|
|
48
|
+
if (value && typeof value === 'object' && !Array.isArray(value)) {
|
|
49
|
+
return value;
|
|
50
|
+
}
|
|
51
|
+
if (typeof value === 'string' && value.trim().startsWith('{')) {
|
|
52
|
+
try {
|
|
53
|
+
const parsed = JSON.parse(value);
|
|
54
|
+
return parsed && typeof parsed === 'object' && !Array.isArray(parsed) ? parsed : {};
|
|
55
|
+
} catch {
|
|
56
|
+
return {};
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
return {};
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* @param {Object} captured
|
|
64
|
+
* @returns {{ signingSecret?: string, botToken?: string, clientSecret?: string }}
|
|
65
|
+
*/
|
|
66
|
+
function pickSlackSecrets(captured) {
|
|
67
|
+
const source = captured || {};
|
|
68
|
+
const nested = asSecretMap(source.body || source.data);
|
|
69
|
+
const credentials = asSecretMap(source.credentials || nested.credentials);
|
|
70
|
+
const fromSource = pickNamedSecret(source, credentials, ['signingSecret', 'signing_secret']);
|
|
71
|
+
const fromNested = pickNamedSecret(nested, credentials, ['signingSecret', 'signing_secret']);
|
|
72
|
+
return {
|
|
73
|
+
signingSecret: fromSource || fromNested,
|
|
74
|
+
botToken: pickNamedSecret(source, credentials, ['botToken', 'bot_token', 'access_token'])
|
|
75
|
+
|| pickNamedSecret(nested, credentials, ['botToken', 'bot_token', 'access_token']),
|
|
76
|
+
clientSecret: pickNamedSecret(source, credentials, ['clientSecret', 'client_secret'])
|
|
77
|
+
|| pickNamedSecret(nested, credentials, ['clientSecret', 'client_secret'])
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* @param {{ signingSecret?: string, botToken?: string, clientSecret?: string }} secrets
|
|
83
|
+
* @returns {Array<{ key: string, value: string }>}
|
|
84
|
+
*/
|
|
85
|
+
function slackSecretItems(secrets) {
|
|
86
|
+
const pairs = [
|
|
87
|
+
[KV_SIGNING_SECRET, secrets && secrets.signingSecret],
|
|
88
|
+
[KV_BOT_TOKEN, secrets && secrets.botToken],
|
|
89
|
+
[KV_CLIENT_SECRET, secrets && secrets.clientSecret]
|
|
90
|
+
];
|
|
91
|
+
return pairs
|
|
92
|
+
.filter(([, value]) => hasSecretValue(value))
|
|
93
|
+
.map(([key, value]) => ({ key, value: String(value).trim() }));
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* @param {Array<{ key: string, value: string }>} items
|
|
98
|
+
* @param {Object} deps
|
|
99
|
+
* @returns {Promise<void>}
|
|
100
|
+
*/
|
|
101
|
+
async function writeSlackSecretsLocal(items, deps) {
|
|
102
|
+
const setSecret =
|
|
103
|
+
deps.setSecretInStore || require('../../core/secrets-ensure').setSecretInStore;
|
|
104
|
+
for (const item of items) {
|
|
105
|
+
await setSecret(kvPathToSecretSetKey(item.key), item.value);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* @param {Object} [deps]
|
|
111
|
+
* @returns {Promise<boolean>}
|
|
112
|
+
*/
|
|
113
|
+
async function localSlackSigningPresent(deps = {}) {
|
|
114
|
+
if (typeof deps.hasLocalSlackSigningSecret === 'function') {
|
|
115
|
+
return deps.hasLocalSlackSigningSecret();
|
|
116
|
+
}
|
|
117
|
+
try {
|
|
118
|
+
const { loadSecrets } = require('../../core/secrets');
|
|
119
|
+
const secrets = await loadSecrets();
|
|
120
|
+
return hasSecretValue(secrets && secrets['slack/signingSecret']);
|
|
121
|
+
} catch {
|
|
122
|
+
return false;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* @param {Array<{ key: string }>} items
|
|
128
|
+
* @returns {{ stored: boolean, storedSigningSecret: boolean, storedBotToken: boolean,
|
|
129
|
+
* storedClientSecret: boolean }}
|
|
130
|
+
*/
|
|
131
|
+
function slackStoreFlags(items) {
|
|
132
|
+
const keys = new Set(items.map((item) => item.key));
|
|
133
|
+
return {
|
|
134
|
+
stored: items.length > 0,
|
|
135
|
+
storedSigningSecret: keys.has(KV_SIGNING_SECRET),
|
|
136
|
+
storedBotToken: keys.has(KV_BOT_TOKEN),
|
|
137
|
+
storedClientSecret: keys.has(KV_CLIENT_SECRET)
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* Write Slack create/install secrets to local store and integration .env, then push.
|
|
143
|
+
*
|
|
144
|
+
* @param {Object} ctx
|
|
145
|
+
* @param {{ signingSecret?: string, botToken?: string, clientSecret?: string }} secrets
|
|
146
|
+
* @returns {Promise<{ stored: boolean, storedSigningSecret: boolean, storedBotToken: boolean,
|
|
147
|
+
* storedClientSecret: boolean }>}
|
|
148
|
+
*/
|
|
149
|
+
async function storeSlackChannelSecrets(ctx, secrets, deps = {}) {
|
|
150
|
+
const items = slackSecretItems(secrets);
|
|
151
|
+
const flags = slackStoreFlags(items);
|
|
152
|
+
if (!flags.stored) {
|
|
153
|
+
return flags;
|
|
154
|
+
}
|
|
155
|
+
await writeSlackSecretsLocal(items, deps);
|
|
156
|
+
writeSlackSecretsEnvFiles(ctx, items, deps);
|
|
157
|
+
const store = deps.storeCredentialSecrets || storeCredentialSecrets;
|
|
158
|
+
await store(ctx.dataplaneUrl, ctx.authConfig, items);
|
|
159
|
+
return flags;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
module.exports = {
|
|
163
|
+
hasSecretValue,
|
|
164
|
+
kvPathToSecretSetKey,
|
|
165
|
+
pickSlackSecrets,
|
|
166
|
+
slackSecretItems,
|
|
167
|
+
localSlackSigningPresent,
|
|
168
|
+
storeSlackChannelSecrets
|
|
169
|
+
};
|