@opencode/browse 0.0.18-dev.193 → 0.0.18-dev.198

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 (45) hide show
  1. package/dist/cli.mjs +62 -117
  2. package/package.json +13 -33
  3. package/dist/Runtime-r9sev1rq.mjs +0 -16
  4. package/dist/THIRD_PARTY_NOTICES.txt +0 -310
  5. package/dist/Undici-xgvbtsb1.mjs +0 -25295
  6. package/dist/cli-ekwkvvmm.mjs +0 -5943
  7. package/dist/coreBundle-mbshhes2.mjs +0 -8
  8. package/dist/helpers-3ycvp75a.mjs +0 -71
  9. package/dist/index-xsb9s479.mjs +0 -13
  10. package/dist/legacy-runtime-v1sdjj5h.mjs +0 -135
  11. package/dist/log-yek648ak.mjs +0 -9
  12. package/dist/main-1qwrze1y.mjs +0 -140
  13. package/dist/main-2p0v71q0.mjs +0 -1752
  14. package/dist/main-3g7fdzbh.mjs +0 -5360
  15. package/dist/main-55a4gpef.mjs +0 -1261
  16. package/dist/main-693wwz19.mjs +0 -4
  17. package/dist/main-91vhk5de.mjs +0 -38
  18. package/dist/main-9t32k44b.mjs +0 -798
  19. package/dist/main-bv9nawja.mjs +0 -5191
  20. package/dist/main-cgnkhs2x.mjs +0 -35
  21. package/dist/main-esdgpebk.mjs +0 -161
  22. package/dist/main-fg5awggs.mjs +0 -5514
  23. package/dist/main-gexpjhk5.mjs +0 -32
  24. package/dist/main-gt2gskrq.mjs +0 -160
  25. package/dist/main-gw77et6v.mjs +0 -342
  26. package/dist/main-j98fzrvv.mjs +0 -68
  27. package/dist/main-kcw411ep.mjs +0 -891
  28. package/dist/main-nnfxg7re.mjs +0 -11403
  29. package/dist/main-pcqtqhgv.mjs +0 -64
  30. package/dist/main-pmfd055v.mjs +0 -63
  31. package/dist/main-pxs5m0kb.mjs +0 -329
  32. package/dist/main-qazf3bhk.mjs +0 -223
  33. package/dist/main-sf7vaxb6.mjs +0 -17
  34. package/dist/main-stf180y1.mjs +0 -229
  35. package/dist/main-tk4axre7.mjs +0 -39
  36. package/dist/main-zedq93ez.mjs +0 -215
  37. package/dist/main-zzggnpf4.mjs +0 -73
  38. package/dist/mcp-xfx04fxe.mjs +0 -9470
  39. package/dist/migrate-4rewxqd7.mjs +0 -354
  40. package/dist/relay-me036e19.mjs +0 -18765
  41. package/dist/remove-stored-secrets-ymhge5va.mjs +0 -6
  42. package/dist/runtime-update-hd2cvy1c.mjs +0 -246
  43. package/dist/setup-0hmbzam5.mjs +0 -1052
  44. package/dist/update-vnkjbc0e.mjs +0 -17
  45. package/dist/version-jn0h3rmc.mjs +0 -8
@@ -1,6 +0,0 @@
1
- import {
2
- removeStoredSecrets2
3
- } from "./main-sf7vaxb6.mjs";
4
- export {
5
- removeStoredSecrets2 as removeStoredSecrets
6
- };
@@ -1,246 +0,0 @@
1
- import"./main-pcqtqhgv.mjs";
2
- import"./main-pmfd055v.mjs";
3
- import"./main-693wwz19.mjs";
4
- import {
5
- runningServiceTarget,
6
- releaseChannel,
7
- checkRelease,
8
- UPDATE_VERSION,
9
- channelOf,
10
- compareVersions,
11
- installedRuntime2,
12
- updateTarget,
13
- installedVersion,
14
- updateState,
15
- effectiveMode,
16
- registryUrl,
17
- fetchPublished,
18
- runInstaller
19
- } from "./main-9t32k44b.mjs";
20
- import"./main-kcw411ep.mjs";
21
- import"./main-91vhk5de.mjs";
22
- import"./main-3g7fdzbh.mjs";
23
- import {
24
- Service,
25
- layerFetch,
26
- restartRelay,
27
- startManagedRelay
28
- } from "./main-55a4gpef.mjs";
29
- import"./main-cgnkhs2x.mjs";
30
- import"./main-zzggnpf4.mjs";
31
- import"./main-zedq93ez.mjs";
32
- import {
33
- cliCommand,
34
- installCommand
35
- } from "./main-1qwrze1y.mjs";
36
- import {
37
- succeed6,
38
- gen,
39
- result,
40
- catch_,
41
- provide3,
42
- runPromise
43
- } from "./main-bv9nawja.mjs";
44
-
45
- // src/update/runtime-update.ts
46
- var log = (line) => process.stdout.write(line + `
47
- `);
48
- async function switchTo(runtime, version, options) {
49
- const installed = installedVersion(runtime);
50
- if (!installed)
51
- return { refused: `${runtime.entry} doesn't report a version` };
52
- if (installed !== version)
53
- return { refused: `${version} isn't installed` };
54
- let from;
55
- const program = gen(function* () {
56
- const relay = yield* Service;
57
- const running = yield* result(relay.version);
58
- if (running._tag === "Failure")
59
- return {};
60
- from = running.success.version;
61
- yield* restartRelay({
62
- relay,
63
- clientKind: "cli",
64
- force: options.force,
65
- otherBuild: true,
66
- start: startManagedRelay(runtime.entry)
67
- });
68
- const now = yield* relay.version;
69
- return now.version === installed ? { from } : { from, refused: `a relay of version ${now.version} started first` };
70
- }).pipe(provide3(layerFetch));
71
- const refusal = (error) => ({
72
- ...from === undefined ? {} : { from },
73
- refused: error.message ?? String(error)
74
- });
75
- return runPromise(program.pipe(catch_((error) => succeed6(refusal(error)))));
76
- }
77
- async function runInstalledUpdate(args, runtime = installedRuntime2()) {
78
- if (!runtime)
79
- return false;
80
- if (runtime.kind === "npx") {
81
- log("This is an npx install; npx resolves the package itself, so there is nothing to update here.");
82
- log(`Install it once with \`${installCommand()}\` to get automatic updates.`);
83
- return true;
84
- }
85
- const channel = channelOf(runtime.version);
86
- if (runtime.kind === "binary") {
87
- const target = runningServiceTarget();
88
- if (!target) {
89
- log("✗ This executable isn't a released browse build, so it has no release channel to follow.");
90
- process.exitCode = 1;
91
- return true;
92
- }
93
- const serviceChannel = releaseChannel(channel);
94
- const answer = await checkRelease({ version: runtime.version, channel: serviceChannel, target }).catch((error) => error);
95
- if (answer instanceof Error) {
96
- log(`✗ Couldn't check for updates: ${answer.message}`);
97
- process.exitCode = 1;
98
- return true;
99
- }
100
- if (answer.status === "missing") {
101
- log(`✗ There is no ${serviceChannel} release of browse yet.`);
102
- process.exitCode = 1;
103
- return true;
104
- }
105
- if (answer.status === "unchanged") {
106
- log(`✓ Up to date: ${runtime.version} is the current ${serviceChannel} release.`);
107
- return true;
108
- }
109
- const decision = answer.decision;
110
- if (decision.action === "reject") {
111
- log(`✗ The ${serviceChannel} release manifest was rejected (${decision.reason}). Try again later.`);
112
- process.exitCode = 1;
113
- return true;
114
- }
115
- if (decision.action === "none") {
116
- updateState(({ failed: _failed, latest: _latest, ...state }) => ({ ...state, checkedAt: Date.now() }));
117
- log(decision.reason === "rollout_deferred" ? `✓ Up to date: ${runtime.version}; the ${serviceChannel} release ${answer.releaseVersion} is still rolling out.` : `✓ Up to date: ${runtime.version} is the current ${serviceChannel} release.`);
118
- return true;
119
- }
120
- updateState(({ failed: _failed, ...state }) => ({ ...state, checkedAt: Date.now(), latest: decision.version, ...answer.etag ? { etag: answer.etag } : {} }));
121
- if (args.includes("--check")) {
122
- log(`Update available: ${decision.version} (you have ${runtime.version}). Run \`${cliCommand("update")}\` to install it.`);
123
- return true;
124
- }
125
- log(`Installing ${decision.version} (you have ${runtime.version})…`);
126
- const installed = await runInstaller({ runtime, channel: serviceChannel }).catch((error) => {
127
- log(`✗ ${error.message}`);
128
- process.exitCode = 1;
129
- return;
130
- });
131
- if (!installed)
132
- return true;
133
- updateState(({ installing: _installing, ...state }) => ({ ...state, lastUpdate: { from: runtime.version, to: installed, at: new Date().toISOString() } }));
134
- const { refused } = await switchTo({ ...runtime, version: installed }, installed, { force: args.includes("--force") });
135
- if (refused) {
136
- const automatic = effectiveMode() === "on";
137
- log(`! Installed ${installed}, but the relay didn't restart (${refused}).`);
138
- log(automatic ? " It keeps running the old version until no agent is using the browser, then restarts." : ` When no agent is using the browser, run \`${cliCommand("update")}\` again.`);
139
- return true;
140
- }
141
- log(`✓ Updated ${runtime.version} → ${installed}.`);
142
- return true;
143
- }
144
- const published = await fetchPublished({ registry: await registryUrl(), channel }).catch((error) => error);
145
- if (published instanceof Error) {
146
- log(`✗ Couldn't check for updates: ${published.message}`);
147
- process.exitCode = 1;
148
- return true;
149
- }
150
- updateState(({ failed: _failed, ...state }) => ({ ...state, checkedAt: Date.now(), latest: published.version }));
151
- if (compareVersions(published.version, runtime.version) <= 0) {
152
- log(`✓ Up to date: ${runtime.version} is the newest on the ${channel} channel.`);
153
- return true;
154
- }
155
- if (args.includes("--check")) {
156
- log(`Update available: ${published.version} (you have ${runtime.version}). Run \`${cliCommand("update")}\` to install it.`);
157
- return true;
158
- }
159
- log(`Installing ${published.version} (you have ${runtime.version})…`);
160
- const installed = await runInstaller({ runtime, version: published.version, channel }).catch((error) => {
161
- log(`✗ ${error.message}`);
162
- process.exitCode = 1;
163
- return;
164
- });
165
- if (!installed)
166
- return true;
167
- updateState(({ installing: _installing, ...state }) => ({ ...state, lastUpdate: { from: runtime.version, to: installed, at: new Date().toISOString() } }));
168
- const target = await updateTarget(runtime);
169
- const { refused } = target ? await switchTo({ ...target, version: installed }, installed, { force: args.includes("--force") }) : { refused: "npm's global folder is unknown (`npm root -g` failed)" };
170
- if (refused) {
171
- const automatic = effectiveMode() === "on";
172
- log(`! Installed ${installed}, but the relay didn't restart (${refused}).`);
173
- log(automatic ? " It keeps running the old version until no agent is using the browser, then restarts." : ` When no agent is using the browser, run \`${cliCommand("update")}\` again.`);
174
- return true;
175
- }
176
- log(`✓ Updated ${runtime.version} → ${installed}.`);
177
- return true;
178
- }
179
- async function runSelfUpdate(args, runtime = installedRuntime2()) {
180
- const version = args[0];
181
- const channelAt = args.indexOf("--channel");
182
- const channel = channelAt === -1 ? channelOf(version ?? "") : args[channelAt + 1];
183
- if (!runtime) {
184
- log("self-update: not an installed runtime");
185
- process.exitCode = 2;
186
- return;
187
- }
188
- if (!version || !UPDATE_VERSION.test(version)) {
189
- log(`self-update: invalid version ${JSON.stringify(version)}`);
190
- process.exitCode = 2;
191
- return;
192
- }
193
- const fromAt = args.indexOf("--from");
194
- const passedFrom = fromAt === -1 ? undefined : args[fromAt + 1];
195
- const fromVersion = passedFrom !== undefined && UPDATE_VERSION.test(passedFrom) ? passedFrom : runtime.version;
196
- try {
197
- const installChannel = releaseChannel(channel ?? channelOf(version));
198
- const installed = await runInstaller({
199
- runtime,
200
- ...runtime.kind === "binary" ? { channel: installChannel } : { version, ...channel ? { channel } : {} }
201
- });
202
- log(`${new Date().toISOString()} installed ${installed}`);
203
- updateState(({ installing, lastError: _lastError, ...state }) => {
204
- const still = installing?.pid === process.pid ? undefined : installing;
205
- return {
206
- ...state,
207
- ...still ? { installing: still } : {},
208
- ...installed !== fromVersion ? { lastUpdate: { from: fromVersion, to: installed, at: new Date().toISOString() } } : {}
209
- };
210
- });
211
- } catch (error) {
212
- updateState(({ installing, ...state }) => {
213
- const still = installing?.pid === process.pid ? undefined : installing;
214
- return {
215
- ...state,
216
- ...still ? { installing: still } : {},
217
- lastError: { message: error.message, at: new Date().toISOString(), version, attempts: 1 + (state.lastError?.version === version ? state.lastError.attempts ?? 1 : 0) }
218
- };
219
- });
220
- log(`${new Date().toISOString()} install of ${version} failed: ${error.message}`);
221
- process.exitCode = 1;
222
- }
223
- }
224
- async function runRuntimeSwitch(args) {
225
- const runtime = installedRuntime2();
226
- if (!runtime) {
227
- log("runtime-switch: not an installed runtime");
228
- process.exitCode = 2;
229
- return;
230
- }
231
- const version = args[0] ?? installedVersion(runtime);
232
- if (!version) {
233
- process.exitCode = 2;
234
- return;
235
- }
236
- const { from, refused } = await switchTo({ ...runtime, version }, version, { force: false });
237
- const before = from ?? runtime.version;
238
- log(`${new Date().toISOString()} switch ${before} → ${version}: ${refused ? `refused (${refused})` : "done"}`);
239
- if (refused)
240
- process.exitCode = 1;
241
- }
242
- export {
243
- runInstalledUpdate,
244
- runRuntimeSwitch,
245
- runSelfUpdate
246
- };