zcode-acp-server 0.46.7 → 0.47.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 (55) hide show
  1. package/README.md +1 -1
  2. package/dist/code-fingerprint.json +2 -2
  3. package/dist/remote/endpoint.d.ts.map +1 -1
  4. package/dist/remote/endpoint.js +6 -0
  5. package/dist/remote/endpoint.js.map +1 -1
  6. package/dist/remote/hub-server.d.ts.map +1 -1
  7. package/dist/remote/hub-server.js +102 -0
  8. package/dist/remote/hub-server.js.map +1 -1
  9. package/dist/remote/settings-endpoint.d.ts +45 -0
  10. package/dist/remote/settings-endpoint.d.ts.map +1 -0
  11. package/dist/remote/settings-endpoint.js +920 -0
  12. package/dist/remote/settings-endpoint.js.map +1 -0
  13. package/dist/settings/agents-config.d.ts +158 -0
  14. package/dist/settings/agents-config.d.ts.map +1 -0
  15. package/dist/settings/agents-config.js +598 -0
  16. package/dist/settings/agents-config.js.map +1 -0
  17. package/dist/settings/app-update.d.ts +193 -0
  18. package/dist/settings/app-update.d.ts.map +1 -0
  19. package/dist/settings/app-update.js +659 -0
  20. package/dist/settings/app-update.js.map +1 -0
  21. package/dist/settings/atomic-write.d.ts +106 -0
  22. package/dist/settings/atomic-write.d.ts.map +1 -0
  23. package/dist/settings/atomic-write.js +228 -0
  24. package/dist/settings/atomic-write.js.map +1 -0
  25. package/dist/settings/cli-config.d.ts +145 -0
  26. package/dist/settings/cli-config.d.ts.map +1 -0
  27. package/dist/settings/cli-config.js +320 -0
  28. package/dist/settings/cli-config.js.map +1 -0
  29. package/dist/settings/coding-plan.d.ts +106 -0
  30. package/dist/settings/coding-plan.d.ts.map +1 -0
  31. package/dist/settings/coding-plan.js +299 -0
  32. package/dist/settings/coding-plan.js.map +1 -0
  33. package/dist/settings/file-lock.d.ts +39 -0
  34. package/dist/settings/file-lock.d.ts.map +1 -0
  35. package/dist/settings/file-lock.js +282 -0
  36. package/dist/settings/file-lock.js.map +1 -0
  37. package/dist/settings/provider-config.d.ts +123 -0
  38. package/dist/settings/provider-config.d.ts.map +1 -0
  39. package/dist/settings/provider-config.js +311 -0
  40. package/dist/settings/provider-config.js.map +1 -0
  41. package/dist/settings/skills.d.ts +72 -0
  42. package/dist/settings/skills.d.ts.map +1 -0
  43. package/dist/settings/skills.js +245 -0
  44. package/dist/settings/skills.js.map +1 -0
  45. package/dist/settings/usage-stats.d.ts +74 -0
  46. package/dist/settings/usage-stats.d.ts.map +1 -0
  47. package/dist/settings/usage-stats.js +235 -0
  48. package/dist/settings/usage-stats.js.map +1 -0
  49. package/dist/utils.d.ts +14 -0
  50. package/dist/utils.d.ts.map +1 -1
  51. package/dist/utils.js +22 -0
  52. package/dist/utils.js.map +1 -1
  53. package/docs/ARCHITECTURE.md +65 -0
  54. package/docs/REMOTE-CLIENTS.md +252 -0
  55. package/package.json +1 -1
@@ -0,0 +1,193 @@
1
+ /**
2
+ * ZCode desktop app self-update.
3
+ *
4
+ * The desktop app updates itself through Electron's autoUpdater, which needs an
5
+ * Electron runtime this process does not have. The parts that DO work headless
6
+ * are the ones that decide WHAT to install: the release manifest
7
+ * (`/api/v1/releases/electron/manifest`), the platform/arch/channel spelling,
8
+ * and the CDN download. So this module reproduces those and hands the actual
9
+ * install back to the OS.
10
+ *
11
+ * Whether the bundle can be swapped is PROBED, never assumed (see
12
+ * `canWriteInstallLocation`): the obvious reading of `/Applications`'s
13
+ * `drwxrwxr-x root:admin` is that an admin user cannot write it, yet the
14
+ * installed `ZCode.app` is user-owned on the machine this was written for — so
15
+ * the code branches on `accessSync` and is correct either way, and no claim is
16
+ * made about which branch a given install takes. What is deliberately NOT done
17
+ * is privileged escalation (a password prompt, a Finder Apple Event, a shipped
18
+ * privileged helper): a long-lived daemon has no good place to ask, and the
19
+ * one-shot confirmation macOS raises when a user drags a bundle into place is
20
+ * already the right amount of trust.
21
+ *
22
+ * What the flow does NOT do is silently swap a running app. The app is replaced
23
+ * on disk while it may be running, and the user is told to quit and reopen —
24
+ * attempting to kill the app from here would be both rude and unsafe (it may
25
+ * have an in-flight session whose state lives in the app process).
26
+ */
27
+ import { rename } from "node:fs/promises";
28
+ /** Channel → the API's numeric spelling (manifestUpdateProvider.ts:41-42). */
29
+ declare const CHANNEL_VALUES: {
30
+ readonly stable: 1;
31
+ readonly preview: 3;
32
+ };
33
+ export type ReleaseChannel = keyof typeof CHANNEL_VALUES;
34
+ /** Node platform → the manifest's spelling (manifestUpdateProvider.ts:57-68). */
35
+ export declare function releasePlatform(platform: NodeJS.Platform, arch: string): string;
36
+ /** One downloadable artifact the manifest offers. */
37
+ export interface ReleaseFile {
38
+ url: string;
39
+ sha512?: string;
40
+ size?: number;
41
+ }
42
+ export interface ReleaseManifest {
43
+ version: string;
44
+ releaseName?: string;
45
+ releaseNotes?: string;
46
+ releaseNotesByLocale?: Record<string, {
47
+ title?: string;
48
+ markdown?: string;
49
+ }>;
50
+ files: ReleaseFile[];
51
+ /** The single-artifact fallback electron-updater uses when no arch matches. */
52
+ path?: string;
53
+ }
54
+ export interface UpdateCheck {
55
+ /** True when the manifest offers a strictly newer version. */
56
+ updateAvailable: boolean;
57
+ currentVersion: string | null;
58
+ latestVersion: string | null;
59
+ channel: ReleaseChannel;
60
+ platform: string;
61
+ /** Populated only when an update is available. */
62
+ release?: ReleaseManifest;
63
+ }
64
+ /**
65
+ * Where the app is installed, or null when it is not found.
66
+ *
67
+ * `ZCODE_APP_PATH` overrides the whole lookup so a test (or a non-standard
68
+ * install) can point somewhere safe. The candidate list mirrors the table in
69
+ * `backend/resolve.ts`: /Applications first, then the per-user location, then
70
+ * the Linux prefixes.
71
+ */
72
+ export declare function appBundlePath(env?: NodeJS.ProcessEnv): string | null;
73
+ /**
74
+ * The installed app's version, read from its bundle.
75
+ *
76
+ * macOS: `CFBundleShortVersionString` out of `Info.plist`, parsed without a
77
+ * plist library (the file is XML for these builds; a binary plist falls back to
78
+ * `defaults read`, which handles both). Windows: the file version of the .exe.
79
+ * Linux: null — there is no reliable in-bundle version.
80
+ */
81
+ export declare function installedAppVersion(appPath: string, env?: NodeJS.ProcessEnv, platform?: NodeJS.Platform): Promise<string | null>;
82
+ /**
83
+ * Compare two version strings numerically, segment by segment.
84
+ *
85
+ * Local on purpose: `utils.compareVersions` is fine for semver-ish strings but
86
+ * the manifest can carry a build suffix (`3.14.1.7714`), and comparing
87
+ * `7714` against a missing segment must not flip the result.
88
+ */
89
+ export declare function isNewerVersion(candidate: string, current: string): boolean;
90
+ /**
91
+ * Parse the manifest YAML.
92
+ *
93
+ * The manifest is a small, fixed-shape document (version + files + release
94
+ * notes), so a real YAML parser would be a dependency for no benefit. This
95
+ * reader handles exactly the shapes the endpoint emits: a flat top level, a
96
+ * `files:` list of mappings, and the `releaseNotesByLocale` nesting. Block
97
+ * scalars (`|-`) are collected by indentation.
98
+ *
99
+ * Anything it does not understand throws rather than guessing — a misparsed
100
+ * manifest would install the wrong build.
101
+ */
102
+ export declare function parseManifest(raw: string): ReleaseManifest;
103
+ /**
104
+ * Pick the artifact to download for this platform.
105
+ *
106
+ * macOS prefers the zip (it extracts to a bundle directly and needs no mount);
107
+ * Windows takes the exe; Linux takes the distro package. Falls back to the
108
+ * manifest's top-level `path`, which is what electron-updater itself uses when
109
+ * no per-arch entry matches.
110
+ */
111
+ export declare function pickReleaseFile(manifest: ReleaseManifest): ReleaseFile | null;
112
+ /**
113
+ * Fetch and parse the release manifest.
114
+ *
115
+ * `fetchImpl` defaults to the module seam (not bare `fetch`) so a test that
116
+ * overrides the network also covers this path, not just `checkForAppUpdate`.
117
+ */
118
+ export declare function fetchReleaseManifest(channel: ReleaseChannel, env?: NodeJS.ProcessEnv, fetchImpl?: typeof fetch): Promise<ReleaseManifest>;
119
+ /** Override the update network. Pass `fetch` to restore the default. */
120
+ export declare function setManifestNetworkForTest(impl: typeof fetch): void;
121
+ /** Override the platform the update flows run as (test seam). */
122
+ export declare function setAppUpdatePlatformForTest(platform: NodeJS.Platform): void;
123
+ /**
124
+ * Compare the installed app against the manifest.
125
+ *
126
+ * A missing install (the bridge running on a machine without the app) is not an
127
+ * error: `updateAvailable` stays false and `currentVersion` is null, so the
128
+ * client can hide the row instead of showing a failure.
129
+ */
130
+ export declare function checkForAppUpdate(options?: {
131
+ channel?: ReleaseChannel;
132
+ env?: NodeJS.ProcessEnv;
133
+ platform?: NodeJS.Platform;
134
+ }): Promise<UpdateCheck>;
135
+ export interface DownloadProgress {
136
+ receivedBytes: number;
137
+ totalBytes: number | null;
138
+ }
139
+ export interface DownloadResult {
140
+ file: string;
141
+ sha512: string;
142
+ sizeBytes: number;
143
+ /** True when the hash matched the manifest's `sha512`. */
144
+ verified: boolean;
145
+ }
146
+ /**
147
+ * Download an artifact into a temp directory, streaming and hashing as it goes.
148
+ *
149
+ * The hash is verified before anything is installed: a truncated or tampered
150
+ * download that failed here is a failed download, not a bad install.
151
+ *
152
+ * The body is consumed as a web `ReadableStream` (what `fetch` returns), not a
153
+ * Node stream — `pipe` does not exist on it.
154
+ */
155
+ export declare function downloadRelease(file: ReleaseFile, options?: {
156
+ destDir?: string;
157
+ fetchImpl?: typeof fetch;
158
+ onProgress?: (p: DownloadProgress) => void;
159
+ }): Promise<DownloadResult>;
160
+ export type InstallStage = "idle" | "downloading" | "installing" | "done" | "needs-user-install" | "failed";
161
+ export interface InstallState {
162
+ stage: InstallStage;
163
+ version: string | null;
164
+ receivedBytes: number;
165
+ totalBytes: number | null;
166
+ /**
167
+ * Where the verified bundle is, for `needs-user-install`. The client shows
168
+ * this path (or reveals it in Finder) so the user can finish the install
169
+ * themselves.
170
+ */
171
+ artifactPath?: string;
172
+ /** True on `done`: the new build is on disk and the app must be reopened. */
173
+ restartRequired?: boolean;
174
+ error?: string;
175
+ }
176
+ /** Current install state — the endpoint reports it verbatim. */
177
+ export declare function appUpdateState(): InstallState;
178
+ /** Override the unzip used by the installer (test seam). */
179
+ export declare function setExtractForTest(impl: (zipPath: string, destDir: string) => Promise<void>): void;
180
+ /** Restore the platform's own unzip (test seam). */
181
+ export declare function resetExtractForTest(): void;
182
+ /** Override the rename used by the installer (test seam). */
183
+ export declare function setInstallRenameForTest(impl: typeof rename): void;
184
+ export declare function startAppUpdate(file: ReleaseFile, version: string, options?: {
185
+ channel?: ReleaseChannel;
186
+ env?: NodeJS.ProcessEnv;
187
+ platform?: NodeJS.Platform;
188
+ fetchImpl?: typeof fetch;
189
+ }): Promise<InstallState>;
190
+ /** Clear the stored install state (test seam). */
191
+ export declare function resetAppUpdateStateForTest(): void;
192
+ export {};
193
+ //# sourceMappingURL=app-update.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"app-update.d.ts","sourceRoot":"","sources":["../../src/settings/app-update.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAKH,OAAO,EAAyB,MAAM,EAAY,MAAM,kBAAkB,CAAC;AAqB3E,8EAA8E;AAC9E,QAAA,MAAM,cAAc;;;CAAqC,CAAC;AAC1D,MAAM,MAAM,cAAc,GAAG,MAAM,OAAO,cAAc,CAAC;AAEzD,iFAAiF;AACjF,wBAAgB,eAAe,CAAC,QAAQ,EAAE,MAAM,CAAC,QAAQ,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAK/E;AAED,qDAAqD;AACrD,MAAM,WAAW,WAAW;IAC1B,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,oBAAoB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE;QAAE,KAAK,CAAC,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAC7E,KAAK,EAAE,WAAW,EAAE,CAAC;IACrB,+EAA+E;IAC/E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