@harperfast/harper 5.2.0-alpha.4 → 5.2.0-alpha.6

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 (173) hide show
  1. package/agent/agent.ts +152 -10
  2. package/agent/bestPractices.ts +58 -0
  3. package/agent/mcpTools.ts +122 -0
  4. package/agent/operations.ts +10 -1
  5. package/agent/registryTools.ts +117 -0
  6. package/agent/session.ts +16 -7
  7. package/agent/tools/fsTools.ts +74 -27
  8. package/agent/tools/inspectorTool.ts +459 -0
  9. package/agent/toolset.ts +27 -7
  10. package/agent/types.ts +2 -0
  11. package/components/Application.ts +566 -85
  12. package/components/OptionsWatcher.ts +62 -2
  13. package/components/Scope.ts +31 -8
  14. package/components/componentLoader.ts +5 -1
  15. package/components/componentSecrets.ts +514 -55
  16. package/components/deploymentRecorder.ts +7 -6
  17. package/components/gitCredentialHelper.js +115 -0
  18. package/components/gitCredentialServer.ts +251 -0
  19. package/components/mcp/tools/application.ts +197 -23
  20. package/components/mcp/tools/operations.ts +1 -1
  21. package/components/mcp/tools/schemas/derive.ts +6 -2
  22. package/components/operations.js +21 -19
  23. package/components/operationsValidation.js +86 -21
  24. package/components/secretOperations.ts +110 -30
  25. package/config/harperConfigEnvVars.ts +90 -5
  26. package/config-root.schema.json +4 -0
  27. package/dist/agent/agent.d.ts +24 -3
  28. package/dist/agent/agent.js +172 -10
  29. package/dist/agent/agent.js.map +1 -1
  30. package/dist/agent/bestPractices.d.ts +24 -0
  31. package/dist/agent/bestPractices.js +60 -0
  32. package/dist/agent/bestPractices.js.map +1 -0
  33. package/dist/agent/mcpTools.d.ts +24 -0
  34. package/dist/agent/mcpTools.js +115 -0
  35. package/dist/agent/mcpTools.js.map +1 -0
  36. package/dist/agent/operations.js +10 -1
  37. package/dist/agent/operations.js.map +1 -1
  38. package/dist/agent/registryTools.d.ts +45 -0
  39. package/dist/agent/registryTools.js +113 -0
  40. package/dist/agent/registryTools.js.map +1 -0
  41. package/dist/agent/session.js +16 -7
  42. package/dist/agent/session.js.map +1 -1
  43. package/dist/agent/tools/fsTools.js +70 -28
  44. package/dist/agent/tools/fsTools.js.map +1 -1
  45. package/dist/agent/tools/inspectorTool.d.ts +40 -0
  46. package/dist/agent/tools/inspectorTool.js +428 -0
  47. package/dist/agent/tools/inspectorTool.js.map +1 -0
  48. package/dist/agent/toolset.d.ts +16 -6
  49. package/dist/agent/toolset.js +17 -7
  50. package/dist/agent/toolset.js.map +1 -1
  51. package/dist/agent/types.d.ts +2 -0
  52. package/dist/components/Application.d.ts +73 -18
  53. package/dist/components/Application.js +475 -64
  54. package/dist/components/Application.js.map +1 -1
  55. package/dist/components/OptionsWatcher.d.ts +1 -1
  56. package/dist/components/OptionsWatcher.js +65 -2
  57. package/dist/components/OptionsWatcher.js.map +1 -1
  58. package/dist/components/Scope.d.ts +8 -6
  59. package/dist/components/Scope.js +22 -6
  60. package/dist/components/Scope.js.map +1 -1
  61. package/dist/components/componentLoader.js +5 -1
  62. package/dist/components/componentLoader.js.map +1 -1
  63. package/dist/components/componentSecrets.d.ts +33 -7
  64. package/dist/components/componentSecrets.js +473 -59
  65. package/dist/components/componentSecrets.js.map +1 -1
  66. package/dist/components/deploymentRecorder.d.ts +2 -2
  67. package/dist/components/deploymentRecorder.js +1 -1
  68. package/dist/components/deploymentRecorder.js.map +1 -1
  69. package/dist/components/gitCredentialHelper.d.ts +1 -0
  70. package/dist/components/gitCredentialHelper.js +113 -0
  71. package/dist/components/gitCredentialHelper.js.map +1 -0
  72. package/dist/components/gitCredentialServer.d.ts +33 -0
  73. package/dist/components/gitCredentialServer.js +236 -0
  74. package/dist/components/gitCredentialServer.js.map +1 -0
  75. package/dist/components/mcp/tools/application.d.ts +19 -0
  76. package/dist/components/mcp/tools/application.js +180 -22
  77. package/dist/components/mcp/tools/application.js.map +1 -1
  78. package/dist/components/mcp/tools/operations.d.ts +13 -0
  79. package/dist/components/mcp/tools/operations.js +1 -0
  80. package/dist/components/mcp/tools/operations.js.map +1 -1
  81. package/dist/components/mcp/tools/schemas/derive.js +6 -2
  82. package/dist/components/mcp/tools/schemas/derive.js.map +1 -1
  83. package/dist/components/operations.js +23 -21
  84. package/dist/components/operations.js.map +1 -1
  85. package/dist/components/operationsValidation.js +84 -21
  86. package/dist/components/operationsValidation.js.map +1 -1
  87. package/dist/components/secretOperations.d.ts +33 -11
  88. package/dist/components/secretOperations.js +90 -26
  89. package/dist/components/secretOperations.js.map +1 -1
  90. package/dist/config/harperConfigEnvVars.d.ts +21 -0
  91. package/dist/config/harperConfigEnvVars.js +95 -5
  92. package/dist/config/harperConfigEnvVars.js.map +1 -1
  93. package/dist/index.d.ts +4 -0
  94. package/dist/index.js +14 -1
  95. package/dist/index.js.map +1 -1
  96. package/dist/resources/Resource.d.ts +19 -0
  97. package/dist/resources/Resource.js +93 -2
  98. package/dist/resources/Resource.js.map +1 -1
  99. package/dist/resources/Table.d.ts +9 -0
  100. package/dist/resources/Table.js +256 -50
  101. package/dist/resources/Table.js.map +1 -1
  102. package/dist/resources/analytics/read.js +28 -25
  103. package/dist/resources/analytics/read.js.map +1 -1
  104. package/dist/resources/defineResource.d.ts +180 -0
  105. package/dist/resources/defineResource.js +505 -0
  106. package/dist/resources/defineResource.js.map +1 -0
  107. package/dist/resources/defineTable.d.ts +221 -0
  108. package/dist/resources/defineTable.js +227 -0
  109. package/dist/resources/defineTable.js.map +1 -0
  110. package/dist/resources/jsonSchemaTypes.d.ts +2 -0
  111. package/dist/resources/jsonSchemaTypes.js +12 -4
  112. package/dist/resources/jsonSchemaTypes.js.map +1 -1
  113. package/dist/resources/openApi.js +69 -13
  114. package/dist/resources/openApi.js.map +1 -1
  115. package/dist/resources/search.js +6 -8
  116. package/dist/resources/search.js.map +1 -1
  117. package/dist/server/graphqlQuerying.js +4 -2
  118. package/dist/server/graphqlQuerying.js.map +1 -1
  119. package/dist/server/http.d.ts +12 -0
  120. package/dist/server/http.js +35 -15
  121. package/dist/server/http.js.map +1 -1
  122. package/dist/server/serverHelpers/serverUtilities.js +8 -5
  123. package/dist/server/serverHelpers/serverUtilities.js.map +1 -1
  124. package/dist/server/serverHelpers/uwsServer.js +23 -0
  125. package/dist/server/serverHelpers/uwsServer.js.map +1 -1
  126. package/dist/utility/errors/hdbError.d.ts +21 -0
  127. package/dist/utility/errors/hdbError.js +23 -1
  128. package/dist/utility/errors/hdbError.js.map +1 -1
  129. package/dist/validation/configValidator.js +22 -6
  130. package/dist/validation/configValidator.js.map +1 -1
  131. package/index.ts +33 -0
  132. package/npm-shrinkwrap.json +9197 -15236
  133. package/package.json +5 -3
  134. package/resources/DESIGN.md +42 -15
  135. package/resources/Resource.ts +99 -2
  136. package/resources/Table.ts +275 -71
  137. package/resources/analytics/read.ts +30 -25
  138. package/resources/defineResource.ts +651 -0
  139. package/resources/defineTable.ts +407 -0
  140. package/resources/jsonSchemaTypes.ts +12 -4
  141. package/resources/openApi.ts +68 -16
  142. package/resources/search.ts +5 -8
  143. package/server/graphqlQuerying.ts +4 -2
  144. package/server/http.ts +40 -16
  145. package/server/serverHelpers/serverUtilities.ts +19 -6
  146. package/server/serverHelpers/uwsServer.ts +24 -0
  147. package/studio/web/assets/{Chat-D4FIaBu7.js → Chat-CTjtL8Z4.js} +2 -2
  148. package/studio/web/assets/{Chat-D4FIaBu7.js.map → Chat-CTjtL8Z4.js.map} +1 -1
  149. package/studio/web/assets/{FloatingChat-DGUC3L4r.js → FloatingChat-CafHR4Ur.js} +4 -4
  150. package/studio/web/assets/{FloatingChat-DGUC3L4r.js.map → FloatingChat-CafHR4Ur.js.map} +1 -1
  151. package/studio/web/assets/{applications-D8Am9ikM.js → applications-Buh_q0Vj.js} +2 -2
  152. package/studio/web/assets/{applications-D8Am9ikM.js.map → applications-Buh_q0Vj.js.map} +1 -1
  153. package/studio/web/assets/{index-HGL4WHdb.js → index-0hXeECkS.js} +6 -6
  154. package/studio/web/assets/{index-HGL4WHdb.js.map → index-0hXeECkS.js.map} +1 -1
  155. package/studio/web/assets/{index.lazy-Dk5j1AoQ.js → index.lazy-B00B7VBT.js} +4 -4
  156. package/studio/web/assets/{index.lazy-Dk5j1AoQ.js.map → index.lazy-B00B7VBT.js.map} +1 -1
  157. package/studio/web/assets/{profile-7bu_CF1f.js → profile-Cg2wwYPn.js} +2 -2
  158. package/studio/web/assets/{profile-7bu_CF1f.js.map → profile-Cg2wwYPn.js.map} +1 -1
  159. package/studio/web/assets/{setComponentFile-MfYm9F94.js → setComponentFile-DCaDIvyB.js} +2 -2
  160. package/studio/web/assets/{setComponentFile-MfYm9F94.js.map → setComponentFile-DCaDIvyB.js.map} +1 -1
  161. package/studio/web/assets/{setup-SKA4UhdE.js → setup-CAVcAQjK.js} +2 -2
  162. package/studio/web/assets/{setup-SKA4UhdE.js.map → setup-CAVcAQjK.js.map} +1 -1
  163. package/studio/web/assets/{status-DetVLUxR.js → status-BRXorNdD.js} +2 -2
  164. package/studio/web/assets/{status-DetVLUxR.js.map → status-BRXorNdD.js.map} +1 -1
  165. package/studio/web/assets/{swagger-ui-react-DLeYARY2.js → swagger-ui-react-Dy1D62vO.js} +2 -2
  166. package/studio/web/assets/{swagger-ui-react-DLeYARY2.js.map → swagger-ui-react-Dy1D62vO.js.map} +1 -1
  167. package/studio/web/assets/{tsMode-DGO-jIF7.js → tsMode-A8gbL74v.js} +2 -2
  168. package/studio/web/assets/{tsMode-DGO-jIF7.js.map → tsMode-A8gbL74v.js.map} +1 -1
  169. package/studio/web/assets/{useEntityRestURL-4M2i6bo4.js → useEntityRestURL-cDodrVcQ.js} +2 -2
  170. package/studio/web/assets/{useEntityRestURL-4M2i6bo4.js.map → useEntityRestURL-cDodrVcQ.js.map} +1 -1
  171. package/studio/web/index.html +1 -1
  172. package/utility/errors/hdbError.ts +32 -0
  173. package/validation/configValidator.ts +23 -6
@@ -1,4 +1,6 @@
1
1
  import { type Logger } from '../utility/logging/logger.ts';
2
+ import type { CredentialReference, ResolvedCredential, ResolvedRegistryCredential } from './secretOperations.ts';
3
+ import { type ResolvedGitCredential } from './gitCredentialServer.ts';
2
4
  import { Readable } from 'node:stream';
3
5
  interface ApplicationConfig {
4
6
  package: string;
@@ -7,11 +9,7 @@ interface ApplicationConfig {
7
9
  timeout?: number;
8
10
  allowInstallScripts?: boolean;
9
11
  };
10
- registryAuth?: {
11
- registry: string;
12
- secret: string;
13
- scope?: string;
14
- }[];
12
+ credentials?: CredentialReference[];
15
13
  [key: string]: unknown;
16
14
  }
17
15
  export declare class InvalidPackageIdentifierError extends TypeError {
@@ -26,10 +24,10 @@ export declare class InvalidInstallCommandError extends TypeError {
26
24
  export declare class InvalidInstallTimeoutError extends TypeError {
27
25
  constructor(applicationName: string, timeout: unknown);
28
26
  }
29
- export declare class InvalidRegistryAuthPropertyError extends TypeError {
30
- constructor(applicationName: string, registryAuth: unknown);
27
+ export declare class InvalidCredentialsPropertyError extends TypeError {
28
+ constructor(applicationName: string, credentials: unknown);
31
29
  }
32
- export declare class InvalidRegistryAuthEntryError extends TypeError {
30
+ export declare class InvalidCredentialEntryError extends TypeError {
33
31
  constructor(applicationName: string);
34
32
  }
35
33
  export declare function assertApplicationConfig(applicationName: string, applicationConfig: Record<'package', unknown> & Record<string, unknown>): asserts applicationConfig is ApplicationConfig;
@@ -40,7 +38,20 @@ export declare function assertApplicationConfig(applicationName: string, applica
40
38
  * an unverified host key.
41
39
  */
42
40
  export declare function isSSHAuthFailure(stderr: string): boolean;
41
+ interface GitReference {
42
+ cloneUrl: string;
43
+ committish?: string;
44
+ }
45
+ /**
46
+ * Parses a `git+ssh://…`/`git+https://…`/`git+http://…`/`git+file://…`/`git://…`, or hosted-git
47
+ * shorthand (`github:owner/repo`, `gitlab:owner/repo`, `bitbucket:owner/repo`, `gist:id`) package
48
+ * identifier into a plain clone URL and optional committish, without depending on npm's own git-spec
49
+ * parser (npm-package-arg/hosted-git-info aren't dependencies of this repo). Returns null for any
50
+ * other form.
51
+ */
52
+ export declare function parseGitReference(packageIdentifier: string): GitReference | null;
43
53
  export declare const ASIDE_STAGING_DIR = ".deploy-aside";
54
+ export declare const GIT_CREDENTIAL_HELPER_PATH: string;
44
55
  /**
45
56
  * Extract an application given payload (content of the application) or package (npm-compatible identifier to the application).
46
57
  *
@@ -80,7 +91,7 @@ interface ApplicationOptions {
80
91
  allowInstallScripts?: boolean;
81
92
  };
82
93
  onInstallLine?: OnInstallLine;
83
- registryAuth?: RegistryAuthEntry[];
94
+ credentials?: ResolvedCredential[];
84
95
  }
85
96
  export declare class Application {
86
97
  #private;
@@ -96,10 +107,14 @@ export declare class Application {
96
107
  dirPath: string;
97
108
  logger: Logger;
98
109
  packageManagerPrefix: string;
99
- registryAuth?: RegistryAuthEntry[];
110
+ registryCredentials?: ResolvedRegistryCredential[];
111
+ gitCredentials?: ResolvedGitCredential[];
100
112
  npmUserconfigPath?: string;
101
- constructor({ name, payload, packageIdentifier, install, onInstallLine, registryAuth }: ApplicationOptions);
113
+ constructor({ name, payload, packageIdentifier, install, onInstallLine, credentials }: ApplicationOptions);
102
114
  writeTransientNpmrc(): Promise<void>;
115
+ get gitCredentialEnv(): Record<string, string> | undefined;
116
+ startGitCredentialSession(): Promise<void>;
117
+ cleanupGitCredentialSession(): Promise<void>;
103
118
  cleanupTransientNpmrc(): Promise<void>;
104
119
  }
105
120
  /**
@@ -131,13 +146,53 @@ export declare function prepareApplication(application: Application): Promise<vo
131
146
  * operations may conflict with each other (such as writing to the same directory).
132
147
  */
133
148
  export declare function installApplications(): Promise<void>;
134
- export interface RegistryAuthEntry {
135
- registry: string;
136
- token: string;
137
- scope?: string;
138
- }
139
- export declare function buildNpmrcContent(registryAuth: RegistryAuthEntry[]): string;
140
- export declare function nonInteractiveSpawn(applicationName: string, command: string, args: string[], cwd: string, timeoutMs?: number, onLine?: (stream: 'stdout' | 'stderr', line: string) => void, npmUserconfigPath?: string): Promise<{
149
+ /**
150
+ * Rewrite every occurrence of `sshDir` in an ssh `config` file's contents to `tempDir`, matching
151
+ * either slash direction per path segment (and case-insensitively on `win32`) rather than relying
152
+ * on the two strings being byte-identical.
153
+ *
154
+ * A plain string substitution (`sshConfig.split(sshDir).join(tempDir)`) doesn't hold
155
+ * cross-platform: ssh config files are frequently forward-slash even on Windows, while `sshDir`
156
+ * (built via `path.join`) is backslash there, so the split would silently never match; Windows
157
+ * paths are also case-insensitive. `sshDir` is split into segments on either separator *before*
158
+ * escaping, so escaping a regex-special character within a segment (e.g. a literal paren in a
159
+ * directory name) can't interact with the separator substitution. A trailing lookahead keeps
160
+ * `sshDir` from partial-matching a sibling directory whose name happens to start with it (e.g.
161
+ * `.../ssh` vs `.../sshhh`).
162
+ *
163
+ * Exported only so unit tests can pin the Windows-path behavior (mixed slash direction, case
164
+ * insensitivity) directly via the `platform` override, without needing to run on Windows.
165
+ */
166
+ export declare function rewriteSshConfigPaths(sshConfig: string, sshDir: string, tempDir: string, platform?: string): string;
167
+ /**
168
+ * Materialize the SSH deploy keys for the lifetime of a single git-over-SSH spawn.
169
+ *
170
+ * Keys are sealed at rest as `enc:v1:` envelopes (Harper Pro's `add_ssh_key`), but ssh needs a key
171
+ * *file*, so each key is decrypted into a fresh 0700 temp dir as a 0600 file and the ssh config is
172
+ * copied with its `IdentityFile` paths repointed at the transient copies. The caller removes the
173
+ * dir as soon as the spawn settles, so the plaintext never outlives the git invocation. Legacy
174
+ * plaintext keys (written before sealing, or on a node with no custody) are copied through
175
+ * unchanged, so this is a no-op for them beyond the temp dir.
176
+ *
177
+ * A key that cannot be decrypted — no custody registered on this node, an envelope sealed under a
178
+ * different cluster key, or a tampered envelope — is logged and skipped rather than failing the
179
+ * spawn: a deploy that doesn't need that key is unaffected, and one that does fails with the usual
180
+ * SSH auth error (see `isSSHAuthFailure`). No log or error message here carries key material or
181
+ * the envelope.
182
+ *
183
+ * @returns The `GIT_SSH_COMMAND` to use plus its cleanup, or undefined when no keys are configured.
184
+ */
185
+ export declare function materializeGitSSH(): Promise<{
186
+ command: string;
187
+ cleanup: () => Promise<void>;
188
+ } | undefined>;
189
+ export declare function buildNpmrcContent(registryCredentials: ResolvedRegistryCredential[]): string;
190
+ /**
191
+ * Run a command with the deploy's SSH key material materialized only for the duration of the
192
+ * spawn. The keys are decrypted to a transient 0700 dir (see `materializeGitSSH`) and removed as
193
+ * soon as the process settles — on success, failure, and timeout alike.
194
+ */
195
+ export declare function nonInteractiveSpawn(applicationName: string, command: string, args: string[], cwd: string, timeoutMs?: number, onLine?: (stream: 'stdout' | 'stderr', line: string) => void, npmUserconfigPath?: string, gitCredentialEnv?: Record<string, string>): Promise<{
141
196
  stdout: string;
142
197
  stderr: string;
143
198
  code: number;