@opencode/browse 0.0.11-dev.75 → 0.0.11-dev.77

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-5980z4hc.mjs → cli-mx6tbg2m.mjs} +63 -52
  2. package/dist/cli.mjs +30 -19
  3. package/dist/{helpers-h1mvscyw.mjs → helpers-hgm1z9h5.mjs} +2 -2
  4. package/dist/{index-0dcypq31.mjs → index-yzz55kxm.mjs} +1 -1
  5. package/dist/{main-d1hydckg.mjs → main-1fdejpga.mjs} +9 -9
  6. package/dist/{main-tcae6pr3.mjs → main-6chyyr6j.mjs} +44 -39
  7. package/dist/{main-rt6g5418.mjs → main-8z9d979q.mjs} +15 -15
  8. package/dist/{setup-q1sfzdr9.mjs → main-b7g6460c.mjs} +3608 -4406
  9. package/dist/{main-gevbt7h7.mjs → main-csnx585b.mjs} +151 -151
  10. package/dist/{main-j38051kb.mjs → main-cymarjp4.mjs} +47 -47
  11. package/dist/main-j2ehvkhk.mjs +465 -0
  12. package/dist/main-r3a6053j.mjs +157 -0
  13. package/dist/main-s7017yah.mjs +161 -0
  14. package/dist/main-sjrzyg3x.mjs +73 -0
  15. package/dist/main-vgzr4689.mjs +61 -0
  16. package/dist/{main-5vffh0gd.mjs → main-zq79yb8r.mjs} +6 -6
  17. package/dist/main-zya5ttbr.mjs +4 -0
  18. package/dist/{mcp-x1vq2n6t.mjs → mcp-h0qcxhqc.mjs} +138 -137
  19. package/dist/migrate-pgckfkg5.mjs +233 -0
  20. package/dist/{relay-94r2w21z.mjs → relay-gafgjtav.mjs} +191 -129
  21. package/dist/runtime-update-p2pnfdy1.mjs +156 -0
  22. package/dist/setup-fhhjnx9r.mjs +956 -0
  23. package/dist/{skill-text-x7sccp6h.mjs → skill-text-6p6scqwe.mjs} +2 -2
  24. package/dist/{supervisor-e2w15458.mjs → supervisor-06t66v4t.mjs} +38 -17
  25. package/dist/{update-c8xwkt5v.mjs → update-7hagfdc0.mjs} +3 -3
  26. package/dist/{version-0jtmhnzb.mjs → version-hhcvk9wm.mjs} +1 -1
  27. package/package.json +1 -1
  28. package/skills/browse/SKILL.md +2 -2
  29. package/dist/main-jkq3ey3t.mjs +0 -805
  30. package/dist/main-nhr7bg32.mjs +0 -131
  31. package/dist/main-s5mqta5j.mjs +0 -303
  32. package/dist/main-wpbmhp3v.mjs +0 -4
  33. package/dist/runtime-update-g516gc7h.mjs +0 -200
@@ -0,0 +1,156 @@
1
+ import"./main-zya5ttbr.mjs";
2
+ import {
3
+ cliCommand,
4
+ installCommand,
5
+ UPDATE_VERSION,
6
+ channelOf,
7
+ compareVersions,
8
+ installedRuntime2,
9
+ installedVersion,
10
+ updateState,
11
+ effectiveMode,
12
+ registryUrl,
13
+ fetchPublished,
14
+ runInstaller
15
+ } from "./main-j2ehvkhk.mjs";
16
+ import"./main-mrew6jy8.mjs";
17
+ import {
18
+ Service,
19
+ layerFetch,
20
+ restartRelay,
21
+ startManagedRelay
22
+ } from "./main-6chyyr6j.mjs";
23
+ import"./main-vgzr4689.mjs";
24
+ import {
25
+ succeed6,
26
+ gen,
27
+ result,
28
+ catch_,
29
+ provide3,
30
+ runPromise
31
+ } from "./main-csnx585b.mjs";
32
+ import"./main-sjrzyg3x.mjs";
33
+
34
+ // src/update/runtime-update.ts
35
+ var log = (line) => process.stdout.write(line + `
36
+ `);
37
+ async function switchTo(runtime, version, options) {
38
+ const installed = installedVersion(runtime);
39
+ if (!installed)
40
+ return `${runtime.entry} doesn't report a version`;
41
+ if (compareVersions(installed, version) < 0)
42
+ return `${version} isn't installed`;
43
+ const program = gen(function* () {
44
+ const relay = yield* Service;
45
+ const running = yield* result(relay.version);
46
+ if (running._tag === "Failure")
47
+ return;
48
+ yield* restartRelay({
49
+ relay,
50
+ clientKind: "cli",
51
+ force: options.force,
52
+ otherBuild: true,
53
+ start: startManagedRelay(runtime.entry)
54
+ });
55
+ const now = yield* relay.version;
56
+ return now.version === installed ? undefined : `a relay of version ${now.version} started first`;
57
+ }).pipe(provide3(layerFetch));
58
+ return runPromise(program.pipe(catch_((error) => succeed6(error.message ?? String(error)))));
59
+ }
60
+ async function runInstalledUpdate(args, runtime = installedRuntime2()) {
61
+ if (!runtime)
62
+ return false;
63
+ if (runtime.kind === "npx") {
64
+ log("This is an npx install; npx resolves the package itself, so there is nothing to update here.");
65
+ log(`Install it once with \`${installCommand()}\` to get automatic updates.`);
66
+ return true;
67
+ }
68
+ const channel = channelOf(runtime.version);
69
+ const published = await fetchPublished({ registry: await registryUrl(), channel }).catch((error) => error);
70
+ if (published instanceof Error) {
71
+ log(`✗ Couldn't check for updates: ${published.message}`);
72
+ process.exitCode = 1;
73
+ return true;
74
+ }
75
+ updateState(({ failed: _failed, ...state }) => ({ ...state, checkedAt: Date.now(), latest: published.version }));
76
+ if (compareVersions(published.version, runtime.version) <= 0) {
77
+ log(`✓ Up to date: ${runtime.version} is the newest on the ${channel} channel.`);
78
+ return true;
79
+ }
80
+ if (args.includes("--check")) {
81
+ log(`Update available: ${published.version} (you have ${runtime.version}). Run \`${cliCommand("update")}\` to install it.`);
82
+ return true;
83
+ }
84
+ log(`Installing ${published.version} (you have ${runtime.version})…`);
85
+ const installed = await runInstaller({ runtime, version: published.version, channel }).catch((error) => {
86
+ log(`✗ ${error.message}`);
87
+ process.exitCode = 1;
88
+ return;
89
+ });
90
+ if (!installed)
91
+ return true;
92
+ updateState(({ installing: _installing, ...state }) => ({ ...state, lastUpdate: { from: runtime.version, to: installed, at: new Date().toISOString() } }));
93
+ const refused = await switchTo({ ...runtime, version: installed }, installed, { force: args.includes("--force") });
94
+ if (refused) {
95
+ const automatic = effectiveMode() === "on";
96
+ log(`! Installed ${installed}, but the relay didn't restart (${refused}).`);
97
+ 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.`);
98
+ return true;
99
+ }
100
+ log(`✓ Updated ${runtime.version} → ${installed}.`);
101
+ return true;
102
+ }
103
+ async function runSelfUpdate(args) {
104
+ const runtime = installedRuntime2();
105
+ const version = args[0];
106
+ const channelAt = args.indexOf("--channel");
107
+ const channel = channelAt === -1 ? channelOf(version ?? "") : args[channelAt + 1];
108
+ if (!runtime) {
109
+ log("self-update: not an installed runtime");
110
+ process.exitCode = 2;
111
+ return;
112
+ }
113
+ if (!version || !UPDATE_VERSION.test(version)) {
114
+ log(`self-update: invalid version ${JSON.stringify(version)}`);
115
+ process.exitCode = 2;
116
+ return;
117
+ }
118
+ try {
119
+ const installed = await runInstaller({ runtime, version, ...channel ? { channel } : {} });
120
+ log(`${new Date().toISOString()} installed ${installed}`);
121
+ } catch (error) {
122
+ updateState(({ installing, ...state }) => {
123
+ const still = installing?.pid === process.pid ? undefined : installing;
124
+ return {
125
+ ...state,
126
+ ...still ? { installing: still } : {},
127
+ lastError: { message: error.message, at: new Date().toISOString(), version, attempts: 1 + (state.lastError?.version === version ? state.lastError.attempts ?? 1 : 0) }
128
+ };
129
+ });
130
+ log(`${new Date().toISOString()} install of ${version} failed: ${error.message}`);
131
+ process.exitCode = 1;
132
+ }
133
+ }
134
+ async function runRuntimeSwitch(args) {
135
+ const runtime = installedRuntime2();
136
+ if (!runtime) {
137
+ log("runtime-switch: not an installed runtime");
138
+ process.exitCode = 2;
139
+ return;
140
+ }
141
+ const version = args[0] ?? installedVersion(runtime);
142
+ if (!version) {
143
+ process.exitCode = 2;
144
+ return;
145
+ }
146
+ const before = runtime.version;
147
+ const refused = await switchTo({ ...runtime, version }, version, { force: false });
148
+ log(`${new Date().toISOString()} switch ${before} → ${version}: ${refused ? `refused (${refused})` : "done"}`);
149
+ if (refused)
150
+ process.exitCode = 1;
151
+ }
152
+ export {
153
+ runInstalledUpdate,
154
+ runRuntimeSwitch,
155
+ runSelfUpdate
156
+ };