@cotal-ai/connector-core 0.84.0 → 0.86.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.d.ts CHANGED
@@ -16,6 +16,7 @@ export * from "./tool-specs.js";
16
16
  export * from "./orientation.js";
17
17
  export * from "./docs.js";
18
18
  export * from "./tools.js";
19
+ export * from "./gateway.js";
19
20
  export * from "./control.js";
20
21
  export * from "./relay.js";
21
22
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/D,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC;AAC1B,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC;AACpC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,uBAAuB,CAAC;AACtC,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC;AACjC,cAAc,oBAAoB,CAAC;AACnC,cAAc,cAAc,CAAC;AAC7B,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC;AACjC,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/D,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC;AAC1B,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC;AACpC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,uBAAuB,CAAC;AACtC,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC;AACjC,cAAc,oBAAoB,CAAC;AACnC,cAAc,cAAc,CAAC;AAC7B,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC;AACjC,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC"}
package/dist/index.js CHANGED
@@ -16,6 +16,7 @@ export * from "./tool-specs.js";
16
16
  export * from "./orientation.js";
17
17
  export * from "./docs.js";
18
18
  export * from "./tools.js";
19
+ export * from "./gateway.js";
19
20
  export * from "./control.js";
20
21
  export * from "./relay.js";
21
22
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/D,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC;AAC1B,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC;AACpC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,uBAAuB,CAAC;AACtC,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC;AACjC,cAAc,oBAAoB,CAAC;AACnC,cAAc,cAAc,CAAC;AAC7B,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC;AACjC,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/D,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC;AAC1B,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC;AACpC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,uBAAuB,CAAC;AACtC,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC;AACjC,cAAc,oBAAoB,CAAC;AACnC,cAAc,cAAc,CAAC;AAC7B,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC;AACjC,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC"}
package/dist/relay.d.ts CHANGED
@@ -1,3 +1,14 @@
1
- /** Relay one hook event from stdin to the connector's control socket and print the reply. */
2
- export declare function runHookRelay(): Promise<void>;
1
+ import { hasIdentity } from "./session-env.js";
2
+ /** Re-exported for a plugin process that must stay off the barrel, as a hook does. */
3
+ export { hasIdentity };
4
+ /** Answers one hook event inside the hook process, before the control socket is resolved. A reply
5
+ * is printed as the hook's output and the event is not relayed; `undefined` relays it as usual.
6
+ * It runs in every session. `managed` says whether the session carries a mesh identity, which is
7
+ * the only kind the relay forwards. */
8
+ export type LocalHookAnswer = (event: unknown, session: {
9
+ managed: boolean;
10
+ }) => Record<string, unknown> | undefined;
11
+ /** Relay one hook event from stdin to the connector's control socket and print the reply. `answer`
12
+ * runs first, so a decision that needs no connector state holds even when the socket is down. */
13
+ export declare function runHookRelay(answer?: LocalHookAnswer): Promise<void>;
3
14
  //# sourceMappingURL=relay.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"relay.d.ts","sourceRoot":"","sources":["../src/relay.ts"],"names":[],"mappings":"AAoGA,6FAA6F;AAC7F,wBAAsB,YAAY,IAAI,OAAO,CAAC,IAAI,CAAC,CAuHlD"}
1
+ {"version":3,"file":"relay.d.ts","sourceRoot":"","sources":["../src/relay.ts"],"names":[],"mappings":"AAUA,OAAO,EAAkB,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAG/D,sFAAsF;AACtF,OAAO,EAAE,WAAW,EAAE,CAAC;AAyFvB;;;wCAGwC;AACxC,MAAM,MAAM,eAAe,GAAG,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE;IAAE,OAAO,EAAE,OAAO,CAAA;CAAE,KAAK,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,CAAC;AAErH;kGACkG;AAClG,wBAAsB,YAAY,CAAC,MAAM,CAAC,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC,CAgI1E"}
package/dist/relay.js CHANGED
@@ -10,6 +10,8 @@
10
10
  import { connect } from "node:net";
11
11
  import { controlFromEnv, hasIdentity } from "./session-env.js";
12
12
  import { HANDOFF_RECEIPT } from "./control.js";
13
+ /** Re-exported for a plugin process that must stay off the barrel, as a hook does. */
14
+ export { hasIdentity };
13
15
  const TIMEOUT_MS = 2000;
14
16
  /** A startup hook may run before the MCP process has bound its socket. Stay inside the existing
15
17
  * hook budget, but do not turn one early ENOENT into a permanently lost lifecycle event. */
@@ -95,10 +97,31 @@ function done(out, confirm) {
95
97
  });
96
98
  setTimeout(exit, 1000);
97
99
  }
98
- /** Relay one hook event from stdin to the connector's control socket and print the reply. */
99
- export async function runHookRelay() {
100
- if (!hasIdentity())
101
- return done(""); // plain session, not a managed one — no-op
100
+ /** Relay one hook event from stdin to the connector's control socket and print the reply. `answer`
101
+ * runs first, so a decision that needs no connector state holds even when the socket is down. */
102
+ export async function runHookRelay(answer) {
103
+ const managed = hasIdentity();
104
+ if (!managed && !answer)
105
+ return done(""); // plain session with nothing to answer — no-op
106
+ const raw = (await readStdin()).trim() || "{}";
107
+ let event = {};
108
+ try {
109
+ event = JSON.parse(raw); // the hook event the runtime piped in
110
+ }
111
+ catch {
112
+ /* malformed — relay an empty event under a valid token */
113
+ }
114
+ let local;
115
+ try {
116
+ local = answer?.(event, { managed });
117
+ }
118
+ catch {
119
+ /* an answer that throws must not block the session; relay the event instead */
120
+ }
121
+ if (local)
122
+ return done(JSON.stringify(local));
123
+ if (!managed)
124
+ return done(""); // plain session, not a managed one — no connector to relay to
102
125
  // The socket path comes from the launch env; the token comes from the launch-material file that
103
126
  // env points at (the same file the in-agent server reads), never recomputed from public identity.
104
127
  // A malformed or missing material file THROWS from controlFromEnv, and a hook that throws is a
@@ -121,14 +144,6 @@ export async function runHookRelay() {
121
144
  if (!control)
122
145
  return done("");
123
146
  const { path, token } = control;
124
- const raw = (await readStdin()).trim() || "{}";
125
- let event = {};
126
- try {
127
- event = JSON.parse(raw); // the hook event the runtime piped in
128
- }
129
- catch {
130
- /* malformed — relay an empty event under a valid token */
131
- }
132
147
  const startupCritical = isSessionStart(event);
133
148
  let sock;
134
149
  let settled = false;
package/dist/relay.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"relay.js","sourceRoot":"","sources":["../src/relay.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AACnC,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/D,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAE/C,MAAM,UAAU,GAAG,IAAI,CAAC;AACxB;4FAC4F;AAC5F,MAAM,wBAAwB,GAAG,EAAE,CAAC;AACpC,MAAM,oBAAoB,GAAG,GAAG,CAAC;AAEjC,MAAM,uBAAuB,GAAG,CAAC,KAAc,EAAW,EAAE;IAC1D,MAAM,IAAI,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAE,KAA+B,CAAC,I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AO,IAAI,IAAI,KAAK,SAAS;gBAAE,OAAO;YAC1C,KAAK,IAAI,CAAC,CAAC;YACX,MAAM,EAAE,GAAG,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;YAC/B,IAAI,EAAE,IAAI,CAAC;gBAAE,iBAAiB,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,EAAE,SAAS,CAAC,CAAC;QAChE,CAAC,CAAC,CAAC;QACH,SAAS,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,KAAK,EAAE,EAAE;YAC9B,IAAI,OAAO,IAAI,IAAI,KAAK,SAAS;gBAAE,OAAO;YAC1C,IAAI,CAAC,SAAS,IAAI,eAAe,IAAI,uBAAuB,CAAC,KAAK,CAAC,EAAE,CAAC;gBACpE,IAAI,CAAC,SAAS,CAAC,CAAC;gBAChB,UAAU,EAAE,CAAC;gBACb,OAAO;YACT,CAAC;YACD,6FAA6F;YAC7F,+FAA+F;YAC/F,6BAA6B;YAC7B,MAAM,CAAC,EAAE,CAAC,CAAC;QACb,CAAC,CAAC,CAAC;QACH,SAAS,CAAC,EAAE,CAAC,KAAK,EAAE,GAAG,EAAE;YACvB,IAAI,OAAO,IAAI,IAAI,KAAK,SAAS;gBAAE,OAAO;YAC1C,MAAM,CAAC,KAAK,CAAC,CAAC;QAChB,CAAC,CAAC,CAAC;IACL,CAAC,CAAC;IAEF,IAAI,EAAE,CAAC;AACT,CAAC"}
@@ -27,7 +27,13 @@ export interface CotalToolSpec {
27
27
  * THIS; none of them re-derives an open object, and none of them can, because
28
28
  * {@link cotalToolSpecs} is the only source and it closes every shape on the way out. */
29
29
  schema: CotalToolInput;
30
- run(agent: MeshAgent, config: AgentConfig, args: any): Promise<ToolResult> | ToolResult;
30
+ run(agent: MeshAgent, config: AgentConfig, args: any, call?: ToolCall): Promise<ToolResult> | ToolResult;
31
+ }
32
+ /** What a surface knows about the request a tool runs for. */
33
+ export interface ToolCall {
34
+ /** Aborts when the caller can no longer receive the result. A read that finds it aborted clears
35
+ * nothing, so the messages stay for the next read. */
36
+ signal?: AbortSignal;
31
37
  }
32
38
  /**
33
39
  * Validate raw tool args against a spec's closed input, for the adapters whose host does NOT
@@ -117,8 +123,19 @@ export declare function renderInbox(opts: {
117
123
  }): InboxResponse;
118
124
  /** Routing context for a `<channel …>` tag. Keys must be [A-Za-z0-9_] (others are dropped). */
119
125
  export declare function channelMeta(i: InboxItem): Record<string, string>;
126
+ /**
127
+ * The channel a send with none goes to, from the channels the agent reads. A mesh that enforces
128
+ * ACLs refuses a post outside `allowPublish`, so there the default is the first concrete channel
129
+ * the agent reads AND may post to: a read-only channel such as an announcements feed is never it.
130
+ * An open mesh enforces no post ACL, so there it is the first concrete channel read, as the
131
+ * endpoint resolves it. A wildcard subscription like `team.>` is not a destination. Undefined when
132
+ * no channel qualifies; a send without a channel is then refused.
133
+ */
134
+ export declare function defaultSendChannel(config: Pick<AgentConfig, "allowPublish" | "creds" | "userAuth">, reading: readonly string[]): string | undefined;
120
135
  /** The full Cotal tool set for a given config. Renderers iterate this; `source` names the
121
136
  * hosting connector and is stamped onto outgoing feedback. An explicit env restricts feedback's
122
- * Git lookup to its global config; omitted preserves process inheritance and repository lookup. */
123
- export declare function cotalToolSpecs(config: AgentConfig, source?: string, env?: NodeJS.ProcessEnv): CotalToolSpec[];
137
+ * Git lookup to its global config; omitted preserves process inheritance and repository lookup.
138
+ * `offered` limits the set to those names for a host that serves only part of the surface, and the
139
+ * orientation card then lists only those. */
140
+ export declare function cotalToolSpecs(config: AgentConfig, source?: string, env?: NodeJS.ProcessEnv, offered?: ReadonlySet<string>): CotalToolSpec[];
124
141
  //# sourceMappingURL=tool-specs.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"tool-specs.d.ts","sourceRoot":"","sources":["../src/tool-specs.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAmB,KAAK,SAAS,EAAE,KA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C,EAAE,OAAO,CAAC;IACf,kFAAkF;IAClF,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;;;;OAMG;IACH,SAAS,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;CACjC,GAAG,aAAa,CA4FhB;AAqRD,+FAA+F;AAC/F,wBAAgB,WAAW,CAAC,CAAC,EAAE,SAAS,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAQhE;AAED;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,IAAI,CAAC,WAAW,EAAE,cAAc,GAAG,OAAO,GAAG,UAAU,CAAC,EAAE,OAAO,EAAE,SAAS,MAAM,EAAE,GAAG,MAAM,GAAG,SAAS,CAGnJ;AAKD;;;;8CAI8C;AAC9C,wBAAgB,cAAc,CAC5B,MAAM,EAAE,WAAW,EACnB,MAAM,SAAc,EACpB,GAAG,CAAC,EAAE,MAAM,CAAC,UAAU,EACvB,OAAO,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC,GAC5B,aAAa,EAAE,CAioCjB"}
@@ -9,7 +9,7 @@
9
9
  */
10
10
  import { execFileSync } from "node:child_process";
11
11
  import { z } from "zod";
12
- import { isConcreteChannel, channelInAllow, AmbiguousPeerError, peerLabel, assertLifecycleToken, isPermissionDenied, renderLifecycleBlocked, EpEnvelopeError, LANG_PROBLEM_DETAIL_KIND, formatAge, presenceAges } from "@cotal-ai/core";
12
+ import { isConcreteChannel, channelInAllow, AmbiguousPeerError, peerLabel, assertLifecycleToken, isPermissionDenied, renderLifecycleBlocked, EpEnvelopeError, LANG_PROBLEM_DETAIL_KIND, formatAge, presenceAges, presenceText } from "@cotal-ai/core";
13
13
  import { afterRecallMark } from "./agent.js";
14
14
  // The neutralization and the per-item rendering live in `framing.ts`, one convention shared with
15
15
  // the auto-injected block, and are used here rather than restated. See that file for the rule.
@@ -124,6 +124,21 @@ export function refuseAnyArgs(name, args) {
124
124
  function statusGlyph(s) {
125
125
  return s === "working" ? "●" : s === "waiting" ? "◐" : s === "idle" ? "○" : "·";
126
126
  }
127
+ /** The manager-instance pin of the manager read and run tools: the same token `cotal_spawn`'s
128
+ * `instance` takes. */
129
+ const managerInstanceArg = z
130
+ .string()
131
+ .refine((value) => {
132
+ try {
133
+ assertLifecycleToken(value, "instance");
134
+ return true;
135
+ }
136
+ catch {
137
+ return false;
138
+ }
139
+ }, "instance must be a lifecycle token ([a-z0-9]{26,32})")
140
+ .optional()
141
+ .describe("Optional manager instance id for a multi-manager space. When omitted, a seat a manager launched uses that manager and any other caller lets the mesh select one; on a user-auth mesh with several of your managers live, that selection refuses and lists their ids. A pin that cannot be resolved is refused without falling back to another manager.");
127
142
  /** One-line meaning of each attention mode, echoed back on set/read so the agent always sees the
128
143
  * effect of a mode it may have set turns ago (self-visibility is the escape hatch for `focus`). */
129
144
  const ATTENTION_DESC = {
@@ -329,8 +344,8 @@ const partOffsets = new WeakMap();
329
344
  */
330
345
  const inboxReads = new WeakMap();
331
346
  function oneReadAtATime(read) {
332
- return (agent, config, args) => {
333
- const turn = (inboxReads.get(agent) ?? Promise.resolve()).then(() => read(agent, config, args));
347
+ return (agent, config, args, call) => {
348
+ const turn = (inboxReads.get(agent) ?? Promise.resolve()).then(() => read(agent, config, args, call));
334
349
  inboxReads.set(agent, turn.catch(() => undefined));
335
350
  return turn;
336
351
  };
@@ -509,10 +524,25 @@ export function channelMeta(i) {
509
524
  m.mentioned = "true"; // we were addressed by name → high priority
510
525
  return m;
511
526
  }
527
+ /**
528
+ * The channel a send with none goes to, from the channels the agent reads. A mesh that enforces
529
+ * ACLs refuses a post outside `allowPublish`, so there the default is the first concrete channel
530
+ * the agent reads AND may post to: a read-only channel such as an announcements feed is never it.
531
+ * An open mesh enforces no post ACL, so there it is the first concrete channel read, as the
532
+ * endpoint resolves it. A wildcard subscription like `team.>` is not a destination. Undefined when
533
+ * no channel qualifies; a send without a channel is then refused.
534
+ */
535
+ export function defaultSendChannel(config, reading) {
536
+ const concrete = reading.filter(isConcreteChannel);
537
+ return isAuthed(config) ? concrete.find((c) => channelInAllow(config.allowPublish, c)) : concrete[0];
538
+ }
539
+ const NO_POSTABLE_DEFAULT = "you may post to none of the channels you read, so there is no default and an omitted channel is refused - name one your post ACL allows (cotal_orientation lists them)";
512
540
  /** The full Cotal tool set for a given config. Renderers iterate this; `source` names the
513
541
  * hosting connector and is stamped onto outgoing feedback. An explicit env restricts feedback's
514
- * Git lookup to its global config; omitted preserves process inheritance and repository lookup. */
515
- export function cotalToolSpecs(config, source = "connector", env) {
542
+ * Git lookup to its global config; omitted preserves process inheritance and repository lookup.
543
+ * `offered` limits the set to those names for a host that serves only part of the surface, and the
544
+ * orientation card then lists only those. */
545
+ export function cotalToolSpecs(config, source = "connector", env, offered) {
516
546
  // Manager-op tools (cotal_spawn / cotal_persona / cotal_personas) ride the `spawn` capability — publish to the
517
547
  // privileged control subject. The AUTH layer is the real boundary: on an authed mesh an agent
518
548
  // without the capability is denied at the wire (nats-server); open mode mints no identity, so
@@ -528,10 +558,7 @@ export function cotalToolSpecs(config, source = "connector", env) {
528
558
  // The same rule for the workflow-run door (SPEC 14.3): the `run` capability mints the manager's
529
559
  // run-* rows, so cotal_run is advertised only where the wire would admit it.
530
560
  const canRun = !isAuthed(config) || (config.capabilities?.includes("run") ?? false);
531
- // The default broadcast target, the same one the endpoint resolves: the first CONCRETE channel of
532
- // the read set (a wildcard subscription like `team.>` is not a destination). Undefined when the
533
- // agent is on no channel, in which case there IS no default and a send without one is refused.
534
- const defaultChannel = config.subscribe.find(isConcreteChannel);
561
+ const defaultChannel = defaultSendChannel(config, config.subscribe);
535
562
  const specs = [
536
563
  {
537
564
  name: "cotal_orientation",
@@ -543,7 +570,7 @@ export function cotalToolSpecs(config, source = "connector", env) {
543
570
  run(agent) {
544
571
  // Reflect the SAME gated tool list the connector exposes (cotalToolSpecs already filters
545
572
  // spawn/persona by capability), so the card can't claim a tool the agent can't call.
546
- const visible = cotalToolSpecs(config, source).map((s) => ({
573
+ const visible = cotalToolSpecs(config, source, env, offered).map((s) => ({
547
574
  name: s.name,
548
575
  title: s.title,
549
576
  }));
@@ -719,9 +746,9 @@ export function cotalToolSpecs(config, source = "connector", env) {
719
746
  const age = presenceAges(p, Date.now());
720
747
  const unchanged = age.statusSince === undefined ? "" : ` · unchanged for ${formatAge(age.statusSince)}`;
721
748
  const active = age.activeAt === undefined ? "" : ` · active ${formatAge(age.activeAt)} ago`;
722
- const condition = (p.condition ? ` (${p.condition.code}${age.conditionSince === undefined ? "" : ` for ${formatAge(age.conditionSince)}`})` : "") + unchanged + active;
749
+ const condition = (p.condition ? ` (${presenceText(p.condition.code)}${age.conditionSince === undefined ? "" : ` for ${formatAge(age.conditionSince)}`})` : "") + unchanged + active;
723
750
  const progress = p.status === "working" ? `working${condition} · progress unknown` : `${p.status}${condition}`;
724
- const activity = p.activity ? `: ${p.activity}${age.activitySince === undefined ? "" : ` (set ${formatAge(age.activitySince)} ago)`}` : "";
751
+ const activity = p.activity ? `: ${presenceText(p.activity)}${age.activitySince === undefined ? "" : ` (set ${formatAge(age.activitySince)} ago)`}` : "";
725
752
  return `${statusGlyph(p.status)} ${who} — ${progress}${activity}${attn}${me}${mutedHint}${id}`;
726
753
  });
727
754
  return ok(`${preface}Present in "${config.space}" (${roster.length}):\n${lines.join("\n")}`);
@@ -734,8 +761,11 @@ export function cotalToolSpecs(config, source = "connector", env) {
734
761
  schema: {
735
762
  peek: z.boolean().optional().describe("If true, show messages without clearing them."),
736
763
  },
737
- run: oneReadAtATime(async (agent, _config, { peek, scope }) => {
764
+ run: oneReadAtATime(async (agent, _config, { peek, scope }, call) => {
738
765
  const inboxScope = scope ?? "all";
766
+ // Asked at each clear, not once: the caller can go while this read waits for the one before
767
+ // it or for focus recall, and what it never receives must stay for the next read.
768
+ const keeps = () => peek === true || call?.signal?.aborted === true;
739
769
  // SELECT, RENDER, THEN CLEAR EXACTLY WHAT WENT OUT (#603). The old order drained the whole
740
770
  // scope up front, so a payload too large for the host to deliver had already been marked
741
771
  // read, and a reconnect replay is both the largest payload and the one most likely to have
@@ -764,7 +794,7 @@ export function cotalToolSpecs(config, source = "connector", env) {
764
794
  item: buffered.find((i) => stuck.has(i.recvKey)),
765
795
  offered: buffered,
766
796
  stuck,
767
- peek: peek ?? false,
797
+ peek: keeps(),
768
798
  last: (i) => agent.drainInboxDeliveries([i.recvKey]),
769
799
  });
770
800
  if (part)
@@ -773,7 +803,7 @@ export function cotalToolSpecs(config, source = "connector", env) {
773
803
  // The response exists before anything is acked: an ack is a claim that these messages were
774
804
  // handed over, so nothing may be cleared while the handing-over is still hypothetical. And
775
805
  // it is the ASSEMBLED response that decides, so what is acked is what a caller was handed.
776
- if (!peek)
806
+ if (!keeps())
777
807
  agent.drainInboxDeliveries(shown.map((i) => i.recvKey));
778
808
  void held;
779
809
  return ok(text);
@@ -861,7 +891,7 @@ export function cotalToolSpecs(config, source = "connector", env) {
861
891
  item,
862
892
  offered: [...buffered, ...fresh],
863
893
  stuck,
864
- peek: peek ?? false,
894
+ peek: keeps(),
865
895
  warning,
866
896
  last: (i) => {
867
897
  if (bufferedIds.has(i.recvKey))
@@ -877,7 +907,7 @@ export function cotalToolSpecs(config, source = "connector", env) {
877
907
  }
878
908
  // Render first, ack second, and only ever ids from the buffered lane: acking a recall id
879
909
  // would mark it handled, so a later live copy of that channel message would be dropped.
880
- if (!peek) {
910
+ if (!keeps()) {
881
911
  agent.drainInboxDeliveries(all.filter((i) => bufferedIds.has(i.recvKey)).map((i) => i.recvKey));
882
912
  // THE MARK MOVES OVER AN UNBROKEN PREFIX, and stops at the first thing this reply did not
883
913
  // carry. Two recall items can share a millisecond, so the mark is a (timestamp, id) pair:
@@ -912,17 +942,20 @@ export function cotalToolSpecs(config, source = "connector", env) {
912
942
  channel: z
913
943
  .string()
914
944
  .optional()
915
- .describe(`Channel to send on (${defaultChannel ? `default: ${defaultChannel}` : "REQUIRED: you are on no channel, so there is no default and an omitted channel is refused - join one first"}). Concrete only, not a wildcard like team.>; reply on the channel you received a message on.`),
945
+ .describe(`Channel to send on (${defaultChannel ? `default: ${defaultChannel}` : config.subscribe.some(isConcreteChannel) ? `REQUIRED: ${NO_POSTABLE_DEFAULT}` : "REQUIRED: you are on no channel, so there is no default and an omitted channel is refused - join one first"}). Concrete only, not a wildcard like team.>; reply on the channel you received a message on.`),
916
946
  mentions: z
917
947
  .array(z.string())
918
948
  .optional()
919
949
  .describe("Names of peers to call out (e.g. ['bob']). Everyone on the channel still receives the message, but a mentioned peer gets high-priority delivery (eg @bob): woken now if idle, instead of waiting for its next idle moment. Use sparingly: a mention WAKES that peer, so only call someone out when you need THAT specific peer to act now; never mention in an acknowledgement, thanks, or sign-off, or mentions ping-pong between peers and wake the channel in a loop."),
920
950
  },
921
- async run(agent, _config, { text: msg, channel, mentions }) {
951
+ async run(agent, config, { text: msg, channel, mentions }) {
922
952
  try {
923
- const target = channel ?? agent.joinedChannels().find(isConcreteChannel);
953
+ const joined = agent.joinedChannels();
954
+ const target = channel ?? defaultSendChannel(config, joined);
955
+ if (target === undefined && joined.some(isConcreteChannel))
956
+ return err(`Couldn't send: ${NO_POSTABLE_DEFAULT}.`);
924
957
  const receipt = target !== undefined ? await agent.describeSendChannel(target) : undefined;
925
- const m = await agent.send(msg, channel, mentions);
958
+ const m = await agent.send(msg, target, mentions);
926
959
  const dest = `Sent to #${m.channel}${m.mentions?.length ? ` (mentioned @${m.mentions.join(", @")})` : ""}`;
927
960
  return ok(receipt ? `${dest} (${receipt}).` : `${dest}.`);
928
961
  }
@@ -1359,6 +1392,7 @@ export function cotalToolSpecs(config, source = "connector", env) {
1359
1392
  value: z.unknown().optional().describe("answer only: supply the value requested by the open checkpoint or ask and match its answer shape. A checkpoint may resolve without a value; an ask must receive its requested record. Use null only when that is the intended answer."),
1360
1393
  artifact: z.string().min(1).optional().describe("answer only: a reference to what you reviewed before answering, recorded beside the answer."),
1361
1394
  endpoint: z.string().min(1).optional().describe("status/ps/answer: the endpoint the run record lives under. Omit for runs the manager hosts."),
1395
+ instance: managerInstanceArg,
1362
1396
  },
1363
1397
  async run(agent, config, a) {
1364
1398
  const need = (field, verb) => a[field] === undefined ? err(`cotal_run ${verb}: \`${String(field)}\` is required`) : undefined;
@@ -1367,7 +1401,7 @@ export function cotalToolSpecs(config, source = "connector", env) {
1367
1401
  const missing = need("source", "start");
1368
1402
  if (missing)
1369
1403
  return missing;
1370
- const reply = await agent.run("start", { source: a.source, file: a.file, timeout: a.timeout });
1404
+ const reply = await agent.run("start", { source: a.source, file: a.file, timeout: a.timeout }, a.instance);
1371
1405
  if (!reply.ok)
1372
1406
  return err(renderRunRefusal("start", reply));
1373
1407
  const { runId } = reply.data;
@@ -1377,13 +1411,13 @@ export function cotalToolSpecs(config, source = "connector", env) {
1377
1411
  const missing = need("runId", "resume");
1378
1412
  if (missing)
1379
1413
  return missing;
1380
- const reply = await agent.run("resume", { runId: a.runId, timeout: a.timeout });
1414
+ const reply = await agent.run("resume", { runId: a.runId, timeout: a.timeout }, a.instance);
1381
1415
  if (!reply.ok)
1382
1416
  return err(renderRunRefusal("resume", reply));
1383
1417
  return ok(`Resumed run ${a.runId} on the manager from its recorded program.`);
1384
1418
  }
1385
1419
  if (a.verb === "ps") {
1386
- const reply = await agent.run("ps", { endpoint: a.endpoint });
1420
+ const reply = await agent.run("ps", { endpoint: a.endpoint }, a.instance);
1387
1421
  if (!reply.ok)
1388
1422
  return err(renderRunRefusal("ps", reply));
1389
1423
  const rows = reply.data;
@@ -1395,7 +1429,7 @@ export function cotalToolSpecs(config, source = "connector", env) {
1395
1429
  const missing = need("runId", "status");
1396
1430
  if (missing)
1397
1431
  return missing;
1398
- const reply = await agent.run("status", { runId: a.runId, endpoint: a.endpoint });
1432
+ const reply = await agent.run("status", { runId: a.runId, endpoint: a.endpoint }, a.instance);
1399
1433
  if (!reply.ok)
1400
1434
  return err(renderRunRefusal("status", reply));
1401
1435
  const v = reply.data;
@@ -1410,7 +1444,7 @@ export function cotalToolSpecs(config, source = "connector", env) {
1410
1444
  return missing;
1411
1445
  // The manager records the answerer from the caller's own credential (SPEC 14.5); the
1412
1446
  // tool sends no name, so it cannot answer as anyone else.
1413
- const reply = await agent.run("answer", { runId: a.runId, stepKey: a.stepKey, value: a.value, artifact: a.artifact, endpoint: a.endpoint });
1447
+ const reply = await agent.run("answer", { runId: a.runId, stepKey: a.stepKey, value: a.value, artifact: a.artifact, endpoint: a.endpoint }, a.instance);
1414
1448
  if (!reply.ok)
1415
1449
  return err(renderRunRefusal("answer", reply));
1416
1450
  return ok(`Answered ${a.stepKey} on run ${a.runId} as ${config.name}: ${JSON.stringify(reply.data)}`);
@@ -1489,11 +1523,12 @@ export function cotalToolSpecs(config, source = "connector", env) {
1489
1523
  .regex(/^[A-Za-z0-9_-]+$/, "letters, digits, _ or - only")
1490
1524
  .optional()
1491
1525
  .describe("Persona to show. Omit to list the catalog."),
1526
+ instance: managerInstanceArg,
1492
1527
  },
1493
- async run(agent, _config, { name }) {
1528
+ async run(agent, _config, { name, instance }) {
1494
1529
  try {
1495
1530
  if (name) {
1496
- const reply = await agent.showPersona(name);
1531
+ const reply = await agent.showPersona(name, instance);
1497
1532
  if (!reply.ok)
1498
1533
  return err(`Couldn't show ${name}: ${reply.error ?? "manager refused"}`);
1499
1534
  const row = (reply.data ?? {});
@@ -1513,7 +1548,7 @@ export function cotalToolSpecs(config, source = "connector", env) {
1513
1548
  lines.push("", row.persona);
1514
1549
  return ok(lines.join("\n"));
1515
1550
  }
1516
- const reply = await agent.listPersonas();
1551
+ const reply = await agent.listPersonas(instance);
1517
1552
  if (!reply.ok)
1518
1553
  return err(`Couldn't list personas: ${reply.error ?? "manager refused"}`);
1519
1554
  const personas = (reply.data?.personas) ?? [];
@@ -1618,6 +1653,7 @@ export function cotalToolSpecs(config, source = "connector", env) {
1618
1653
  return specs
1619
1654
  .filter((spec) => canSpawn || (spec.name !== "cotal_spawn" && spec.name !== "cotal_persona" && spec.name !== "cotal_personas"))
1620
1655
  .filter((spec) => canRun || spec.name !== "cotal_run")
1656
+ .filter((spec) => !offered || offered.has(spec.name))
1621
1657
  .map((spec) => ({ ...spec, schema: z.strictObject(spec.schema ?? {}) }));
1622
1658
  }
1623
1659
  //# sourceMappingURL=tool-specs.js.map