@vibest/cli 0.0.1-beta.13 → 0.0.1-beta.15

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.
@@ -4731,7 +4731,7 @@ var TypeId6 = "~effect/Layer", MemoMapTypeId = "~effect/Layer/MemoMap", makeMemo
4731
4731
  return forEach(layers, (layer) => layer.build(memoMap, forkUnsafe2(parentScope, "sequential")), {
4732
4732
  concurrency: layers.length
4733
4733
  }).pipe(map5((context) => mergeAll(...context)));
4734
- }, mergeAll2 = (...layers) => fromBuild((memoMap, scope) => mergeAllEffect(layers, memoMap, scope)), provideWith = (self, that, f) => fromBuild((memoMap, scope) => flatMap2(Array.isArray(that) ? mergeAllEffect(that, memoMap, scope) : that.build(memoMap, scope), (context) => self.build(memoMap, scope).pipe(provideContext(context), map5((merged) => f(merged, context))))), provide2, provideMerge, flatMap3;
4734
+ }, mergeAll2 = (...layers) => fromBuild((memoMap, scope) => mergeAllEffect(layers, memoMap, scope)), merge2, provideWith = (self, that, f) => fromBuild((memoMap, scope) => flatMap2(Array.isArray(that) ? mergeAllEffect(that, memoMap, scope) : that.build(memoMap, scope), (context) => self.build(memoMap, scope).pipe(provideContext(context), map5((merged) => f(merged, context))))), provide2, provideMerge, flatMap3;
4735
4735
  var init_Layer = __esm(() => {
4736
4736
  init_Context();
4737
4737
  init_Deferred();
@@ -4798,6 +4798,7 @@ var init_Layer = __esm(() => {
4798
4798
  buildWithScope = /* @__PURE__ */ dual(2, (self, scope) => withFiber((fiber) => buildWithMemoMap(self, CurrentMemoMap.forkOrCreate(fiber.context), scope)));
4799
4799
  empty4 = /* @__PURE__ */ succeedContext(/* @__PURE__ */ empty3());
4800
4800
  unwrapKey = /* @__PURE__ */ Service("effect/Layer/unwrap");
4801
+ merge2 = /* @__PURE__ */ dual(2, (self, that) => mergeAll2(self, ...Array.isArray(that) ? that : [that]));
4801
4802
  provide2 = /* @__PURE__ */ dual(2, (self, that) => provideWith(self, that, identity));
4802
4803
  provideMerge = /* @__PURE__ */ dual(2, (self, that) => provideWith(self, that, (self, that) => merge(that, self)));
4803
4804
  flatMap3 = /* @__PURE__ */ dual(2, (self, f) => fromBuild((memoMap, scope) => flatMap2(self.build(memoMap, scope), (context) => f(context).build(memoMap, scope))));
@@ -6254,7 +6255,7 @@ var TypeId15 = "~effect/Channel", isChannel = (u) => hasProperty(u, TypeId15), C
6254
6255
  return flatMap4(close2, () => makePull);
6255
6256
  });
6256
6257
  return suspend2(() => childPull ?? makePull);
6257
- })), flatMapConcurrent = (self, f, options) => self.pipe(map8(f), mergeAll3(options)), flatten4 = (channels) => flatMap5(channels, identity), mapAccum, mergeAll3, merge2, splitLines = () => fromTransform((upstream, _scope) => sync2(() => {
6258
+ })), flatMapConcurrent = (self, f, options) => self.pipe(map8(f), mergeAll3(options)), flatten4 = (channels) => flatMap5(channels, identity), mapAccum, mergeAll3, merge3, splitLines = () => fromTransform((upstream, _scope) => sync2(() => {
6258
6259
  let stringBuilder = "";
6259
6260
  let midCRLF = false;
6260
6261
  let done = none2();
@@ -6492,7 +6493,7 @@ var init_Channel = __esm(() => {
6492
6493
  }), forkIn2(forkedScope));
6493
6494
  return take2(queue);
6494
6495
  })));
6495
- merge2 = /* @__PURE__ */ dual((args) => isChannel(args[0]) && isChannel(args[1]), (left, right, options) => fromTransformBracket(fnUntraced2(function* (upstream, _scope, forkedScope) {
6496
+ merge3 = /* @__PURE__ */ dual((args) => isChannel(args[0]) && isChannel(args[1]), (left, right, options) => fromTransformBracket(fnUntraced2(function* (upstream, _scope, forkedScope) {
6496
6497
  const strategy = options?.haltStrategy ?? "both";
6497
6498
  const queue = yield* bounded(0);
6498
6499
  yield* addFinalizer(forkedScope, shutdown(queue));
@@ -6646,7 +6647,7 @@ function* concatChannels(self, that) {
6646
6647
  stack.push(parts[1], parts[0]);
6647
6648
  }
6648
6649
  }
6649
- var TypeId19 = "~effect/Stream", isStream = (u) => hasProperty(u, TypeId19), fromChannel3, fromPull2 = (pull) => fromChannel3(fromPull(pull)), transformPull2 = (self, f) => fromChannel3(fromTransform((_, scope) => flatMap4(toPullScoped(self.channel, scope), (pull) => f(pull, scope)))), toChannel2 = (stream) => stream.channel, callback3 = (f, options) => fromChannel3(callbackArray(f, options)), empty6, succeed9 = (value) => fromChannel3(succeed8(of(value))), make13 = (...values) => fromArray2(values), suspend4 = (stream) => fromChannel3(suspend3(() => stream().channel)), fromArray2 = (array) => isReadonlyArrayNonEmpty(array) ? fromChannel3(succeed8(array)) : empty6, fromQueue = (queue) => fromChannel3(fromQueueArray(queue)), never4, unwrap4 = (effect) => fromChannel3(unwrap2(map7(effect, toChannel2))), map9, concat, concatParts, merge3, takeUntil, scan, transduce, decodeText, splitLines2 = (self) => self.channel.pipe(pipeTo(splitLines()), fromChannel3), provideContext4, run, runCollect = (self) => runFold(self.channel, () => [], (acc, chunk) => {
6650
+ var TypeId19 = "~effect/Stream", isStream = (u) => hasProperty(u, TypeId19), fromChannel3, fromPull2 = (pull) => fromChannel3(fromPull(pull)), transformPull2 = (self, f) => fromChannel3(fromTransform((_, scope) => flatMap4(toPullScoped(self.channel, scope), (pull) => f(pull, scope)))), toChannel2 = (stream) => stream.channel, callback3 = (f, options) => fromChannel3(callbackArray(f, options)), empty6, succeed9 = (value) => fromChannel3(succeed8(of(value))), make13 = (...values) => fromArray2(values), suspend4 = (stream) => fromChannel3(suspend3(() => stream().channel)), fromArray2 = (array) => isReadonlyArrayNonEmpty(array) ? fromChannel3(succeed8(array)) : empty6, fromQueue = (queue) => fromChannel3(fromQueueArray(queue)), never4, unwrap4 = (effect) => fromChannel3(unwrap2(map7(effect, toChannel2))), map9, concat, concatParts, merge4, takeUntil, scan, transduce, decodeText, splitLines2 = (self) => self.channel.pipe(pipeTo(splitLines()), fromChannel3), provideContext4, run, runCollect = (self) => runFold(self.channel, () => [], (acc, chunk) => {
6650
6651
  for (let i = 0;i < chunk.length; i++) {
6651
6652
  acc.push(chunk[i]);
6652
6653
  }
@@ -6675,7 +6676,7 @@ var init_Stream = __esm(() => {
6675
6676
  return stream;
6676
6677
  });
6677
6678
  concatParts = /* @__PURE__ */ new WeakMap;
6678
- merge3 = /* @__PURE__ */ dual((args) => isStream(args[0]) && isStream(args[1]), (self, that, options) => fromChannel3(merge2(toChannel2(self), toChannel2(that), options)));
6679
+ merge4 = /* @__PURE__ */ dual((args) => isStream(args[0]) && isStream(args[1]), (self, that, options) => fromChannel3(merge3(toChannel2(self), toChannel2(that), options)));
6679
6680
  takeUntil = /* @__PURE__ */ dual((args) => isStream(args[0]), (self, predicate, options) => transformPull2(self, (pull, _scope) => sync2(() => {
6680
6681
  let i = 0;
6681
6682
  let done = false;
@@ -10064,7 +10065,7 @@ var TypeId28, Proto5, make20 = (input) => Object.assign(Object.create(Proto5), i
10064
10065
  }
10065
10066
  }
10066
10067
  return out;
10067
- }, merge4, redact2, CurrentRedactedNames;
10068
+ }, merge5, redact2, CurrentRedactedNames;
10068
10069
  var init_Headers = __esm(() => {
10069
10070
  init_Context();
10070
10071
  init_Equal();
@@ -10109,7 +10110,7 @@ var init_Headers = __esm(() => {
10109
10110
  });
10110
10111
  Equivalence3 = /* @__PURE__ */ makeEquivalence(/* @__PURE__ */ strictEqual());
10111
10112
  empty7 = /* @__PURE__ */ Object.create(Proto5);
10112
- merge4 = /* @__PURE__ */ dual(2, (self, headers) => {
10113
+ merge5 = /* @__PURE__ */ dual(2, (self, headers) => {
10113
10114
  const out = make20(self);
10114
10115
  Object.assign(out, headers);
10115
10116
  return out;
@@ -15885,50 +15886,6 @@ var init_dist = __esm(() => {
15885
15886
  init_Version();
15886
15887
  });
15887
15888
 
15888
- // ../../../node_modules/.pnpm/effect@4.0.2/node_modules/effect/dist/process/index.js
15889
- var init_process = __esm(() => {
15890
- init_ChildProcess();
15891
- init_ChildProcessSpawner();
15892
- });
15893
-
15894
- // ../../schema/src/layout.ts
15895
- var Layout, VibestCommand, shellQuote = (s) => /^[\w@%+=:,./-]+$/.test(s) ? s : `'${s.replace(/'/g, `'\\''`)}'`;
15896
- var init_layout = __esm(() => {
15897
- init_dist();
15898
- Layout = class Layout extends Service()("vibest/Layout") {
15899
- static make = (home) => gen2(function* () {
15900
- const path = yield* Path;
15901
- return Layout.of({
15902
- home,
15903
- database: path.join(home, "vibest.db"),
15904
- socket: path.join(home, "vibest.sock"),
15905
- daemonInfo: path.join(home, "vibestd.pid"),
15906
- results: path.join(home, "results"),
15907
- reports: path.join(home, "reports"),
15908
- worktrees: path.join(home, "worktrees"),
15909
- projects: path.join(home, "projects"),
15910
- config: path.join(home, "vibest.json"),
15911
- plugins: path.join(home, "plugins"),
15912
- resultFile: (id) => path.join(home, "results", `${id}.json`),
15913
- reportFile: (id) => path.join(home, "reports", `${id}.jsonl`),
15914
- rulesFile: (id) => path.join(home, "rules", `${id}.md`),
15915
- coordinatorRules: (key) => path.join(home, "coordinator", `${key}.md`),
15916
- legacyWorktree: (id) => path.join(home, "worktrees", id),
15917
- allocationWorktree: (repository, name) => path.join(home, "worktrees", repository, name),
15918
- project: (key) => path.join(home, "projects", key),
15919
- scratch: (key) => path.join(home, "projects", key, "scratch"),
15920
- inboxClaim: (generation, token) => path.join(home, "inbox-claims", `${generation}-${token}`)
15921
- });
15922
- });
15923
- static layer = effect(Layout, gen2(function* () {
15924
- const path = yield* Path;
15925
- const home = yield* String7("VIBEST_HOME").pipe(orElse(() => String7("HOME").pipe(map10((h) => path.join(h, ".vibest")))));
15926
- return yield* Layout.make(home);
15927
- }));
15928
- };
15929
- VibestCommand = Reference("vibest/VibestCommand", { defaultValue: () => ["vibest"] });
15930
- });
15931
-
15932
15889
  // ../../schema/src/session.ts
15933
15890
  var AgentStatus, TurnState, InboxKind, InboxStatus, RuntimeAddress, RuntimeLocation, RuntimeMachine, InboxRow, HARNESS_IDS, isHarnessId = (s) => HARNESS_IDS.includes(s), HarnessUnavailable, RuntimeUnreachable, NoRuntime, RuntimeIncompatible, NoSuchSession, AllocationFailed, SessionBusy, LimitReached, NotReady, NoHarnessChosen, LaunchFailed, NotInRepository;
15934
15891
  var init_session = __esm(() => {
@@ -15941,7 +15898,10 @@ var init_session = __esm(() => {
15941
15898
  machine: String6,
15942
15899
  id: String6
15943
15900
  });
15944
- RuntimeLocation = Union2([Struct({ socketPath: String6 }), Struct({ session: String6 })]);
15901
+ RuntimeLocation = Union2([
15902
+ Struct({ socketPath: String6 }),
15903
+ Struct({ session: String6 })
15904
+ ]);
15945
15905
  RuntimeMachine = Struct({
15946
15906
  id: String6,
15947
15907
  target: optional2(String6)
@@ -15973,25 +15933,38 @@ var init_session = __esm(() => {
15973
15933
  message: String6
15974
15934
  }) {
15975
15935
  };
15976
- NoSuchSession = class NoSuchSession extends TaggedError3()("NoSuchSession", { id: String6, message: String6 }) {
15936
+ NoSuchSession = class NoSuchSession extends TaggedError3()("NoSuchSession", {
15937
+ id: String6,
15938
+ message: String6
15939
+ }) {
15977
15940
  };
15978
- AllocationFailed = class AllocationFailed extends TaggedError3()("AllocationFailed", { message: String6 }) {
15941
+ AllocationFailed = class AllocationFailed extends TaggedError3()("AllocationFailed", {
15942
+ message: String6
15943
+ }) {
15979
15944
  };
15980
- SessionBusy = class SessionBusy extends TaggedError3()("SessionBusy", { id: String6, message: String6 }) {
15945
+ SessionBusy = class SessionBusy extends TaggedError3()("SessionBusy", {
15946
+ id: String6,
15947
+ message: String6
15948
+ }) {
15981
15949
  };
15982
15950
  LimitReached = class LimitReached extends TaggedError3()("LimitReached", { limit: Number6 }) {
15983
15951
  get message() {
15984
15952
  return `VIBEST_MAX_SESSIONS=${this.limit} sessions are already open (working or kept); vibest archive one first`;
15985
15953
  }
15986
15954
  };
15987
- NotReady = class NotReady extends TaggedError3()("NotReady", { id: String6, message: String6 }) {
15955
+ NotReady = class NotReady extends TaggedError3()("NotReady", {
15956
+ id: String6,
15957
+ message: String6
15958
+ }) {
15988
15959
  };
15989
15960
  NoHarnessChosen = class NoHarnessChosen extends TaggedError3()("NoHarnessChosen", {}) {
15990
15961
  get message() {
15991
15962
  return "no harness chosen: pass harness, or install a routing plugin";
15992
15963
  }
15993
15964
  };
15994
- LaunchFailed = class LaunchFailed extends TaggedError3()("LaunchFailed", { message: String6, tail: String6 }) {
15965
+ LaunchFailed = class LaunchFailed extends TaggedError3()("LaunchFailed", {
15966
+ message: String6
15967
+ }) {
15995
15968
  };
15996
15969
  NotInRepository = class NotInRepository extends TaggedError3()("NotInRepository", { path: String6 }) {
15997
15970
  get message() {
@@ -16000,6 +15973,52 @@ var init_session = __esm(() => {
16000
15973
  };
16001
15974
  });
16002
15975
 
15976
+ // ../../schema/src/layout.ts
15977
+ var Layout, VibestCommand, shellQuote = (s) => /^[\w@%+=:,./-]+$/.test(s) ? s : `'${s.replace(/'/g, `'\\''`)}'`;
15978
+ var init_layout = __esm(() => {
15979
+ init_dist();
15980
+ Layout = class Layout extends Service()("vibest/Layout") {
15981
+ static make = (home) => gen2(function* () {
15982
+ const path = yield* Path;
15983
+ return Layout.of({
15984
+ home,
15985
+ database: path.join(home, "vibest.db"),
15986
+ socket: path.join(home, "vibest.sock"),
15987
+ httpSocket: path.join(home, "vibest-http.sock"),
15988
+ daemonInfo: path.join(home, "vibestd.pid"),
15989
+ results: path.join(home, "results"),
15990
+ reports: path.join(home, "reports"),
15991
+ worktrees: path.join(home, "worktrees"),
15992
+ projects: path.join(home, "projects"),
15993
+ config: path.join(home, "vibest.json"),
15994
+ plugins: path.join(home, "plugins"),
15995
+ resultFile: (id) => path.join(home, "results", `${id}.json`),
15996
+ reportFile: (id) => path.join(home, "reports", `${id}.jsonl`),
15997
+ rulesFile: (id) => path.join(home, "rules", `${id}.md`),
15998
+ coordinatorRules: (key) => path.join(home, "coordinator", `${key}.md`),
15999
+ legacyWorktree: (id) => path.join(home, "worktrees", id),
16000
+ allocationWorktree: (repository, name) => path.join(home, "worktrees", repository, name),
16001
+ project: (key) => path.join(home, "projects", key),
16002
+ scratch: (key) => path.join(home, "projects", key, "scratch")
16003
+ });
16004
+ });
16005
+ static layer = effect(Layout, gen2(function* () {
16006
+ const path = yield* Path;
16007
+ const home = yield* String7("VIBEST_HOME").pipe(orElse(() => String7("HOME").pipe(map10((h) => path.join(h, ".vibest")))));
16008
+ return yield* Layout.make(home);
16009
+ }));
16010
+ };
16011
+ VibestCommand = Reference("vibest/VibestCommand", {
16012
+ defaultValue: () => ["vibest"]
16013
+ });
16014
+ });
16015
+
16016
+ // ../../../node_modules/.pnpm/effect@4.0.2/node_modules/effect/dist/process/index.js
16017
+ var init_process = __esm(() => {
16018
+ init_ChildProcess();
16019
+ init_ChildProcessSpawner();
16020
+ });
16021
+
16003
16022
  // ../../core/src/models.ts
16004
16023
  var exports_models = {};
16005
16024
  __export(exports_models, {
@@ -16011,7 +16030,14 @@ __export(exports_models, {
16011
16030
  normalizeModels: () => normalizeModels,
16012
16031
  withConfigured: () => withConfigured
16013
16032
  });
16014
- var Model, normalizeModels = (harness, provider, raw) => raw.map((r) => ({ harness, provider: r.provider ?? provider, model: r.model, name: r.name || r.model, description: r.description ?? "", default: r.default })).filter((m) => !provider || m.provider === provider), jsonLines = (...messages) => messages.map((m) => `${JSON.stringify(m)}
16033
+ var Model, normalizeModels = (harness, provider, raw) => raw.map((r) => ({
16034
+ harness,
16035
+ provider: r.provider ?? provider,
16036
+ model: r.model,
16037
+ name: r.name || r.model,
16038
+ description: r.description ?? "",
16039
+ default: r.default
16040
+ })).filter((m) => !provider || m.provider === provider), jsonLines = (...messages) => messages.map((m) => `${JSON.stringify(m)}
16015
16041
  `).join(""), findMessage2 = (schema) => {
16016
16042
  const decode = decodeUnknownOption2(fromJsonString2(schema));
16017
16043
  return (lines) => {
@@ -16063,10 +16089,10 @@ var init_models = __esm(() => {
16063
16089
  // ../../core/src/harness.ts
16064
16090
  var encodeCommand, Harnesses, MODELS_TTL, Harness, preflight, harnessOptions;
16065
16091
  var init_harness = __esm(() => {
16066
- init_dist();
16067
- init_process();
16068
16092
  init_layout();
16069
16093
  init_session();
16094
+ init_dist();
16095
+ init_process();
16070
16096
  init_session();
16071
16097
  encodeCommand = encodeSync(fromJsonString2(ArraySchema(String6)));
16072
16098
  Harnesses = class Harnesses extends Service()("vibest/Harnesses") {
@@ -16085,7 +16111,11 @@ var init_harness = __esm(() => {
16085
16111
  const harnesses = yield* Harnesses;
16086
16112
  const self = yield* VibestCommand;
16087
16113
  const pkg = self.length === 1 && path.isAbsolute(self[0]) ? path.dirname(path.dirname(self[0])) : undefined;
16088
- const beside = pkg === undefined ? undefined : yield* findFirst2([path.join(pkg, "harnesses"), path.join(pkg, "..", "cli", "harnesses"), path.join(pkg, "..", "..", "..", "harnesses")], (dir) => fs.exists(dir).pipe(orElseSucceed2(() => false))).pipe(map7((found) => getOrElse(found, () => path.join(pkg, "harnesses"))));
16114
+ const beside = pkg === undefined ? undefined : yield* findFirst2([
16115
+ path.join(pkg, "harnesses"),
16116
+ path.join(pkg, "..", "cli", "harnesses"),
16117
+ path.join(pkg, "..", "..", "..", "harnesses")
16118
+ ], (dir) => fs.exists(dir).pipe(orElseSucceed2(() => false))).pipe(map7((found) => getOrElse(found, () => path.join(pkg, "harnesses"))));
16089
16119
  const plugins = getOrUndefined(yield* option3(String7("VIBEST_HARNESSES"))) || beside;
16090
16120
  const searchPath = (yield* String7("PATH").pipe(withDefault3(""))).split(":").filter(Boolean);
16091
16121
  const { listModels } = yield* promise2(() => Promise.resolve().then(() => (init_models(), exports_models)));
@@ -16135,6 +16165,10 @@ var init_harness = __esm(() => {
16135
16165
  harnessOptions = forEach2(HARNESS_IDS, (id) => preflight(id, null, null).pipe(map7(() => ({ harness: id, available: true })), catchTag2("HarnessUnavailable", (e) => succeed7({ harness: id, available: false, problem: e.message }))), { concurrency: "unbounded" });
16136
16166
  });
16137
16167
 
16168
+ // src/extension.ts
16169
+ import path from "node:path";
16170
+ import url from "node:url";
16171
+
16138
16172
  // ../../../node_modules/.pnpm/@effect+platform-node-shared@4.0.2_effect@4.0.2/node_modules/@effect/platform-node-shared/dist/NodeChildProcessSpawner.js
16139
16173
  init_Deferred();
16140
16174
  init_Duration();
@@ -16556,7 +16590,7 @@ var make18 = /* @__PURE__ */ gen2(function* () {
16556
16590
  if (isSink(stderrConfig.stream)) {
16557
16591
  stderr = transduce(stderr, stderrConfig.stream);
16558
16592
  }
16559
- const all = merge3(stdout, stderr);
16593
+ const all = merge4(stdout, stderr);
16560
16594
  return {
16561
16595
  stdout,
16562
16596
  stderr,
@@ -17797,57 +17831,285 @@ var fromDuplex = (open, options) => withFiber2((fiber) => {
17797
17831
  }));
17798
17832
  });
17799
17833
 
17800
- // ../../client/src/client.ts
17834
+ // ../../protocol/src/protocol.ts
17835
+ var PROTOCOL = 4;
17836
+ var MISMATCH_ACTION = "vibest update";
17837
+ var protocolMismatch = (caller, server, version, callerVersion) => ({
17838
+ protocol: server,
17839
+ version,
17840
+ message: caller !== undefined && caller > server ? `vibestd is older (${version}); run ${MISMATCH_ACTION}` : `this agent runs ${callerVersion ? `vibest ${callerVersion}` : "an older vibest"} (protocol ${caller ?? "none"}), vibestd runs ${version} (protocol ${server}); run ${MISMATCH_ACTION} to restart this agent on it`,
17841
+ action: MISMATCH_ACTION
17842
+ });
17843
+ var PROTOCOL_HEADER = "vibest-protocol";
17844
+ var CALLER_HEADER = "vibest-caller";
17845
+ var SESSION_HEADER = "vibest-session-id";
17846
+ var REPOSITORY_HEADER = "vibest-repository";
17847
+ var PROJECT_HEADER = "vibest-project-id";
17848
+ var HARNESS_SESSION_HEADER = "vibest-harness-session-id";
17849
+ var AGENT_HEADER = "vibest-agent";
17850
+ var HARNESS_HEADER = "vibest-harness";
17851
+ var CWD_HEADER = "vibest-cwd";
17852
+ var RUNTIME_HEADER = "vibest-runtime";
17853
+ var PLUGIN_VERSION_HEADER = "vibest-plugin-version";
17854
+ var sessionHeaders = (who) => {
17855
+ const headers = {
17856
+ [PROTOCOL_HEADER]: String(PROTOCOL),
17857
+ [CALLER_HEADER]: "session",
17858
+ [SESSION_HEADER]: who.sessionId
17859
+ };
17860
+ const put = (name, value) => {
17861
+ if (value)
17862
+ headers[name] = value;
17863
+ };
17864
+ put(PROJECT_HEADER, who.projectId);
17865
+ put(HARNESS_SESSION_HEADER, who.harnessSessionId);
17866
+ put(AGENT_HEADER, who.agent);
17867
+ put(HARNESS_HEADER, who.harness);
17868
+ put(CWD_HEADER, who.cwd === undefined ? undefined : encodeURIComponent(who.cwd));
17869
+ put(RUNTIME_HEADER, who.runtime);
17870
+ put(PLUGIN_VERSION_HEADER, who.pluginVersion);
17871
+ if (who.repositoryRoot !== undefined)
17872
+ headers[REPOSITORY_HEADER] = who.repositoryRoot;
17873
+ return headers;
17874
+ };
17875
+
17876
+ // ../../schema/src/model.ts
17801
17877
  init_dist();
17802
- init_process();
17878
+ var ProjectID = brand("ProjectID")(Int);
17879
+ var sessionId = brand("SessionID")(String6.check(isPattern2(/^[0-9a-f]{8}$/)));
17880
+ var SessionID = Object.assign(sessionId, {
17881
+ create: () => {
17882
+ let id = "";
17883
+ for (let i = 0;i < 8; i++)
17884
+ id += Math.floor(Math.random() * 16).toString(16);
17885
+ return id;
17886
+ }
17887
+ });
17888
+ var InboxID = brand("InboxID")(Int);
17889
+ var MessageID = brand("MessageID")(Int);
17890
+ var Time = Number6;
17891
+ var Json3 = Record(String6, Unknown2);
17892
+ var Project = Struct({
17893
+ id: ProjectID,
17894
+ directory: String6,
17895
+ mainSessionId: optional2(SessionID)
17896
+ });
17897
+ var Runtime = Json3;
17898
+ var Session = Struct({
17899
+ id: SessionID,
17900
+ projectId: ProjectID,
17901
+ parentSessionId: optional2(SessionID),
17902
+ agentType: String6,
17903
+ harness: String6,
17904
+ directory: String6,
17905
+ runtime: optional2(Runtime),
17906
+ harnessSessionId: optional2(String6),
17907
+ metadata: Json3,
17908
+ createdAt: Time,
17909
+ endedAt: optional2(Time)
17910
+ });
17911
+ var SenderType = Literals(["user", "session", "system", "plugin"]);
17912
+ var DeliveryStatus = Literals(["pending", "delivering", "delivered", "failed", "dropped"]);
17913
+ var Inbox = Struct({
17914
+ id: InboxID,
17915
+ recipientSessionId: SessionID,
17916
+ senderType: SenderType,
17917
+ senderId: optional2(String6),
17918
+ content: String6,
17919
+ resultMessageId: optional2(MessageID),
17920
+ deliveryStatus: DeliveryStatus
17921
+ });
17922
+ var MessageStatus = Literals(["working", "completed", "failed", "interrupted", "lost", "not_started"]);
17923
+ var Message = Struct({
17924
+ id: MessageID,
17925
+ sessionId: SessionID,
17926
+ inboxId: optional2(InboxID),
17927
+ input: String6,
17928
+ output: optional2(String6),
17929
+ status: MessageStatus,
17930
+ metadata: Json3,
17931
+ startedAt: Time,
17932
+ endedAt: optional2(Time)
17933
+ });
17803
17934
 
17804
- // ../../../node_modules/.pnpm/effect@4.0.2/node_modules/effect/dist/rpc/Rpc.js
17805
- init_Context();
17806
- init_Option();
17807
- init_Pipeable();
17808
- init_PrimaryKey();
17809
- init_Schema();
17935
+ // ../../schema/src/plugin.ts
17936
+ init_dist();
17810
17937
 
17811
- // ../../../node_modules/.pnpm/effect@4.0.2/node_modules/effect/dist/rpc/RpcSchema.js
17812
- init_Option();
17813
- init_Predicate();
17814
- init_Schema();
17815
- init_Stream();
17816
- var StreamSchemaTypeId = "~effect/rpc/RpcSchema/StreamSchema";
17817
- function isStreamSchema(schema) {
17818
- return hasProperty(schema, StreamSchemaTypeId);
17819
- }
17820
- function getStreamSchemas(schema) {
17821
- return isStreamSchema(schema) ? some2({
17822
- success: schema.success,
17823
- error: schema.error
17824
- }) : none2();
17938
+ class AgentRefused extends TaggedError3()("AgentRefused", {
17939
+ plugin: String6,
17940
+ reason: String6
17941
+ }) {
17942
+ get message() {
17943
+ return `refused by ${this.plugin}: ${this.reason}`;
17944
+ }
17825
17945
  }
17826
- var schema2 = /* @__PURE__ */ declare(isStream);
17827
- function Stream2(success, error) {
17828
- return make23(schema2.ast, {
17829
- [StreamSchemaTypeId]: StreamSchemaTypeId,
17830
- success,
17831
- error
17832
- });
17946
+
17947
+ class HookFailed extends TaggedError3()("HookFailed", { message: String6 }) {
17833
17948
  }
17949
+ var Change = Struct({
17950
+ field: String6,
17951
+ from: optional2(Unknown2),
17952
+ to: optional2(Unknown2),
17953
+ overwrote: optional2(String6)
17954
+ });
17955
+ var TraceEntry = Struct({
17956
+ plugin: String6,
17957
+ hook: String6,
17958
+ outcome: Literals(["ok", "refused", "crashed", "timeout"]),
17959
+ ms: Number6,
17960
+ changes: ArraySchema(Change),
17961
+ reason: optional2(String6),
17962
+ error: optional2(String6)
17963
+ });
17964
+ var Routing = Struct({
17965
+ decidedBy: Record(String6, String6),
17966
+ trace: ArraySchema(TraceEntry)
17967
+ });
17968
+ var PluginInfo = Struct({
17969
+ id: String6,
17970
+ source: String6,
17971
+ revision: String6,
17972
+ loadedAt: Number6,
17973
+ status: Literals(["active", "failed"]),
17974
+ error: optional2(String6),
17975
+ calls: Number6,
17976
+ changed: Number6,
17977
+ crashed: Number6,
17978
+ timedOut: Number6,
17979
+ refused: Number6,
17980
+ lastError: optional2(String6)
17981
+ });
17834
17982
 
17835
- // ../../../node_modules/.pnpm/effect@4.0.2/node_modules/effect/dist/rpc/Rpc.js
17836
- var TypeId50 = "~effect/rpc/Rpc";
17837
- var Proto18 = {
17838
- [TypeId50]: TypeId50,
17839
- pipe() {
17840
- return pipeArguments(this, arguments);
17841
- },
17842
- setSuccess(successSchema) {
17843
- return makeProto2({
17844
- _tag: this._tag,
17845
- payloadSchema: this.payloadSchema,
17846
- successSchema,
17847
- errorSchema: this.errorSchema,
17848
- defectSchema: this.defectSchema,
17849
- annotations: this.annotations,
17850
- middlewares: this.middlewares
17983
+ // ../../schema/src/project.ts
17984
+ init_dist();
17985
+ var ProjectKind = Literals(["docs", "memory", "scratch"]);
17986
+ var ProjectEntry = Struct({
17987
+ path: String6,
17988
+ size: Number6,
17989
+ mtime: String6,
17990
+ version: String6,
17991
+ description: String6
17992
+ });
17993
+ var ProjectInfoResult = Struct({
17994
+ instructions: String6,
17995
+ docs: ArraySchema(ProjectEntry),
17996
+ memory: ArraySchema(ProjectEntry),
17997
+ scratch: ArraySchema(ProjectEntry),
17998
+ scratchPath: String6
17999
+ });
18000
+ var ProjectListInput = Struct({ kind: ProjectKind });
18001
+ var ProjectReadInput = Struct({ kind: ProjectKind, path: String6 });
18002
+ var ProjectReadResult = Struct({ content: String6, version: String6 });
18003
+ var ProjectSearchInput = Struct({ query: String6, kind: optional2(ProjectKind) });
18004
+ var ProjectWriteInput = Struct({
18005
+ kind: ProjectKind,
18006
+ path: String6,
18007
+ content: String6,
18008
+ ifVersion: String6
18009
+ });
18010
+ var ProjectWriteResult = Struct({ version: String6 });
18011
+ var ProjectDeleteInput = Struct({ kind: ProjectKind, path: String6, ifVersion: String6 });
18012
+
18013
+ class ProjectConflict extends TaggedError3()("ProjectConflict", {
18014
+ message: String6
18015
+ }) {
18016
+ }
18017
+
18018
+ class ProjectInvalid extends TaggedError3()("ProjectInvalid", {
18019
+ message: String6
18020
+ }) {
18021
+ }
18022
+
18023
+ // ../../schema/src/remove.ts
18024
+ init_dist();
18025
+ var RemoveOutcome = Struct({
18026
+ id: String6,
18027
+ processes: Literals(["exited", "alive", "unknown"]),
18028
+ pane: Literals(["closed", "kept", "none"]),
18029
+ workspace: Literals(["closed", "kept", "none"]),
18030
+ worktree: Literals(["removed", "kept", "gone"]),
18031
+ path: String6,
18032
+ branch: NullOr(String6),
18033
+ reasons: ArraySchema(String6)
18034
+ });
18035
+
18036
+ // ../../protocol/src/rpc.ts
18037
+ init_session();
18038
+
18039
+ // ../../schema/src/subscription.ts
18040
+ init_dist();
18041
+ init_session();
18042
+ var SubscriptionAccount = Struct({
18043
+ kind: Literals(["subscription", "api-key", "none"]),
18044
+ plan: optional2(String6),
18045
+ provider: optional2(String6)
18046
+ });
18047
+ var SubscriptionLimit = Struct({
18048
+ window: String6,
18049
+ percent: Number6,
18050
+ status: Literals(["available", "limited"]),
18051
+ resetTime: NullOr(Number6)
18052
+ });
18053
+ var Subscription = Struct({
18054
+ harness: Literals(HARNESS_IDS),
18055
+ provider: String6,
18056
+ machine: Literal2("local"),
18057
+ account: SubscriptionAccount,
18058
+ limits: ArraySchema(SubscriptionLimit),
18059
+ updatedAt: Number6,
18060
+ error: optional2(String6)
18061
+ });
18062
+
18063
+ // ../../protocol/src/rpc.ts
18064
+ init_dist();
18065
+
18066
+ // ../../../node_modules/.pnpm/effect@4.0.2/node_modules/effect/dist/rpc/Rpc.js
18067
+ init_Context();
18068
+ init_Option();
18069
+ init_Pipeable();
18070
+ init_PrimaryKey();
18071
+ init_Schema();
18072
+
18073
+ // ../../../node_modules/.pnpm/effect@4.0.2/node_modules/effect/dist/rpc/RpcSchema.js
18074
+ init_Option();
18075
+ init_Predicate();
18076
+ init_Schema();
18077
+ init_Stream();
18078
+ var StreamSchemaTypeId = "~effect/rpc/RpcSchema/StreamSchema";
18079
+ function isStreamSchema(schema) {
18080
+ return hasProperty(schema, StreamSchemaTypeId);
18081
+ }
18082
+ function getStreamSchemas(schema) {
18083
+ return isStreamSchema(schema) ? some2({
18084
+ success: schema.success,
18085
+ error: schema.error
18086
+ }) : none2();
18087
+ }
18088
+ var schema2 = /* @__PURE__ */ declare(isStream);
18089
+ function Stream2(success, error) {
18090
+ return make23(schema2.ast, {
18091
+ [StreamSchemaTypeId]: StreamSchemaTypeId,
18092
+ success,
18093
+ error
18094
+ });
18095
+ }
18096
+
18097
+ // ../../../node_modules/.pnpm/effect@4.0.2/node_modules/effect/dist/rpc/Rpc.js
18098
+ var TypeId50 = "~effect/rpc/Rpc";
18099
+ var Proto18 = {
18100
+ [TypeId50]: TypeId50,
18101
+ pipe() {
18102
+ return pipeArguments(this, arguments);
18103
+ },
18104
+ setSuccess(successSchema) {
18105
+ return makeProto2({
18106
+ _tag: this._tag,
18107
+ payloadSchema: this.payloadSchema,
18108
+ successSchema,
18109
+ errorSchema: this.errorSchema,
18110
+ defectSchema: this.defectSchema,
18111
+ annotations: this.annotations,
18112
+ middlewares: this.middlewares
17851
18113
  });
17852
18114
  },
17853
18115
  setError(errorSchema) {
@@ -18513,7 +18775,7 @@ var makeNoSerialization = /* @__PURE__ */ fnUntraced2(function* (group, options)
18513
18775
  spanId: span.spanId,
18514
18776
  sampled: span.sampled
18515
18777
  } : {},
18516
- headers: merge4(parentFiber.getRef(CurrentHeaders), headers)
18778
+ headers: merge5(parentFiber.getRef(CurrentHeaders), headers)
18517
18779
  });
18518
18780
  if (discard) {
18519
18781
  return send;
@@ -18587,7 +18849,7 @@ var makeNoSerialization = /* @__PURE__ */ fnUntraced2(function* (group, options)
18587
18849
  spanId: span.spanId,
18588
18850
  sampled: span.sampled
18589
18851
  } : {},
18590
- headers: merge4(fiber.getRef(CurrentHeaders), headers)
18852
+ headers: merge5(fiber.getRef(CurrentHeaders), headers)
18591
18853
  }).pipe(span ? withParentSpan2(span, {
18592
18854
  captureStackTrace: false
18593
18855
  }) : identity, onError2((cause) => failCause4(queue, cause)), interruptible2, forkIn2(scope, {
@@ -18843,7 +19105,7 @@ var makeRpcSchemas = (codecFor) => {
18843
19105
  var CurrentHeaders = /* @__PURE__ */ Reference("effect/rpc/RpcClient/CurrentHeaders", {
18844
19106
  defaultValue: () => empty7
18845
19107
  });
18846
- var withHeaders = /* @__PURE__ */ dual(2, (effect, headers) => updateService2(effect, CurrentHeaders, merge4(fromInput(headers))));
19108
+ var withHeaders = /* @__PURE__ */ dual(2, (effect, headers) => updateService2(effect, CurrentHeaders, merge5(fromInput(headers))));
18847
19109
 
18848
19110
  class Protocol extends (/* @__PURE__ */ Service()("effect/rpc/RpcClient/Protocol")) {
18849
19111
  static make = withRunClient;
@@ -19168,200 +19430,13 @@ var Service2 = () => (id, options) => {
19168
19430
  ServiceClass_.requiredForClient = options?.requiredForClient ?? false;
19169
19431
  return ServiceClass;
19170
19432
  };
19171
- // ../../client/src/client.ts
19172
- init_layout();
19173
-
19174
- // ../../protocol/src/protocol.ts
19175
- var PROTOCOL = 3;
19176
- var PROTOCOL_HEADER = "vibest-protocol";
19177
- var CALLER_HEADER = "vibest-caller";
19178
- var SESSION_HEADER = "vibest-session-id";
19179
- var REPOSITORY_HEADER = "vibest-repository";
19180
-
19181
- // ../../protocol/src/rpc.ts
19182
- init_dist();
19183
-
19184
- // ../../schema/src/plugin.ts
19185
- init_dist();
19186
-
19187
- class AgentRefused extends TaggedError3()("AgentRefused", { plugin: String6, reason: String6 }) {
19188
- get message() {
19189
- return `refused by ${this.plugin}: ${this.reason}`;
19190
- }
19191
- }
19192
-
19193
- class HookFailed extends TaggedError3()("HookFailed", { message: String6 }) {
19194
- }
19195
- var Change = Struct({
19196
- field: String6,
19197
- from: optional2(Unknown2),
19198
- to: optional2(Unknown2),
19199
- overwrote: optional2(String6)
19200
- });
19201
- var TraceEntry = Struct({
19202
- plugin: String6,
19203
- hook: String6,
19204
- outcome: Literals(["ok", "refused", "crashed", "timeout"]),
19205
- ms: Number6,
19206
- changes: ArraySchema(Change),
19207
- reason: optional2(String6),
19208
- error: optional2(String6)
19209
- });
19210
- var Routing = Struct({
19211
- decidedBy: Record(String6, String6),
19212
- trace: ArraySchema(TraceEntry)
19213
- });
19214
- var PluginInfo = Struct({
19215
- id: String6,
19216
- source: String6,
19217
- revision: String6,
19218
- loadedAt: Number6,
19219
- status: Literals(["active", "failed"]),
19220
- error: optional2(String6),
19221
- calls: Number6,
19222
- changed: Number6,
19223
- crashed: Number6,
19224
- timedOut: Number6,
19225
- refused: Number6,
19226
- lastError: optional2(String6)
19227
- });
19228
-
19229
- // ../../schema/src/subscription.ts
19230
- init_dist();
19231
- init_session();
19232
- var SubscriptionAccount = Struct({
19233
- kind: Literals(["subscription", "api-key", "none"]),
19234
- plan: optional2(String6),
19235
- provider: optional2(String6)
19236
- });
19237
- var SubscriptionLimit = Struct({
19238
- window: String6,
19239
- percent: Number6,
19240
- status: Literals(["available", "limited"]),
19241
- resetTime: NullOr(Number6)
19242
- });
19243
- var Subscription = Struct({
19244
- harness: Literals(HARNESS_IDS),
19245
- provider: String6,
19246
- machine: Literal2("local"),
19247
- account: SubscriptionAccount,
19248
- limits: ArraySchema(SubscriptionLimit),
19249
- updatedAt: Number6,
19250
- error: optional2(String6)
19251
- });
19252
-
19253
- // ../../schema/src/project.ts
19254
- init_dist();
19255
- var ProjectKind = Literals(["docs", "memory", "scratch"]);
19256
- var ProjectEntry = Struct({
19257
- path: String6,
19258
- size: Number6,
19259
- mtime: String6,
19260
- version: String6,
19261
- description: String6
19262
- });
19263
- var ProjectInfoResult = Struct({
19264
- instructions: String6,
19265
- docs: ArraySchema(ProjectEntry),
19266
- memory: ArraySchema(ProjectEntry),
19267
- scratch: ArraySchema(ProjectEntry),
19268
- scratchPath: String6
19269
- });
19270
- var ProjectListInput = Struct({ kind: ProjectKind });
19271
- var ProjectReadInput = Struct({ kind: ProjectKind, path: String6 });
19272
- var ProjectReadResult = Struct({ content: String6, version: String6 });
19273
- var ProjectSearchInput = Struct({ query: String6, kind: optional2(ProjectKind) });
19274
- var ProjectWriteInput = Struct({ kind: ProjectKind, path: String6, content: String6, ifVersion: String6 });
19275
- var ProjectWriteResult = Struct({ version: String6 });
19276
- var ProjectDeleteInput = Struct({ kind: ProjectKind, path: String6, ifVersion: String6 });
19277
-
19278
- class ProjectConflict extends TaggedError3()("ProjectConflict", { message: String6 }) {
19279
- }
19280
-
19281
- class ProjectInvalid extends TaggedError3()("ProjectInvalid", { message: String6 }) {
19282
- }
19283
-
19284
- // ../../schema/src/remove.ts
19285
- init_dist();
19286
- var RemoveOutcome = Struct({
19287
- id: String6,
19288
- processes: Literals(["exited", "alive", "unknown"]),
19289
- pane: Literals(["closed", "kept", "none"]),
19290
- workspace: Literals(["closed", "kept", "none"]),
19291
- worktree: Literals(["removed", "kept", "gone"]),
19292
- path: String6,
19293
- branch: NullOr(String6),
19294
- reasons: ArraySchema(String6)
19295
- });
19296
-
19297
- // ../../schema/src/model.ts
19298
- init_dist();
19299
- var ProjectID = brand("ProjectID")(Int);
19300
- var sessionId = brand("SessionID")(String6.check(isPattern2(/^[0-9a-f]{8}$/)));
19301
- var SessionID = Object.assign(sessionId, {
19302
- create: () => {
19303
- let id = "";
19304
- for (let i = 0;i < 8; i++)
19305
- id += Math.floor(Math.random() * 16).toString(16);
19306
- return id;
19307
- }
19308
- });
19309
- var InboxID = brand("InboxID")(Int);
19310
- var MessageID = brand("MessageID")(Int);
19311
- var Time = Number6;
19312
- var Json3 = Record(String6, Unknown2);
19313
- var Project = Struct({
19314
- id: ProjectID,
19315
- directory: String6,
19316
- mainSessionId: optional2(SessionID)
19317
- });
19318
- var Runtime = Json3;
19319
- var Session = Struct({
19320
- id: SessionID,
19321
- projectId: ProjectID,
19322
- parentSessionId: optional2(SessionID),
19323
- agentType: String6,
19324
- harness: String6,
19325
- directory: String6,
19326
- runtime: optional2(Runtime),
19327
- harnessSessionId: optional2(String6),
19328
- metadata: Json3,
19329
- createdAt: Time,
19330
- endedAt: optional2(Time)
19331
- });
19332
- var SenderType = Literals(["user", "session", "system", "plugin"]);
19333
- var DeliveryStatus = Literals(["pending", "delivering", "delivered", "failed", "dropped"]);
19334
- var Inbox = Struct({
19335
- id: InboxID,
19336
- recipientSessionId: SessionID,
19337
- senderType: SenderType,
19338
- senderId: optional2(String6),
19339
- content: String6,
19340
- resultMessageId: optional2(MessageID),
19341
- deliveryStatus: DeliveryStatus
19342
- });
19343
- var MessageStatus = Literals(["working", "completed", "failed", "interrupted", "lost", "not_started"]);
19344
- var Message = Struct({
19345
- id: MessageID,
19346
- sessionId: SessionID,
19347
- inboxId: optional2(InboxID),
19348
- input: String6,
19349
- output: optional2(String6),
19350
- status: MessageStatus,
19351
- metadata: Json3,
19352
- startedAt: Time,
19353
- endedAt: optional2(Time)
19354
- });
19355
-
19356
- // ../../protocol/src/rpc.ts
19357
- init_session();
19358
19433
  // ../../protocol/package.json
19359
19434
  var package_default = {
19360
19435
  name: "@vibest/protocol",
19361
- version: "0.0.1-beta.13",
19436
+ version: "0.0.1-beta.15",
19362
19437
  private: true,
19363
- type: "module",
19364
19438
  license: "MIT",
19439
+ type: "module",
19365
19440
  exports: {
19366
19441
  "./*": "./src/*.ts"
19367
19442
  },
@@ -19381,28 +19456,43 @@ var DaemonIdentity = Struct({
19381
19456
  command: optional2(ArraySchema(String6)),
19382
19457
  startedAt: optional2(Number6)
19383
19458
  });
19384
- var RuntimeStatus = Struct({ kind: String6, status: String6, reason: optional2(String6) });
19459
+ var RuntimeStatus = Struct({
19460
+ kind: String6,
19461
+ status: String6,
19462
+ reason: optional2(String6)
19463
+ });
19385
19464
  var RuntimeDoctor = Struct({
19386
19465
  kind: String6,
19387
19466
  status: String6,
19388
19467
  reason: optional2(String6),
19389
19468
  name: String6,
19390
- checks: ArraySchema(Struct({ ok: Boolean3, subject: optional2(String6), text: String6, fix: optional2(String6) }))
19469
+ checks: ArraySchema(Struct({
19470
+ ok: Boolean3,
19471
+ subject: optional2(String6),
19472
+ text: String6,
19473
+ fix: optional2(String6)
19474
+ }))
19391
19475
  });
19392
19476
  var PingResult = Struct({
19393
19477
  protocol: optional2(Number6),
19394
19478
  version: String6,
19395
19479
  runtimes: optional2(ArraySchema(RuntimeStatus)),
19396
- ...DaemonIdentity.fields
19480
+ ...DaemonIdentity.fields,
19481
+ capabilities: optional2(Record(String6, Boolean3))
19397
19482
  });
19398
19483
  var VERSION = package_default.version;
19399
19484
  class ProtocolRejected extends TaggedError3()("ProtocolRejected", {
19400
19485
  method: String6,
19401
- protocol: NullOr(String6)
19486
+ protocol: NullOr(String6),
19487
+ mismatch: Struct({
19488
+ protocol: Number6,
19489
+ version: String6,
19490
+ message: String6,
19491
+ action: String6
19492
+ })
19402
19493
  }) {
19403
19494
  get message() {
19404
- const got = this.protocol === null ? "none" : this.protocol;
19405
- return `${this.method} requires vibest protocol ${PROTOCOL}; the request sent ${got}. Restart vibestd with this vibest (\`vibest daemon\`). An old client that cannot read this error is still refused.`;
19495
+ return `${this.method} refused: ${this.mismatch.message}`;
19406
19496
  }
19407
19497
  }
19408
19498
 
@@ -19412,7 +19502,10 @@ class InvalidCaller extends TaggedError3()("InvalidCaller", {
19412
19502
  }) {
19413
19503
  }
19414
19504
 
19415
- class Forbidden2 extends TaggedError3()("Forbidden", { method: String6, message: String6 }) {
19505
+ class Forbidden2 extends TaggedError3()("Forbidden", {
19506
+ method: String6,
19507
+ message: String6
19508
+ }) {
19416
19509
  }
19417
19510
 
19418
19511
  class Caller extends Service()("vibest/Caller") {
@@ -19427,15 +19520,15 @@ var Blocker = Struct({ id: String6, reason: String6 });
19427
19520
 
19428
19521
  class DaemonBusy extends TaggedError3()("DaemonBusy", { blockers: ArraySchema(Blocker) }) {
19429
19522
  get message() {
19430
- return [
19431
- "vibestd was not stopped; still in use by:",
19432
- ...this.blockers.map((b) => ` ${b.id}: ${b.reason}`)
19433
- ].join(`
19523
+ return ["vibestd was not stopped; still in use by:", ...this.blockers.map((b) => ` ${b.id}: ${b.reason}`)].join(`
19434
19524
  `);
19435
19525
  }
19436
19526
  }
19437
19527
 
19438
- class WrongInstance extends TaggedError3()("WrongInstance", { expected: String6, actual: NullOr(String6) }) {
19528
+ class WrongInstance extends TaggedError3()("WrongInstance", {
19529
+ expected: String6,
19530
+ actual: NullOr(String6)
19531
+ }) {
19439
19532
  get message() {
19440
19533
  return `vibestd instance ${this.actual ?? "unknown"} answers, not ${this.expected}; nothing was stopped`;
19441
19534
  }
@@ -19458,7 +19551,12 @@ class CallerGate extends Service2()("vibest/CallerGate", {
19458
19551
  var protocol = (rpc) => rpc.middleware(ProtocolGate);
19459
19552
  var admitted = (rpc) => rpc.middleware(Admission);
19460
19553
  var scoped4 = (rpc) => rpc.middleware(CallerGate).middleware(ProtocolGate);
19461
- var GitInfo = Struct({ branch: String6, pushed: Boolean3, saved: Boolean3, why: String6 });
19554
+ var GitInfo = Struct({
19555
+ branch: String6,
19556
+ pushed: Boolean3,
19557
+ saved: Boolean3,
19558
+ why: String6
19559
+ });
19462
19560
  var SessionInfo = Struct({
19463
19561
  id: String6,
19464
19562
  name: String6,
@@ -19488,17 +19586,6 @@ var SessionInfo = Struct({
19488
19586
  });
19489
19587
  var InboxMessage = Struct({ ...InboxRow.fields, details: Record(String6, Unknown2) });
19490
19588
  var SessionStatusInfo = Struct({ ...SessionInfo.fields, result: NullOr(InboxMessage) });
19491
- var InboxResult = Struct({
19492
- generation: optional2(String6),
19493
- token: optional2(String6),
19494
- file: optional2(String6),
19495
- acked: optional2(Boolean3),
19496
- released: optional2(Boolean3),
19497
- already: optional2(Boolean3),
19498
- empty: optional2(Boolean3),
19499
- error: optional2(String6),
19500
- bytes: optional2(Number6)
19501
- });
19502
19589
 
19503
19590
  class VibestRpcs extends make31(make29("Ping", { success: PingResult }), scoped4(admitted(make29("Spawn", {
19504
19591
  payload: {
@@ -19520,17 +19607,41 @@ class VibestRpcs extends make31(make29("Ping", { success: PingResult }), scoped4
19520
19607
  model: optional2(String6),
19521
19608
  ...Routing.fields
19522
19609
  }),
19523
- error: Union2([InvalidCaller, Forbidden2, LimitReached, AllocationFailed, HarnessUnavailable, NotInRepository, NoHarnessChosen, NoRuntime, AgentRefused, NoSuchSession, RuntimeUnreachable, RuntimeIncompatible])
19524
- }))), protocol(make29("Plugins", { success: ArraySchema(PluginInfo) })), protocol(make29("Runtimes.Doctor", { payload: { harnesses: ArraySchema(String6) }, success: ArraySchema(RuntimeDoctor) })), protocol(make29("Subscriptions", { success: ArraySchema(Subscription) })), protocol(make29("Republish", { success: Number6 })), scoped4(admitted(make29("Launch", {
19610
+ error: Union2([
19611
+ InvalidCaller,
19612
+ Forbidden2,
19613
+ LimitReached,
19614
+ AllocationFailed,
19615
+ HarnessUnavailable,
19616
+ NotInRepository,
19617
+ NoHarnessChosen,
19618
+ NoRuntime,
19619
+ AgentRefused,
19620
+ NoSuchSession,
19621
+ RuntimeUnreachable,
19622
+ RuntimeIncompatible
19623
+ ])
19624
+ }))), protocol(make29("Plugins", { success: ArraySchema(PluginInfo) })), protocol(make29("Runtimes.Doctor", {
19625
+ payload: { harnesses: ArraySchema(String6) },
19626
+ success: ArraySchema(RuntimeDoctor)
19627
+ })), protocol(make29("Subscriptions", { success: ArraySchema(Subscription) })), protocol(make29("Republish", { success: Number6 })), scoped4(admitted(make29("Launch", {
19525
19628
  payload: {
19526
19629
  argv: ArraySchema(String6),
19527
19630
  focus: Boolean3,
19528
19631
  machine: optional2(RuntimeMachine),
19529
19632
  runtime: optional2(String6)
19530
19633
  },
19531
- success: Struct({ runtime: String6, terminal: String6, place: String6, attach: NullOr(ArraySchema(String6)) }),
19634
+ success: Struct({
19635
+ runtime: String6,
19636
+ terminal: String6,
19637
+ place: String6,
19638
+ attach: NullOr(ArraySchema(String6))
19639
+ }),
19532
19640
  error: Union2([InvalidCaller, Forbidden2, NotInRepository, LaunchFailed, NoRuntime, AgentRefused])
19533
- }))), scoped4(admitted(make29("Send", { payload: { id: String6, message: String6 }, error: Union2([Forbidden2, NoSuchSession]) }))), scoped4(admitted(make29("Interrupt", {
19641
+ }))), scoped4(admitted(make29("Send", {
19642
+ payload: { id: String6, message: String6 },
19643
+ error: Union2([Forbidden2, NoSuchSession])
19644
+ }))), scoped4(admitted(make29("Interrupt", {
19534
19645
  payload: { id: String6 },
19535
19646
  success: Struct({ message: String6 }),
19536
19647
  error: Union2([Forbidden2, NoSuchSession, SessionBusy, RuntimeUnreachable, NoRuntime])
@@ -19542,23 +19653,15 @@ class VibestRpcs extends make31(make29("Ping", { success: PingResult }), scoped4
19542
19653
  payload: { stopped: optional2(Boolean3), all: optional2(Boolean3) },
19543
19654
  success: ArraySchema(SessionInfo),
19544
19655
  error: Union2([Forbidden2])
19545
- })), scoped4(make29("Get", { payload: { id: String6 }, success: SessionStatusInfo, error: Union2([Forbidden2, NoSuchSession]) })), scoped4(admitted(make29("Report", { payload: { message: String6 }, error: Union2([Forbidden2, NoSuchSession]) }))), scoped4(make29("Inbox.Subscribe", { success: String6, error: Union2([Forbidden2]), stream: true })), scoped4(admitted(make29("Inbox.Attach", {
19546
- payload: { claudeSessionId: String6, replace: Boolean3, terminal: String6, machine: optional2(RuntimeMachine) },
19547
- success: InboxResult,
19548
- error: Union2([InvalidCaller, Forbidden2, RuntimeUnreachable, RuntimeIncompatible])
19549
- }))), scoped4(admitted(make29("Inbox.Pull", {
19550
- payload: { generation: String6, claudeSessionId: String6, terminal: String6, machine: optional2(RuntimeMachine) },
19551
- success: InboxResult,
19552
- error: Union2([InvalidCaller, Forbidden2, RuntimeUnreachable, RuntimeIncompatible])
19553
- }))), scoped4(admitted(make29("Inbox.Ack", {
19554
- payload: { generation: String6, claudeSessionId: String6, token: String6, terminal: String6, machine: optional2(RuntimeMachine) },
19555
- success: InboxResult,
19556
- error: Union2([InvalidCaller, Forbidden2, RuntimeUnreachable, RuntimeIncompatible])
19557
- }))), scoped4(admitted(make29("Inbox.Release", {
19558
- payload: { generation: String6, claudeSessionId: String6, token: String6, retry: Boolean3, terminal: String6, machine: optional2(RuntimeMachine) },
19559
- success: InboxResult,
19560
- error: Union2([InvalidCaller, Forbidden2, RuntimeUnreachable, RuntimeIncompatible])
19561
- }))), protocol(admitted(make29("ResultReady", { payload: { sessionId: String6 } }))), protocol(admitted(make29("Prompt", { payload: { sessionId: String6, text: String6 } }))), scoped4(admitted(make29("Project.CoordinatorSession", {
19656
+ })), scoped4(make29("Get", {
19657
+ payload: { id: String6 },
19658
+ success: SessionStatusInfo,
19659
+ error: Union2([Forbidden2, NoSuchSession])
19660
+ })), scoped4(make29("Peek", {
19661
+ payload: { id: String6, lines: optional2(Number6) },
19662
+ success: Struct({ text: String6 }),
19663
+ error: Union2([Forbidden2, NoSuchSession, NoRuntime, RuntimeUnreachable])
19664
+ })), scoped4(admitted(make29("Report", { payload: { message: String6 }, error: Union2([Forbidden2, NoSuchSession]) }))), scoped4(make29("Inbox.Subscribe", { success: String6, error: Union2([Forbidden2]), stream: true })), protocol(admitted(make29("ResultReady", { payload: { sessionId: String6 } }))), protocol(admitted(make29("Prompt", { payload: { sessionId: String6, text: String6 } }))), scoped4(admitted(make29("Project.CoordinatorSession", {
19562
19665
  payload: {
19563
19666
  harness: Literals(HARNESS_IDS),
19564
19667
  fresh: Boolean3,
@@ -19567,9 +19670,16 @@ class VibestRpcs extends make31(make29("Ping", { success: PingResult }), scoped4
19567
19670
  runtime: optional2(String6),
19568
19671
  provider: optional2(String6),
19569
19672
  model: optional2(String6),
19570
- routing: optional2(Routing)
19673
+ routing: optional2(Routing),
19674
+ pid: optional2(Number6),
19675
+ env: optional2(Record(String6, String6))
19571
19676
  },
19572
- success: Struct({ sessionId: String6, harnessSessionId: NullOr(String6) }),
19677
+ success: Struct({
19678
+ sessionId: String6,
19679
+ harnessSessionId: NullOr(String6),
19680
+ projectId: optional2(Number6),
19681
+ runtime: optional2(String6)
19682
+ }),
19573
19683
  error: Union2([InvalidCaller, Forbidden2, NotInRepository, RuntimeUnreachable, RuntimeIncompatible])
19574
19684
  }))), scoped4(make29("Project.StartMain", {
19575
19685
  payload: {
@@ -19585,14 +19695,30 @@ class VibestRpcs extends make31(make29("Ping", { success: PingResult }), scoped4
19585
19695
  runtime: String6,
19586
19696
  ...Routing.fields
19587
19697
  }),
19588
- error: Union2([InvalidCaller, Forbidden2, NotInRepository, NoHarnessChosen, AgentRefused, HarnessUnavailable, NoRuntime])
19698
+ error: Union2([
19699
+ InvalidCaller,
19700
+ Forbidden2,
19701
+ NotInRepository,
19702
+ NoHarnessChosen,
19703
+ AgentRefused,
19704
+ HarnessUnavailable,
19705
+ NoRuntime
19706
+ ])
19589
19707
  })), scoped4(make29("Project.RunningCoordinator", {
19590
19708
  payload: { terminal: String6, machine: optional2(RuntimeMachine) },
19591
- success: NullOr(Struct({ harness: Literals(HARNESS_IDS), place: String6, runtime: String6, address: String6 })),
19709
+ success: NullOr(Struct({
19710
+ harness: Literals(HARNESS_IDS),
19711
+ place: String6,
19712
+ runtime: String6,
19713
+ address: String6
19714
+ })),
19592
19715
  error: Union2([InvalidCaller, Forbidden2, NotInRepository, RuntimeUnreachable, RuntimeIncompatible])
19593
19716
  })), scoped4(admitted(make29("Project.StopCoordinator", {
19594
19717
  payload: { runtime: String6, address: String6 },
19595
- success: Struct({ result: Literals(["stopped", "running", "moved"]) }),
19718
+ success: Struct({
19719
+ result: Literals(["stopped", "running", "moved", "unsupported"]),
19720
+ reason: optional2(String6)
19721
+ }),
19596
19722
  error: Union2([Forbidden2, NotInRepository, RuntimeUnreachable, NoRuntime, InvalidCaller])
19597
19723
  }))), protocol(admitted(make29("CoordinatorSessionReady", {
19598
19724
  payload: { sessionId: String6, harness: Literals(HARNESS_IDS), harnessSessionId: String6 }
@@ -19619,9 +19745,46 @@ class VibestRpcs extends make31(make29("Ping", { success: PingResult }), scoped4
19619
19745
  payload: { instance: String6 },
19620
19746
  success: Struct({ instance: String6 }),
19621
19747
  error: Union2([Forbidden2, WrongInstance, DaemonBusy, DaemonStopping])
19748
+ })), scoped4(make29("Daemon.Handoff", {
19749
+ payload: { instance: String6, command: ArraySchema(String6) },
19750
+ success: Struct({ instance: String6 }),
19751
+ error: Union2([Forbidden2, WrongInstance, DaemonBusy, DaemonStopping, LaunchFailed])
19752
+ })), scoped4(make29("Session.Start", {
19753
+ payload: { id: String6 },
19754
+ success: Struct({
19755
+ harness: Literals(HARNESS_IDS),
19756
+ harnessSessionId: NullOr(String6),
19757
+ provider: NullOr(String6),
19758
+ model: NullOr(String6),
19759
+ projectId: Number6,
19760
+ runtime: optional2(String6),
19761
+ env: Record(String6, String6)
19762
+ }),
19763
+ error: Union2([Forbidden2, NoSuchSession])
19764
+ })), scoped4(make29("Session.Ready", {
19765
+ payload: { id: String6, pid: optional2(Number6) },
19766
+ error: Union2([Forbidden2, NoSuchSession])
19767
+ })), scoped4(make29("Agents.Outdated", {
19768
+ success: ArraySchema(Struct({
19769
+ id: String6,
19770
+ agent: String6,
19771
+ harness: Literals(HARNESS_IDS),
19772
+ integration: NullOr(String6),
19773
+ working: Boolean3,
19774
+ blocked: NullOr(String6)
19775
+ })),
19776
+ error: Forbidden2
19777
+ })), scoped4(make29("Agents.Restart", {
19778
+ payload: { ids: ArraySchema(String6), after: optional2(Number6) },
19779
+ error: Forbidden2
19622
19780
  }))) {
19623
19781
  }
19624
19782
 
19783
+ // ../../client/src/client.ts
19784
+ init_layout();
19785
+ init_dist();
19786
+ init_process();
19787
+
19625
19788
  // ../../client/src/socket-connector.ts
19626
19789
  init_dist();
19627
19790
 
@@ -19631,7 +19794,10 @@ class SocketConnector extends Service()("vibest/SocketConnector") {
19631
19794
  // ../../client/src/client.ts
19632
19795
  var DAEMON_START_TIMEOUT = seconds(10);
19633
19796
 
19634
- class DaemonUnavailable extends TaggedError3()("DaemonUnavailable", { socket: String6, message: String6 }) {
19797
+ class DaemonUnavailable extends TaggedError3()("DaemonUnavailable", {
19798
+ socket: String6,
19799
+ message: String6
19800
+ }) {
19635
19801
  }
19636
19802
  var stopByHand = (socket, pid) => {
19637
19803
  const p = pid === undefined ? "<pid>" : String(pid);
@@ -19652,7 +19818,8 @@ class IncompatibleDaemon extends TaggedError3()("IncompatibleDaemon", {
19652
19818
  get message() {
19653
19819
  const got = this.daemonProtocol === null ? "no protocol" : `protocol ${this.daemonProtocol}`;
19654
19820
  const self = `vibest ${this.client.version} (${this.client.command.map(shellQuote).join(" ")})`;
19655
- return `${described(this.daemonVersion, this.daemon)} on ${this.socket} speaks ${got}; ${self} speaks protocol ${PROTOCOL}. To replace it: vibest daemon restart (or ${stopByHand(this.socket, this.daemon.pid).replace(/^To replace it, /, "")}). A package-version difference alone does not require a restart.`;
19821
+ const mismatch = protocolMismatch(PROTOCOL, this.daemonProtocol ?? 0, this.daemonVersion || "unknown", this.client.version);
19822
+ return `${mismatch.message}. ${described(this.daemonVersion, this.daemon)} on ${this.socket} speaks ${got}; ${self} speaks protocol ${PROTOCOL}. If \`vibest daemon restart\` cannot replace it: ${stopByHand(this.socket, this.daemon.pid).replace(/^To replace it, /, "")}. A package-version difference alone does not require a restart.`;
19656
19823
  }
19657
19824
  }
19658
19825
  var protocolHeaders = () => ({ [PROTOCOL_HEADER]: String(PROTOCOL) });
@@ -19661,13 +19828,23 @@ var cliHeaders = (repositoryRoot) => ({
19661
19828
  [CALLER_HEADER]: "cli",
19662
19829
  [REPOSITORY_HEADER]: repositoryRoot
19663
19830
  });
19664
- var sessionHeaders = (sessionId, repositoryRoot) => ({
19665
- ...protocolHeaders(),
19666
- [CALLER_HEADER]: "session",
19667
- [SESSION_HEADER]: sessionId,
19668
- ...repositoryRoot === undefined ? {} : { [REPOSITORY_HEADER]: repositoryRoot }
19669
- });
19670
- var claimHeaders = (claim) => claim._tag === "cli" ? cliHeaders(claim.repositoryRoot) : sessionHeaders(claim.sessionId, claim.repositoryRoot);
19831
+ var fromEnv2 = gen2(function* () {
19832
+ const read = (name) => option3(String7(name)).pipe(map7((v) => getOrUndefined(v) || undefined));
19833
+ return {
19834
+ projectId: yield* read("VIBEST_PROJECT_ID"),
19835
+ agent: yield* read("VIBEST_AGENT"),
19836
+ harness: yield* read("VIBEST_HARNESS"),
19837
+ runtime: yield* read("VIBEST_RUNTIME"),
19838
+ cwd: (yield* Path).resolve(".")
19839
+ };
19840
+ }).pipe(orElseSucceed2(() => ({})));
19841
+ var claimHeaders = (claim) => claim._tag === "cli" ? succeed7(cliHeaders(claim.repositoryRoot)) : map7(fromEnv2, (more) => sessionHeaders({
19842
+ ...more,
19843
+ sessionId: claim.sessionId,
19844
+ repositoryRoot: claim.repositoryRoot,
19845
+ harnessSessionId: claim.harnessSessionId,
19846
+ pluginVersion: claim.pluginVersion
19847
+ }));
19671
19848
  var connect2 = (socket) => build(layerProtocolSocket({ pingInterval: "1 minute", pingTimeout: "1 day" }).pipe(provide2(effect(Socket, flatMap4(SocketConnector, (dial) => dial(socket)))), provide2(layerNdJsonRpc()))).pipe(flatMap4((protocol) => make30(VibestRpcs).pipe(provide4(protocol))));
19672
19849
  var readPing = (socket) => connect2(socket).pipe(flatMap4((client) => client.Ping(undefined)), timeout2("1 second"), option2, scoped2);
19673
19850
  var probe = (socket) => readPing(socket).pipe(map7(isSome2), orElseSucceed2(() => false));
@@ -19679,16 +19856,22 @@ var incompatibleDaemon = (socket, ping, self) => ping.protocol === PROTOCOL ? un
19679
19856
  daemon: { pid: ping.pid, instance: ping.instance, command: ping.command, startedAt: ping.startedAt },
19680
19857
  client: { version: VERSION, command: self }
19681
19858
  });
19682
- var startDaemon = gen2(function* () {
19859
+ var spawnDaemon = (command, args = []) => gen2(function* () {
19683
19860
  const layout = yield* Layout;
19684
19861
  const path = yield* Path;
19685
19862
  const spawner = yield* ChildProcessSpawner;
19686
- const self = yield* VibestCommand;
19687
- const fs = yield* FileSystem;
19688
19863
  const log = path.join(layout.home, "vibestd.log");
19689
- const logAt = yield* fs.stat(log).pipe(map7((info) => Number(info.size)), orElseSucceed2(() => 0));
19690
19864
  yield* gen2(function* () {
19691
- const handle = yield* spawner.spawn(make17("sh", ["-c", `mkdir -p "$1" && shift && exec "$@" >>"${log}" 2>&1`, "sh", layout.home, ...self, "daemon", "--foreground"], {
19865
+ const handle = yield* spawner.spawn(make17("sh", [
19866
+ "-c",
19867
+ `mkdir -p "$1" && shift && exec "$@" >>"${log}" 2>&1`,
19868
+ "sh",
19869
+ layout.home,
19870
+ ...command,
19871
+ "daemon",
19872
+ "--foreground",
19873
+ ...args
19874
+ ], {
19692
19875
  detached: true,
19693
19876
  stdin: "ignore",
19694
19877
  stdout: "ignore",
@@ -19696,6 +19879,14 @@ var startDaemon = gen2(function* () {
19696
19879
  }));
19697
19880
  yield* handle.unref;
19698
19881
  }).pipe(scoped2, mapError3((e) => new DaemonUnavailable({ socket: layout.socket, message: e.message })));
19882
+ });
19883
+ var startDaemon = gen2(function* () {
19884
+ const layout = yield* Layout;
19885
+ const path = yield* Path;
19886
+ const fs = yield* FileSystem;
19887
+ const log = path.join(layout.home, "vibestd.log");
19888
+ const logAt = yield* fs.stat(log).pipe(map7((info) => Number(info.size)), orElseSucceed2(() => 0));
19889
+ yield* spawnDaemon(yield* VibestCommand);
19699
19890
  if (yield* awaitDaemon(layout.socket))
19700
19891
  return;
19701
19892
  const bytes = yield* fs.readFile(log).pipe(orElseSucceed2(() => new Uint8Array));
@@ -19712,16 +19903,22 @@ var withVibest = (claim, f, options) => gen2(function* () {
19712
19903
  const up = yield* readPing(layout.socket);
19713
19904
  if (isNone2(up)) {
19714
19905
  if (options?.start === false)
19715
- return yield* new DaemonUnavailable({ socket: layout.socket, message: `vibestd is unreachable on ${layout.socket} (not running, or this process may not connect to its socket); ask the user to check it, or to run: vibest daemon` });
19906
+ return yield* new DaemonUnavailable({
19907
+ socket: layout.socket,
19908
+ message: `vibestd is unreachable on ${layout.socket} (not running, or this process may not connect to its socket); ask the user to check it, or to run: vibest daemon`
19909
+ });
19716
19910
  yield* startDaemon;
19717
19911
  }
19718
19912
  const ping = isSome2(up) ? up.value : getOrUndefined(yield* readPing(layout.socket));
19719
19913
  if (ping === undefined)
19720
- return yield* new DaemonUnavailable({ socket: layout.socket, message: `vibestd did not answer Ping on ${layout.socket}` });
19914
+ return yield* new DaemonUnavailable({
19915
+ socket: layout.socket,
19916
+ message: `vibestd did not answer Ping on ${layout.socket}`
19917
+ });
19721
19918
  const incompatible = incompatibleDaemon(layout.socket, ping, yield* VibestCommand);
19722
19919
  if (incompatible)
19723
19920
  return yield* incompatible;
19724
- return yield* withHeaders(connect2(layout.socket).pipe(flatMap4((client) => f(client))), claimHeaders(claim));
19921
+ return yield* withHeaders(connect2(layout.socket).pipe(flatMap4((client) => f(client))), yield* claimHeaders(claim));
19725
19922
  }).pipe(scoped2);
19726
19923
 
19727
19924
  // ../../core/src/guard.ts
@@ -19773,7 +19970,21 @@ var interactive = gen2(function* () {
19773
19970
  });
19774
19971
 
19775
19972
  // ../../core/src/guard.ts
19776
- var PATH_TOOLS = new Set(["read", "write", "edit", "multiedit", "notebookedit", "ls", "grep", "glob", "find", "delete", "list", "readlints"]);
19973
+ var PATH_TOOLS = new Set([
19974
+ "read",
19975
+ "write",
19976
+ "edit",
19977
+ "multiedit",
19978
+ "notebookedit",
19979
+ "notebookread",
19980
+ "ls",
19981
+ "grep",
19982
+ "glob",
19983
+ "find",
19984
+ "delete",
19985
+ "list",
19986
+ "readlints"
19987
+ ]);
19777
19988
  var SEARCH_TOOLS = new Set(["grep", "glob", "find"]);
19778
19989
  var EDIT_TOOLS = new Set(["write", "edit", "multiedit", "notebookedit"]);
19779
19990
  var fileWritingTool = (tool) => {
@@ -19959,6 +20170,8 @@ var shellBlock = (command, vibest, coordinator) => {
19959
20170
  const name = base(program);
19960
20171
  if (name === "herdr" && HERDR_CONTROL.has(firstWord(rest)))
19961
20172
  return "Agents must not control herdr agents, panes, tabs, workspaces or worktrees; vibest manages them.";
20173
+ if (name === "herdr" && !coordinator)
20174
+ return "Sessions do not run herdr; vibest manages it.";
19962
20175
  if (coordinator && HARNESS_CLIS.has(name))
19963
20176
  return `The coordinator does not start ${name} itself: it would inherit the coordinator's identity and report its turns as the coordinator's. Start agents with vibest run.`;
19964
20177
  if (coordinator && name === "gh" && GH_UNSAFE.has(firstWord(rest)))
@@ -20025,18 +20238,16 @@ var session = fn2("Guard.session")(function* (call) {
20025
20238
  const layout = yield* Layout;
20026
20239
  const projects = yield* physical(layout.projects);
20027
20240
  const vibestHome = yield* physical(layout.home);
20028
- const projectsRoot = path.join(vibestHome, "projects");
20029
- const inScratch = (target) => {
20030
- const rel = path.relative(projectsRoot, target);
20031
- return rel !== "" && !rel.startsWith("..") && !path.isAbsolute(rel) && rel.split(path.sep).includes("scratch");
20032
- };
20241
+ const own = getOrUndefined(yield* option3(String7("VIBEST_SCRATCH")));
20242
+ const scratch = own ? yield* physical(own) : undefined;
20033
20243
  const inside = (p, dir) => p === dir || p.startsWith(dir + path.sep);
20244
+ const inScratch = (target) => scratch !== undefined && inside(target, scratch);
20034
20245
  const resolve = (raw) => gen2(function* () {
20035
20246
  const p = yield* toolPath(raw, call.cwd, home);
20036
20247
  return p === undefined ? undefined : [yield* physical(p), yield* physical(path.normalize(p))];
20037
20248
  });
20038
20249
  const BAD_URL = "The call names a file URL vibest cannot read; refused.";
20039
- const blocked = (target, search) => (inScratch(target) ? false : inside(target, projects)) || search && inside(projects, target);
20250
+ const blocked = (target, search) => search && inside(projects, target) || inside(target, projects) && !inScratch(target);
20040
20251
  const tool = call.tool.toLowerCase();
20041
20252
  if (SHELL_TOOLS.has(tool)) {
20042
20253
  const command = shellCommand(call.input);
@@ -20100,7 +20311,12 @@ var encodeReportLine = (line) => `${JSON.stringify(line)}
20100
20311
  `;
20101
20312
  var ReportLineJson = fromJsonString2(Union2([
20102
20313
  Struct({ turn: Literals(["start"]), ts: Number6, prompt: String6 }),
20103
- Struct({ turn: Literals(["end"]), ts: Number6, harness: Literals(HARNESS_IDS), payload: Record(String6, Unknown2) })
20314
+ Struct({
20315
+ turn: Literals(["end"]),
20316
+ ts: Number6,
20317
+ harness: Literals(HARNESS_IDS),
20318
+ payload: Record(String6, Unknown2)
20319
+ })
20104
20320
  ]));
20105
20321
  var appendReportLine = (file, line) => gen2(function* () {
20106
20322
  const fs = yield* FileSystem;
@@ -20129,15 +20345,14 @@ var readResult = fn2("readResult")(function* (file) {
20129
20345
  mtimeMs: match(info.mtime, { onNone: () => 0, onSome: (d) => d.getTime() }),
20130
20346
  text: typeof text === "string" ? text : "",
20131
20347
  error: typeof error === "string" && error ? typeof details === "string" && details ? `${error}: ${details}` : error : undefined,
20132
- conversationId: typeof conversation === "string" && /^\w[\w.:-]{0,127}$/.test(conversation) ? conversation : undefined
20348
+ conversationId: typeof conversation === "string" && /^\w[\w.:-]{0,127}$/.test(conversation) ? conversation : undefined,
20349
+ interrupted: envelope.payload.aborted === true
20133
20350
  };
20134
20351
  }).pipe(option2);
20135
20352
  });
20136
20353
 
20137
20354
  // src/extension.ts
20138
20355
  init_dist();
20139
- import path from "node:path";
20140
- import url from "node:url";
20141
20356
 
20142
20357
  // src/pi.ts
20143
20358
  init_dist();
@@ -20377,7 +20592,13 @@ function tool_groups_default(pi) {
20377
20592
  for (const call of nested) {
20378
20593
  if (!call?.id || calls.has(call.id))
20379
20594
  continue;
20380
- remember(call.id, { name: call.name, args: call.arguments, parentId: message.toolCallId, isError: call.status === "error", isPartial: call.status === "unfinished" });
20595
+ remember(call.id, {
20596
+ name: call.name,
20597
+ args: call.arguments,
20598
+ parentId: message.toolCallId,
20599
+ isError: call.status === "error",
20600
+ isPartial: call.status === "unfinished"
20601
+ });
20381
20602
  }
20382
20603
  return;
20383
20604
  }
@@ -20485,7 +20706,18 @@ function tool_groups_default(pi) {
20485
20706
  const search = named("tool_search").length;
20486
20707
  if (search)
20487
20708
  parts.push(times(search, "tool search", "tool searches"));
20488
- const known = new Set(["codemode", "read", "write", "edit", "bash", "powershell", "grep", "find", "ls", "tool_search"]);
20709
+ const known = new Set([
20710
+ "codemode",
20711
+ "read",
20712
+ "write",
20713
+ "edit",
20714
+ "bash",
20715
+ "powershell",
20716
+ "grep",
20717
+ "find",
20718
+ "ls",
20719
+ "tool_search"
20720
+ ]);
20489
20721
  const other = all.filter((item) => item.name && !known.has(item.name)).length;
20490
20722
  if (other)
20491
20723
  parts.push(times(other, "other tool call", "other tool calls"));
@@ -20659,12 +20891,24 @@ function tool_groups_default(pi) {
20659
20891
  if (!event?.toolCallId)
20660
20892
  return;
20661
20893
  runActive = true;
20662
- remember(event.toolCallId, { name: event.toolName, args: event.args, parentId: event.parentToolCallId, isPartial: true });
20894
+ remember(event.toolCallId, {
20895
+ name: event.toolName,
20896
+ args: event.args,
20897
+ parentId: event.parentToolCallId,
20898
+ isPartial: true
20899
+ });
20663
20900
  });
20664
20901
  pi.on("tool_execution_end", (event) => {
20665
20902
  if (!event?.toolCallId)
20666
20903
  return;
20667
- remember(event.toolCallId, { name: event.toolName, args: event.args, parentId: event.parentToolCallId, isError: event.isError === true, isPartial: false, result: event.result });
20904
+ remember(event.toolCallId, {
20905
+ name: event.toolName,
20906
+ args: event.args,
20907
+ parentId: event.parentToolCallId,
20908
+ isError: event.isError === true,
20909
+ isPartial: false,
20910
+ result: event.result
20911
+ });
20668
20912
  });
20669
20913
  pi.registerToolRenderer((toolName, next) => {
20670
20914
  const later = next();
@@ -20697,15 +20941,21 @@ function tool_groups_default(pi) {
20697
20941
  let native;
20698
20942
  if (renderers?.renderCall) {
20699
20943
  try {
20700
- native = renderers.renderCall(args, theme, { ...ctx, expanded: true, lastComponent: ctx.lastComponent?.native });
20944
+ native = renderers.renderCall(args, theme, {
20945
+ ...ctx,
20946
+ expanded: true,
20947
+ lastComponent: ctx.lastComponent?.native
20948
+ });
20701
20949
  } catch {
20702
20950
  native = undefined;
20703
20951
  }
20704
20952
  }
20705
- const body = native ? frameComponent(renderers, native, ctx.outputPad) : { render(innerWidth) {
20706
- const { pad, limit } = gutter(innerWidth, ctx.outputPad);
20707
- return indent(plainCall(toolName, args, limit), pad);
20708
- } };
20953
+ const body = native ? frameComponent(renderers, native, ctx.outputPad) : {
20954
+ render(innerWidth) {
20955
+ const { pad, limit } = gutter(innerWidth, ctx.outputPad);
20956
+ return indent(plainCall(toolName, args, limit), pad);
20957
+ }
20958
+ };
20709
20959
  return {
20710
20960
  native,
20711
20961
  invalidate() {
@@ -20762,15 +21012,20 @@ function tool_groups_default(pi) {
20762
21012
  let native;
20763
21013
  if (renderers?.renderResult) {
20764
21014
  try {
20765
- native = renderers.renderResult(result, { ...options, expanded: true }, theme, { ...ctx, lastComponent: ctx.lastComponent?.native });
21015
+ native = renderers.renderResult(result, { ...options, expanded: true }, theme, {
21016
+ ...ctx,
21017
+ lastComponent: ctx.lastComponent?.native
21018
+ });
20766
21019
  } catch {
20767
21020
  native = undefined;
20768
21021
  }
20769
21022
  }
20770
- const body = native ? frameComponent(renderers, native, ctx.outputPad) : { render(innerWidth) {
20771
- const { pad, limit } = gutter(innerWidth, ctx.outputPad);
20772
- return indent(plainResult(result, ctx.isError, limit), pad);
20773
- } };
21023
+ const body = native ? frameComponent(renderers, native, ctx.outputPad) : {
21024
+ render(innerWidth) {
21025
+ const { pad, limit } = gutter(innerWidth, ctx.outputPad);
21026
+ return indent(plainResult(result, ctx.isError, limit), pad);
21027
+ }
21028
+ };
20774
21029
  return {
20775
21030
  native,
20776
21031
  invalidate() {
@@ -20797,7 +21052,12 @@ function readLease(proto) {
20797
21052
  }
20798
21053
  function writeLease(proto, lease) {
20799
21054
  if (lease)
20800
- Object.defineProperty(proto, "vibestCompactUserMessagesLease", { value: lease, configurable: true, enumerable: false, writable: false });
21055
+ Object.defineProperty(proto, "vibestCompactUserMessagesLease", {
21056
+ value: lease,
21057
+ configurable: true,
21058
+ enumerable: false,
21059
+ writable: false
21060
+ });
20801
21061
  else
20802
21062
  delete proto.vibestCompactUserMessagesLease;
20803
21063
  }
@@ -20958,6 +21218,12 @@ var lastReply = (messages) => {
20958
21218
  const text = (message?.content ?? []).flatMap((c) => c.type === "text" ? [c.text] : []).join("");
20959
21219
  return { text, error: message?.stopReason === "error" ? message.errorMessage || "error" : "" };
20960
21220
  };
21221
+ var piHeaders = (sessionId, ctx) => claimHeaders({
21222
+ _tag: "session",
21223
+ sessionId,
21224
+ harnessSessionId: ctx.sessionManager.getSessionId(),
21225
+ pluginVersion: VERSION
21226
+ });
20961
21227
  var session2 = (sessionId) => effectDiscard(gen2(function* () {
20962
21228
  const pi = yield* Pi;
20963
21229
  const layout = yield* Layout;
@@ -20965,11 +21231,16 @@ var session2 = (sessionId) => effectDiscard(gen2(function* () {
20965
21231
  const reply = yield* make28({ text: "", error: "" });
20966
21232
  yield* pi.handle("session_start", (_e, ctx) => set2(root, ctx.mode === "tui"));
20967
21233
  yield* pi.handle("agent_end", (e) => set2(reply, lastReply(e.messages)));
20968
- yield* pi.handle("input", (e) => gen2(function* () {
21234
+ yield* pi.handle("input", (e, ctx) => gen2(function* () {
20969
21235
  if (e.source === "extension" || e.text.trim() === "")
20970
21236
  return;
20971
- yield* connect2(layout.socket).pipe(flatMap4((client) => client.Prompt({ sessionId, text: e.text }, { headers: protocolHeaders() })), scoped2, timeout2("500 millis"), ignore2);
20972
- yield* appendReportLine(layout.reportFile(sessionId), { turn: "start", ts: yield* currentTimeMillis2, prompt: e.text });
21237
+ const headers = yield* piHeaders(sessionId, ctx);
21238
+ yield* connect2(layout.socket).pipe(flatMap4((client) => client.Prompt({ sessionId, text: e.text }, { headers })), scoped2, timeout2("500 millis"), ignore2);
21239
+ yield* appendReportLine(layout.reportFile(sessionId), {
21240
+ turn: "start",
21241
+ ts: yield* currentTimeMillis2,
21242
+ prompt: e.text
21243
+ });
20973
21244
  yield* writeTerminalStatus("working");
20974
21245
  }));
20975
21246
  yield* pi.handle("agent_settled", (e, ctx) => gen2(function* () {
@@ -20979,9 +21250,15 @@ var session2 = (sessionId) => effectDiscard(gen2(function* () {
20979
21250
  const ts = Math.floor((yield* currentTimeMillis2) / 1000);
20980
21251
  const payload = { text, error: error || (e.aborted ? "aborted" : ""), aborted: e.aborted };
20981
21252
  yield* writeAtomic(layout.resultFile(sessionId), encodeJson({ harness: "pi", ts, payload }));
20982
- yield* appendReportLine(layout.reportFile(sessionId), { turn: "end", ts: yield* currentTimeMillis2, harness: "pi", payload });
21253
+ yield* appendReportLine(layout.reportFile(sessionId), {
21254
+ turn: "end",
21255
+ ts: yield* currentTimeMillis2,
21256
+ harness: "pi",
21257
+ payload
21258
+ });
20983
21259
  yield* writeTerminalStatus("idle");
20984
- yield* connect2(layout.socket).pipe(flatMap4((client) => client.ResultReady({ sessionId }, { headers: protocolHeaders() })), scoped2, timeout2("500 millis"), ignore2);
21260
+ const headers = yield* piHeaders(sessionId, ctx);
21261
+ yield* connect2(layout.socket).pipe(flatMap4((client) => client.ResultReady({ sessionId }, { headers })), scoped2, timeout2("500 millis"), ignore2);
20985
21262
  }));
20986
21263
  }));
20987
21264
  var reportSession = fn2("reportSession")(function* (sessionId) {
@@ -20993,7 +21270,8 @@ var reportSession = fn2("reportSession")(function* (sessionId) {
20993
21270
  const harnessSessionId = ctx.sessionManager.getSessionId();
20994
21271
  if (ctx.mode !== "tui" || (yield* get2(reported)) === harnessSessionId)
20995
21272
  return;
20996
- yield* connect2(layout.socket).pipe(flatMap4((client) => client.CoordinatorSessionReady({ sessionId, harness: "pi", harnessSessionId }, { headers: protocolHeaders() })), scoped2, timeout2("1 second"), andThen2(set2(reported, harnessSessionId)), catchCause2((cause) => hasInterruptsOnly2(cause) ? void_3 : sync2(() => ctx.ui.notify(`vibest: the coordinator's conversation may not have been saved: ${pretty(cause)}`, "warning"))), forkIn2(scope));
21273
+ const headers = yield* piHeaders(sessionId, ctx);
21274
+ yield* connect2(layout.socket).pipe(flatMap4((client) => client.CoordinatorSessionReady({ sessionId, harness: "pi", harnessSessionId }, { headers })), scoped2, timeout2("1 second"), andThen2(set2(reported, harnessSessionId)), catchCause2((cause) => hasInterruptsOnly2(cause) ? void_3 : sync2(() => ctx.ui.notify(`vibest: the coordinator's conversation may not have been saved: ${pretty(cause)}`, "warning"))), forkIn2(scope));
20997
21275
  });
20998
21276
  yield* pi.handle("session_start", (event, ctx) => event.reason === "new" || event.reason === "resume" || event.reason === "fork" ? send(ctx) : void_3);
20999
21277
  yield* pi.handle("agent_end", (_event, ctx) => send(ctx));
@@ -21012,17 +21290,30 @@ var coordinator2 = effectDiscard(gen2(function* () {
21012
21290
  yield* reportSession(sessionId.value);
21013
21291
  const started = yield* make6();
21014
21292
  yield* pi.handle("session_start", (_e, ctx) => ctx.mode === "tui" ? succeed4(started, ctx).pipe(asVoid2) : void_3);
21015
- const subscribe = withVibest({ _tag: "session", sessionId: sessionId.value }, (client) => client["Inbox.Subscribe"](undefined).pipe(runForEach2((content) => pi.sendMessage({ customType: "vibest", content, display: false }, { triggerTurn: true, deliverAs: "followUp" }))), { start: false }).pipe(retry2({ while: (e) => e._tag === "RpcClientError" || e._tag === "DaemonUnavailable", schedule: spaced("2 seconds") }), repeat2(spaced("2 seconds")));
21016
- yield* _await(started).pipe(flatMap4((ctx) => subscribe.pipe(catchCause2((cause) => hasInterruptsOnly2(cause) ? void_3 : sync2(() => ctx.ui.notify(`vibest: inbox subscription ended: ${pretty(cause)}`, "error"))))), forkScoped2);
21293
+ const subscribe = (ctx) => withVibest({
21294
+ _tag: "session",
21295
+ sessionId: sessionId.value,
21296
+ harnessSessionId: ctx.sessionManager.getSessionId(),
21297
+ pluginVersion: VERSION
21298
+ }, (client) => client["Inbox.Subscribe"](undefined).pipe(runForEach2((content) => pi.sendMessage({ customType: "vibest", content, display: false }, { triggerTurn: true, deliverAs: "followUp" })), catchCause2((cause) => hasInterruptsOnly2(cause) ? void_3 : failCause3(cause))), { start: false }).pipe(retry2({
21299
+ while: (e) => e._tag === "RpcClientError" || e._tag === "DaemonUnavailable",
21300
+ schedule: spaced("2 seconds")
21301
+ }), repeat2(spaced("2 seconds")));
21302
+ yield* _await(started).pipe(flatMap4((ctx) => subscribe(ctx).pipe(catchCause2((cause) => hasInterruptsOnly2(cause) ? void_3 : sync2(() => ctx.ui.notify(`vibest: inbox subscription ended: ${pretty(cause)}`, "error"))))), forkScoped2);
21303
+ }));
21304
+ var ready = (sessionId) => effectDiscard(gen2(function* () {
21305
+ const pi = yield* Pi;
21306
+ yield* pi.handle("session_start", (_e, ctx) => ctx.mode !== "tui" ? void_3 : withVibest({ _tag: "session", sessionId, pluginVersion: VERSION }, (client) => client["Session.Ready"]({ id: sessionId, pid: process.pid }), { start: false }).pipe(timeout2("2 seconds"), ignore2));
21017
21307
  }));
21018
21308
  var extension2 = unwrap(gen2(function* () {
21019
21309
  const agent = getOrUndefined(yield* option3(String7("VIBEST_AGENT")));
21020
21310
  if (!agent)
21021
21311
  return empty4;
21022
- const guard = effectDiscard(guarded(rulesOf(agent)));
21312
+ const guarding = effectDiscard(guarded(rulesOf(agent)));
21313
+ const sessionId = getOrUndefined(yield* option3(String7("VIBEST_SESSION_ID")));
21314
+ const guard = sessionId ? merge2(guarding, ready(sessionId)) : guarding;
21023
21315
  if (agent === COORDINATOR)
21024
21316
  return coordinator2.pipe(provideMerge(guard));
21025
- const sessionId = getOrUndefined(yield* option3(String7("VIBEST_SESSION_ID")));
21026
21317
  return sessionId ? session2(sessionId).pipe(provideMerge(guard)) : guard;
21027
21318
  }));
21028
21319
  var vibestCommand = effect(VibestCommand, schema(fromJsonString2(ArraySchema(String6)), "VIBEST_COMMAND").pipe(withDefault3(["vibest"])));