@opencode/browse 0.0.11-dev.76 → 0.0.11-dev.78

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 (33) hide show
  1. package/dist/{cli-qpkh40gh.mjs → cli-e9x2hzbm.mjs} +63 -52
  2. package/dist/cli.mjs +30 -19
  3. package/dist/{helpers-kp0j46jt.mjs → helpers-681ybn8r.mjs} +2 -2
  4. package/dist/{index-0dcypq31.mjs → index-yzz55kxm.mjs} +1 -1
  5. package/dist/{main-eej5z0y5.mjs → main-0yxzwqt8.mjs} +6 -6
  6. package/dist/main-1ja7rnnp.mjs +4 -0
  7. package/dist/main-3d4mj1xj.mjs +157 -0
  8. package/dist/main-4qeb707s.mjs +161 -0
  9. package/dist/{main-rt6g5418.mjs → main-8z9d979q.mjs} +15 -15
  10. package/dist/{main-nqmm7pdz.mjs → main-93xmqcr3.mjs} +47 -47
  11. package/dist/{main-gevbt7h7.mjs → main-csnx585b.mjs} +151 -151
  12. package/dist/{setup-j76yv51b.mjs → main-fkskfb8a.mjs} +3608 -4406
  13. package/dist/main-ftsbt0hk.mjs +73 -0
  14. package/dist/{main-brv9dhy5.mjs → main-gdvgbgce.mjs} +9 -9
  15. package/dist/{main-ajza8egc.mjs → main-mysz5yma.mjs} +44 -39
  16. package/dist/main-qzvstggv.mjs +465 -0
  17. package/dist/main-vgzr4689.mjs +61 -0
  18. package/dist/{mcp-sy8qgkyr.mjs → mcp-3v0wxzr5.mjs} +139 -138
  19. package/dist/migrate-5phz1hha.mjs +233 -0
  20. package/dist/{relay-ateyg5ax.mjs → relay-4chyv51v.mjs} +128 -123
  21. package/dist/runtime-update-pzazb7sh.mjs +156 -0
  22. package/dist/setup-5g5kza58.mjs +956 -0
  23. package/dist/{skill-text-x7sccp6h.mjs → skill-text-mrxy6zpc.mjs} +5 -4
  24. package/dist/{supervisor-0rvjpf4e.mjs → supervisor-bfrn5cxb.mjs} +38 -17
  25. package/dist/{update-rbd2025v.mjs → update-42j1j7w1.mjs} +3 -3
  26. package/dist/{version-4cjr3wpp.mjs → version-w0dwcyve.mjs} +1 -1
  27. package/package.json +1 -1
  28. package/skills/browse/SKILL.md +5 -4
  29. package/dist/main-7wgmq04v.mjs +0 -303
  30. package/dist/main-exnm62gg.mjs +0 -4
  31. package/dist/main-hm4fcpfz.mjs +0 -131
  32. package/dist/main-rn7hdcq2.mjs +0 -805
  33. package/dist/runtime-update-70gqzynp.mjs +0 -200
@@ -1,200 +0,0 @@
1
- import"./main-exnm62gg.mjs";
2
- import {
3
- cliCommand,
4
- installCommand,
5
- runtimeLayout,
6
- versionEntry,
7
- channelOf,
8
- UPDATE_VERSION,
9
- compareVersions,
10
- readCurrent,
11
- writeCurrent,
12
- updateState,
13
- npmRuntime,
14
- effectiveMode,
15
- registryUrl,
16
- InstallVerificationError,
17
- fetchPublished,
18
- installVersion,
19
- pruneVersions,
20
- switchVersion
21
- } from "./main-rn7hdcq2.mjs";
22
- import"./main-mrew6jy8.mjs";
23
- import {
24
- Service,
25
- layerFetch,
26
- restartRelay,
27
- startManagedRelay
28
- } from "./main-ajza8egc.mjs";
29
- import"./main-hm4fcpfz.mjs";
30
- import {
31
- succeed6,
32
- suspend2,
33
- sync2,
34
- void_3,
35
- gen,
36
- andThen,
37
- result,
38
- catch_,
39
- provide3,
40
- runPromise
41
- } from "./main-gevbt7h7.mjs";
42
-
43
- // src/update/runtime-update.ts
44
- import { existsSync } from "node:fs";
45
- var log = (line) => process.stdout.write(line + `
46
- `);
47
- async function switchTo(layout, version, options) {
48
- const entry = versionEntry(layout, version);
49
- if (!existsSync(entry))
50
- return `${version} isn't installed`;
51
- const before = readCurrent(layout);
52
- let switched = false;
53
- const point = sync2(() => {
54
- switchVersion(layout, version, options.previous);
55
- switched = true;
56
- });
57
- const program = gen(function* () {
58
- const relay = yield* Service;
59
- const running = yield* result(relay.version);
60
- if (running._tag === "Failure") {
61
- yield* point;
62
- return;
63
- }
64
- yield* restartRelay({
65
- relay,
66
- clientKind: "cli",
67
- force: options.force,
68
- otherBuild: true,
69
- onShutdownAccepted: point,
70
- start: suspend2(() => switched ? void_3 : point).pipe(andThen(startManagedRelay(entry)))
71
- });
72
- const now = yield* relay.version;
73
- return now.version === version ? undefined : `a relay of version ${now.version} started first`;
74
- }).pipe(provide3(layerFetch));
75
- const refused = await runPromise(program.pipe(catch_((error) => succeed6(error.message ?? String(error)))));
76
- if (refused && switched && before)
77
- writeCurrent(layout, before);
78
- return refused;
79
- }
80
- function npmOnly(command) {
81
- const runtime = npmRuntime();
82
- if (runtime)
83
- return runtime;
84
- log(`\`${command}\` is for installs that update themselves (\`${installCommand()}\`); this one isn't.`);
85
- process.exitCode = 1;
86
- return;
87
- }
88
- async function runRollback(args) {
89
- const runtime = npmOnly("rollback");
90
- if (!runtime)
91
- return;
92
- const { layout } = runtime;
93
- const current = readCurrent(layout);
94
- const previous = current.previous;
95
- if (!previous || !existsSync(versionEntry(layout, previous))) {
96
- log(`Nothing to roll back to: ${current.version} has no previous version installed.`);
97
- process.exitCode = 1;
98
- return;
99
- }
100
- const refused = await switchTo(layout, previous, { previous: current.version, force: args.includes("--force") });
101
- if (refused) {
102
- log(`✗ Not rolled back: the relay didn't restart (${refused}).`);
103
- log(` When no agent is using the browser, run \`${cliCommand("rollback")}\` again (or add --force to end what's blocking it).`);
104
- process.exitCode = 1;
105
- return;
106
- }
107
- updateState(layout, ({ pending: _pending, ...state }) => ({ ...state, skipped: current.version, lastUpdate: { from: current.version, to: previous, at: new Date().toISOString() } }));
108
- log(`✓ Rolled back ${current.version} → ${previous}. Auto-update skips ${current.version} until a newer version is published.`);
109
- log(" Running MCP servers switch to it between requests; restart opencode if a tool still reports the old version.");
110
- }
111
- async function runNpmUpdate(args, layout) {
112
- const runtime = npmRuntime(layout ? { layout } : {});
113
- if (!runtime)
114
- return false;
115
- const lay = runtime.layout;
116
- const channel = channelOf(runtime.version);
117
- const published = await fetchPublished({ registry: await registryUrl(), channel }).catch((error) => error);
118
- if (published instanceof Error) {
119
- log(`✗ Couldn't check for updates: ${published.message}`);
120
- process.exitCode = 1;
121
- return true;
122
- }
123
- updateState(lay, ({ failed: _failed, ...state }) => ({ ...state, checkedAt: Date.now(), latest: published.version, integrity: published.integrity }));
124
- if (compareVersions(published.version, runtime.version) <= 0) {
125
- log(`✓ Up to date: ${runtime.version} is the newest on the ${channel} channel.`);
126
- return true;
127
- }
128
- if (args.includes("--check")) {
129
- log(`Update available: ${published.version} (you have ${runtime.version}). Run \`${cliCommand("update")}\` to install it.`);
130
- return true;
131
- }
132
- log(`Installing ${published.version} (you have ${runtime.version})…`);
133
- const entry = await installVersion({ layout: lay, version: published.version, integrity: published.integrity, ...process.env.OPENCODE_BROWSER_NPM_REGISTRY ? { registry: await registryUrl() } : {} }).catch((error) => {
134
- log(`✗ ${error.message}`);
135
- process.exitCode = 1;
136
- return;
137
- });
138
- if (!entry)
139
- return true;
140
- updateState(lay, ({ skipped: _skipped, ...state }) => ({ ...state, pending: published.version }));
141
- const current = readCurrent(lay);
142
- const refused = await switchTo(lay, published.version, { previous: current.version, force: args.includes("--force") });
143
- if (refused) {
144
- const automatic = effectiveMode(lay) === "on";
145
- log(`! Installed ${published.version}, but the relay didn't restart (${refused}).`);
146
- log(automatic ? " It switches to the new version by itself once no agent is using the browser." : ` When no agent is using the browser, run \`${cliCommand("update")}\` again.`);
147
- return true;
148
- }
149
- updateState(lay, ({ pending: _pending, ...state }) => ({ ...state, lastUpdate: { from: current.version, to: published.version, at: new Date().toISOString() } }));
150
- pruneVersions(lay);
151
- log(`✓ Updated ${current.version} → ${published.version}.`);
152
- return true;
153
- }
154
- async function runRuntimeInstall(args) {
155
- const layout = runtimeLayout();
156
- const version = args[0];
157
- const integrityAt = args.indexOf("--integrity");
158
- const integrity = integrityAt === -1 ? undefined : args[integrityAt + 1];
159
- if (!version || !UPDATE_VERSION.test(version)) {
160
- log(`runtime-install: invalid version ${JSON.stringify(version)}`);
161
- process.exitCode = 2;
162
- return;
163
- }
164
- const clear = (installing) => installing?.pid === process.pid ? undefined : installing;
165
- try {
166
- await installVersion({ layout, version, ...integrity ? { integrity } : {}, ...process.env.OPENCODE_BROWSER_NPM_REGISTRY ? { registry: await registryUrl() } : {} });
167
- updateState(layout, ({ installing, lastError: _error, ...state }) => {
168
- const still = clear(installing);
169
- return { ...state, ...still ? { installing: still } : {}, pending: version };
170
- });
171
- log(`${new Date().toISOString()} installed ${version}`);
172
- } catch (error) {
173
- updateState(layout, ({ installing, ...state }) => {
174
- const still = clear(installing);
175
- const attempts = 1 + (state.lastError?.version === version ? state.lastError.attempts ?? 1 : 0);
176
- return { ...state, ...still ? { installing: still } : {}, lastError: { message: error.message, at: new Date().toISOString(), version, attempts, verification: error instanceof InstallVerificationError } };
177
- });
178
- log(`${new Date().toISOString()} install of ${version} failed: ${error.message}`);
179
- process.exitCode = 1;
180
- }
181
- }
182
- async function runRuntimeSwitch(args) {
183
- const layout = runtimeLayout();
184
- const version = args[0];
185
- const current = readCurrent(layout);
186
- if (!version || !current) {
187
- process.exitCode = 2;
188
- return;
189
- }
190
- const refused = await switchTo(layout, version, { previous: current.version, force: false });
191
- log(`${new Date().toISOString()} switch ${current.version} → ${version}: ${refused ? `refused (${refused})` : "done"}`);
192
- if (refused)
193
- process.exitCode = 1;
194
- }
195
- export {
196
- runNpmUpdate,
197
- runRollback,
198
- runRuntimeInstall,
199
- runRuntimeSwitch
200
- };