@bluestep-systems/b6p-core 0.8.1 → 1.0.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 (149) hide show
  1. package/README.md +310 -32
  2. package/dist/B6PCore.d.ts +7 -0
  3. package/dist/B6PCore.js +96 -1
  4. package/dist/B6PCore.js.map +1 -1
  5. package/dist/B6PUri.d.ts +6 -8
  6. package/dist/B6PUri.js +6 -8
  7. package/dist/B6PUri.js.map +1 -1
  8. package/dist/Err.d.ts +421 -0
  9. package/dist/Err.js +558 -0
  10. package/dist/Err.js.map +1 -1
  11. package/dist/auth/BearerAuthProvider.d.ts +32 -0
  12. package/dist/auth/BearerAuthProvider.js +49 -0
  13. package/dist/auth/BearerAuthProvider.js.map +1 -1
  14. package/dist/cache/OrgCache.js.map +1 -1
  15. package/dist/cache/ScriptMetaDataStore.js.map +1 -1
  16. package/dist/constants/ApiEndpoints.d.ts +1 -0
  17. package/dist/constants/ApiEndpoints.js +1 -0
  18. package/dist/constants/ApiEndpoints.js.map +1 -1
  19. package/dist/constants/AuthTypes.js.map +1 -1
  20. package/dist/constants/BlueHQ.js.map +1 -1
  21. package/dist/constants/CryptoAlgorithms.js.map +1 -1
  22. package/dist/constants/ExtensionConfig.js.map +1 -1
  23. package/dist/constants/FileExtensions.js.map +1 -1
  24. package/dist/constants/FolderNames.js.map +1 -1
  25. package/dist/constants/Gateway.d.ts +71 -0
  26. package/dist/constants/Gateway.js +79 -0
  27. package/dist/constants/Gateway.js.map +1 -0
  28. package/dist/constants/GitHubUrls.js.map +1 -1
  29. package/dist/constants/Http.js.map +1 -1
  30. package/dist/constants/MimeTypes.js.map +1 -1
  31. package/dist/constants/Numerical.js.map +1 -1
  32. package/dist/constants/OutputChannels.js.map +1 -1
  33. package/dist/constants/SettingsKeys.d.ts +5 -0
  34. package/dist/constants/SettingsKeys.js +5 -0
  35. package/dist/constants/SettingsKeys.js.map +1 -1
  36. package/dist/constants/SpecialFiles.js.map +1 -1
  37. package/dist/constants/WebDAVElements.js.map +1 -1
  38. package/dist/constants/index.d.ts +1 -0
  39. package/dist/constants/index.js +3 -1
  40. package/dist/constants/index.js.map +1 -1
  41. package/dist/data/DownstairsPathParser.js.map +1 -1
  42. package/dist/data/GlobMatcher.js.map +1 -1
  43. package/dist/data/IdUtility.js.map +1 -1
  44. package/dist/data/OrgWorker.js.map +1 -1
  45. package/dist/data/ScriptKey.d.ts +3 -27
  46. package/dist/data/ScriptKey.js +12 -24
  47. package/dist/data/ScriptKey.js.map +1 -1
  48. package/dist/data/ScriptUrlParser.js +3 -1
  49. package/dist/data/ScriptUrlParser.js.map +1 -1
  50. package/dist/data/ServerVersion.d.ts +76 -0
  51. package/dist/data/ServerVersion.js +111 -0
  52. package/dist/data/ServerVersion.js.map +1 -0
  53. package/dist/data/index.d.ts +2 -0
  54. package/dist/data/index.js +7 -1
  55. package/dist/data/index.js.map +1 -1
  56. package/dist/gateway/GatewayClient.d.ts +147 -0
  57. package/dist/gateway/GatewayClient.js +395 -0
  58. package/dist/gateway/GatewayClient.js.map +1 -0
  59. package/dist/gateway/GatewayContext.d.ts +43 -0
  60. package/dist/gateway/GatewayContext.js +3 -0
  61. package/dist/gateway/GatewayContext.js.map +1 -0
  62. package/dist/gateway/GatewayGit.d.ts +291 -0
  63. package/dist/gateway/GatewayGit.js +731 -0
  64. package/dist/gateway/GatewayGit.js.map +1 -0
  65. package/dist/gateway/GatewayKb.d.ts +173 -0
  66. package/dist/gateway/GatewayKb.js +354 -0
  67. package/dist/gateway/GatewayKb.js.map +1 -0
  68. package/dist/gateway/GatewayMarketplace.d.ts +116 -0
  69. package/dist/gateway/GatewayMarketplace.js +278 -0
  70. package/dist/gateway/GatewayMarketplace.js.map +1 -0
  71. package/dist/gateway/GatewayService.d.ts +47 -0
  72. package/dist/gateway/GatewayService.js +54 -0
  73. package/dist/gateway/GatewayService.js.map +1 -0
  74. package/dist/gateway/GatewayToken.d.ts +18 -0
  75. package/dist/gateway/GatewayToken.js +43 -0
  76. package/dist/gateway/GatewayToken.js.map +1 -0
  77. package/dist/gateway/GatewayTokenService.d.ts +101 -0
  78. package/dist/gateway/GatewayTokenService.js +465 -0
  79. package/dist/gateway/GatewayTokenService.js.map +1 -0
  80. package/dist/index.d.ts +29 -8
  81. package/dist/index.js +81 -9
  82. package/dist/index.js.map +1 -1
  83. package/dist/network/HttpClient.js.map +1 -1
  84. package/dist/network/HttpClientProvider.js.map +1 -1
  85. package/dist/network/StatusCodes.js.map +1 -1
  86. package/dist/persistence/PersistablePseudoMap.js.map +1 -1
  87. package/dist/persistence/PersistenceKeys.js.map +1 -1
  88. package/dist/persistence/PrivatePersistanceMap.js.map +1 -1
  89. package/dist/persistence/PseudoMap.js.map +1 -1
  90. package/dist/persistence/PublicPersistanceMap.js.map +1 -1
  91. package/dist/persistence/Serializable.js.map +1 -1
  92. package/dist/persistence/SharedFilePersistence.d.ts +22 -0
  93. package/dist/persistence/SharedFilePersistence.js +65 -14
  94. package/dist/persistence/SharedFilePersistence.js.map +1 -1
  95. package/dist/persistence/TypedMap.js.map +1 -1
  96. package/dist/persistence/TypedPersistable.js.map +1 -1
  97. package/dist/persistence/TypedPrivatePersistable.js.map +1 -1
  98. package/dist/persistence/dirLockdown.js.map +1 -1
  99. package/dist/providers.d.ts +46 -16
  100. package/dist/script/GitIdentity.d.ts +48 -0
  101. package/dist/script/GitIdentity.js +52 -0
  102. package/dist/script/GitIdentity.js.map +1 -0
  103. package/dist/script/GitSync.d.ts +388 -0
  104. package/dist/script/GitSync.js +1068 -0
  105. package/dist/script/GitSync.js.map +1 -0
  106. package/dist/script/ScriptContext.d.ts +20 -5
  107. package/dist/script/ScriptFactory.d.ts +1 -2
  108. package/dist/script/ScriptFactory.js +1 -2
  109. package/dist/script/ScriptFactory.js.map +1 -1
  110. package/dist/script/ScriptFile.d.ts +0 -94
  111. package/dist/script/ScriptFile.js +0 -245
  112. package/dist/script/ScriptFile.js.map +1 -1
  113. package/dist/script/ScriptFolder.d.ts +0 -9
  114. package/dist/script/ScriptFolder.js +4 -7
  115. package/dist/script/ScriptFolder.js.map +1 -1
  116. package/dist/script/ScriptNode.d.ts +0 -9
  117. package/dist/script/ScriptNode.js.map +1 -1
  118. package/dist/script/ScriptRoot.d.ts +0 -65
  119. package/dist/script/ScriptRoot.js +0 -199
  120. package/dist/script/ScriptRoot.js.map +1 -1
  121. package/dist/script/ScriptService.d.ts +113 -9
  122. package/dist/script/ScriptService.js +164 -52
  123. package/dist/script/ScriptService.js.map +1 -1
  124. package/dist/script/ServerCompile.d.ts +35 -0
  125. package/dist/script/ServerCompile.js +40 -0
  126. package/dist/script/ServerCompile.js.map +1 -0
  127. package/dist/script/TsConfig.d.ts +2 -2
  128. package/dist/script/TsConfig.js +3 -3
  129. package/dist/script/TsConfig.js.map +1 -1
  130. package/dist/script/push.d.ts +162 -188
  131. package/dist/script/push.js +216 -474
  132. package/dist/script/push.js.map +1 -1
  133. package/dist/session/SessionManager.js.map +1 -1
  134. package/dist/testing/FakeGateway.d.ts +280 -0
  135. package/dist/testing/FakeGateway.js +627 -0
  136. package/dist/testing/FakeGateway.js.map +1 -0
  137. package/dist/testing/MockFileSystem.js.map +1 -1
  138. package/dist/types.d.ts +332 -0
  139. package/dist/update/UpdateService.js.map +1 -1
  140. package/package.json +17 -12
  141. package/dist/script/ScriptTranspiler.d.ts +0 -121
  142. package/dist/script/ScriptTranspiler.js +0 -333
  143. package/dist/script/ScriptTranspiler.js.map +0 -1
  144. package/dist/script/SnapshotHistoryRecorder.d.ts +0 -47
  145. package/dist/script/SnapshotHistoryRecorder.js +0 -231
  146. package/dist/script/SnapshotHistoryRecorder.js.map +0 -1
  147. package/dist/script/TsLibResolver.d.ts +0 -60
  148. package/dist/script/TsLibResolver.js +0 -134
  149. package/dist/script/TsLibResolver.js.map +0 -1
package/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # @bluestep-systems/b6p-core
2
2
 
3
3
  The core library for **B6P** — BlueStep script management (push / pull / audit / deploy of JavaScript &
4
- TypeScript "formula" scripts over WebDAV).
4
+ TypeScript "formula" scripts, through git).
5
5
 
6
6
  This package contains the headless orchestration logic shared by the
7
7
  [`b6p` CLI](https://github.com/Bluestep-Systems/b6p-cli) and the
@@ -9,6 +9,16 @@ This package contains the headless orchestration logic shared by the
9
9
  anywhere Node does. You supply the platform adapters (file system, prompts, logging, progress,
10
10
  persistence) through provider interfaces.
11
11
 
12
+ ## Requirements
13
+
14
+ Node.js **24 or newer** (`engines.node` is `>=24`).
15
+
16
+ ## Packages
17
+
18
+ This repo holds two npm packages: `@bluestep-systems/b6p-core` (this one, Node) and
19
+ [`@bluestep-systems/b6p-core-bsjs-git`](packages/bsjs-git/README.md) (browser and Node: git editing, publish and history
20
+ of BSJS scripts through the platform's git proxy). The first depends on the second and re-exports it as `bsjsGit`.
21
+
12
22
  ## Installation
13
23
 
14
24
  ```bash
@@ -24,16 +34,16 @@ the platform through its subsystem services:
24
34
  import { B6PCore, type B6PProviders } from "@bluestep-systems/b6p-core";
25
35
 
26
36
  const providers: B6PProviders = {
27
- fs, // FileSystem — read/write/list files
37
+ fs, // FileSystem — read/write/list files
28
38
  persistence, // Persistence — durable key/value (settings, sessions)
29
- prompt, // Prompt — ask the user for input/credentials
30
- logger, // Logger — diagnostic logging
31
- progress, // Progress — long-running task reporting
39
+ prompt, // Prompt — ask the user for input/credentials
40
+ logger, // Logger — diagnostic logging
41
+ progress, // Progress — long-running task reporting
32
42
  };
33
43
 
34
44
  const core = new B6PCore(providers);
35
45
 
36
- await core.script.pull({ formulaUrl: "https://org.bluestep.net/files/<id>/draft/", workspacePath });
46
+ await core.script.pull({ formulaUrl: "https://org.bluestep.net/files/<id>/", workspacePath });
37
47
  await core.script.push({ rootPath, snapshot: true, message: "Update script" });
38
48
  const audit = await core.script.audit({ filePath, workspacePath });
39
49
  ```
@@ -46,61 +56,133 @@ functionality as its own service. Script management is `core.script`; further su
46
56
  beside it rather than onto `B6PCore` itself.
47
57
 
48
58
  `core.script` ([`ScriptService`](src/script/ScriptService.ts)) — everything that moves a script tree
49
- between the local filesystem and the platform over WebDAV:
59
+ between the local filesystem and the platform (the draft over git, `declarations/` over WebDAV):
50
60
 
51
61
  | Method | Purpose |
52
62
  | --- | --- |
53
- | `push` / `pushCurrent` | Upload local script files to the platform (optional versioned snapshot) |
54
- | `pull` / `pullCurrent` | Download script files from a formula URL into a workspace |
63
+ | `push` / `pushCurrent` | Commit and push the draft folder (optionally publish it as a snapshot) |
64
+ | `pull` / `pullCurrent` | Clone or fast-forward the draft into a workspace |
55
65
  | `audit` / `auditPull` | Compare local vs. server; optionally pull differences |
56
66
  | `deploy` | Multi-target deploy driven by a config file |
57
67
  | `getSetupUrl` | Resolve a pulled script's web-UI setup page |
58
68
  | `deriveWorkspacePath` | Recover the workspace folder from a path inside a script root |
59
69
  | `getFactory` | The `ScriptFactory` for entering the script tree from a bare path |
60
70
 
71
+ `core.gateway` ([`GatewayService`](src/gateway/GatewayService.ts)) — web-global's gateway
72
+ (`https://gateway.bluestep.net`), the origin for knowledge bases and marketplace repos. It
73
+ holds the HTTP client, the git layer, `core.gateway.kb` (knowledge bases), `core.gateway.marketplace`
74
+ and `core.gateway.tokens` for managing the caller's own access tokens; see [Gateway](#gateway) below.
75
+
61
76
  `core` itself — cross-cutting state that is not specific to any one subsystem:
62
77
 
63
- | Method | Purpose |
64
- | --- | --- |
65
- | `report` | Report cached metadata / org-cache state |
66
- | `updateCredentials` / `clearSessions` / `clearSettings` / `clearAll` | Auth & state management |
67
- | `getConfig` / `setConfig` | Configuration helpers |
68
- | `checkForUpdates` | GitHub-releases-based update check |
69
- | `dispose` | Release the session cleanup timer and org-cache resources |
78
+ | Method | Purpose |
79
+ | -------------------------------------------------------------------- | --------------------------------------------------------- |
80
+ | `report` | Report cached metadata / org-cache state |
81
+ | `updateCredentials` / `clearSessions` / `clearSettings` / `clearAll` | Auth & state management |
82
+ | `getConfig` / `setConfig` | Configuration helpers |
83
+ | `checkForUpdates` | GitHub-releases-based update check |
84
+ | `dispose` | Release the session cleanup timer and org-cache resources |
70
85
 
71
86
  See [`src/index.ts`](src/index.ts) for the full set of exported classes, provider interfaces, data
72
87
  utilities, constants, and types.
73
88
 
89
+ ### Scripts are git (since 0.9.0)
90
+
91
+ A script's **draft folder is a git working tree**: `<workspace>/<U>/<script>/draft/` holds the files and its `.git`;
92
+ `declarations/` (generated typings, outside git) stays beside it. Everything about a script's draft and snapshot goes
93
+ through the platform's git proxy by way of [`bsjsGit`](packages/bsjs-git/README.md); no draft or snapshot file is read or
94
+ written over WebDAV any more (only `declarations/` and the root `.gitignore` still are).
95
+
96
+ - **pull** clones the draft branch into `draft/`, or fetches and fast-forwards it. A local edit to a file the platform
97
+ also changed is kept and reported (`keptLocalPaths`); files missing locally come back. A folder pulled before git (files,
98
+ no repository) is bound to the repo as it stands: its files that its last sync record shows unedited take the platform
99
+ copy, edited ones are kept.
100
+ - **push** commits the working tree as the author and pushes the draft branch; the platform then builds it (see below).
101
+ A **snapshot** push also publishes the build (`publishedSha`) and reads back that the platform's `master` is at that
102
+ commit.
103
+ - **audit** compares the working tree with the platform's draft (a folder that is not a git working copy yet is reported
104
+ as not pulled).
105
+ - **deploy** pushes the source draft's files to each target script through a scratch clone, and the target's platform
106
+ builds them; the source folder is never bound to a target.
107
+ - **A script that still publishes over WebDAV is switched to git, one way.** A push does it on its first write (and
108
+ `PushResult.switchedToGit` and a warning say so); a pull asks first (`Prompt.confirm`, safe answer first, so
109
+ auto-confirm declines and the pull returns `null`) unless `enableGit: true` is passed. After the switch the script's
110
+ draft and snapshot refuse WebDAV writes.
111
+ - **The commit author is never invented.** It is the `author` option of `push`/`pushCurrent`/`deploy`, else `git config
112
+ user.name`/`user.email` for the draft folder (global config included), else `GIT_AUTHOR_NAME`/`GIT_AUTHOR_EMAIL`
113
+ (then `GIT_COMMITTER_*`) from the environment, else a `GitIdentityError` before the platform is touched.
114
+ - `B6PProviders.gitFs` (default `node:fs`) is the Node-style file system git works on; it must read and write the same
115
+ disk as the `fs` provider.
116
+
74
117
  ### Push results
75
118
 
76
119
  `push` / `pushCurrent` resolve to a [`PushResult`](src/script/push.ts) (or `null` when no target was
77
- given). Read `pushed` first: `false` means nothing was uploaded.
120
+ given). Read `pushed` first: `false` means nothing was pushed.
78
121
 
79
122
  | Field | Meaning |
80
123
  | --- | --- |
81
- | `pushed` | The upload ran. `false` when the draft folder is missing or empty, or a snapshot's compiled `scripts/app.js` is missing or has no code (only comments and empty-module lines, as from a blank or types-only `app.ts`) |
82
- | `historyRecorded` | A snapshot's history entry was recorded. `false` also when the push stopped early |
83
- | `typeCheckDiagnostics` | Snapshot type-check: `0` clean, `> 0` published with diagnostics, `null` no check ran |
84
- | `liveVerified` | `true`: every `snapshot/` copy the push wrote reads back identical (by ETag). `false`: one is still different, missing or unreadable after one re-send, and the push stops before cleanup and history. `null`: not proven either way (a plain push, an early stop, or a copy served without a content hash, named in a warning) |
85
- | `liveMismatches` | Draft-relative paths whose live copy was still different, missing or unreadable after one re-send |
86
- | `keptPlatformOnly` | Platform-only files kept because deleting them was not confirmed |
87
-
88
- A snapshot push checks the compiled entrypoint before uploading, fails on a refused `snapshot/`
89
- write, re-uploads a file whose `snapshot/` copy is stale even when `draft/` matches, and reads the
90
- live copies back afterwards.
124
+ | `pushed` | The draft is on the platform. `false` when the draft folder is missing or empty |
125
+ | `commitSha` | The draft commit this push made, or the one already there; `null` when `pushed` is `false` |
126
+ | `route` | Which route ran: `{ mode: "server-build" \| "push-only", reason, serverVersion, required }`, `reason` one of `dev`, `at-or-above-floor`, `below-floor`, `unknown`, `floor-unset`. `null` when the push stopped before asking |
127
+ | `snapshotRefused` | Set when a snapshot was asked for on a server that does not build git drafts: `{ reason: "too-old" \| "unknown" \| "floor-unset", serverVersion, required }`. The draft was pushed; nothing was built or published |
128
+ | `build` | The platform's compile of the pushed draft (`compileDraft`): `status` (`COMPILED`, `GATE_TRIPPED`, `EMIT_WITHHELD`, `NOTHING_TO_COMPILE`, `SKIPPED_EXTERNALLY_BUILT`, …, or `UNKNOWN` with `rawStatus`), `errors` / `warnings`, `diagnostics` (+ `diagnosticsOmitted`), `gate`. `null` when no build ran or the request failed |
129
+ | `buildCommitSha` | The platform's build commit (output, and the manifest when it vouched); the folder was moved to it unless `buildFastForward` says otherwise. `null` when it made none (already built, nothing to build) |
130
+ | `buildFastForward` | How the folder was moved to the build: `{ state, blockedPaths, error }`, `state` `fast-forwarded`, `unchanged`, `blocked` (local files the build changes match neither side, listed; nothing was changed, nothing published) or `failed`. `null` when no build answer came |
131
+ | `buildIncomplete` | The build ended in a status after which the draft does not publish (`BUSY` / `INPUT_INCOMPLETE` once retries ran out, `COMPILER_UNAVAILABLE`, `NOT_PERMITTED`, `WRITE_FAILED`, `OUTPUT_UPLOAD`, `SKIPPED_GIT_MANAGED`, `GATE_TRIPPED`, `EMIT_WITHHELD`, `UNKNOWN`): `{ status, rawStatus, description }`. `null` otherwise |
132
+ | `buildVouched` | `true`: the build is clean and its manifest committed, or the draft needs none (externally built, nothing to build). `false`: unclean, output committed without a manifest, so a publish is refused until it builds cleanly. `null`: no build ran |
133
+ | `buildError` / `buildErrorKind` | Why no build answer came after a successful push, and whether a build was `not-requested` (the platform's draft was no longer the pushed commit) or the `request-failed` (it may have run); otherwise `null` |
134
+ | `publishedSha` | The commit the platform published on a snapshot push (the build commit); `null` on a plain push, when nothing was published, or on a failed publish. A caller that asked for a snapshot treats `null` as a failure |
135
+ | `publishError` / `publishRefusal` | Why the platform refused or failed the publish (the draft stays pushed), and the structured `{ reason, withheld }` (`BUILD_STALE`, `BUILD_MANIFEST_MISSING`, `DRAFT_MOVED`, `ENTRYPOINT_MISSING`, …) |
136
+ | `switchedToGit` | This push switched a WebDAV script to git, which cannot be undone |
137
+ | `typeCheckDiagnostics` | The platform build's whole count of `ERROR` and `WARNING` diagnostics; `null` when no build ran |
138
+ | `typeCheckErrors` | Those in the script's own sources (never a `.d.ts`), as listed by the platform, which lists at most 20: `{ file, line, column, code, message, severity }`, a type-checker finding being a `WARNING`. Empty when none or no build ran |
139
+ | `liveVerified` | `true`: the platform's `master` is at `publishedSha`. `false`: it is at another commit. `null`: not proven either way |
140
+ | `liveMismatches` | Draft-relative paths that differ between `publishedSha` and `master` when `liveVerified` is `false` |
141
+ | `keptPlatformOnly` | Platform-only files kept because deleting them was not confirmed (they are part of the pushed commit) |
142
+
143
+ ### How a push builds (since 1.0.0)
144
+
145
+ Nothing compiles in core or in `bsjsGit`; neither package has a runtime `typescript` dependency. The platform builds:
146
+
147
+ 1. The draft is committed and pushed over git (the confirmations above).
148
+ 2. `compileDraft` (GraphQL, `bsjsGit.ScriptRepo.compileDraft`) asks the platform to build the draft branch at the pushed
149
+ commit (`expectedDraftSha`; a draft that moved meanwhile is refused, `DraftBuildMovedError`). It commits the output,
150
+ plus the build manifest when the build is clean, as one build commit authored by the pushing user, and the folder is
151
+ fast-forwarded to it: the working tree and index first, for exactly the paths the build changed, then the branch. A
152
+ local file in the way (an edit, or an untracked or ignored copy matching neither side) leaves the folder as it was
153
+ and is reported (`buildFastForward`); a later push stops on it (`GitBuildFastForwardBlockedError`, with the paths)
154
+ until it is out of the way. A build whose answer was lost is taken in by the next push, not asked about: only a commit with the platform's
155
+ `Bluestep-Build-Of: <pushed sha>` trailer, one parent and an output-only diff (or a chain of such rebuilds) counts. `BUSY` is retried 3 times 5 s apart, `INPUT_INCOMPLETE` 3 times 2 s apart,
156
+ `COMPILER_UNAVAILABLE` and a failed request once. Every push builds, plain ones too.
157
+ 3. A snapshot push whose build status publishes (`COMPILED`, `NOTHING_TO_COMPILE`, `SKIPPED_EXTERNALLY_BUILT`) then
158
+ publishes the build commit and reads `master` back. An unclean build is refused by the platform's manifest check
159
+ (`publishRefusal.reason` `BUILD_MANIFEST_MISSING` or `BUILD_STALE`); a tripped gate or withheld emit publishes
160
+ nothing. Once the push succeeded, nothing throws: a failed build is `buildError`, a status that does not publish
161
+ `buildIncomplete`, a failed publish `publishError`, and none of them is reported complete. A deploy counts a
162
+ snapshot target that published nothing as failed.
163
+
164
+ Before pushing, a push asks the org's server for its version (`/appinfo/version`) and picks the route; it never refuses
165
+ a push for the version. A `dev` or `latest` server, or one at or above `MIN_SERVER_VERSION`, builds as above. Any other
166
+ (below the floor, an unreadable version, the floor unset) gets the git push alone: no build, and a snapshot push takes
167
+ no snapshot (`snapshotRefused`). `MIN_SERVER_VERSION` is `26.11.16.00`, the day the git build
168
+ (web#2022) was readied; every web release from that day on has it.
91
169
 
92
170
  ### Overwrites and destructive prompts
93
171
 
94
- Before uploading, a push asks **once** about every file whose upload would overwrite a platform
95
- version nobody here has seen: the platform has a `draft/` copy that differs from local and from the
96
- last push or pull here, or that was never synced here. New files and files already in sync never
97
- ask. Declining throws `Err.OverwriteDeclinedError` (a `UserCancelledError`) with the files in
98
- `paths`, before anything is written. To confirm without a prompt, pass their draft-relative paths:
172
+ Before anything is pushed, a push asks **once** about every file it would overwrite that the platform changed since
173
+ this folder was last synced (git: the draft branch moved on, or, for a folder with no repo of its own, the platform copy
174
+ differs from what the sync record says this machine last had). Files only changed here never ask. Declining throws
175
+ `Err.OverwriteDeclinedError` (a `UserCancelledError`) with the files in `paths`, before anything is pushed. Confirming
176
+ pushes a merge commit, so the platform's commits stay in the history. To confirm without a prompt, pass the
177
+ draft-relative paths:
99
178
 
100
179
  ```typescript
101
180
  await core.script.push({ rootPath, overwrite: ["scripts/app.ts"] });
102
181
  ```
103
182
 
183
+ A second prompt covers platform files the platform gained since the last sync that have no local copy ("delete them from
184
+ the platform?", `No` first); anything but `Yes` keeps them and reports them in `keptPlatformOnly`.
185
+
104
186
  Every prompt that overwrites or deletes puts its **safe option first** and marks itself with the
105
187
  optional third argument of `Prompt.confirm`:
106
188
 
@@ -114,6 +196,202 @@ So a `Prompt` that answers `options[0]` without asking (an empty answer, an auto
114
196
  declines. Core's messages say what was kept and why. How to confirm (a flag, a button, piped
115
197
  input) is the consumer's to explain.
116
198
 
199
+ ### Gateway
200
+
201
+ `core.gateway.client` ([`GatewayClient`](src/gateway/GatewayClient.ts)) talks to web-global's gateway
202
+ with the same `b6pt_` access token `BearerAuthProvider` already stores: it reads the stored token on
203
+ every request (never prompting) and sends it as `Authorization: Bearer <token>`. There is no session
204
+ or login on this origin. REST requests through the client run one at a time; redirects are never
205
+ followed, and a request path that resolves off the gateway's origin is refused before sending.
206
+
207
+ ```typescript
208
+ await core.setConfig("gatewayUrl", "https://gateway.bluestep.net"); // the default; https only, except loopback
209
+ const list = await core.gateway.client.getJson("/api/v1/knowledge-bases", { scope: "global" });
210
+ const headers = await core.gateway.client.authHeadersFor(gitUrl); // for a git client; gateway origin only
211
+ ```
212
+
213
+ Failures are typed, all extending `Err.GatewayError` (`status`, `code`):
214
+
215
+ | Error | When |
216
+ | --- | --- |
217
+ | `GatewayAuthError` (`reason`) | `token-missing` (none stored; thrown before sending), `token-invalid` (401), `token-malformed` (not a `b6pt_` token; nothing sent) |
218
+ | `GatewayScopeError` (`scope`) | `403 scope-missing` |
219
+ | `GatewayNotPermittedError` | `403 not-permitted` |
220
+ | `GatewayNotFoundError` | `404` (also for something that exists but is not visible) |
221
+ | `GatewayScopeEscalationError` | `403 scope-escalation` (a new token asked for a scope the presenting one lacks) |
222
+ | `GatewayConflictError` | `409 non-fast-forward` |
223
+ | `GatewayAliasTakenError` | `409 alias-taken` |
224
+ | `GatewayTooLargeError` | `413 too-large` |
225
+ | `GatewayUnavailableError` | `502`/`503`/`504`, a network failure or a timeout |
226
+ | `GatewayUnexpectedResponseError` | any other status, a redirect (`code: "redirect-refused"`, not followed), or a 2xx body that is not JSON |
227
+ | `GatewayConfigError` | an unusable `gatewayUrl`, or a URL or request path that resolves off the gateway's origin |
228
+ | `GatewayDirtyWorkingTreeError` (`paths`) | a pull would overwrite local changes (git layer) |
229
+ | `GatewayCloneMismatchError` (`reason`, `dir`, `repo`) | a marketplace pull found a clone it must not update: `different-repo`, `different-ref`, `tag-moved` (the tag now names another commit) or `tag-gone` (the gateway no longer has it) |
230
+ | `GatewayKnowledgeBaseError` (`reason`, `ref`, `candidates`) | a knowledge base address is `bad-ref`, `not-found`, `ambiguous`, `unsafe-name`, `wrong-branch` (a pull or push from a clone that is detached, off the live branch, or not tracking it; fields `branch`, `liveBranch`, `upstream`), or a clone is `not-a-kb` |
231
+ | `GatewayKnowledgeBasePushNotPermittedError` (`ref`) | a push to a KB whose listing says `canPush: false` (a `GatewayNotPermittedError`) |
232
+ | `GatewayInvalidArgumentError` | refused before sending: an empty alias or scope list, an expiry that is not a date, a pasted `b6pt_` secret where an id or alias belongs (token operations), or a relative path with no absolute `cwd` to resolve it against (core never reads `process.cwd()`) |
233
+ | `GatewayWorkingCopyError` (`reason`) | the local folder cannot be used: `not-empty`, `not-a-clone`, `detached`, `no-upstream`, `diverged`, `ref-not-found`, `unsafe-target` (git layer), `wrong-repository` (knowledge-base pull) |
234
+
235
+ `core.gateway.client.sequence((seq) => …)` runs a unit as one queue entry: nothing else on the
236
+ client runs until it settles. `seq.token()` reads the token once, and `seq.request` presents that
237
+ read. The git layer holds the queue for a whole operation with it, and token rotation uses it so
238
+ nothing runs between the revoke and the store.
239
+
240
+ `gatewayErrorFor(status, body, what)` applies the same mapping to a status seen elsewhere (the git
241
+ layer). The token never appears in a message or a log line, including when the server echoes it.
242
+
243
+ #### Git
244
+
245
+ `core.gateway.git` ([`GatewayGit`](src/gateway/GatewayGit.ts)) clones and updates the repositories behind
246
+ a knowledge base or marketplace listing, in pure JS ([isomorphic-git](https://isomorphic-git.org), MIT;
247
+ no git install needed) over the gateway's smart HTTP endpoints. It takes the `gitUrl` from a listing
248
+ and never builds one; a URL off the gateway's origin is refused before any request, and a redirect is
249
+ not followed (`redirect-refused`). The folders are real local paths, read and written through Node's `fs`, and file
250
+ contents are never rewritten (no autocrlf).
251
+
252
+ ```typescript
253
+ await core.gateway.git.clone(kb.gitUrl, dir, { ref: "master" }); // dir missing or empty
254
+ const status = await core.gateway.git.status(dir, { fetch: true }); // branch, dirty, ahead, behind
255
+ await core.gateway.git.pull(dir); // fetch + fast-forward only
256
+ await core.gateway.git.push(dir); // current branch to its upstream, fast-forward only
257
+ await core.gateway.git.inspect(dir, "v1"); // origin url, branch, head, upstream, local tag commit (typed `not-a-clone` if damaged)
258
+ await core.gateway.git.remoteTagCommit(kb.gitUrl, "v1"); // the commit a tag names on the gateway now, or null
259
+ ```
260
+
261
+ - `pull` never merges or rebases. A clean tree just proceeds, and unstaged edits and untracked files
262
+ on paths the incoming commits do not touch are kept. Anything staged refuses the pull (the checkout
263
+ would drop it), naming the paths. A pull interrupted after its checkout is finished on the next call. If they do touch them, it throws `GatewayDirtyWorkingTreeError` with the
264
+ `paths` and changes nothing. If both sides have moved on it throws `GatewayWorkingCopyError`
265
+ (`diverged`).
266
+ - `push` is never forced, never deletes a ref and never sends tags. An upstream that has moved on
267
+ (found locally, or reported by the gateway as `409`) is `GatewayConflictError`; a token without
268
+ `kb:push` is `GatewayScopeError`.
269
+ - Gateway failures map through `gatewayErrorFor`, as for REST. Operations share the client's
270
+ one-at-a-time queue.
271
+
272
+ #### Access tokens
273
+
274
+ `core.gateway.tokens` ([`GatewayTokenService`](src/gateway/GatewayTokenService.ts)) manages the
275
+ caller's **own** tokens. Every call needs the `tokens:self` scope on the stored token
276
+ (`GatewayScopeError` with `scope: "tokens:self"` otherwise); nothing addresses another user.
277
+
278
+ ```typescript
279
+ const tokens = await core.gateway.tokens.list(); // [{ id, alias, scopes, createdAt (null for old tokens), expiresAt, lastUsedAt (approximate), current, neverExpires, expired }] - expired tokens are listed too
280
+ const minted = await core.gateway.tokens.create({ alias: "ci", scopes: ["kb:read"] }); // 90 days by default
281
+ minted.expiryCapped; // null, or { cappedTo, requested: "90d" } when the 90-day default was cut to the stored token's own expiry
282
+ minted.token; // the b6pt_ secret, shown this once; expiresAt: null mints one that never expires (neverExpires: true)
283
+ await core.gateway.tokens.revoke("ci"); // id or alias → { id, alias, revokedCurrent }
284
+ await core.gateway.tokens.rotate("laptop"); // → { replaced, token, rotatedCurrent }
285
+ ```
286
+
287
+ - An id or alias is trimmed and resolved through `list()` first: no match is `GatewayNotFoundError`,
288
+ a value that is one token's id and another's alias is `GatewayTokenAmbiguousError`, and a value
289
+ containing `b6pt_` anywhere (a pasted secret) is refused (`GatewayInvalidArgumentError`) without
290
+ being sent. Nothing is revoked or rotated in any of these cases, and no message quotes the value.
291
+ - `create` refuses an empty or whitespace alias, an empty scope list or an expiry that is not a
292
+ strict ISO 8601 date-time with a time zone (`2027-02-01T00:00:00Z`, `…+05:30`; a plain date,
293
+ `March 7` or `1` is refused) before sending (`GatewayInvalidArgumentError`). A new token's scopes must be a subset of the
294
+ stored token's.
295
+ - **Expiry.** The gateway caps a new token's expiry at the presenting token's. With no `expiresAt`,
296
+ `create` sends none and the gateway mints for the sooner of 90 days and the stored token's expiry;
297
+ `expiryCapped` (`{ cappedTo, requested: "90d" }`, `cappedTo` = the returned `expiresAt`) is set only
298
+ when that cut more than 24 hours off the 90 days. An explicit expiry, or `null`, is sent as given. A
299
+ `403 not-permitted` on a mint or rotate is typed by the body's `reason`:
300
+ `expiry-exceeds-presenting` (with `presentingExpiresAt`) is `GatewayTokenExpiryRefusedError`,
301
+ `restricted-mints-disabled` is `GatewayRestrictedMintsDisabledError`, `rewrite-not-permitted` (with
302
+ `scope: "kb:rewrite"`) is `GatewayRewriteNotPermittedError`, and any other or missing
303
+ reason stays `GatewayNotPermittedError` (`reason` says what arrived). Other mint failures:
304
+ `GatewayTokenLimitError` (`409 token-limit`, `limit`), `GatewayInvalidRequestError` (`400`). Scopes
305
+ (including `kb:rewrite`) are not checked client-side.
306
+ - **Rotating the stored token** (`current`) stores the replacement in its place: there is still one
307
+ stored token. If storing fails after the gateway has rotated (so the old token is already
308
+ revoked), `rotate` throws `GatewayTokenStoreError`, whose non-enumerable `replacement` property
309
+ carries the new token, secret included, so it can be shown and the user is not locked out. The
310
+ store also refuses, the same way, when the stored token is no longer the one that was rotated
311
+ (an in-process compare-then-write, not atomic across processes). The list, the rotate and the
312
+ store run as one entry in the client's queue with one read of the stored token, so a request
313
+ queued behind a rotation presents the replacement, never the revoked token.
314
+ - **A minted secret that reaches core is never dropped.** When a create or rotate answer carries
315
+ the secret but is otherwise off-contract, the call throws `GatewayOffContractTokenError`, whose
316
+ non-enumerable `secret` holds it; for a rotation of the stored token it is still offered to the
317
+ store, and `stored` says whether that worked. The store reads the token back after writing, so
318
+ another writer's overwrite (for example a second b6p process) is `GatewayTokenStoreError`, not
319
+ success.
320
+ - **An answer that never arrives** (a dropped connection, a timeout, or `502`/`503`/`504` on the
321
+ create or rotate request) is `GatewayOutcomeUnknownError` (a `GatewayUnavailableError`,
322
+ `operation` `create` or `rotate`): the token may have been minted or rotated, and for a rotation
323
+ the old one may already be revoked. Any new secret is lost; the error says the outcome is unknown.
324
+ - **Rotation is retried once.** `rotate` sends an `Idempotency-Key` (a fresh UUID per call). When the
325
+ rotate request goes unanswered, it is retried once with the same key and presenting token, and the
326
+ gateway answers the retry with the first attempt's result without rotating again; a successful
327
+ retry is the normal path. `GatewayOutcomeUnknownError` (`retried: true`) follows only when the
328
+ retry is unanswered too, or is refused `401`/`404` while rotating the stored token (the first
329
+ attempt most likely rotated and so revoked it); the store is then left untouched. A create is
330
+ never retried. A rotated token keeps its absolute end date; an expired one cannot be rotated
331
+ (`GatewayInvalidRequestError`).
332
+ - **Revoking the stored token** is allowed. The result says `revokedCurrent: true` and the stored
333
+ (now dead) token is left in place; what to do next is the consumer's call.
334
+ - Core never logs a secret or puts one in an error message. Warning about a token that never
335
+ expires is the consumer's job; results carry `neverExpires`.
336
+
337
+ #### Marketplace
338
+
339
+ `core.gateway.marketplace` ([`GatewayMarketplace`](src/gateway/GatewayMarketplace.ts)) lists the
340
+ marketplace repos (name, description, default branch, tags, `gitUrl`; the body is validated) and
341
+ pulls a plain working clone of one. It is unrelated to any script's sources or pins, and there is
342
+ no push (the gateway refuses it for the marketplace).
343
+
344
+ ```typescript
345
+ const repos = await core.gateway.marketplace.list();
346
+ const repo = await core.gateway.marketplace.get("core"); // GatewayNotFoundError if absent
347
+ await core.gateway.marketplace.pull("core", { cwd }); // <cwd>/core at the default branch
348
+ await core.gateway.marketplace.pull("core", { cwd, dir, ref: "v1.1.0" }); // a tag (detached head) or branch
349
+ ```
350
+
351
+ `cwd` is the consumer's own working directory (core never reads `process.cwd()`); `dir` is relative to it.
352
+ `list` leaves out a malformed entry rather than failing for every repo (`get` of that name is
353
+ `GatewayUnexpectedResponseError`), and a name is checked as a folder name only when `dir` is omitted.
354
+ `ref` may be a short name or `refs/heads/x` / `refs/tags/x` (normalised to `x`). A folder name from the listing must be a plain segment: no leading dot (so never `.git`), `git~N`, control or reserved characters, or Windows device names (`CON`, `CONIN$`, `COM0`..., also `CON .txt`), and no Unicode control, format or invisible characters (those make the whole listing entry malformed, in any text field). `cwd` must be absolute and is required unless `dir` is absolute: a relative folder without it is `GatewayConfigError`.
355
+ `pull` clones into a missing or empty folder. A folder that already holds a clone of the same
356
+ `gitUrl` on a branch is fast-forwarded (`action`: `fast-forwarded`, `up-to-date` or `ahead`); a tag
357
+ checkout is `up-to-date` when the gateway's tag still points at the checked-out commit, else
358
+ `GatewayCloneMismatchError` (`tag-moved`, or `tag-gone` when the gateway no longer has the tag). A clone of another repo, or on another ref than asked for, is
359
+ `GatewayCloneMismatchError` (`reason`: `different-repo` / `different-ref` / `tag-moved` / `tag-gone`, plus `dir` and `repo`) and is
360
+ left untouched; local changes the incoming commits would overwrite are `GatewayDirtyWorkingTreeError`;
361
+ a folder with files but no clone is `GatewayWorkingCopyError` (`not-empty`).
362
+
363
+ #### Knowledge bases
364
+
365
+ `core.gateway.kb` ([`GatewayKb`](src/gateway/GatewayKb.ts)) lists the knowledge bases the token's user
366
+ may read, global and tenant, and pulls and pushes them over `core.gateway.git`. A KB is addressed as
367
+ `<name>` (global) or `<U…>/<name>` (tenant); the listing's own `global/<name>` and
368
+ `tenant/<U…>/<name>` forms work too.
369
+
370
+ ```typescript
371
+ const kbs = await core.gateway.kb.list({ scope: "tenant", tenant: "U142133" }); // ref, scope, tenant, name, title, liveBranch, canPush, gitUrl
372
+ const kb = await core.gateway.kb.resolve("onboarding");
373
+ const pulled = await core.gateway.kb.pull("U142133/handbook", { cwd: process.cwd() }); // clones into <cwd>/U142133-handbook
374
+ const pushed = await core.gateway.kb.push(pulled.dir); // { pushed, commit, ref }; a relative dir needs { cwd }
375
+ ```
376
+
377
+ - `list` checks the body's shape and throws `GatewayUnexpectedResponseError` for a bad one.
378
+ - `resolve` throws `GatewayKnowledgeBaseError` (`reason`: `bad-ref`, `not-found`, `ambiguous` with
379
+ `candidates`).
380
+ - `pull` clones the live branch into a missing or empty folder (`dir`, relative to the `cwd` you pass;
381
+ default `<name>`, or `<tenant>-<name>`), and fast-forwards an existing clone of the same repository.
382
+ An existing clone that is not on the KB's live branch, does not track it, or is detached is refused before any fetch with `GatewayKnowledgeBaseError` (`wrong-branch`, `branch`, `liveBranch`). A clone of a different repository is `GatewayWorkingCopyError` (`wrong-repository`); incoming commits
383
+ that touch locally changed files are `GatewayDirtyWorkingTreeError` (`paths`). It never prompts and
384
+ has no way to discard local changes.
385
+ - `push` finds the KB from the clone's remote in a fresh listing and refuses a KB with
386
+ `canPush: false` before sending anything, with `GatewayKnowledgeBasePushNotPermittedError` (`ref`).
387
+ A clone not on the KB's live branch, not tracking it, or detached is refused the same way with `GatewayKnowledgeBaseError` (`wrong-branch`, `branch`, `liveBranch`). A gateway branch that moved on is `GatewayConflictError`.
388
+
389
+ For specs, [`FakeGateway`](src/testing/FakeGateway.ts) is an in-process gateway on `127.0.0.1` that
390
+ answers the contract's REST routes (the token routes included) and error codes, with `grantToken`
391
+ (scopes, plus optional id, alias, owner and expiry; an expired token is `401 token-invalid`),
392
+ `issuedTokens`, `issuedSecrets` (every secret ever accepted, revoked ones included, for leak
393
+ checks), `failNext` and `route` (for mounting git smart-HTTP handlers).
394
+
117
395
  ## Development
118
396
 
119
397
  ```bash
package/dist/B6PCore.d.ts CHANGED
@@ -5,6 +5,7 @@ import { ScriptMetaDataStore } from "./cache/ScriptMetaDataStore";
5
5
  import { OrgCache } from "./cache/OrgCache";
6
6
  import { ScriptService } from "./script/ScriptService";
7
7
  import { UpdateService } from "./update/UpdateService";
8
+ import { GatewayService } from "./gateway/GatewayService";
8
9
  /**
9
10
  * Result returned by the report command.
10
11
  */
@@ -59,6 +60,12 @@ export declare class B6PCore {
59
60
  * @lastreviewed null
60
61
  */
61
62
  readonly script: ScriptService;
63
+ /**
64
+ * Web-global's gateway: knowledge bases, marketplace repos and the caller's own tokens, over the
65
+ * `b6pt_` token.
66
+ * @lastreviewed null
67
+ */
68
+ readonly gateway: GatewayService;
62
69
  private readonly _isDebugMode;
63
70
  constructor(providers: B6PProviders);
64
71
  isDebugMode(): boolean;
package/dist/B6PCore.js CHANGED
@@ -1,15 +1,81 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
2
35
  Object.defineProperty(exports, "__esModule", { value: true });
3
36
  exports.B6PCore = void 0;
37
+ const nodeFs = __importStar(require("node:fs"));
38
+ const constants_1 = require("./constants");
4
39
  const BearerAuthProvider_1 = require("./auth/BearerAuthProvider");
5
40
  const SessionManager_1 = require("./session/SessionManager");
6
41
  const ScriptMetaDataStore_1 = require("./cache/ScriptMetaDataStore");
7
42
  const OrgCache_1 = require("./cache/OrgCache");
8
43
  const ScriptService_1 = require("./script/ScriptService");
9
44
  const UpdateService_1 = require("./update/UpdateService");
45
+ const GatewayService_1 = require("./gateway/GatewayService");
46
+ const Gateway_1 = require("./constants/Gateway");
47
+ const SettingsKeys_1 = require("./constants/SettingsKeys");
10
48
  const NOOP_ORG_CACHE_SETTINGS = {
11
49
  getParsedAnyDomainOverrideUrl: () => null,
12
50
  };
51
+ /**
52
+ * The gateway's token source: the `b6pt_` token the bearer provider already stores (ruling 22),
53
+ * read without prompting. A consumer-supplied {@link AuthProvider} of some other scheme holds no
54
+ * such token, so the gateway then has none and every request fails `token-missing` before sending.
55
+ * @lastreviewed null
56
+ */
57
+ function gatewayTokenFrom(auth) {
58
+ if (auth instanceof BearerAuthProvider_1.BearerAuthProvider) {
59
+ return { token: () => auth.storedToken() };
60
+ }
61
+ return { token: async () => undefined };
62
+ }
63
+ /**
64
+ * Where a rotated replacement of the stored token is written: {@link BearerAuthProvider.replaceStoredToken}.
65
+ * Any other {@link AuthProvider} stores no `b6pt_` token, so the gateway never presented one and
66
+ * there is nothing to replace; the write is refused.
67
+ * @lastreviewed null
68
+ */
69
+ function gatewayTokenStoreFrom(auth) {
70
+ if (auth instanceof BearerAuthProvider_1.BearerAuthProvider) {
71
+ return { replace: (expected, next) => auth.replaceStoredToken(expected, next) };
72
+ }
73
+ return {
74
+ replace: async () => {
75
+ throw new Error("The configured auth provider stores no gateway token to replace.");
76
+ },
77
+ };
78
+ }
13
79
  /**
14
80
  * Headless SDK entry point for the BlueStep platform.
15
81
  *
@@ -56,6 +122,12 @@ class B6PCore {
56
122
  * @lastreviewed null
57
123
  */
58
124
  script;
125
+ /**
126
+ * Web-global's gateway: knowledge bases, marketplace repos and the caller's own tokens, over the
127
+ * `b6pt_` token.
128
+ * @lastreviewed null
129
+ */
130
+ gateway;
59
131
  _isDebugMode;
60
132
  constructor(providers) {
61
133
  this.fs = providers.fs;
@@ -86,7 +158,30 @@ class B6PCore {
86
158
  ...platform,
87
159
  scriptMetadataStore: this.scriptMetadataStore,
88
160
  orgCache: this.orgCache,
89
- typescriptLibDirs: providers.typescriptLibDirs,
161
+ gitFs: providers.gitFs ?? nodeFs,
162
+ gitToken: async () => {
163
+ const header = await this.auth.authHeaderValue();
164
+ return header.startsWith(constants_1.AuthTypes.BEARER_PREFIX) ? header.slice(constants_1.AuthTypes.BEARER_PREFIX.length) : header;
165
+ },
166
+ gitFetch: providers.fetchFn,
167
+ gitEnv: providers.gitEnv,
168
+ });
169
+ // The gateway is a second origin that takes the same stored `b6pt_` token, but per request: it
170
+ // reads it through a non-prompting accessor and never goes through `SessionManager`'s cookie
171
+ // bootstrap or `auth.authHeaderValue()`. Its URL is read from core config on every
172
+ // request (default gateway.bluestep.net) and validated by the client.
173
+ const persistence = this.persistence;
174
+ this.gateway = new GatewayService_1.GatewayService({
175
+ ...platform,
176
+ gatewayToken: gatewayTokenFrom(this.auth),
177
+ gatewayTokenStore: gatewayTokenStoreFrom(this.auth),
178
+ gatewayUrl: async () => {
179
+ const configured = await persistence.get(`settings.${SettingsKeys_1.SettingsKeys.GATEWAY_URL}`);
180
+ return configured === undefined || configured === null || configured === ""
181
+ ? Gateway_1.Gateway.DEFAULT_URL
182
+ : String(configured);
183
+ },
184
+ fetchFn: providers.fetchFn ?? globalThis.fetch.bind(globalThis),
90
185
  });
91
186
  // Initialize update service if configuration is provided
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,CAAC;iBAAM,CAAC;gBACN,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,wCAAwC,IAAI,CAAC,aAAa,CAAC,iBAAiB,EAAE,GAAG,CAAC,CAAC;YACtG,CAAC;QACH,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,+BAA+B,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC;QACrG,CAAC;IACH,CAAC;IAED,qEAAqE;IAErE,KAAK,CAAC,SAAS,CAAC,GAAW,EAAE,KAAc;QACzC,MAAM,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,YAAY,GAAG,EAAE,EAAE,KAAK,CAAC,CAAC;QACrD,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,GAAG,MAAM,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;IAC5D,CAAC;IAED,KAAK,CAAC,SAAS,CAAI,GAAW;QAC5B,OAAO,IAAI,CAAC,WAAW,CAAC,GAAG,CAAI,YAAY,GAAG,EAAE,CAAC,CAAC;IACpD,CAAC;IAED;;OAEG;IACH,OAAO;QACL,IAAI,CAAC,cAAc,CAAC,OAAO,EAAE,CAAC;QAC9B,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAC;IAC1B,CAAC;CACF"}
package/dist/B6PUri.d.ts CHANGED
@@ -124,11 +124,11 @@ export declare class B6PUri {
124
124
  * of one directory compare equal.
125
125
  *
126
126
  * The single definition behind every marker-insensitive comparison in the codebase:
127
- * `ScriptFolder.contains`/`equals`, `ScriptRoot.selectStaleBundles`'s containment
128
- * test, and `MockFileSystem`'s entry keys. It lives here, beside
127
+ * `ScriptFolder.contains`/`equals`, path-containment checks in the push, and
128
+ * `MockFileSystem`'s entry keys. It lives here, beside
129
129
  * {@link B6PUri.isDirectoryMarked} and {@link B6PUri.asDirectory}, because a
130
- * comparison rule that disagrees with the API producing the marker is how the
131
- * stale-bundle regression happened.
130
+ * comparison rule that disagrees with the API producing the marker once silently
131
+ * broke a containment check.
132
132
  *
133
133
  * Accepts either a filesystem path or a URL string, and handles each on its own
134
134
  * terms:
@@ -154,10 +154,8 @@ export declare class B6PUri {
154
154
  * The result is a directory in every case by construction, so marking it looks
155
155
  * right — and an earlier revision did exactly that, via {@link B6PUri.asDirectory}.
156
156
  * It caused a real regression: `TsConfig.folder()` is built from `rawUri.dirname`,
157
- * so `ScriptRoot.findStaleClientBundles` began pushing a marker-terminated
158
- * `sourceRoot`, and `selectStaleBundles`'s containment test compared against
159
- * `"…/static" + sep + sep`. Nothing ever matched, and `b6p push` silently stopped
160
- * warning about stale compiled client bundles.
157
+ * so a containment test began comparing against `"…/static" + sep + sep`.
158
+ * Nothing ever matched, and a check that depended on it silently stopped working.
161
159
  *
162
160
  * The misclassification the marker was meant to prevent — `ScriptFactory.createNode`
163
161
  * treating a parent directory as a `ScriptFile` — is not reachable from any call