@stigmer/mcp-server 3.5.3 → 3.7.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.
Files changed (58) hide show
  1. package/cli/mcp-server-stigmer.js +6 -4
  2. package/config.d.ts +5 -1
  3. package/config.d.ts.map +1 -1
  4. package/config.js +2 -2
  5. package/config.js.map +1 -1
  6. package/domains/channels/calls.d.ts +15 -0
  7. package/domains/channels/calls.d.ts.map +1 -0
  8. package/domains/channels/calls.js +54 -0
  9. package/domains/channels/calls.js.map +1 -0
  10. package/domains/channels/errors.d.ts +21 -0
  11. package/domains/channels/errors.d.ts.map +1 -0
  12. package/domains/channels/errors.js +77 -0
  13. package/domains/channels/errors.js.map +1 -0
  14. package/domains/channels/tools.d.ts +5 -0
  15. package/domains/channels/tools.d.ts.map +1 -0
  16. package/domains/channels/tools.js +90 -0
  17. package/domains/channels/tools.js.map +1 -0
  18. package/domains/conversation/calls.d.ts +9 -0
  19. package/domains/conversation/calls.d.ts.map +1 -0
  20. package/domains/conversation/calls.js +30 -0
  21. package/domains/conversation/calls.js.map +1 -0
  22. package/domains/conversation/errors.d.ts +19 -0
  23. package/domains/conversation/errors.d.ts.map +1 -0
  24. package/domains/conversation/errors.js +73 -0
  25. package/domains/conversation/errors.js.map +1 -0
  26. package/domains/conversation/tools.d.ts +13 -0
  27. package/domains/conversation/tools.d.ts.map +1 -0
  28. package/domains/conversation/tools.js +69 -0
  29. package/domains/conversation/tools.js.map +1 -0
  30. package/gen/mcpserver.js +2 -2
  31. package/gen/mcpserver.js.map +1 -1
  32. package/gen/workflow.d.ts +156 -63
  33. package/gen/workflow.d.ts.map +1 -1
  34. package/gen/workflow.js +98 -46
  35. package/gen/workflow.js.map +1 -1
  36. package/index.d.ts +1 -1
  37. package/index.d.ts.map +1 -1
  38. package/index.js +1 -1
  39. package/index.js.map +1 -1
  40. package/package.json +3 -3
  41. package/server.d.ts +54 -9
  42. package/server.d.ts.map +1 -1
  43. package/server.js +89 -8
  44. package/server.js.map +1 -1
  45. package/src/config.ts +9 -3
  46. package/src/domains/channels/calls.ts +86 -0
  47. package/src/domains/channels/channels.integration.test.ts +272 -0
  48. package/src/domains/channels/errors.ts +94 -0
  49. package/src/domains/channels/tools.ts +116 -0
  50. package/src/domains/conversation/calls.ts +41 -0
  51. package/src/domains/conversation/conversation.integration.test.ts +233 -0
  52. package/src/domains/conversation/errors.ts +88 -0
  53. package/src/domains/conversation/tools.ts +87 -0
  54. package/src/gen/mcpserver.ts +2 -2
  55. package/src/gen/workflow.ts +99 -40
  56. package/src/http.integration.test.ts +56 -2
  57. package/src/index.ts +11 -1
  58. package/src/server.ts +95 -12
package/config.d.ts CHANGED
@@ -9,8 +9,12 @@ export type Transport = "stdio" | "http" | "both";
9
9
  * argument surface. This is what the runner-synthesized datastore
10
10
  * attachment spawns over stdio (T05 R1); over HTTP the same roster is
11
11
  * served on the /records route regardless of this setting.
12
+ * - "channels": only send_channel_message (proactive-messaging DD-006
13
+ * D8) with the agent-facing argument surface. This is what the
14
+ * runner-synthesized channel attachment spawns over stdio; over HTTP
15
+ * the same roster is served on the /channels route.
12
16
  */
13
- export type Roster = "full" | "records";
17
+ export type Roster = "full" | "records" | "channels";
14
18
  /**
15
19
  * OAuth 2.0 Protected Resource Metadata (RFC 9728) discovery settings.
16
20
  *
package/config.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAQA,OAAO,EAAO,KAAK,SAAS,EAAE,KAAK,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEjE,6DAA6D;AAC7D,MAAM,MAAM,SAAS,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,CAAC;AAElD;;;;;;;;GAQG;AACH,MAAM,MAAM,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;AAExC;;;;;;GAMG;AACH,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,OAAO,EAAE,O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AAO,CAAC;IAC1B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,oBAAoB,EAAE,MAAM,EAAE,CAAC;IACxC,QAAQ,CAAC,eAAe,EAAE,MAAM,EAAE,CAAC;CACpC;AAED,gDAAgD;AAChD,MAAM,WAAW,MAAM;IACrB,mEAAmE;IACnE,QAAQ,CAAC,oBAAoB,EAAE,MAAM,CAAC;IACtC;;;;OAIG;IACH,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,SAAS,EAAE,SAAS,CAAC;IAC9B,kEAAkE;IAClE,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,qEAAqE;IACrE,QAAQ,CAAC,eAAe,EAAE,OAAO,CAAC;IAClC,QAAQ,CAAC,KAAK,EAAE,WAAW,CAAC;IAC5B,QAAQ,CAAC,SAAS,EAAE,SAAS,CAAC;IAC9B,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC;CAC7B;AAOD,2EAA2E;AAC3E,wBAAgB,iBAAiB,CAAC,GAAG,GAAE,MAAM,CAAC,UAAwB,GAAG,MAAM,CAkB9E;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAoDhD"}
package/config.js CHANGED
@@ -7,7 +7,7 @@
7
7
  // reproduces Go's hard-errors AND warnings, not just the defaults.
8
8
  import { log } from "./logger.js";
9
9
  const VALID_TRANSPORTS = ["stdio", "http", "both"];
10
- const VALID_ROSTERS = ["full", "records"];
10
+ const VALID_ROSTERS = ["full", "records", "channels"];
11
11
  const VALID_LOG_FORMATS = ["text", "json"];
12
12
  const VALID_LOG_LEVELS = ["debug", "info", "warn", "error"];
13
13
  /** Reads configuration from the process environment, applying defaults. */
@@ -41,7 +41,7 @@ export function validateConfig(cfg) {
41
41
  throw new Error(`invalid STIGMER_MCP_TRANSPORT "${cfg.transport}": must be stdio, http, or both`);
42
42
  }
43
43
  if (!VALID_ROSTERS.includes(cfg.roster)) {
44
- throw new Error(`invalid STIGMER_MCP_ROSTER "${cfg.roster}": must be full or records`);
44
+ throw new Error(`invalid STIGMER_MCP_ROSTER "${cfg.roster}": must be full, records, or channels`);
45
45
  }
46
46
  if (cfg.stigmerServerAddress === "") {
47
47
  throw new Error("STIGMER_SERVER_ADDRESS must not be empty");
package/config.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,6DAA6D;AAC7D,EAAE;AACF,2EAA2E;AAC3E,6EAA6E;AAC7E,+EAA+E;AAC/E,2EAA2E;AAC3E,mEAAmE;AAEnE,OAAO,EAAE,GAAG,EAAiC,MAAM,aAAa,CAAC;AAmDjE,MAAM,gBAAgB,GAAsB,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;AACtE,MAAM,aAAa,GAAsB,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;AAC7D,MAAM,iBAAiB,GAAsB,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAC9D,MAAM,gBAAgB,GAAsB,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;AAE/E,2EAA2E;AAC3E,MAAM,UAAU,iBAAiB,CAAC,MAAyB,OAAO,CAAC,GAAG;IACpE,OAAO;QACL,oBAAoB,EAAE,KAAK,CAAC,GAAG,EAAE,wBAAwB,EAAE,gBAAgB,CAAC;QAC5E,MAAM,EAAE,GAAG,CAAC,eAAe,IAAI,EAAE;QACjC,SAAS,EAAE,KAAK,CAAC,GAAG,EAAE,uBAAuB,EAAE,OAAO,CAAC,CAAC,WAAW,EAAe;QAClF,MAAM,EAAE,KAAK,CAAC,GAAG,EAAE,oBAAoB,EAAE,MAAM,CAAC,CAAC,WAAW,EAAY;QACxE,QAAQ,EAAE,KAAK,CAAC,GAAG,EAAE,u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AAC,KAAK,SAAS,CAAC;AAClE,CAAC"}
@@ -0,0 +1,15 @@
1
+ /** The template arm as the model supplies it (mirrors TemplatePayload). */
2
+ export interface TemplateArg {
3
+ name: string;
4
+ language?: string;
5
+ parameters?: Record<string, string>;
6
+ header_image_link?: string;
7
+ }
8
+ export interface SendArgs {
9
+ recipient: string;
10
+ text?: string;
11
+ template?: TemplateArg;
12
+ channel?: string;
13
+ }
14
+ export declare function sendChannelMessage(serverAddress: string, token: string, args: SendArgs): Promise<string>;
15
+ //# sourceMappingURL=calls.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"calls.d.ts","sourceRoot":"","sources":["../../../src/domains/channels/calls.ts"],"names":[],"mappings":"AA2BA,2EAA2E;AAC3E,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACpC,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B;AAED,MAAM,WAAW,QAAQ;IACvB,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,WAAW,CAAC;IACvB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,wBAAsB,kBAAkB,CACtC,aAAa,EAAE,MAAM,EACrB,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,QAAQ,GACb,OAAO,CAAC,MAAM,CAAC,CAYjB"}
@@ -0,0 +1,54 @@
1
+ // Channel-messaging RPC invocations for the send_channel_message tool —
2
+ // a 1:1 projection of ChannelMessageCommandController.sendMessage
3
+ // (proactive-messaging DD-006 D5: the tool layer adds no semantics;
4
+ // reach, recipient policy, caps, and the template pre-check all live in
5
+ // the cloud handler, and the OSS edition refuses with the documented
6
+ // FAILED_PRECONDITION).
7
+ //
8
+ // The records-domain calls.ts shape: build request, call, marshal. The
9
+ // typed outcome (accepted/queued/refused + detail) rides back VERBATIM
10
+ // as proto JSON — a refusal is an ANSWER the model adapts to (DD-002
11
+ // D4), never a tool error.
12
+ import { create } from "@bufbuild/protobuf";
13
+ import { ChannelMessageCommandController, } from "@stigmer/protos/ai/stigmer/agentic/agentchannel/v1/message_command_pb";
14
+ import { ChannelOutboundPayloadSchema, SendChannelMessageInputSchema, SendChannelMessageOutputSchema, TemplatePayloadSchema, TextPayloadSchema, } from "@stigmer/protos/ai/stigmer/agentic/agentchannel/v1/message_io_pb";
15
+ import { withClient } from "../client.js";
16
+ import { toProtoJson } from "../marshal.js";
17
+ export async function sendChannelMessage(serverAddress, token, args) {
18
+ const request = create(SendChannelMessageInputSchema, {
19
+ channel: args.channel ?? "",
20
+ // org is deliberately never sent: a session-bound caller's org is
21
+ // server-derived, and an explicit value is rejected (the records
22
+ // T05 R3 rule applied to messaging).
23
+ recipient: args.recipient,
24
+ payload: buildPayload(args),
25
+ });
26
+ return withClient(ChannelMessageCommandController, serverAddress, token, async (client, opts) => toProtoJson(SendChannelMessageOutputSchema, await client.sendMessage(request, opts)));
27
+ }
28
+ /**
29
+ * The payload oneof from the tool's mutually exclusive arguments. The
30
+ * tool handler enforces exactly-one before calling; the server's
31
+ * required-oneof validation is the backstop.
32
+ */
33
+ function buildPayload(args) {
34
+ if (args.template !== undefined) {
35
+ return create(ChannelOutboundPayloadSchema, {
36
+ kind: {
37
+ case: "template",
38
+ value: create(TemplatePayloadSchema, {
39
+ name: args.template.name,
40
+ language: args.template.language ?? "",
41
+ parameters: args.template.parameters ?? {},
42
+ headerImageLink: args.template.header_image_link ?? "",
43
+ }),
44
+ },
45
+ });
46
+ }
47
+ return create(ChannelOutboundPayloadSchema, {
48
+ kind: {
49
+ case: "text",
50
+ value: create(TextPayloadSchema, { body: args.text ?? "" }),
51
+ },
52
+ });
53
+ }
54
+ //# sourceMappingURL=calls.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"calls.js","sourceRoot":"","sources":["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ChB,KAAK,EAAE,MAAM,CAAC,qBAAqB,EAAE;oBACnC,IAAI,EAAE,IAAI,CAAC,QAAQ,CAAC,IAAI;oBACxB,QAAQ,EAAE,IAAI,CAAC,QAAQ,CAAC,QAAQ,IAAI,EAAE;oBACtC,UAAU,EAAE,IAAI,CAAC,QAAQ,CAAC,UAAU,IAAI,EAAE;oBAC1C,eAAe,EAAE,IAAI,CAAC,QAAQ,CAAC,iBAAiB,IAAI,EAAE;iBACvD,CAAC;aACH;SACF,CAAC,CAAC;IACL,CAAC;IACD,OAAO,MAAM,CAAC,4BAA4B,EAAE;QAC1C,IAAI,EAAE;YACJ,IAAI,EAAE,MAAM;YACZ,KAAK,EAAE,MAAM,CAAC,iBAAiB,EAAE,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,IAAI,EAAE,EAAE,CAAC;SAC5D;KACF,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,21 @@
1
+ import { ConnectError } from "@connectrpc/connect";
2
+ import type { CallToolResult } from "@modelcontextprotocol/sdk/types.js";
3
+ /** The structured error payload channel tools return for domain errors. */
4
+ export interface ChannelToolError {
5
+ /** The server's relayable message, byte-for-byte. */
6
+ error: string;
7
+ /** gRPC status name in SCREAMING_SNAKE (e.g. PERMISSION_DENIED). */
8
+ code: string;
9
+ /** ErrorInfo reason (e.g. WHATSAPP_MANAGEMENT_SCOPE_MISSING), when present. */
10
+ reason?: string;
11
+ }
12
+ /**
13
+ * Run a channel-tool body: a string payload becomes a text result; a
14
+ * domain error becomes an isError JSON result carrying the verbatim
15
+ * message + ErrorInfo reason; a transport error delegates to the shared
16
+ * classifier. The only try/catch in this domain.
17
+ */
18
+ export declare function channelResult(toolContext: string, produce: () => Promise<string>): Promise<CallToolResult>;
19
+ /** Project a domain ConnectError into the structured tool payload. */
20
+ export declare function domainError(ce: ConnectError): ChannelToolError;
21
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../../src/domains/channels/errors.ts"],"names":[],"mappings":"AAoBA,OAAO,EAAQ,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AAmBzE,2EAA2E;AAC3E,MAAM,WAAW,gBAAgB;IAC/B,qDAAqD;IACrD,KAAK,EAAE,MAAM,CAAC;IACd,oEAAoE;IACpE,IAAI,EAAE,MAAM,CAAC;IACb,+EAA+E;IAC/E,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;;;;GAKG;AACH,wBAAsB,aAAa,CACjC,WAAW,EAAE,MAAM,EACnB,OAAO,EAAE,MAAM,OAAO,CAAC,MAAM,CAAC,GAC7B,OAAO,CAAC,cAAc,CAAC,CAazB;AAED,sEAAsE;AACtE,wBAAgB,WAAW,CAAC,EAAE,EAAE,YAAY,GAAG,gBAAgB,CAa9D"}
@@ -0,0 +1,77 @@
1
+ // The channels-domain error mapper — the records-domain sibling
2
+ // (DD-004 S-7's recorded posture: siblings share the idiom, never an
3
+ // abstraction over it; each domain documents its own contract).
4
+ //
5
+ // Channel-messaging domain errors carry agent-relayable messages that
6
+ // are contract bytes (proactive-messaging DD-002 D4's error table):
7
+ // "this agent has no proactive-messaging channel it can use", "channel
8
+ // is required: this agent serves multiple proactive-enabled channels:
9
+ // …", the OSS "proactive channel messaging requires Stigmer Cloud".
10
+ // The shared ../rpcerr.ts would rewrite them into transport advice and
11
+ // discard google.rpc.ErrorInfo; here the domain codes pass the server's
12
+ // message through VERBATIM as isError JSON `{error, code, reason}` so
13
+ // the model can self-correct (name the channel on INVALID_ARGUMENT;
14
+ // stop and relay on PERMISSION_DENIED). Transport codes still delegate
15
+ // to the shared helper, whose advice is right for them.
16
+ //
17
+ // Typed send outcomes (accepted/queued/refused) never reach this file:
18
+ // they are successful responses by design (DD-002 D4 — policy refusals
19
+ // are answers, not errors).
20
+ import { Code, ConnectError } from "@connectrpc/connect";
21
+ import { ErrorInfoSchema } from "@stigmer/protos/google/rpc/error_details_pb";
22
+ import { rpcError } from "../rpcerr.js";
23
+ import { errorResult, textResult } from "../toolresult.js";
24
+ /**
25
+ * The gRPC codes whose messages are the channel-messaging domain
26
+ * contract: reach denials (PERMISSION_DENIED, one fail-closed text per
27
+ * failure class), contract misuse with corrective copy
28
+ * (INVALID_ARGUMENT — ambiguous channel, ambiguous template language),
29
+ * and actionable preconditions (FAILED_PRECONDITION — the OSS refusal,
30
+ * not-installed, registry misconfiguration with its ErrorInfo reason).
31
+ */
32
+ const DOMAIN_CODES = new Set([
33
+ Code.PermissionDenied,
34
+ Code.InvalidArgument,
35
+ Code.FailedPrecondition,
36
+ ]);
37
+ /**
38
+ * Run a channel-tool body: a string payload becomes a text result; a
39
+ * domain error becomes an isError JSON result carrying the verbatim
40
+ * message + ErrorInfo reason; a transport error delegates to the shared
41
+ * classifier. The only try/catch in this domain.
42
+ */
43
+ export async function channelResult(toolContext, produce) {
44
+ try {
45
+ return textResult(await produce());
46
+ }
47
+ catch (err) {
48
+ const ce = ConnectError.from(err);
49
+ if (DOMAIN_CODES.has(ce.code)) {
50
+ return {
51
+ content: [{ type: "text", text: JSON.stringify(domainError(ce)) }],
52
+ isError: true,
53
+ };
54
+ }
55
+ return errorResult(rpcError(ce, toolContext));
56
+ }
57
+ }
58
+ /** Project a domain ConnectError into the structured tool payload. */
59
+ export function domainError(ce) {
60
+ const payload = {
61
+ error: ce.rawMessage,
62
+ code: grpcStatusName(ce.code),
63
+ };
64
+ // The messaging RPCs attach google.rpc.ErrorInfo to operator-actionable
65
+ // preconditions (DD-005 D8); absence means the message alone carries
66
+ // the contract.
67
+ const details = ce.findDetails(ErrorInfoSchema);
68
+ if (details.length > 0 && details[0].reason !== "") {
69
+ payload.reason = details[0].reason;
70
+ }
71
+ return payload;
72
+ }
73
+ /** Connect's PascalCase code name → the gRPC SCREAMING_SNAKE status name. */
74
+ function grpcStatusName(code) {
75
+ return Code[code].replace(/([a-z0-9])([A-Z])/g, "$1_$2").toUpperCase();
76
+ }
77
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../../../src/domains/channels/errors.ts"],"names":[],"mappings":"AAAA,gEAAgE;AAChE,qEAAqE;AACrE,gEAAgE;AAChE,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,uEAAuE;AACvE,sEAAsE;AACtE,oEAAoE;AACpE,uEAAuE;AACvE,wEAAwE;AACxE,sEAAsE;AACtE,oEAAoE;AACpE,uEAAuE;AACvE,wDAAwD;AACxD,EAAE;AACF,uEAAuE;AACvE,uEAAuE;AACvE,4BAA4B;AAE5B,OAAO,EAAE,IAAI,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAEzD,OAAO,EAAE,eAAe,EAAE,MAAM,6CAA6C,CAAC;AAC9E,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AACxC,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE3D;;;;;;;GAOG;AACH,MAAM,YAAY,GAAsB,IAAI,GAAG,CAAC;IAC9C,IAAI,CAAC,gBAAgB;IACrB,IAAI,CAAC,eAAe;IACpB,IAAI,CAAC,kBAAkB;CACxB,CAAC,CAAC;AAYH;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,CACjC,WAAmB,EACnB,OAA8B;IAE9B,IAAI,CAAC;QACH,OAAO,UAAU,CAAC,MAAM,OAAO,EAAE,CAAC,CAAC;IACrC,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,MAAM,EAAE,GAAG,YAAY,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAClC,IAAI,YAAY,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC;YAC9B,OAAO;gBACL,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC;gBAClE,OAAO,EAAE,IAAI;aACd,CAAC;QACJ,CAAC;QACD,OAAO,WAAW,CAAC,QAAQ,CAAC,EAAE,EAAE,WAAW,CAAC,CAAC,CAAC;IAChD,CAAC;AACH,CAAC;AAED,sEAAsE;AACtE,MAAM,UAAU,WAAW,CAAC,EAAgB;IAC1C,MAAM,OAAO,GAAqB;QAChC,KAAK,EAAE,EAAE,CAAC,UAAU;QACpB,IAAI,EAAE,cAAc,CAAC,EAAE,CAAC,IAAI,CAAC;KAC9B,CAAC;IACF,wEAAwE;IACxE,qEAAqE;IACrE,gBAAgB;IAChB,MAAM,OAAO,GAAG,EAAE,CAAC,WAAW,CAAC,eAAe,CAAC,CAAC;IAChD,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,IAAI,OAAO,CAAC,CAAC,CAAC,CAAC,MAAM,KAAK,EAAE,EAAE,CAAC;QACnD,OAAO,CAAC,MAAM,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC;IACrC,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC;AAED,6EAA6E;AAC7E,SAAS,cAAc,CAAC,IAAU;IAChC,OAAO,IAAI,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,oBAAoB,EAAE,OAAO,CAAC,CAAC,WAAW,EAAE,CAAC;AACzE,CAAC"}
@@ -0,0 +1,5 @@
1
+ import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
2
+ import { type BackendTarget } from "../client.js";
3
+ /** Register the channel messaging tool; returns the tool names. */
4
+ export declare function registerChannelTools(server: McpServer, target: BackendTarget): string[];
5
+ //# sourceMappingURL=tools.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../../../src/domains/channels/tools.ts"],"names":[],"mappings":"AAmBA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAGzE,OAAO,EAAgB,KAAK,aAAa,EAAE,MAAM,cAAc,CAAC;AA6BhE,mEAAmE;AACnE,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,aAAa,GAAG,MAAM,EAAE,CA+DvF"}
@@ -0,0 +1,90 @@
1
+ // The send_channel_message tool — the ONE tool of the channels roster
2
+ // (proactive-messaging DD-002 D7, arguments amended by DD-006 D5 to
3
+ // mirror the ChannelOutboundPayload oneof: `text` | `template`, exactly
4
+ // one).
5
+ //
6
+ // Agent audience only, by construction: this roster is what the
7
+ // runner-synthesized channel attachment connects to, and a session-bound
8
+ // caller's org derives from its token (an explicit org is rejected —
9
+ // the records T05 R3 rule), so no `org` argument exists to invite
10
+ // rejected calls. A direct-audience variant on the full roster is
11
+ // deliberately NOT registered: operators send through the console, CLI,
12
+ // and SDK, which carry the org+channel addressing the direct reach path
13
+ // requires.
14
+ //
15
+ // The typed outcome is the tool's answer, verbatim proto JSON:
16
+ // `accepted` (delivered to the provider), `queued` (transient failure —
17
+ // the platform retries in the background; do NOT resend), `refused`
18
+ // (terminal; `detail` says why — adapt, never retry the same send).
19
+ import { z } from "zod";
20
+ import { resolveToken } from "../client.js";
21
+ import { sendChannelMessage } from "./calls.js";
22
+ import { channelResult } from "./errors.js";
23
+ import { errorResult } from "../toolresult.js";
24
+ const templateShape = z.object({
25
+ name: z.string().describe("Approved template name on the channel's provider registry."),
26
+ language: z
27
+ .string()
28
+ .optional()
29
+ .describe("Template language code (e.g. en, en_US). Omit when the template exists in exactly one language."),
30
+ parameters: z
31
+ .record(z.string())
32
+ .optional()
33
+ .describe('Placeholder values. Positional templates key by position ("1", "2", …); ' +
34
+ 'named templates key by parameter name ("member_name").'),
35
+ header_image_link: z
36
+ .string()
37
+ .optional()
38
+ .describe("Public HTTPS URL for the image header. Required exactly when the template " +
39
+ "declares an image header."),
40
+ });
41
+ /** Register the channel messaging tool; returns the tool names. */
42
+ export function registerChannelTools(server, target) {
43
+ server.registerTool("send_channel_message", {
44
+ description: "Send a business-initiated message to a recipient on this agent's messaging channel " +
45
+ "(e.g. WhatsApp). Exactly one of text | template. Outside a 24-hour customer-service " +
46
+ "window the provider only accepts a pre-approved template, so prefer a template from " +
47
+ "<available_channel_templates>. The result carries a typed outcome: accepted (sent), " +
48
+ "queued (the platform retries in the background — do not resend), or refused " +
49
+ "(terminal; detail says why — adapt, never retry the same send).",
50
+ inputSchema: {
51
+ recipient: z
52
+ .string()
53
+ .describe("Recipient's key on the channel's provider, passed to the provider verbatim. " +
54
+ 'WhatsApp: the wa_id — digits only INCLUDING the country code, no "+" or ' +
55
+ 'separators (e.g. "919912850490"). Never reformat a wa_id another tool returned.'),
56
+ text: z
57
+ .string()
58
+ .optional()
59
+ .describe("Plain text body. Only deliverable inside an open 24-hour customer-service window."),
60
+ template: templateShape
61
+ .optional()
62
+ .describe("Pre-approved template send — required outside a 24-hour window."),
63
+ channel: z
64
+ .string()
65
+ .optional()
66
+ .describe("Channel slug. Only needed when this agent serves more than one " +
67
+ "proactive-messaging channel (a refusal will list them)."),
68
+ },
69
+ }, (args, extra) => {
70
+ // Exactly-one, checked here with corrective copy the model can act
71
+ // on immediately; the server's required-oneof validation is the
72
+ // backstop (DD-006 D5).
73
+ const hasText = args.text !== undefined && args.text !== "";
74
+ const hasTemplate = args.template !== undefined;
75
+ if (hasText === hasTemplate) {
76
+ return Promise.resolve(errorResult(hasText
77
+ ? "supply exactly one of text | template, not both"
78
+ : "supply exactly one of text | template — text for an open 24-hour window, " +
79
+ "template otherwise"));
80
+ }
81
+ return channelResult(`message to "${args.recipient}"`, () => sendChannelMessage(target.serverAddress, resolveToken(extra, target.apiKey), {
82
+ recipient: args.recipient,
83
+ text: args.text,
84
+ template: args.template,
85
+ channel: args.channel,
86
+ }));
87
+ });
88
+ return ["send_channel_message"];
89
+ }
90
+ //# sourceMappingURL=tools.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tools.js","sourceRoot":"","sources":["../../../src/domains/channels/tools.ts"],"names":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AClC,CAAC"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Flag the calling session's conversation for human attention. The input
3
+ * carries only the reason: the conversation identity derives server-side
4
+ * from the session-scoped credential's channel labels (the DD-003
5
+ * identity doctrine), so there is nothing else a caller could
6
+ * legitimately send.
7
+ */
8
+ export declare function escalateConversation(serverAddress: string, token: string, reason: string): Promise<void>;
9
+ //# sourceMappingURL=calls.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"calls.d.ts","sourceRoot":"","sources":["../../../src/domains/conversation/calls.ts"],"names":[],"mappings":"AAwBA;;;;;;GAMG;AACH,wBAAsB,oBAAoB,CACxC,aAAa,EAAE,MAAM,EACrB,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,IAAI,CAAC,CAKf"}
@@ -0,0 +1,30 @@
1
+ // Conversation RPC invocations for the escalate_to_human tool — a 1:1
2
+ // projection of ChannelConversationCommandController.escalate
3
+ // (channel-conversations DD-008: the tool layer adds no semantics; the
4
+ // reach, the idempotent writer, and the attention projection all live
5
+ // in the cloud handler, and the OSS edition refuses with the documented
6
+ // FAILED_PRECONDITION).
7
+ //
8
+ // The channels-domain calls.ts shape, with one deliberate divergence:
9
+ // the RPC's ChannelConversation response is DISCARDED instead of
10
+ // marshaled back as proto JSON. A15 rules the tool's answer is fixed
11
+ // behavioral copy (tools.ts owns it) — the row's control state,
12
+ // timestamps, and conversation key give the model nothing actionable,
13
+ // and reflecting them would only invite the model to narrate internal
14
+ // state to the customer.
15
+ import { create } from "@bufbuild/protobuf";
16
+ import { ChannelConversationCommandController, } from "@stigmer/protos/ai/stigmer/agentic/agentchannel/v1/conversation_command_pb";
17
+ import { EscalateConversationInputSchema, } from "@stigmer/protos/ai/stigmer/agentic/agentchannel/v1/conversation_io_pb";
18
+ import { withClient } from "../client.js";
19
+ /**
20
+ * Flag the calling session's conversation for human attention. The input
21
+ * carries only the reason: the conversation identity derives server-side
22
+ * from the session-scoped credential's channel labels (the DD-003
23
+ * identity doctrine), so there is nothing else a caller could
24
+ * legitimately send.
25
+ */
26
+ export async function escalateConversation(serverAddress, token, reason) {
27
+ const request = create(EscalateConversationInputSchema, { reason });
28
+ await withClient(ChannelConversationCommandController, serverAddress, token, (client, opts) => client.escalate(request, opts));
29
+ }
30
+ //# sourceMappingURL=calls.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"calls.js","sourceRoot":"","sources":["../../../src/domains/conversation/calls.ts"],"names":[],"mappings":"AAAA,sEAAsE;AACtE,8DAA8D;AAC9D,uEAAuE;AACvE,sEAAsE;AACtE,wEAAwE;AACxE,wBAAwB;AACxB,EAAE;AACF,sEAAsE;AACtE,iEAAiE;AACjE,qEAAqE;AACrE,gEAAgE;AAChE,sEAAsE;AACtE,sEAAsE;AACtE,yBAAyB;AAEzB,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC5C,OAAO,EACL,oCAAoC,GACrC,MAAM,4EAA4E,CAAC;AACpF,OAAO,EACL,+BAA+B,GAChC,MAAM,uEAAuE,CAAC;AAC/E,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,oBAAoB,CACxC,aAAqB,EACrB,KAAa,EACb,MAAc;IAEd,MAAM,OAAO,GAAG,MAAM,CAAC,+BAA+B,EAAE,EAAE,MAAM,EAAE,CAAC,CAAC;IACpE,MAAM,UAAU,CAAC,oCAAoC,EAAE,aAAa,EAAE,KAAK,EACzE,CAAC,MAAM,EAAE,IAAI,EAAE,EAAE,CAAC,MAAM,CAAC,QAAQ,CAAC,OAAO,EAAE,IAAI,CAAC,CACjD,CAAC;AACJ,CAAC"}
@@ -0,0 +1,19 @@
1
+ import { ConnectError } from "@connectrpc/connect";
2
+ import type { CallToolResult } from "@modelcontextprotocol/sdk/types.js";
3
+ /** The structured error payload conversation tools return for domain errors. */
4
+ export interface ConversationToolError {
5
+ /** The server's relayable message, byte-for-byte. */
6
+ error: string;
7
+ /** gRPC status name in SCREAMING_SNAKE (e.g. PERMISSION_DENIED). */
8
+ code: string;
9
+ }
10
+ /**
11
+ * Run a conversation-tool body: a string payload becomes a text result;
12
+ * a domain error becomes an isError JSON result carrying the verbatim
13
+ * message; a transport error delegates to the shared classifier. The
14
+ * only try/catch in this domain.
15
+ */
16
+ export declare function conversationResult(toolContext: string, produce: () => Promise<string>): Promise<CallToolResult>;
17
+ /** Project a domain ConnectError into the structured tool payload. */
18
+ export declare function domainError(ce: ConnectError): ConversationToolError;
19
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../../src/domains/conversation/errors.ts"],"names":[],"mappings":"AAwBA,OAAO,EAAQ,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AAmBzE,gFAAgF;AAChF,MAAM,WAAW,qBAAqB;IACpC,qDAAqD;IACrD,KAAK,EAAE,MAAM,CAAC;IACd,oEAAoE;IACpE,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;;;;GAKG;AACH,wBAAsB,kBAAkB,CACtC,WAAW,EAAE,MAAM,EACnB,OAAO,EAAE,MAAM,OAAO,CAAC,MAAM,CAAC,GAC7B,OAAO,CAAC,cAAc,CAAC,CAazB;AAED,sEAAsE;AACtE,wBAAgB,WAAW,CAAC,EAAE,EAAE,YAAY,GAAG,qBAAqB,CAKnE"}
@@ -0,0 +1,73 @@
1
+ // The conversation-domain error mapper — the channels-domain sibling
2
+ // (DD-004 S-7's recorded posture: siblings share the idiom, never an
3
+ // abstraction over it; each domain documents its own contract).
4
+ //
5
+ // Conversation domain errors carry agent-relayable messages that are
6
+ // contract bytes (the ChannelConversationReach refusal matrix):
7
+ // "escalate is agent-audience only: it requires a session-scoped runner
8
+ // credential", "conversation identity could not be verified for this
9
+ // session", "this session is not serving a channel conversation, so
10
+ // there is nothing to escalate", the OSS "conversation participation
11
+ // requires Stigmer Cloud". The shared ../rpcerr.ts would rewrite them
12
+ // into transport advice; here the domain codes pass the server's
13
+ // message through VERBATIM as isError JSON `{error, code}` so the model
14
+ // can stop and adapt.
15
+ //
16
+ // Two deliberate differences from the channels set, each this domain's
17
+ // own contract:
18
+ // - NOT_FOUND is a domain code HERE: the handler's "no conversation
19
+ // with this key exists on channel …" is contract copy, and the
20
+ // shared classifier's rewrite ("Verify the org and slug are
21
+ // correct") names arguments escalate does not take.
22
+ // - No google.rpc.ErrorInfo extraction: the conversation commands
23
+ // attach none — the message alone carries the contract.
24
+ import { Code, ConnectError } from "@connectrpc/connect";
25
+ import { rpcError } from "../rpcerr.js";
26
+ import { errorResult, textResult } from "../toolresult.js";
27
+ /**
28
+ * The gRPC codes whose messages are the conversation domain contract:
29
+ * reach denials (PERMISSION_DENIED, one fail-closed text per failure
30
+ * class), contract misuse with corrective copy (INVALID_ARGUMENT — an
31
+ * empty or over-budget reason), actionable preconditions
32
+ * (FAILED_PRECONDITION — the OSS refusal, a session serving no channel
33
+ * conversation), and the absent-conversation answer (NOT_FOUND).
34
+ */
35
+ const DOMAIN_CODES = new Set([
36
+ Code.PermissionDenied,
37
+ Code.InvalidArgument,
38
+ Code.FailedPrecondition,
39
+ Code.NotFound,
40
+ ]);
41
+ /**
42
+ * Run a conversation-tool body: a string payload becomes a text result;
43
+ * a domain error becomes an isError JSON result carrying the verbatim
44
+ * message; a transport error delegates to the shared classifier. The
45
+ * only try/catch in this domain.
46
+ */
47
+ export async function conversationResult(toolContext, produce) {
48
+ try {
49
+ return textResult(await produce());
50
+ }
51
+ catch (err) {
52
+ const ce = ConnectError.from(err);
53
+ if (DOMAIN_CODES.has(ce.code)) {
54
+ return {
55
+ content: [{ type: "text", text: JSON.stringify(domainError(ce)) }],
56
+ isError: true,
57
+ };
58
+ }
59
+ return errorResult(rpcError(ce, toolContext));
60
+ }
61
+ }
62
+ /** Project a domain ConnectError into the structured tool payload. */
63
+ export function domainError(ce) {
64
+ return {
65
+ error: ce.rawMessage,
66
+ code: grpcStatusName(ce.code),
67
+ };
68
+ }
69
+ /** Connect's PascalCase code name → the gRPC SCREAMING_SNAKE status name. */
70
+ function grpcStatusName(code) {
71
+ return Code[code].replace(/([a-z0-9])([A-Z])/g, "$1_$2").toUpperCase();
72
+ }
73
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../../../src/domains/conversation/errors.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,qEAAqE;AACrE,gEAAgE;AAChE,EAAE;AACF,qEAAqE;AACrE,gEAAgE;AAChE,wEAAwE;AACxE,qEAAqE;AACrE,oEAAoE;AACpE,qEAAqE;AACrE,sEAAsE;AACtE,iEAAiE;AACjE,wEAAwE;AACxE,sBAAsB;AACtB,EAAE;AACF,uEAAuE;AACvE,gBAAgB;AAChB,sEAAsE;AACtE,mEAAmE;AACnE,gEAAgE;AAChE,wDAAwD;AACxD,oEAAoE;AACpE,4DAA4D;AAE5D,OAAO,EAAE,IAAI,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAEzD,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AACxC,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE3D;;;;;;;GAOG;AACH,MAAM,YAAY,GAAsB,IAAI,GAAG,CAAC;IAC9C,IAAI,CAAC,gBAAgB;IACrB,IAAI,CAAC,eAAe;IACpB,IAAI,CAAC,kBAAkB;IACvB,IAAI,CAAC,QAAQ;CACd,CAAC,CAAC;AAUH;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,kBAAkB,CACtC,WAAmB,EACnB,OAA8B;IAE9B,IAAI,CAAC;QACH,OAAO,UAAU,CAAC,MAAM,OAAO,EAAE,CAAC,CAAC;IACrC,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,MAAM,EAAE,GAAG,YAAY,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAClC,IAAI,YAAY,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC;YAC9B,OAAO;gBACL,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC;gBAClE,OAAO,EAAE,IAAI;aACd,CAAC;QACJ,CAAC;QACD,OAAO,WAAW,CAAC,QAAQ,CAAC,EAAE,EAAE,WAAW,CAAC,CAAC,CAAC;IAChD,CAAC;AACH,CAAC;AAED,sEAAsE;AACtE,MAAM,UAAU,WAAW,CAAC,EAAgB;IAC1C,OAAO;QACL,KAAK,EAAE,EAAE,CAAC,UAAU;QACpB,IAAI,EAAE,cAAc,CAAC,EAAE,CAAC,IAAI,CAAC;KAC9B,CAAC;AACJ,CAAC;AAED,6EAA6E;AAC7E,SAAS,cAAc,CAAC,IAAU;IAChC,OAAO,IAAI,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,oBAAoB,EAAE,OAAO,CAAC,CAAC,WAAW,EAAE,CAAC;AACzE,CAAC"}
@@ -0,0 +1,13 @@
1
+ import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
2
+ import { type BackendTarget } from "../client.js";
3
+ /**
4
+ * The success answer (A15): states only recorded fact and repeats the
5
+ * no-promise instruction at the moment of temptation — the model's next
6
+ * message to the customer. Deliberately does NOT claim the flag "shows
7
+ * in the team's console": no console surface renders needs_attention
8
+ * yet (the Conversations surface is T04+); add the claim when it ships.
9
+ */
10
+ export declare const ESCALATION_RECORDED_COPY: string;
11
+ /** Register the conversation participation tool; returns the tool names. */
12
+ export declare function registerConversationTools(server: McpServer, target: BackendTarget): string[];
13
+ //# sourceMappingURL=tools.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../../../src/domains/conversation/tools.ts"],"names":[],"mappings":"AAoBA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAGzE,OAAO,EAAgB,KAAK,aAAa,EAAE,MAAM,cAAc,CAAC;AAiBhE;;;;;;GAMG;AACH,eAAO,MAAM,wBAAwB,QAGY,CAAC;AAElD,4EAA4E;AAC5E,wBAAgB,yBAAyB,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,aAAa,GAAG,MAAM,EAAE,CAiC5F"}
@@ -0,0 +1,69 @@
1
+ // The escalate_to_human tool — the ONE tool of the conversation roster
2
+ // (channel-conversations DD-008 D-b). A14 named the roster
3
+ // stigmer-conversation, axis-named like stigmer-channels: the
4
+ // conditioning axis is "this session IS a live channel conversation",
5
+ // and the notes/loop-in tools DD-008 anticipates join this roster
6
+ // instead of earning new routes.
7
+ //
8
+ // Agent audience only, by construction: escalate derives the
9
+ // conversation identity server-side from the session-scoped credential
10
+ // (the DD-003 identity doctrine), so a direct principal is always
11
+ // refused PERMISSION_DENIED — which is why no variant exists on the
12
+ // full roster and why the input surface is a single `reason`.
13
+ //
14
+ // The tool's answer is FIXED COPY, never the RPC's ChannelConversation
15
+ // row — a deliberate divergence from the channels roster's
16
+ // verbatim-proto-JSON convention. A15 rules the result states only what
17
+ // the platform can keep at 3am (attention is a stored flag; no one is
18
+ // paged; no console surface renders it yet) and instructs the agent
19
+ // never to promise a human or a response time.
20
+ import { z } from "zod";
21
+ import { resolveToken } from "../client.js";
22
+ import { escalateConversation } from "./calls.js";
23
+ import { conversationResult } from "./errors.js";
24
+ const ESCALATE_DESCRIPTION = [
25
+ "Flag this conversation for a human teammate to look at. Use this when you " +
26
+ "cannot resolve the customer's request yourself: you lack the information, " +
27
+ "the request needs a decision you are not authorized to make, or the " +
28
+ "customer has asked for a person.",
29
+ "You keep serving the conversation after calling this. Nothing is handed " +
30
+ "off automatically and no one is paged. Do not tell the customer a human " +
31
+ "will reply, and never promise a response time.",
32
+ "Write the reason for a teammate who has not read the conversation. " +
33
+ "Calling this again with a new reason is safe; the latest reason is what " +
34
+ "they see.",
35
+ ].join("\n\n");
36
+ /**
37
+ * The success answer (A15): states only recorded fact and repeats the
38
+ * no-promise instruction at the moment of temptation — the model's next
39
+ * message to the customer. Deliberately does NOT claim the flag "shows
40
+ * in the team's console": no console surface renders needs_attention
41
+ * yet (the Conversations surface is T04+); add the claim when it ships.
42
+ */
43
+ export const ESCALATION_RECORDED_COPY = "Flagged for human attention. Your reason was recorded on this " +
44
+ "conversation. Keep helping the customer as best you can, and do not " +
45
+ "tell the customer a human will reply or when.";
46
+ /** Register the conversation participation tool; returns the tool names. */
47
+ export function registerConversationTools(server, target) {
48
+ server.registerTool("escalate_to_human", {
49
+ description: ESCALATE_DESCRIPTION,
50
+ inputSchema: {
51
+ // Bounds mirror the protovalidate constraints on
52
+ // EscalateConversationInput.reason (conversation_io.proto:
53
+ // min_len 1, max_len 1024) so the model gets corrective feedback
54
+ // without an RPC; the server's validation is the backstop.
55
+ reason: z
56
+ .string()
57
+ .min(1)
58
+ .max(1024)
59
+ .describe("Why you are escalating, written for a teammate who has not read " +
60
+ "the conversation. Staff see it as the conversation's attention " +
61
+ "reason. 1-1024 characters."),
62
+ },
63
+ }, (args, extra) => conversationResult("escalation", async () => {
64
+ await escalateConversation(target.serverAddress, resolveToken(extra, target.apiKey), args.reason);
65
+ return ESCALATION_RECORDED_COPY;
66
+ }));
67
+ return ["escalate_to_human"];
68
+ }
69
+ //# sourceMappingURL=tools.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tools.js","sourceRoot":"","sources":["../../../src/domains/conversation/tools.ts"],"names":[],"mappings":"AAAA,uEAAuE;AACvE,2DAA2D;AAC3D,8DAA8D;AAC9D,sEAAsE;AACtE,kEAAkE;AAClE,iCAAiC;AACjC,EAAE;AACF,6DAA6D;AAC7D,uEAAuE;AACvE,kEAAkE;AAClE,oEAAoE;AACpE,8DAA8D;AAC9D,EAAE;AACF,uEAAuE;AACvE,2DAA2D;A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