@harrylabsj/kiwi 0.7.9 → 0.7.10

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 (80) hide show
  1. package/contracts/commerce-intent/1.0/schema.json +124 -0
  2. package/contracts/delegation-policy/1.0/schema.json +143 -0
  3. package/contracts/effective-authorization/1.0/schema.json +167 -0
  4. package/contracts/kiwi-contracts.lock.json +1 -1
  5. package/contracts/manifest.json +25 -1
  6. package/contracts/persistent-task/1.0/schema.json +191 -0
  7. package/contracts/vectors/commerce-intent.invalid-no-items.json +7 -0
  8. package/contracts/vectors/commerce-intent.valid.json +32 -0
  9. package/contracts/vectors/delegation-policy.invalid-payment-auto.json +15 -0
  10. package/contracts/vectors/delegation-policy.valid.json +25 -0
  11. package/contracts/vectors/effective-authorization.invalid-deny-wins.json +20 -0
  12. package/contracts/vectors/effective-authorization.valid.json +23 -0
  13. package/contracts/vectors/persistent-task.invalid-no-idempotency.json +7 -0
  14. package/contracts/vectors/persistent-task.valid.json +45 -0
  15. package/dist/a2a/client/url-policy.js +52 -14
  16. package/dist/a2a/client/url-policy.js.map +1 -1
  17. package/dist/a2a/node.js +4 -1
  18. package/dist/a2a/node.js.map +1 -1
  19. package/dist/a2a/signing-key.js +18 -0
  20. package/dist/a2a/signing-key.js.map +1 -1
  21. package/dist/buyer-core/build-service.d.ts +28 -0
  22. package/dist/buyer-core/build-service.js +58 -0
  23. package/dist/buyer-core/build-service.js.map +1 -0
  24. package/dist/buyer-core/errors.d.ts +31 -0
  25. package/dist/buyer-core/errors.js +52 -0
  26. package/dist/buyer-core/errors.js.map +1 -0
  27. package/dist/buyer-core/merchant-index.d.ts +53 -0
  28. package/dist/buyer-core/merchant-index.js +138 -0
  29. package/dist/buyer-core/merchant-index.js.map +1 -0
  30. package/dist/buyer-core/negotiator.d.ts +51 -0
  31. package/dist/buyer-core/negotiator.js +181 -0
  32. package/dist/buyer-core/negotiator.js.map +1 -0
  33. package/dist/buyer-core/quote-fetcher.d.ts +46 -0
  34. package/dist/buyer-core/quote-fetcher.js +166 -0
  35. package/dist/buyer-core/quote-fetcher.js.map +1 -0
  36. package/dist/buyer-core/service.d.ts +192 -0
  37. package/dist/buyer-core/service.js +510 -0
  38. package/dist/buyer-core/service.js.map +1 -0
  39. package/dist/buyer-core/store.d.ts +84 -0
  40. package/dist/buyer-core/store.js +256 -0
  41. package/dist/buyer-core/store.js.map +1 -0
  42. package/dist/cli.js +25 -0
  43. package/dist/cli.js.map +1 -1
  44. package/dist/contracts/northbound-schema.d.ts +27 -0
  45. package/dist/contracts/northbound-schema.js +102 -0
  46. package/dist/contracts/northbound-schema.js.map +1 -0
  47. package/dist/handoff/destination.js +16 -5
  48. package/dist/handoff/destination.js.map +1 -1
  49. package/dist/http/cli.d.ts +16 -0
  50. package/dist/http/cli.js +111 -0
  51. package/dist/http/cli.js.map +1 -0
  52. package/dist/http/server.d.ts +39 -0
  53. package/dist/http/server.js +297 -0
  54. package/dist/http/server.js.map +1 -0
  55. package/dist/mcp/cli.d.ts +61 -0
  56. package/dist/mcp/cli.js +125 -0
  57. package/dist/mcp/cli.js.map +1 -0
  58. package/dist/mcp/server.d.ts +41 -0
  59. package/dist/mcp/server.js +141 -0
  60. package/dist/mcp/server.js.map +1 -0
  61. package/dist/mcp/tools.d.ts +28 -0
  62. package/dist/mcp/tools.js +230 -0
  63. package/dist/mcp/tools.js.map +1 -0
  64. package/dist/mcp/types.d.ts +107 -0
  65. package/dist/mcp/types.js +50 -0
  66. package/dist/mcp/types.js.map +1 -0
  67. package/dist/merchant/ops.d.ts +80 -0
  68. package/dist/merchant/ops.js +75 -0
  69. package/dist/merchant/ops.js.map +1 -0
  70. package/dist/merchant/ucp-profile.d.ts +39 -0
  71. package/dist/merchant/ucp-profile.js +55 -0
  72. package/dist/merchant/ucp-profile.js.map +1 -0
  73. package/dist/product-cli.d.ts +1 -1
  74. package/dist/product-cli.js +1 -1
  75. package/dist/product-cli.js.map +1 -1
  76. package/dist/trust/identity/auth-verifier.js +19 -1
  77. package/dist/trust/identity/auth-verifier.js.map +1 -1
  78. package/dist/trust/identity/message-signature.js +14 -8
  79. package/dist/trust/identity/message-signature.js.map +1 -1
  80. package/package.json +4 -2
@@ -0,0 +1,125 @@
1
+ /**
2
+ * Copyright 2026 harrylabsj
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ /**
17
+ * `kiwi mcp serve` —— 启动 kiwi-buyer-mcp stdio server(战略 v2.5 §6.1/§6.5)。
18
+ *
19
+ * 配置来源:
20
+ * --db <path> 持久 store 路径(默认 ./.kiwi/mcp/state.sqlite)
21
+ * --principal <id> Principal opaque 标识(默认 env KIWI_PRINCIPAL)
22
+ * --agent <id> buyer_agent_id(默认 env KIWI_BUYER_AGENT)
23
+ * --session <id> session_id(默认 env KIWI_SESSION)
24
+ * --policy <file> 冻结 DelegationPolicy JSON(默认 env KIWI_DELEGATION_POLICY;
25
+ * 未提供则用内置安全默认:读 AUTO、accept/handoff ASK、payment NEVER)
26
+ *
27
+ * 执行 seam(MerchantIndex/QuoteFetcher/Negotiator)在 v0.1 CLI 中未接线,由 Phase 2
28
+ * 注入真实 merchant 网络;本 server 负责契约面 + 持久任务/审批状态机。
29
+ */
30
+ import { readFileSync } from "node:fs";
31
+ import path from "node:path";
32
+ import { assertNorthboundContractValid } from "../contracts/northbound-schema.js";
33
+ import { buildBuyerService } from "../buyer-core/build-service.js";
34
+ import { McpServer } from "./server.js";
35
+ import { buildKiwiTools } from "./tools.js";
36
+ export const KIWI_MCP_VERSION = "0.1.0";
37
+ /** 内置安全默认 DelegationPolicy(§5.3 默认映射)。 */
38
+ export const DEFAULT_DELEGATION_POLICY = {
39
+ policy_id: "dp-default",
40
+ version: "1.0",
41
+ principal: "principal:unset",
42
+ expires_at: "2099-12-31T23:59:59Z",
43
+ actions: {
44
+ discover: { mode: "auto" },
45
+ inquiry_rfq: { mode: "auto" },
46
+ compare_offers: { mode: "auto" },
47
+ counter_offer: { mode: "auto", note: "受限 AUTO:受 limits 约束" },
48
+ accept_nonbinding: { mode: "ask" },
49
+ handoff: { mode: "ask" },
50
+ payment: { mode: "never" },
51
+ },
52
+ limits: { max_rounds: 3 },
53
+ };
54
+ function readPolicy(options, principal) {
55
+ const fromEnv = process.env.KIWI_DELEGATION_POLICY;
56
+ if (fromEnv !== undefined && fromEnv.trim() !== "") {
57
+ try {
58
+ return JSON.parse(fromEnv);
59
+ }
60
+ catch {
61
+ throw new Error("KIWI_DELEGATION_POLICY is not valid JSON");
62
+ }
63
+ }
64
+ const raw = options.policy !== undefined
65
+ ? options.policy
66
+ : { ...DEFAULT_DELEGATION_POLICY, principal };
67
+ assertNorthboundContractValid("delegation-policy", raw, "delegation policy");
68
+ return raw;
69
+ }
70
+ export async function runMcpServe(args) {
71
+ const opts = {};
72
+ for (let i = 0; i < args.length; i += 1) {
73
+ const flag = args[i];
74
+ const value = args[i + 1];
75
+ if (value === undefined)
76
+ continue;
77
+ if (flag === "--db")
78
+ opts.db = value;
79
+ else if (flag === "--principal")
80
+ opts.principal = value;
81
+ else if (flag === "--agent")
82
+ opts.buyerAgentId = value;
83
+ else if (flag === "--session")
84
+ opts.sessionId = value;
85
+ else if (flag === "--catalog-url")
86
+ opts.catalogUrl = value;
87
+ else if (flag === "--marketplace-url")
88
+ opts.marketplaceUrl = value;
89
+ else if (flag === "--buyer-bootstrap-token")
90
+ opts.buyerBootstrapToken = value;
91
+ else if (flag === "--policy") {
92
+ try {
93
+ opts.policy = JSON.parse(readFileSync(value, "utf-8"));
94
+ }
95
+ catch {
96
+ process.stderr.write(`cannot read --policy file ${value}\n`);
97
+ return 2;
98
+ }
99
+ }
100
+ }
101
+ const principal = opts.principal ?? process.env.KIWI_PRINCIPAL ?? "principal:local";
102
+ const buyerAgentId = opts.buyerAgentId ?? process.env.KIWI_BUYER_AGENT ?? "buyer-agent:kiwi-mcp";
103
+ const sessionId = opts.sessionId ?? process.env.KIWI_SESSION ?? `session-${process.pid}`;
104
+ const policy = readPolicy(opts, principal);
105
+ const dbPath = opts.db ?? path.join(".kiwi", "mcp", "state.sqlite");
106
+ // 单核心多包装:MCP 与 HTTP 共用同一 buildBuyerService(§6.3)。
107
+ const service = buildBuyerService({
108
+ dbPath,
109
+ principal,
110
+ buyerAgentId,
111
+ sessionId,
112
+ policy,
113
+ catalogUrl: opts.catalogUrl,
114
+ marketplaceUrl: opts.marketplaceUrl,
115
+ buyerBootstrapToken: opts.buyerBootstrapToken ?? process.env.SHOPPING_BUYER_BOOTSTRAP_TOKEN,
116
+ });
117
+ const tools = buildKiwiTools(service);
118
+ const server = new McpServer({
119
+ tools,
120
+ serverInfo: { name: "kiwi-buyer-mcp", version: KIWI_MCP_VERSION },
121
+ });
122
+ await server.serve();
123
+ return 0;
124
+ }
125
+ //# sourceMappingURL=cli.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.js","sourceRoot":"","sources":["../../src/mcp/cli.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,EAAE,6BAA6B,EAAE,MAAM,mCAAmC,CAAC;AAClF,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AACnE,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAE5C,MAAM,CAAC,MAAM,gBAAgB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AS,GAAG,IAAI,CAAC,SAAS,IAAI,OAAO,CAAC,GAAG,CAAC,cAAc,IAAI,iBAAiB,CAAC;IACpF,MAAM,YAAY,GAAG,IAAI,CAAC,YAAY,IAAI,OAAO,CAAC,GAAG,CAAC,gBAAgB,IAAI,sBAAsB,CAAC;IACjG,MAAM,SAAS,GAAG,IAAI,CAAC,SAAS,IAAI,OAAO,CAAC,GAAG,CAAC,YAAY,IAAI,WAAW,OAAO,CAAC,GAAG,EAAE,CAAC;IACzF,MAAM,MAAM,GAAG,UAAU,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;IAC3C,MAAM,MAAM,GAAG,IAAI,CAAC,EAAE,IAAI,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,KAAK,EAAE,cAAc,CAAC,CAAC;IACpE,kDAAkD;IAClD,MAAM,OAAO,GAAG,iBAAiB,CAAC;QAChC,MAAM;QACN,SAAS;QACT,YAAY;QACZ,SAAS;QACT,MAAM;QACN,UAAU,EAAE,IAAI,CAAC,UAAU;QAC3B,cAAc,EAAE,IAAI,CAAC,cAAc;QACnC,mBAAmB,EAAE,IAAI,CAAC,mBAAmB,IAAI,OAAO,CAAC,GAAG,CAAC,8BAA8B;KAC5F,CAAC,CAAC;IACH,MAAM,KAAK,GAAG,cAAc,CAAC,OAAO,CAAC,CAAC;IACtC,MAAM,MAAM,GAAG,IAAI,SAAS,CAAC;QAC3B,KAAK;QACL,UAAU,EAAE,EAAE,IAAI,EAAE,gBAAgB,EAAE,OAAO,EAAE,gBAAgB,EAAE;KAClE,CAAC,CAAC;IACH,MAAM,MAAM,CAAC,KAAK,EAAE,CAAC;IACrB,OAAO,CAAC,CAAC;AACX,CAAC"}
@@ -0,0 +1,41 @@
1
+ /**
2
+ * Copyright 2026 harrylabsj
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ import { type JsonRpcResponse } from "./types.js";
17
+ import type { KiwiToolDefinition } from "./types.js";
18
+ export interface McpServerOptions {
19
+ tools: KiwiToolDefinition[];
20
+ serverInfo: {
21
+ name: string;
22
+ version: string;
23
+ };
24
+ }
25
+ export declare class McpServer {
26
+ private readonly tools;
27
+ private readonly serverInfo;
28
+ private initialized;
29
+ private initRequested;
30
+ constructor(options: McpServerOptions);
31
+ /** 处理单个 JSON-RPC 消息,返回响应(notification 返回 undefined)。 */
32
+ handleMessage(raw: string): Promise<JsonRpcResponse | undefined>;
33
+ private requireInit;
34
+ private handleInitialize;
35
+ private handleListTools;
36
+ private handleCallTool;
37
+ private result;
38
+ private error;
39
+ /** 阻塞运行 stdio 循环(CLI 入口)。逐行读 stdin,逐行写 stdout。 */
40
+ serve(): Promise<void>;
41
+ }
@@ -0,0 +1,141 @@
1
+ /**
2
+ * Copyright 2026 harrylabsj
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ /**
17
+ * kiwi-buyer-mcp stdio server(战略 v2.5 §6.1)。
18
+ *
19
+ * 最小 JSON-RPC 2.0 MCP 实现:initialize 握手(version negotiation,fail-closed)、
20
+ * notifications/initialized、tools/list、tools/call;未实现方法一律
21
+ * METHOD_NOT_FOUND;初始化前调用 tools/* 返回 SERVER_NOT_INITIALIZED。
22
+ * 一行一行读 stdin(readline),每行一个 JSON-RPC 消息,响应写 stdout 换行分隔。
23
+ *
24
+ * 本 server 不持有任何商业状态——状态唯一权威在 KiwiBuyerService 的持久 store。
25
+ * 输入/输出均投影,不保存第二套状态机(§6.2)。
26
+ */
27
+ import { createInterface } from "node:readline";
28
+ import { MCP_ERROR } from "./types.js";
29
+ import { MCP_PROTOCOL_VERSIONS } from "./types.js";
30
+ import { McpError } from "../buyer-core/errors.js";
31
+ export class McpServer {
32
+ tools;
33
+ serverInfo;
34
+ initialized = false;
35
+ initRequested = false;
36
+ constructor(options) {
37
+ this.tools = new Map(options.tools.map((t) => [t.name, t]));
38
+ this.serverInfo = options.serverInfo;
39
+ }
40
+ /** 处理单个 JSON-RPC 消息,返回响应(notification 返回 undefined)。 */
41
+ async handleMessage(raw) {
42
+ let request;
43
+ try {
44
+ request = JSON.parse(raw);
45
+ }
46
+ catch {
47
+ return this.error(null, MCP_ERROR.PARSE_ERROR, "parse error: not valid JSON");
48
+ }
49
+ if (request.jsonrpc !== "2.0" || typeof request.method !== "string") {
50
+ return this.error(request.id, MCP_ERROR.INVALID_REQUEST, "invalid request: expected jsonrpc 2.0 request");
51
+ }
52
+ try {
53
+ switch (request.method) {
54
+ case "initialize":
55
+ return await this.handleInitialize(request);
56
+ case "notifications/initialized":
57
+ if (this.initRequested)
58
+ this.initialized = true;
59
+ return undefined;
60
+ case "tools/list":
61
+ return this.requireInit(request, () => this.handleListTools(request));
62
+ case "tools/call":
63
+ return this.requireInit(request, () => this.handleCallTool(request));
64
+ default:
65
+ return this.error(request.id, MCP_ERROR.METHOD_NOT_FOUND, `method not found: ${request.method}`);
66
+ }
67
+ }
68
+ catch (error) {
69
+ if (error instanceof McpError) {
70
+ return this.error(request.id, error.toJsonRpc().code, error.message, error.detail);
71
+ }
72
+ return this.error(request.id, MCP_ERROR.INTERNAL_ERROR, `internal error: ${error instanceof Error ? error.message : String(error)}`);
73
+ }
74
+ }
75
+ async requireInit(request, fn) {
76
+ if (!this.initialized) {
77
+ return this.error(request.id, MCP_ERROR.SERVER_NOT_INITIALIZED, "server not initialized: call initialize first");
78
+ }
79
+ return fn();
80
+ }
81
+ async handleInitialize(request) {
82
+ const params = (request.params ?? {});
83
+ const requested = params.protocolVersion;
84
+ if (typeof requested !== "string" || !MCP_PROTOCOL_VERSIONS.includes(requested)) {
85
+ // version negotiation fail-closed:未知版本拒绝(§6.10 兼容矩阵 fail closed)。
86
+ return this.error(request.id, MCP_ERROR.INVALID_PARAMS, `unsupported MCP protocol version: ${String(requested)}`);
87
+ }
88
+ // 规范:initialize 只协商版本;随后客户端发 notifications/initialized 后才允许
89
+ // tools/*。因此这里只标记 initRequested,不放行工具调用。
90
+ this.initRequested = true;
91
+ const result = {
92
+ protocolVersion: requested,
93
+ capabilities: { tools: { listChanged: false } },
94
+ serverInfo: this.serverInfo,
95
+ };
96
+ return this.result(request.id, result);
97
+ }
98
+ handleListTools(request) {
99
+ const result = {
100
+ tools: [...this.tools.values()].map((t) => ({
101
+ name: t.name,
102
+ description: t.description,
103
+ inputSchema: t.inputSchema,
104
+ })),
105
+ };
106
+ return this.result(request.id, result);
107
+ }
108
+ async handleCallTool(request) {
109
+ const params = (request.params ?? {});
110
+ if (typeof params.name !== "string") {
111
+ return this.error(request.id, MCP_ERROR.INVALID_PARAMS, "tools/call requires params.name");
112
+ }
113
+ const tool = this.tools.get(params.name);
114
+ if (tool === undefined) {
115
+ return this.error(request.id, MCP_ERROR.TOOL_NOT_FOUND, `tool not found: ${params.name}`);
116
+ }
117
+ const args = params.arguments !== undefined && typeof params.arguments === "object"
118
+ ? params.arguments
119
+ : {};
120
+ const toolResult = await tool.handle(args);
121
+ return this.result(request.id, toolResult);
122
+ }
123
+ result(id, result) {
124
+ return { jsonrpc: "2.0", id, result };
125
+ }
126
+ error(id, code, message, data) {
127
+ return { jsonrpc: "2.0", id, error: { code, message, data } };
128
+ }
129
+ /** 阻塞运行 stdio 循环(CLI 入口)。逐行读 stdin,逐行写 stdout。 */
130
+ async serve() {
131
+ const rl = createInterface({ input: process.stdin });
132
+ for await (const line of rl) {
133
+ if (line.trim() === "")
134
+ continue;
135
+ const response = await this.handleMessage(line);
136
+ if (response !== undefined)
137
+ process.stdout.write(`${JSON.stringify(response)}\n`);
138
+ }
139
+ }
140
+ }
141
+ //# sourceMappingURL=server.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server.js","sourceRoot":"","sources":["../../src/mcp/server.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EAAE,SAAS,EAAmF,MAAM,YAAY,CAAC;AACxH,OAAO,EAAE,qBAAqB,EAAqD,MAAM,YAAY,CAAC;AACtG,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AAQnD,MAAM,OAAO,SAAS;IACH,KAAK,CAAkC;IACvC,UAAU,CAAoC;IACvD,WAAW,GAAG,KAAK,CAAC;IACpB,aAAa,GAAG,KAAK,CAAC;IAE9B,YAAY,OAAyB;QACnC,IAAI,CAAC,KAAK,GAAG,IAAI,GAAG,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;QAC5D,IAAI,CAAC,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC;IACvC,CAAC;IAED,wDAAwD;IACxD,KAAK,CAAC,aAAa,CAAC,GAAW;QAC7B,IAAI,OAAuB,CAAC;QAC5B,IAAI,CAAC;YACH,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAmB,CAAC;QAC9C,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,SAAS,CAAC,WAAW,EAAE,6BAA6B,CAAC,CAAC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C,CAAC;IAEO,MAAM,CAAC,EAA0B,EAAE,MAAe;QACxD,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,EAAE,EAAE,MAAM,EAAE,CAAC;IACxC,CAAC;IAEO,KAAK,CAAC,EAA0B,EAAE,IAAY,EAAE,OAAe,EAAE,IAAc;QACrF,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,EAAE,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,CAAC;IAChE,CAAC;IAED,kDAAkD;IAClD,KAAK,CAAC,KAAK;QACT,MAAM,EAAE,GAAG,eAAe,CAAC,EAAE,KAAK,EAAE,OAAO,CAAC,KAAK,EAAE,CAAC,CAAC;QACrD,IAAI,KAAK,EAAE,MAAM,IAAI,IAAI,EAAE,EAAE,CAAC;YAC5B,IAAI,IAAI,CAAC,IAAI,EAAE,KAAK,EAAE;gBAAE,SAAS;YACjC,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;YAChD,IAAI,QAAQ,KAAK,SAAS;gBAAE,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;QACpF,CAAC;IACH,CAAC;CACF"}
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Copyright 2026 harrylabsj
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ /**
17
+ * 7 个高层 Kiwi Sourcing Tools(战略 v2.5 §6.1,词表单一来源见 KIWI_SOURCING_TOOLS)。
18
+ *
19
+ * 原则:不暴露 KNP 每个底层消息、不复制 UCP 的 Catalog/Checkout tools;宿主 Agent
20
+ * 用少量跨 Merchant 高层工具完成『找供应商 → RFQ → 比较 → 磋商 → Agreement →
21
+ * UCP handoff』编排。每个写工具绑定 idempotency_key 并返回稳定 task_id /
22
+ * candidate_id / approval_id / agreement_id(§6.2)。业务错误经 isError 带内返回,
23
+ * 错误分类(McpError.code)作为跨宿主语义不变量(§6.10)。
24
+ */
25
+ import type { KiwiToolDefinition } from "./types.js";
26
+ import { KiwiBuyerService } from "../buyer-core/service.js";
27
+ /** 构造 7 个高层工具。任意 handler 抛出的 McpError 都会被转成 isError 结果。 */
28
+ export declare function buildKiwiTools(service: KiwiBuyerService): KiwiToolDefinition[];
@@ -0,0 +1,230 @@
1
+ /**
2
+ * Copyright 2026 harrylabsj
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ import { McpError } from "../buyer-core/errors.js";
17
+ import { KiwiBuyerService } from "../buyer-core/service.js";
18
+ function ok(text) {
19
+ return { content: [{ type: "text", text }] };
20
+ }
21
+ function err(error) {
22
+ if (error instanceof McpError) {
23
+ return {
24
+ content: [{ type: "text", text: `error ${error.code}: ${error.message}` }],
25
+ isError: true,
26
+ };
27
+ }
28
+ return {
29
+ content: [{ type: "text", text: `error internal_error: ${error instanceof Error ? error.message : String(error)}` }],
30
+ isError: true,
31
+ };
32
+ }
33
+ /** 构造 7 个高层工具。任意 handler 抛出的 McpError 都会被转成 isError 结果。 */
34
+ export function buildKiwiTools(service) {
35
+ const tools = [
36
+ {
37
+ name: "kiwi_search",
38
+ description: "发现候选供应商,并按需跨商家搜索商品。只读。内部语义:Merchant routing + UCP Catalog orchestration + trust/freshness。",
39
+ inputSchema: {
40
+ $schema: "https://json-schema.org/draft/2020-12/schema",
41
+ type: "object",
42
+ additionalProperties: false,
43
+ required: ["query"],
44
+ properties: {
45
+ query: { type: "string", minLength: 1 },
46
+ category: { type: "string" },
47
+ region: { type: "string" },
48
+ },
49
+ },
50
+ async handle(args) {
51
+ try {
52
+ const result = await service.search({
53
+ query: String(args.query),
54
+ category: args.category === undefined ? undefined : String(args.category),
55
+ region: args.region === undefined ? undefined : String(args.region),
56
+ });
57
+ return ok(JSON.stringify({ merchants: result.merchants, note: result.note }));
58
+ }
59
+ catch (error) {
60
+ return err(error);
61
+ }
62
+ },
63
+ },
64
+ {
65
+ name: "kiwi_request_quotes",
66
+ description: "向一个或多个商家发起询价。写操作;必须携带 idempotency_key(可选,缺省自动生成),返回稳定 task_id;KNP RFQ fan-out。CommerceIntent 必须满足冻结契约。",
67
+ inputSchema: {
68
+ $schema: "https://json-schema.org/draft/2020-12/schema",
69
+ type: "object",
70
+ additionalProperties: false,
71
+ required: ["intent"],
72
+ properties: {
73
+ intent: {
74
+ type: "object",
75
+ additionalProperties: true,
76
+ required: ["intent_id", "intent_type", "items"],
77
+ properties: {
78
+ intent_id: { type: "string", minLength: 1 },
79
+ intent_type: { type: "string", enum: ["purchase", "procurement", "inquiry"] },
80
+ items: { type: "array", minItems: 1 },
81
+ },
82
+ },
83
+ idempotency_key: { type: "string", minLength: 1 },
84
+ merchant_ids: { type: "array", items: { type: "string", minLength: 1 } },
85
+ },
86
+ },
87
+ async handle(args) {
88
+ try {
89
+ const result = await service.requestQuotes({
90
+ intent: (args.intent ?? {}),
91
+ idempotency_key: args.idempotency_key === undefined ? undefined : String(args.idempotency_key),
92
+ merchant_ids: args.merchant_ids === undefined
93
+ ? undefined
94
+ : args.merchant_ids.map(String),
95
+ });
96
+ return ok(JSON.stringify({ task_id: result.task.task_id, task: result.task, created: result.created }));
97
+ }
98
+ catch (error) {
99
+ return err(error);
100
+ }
101
+ },
102
+ },
103
+ {
104
+ name: "kiwi_get_task",
105
+ description: "读取任务状态、报价、部分失败、待审批与过期信息。统一 status/resume 读取面;替代把 offer/pending 状态放在插件内存。",
106
+ inputSchema: {
107
+ $schema: "https://json-schema.org/draft/2020-12/schema",
108
+ type: "object",
109
+ additionalProperties: false,
110
+ required: ["task_id"],
111
+ properties: { task_id: { type: "string", minLength: 1 } },
112
+ },
113
+ async handle(args) {
114
+ try {
115
+ return ok(JSON.stringify(service.getTask(String(args.task_id))));
116
+ }
117
+ catch (error) {
118
+ return err(error);
119
+ }
120
+ },
121
+ },
122
+ {
123
+ name: "kiwi_negotiate",
124
+ description: "在委托边界内推进磋商。更新同一 task_id;CounterOffer / Clarification;可产生 candidate_id;受 DelegationPolicy max_rounds 等硬约束。",
125
+ inputSchema: {
126
+ $schema: "https://json-schema.org/draft/2020-12/schema",
127
+ type: "object",
128
+ additionalProperties: false,
129
+ required: ["task_id", "action", "summary"],
130
+ properties: {
131
+ task_id: { type: "string", minLength: 1 },
132
+ action: { type: "string", enum: ["counter_offer", "clarification"] },
133
+ summary: { type: "string", minLength: 1 },
134
+ },
135
+ },
136
+ async handle(args) {
137
+ try {
138
+ const result = await service.negotiate({
139
+ task_id: String(args.task_id),
140
+ action: args.action,
141
+ summary: String(args.summary),
142
+ });
143
+ return ok(JSON.stringify(result));
144
+ }
145
+ catch (error) {
146
+ return err(error);
147
+ }
148
+ },
149
+ },
150
+ {
151
+ name: "kiwi_accept_agreement",
152
+ description: "请求确认并接受非绑定协议。要求有效 approval_id + candidate_id;输出稳定 agreement_id。DelegationPolicy=ask 时若缺审批会返回 approval_required(含持久 approval_id),宿主完成人工审批后携 approval_id 重试。",
153
+ inputSchema: {
154
+ $schema: "https://json-schema.org/draft/2020-12/schema",
155
+ type: "object",
156
+ additionalProperties: false,
157
+ required: ["task_id", "candidate_id"],
158
+ properties: {
159
+ task_id: { type: "string", minLength: 1 },
160
+ candidate_id: { type: "string", minLength: 1 },
161
+ approval_id: { type: "string", minLength: 1 },
162
+ },
163
+ },
164
+ async handle(args) {
165
+ try {
166
+ const result = await service.acceptAgreement({
167
+ task_id: String(args.task_id),
168
+ candidate_id: String(args.candidate_id),
169
+ approval_id: args.approval_id === undefined ? undefined : String(args.approval_id),
170
+ });
171
+ return ok(JSON.stringify(result));
172
+ }
173
+ catch (error) {
174
+ return err(error);
175
+ }
176
+ },
177
+ },
178
+ {
179
+ name: "kiwi_get_agreement",
180
+ description: "读取最终协议、provenance 与审计摘要。只读;Agreement retrieval + digest + audit summary。",
181
+ inputSchema: {
182
+ $schema: "https://json-schema.org/draft/2020-12/schema",
183
+ type: "object",
184
+ additionalProperties: false,
185
+ required: ["agreement_id"],
186
+ properties: { agreement_id: { type: "string", minLength: 1 } },
187
+ },
188
+ async handle(args) {
189
+ try {
190
+ return ok(JSON.stringify(service.getAgreement(String(args.agreement_id))));
191
+ }
192
+ catch (error) {
193
+ return err(error);
194
+ }
195
+ },
196
+ },
197
+ {
198
+ name: "kiwi_handoff",
199
+ description: "生成交易/PO/联系路径。要求持久 approval;Agreement → UCP Checkout / merchant transaction endpoint。",
200
+ inputSchema: {
201
+ $schema: "https://json-schema.org/draft/2020-12/schema",
202
+ type: "object",
203
+ additionalProperties: false,
204
+ required: ["agreement_id", "approval_id", "destination_type"],
205
+ properties: {
206
+ agreement_id: { type: "string", minLength: 1 },
207
+ approval_id: { type: "string", minLength: 1 },
208
+ destination_type: { type: "string", minLength: 1 },
209
+ url: { type: "string" },
210
+ },
211
+ },
212
+ async handle(args) {
213
+ try {
214
+ const result = await service.handoff({
215
+ agreement_id: String(args.agreement_id),
216
+ approval_id: String(args.approval_id),
217
+ destination_type: String(args.destination_type),
218
+ url: args.url === undefined ? undefined : String(args.url),
219
+ });
220
+ return ok(JSON.stringify(result));
221
+ }
222
+ catch (error) {
223
+ return err(error);
224
+ }
225
+ },
226
+ },
227
+ ];
228
+ return tools.map(({ raw: _raw, ...t }) => t);
229
+ }
230
+ //# sourceMappingURL=tools.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tools.js","sourceRoot":"","sources":["../../src/mcp/tools.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAaH,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AACnD,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAE5D,SAAS,EAAE,CAAC,IAAY;IACtB,OAAO,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC;AAC/C,CAAC;AAED,SAAS,GAAG,CAAC,KAAc;IACzB,IAAI,KAAK,YAAY,QAAQ,EAAE,CAAC;QAC9B,OAAO;YACL,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,KAAK,CAAC,IAAI,KAAK,KAAK,CAAC,OAAO,EAAE,EAAE,CAAC;YAC1E,OAAO,EAAE,IAAI;SACd,CAAC;IACJ,CAAC;IACD,OAAO;QACL,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,yBAAyB,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,EAAE,CAAC;QACpH,OAAO,EAAE,IAAI;KACd,CAAC;AACJ,CAAC;AAED,2DAA2D;AAC3D,MAAM,UAAU,cAAc,CAAC,OAAyB;IACtD,MAAM,KAAK,GAAkD;QAC3D;YACE,IAAI,EAAE,aAAa;YACnB,WAAW,EACT,4FAA4F;YAC9F,WAAW,EAAE;gBACX,OAAO,EAAE,8CAA8C;gBACvD,IAAI,EAAE,QAAQ;gBACd,oBAAoB,EAAE,KAAK;gBAC3B,QAAQ,EAAE,CAAC,OAAO,CA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