@agentconnect.md/daemon 1.0.0-rc.270 → 1.0.0-rc.271

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.
@@ -3,9 +3,9 @@ import { n as require_ms, t as require_src$3 } from "./src-DDtlVutj.js";
3
3
  import { n as init_esm_shims, t as __dirname } from "./esm-shims-DxGcm4Hw.js";
4
4
  import { t as DAEMON_VERSION } from "./version-DGaRXjBK.js";
5
5
  import { C as _coercedNumber, T as NEVER, a as array, d as literal, f as looseObject, i as any, m as object, o as boolean, p as number$1, t as ZodNumber, v as string, x as url$4 } from "./schemas-CQkO9hC5.js";
6
- import { C as ZodIssueCode, S as RESERVED_MCP_SERVER_NAME, _ as buildEnvelope, a as agentChildEnv, b as MAX_FRAME_BYTES, c as persistRelays, d as normalizeGitUrl, f as RELAY_DAEMON_SUBPROTOCOL, g as SHARED_CONFIG_ACTION_ID, h as decodeRelayDaemonFrame, i as selectAgent, m as buildRelayDaemonFrame, n as findAgentFiles, o as loadConfig, p as RELAY_DAEMON_WS_PATH, r as loadAgents, s as persistDaemonId, v as decodeEnvelope, y as encode } from "./load-agents-DhUBoDuc.js";
6
+ import { C as ZodIssueCode, S as RESERVED_MCP_SERVER_NAME, _ as buildEnvelope, a as agentChildEnv, b as MAX_FRAME_BYTES, c as persistRelays, d as normalizeGitUrl, f as RELAY_DAEMON_SUBPROTOCOL, g as SHARED_CONFIG_ACTION_ID, h as decodeRelayDaemonFrame, i as selectAgent, m as buildRelayDaemonFrame, n as findAgentFiles, o as loadConfig, p as RELAY_DAEMON_WS_PATH, r as loadAgents, s as persistDaemonId, v as decodeEnvelope, y as encode } from "./load-agents-Amic2B8b.js";
7
7
  import { l as resolveRoot, o as mcpSocketPath, u as statePath } from "./paths-DEcUO8lC.js";
8
- import { S as resolveRuntimes, _ as writeMemoryFile, a as initGitInjection, b as cachedRuntimeNames, c as simpleGit, d as memoryProviderFor, f as MemoryConflictError, g as resolveInMemoryDir, h as listMemory, i as prepareWorkspace, l as createMemoryProvider, m as MemoryTooLargeError, n as installedRuntimes, o as probeGitVersion, p as MemoryPathError, r as prefetchWorkspace, s as sessionGitEnv, t as AcpHost, u as memoryKindOf, v as MEMORY_TOOL_NAMES, x as cachedRuntimeVersions, y as toolsForIntegrations } from "./acp-host-xCr--GKm.js";
8
+ import { S as resolveRuntimes, _ as writeMemoryFile, a as initGitInjection, b as cachedRuntimeNames, c as simpleGit, d as memoryProviderFor, f as MemoryConflictError, g as resolveInMemoryDir, h as listMemory, i as prepareWorkspace, l as createMemoryProvider, m as MemoryTooLargeError, n as installedRuntimes, o as probeGitVersion, p as MemoryPathError, r as prefetchWorkspace, s as sessionGitEnv, t as AcpHost, u as memoryKindOf, v as MEMORY_TOOL_NAMES, x as cachedRuntimeVersions, y as toolsForIntegrations } from "./acp-host-Da9dMauw.js";
9
9
  import { i as GitCredentialCache, n as gitcredSocketPath, r as writeGitcredShim, t as GitCredServer } from "./gitcred-server-CMC80O_1.js";
10
10
  import { B as ToolListChangedNotificationSchema, D as ListPromptsResultSchema, E as ListChangedOptionsBaseSchema, F as PromptListChangedNotificationSchema, G as isZ4Schema, H as isJSONRPCRequest, I as ReadResourceResultSchema, J as encodeFrame, K as safeParse, L as ResourceListChangedNotificationSchema, M as ListToolsResultSchema, O as ListResourceTemplatesResultSchema, P as McpError, R as SUPPORTED_PROTOCOL_VERSIONS, S as InitializeResultSchema, T as LATEST_PROTOCOL_VERSION, U as isJSONRPCResultResponse, V as isInitializedNotification, W as getObjectShape, _ as ElicitResultSchema, a as AjvJsonSchemaValidator, b as GetPromptResultSchema, c as mergeCapabilities, d as CompleteResultSchema, f as CreateMessageRequestSchema, g as ElicitRequestSchema, h as CreateTaskResultSchema, i as assertToolsCallTaskCapability, k as ListResourcesResultSchema, m as CreateMessageResultWithToolsSchema, n as serializeMessage, o as require_fast_deep_equal, p as CreateMessageResultSchema, q as decodeFrames, r as assertClientRequestTaskCapability, s as Protocol, t as ReadBuffer, u as CallToolResultSchema, v as EmptyResultSchema, w as JSONRPCMessageSchema, y as ErrorCode } from "./stdio-DnS8WcXi.js";
11
11
  import { URL as URL$1 } from "url";
@@ -7116,6 +7116,22 @@ async function executeTool(ctx, name, args, deps) {
7116
7116
  agents: res.agents
7117
7117
  };
7118
7118
  }
7119
+ if (name === "messageAgent") {
7120
+ const toAgentId = requireString(args, "toAgentId");
7121
+ const text = requireString(args, "text");
7122
+ const channel = optionalString(args, "channel") ?? ctx.channel;
7123
+ const thread = "thread" in args ? optionalString(args, "thread") || void 0 : ctx.thread;
7124
+ const correlationId = optionalString(args, "correlationId");
7125
+ return await deps.messageAgent({
7126
+ callerAgentId: ctx.agentId,
7127
+ platform: ctx.platform,
7128
+ toAgentId,
7129
+ text,
7130
+ channel,
7131
+ ...thread !== void 0 ? { thread } : {},
7132
+ ...correlationId !== void 0 ? { correlationId } : {}
7133
+ });
7134
+ }
7119
7135
  const gw = ctx.integrationId ? deps.gatewayFor(ctx.integrationId) : void 0;
7120
7136
  if (!gw) throw new Error(`no live platform connection for integration ${ctx.integrationId ?? "(none)"}`);
7121
7137
  switch (name) {
@@ -197575,6 +197591,8 @@ function applySpecFields(raw, spec, opts) {
197575
197591
  else raw.permissionMode = spec.permissionMode;
197576
197592
  if (spec.pause !== void 0) raw.pause = spec.pause;
197577
197593
  if (spec.mcpServers !== void 0) raw.mcpServers = spec.mcpServers;
197594
+ if (spec.callPolicy !== void 0) raw.callPolicy = spec.callPolicy;
197595
+ if (spec.allowedCallerAgentIds !== void 0) raw.allowedCallerAgentIds = spec.allowedCallerAgentIds;
197578
197596
  if (spec.memory !== void 0) raw.memory = spec.memory;
197579
197597
  if (spec.outputMode !== void 0) {
197580
197598
  const out = typeof raw.output === "object" && raw.output !== null ? raw.output : {};
@@ -213861,6 +213879,7 @@ var Daemon = class Daemon {
213861
213879
  if (!client) throw Object.assign(/* @__PURE__ */ new Error("control plane is not connected"), { code: "INTERNAL" });
213862
213880
  return client.channelAgents(req);
213863
213881
  },
213882
+ messageAgent: (req) => this.messageAgent(req),
213864
213883
  memory: this.memory,
213865
213884
  recordOutbound: (ctx, channel, thread, text, ts) => this.store.appendTranscript({
213866
213885
  channel,
@@ -214718,6 +214737,7 @@ var Daemon = class Daemon {
214718
214737
  this.log.debug(`webchat cancel: no in-flight turn for conversation ${conversationId}`);
214719
214738
  }
214720
214739
  relayMsgAcks = /* @__PURE__ */ new Map();
214740
+ agentCallDeliveries = /* @__PURE__ */ new Map();
214721
214741
  /**
214722
214742
  * Dispatch one inbound relay item (`rd/msg` — a webchat op or a hook fire) and
214723
214743
  * return the `rd/ack` verdict — the relay-path entry, reusing the SAME turn
@@ -214766,6 +214786,91 @@ var Daemon = class Daemon {
214766
214786
  };
214767
214787
  }
214768
214788
  /**
214789
+ * Same-daemon agent→agent delivery — the impl behind the `messageAgent` MCP tool
214790
+ * (design §2.2/§2.3, P1). Wakes `toAgentId` by constructing a NormalizedMessage at
214791
+ * the target's coords and dispatching it into that agent's local session, mirroring
214792
+ * {@link handleRelayIm}'s dispatch seam. The caller identity in `req.callerAgentId` is
214793
+ * TRUSTED (the daemon set it from the session context, not tool input).
214794
+ *
214795
+ * P1 is SAME-DAEMON ONLY: a target not on this daemon returns `delivered:false,
214796
+ * reason:'not_local'` (no relay). Enforces: self-message guard, local call policy
214797
+ * (§2.5), a STABLE deliveryId + monotonic ts so transcript ordering/replay holds
214798
+ * (§6.3), admission idempotency (a repeat deliveryId is a no-op), and a hop cap (§2.4).
214799
+ * The trusted call metadata rides a daemon-private turn context (Pending.callMeta),
214800
+ * NOT the model-visible prompt (§6.6/§6.7).
214801
+ */
214802
+ async messageAgent(req) {
214803
+ const platform = this.narrowPlatform(req.platform);
214804
+ const channel = req.channel;
214805
+ const thread = req.thread;
214806
+ const deliveryId = monotonicTs();
214807
+ const msgId = `agentcall:${channel}:${deliveryId}`;
214808
+ const targetSession = sessionKey(platform, channel, thread ?? msgId, req.toAgentId);
214809
+ if (req.toAgentId === req.callerAgentId) return {
214810
+ delivered: false,
214811
+ targetSession,
214812
+ reason: "self"
214813
+ };
214814
+ const prior = this.agentCallDeliveries.get(deliveryId);
214815
+ if (prior) return prior;
214816
+ const record = (result) => {
214817
+ if (this.agentCallDeliveries.size >= 2e3) this.agentCallDeliveries.clear();
214818
+ this.agentCallDeliveries.set(deliveryId, result);
214819
+ return result;
214820
+ };
214821
+ const target = this.agents.get(req.toAgentId);
214822
+ if (!target) return record({
214823
+ delivered: false,
214824
+ targetSession,
214825
+ reason: "not_local"
214826
+ });
214827
+ if (target.callPolicy === "selected" && !target.allowedCallerAgentIds.includes(req.callerAgentId)) {
214828
+ this.log.info(`messageAgent: ${req.callerAgentId} not allowed to call ${req.toAgentId} (policy=selected)`);
214829
+ return record({
214830
+ delivered: false,
214831
+ targetSession,
214832
+ reason: "not_allowed"
214833
+ });
214834
+ }
214835
+ const hopCount = 0;
214836
+ const callMeta = {
214837
+ callFrom: req.callerAgentId,
214838
+ ...req.correlationId !== void 0 ? { correlationId: req.correlationId } : {},
214839
+ hopCount,
214840
+ deliveryId
214841
+ };
214842
+ const resolved = this.resolveCpAgent(req.toAgentId);
214843
+ const integrationId = resolved?.integrationId;
214844
+ const text = `@${req.callerAgentId} asked:\n${req.text}`;
214845
+ const normalized = {
214846
+ msgId,
214847
+ traceId: deliveryId,
214848
+ source: "agent",
214849
+ platform,
214850
+ channel,
214851
+ ...thread !== void 0 ? { thread } : {},
214852
+ sender: {
214853
+ id: req.callerAgentId,
214854
+ isBot: true
214855
+ },
214856
+ text,
214857
+ mentionedBots: resolved?.botUserId ? [resolved.botUserId] : [],
214858
+ isDm: false
214859
+ };
214860
+ this.dispatch(req.toAgentId, normalized, integrationId, void 0, callMeta).catch((err) => this.log.error(`messageAgent dispatch failed for agent "${req.toAgentId}": ${formatErr(err)}`));
214861
+ this.log.info(`messageAgent: ${req.callerAgentId} → ${req.toAgentId} (${targetSession}) delivery=${deliveryId}`);
214862
+ return record({
214863
+ delivered: true,
214864
+ targetSession
214865
+ });
214866
+ }
214867
+ /** Narrow the trusted session-context platform string to the NormalizedMessage union;
214868
+ * falls back to 'slack' for an unrecognized value (coords still resolve — the union is
214869
+ * a routing/key detail, not the trust basis). */
214870
+ narrowPlatform(p) {
214871
+ return p === "telegram" || p === "webchat" || p === "discord" || p === "hook" ? p : "slack";
214872
+ }
214873
+ /**
214769
214874
  * Ack-verdict gate for one hook fire (`rd/msg` hook member) — the mirror of
214770
214875
  * {@link dispatchWebchatTurn}'s synchronous gates: the relay's rc/run-report
214771
214876
  * needs a REASONED rejection now, not a silently dropped fire-and-forget
@@ -215328,7 +215433,7 @@ var Daemon = class Daemon {
215328
215433
  ctx.replyConn.postMessage(ctx.channel, `⚠️ Agent failed to respond: ${reason}`, ctx.thread);
215329
215434
  }
215330
215435
  }
215331
- async dispatch(agentId, msg, integrationId, webchat) {
215436
+ async dispatch(agentId, msg, integrationId, webchat, callMeta) {
215332
215437
  if (this.draining || this.drainingAgents.has(agentId)) {
215333
215438
  this.log.debug(`dispatch: skipped for agent "${agentId}" (draining)`);
215334
215439
  return null;
@@ -215386,6 +215491,7 @@ var Daemon = class Daemon {
215386
215491
  applyChain: Promise.resolve(),
215387
215492
  done,
215388
215493
  resolveDone,
215494
+ ...callMeta ? { callMeta } : {},
215389
215495
  ...webchat ? { webchat: {
215390
215496
  ...webchat,
215391
215497
  index: 0,
@@ -216682,4 +216788,4 @@ async function runForeground(opts, deps = {}) {
216682
216788
  //#endregion
216683
216789
  export { ClientTransport as i, CP_SUBPROTOCOL as n, CP_WS_PATH as r, runForeground as t };
216684
216790
 
216685
- //# sourceMappingURL=run-foreground-BQ2MBshl.js.map
216791
+ //# sourceMappingURL=run-foreground-C4qribod.js.map