@bridgebrew/harness-opencode 0.0.5 → 0.0.8

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 (2) hide show
  1. package/package.json +4 -3
  2. package/server.ts +6 -4
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bridgebrew/harness-opencode",
3
- "version": "0.0.5",
3
+ "version": "0.0.8",
4
4
  "license": "MIT",
5
5
  "description": "Lets the harness run OpenCode 2, one server per session.",
6
6
  "keywords": [
@@ -52,7 +52,8 @@
52
52
  }
53
53
  }
54
54
  },
55
- "provenance": "official"
55
+ "provenance": "official",
56
+ "placement": "both"
56
57
  },
57
58
  "peerDependencies": {
58
59
  "cordis": "4.0.0-rc.11"
@@ -63,6 +64,6 @@
63
64
  "typecheck": "bridge plugin check ."
64
65
  },
65
66
  "engines": {
66
- "bridge": ">=0.0.1-nightly.20261114.1"
67
+ "bridge": ">=0.0.1-nightly.20261119.1"
67
68
  }
68
69
  }
package/server.ts CHANGED
@@ -37,6 +37,7 @@ import { randomBytes } from 'node:crypto';
37
37
  import { readFileSync } from 'node:fs';
38
38
  import { resolve } from 'node:path';
39
39
  import { pathToFileURL } from 'node:url';
40
+ import { stripVTControlCharacters } from 'node:util';
40
41
  import { isRecord, listOf } from './json.ts';
41
42
  import type { Context } from 'cordis';
42
43
  import { ApiError, connect, located, type Api, type Event, type Fetch } from './api.ts';
@@ -418,8 +419,7 @@ export const askTitle = (action: string, resources: string[]) => {
418
419
 
419
420
  /** The stderr tail an error message carries: its last lines. */
420
421
  const tailOf = (stderr: string) => {
421
- const lines = stderr
422
- .replace(/\x1b\[[0-9;]*m/g, '')
422
+ const lines = stripVTControlCharacters(stderr)
423
423
  .split('\n')
424
424
  .map((line) => line.trim())
425
425
  .filter(Boolean)
@@ -567,7 +567,7 @@ export const opencodeDriver = ({
567
567
  name: 'opencode',
568
568
  capabilities: () => ({ resume: true, images: true, models: true, modes: true, steer: true }),
569
569
  // `GET /api/model` from a throwaway server (its default marked current), kept `MODELS_TTL_MS` per setup. A list that
570
- // cannot be read is empty (and not kept): the entry's custom models still show.
570
+ // cannot be read, or lists nothing (a cold server), is empty and not kept: the entry's custom models still show.
571
571
  async models({ harness, config, cwd }) {
572
572
  let setup: Setup;
573
573
  try {
@@ -610,7 +610,9 @@ export const opencodeDriver = ({
610
610
  })();
611
611
  listed.set(key, { at: Date.now(), models });
612
612
  try {
613
- return await models;
613
+ const found = await models;
614
+ if (!found.length) listed.delete(key);
615
+ return found;
614
616
  } catch (error) {
615
617
  listed.delete(key);
616
618
  log.error(`harness ${harness}: OpenCode's models could not be listed`, error);