@wildo-ai/wildo-cli 1.1.15 → 1.1.16

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 (102) hide show
  1. package/dist/src/commands/context/journey.command.d.ts.map +1 -1
  2. package/dist/src/commands/context/journey.command.js +12 -0
  3. package/dist/src/commands/context/journey.command.js.map +1 -1
  4. package/dist/src/commands/creation/drive.command.d.ts.map +1 -1
  5. package/dist/src/commands/creation/drive.command.js +2 -1
  6. package/dist/src/commands/creation/drive.command.js.map +1 -1
  7. package/dist/src/commands/local/dev.command.d.ts +44 -0
  8. package/dist/src/commands/local/dev.command.d.ts.map +1 -1
  9. package/dist/src/commands/local/dev.command.js +74 -3
  10. package/dist/src/commands/local/dev.command.js.map +1 -1
  11. package/dist/src/commands/providers/grant-export.command.d.ts +16 -0
  12. package/dist/src/commands/providers/grant-export.command.d.ts.map +1 -0
  13. package/dist/src/commands/providers/grant-export.command.js +78 -0
  14. package/dist/src/commands/providers/grant-export.command.js.map +1 -0
  15. package/dist/src/commands/providers/grant-import.command.d.ts +15 -0
  16. package/dist/src/commands/providers/grant-import.command.d.ts.map +1 -0
  17. package/dist/src/commands/providers/grant-import.command.js +78 -0
  18. package/dist/src/commands/providers/grant-import.command.js.map +1 -0
  19. package/dist/src/kernel/command-runner.d.ts.map +1 -1
  20. package/dist/src/kernel/command-runner.js +4 -6
  21. package/dist/src/kernel/command-runner.js.map +1 -1
  22. package/dist/src/kernel/hooks.d.ts.map +1 -1
  23. package/dist/src/kernel/hooks.js +2 -1
  24. package/dist/src/kernel/hooks.js.map +1 -1
  25. package/dist/src/kernel/json-document-output.d.ts +7 -0
  26. package/dist/src/kernel/json-document-output.d.ts.map +1 -1
  27. package/dist/src/kernel/json-document-output.js +8 -0
  28. package/dist/src/kernel/json-document-output.js.map +1 -1
  29. package/dist/src/kernel/types.d.ts +8 -0
  30. package/dist/src/kernel/types.d.ts.map +1 -1
  31. package/dist/src/kernel/types.js.map +1 -1
  32. package/dist/src/services/application/app-bootstrap.service.d.ts +24 -6
  33. package/dist/src/services/application/app-bootstrap.service.d.ts.map +1 -1
  34. package/dist/src/services/application/app-bootstrap.service.js +46 -13
  35. package/dist/src/services/application/app-bootstrap.service.js.map +1 -1
  36. package/dist/src/services/application/app-local-runtime-addresses.service.d.ts +1 -1
  37. package/dist/src/services/application/app-local-runtime-addresses.service.d.ts.map +1 -1
  38. package/dist/src/services/application/app-local-runtime-addresses.service.js.map +1 -1
  39. package/dist/src/services/application/app-runtime-targets.service.d.ts.map +1 -1
  40. package/dist/src/services/application/app-runtime-targets.service.js +7 -1
  41. package/dist/src/services/application/app-runtime-targets.service.js.map +1 -1
  42. package/dist/src/services/application/application-runtime-bootstrap.service.d.ts +13 -0
  43. package/dist/src/services/application/application-runtime-bootstrap.service.d.ts.map +1 -1
  44. package/dist/src/services/application/application-runtime-bootstrap.service.js +32 -0
  45. package/dist/src/services/application/application-runtime-bootstrap.service.js.map +1 -1
  46. package/dist/src/services/application/environment-provider-configurations.service.d.ts +7 -0
  47. package/dist/src/services/application/environment-provider-configurations.service.d.ts.map +1 -1
  48. package/dist/src/services/application/environment-provider-configurations.service.js +1 -1
  49. package/dist/src/services/application/environment-provider-configurations.service.js.map +1 -1
  50. package/dist/src/services/application/local-tunnel.service.d.ts.map +1 -1
  51. package/dist/src/services/application/local-tunnel.service.js +2 -1
  52. package/dist/src/services/application/local-tunnel.service.js.map +1 -1
  53. package/dist/src/services/companion/companion-client.service.d.ts +17 -0
  54. package/dist/src/services/companion/companion-client.service.d.ts.map +1 -1
  55. package/dist/src/services/companion/companion-client.service.js +21 -0
  56. package/dist/src/services/companion/companion-client.service.js.map +1 -1
  57. package/dist/src/services/companion/creation-drive.service.d.ts +18 -0
  58. package/dist/src/services/companion/creation-drive.service.d.ts.map +1 -1
  59. package/dist/src/services/companion/creation-drive.service.js +70 -1
  60. package/dist/src/services/companion/creation-drive.service.js.map +1 -1
  61. package/dist/src/services/deployment/docker/docker-compose-generator.service.d.ts +10 -1
  62. package/dist/src/services/deployment/docker/docker-compose-generator.service.d.ts.map +1 -1
  63. package/dist/src/services/deployment/docker/docker-compose-generator.service.js +24 -10
  64. package/dist/src/services/deployment/docker/docker-compose-generator.service.js.map +1 -1
  65. package/dist/src/services/deployment/framework-pod-network-membership.d.ts.map +1 -1
  66. package/dist/src/services/deployment/framework-pod-network-membership.js +5 -0
  67. package/dist/src/services/deployment/framework-pod-network-membership.js.map +1 -1
  68. package/dist/src/services/deployment/local-dev-late-workspace-members.service.d.ts +43 -4
  69. package/dist/src/services/deployment/local-dev-late-workspace-members.service.d.ts.map +1 -1
  70. package/dist/src/services/deployment/local-dev-late-workspace-members.service.js +116 -9
  71. package/dist/src/services/deployment/local-dev-late-workspace-members.service.js.map +1 -1
  72. package/dist/src/services/environment/authored-infra-config.utils.d.ts +4 -3
  73. package/dist/src/services/environment/authored-infra-config.utils.d.ts.map +1 -1
  74. package/dist/src/services/environment/authored-infra-config.utils.js +4 -3
  75. package/dist/src/services/environment/authored-infra-config.utils.js.map +1 -1
  76. package/dist/src/services/framework/package-install.service.d.ts +7 -0
  77. package/dist/src/services/framework/package-install.service.d.ts.map +1 -1
  78. package/dist/src/services/framework/package-install.service.js +8 -1
  79. package/dist/src/services/framework/package-install.service.js.map +1 -1
  80. package/dist/src/services/registry/application-provider-connection.service.d.ts +16 -1
  81. package/dist/src/services/registry/application-provider-connection.service.d.ts.map +1 -1
  82. package/dist/src/services/registry/application-provider-connection.service.js +23 -0
  83. package/dist/src/services/registry/application-provider-connection.service.js.map +1 -1
  84. package/dist/src/services/registry/provider-grant-transfer.service.d.ts +48 -0
  85. package/dist/src/services/registry/provider-grant-transfer.service.d.ts.map +1 -0
  86. package/dist/src/services/registry/provider-grant-transfer.service.js +144 -0
  87. package/dist/src/services/registry/provider-grant-transfer.service.js.map +1 -0
  88. package/dist/src/services/registry/provider-module-scaffold.service.d.ts.map +1 -1
  89. package/dist/src/services/registry/provider-module-scaffold.service.js +10 -3
  90. package/dist/src/services/registry/provider-module-scaffold.service.js.map +1 -1
  91. package/dist/tsconfig.build.tsbuildinfo +1 -1
  92. package/package.json +19 -19
  93. package/templates/infra/docker-compose/docker-compose.wildo-platform.yml.hbs +2 -0
  94. package/templates/saas/i18n/email/system/remote-agent-task-updated/labels.en.ts +11 -0
  95. package/templates/saas/i18n/email/system/remote-agent-task-updated/template.tsx +56 -0
  96. package/templates/saas/i18n/engine/components/APP_LAYOUTS_AGENT_ACTIVITY_SETTINGS.en.ts +61 -0
  97. package/templates/saas/i18n/engine/components/APP_LAYOUTS_AGENT_ACTIVITY_SETTINGS.fr.ts +61 -0
  98. package/templates/saas/scenarios/add-technical-doc/files/technical-doc/docusaurus.config.ts.hbs +5 -4
  99. package/templates/saas/scenarios/add-technical-doc/files/technical-doc/package.json.hbs +1 -1
  100. package/templates/saas/scenarios/add-technical-doc/files/technical-doc/scripts/substitute-api-origin.mjs +97 -32
  101. package/templates/saas/scenarios/add-technical-doc/files/technical-doc/src/plugins/api-reference-pages.ts +7 -6
  102. package/wildo-framework.info.json +1 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wildo-ai/wildo-cli",
3
- "version": "1.1.15",
3
+ "version": "1.1.16",
4
4
  "description": "Wildo.ai CLI — context-aware developer toolkit",
5
5
  "license": "SEE LICENSE IN LICENSE",
6
6
  "author": "Wildo AI",
@@ -66,23 +66,23 @@
66
66
  "@radix-ui/react-tooltip": "^1.2.8",
67
67
  "@radix-ui/react-use-controllable-state": "^1.2.2",
68
68
  "@tanstack/react-table": "^8.21.3",
69
- "@wildo-ai/application-creation-runtime": "1.1.15",
70
- "@wildo-ai/assurance-cycle": "1.1.15",
71
- "@wildo-ai/external-connectors-models": "^1.1.15",
72
- "@wildo-ai/external-connectors-private": "1.1.15",
73
- "@wildo-ai/framework-knowledge": "1.1.15",
74
- "@wildo-ai/platform-config-lib": "1.1.15",
75
- "@wildo-ai/platform-core-backend": "1.1.15",
76
- "@wildo-ai/platform-core-shared": "1.1.15",
77
- "@wildo-ai/platform-infra-providers": "1.1.15",
78
- "@wildo-ai/platform-shared-lib": "1.1.15",
79
- "@wildo-ai/presets-components-models": "1.1.15",
80
- "@wildo-ai/saas-backend-lib": "1.1.15",
81
- "@wildo-ai/saas-models": "1.1.15",
82
- "@wildo-ai/saas-specifications": "1.1.15",
83
- "@wildo-ai/saas-website": "^1.1.15",
84
- "@wildo-ai/wildo-module-client": "1.1.15",
85
- "@wildo-ai/zod-decorators": "1.1.15",
69
+ "@wildo-ai/application-creation-runtime": "1.1.16",
70
+ "@wildo-ai/assurance-cycle": "1.1.16",
71
+ "@wildo-ai/external-connectors-models": "^1.1.16",
72
+ "@wildo-ai/external-connectors-private": "1.1.16",
73
+ "@wildo-ai/framework-knowledge": "1.1.16",
74
+ "@wildo-ai/platform-config-lib": "1.1.16",
75
+ "@wildo-ai/platform-core-backend": "1.1.16",
76
+ "@wildo-ai/platform-core-shared": "1.1.16",
77
+ "@wildo-ai/platform-infra-providers": "1.1.16",
78
+ "@wildo-ai/platform-shared-lib": "1.1.16",
79
+ "@wildo-ai/presets-components-models": "1.1.16",
80
+ "@wildo-ai/saas-backend-lib": "1.1.16",
81
+ "@wildo-ai/saas-models": "1.1.16",
82
+ "@wildo-ai/saas-specifications": "1.1.16",
83
+ "@wildo-ai/saas-website": "^1.1.16",
84
+ "@wildo-ai/wildo-module-client": "1.1.16",
85
+ "@wildo-ai/zod-decorators": "1.1.16",
86
86
  "@xyflow/react": "^12.9.3",
87
87
  "ai": "7.0.142",
88
88
  "axios": "^1.20.0",
@@ -147,7 +147,7 @@
147
147
  "@types/semver": "7.8.0",
148
148
  "@types/yauzl": "^2.10.3",
149
149
  "@types/yazl": "^3.3.1",
150
- "@wildo-ai/external-connectors-public": "1.1.15",
150
+ "@wildo-ai/external-connectors-public": "1.1.16",
151
151
  "dotenv": "^17.3.1",
152
152
  "rimraf": "^6.1.4",
153
153
  "tsc-alias": "1.8.16",
@@ -1319,6 +1319,8 @@ services:
1319
1319
  - platform-crontabs-batches-manager-internal
1320
1320
  wildo-data-mongo:
1321
1321
  wildo-data-redis:
1322
+ # On a PostgreSQL platform the scheduler's repositories and delivery outbox live there (see the membership table).
1323
+ wildo-data-postgres:
1322
1324
  wildo-data-objects:
1323
1325
  wildo-data-telemetry:
1324
1326
  wildo-host-access:
@@ -0,0 +1,11 @@
1
+ export const labels = {
2
+ subject: '{agent} has news about a task — {appName}',
3
+ heading: 'News from {agent}',
4
+ body: '{agent}, an assistant run by another company, has news about a task one of your conversations handed to it. It may have finished, or it may need something from you. Open the conversation and your assistant will go through the update with you.',
5
+ previewText: '{heading}',
6
+ buttonOpenConversation: 'Open the conversation',
7
+ buttonOpen: 'Open {appName}',
8
+ footerMuted: 'This is an automated message from {appName}, sent because one of your conversations handed this task on.',
9
+ };
10
+
11
+ export type TemplateLabels = typeof labels;
@@ -0,0 +1,56 @@
1
+ import * as React from 'react';
2
+ import { type EmailTemplateDefinition } from '@wildo-ai/saas-backend-lib';
3
+ import { interpolateEmailLabel } from '@wildo-ai/saas-backend-lib';
4
+ import type { TemplateLabels } from './labels.en';
5
+ import { EmailLayout, HeadingText, BodyText, PrimaryButton, Divider } from '~backend-api/engine/email/components'
6
+
7
+ /**
8
+ * Another company's agent reported news about a task one of the recipient's conversations handed to it (#4013). Sent
9
+ * with the in-app notice, so a person who is not connected hears of it too. Names the agent by the name the application
10
+ * declared for it, and links to the conversation. It never says what the news is and never carries the agent's own
11
+ * words: the conversation is where the person's assistant reads the update.
12
+ */
13
+ const template: EmailTemplateDefinition<TemplateLabels> = {
14
+ subject: ({ context, labels }) => {
15
+ const appName = context.objectContext.primaryScopeContext.appName;
16
+ const { agentName } = context.additionalContext as { agentName: string };
17
+ return interpolateEmailLabel(labels.subject, { appName, agent: agentName });
18
+ },
19
+
20
+ body: ({ context, brand, labels }) => {
21
+ const appName = context.objectContext.primaryScopeContext.appName;
22
+ const { agentName, conversationUrl, appUrl } = context.additionalContext as { agentName: string; conversationUrl?: string; appUrl?: string };
23
+ const heading = interpolateEmailLabel(labels.heading, { agent: agentName });
24
+
25
+ return (
26
+ <EmailLayout
27
+ brand={brand}
28
+ appName={appName}
29
+ logoUrl={context.objectContext?.primaryScopeContext?.logoUrl}
30
+ previewText={interpolateEmailLabel(labels.previewText, { heading })}
31
+ >
32
+ <HeadingText brand={brand} level={2}>
33
+ {heading}
34
+ </HeadingText>
35
+ <BodyText brand={brand}>{interpolateEmailLabel(labels.body, { agent: agentName })}</BodyText>
36
+ {conversationUrl ? (
37
+ <PrimaryButton href={conversationUrl} brand={brand}>
38
+ {labels.buttonOpenConversation}
39
+ </PrimaryButton>
40
+ ) : appUrl && (
41
+ <PrimaryButton href={appUrl} brand={brand}>
42
+ {interpolateEmailLabel(labels.buttonOpen, { appName })}
43
+ </PrimaryButton>
44
+ )}
45
+ <Divider brand={brand} />
46
+ <BodyText brand={brand} muted style={{ fontSize: '14px' }}>
47
+ {interpolateEmailLabel(labels.footerMuted, { appName })}
48
+ </BodyText>
49
+ </EmailLayout>
50
+ );
51
+ },
52
+
53
+ description: 'Tells a person that another company\'s agent has news about a task one of their conversations handed to it.',
54
+ };
55
+
56
+ export default template;
@@ -0,0 +1,61 @@
1
+ /**
2
+ * English (en) — application labels.
3
+ * Primary locale source-of-truth file generated from application context.
4
+ */
5
+ export const labels = {
6
+ "components": {
7
+ "APP_LAYOUTS_AGENT_ACTIVITY_SETTINGS": {
8
+ "agentToAgentDescription": "Tasks exchanged with other agents, newest first.",
9
+ "agentToAgentEmpty": "No tasks exchanged with other agents yet.",
10
+ "agentToAgentError": "Couldn't load agent-to-agent tasks. Please try again.",
11
+ "agentToAgentHeading": "Agent-to-Agent Tasks",
12
+ "applicationOwnClient": "Application client",
13
+ "applicationPageDescription": "Runs across all organizations, logged for audit.",
14
+ "applicationPageTitle": "Agent Activity Across Organizations",
15
+ "backToRuns": "Back to runs",
16
+ "columnActions": "Actions",
17
+ "columnCase": "Case",
18
+ "columnCounterpart": "Other party",
19
+ "columnDirection": "Direction",
20
+ "columnFinished": "Finished",
21
+ "columnKind": "Type",
22
+ "columnOrganization": "Organization",
23
+ "columnStarted": "Started",
24
+ "columnStatus": "Status",
25
+ "columnSystem": "Workflow or team",
26
+ "columnTaskEnded": "Ended",
27
+ "columnTaskStarted": "Started",
28
+ "columnTaskState": "Status",
29
+ "decisionEnded": "{outcome} on {at}",
30
+ "decisionsHeading": "Decisions",
31
+ "direction_delegated": "Sent",
32
+ "direction_received": "Received",
33
+ "empty": "No runs yet.",
34
+ "errorAccessGrantRequired": "Viewing runs across organizations needs an approved access grant. Request one under Access grants.",
35
+ "errorGeneric": "Couldn't load runs. Please try again.",
36
+ "errorRun": "Couldn't load this run. It may no longer exist.",
37
+ "flowFailureLabel": "Failure reason",
38
+ "flowStepsHeading": "Workflow Steps",
39
+ "flowStepsUntimed": "{count, plural, one {# earlier step has} other {# earlier steps have}} no recorded time.",
40
+ "kind_actor_system": "Agent team",
41
+ "kind_flow": "Workflow",
42
+ "kind_undeclared": "No longer available",
43
+ "loadMore": "Load more",
44
+ "loadMoreTasks": "Load more",
45
+ "loading": "Loading…",
46
+ "noOrganization": "Select an organization to see its runs.",
47
+ "noTasks": "No tasks yet.",
48
+ "notFinished": "Not finished",
49
+ "openRun": "Open",
50
+ "pageDescription": "Workflow and agent team runs, newest first.",
51
+ "pageTitle": "Agent Activity",
52
+ "receivedByAgent": "Received by {agent}",
53
+ "receivedByDefaultAgent": "Received by main agent",
54
+ "stateNotReported": "Not reported",
55
+ "stateReportedAt": "Reported {at}",
56
+ "taskNotEnded": "Not ended",
57
+ "tasksHeading": "Tasks",
58
+ "unknownClient": "Unknown client"
59
+ }
60
+ }
61
+ } as const;
@@ -0,0 +1,61 @@
1
+ /**
2
+ * French (fr) — application labels.
3
+ * Translated from the primary locale; keep semantic keys and placeholders faithful to the source.
4
+ */
5
+ export const labels = {
6
+ "components": {
7
+ "APP_LAYOUTS_AGENT_ACTIVITY_SETTINGS": {
8
+ "agentToAgentDescription": "Tâches échangées avec d’autres agents, des plus récentes aux plus anciennes.",
9
+ "agentToAgentEmpty": "Aucune tâche échangée avec d’autres agents pour le moment.",
10
+ "agentToAgentError": "Impossible de charger les tâches entre agents. Veuillez réessayer.",
11
+ "agentToAgentHeading": "Tâches entre agents",
12
+ "applicationOwnClient": "Client de l’application",
13
+ "applicationPageDescription": "Exécutions de toutes les organisations, consignées pour l’audit.",
14
+ "applicationPageTitle": "Activité des agents dans toutes les organisations",
15
+ "backToRuns": "Retour aux exécutions",
16
+ "columnActions": "Actions",
17
+ "columnCase": "Dossier",
18
+ "columnCounterpart": "Interlocuteur",
19
+ "columnDirection": "Sens",
20
+ "columnFinished": "Fin",
21
+ "columnKind": "Type",
22
+ "columnOrganization": "Organisation",
23
+ "columnStarted": "Début",
24
+ "columnStatus": "Statut",
25
+ "columnSystem": "Workflow ou équipe",
26
+ "columnTaskEnded": "Fin",
27
+ "columnTaskStarted": "Début",
28
+ "columnTaskState": "Statut",
29
+ "decisionEnded": "{outcome} le {at}",
30
+ "decisionsHeading": "Décisions",
31
+ "direction_delegated": "Envoyée",
32
+ "direction_received": "Reçue",
33
+ "empty": "Aucune exécution pour le moment.",
34
+ "errorAccessGrantRequired": "La consultation des exécutions de toutes les organisations nécessite une autorisation d’accès approuvée. Demandez-en une dans Autorisations d’accès.",
35
+ "errorGeneric": "Impossible de charger les exécutions. Veuillez réessayer.",
36
+ "errorRun": "Impossible de charger cette exécution. Elle n’existe peut-être plus.",
37
+ "flowFailureLabel": "Motif de l’échec",
38
+ "flowStepsHeading": "Étapes du workflow",
39
+ "flowStepsUntimed": "{count, plural, one {# étape antérieure n’a} many {# étapes antérieures n’ont} other {# étapes antérieures n’ont}} aucune heure enregistrée.",
40
+ "kind_actor_system": "Équipe d’agents",
41
+ "kind_flow": "Workflow",
42
+ "kind_undeclared": "Plus disponible",
43
+ "loadMore": "Charger plus",
44
+ "loadMoreTasks": "Charger plus",
45
+ "loading": "Chargement…",
46
+ "noOrganization": "Sélectionnez une organisation pour voir ses exécutions.",
47
+ "noTasks": "Aucune tâche pour le moment.",
48
+ "notFinished": "Non terminée",
49
+ "openRun": "Ouvrir",
50
+ "pageDescription": "Exécutions des workflows et des équipes d’agents, des plus récentes aux plus anciennes.",
51
+ "pageTitle": "Activité des agents",
52
+ "receivedByAgent": "Reçue par {agent}",
53
+ "receivedByDefaultAgent": "Reçue par l’agent principal",
54
+ "stateNotReported": "Non communiqué",
55
+ "stateReportedAt": "Communiqué le {at}",
56
+ "taskNotEnded": "Non terminée",
57
+ "tasksHeading": "Tâches",
58
+ "unknownClient": "Client inconnu"
59
+ }
60
+ }
61
+ } as const;
@@ -268,10 +268,11 @@ const config: Config = {
268
268
  // URL-shaped folder label or duplicating that overview as a child.
269
269
  // API-reference routes remain page-owned seams outside this generated sidebar.
270
270
  sidebarPath: documentationContent.consumerDocumentationSidebarPath,
271
- // The generated pages carry the API-origin token, which the image build resolves before
272
- // Docusaurus runs (`substitute:api-origin`). `docusaurus start` resolves it while compiling
273
- // instead, so a local page shows this site's API origin without rewriting the committed
274
- // tree (#1203). After the build step there is no token left, so this changes nothing there.
271
+ // The generated pages carry the API-origin token, and this resolves it while Docusaurus compiles
272
+ // them, under `docusaurus start` and `docusaurus build` alike, so a page shows this site's API
273
+ // origin without the committed tree ever being rewritten (#1203). A build never rewrites the
274
+ // sources (#4017): what Docusaurus copies rather than compiles is resolved in `build/` by
275
+ // `substitute:api-origin`, which runs after it.
275
276
  beforeDefaultRemarkPlugins: [createDocsApiOriginRemarkPlugin(process.env.WILDO_DOCS_API_BASE_URL)],
276
277
  },
277
278
  ],
@@ -6,7 +6,7 @@
6
6
  "scripts": {
7
7
  "dev": "node scripts/wait-for-publication.mjs --port {{docsPort}} && pnpm run start",
8
8
  "start": "pnpm exec docusaurus start --port {{docsPort}} --host 0.0.0.0",
9
- "build": "pnpm run substitute:api-origin && pnpm exec docusaurus build",
9
+ "build": "pnpm exec docusaurus build && pnpm run substitute:api-origin",
10
10
  "serve": "pnpm exec docusaurus serve --port {{docsPort}} --host 0.0.0.0",
11
11
  "clean": "pnpm exec docusaurus clear",
12
12
  "swizzle": "pnpm exec docusaurus swizzle",
@@ -1,64 +1,129 @@
1
1
  #!/usr/bin/env node
2
2
  /**
3
- * Put THIS image's API origin into the generated documentation, before Docusaurus builds it (#1203).
3
+ * Put THIS build's API origin into the BUILT documentation site, after Docusaurus has written it (#1203, #4017).
4
4
  *
5
5
  * ## Why this step exists
6
6
  *
7
7
  * `technical-doc/src/generated/**` is a COMMITTED artifact, so whatever origin it was generated
8
8
  * against travels into every later build. A staging image shipped 42 occurrences of
9
9
  * `http://localhost:4241` — including the SCIM base URL an administrator pastes into their identity
10
- * provider, and the `servers` of the published API description. The CSP already had a per-environment
11
- * regeneration step; the content had none.
10
+ * provider, and the `servers` of the published API description. Generation now writes a TOKEN where
11
+ * the application's primary origin belongs, which keeps the committed artifact environment-independent,
12
+ * and a build resolves it from `WILDO_DOCS_API_BASE_URL`, the docker build argument CI supplies for
13
+ * `AppFrontendType.TECH_DOC`.
12
14
  *
13
- * Generation now writes a TOKEN where the application's primary origin belongs, which keeps the
14
- * committed artifact environment-independent. This resolves it from `WILDO_DOCS_API_BASE_URL`, the
15
- * docker build argument CI already supplies for `AppFrontendType.TECH_DOC`.
15
+ * ## Why it rewrites the OUTPUT and never the sources (#4017)
16
16
  *
17
- * It walks FILES rather than relying on the docs runtime, because the OpenAPI documents are served as
18
- * static files and have no runtime to read `customFields` from — the reason a runtime-only fix could
19
- * not cover every surface.
17
+ * This step used to run BEFORE `docusaurus build` and rewrite `src/generated/**` in place. That made
18
+ * every build a write to committed files: `check:technical-doc-build`, a VERIFICATION run at the end
19
+ * of an application build, left the API reference and 14 pages modified, and the creation run read
20
+ * the change as a hand edit. A verification must leave the tree as it found it, so the sources are
21
+ * now only ever READ:
20
22
  *
21
- * Idempotent: a tree with no token is left byte-identical, so running it twice, or on an
22
- * already-substituted tree, changes nothing.
23
+ * - the pages are resolved while Docusaurus compiles them — the consumer pages by the remark plugin
24
+ * in `docusaurus.config.ts`, the API-reference pages by `src/plugins/api-reference-pages.ts` — both
25
+ * from the same `WILDO_DOCS_API_BASE_URL`;
26
+ * - what Docusaurus COPIES rather than compiles — the published OpenAPI documents, served as static
27
+ * files with no runtime to read the origin from — reaches `build/` still carrying the token, and
28
+ * this step resolves it there.
29
+ *
30
+ * It then refuses to leave a single token anywhere in the output, so the published site carries the
31
+ * real origin (or, with none supplied, the visible substitute-your-own stand-in) and never the token.
32
+ *
33
+ * Usage: `node scripts/substitute-api-origin.mjs [<output directory>]` — the directory defaults to
34
+ * `build`, Docusaurus's own default. Inside the site only `build/` (gitignored) or a directory below it is
35
+ * accepted; anywhere else, any directory that does not contain the site — the same places
36
+ * `docusaurus build --out-dir` may write to without touching a committed file.
37
+ *
38
+ * Idempotent: an output with no token is left byte-identical, so running it twice changes nothing.
23
39
  */
24
- import { readdirSync, readFileSync, statSync, writeFileSync } from 'node:fs';
25
- import { join, dirname } from 'node:path';
40
+ import { existsSync, readdirSync, readFileSync, statSync, writeFileSync } from 'node:fs';
41
+ import { dirname, isAbsolute, join, relative, resolve, sep } from 'node:path';
26
42
  import { fileURLToPath } from 'node:url';
27
- import { substituteDocsApiOrigin, containsUnsubstitutedDocsApiOrigin, normalizeDocsApiOrigin } from '@wildo-ai/saas-technical-doc/openapi-reference-model';
43
+ import { DOCS_API_ORIGIN_TOKEN, normalizeDocsApiOrigin } from '@wildo-ai/saas-technical-doc/openapi-reference-model';
44
+
45
+ const SITE_ROOT = resolve(dirname(fileURLToPath(import.meta.url)), '..');
46
+
47
+ // The same `.env` `docusaurus.config.ts` loads, for the same reason: `wildo config sync` writes the API
48
+ // origin there and Node does not read it unasked. Without it a local build would resolve its pages to the
49
+ // `.env` origin (the config loads it) and its OpenAPI documents to the stand-in. A variable already in the
50
+ // environment wins, so an image build's argument is never overridden. Non-fatal: an image build has no
51
+ // `.env`, and a portal built on its own may have none.
52
+ try {
53
+ process.loadEnvFile(join(SITE_ROOT, '.env'));
54
+ } catch {
55
+ // No `.env` beside this site: the environment alone decides.
56
+ }
57
+
58
+ const DEFAULT_OUTPUT_ROOT = join(SITE_ROOT, 'build');
59
+ const OUTPUT_ROOT = resolve(SITE_ROOT, process.argv[2] ?? 'build');
60
+
61
+ /** Whether `path` is `root` itself or lies below it. */
62
+ function isWithin(path, root) {
63
+ const fromRoot = relative(root, path);
64
+ return fromRoot === '' || (fromRoot !== '..' && !fromRoot.startsWith(`..${sep}`) && !isAbsolute(fromRoot));
65
+ }
28
66
 
29
- const HERE = dirname(fileURLToPath(import.meta.url));
30
- const GENERATED_ROOT = join(HERE, '..', 'src', 'generated');
31
- const SUBSTITUTABLE = /\.(md|mdx|json|yaml|yml|ts|tsx)$/;
67
+ // The whole point of this step is that it never writes a committed file. Every directory of the site except
68
+ // `build/` holds committed files (`src/`, `static/`, `i18n/`, `scripts/`), so inside the site only `build/`
69
+ // is accepted, and a directory that contains the site is refused wherever it is.
70
+ if (isWithin(SITE_ROOT, OUTPUT_ROOT) || (isWithin(OUTPUT_ROOT, SITE_ROOT) && !isWithin(OUTPUT_ROOT, DEFAULT_OUTPUT_ROOT))) {
71
+ console.error(`[docs-api-origin] refusing to rewrite ${OUTPUT_ROOT}: inside the site only ${DEFAULT_OUTPUT_ROOT} is a build output, and the output directory must not contain the site.`);
72
+ process.exit(1);
73
+ }
74
+ if (!existsSync(OUTPUT_ROOT) || !statSync(OUTPUT_ROOT).isDirectory()) {
75
+ console.error(`[docs-api-origin] ${OUTPUT_ROOT} does not exist: run \`docusaurus build\` first; this step resolves the origin in its output.`);
76
+ process.exit(1);
77
+ }
32
78
 
33
79
  function* walk(directory) {
34
- for (const entry of readdirSync(directory)) {
35
- const path = join(directory, entry);
36
- if (statSync(path).isDirectory()) yield* walk(path);
37
- else if (SUBSTITUTABLE.test(entry)) yield path;
80
+ for (const entry of readdirSync(directory, { withFileTypes: true })) {
81
+ const path = join(directory, entry.name);
82
+ if (entry.isDirectory()) yield* walk(path);
83
+ else if (entry.isFile()) yield path;
84
+ }
85
+ }
86
+
87
+ /**
88
+ * Replace every occurrence of `token` in `bytes`, at the BYTE level. Every file of the output is read,
89
+ * whatever its extension, so a token Docusaurus carried into a bundle or an asset is caught as well as
90
+ * one in a copied document; working on bytes leaves every other byte of a file exactly as it was.
91
+ */
92
+ function replaceBytes(bytes, token, replacement) {
93
+ const parts = [];
94
+ let from = 0;
95
+ for (let at = bytes.indexOf(token, from); at !== -1; at = bytes.indexOf(token, from)) {
96
+ parts.push(bytes.subarray(from, at), replacement);
97
+ from = at + token.length;
38
98
  }
99
+ parts.push(bytes.subarray(from));
100
+ return Buffer.concat(parts);
39
101
  }
40
102
 
41
- const origin = normalizeDocsApiOrigin(process.env.WILDO_DOCS_API_BASE_URL);
103
+ const apiBaseUrl = process.env.WILDO_DOCS_API_BASE_URL;
104
+ const origin = normalizeDocsApiOrigin(apiBaseUrl);
105
+ const token = Buffer.from(DOCS_API_ORIGIN_TOKEN, 'utf8');
106
+ const replacement = Buffer.from(origin, 'utf8');
42
107
  let changed = 0;
43
- let remaining = 0;
108
+ const remaining = [];
44
109
 
45
- for (const path of walk(GENERATED_ROOT)) {
46
- const before = readFileSync(path, 'utf8');
47
- if (!containsUnsubstitutedDocsApiOrigin(before)) continue;
48
- const after = substituteDocsApiOrigin(before, process.env.WILDO_DOCS_API_BASE_URL);
110
+ for (const path of walk(OUTPUT_ROOT)) {
111
+ const before = readFileSync(path);
112
+ if (before.indexOf(token) === -1) continue;
113
+ const after = replaceBytes(before, token, replacement);
49
114
  writeFileSync(path, after);
50
115
  changed += 1;
51
- if (containsUnsubstitutedDocsApiOrigin(after)) remaining += 1;
116
+ if (after.indexOf(token) !== -1) remaining.push(relative(SITE_ROOT, path));
52
117
  }
53
118
 
54
- console.log(`[docs-api-origin] ${changed} file(s) → ${origin}`);
55
- if (!process.env.WILDO_DOCS_API_BASE_URL) {
119
+ console.log(`[docs-api-origin] ${changed} file(s) in ${relative(SITE_ROOT, OUTPUT_ROOT) || '.'} → ${origin}`);
120
+ if (!apiBaseUrl || apiBaseUrl.trim().length === 0) {
56
121
  // Not fatal: a local preview has no environment to name, and the stand-in is the same one an
57
122
  // application publishing no base URL already gets. A DEPLOY lane that reaches here without the
58
123
  // argument would publish that stand-in, which is visibly a placeholder rather than a wrong origin.
59
124
  console.warn('[docs-api-origin] WILDO_DOCS_API_BASE_URL is unset — published pages will show the substitute-your-own stand-in.');
60
125
  }
61
- if (remaining > 0) {
62
- console.error(`[docs-api-origin] ${remaining} file(s) still carry the token after substitution.`);
126
+ if (remaining.length > 0) {
127
+ console.error(`[docs-api-origin] ${remaining.length} file(s) still carry the token after substitution: ${remaining.join(', ')}`);
63
128
  process.exit(1);
64
129
  }
@@ -30,12 +30,13 @@ import {
30
30
  * they opened rather than the whole API. A document that fails the model's validation fails the build
31
31
  * here, where it used to fail in the reader's browser.
32
32
  *
33
- * The published documents carry the API-origin token as their primary server (#1203). The image build
34
- * resolves it in the files before Docusaurus runs; under `docusaurus start` nothing does, so this plugin
35
- * resolves it as it reads each document, from `WILDO_DOCS_API_BASE_URL` — the local API origin the
36
- * site's `.env` names. The reference pages and their "Try it" requests then address the running API
37
- * rather than a token. The files on disk are not rewritten, so the committed tree stays
38
- * environment-independent; on an already-substituted tree this changes nothing.
33
+ * The published documents carry the API-origin token as their primary server (#1203). This plugin
34
+ * resolves it as it reads each document, under `docusaurus start` and `docusaurus build` alike, from
35
+ * `WILDO_DOCS_API_BASE_URL` — the image's build argument, or locally the origin the site's `.env` names.
36
+ * The reference pages and their "Try it" requests then address that API rather than a token. The files on
37
+ * disk are never rewritten, so the committed tree stays environment-independent and a build leaves it as
38
+ * it found it (#4017); the copies of the documents Docusaurus publishes as static files are resolved in
39
+ * `build/` by `substitute:api-origin`, after the build.
39
40
  */
40
41
 
41
42
  interface ApiReferenceSectionSource {
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "wildo-ai",
3
- "version": "1.1.15",
3
+ "version": "1.1.16",
4
4
  "minCliVersion": "0.2.0"
5
5
  }