@cotal-ai/connector-opencode 0.72.1 → 0.76.0

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.
package/dist/index.js CHANGED
@@ -17,13 +17,13 @@ import { DEFAULT_SERVER, DEV_OWNER, LAUNCH_MATERIAL_ENV as LAUNCH_MATERIAL_ENV2,
17
17
  import { LAUNCH_MATERIAL_ENV, readLaunchMaterial } from "@cotal-ai/core/launch-material";
18
18
 
19
19
  // ../connector-core/dist/agent.js
20
- import { normalizeMentions, RUN_LAUNCH_DEADLINE_MS, subjectMatches, isConcreteChannel as isConcreteChannel2, assertValidChannel as assertValidChannel2, channelInAllow as channelInAllow2, resolvePeer as resolvePeerInRoster, peerLabel as peerLabel2, CotalEndpoint, BASELINE_LIFECYCLE_ENDPOINT as BASELINE_LIFECYCLE_ENDPOINT2, BIND_SPLIT_REISSUES, assertLifecycleToken as assertLifecycleToken3, EpEnvelopeError, isPublishPermissionDenied, unansweredRequest, renderLifecycleBlocked, controlReplyFrom, runAgentBearer, partsToText, assertValidRole } from "@cotal-ai/core";
20
+ import { normalizeMentions, RUN_LAUNCH_DEADLINE_MS, subjectMatches, isConcreteChannel as isConcreteChannel2, assertValidChannel as assertValidChannel2, channelInAllow as channelInAllow2, resolvePeer as resolvePeerInRoster, peerLabel as peerLabel2, CotalEndpoint, acquireLocalConsumer, BASELINE_LIFECYCLE_ENDPOINT as BASELINE_LIFECYCLE_ENDPOINT2, BIND_SPLIT_REISSUES, assertLifecycleToken as assertLifecycleToken2, EpEnvelopeError, isPublishPermissionDenied, unansweredRequest, renderLifecycleBlocked, controlReplyFrom, runAgentBearer, partsToText, assertValidRole } from "@cotal-ai/core";
21
21
 
22
22
  // ../connector-core/dist/framing.js
23
23
  import { peerLabel } from "@cotal-ai/core";
24
24
 
25
25
  // ../connector-core/dist/manager-call.js
26
- import { BASELINE_LIFECYCLE_ENDPOINT, assertLifecycleToken as assertLifecycleToken2, dialerFor, goalFollowRefusal, invokeCommand, isPermissionDenied, issuedUserCaller, replyRefusedBeforeEffect, resolveService, standaloneConnectOpts } from "@cotal-ai/core";
26
+ import { BASELINE_LIFECYCLE_ENDPOINT, dialerFor, goalFollowRefusal, invokeCommand, isPermissionDenied, issuedUserCaller, managerCallerBinding, replyRefusedBeforeEffect, resolveService, standaloneConnectOpts } from "@cotal-ai/core";
27
27
 
28
28
  // ../connector-core/dist/runtime.js
29
29
  import { tmpdir } from "node:os";
@@ -145,11 +145,11 @@ function launchEnv(opts = {}) {
145
145
  }
146
146
  function aclEnv(opts) {
147
147
  const env = {};
148
- if (opts.subscribe?.length)
148
+ if (opts.subscribe)
149
149
  env.COTAL_SUBSCRIBE = opts.subscribe.join(",");
150
- if (opts.allowSubscribe?.length)
150
+ if (opts.allowSubscribe)
151
151
  env.COTAL_ALLOW_SUBSCRIBE = opts.allowSubscribe.join(",");
152
- if (opts.allowPublish?.length)
152
+ if (opts.allowPublish)
153
153
  env.COTAL_ALLOW_PUBLISH = opts.allowPublish.join(",");
154
154
  if (opts.capabilities?.length)
155
155
  env.COTAL_CAPABILITIES = opts.capabilities.join(",");
@@ -14866,7 +14866,7 @@ function date4(params) {
14866
14866
  config(en_default());
14867
14867
 
14868
14868
  // ../connector-core/dist/tool-specs.js
14869
- import { isConcreteChannel as isConcreteChannel3, channelInAllow as channelInAllow3, AmbiguousPeerError, peerLabel as peerLabel4, assertLifecycleToken as assertLifecycleToken4, isPermissionDenied as isPermissionDenied2, renderLifecycleBlocked as renderLifecycleBlocked2, LANG_PROBLEM_DETAIL_KIND, formatAge, presenceAges } from "@cotal-ai/core";
14869
+ import { isConcreteChannel as isConcreteChannel3, channelInAllow as channelInAllow3, AmbiguousPeerError, peerLabel as peerLabel4, assertLifecycleToken as assertLifecycleToken3, isPermissionDenied as isPermissionDenied2, renderLifecycleBlocked as renderLifecycleBlocked2, EpEnvelopeError as EpEnvelopeError2, LANG_PROBLEM_DETAIL_KIND, formatAge, presenceAges } from "@cotal-ai/core";
14870
14870
 
14871
14871
  // ../connector-core/dist/orientation.js
14872
14872
  import { peerLabel as peerLabel3 } from "@cotal-ai/core";
@@ -1 +1 @@
1
- {"version":3,"file":"launch.d.ts","sourceRoot":"","sources":["../src/launch.ts"],"names":[],"mappings":"AAgDA,eAAO,MAAM,GAAG,QAAuB,CAAC;AAqExC;kEACkE;AAClE,MAAM,MAAM,OAAO,GAAG,CAAC,MAAM,EAAE;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,CAAC,GAAG,CAAC,CAAA;CAAE,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,MAAM,EAAE,CAAC,CAAC;AAEtH;;0BAE0B;AAC1B,MAAM,MAAM,QAAQ,GAAG,CAAC,SAAS,EAAE,MAAM,KAAK,MAAM,CAAC,UAAU,CAAC;AAEhE,wBAAsB,MAAM,CAAC,OAAO,EAAE,OAAO,EAAE,QAAQ,CAAC,EAAE,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC,CA+IjF"}
1
+ {"version":3,"file":"launch.d.ts","sourceRoot":"","sources":["../src/launch.ts"],"names":[],"mappings":"AAgDA,eAAO,MAAM,GAAG,QAAuB,CAAC;AA2ExC;kEACkE;AAClE,MAAM,MAAM,OAAO,GAAG,CAAC,MAAM,EAAE;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,CAAC,GAAG,CAAC,CAAA;CAAE,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,MAAM,EAAE,CAAC,CAAC;AAEtH;;0BAE0B;AAC1B,MAAM,MAAM,QAAQ,GAAG,CAAC,SAAS,EAAE,MAAM,KAAK,MAAM,CAAC,UAAU,CAAC;AAEhE,wBAAsB,MAAM,CAAC,OAAO,EAAE,OAAO,EAAE,QAAQ,CAAC,EAAE,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC,CAqJjF"}
package/dist/launch.js CHANGED
@@ -3,7 +3,7 @@ import { execFileSync, spawn } from "node:child_process";
3
3
  import { createServer } from "node:net";
4
4
  import { once } from "node:events";
5
5
  import { randomBytes } from "node:crypto";
6
- import { existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from "node:fs";
6
+ import { existsSync, mkdirSync, readFileSync, rmdirSync, rmSync, writeFileSync } from "node:fs";
7
7
  import { delimiter, join } from "node:path";
8
8
 
9
9
  // src/opencode-line.ts
@@ -70,15 +70,18 @@ function processCommand(pid) {
70
70
  return void 0;
71
71
  }
72
72
  }
73
- function isLiveOpencodeServe(pid) {
74
- if (!Number.isInteger(pid) || pid <= 0) return false;
73
+ function pidAlive(pid) {
75
74
  try {
76
75
  process.kill(pid, 0);
76
+ return true;
77
77
  } catch {
78
78
  return false;
79
79
  }
80
+ }
81
+ function isLiveOpencodeServe(pid) {
82
+ if (!Number.isInteger(pid) || pid <= 0 || !pidAlive(pid)) return false;
80
83
  const cmd = processCommand(pid);
81
- if (!cmd) return true;
84
+ if (!cmd) return pidAlive(pid);
82
85
  return /\bserve\b/.test(cmd) && (/(?:^|[\\/\s])opencode(?:\.exe)?(?:\s|$)/i.test(cmd) || /--hostname\s+127\.0\.0\.1\b/.test(cmd) && /--port\s+\d+\b/.test(cmd));
83
86
  }
84
87
  async function launch(tuiArgv, serveEnv) {
@@ -92,7 +95,12 @@ async function launch(tuiArgv, serveEnv) {
92
95
  const pidFile = join(agentHome, "serve.pid");
93
96
  let recorded;
94
97
  try {
95
- recorded = readFileSync(pidFile, "utf8");
98
+ try {
99
+ recorded = readFileSync(pidFile, "utf8");
100
+ } catch (e) {
101
+ if (e.code !== "EISDIR") throw e;
102
+ rmdirSync(pidFile);
103
+ }
96
104
  } catch (e) {
97
105
  if (e.code !== "ENOENT") throw e;
98
106
  }