@harrylabsj/kiwi 0.7.21 → 0.8.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 (146) hide show
  1. package/README.md +45 -10
  2. package/dist/a2a/node.js +1 -1
  3. package/dist/a2a/node.js.map +1 -1
  4. package/dist/agent/buyer/buyer-tools.d.ts +7 -0
  5. package/dist/agent/buyer/buyer-tools.js +53 -0
  6. package/dist/agent/buyer/buyer-tools.js.map +1 -1
  7. package/dist/agent/buyer/scheduler.d.ts +4 -0
  8. package/dist/agent/buyer/scheduler.js +5 -1
  9. package/dist/agent/buyer/scheduler.js.map +1 -1
  10. package/dist/agent/buyer/task-store.d.ts +5 -0
  11. package/dist/agent/buyer/task-store.js +13 -0
  12. package/dist/agent/buyer/task-store.js.map +1 -1
  13. package/dist/agent/chat-tools.js +10 -3
  14. package/dist/agent/chat-tools.js.map +1 -1
  15. package/dist/agent/context/fencing.d.ts +27 -0
  16. package/dist/agent/context/fencing.js +126 -0
  17. package/dist/agent/context/fencing.js.map +1 -0
  18. package/dist/agent/context/grounding.d.ts +18 -0
  19. package/dist/agent/context/grounding.js +22 -0
  20. package/dist/agent/context/grounding.js.map +1 -0
  21. package/dist/agent/host/events.d.ts +31 -0
  22. package/dist/agent/host/events.js +62 -0
  23. package/dist/agent/host/events.js.map +1 -0
  24. package/dist/agent/host/tui-renderer.d.ts +17 -0
  25. package/dist/agent/host/tui-renderer.js +125 -0
  26. package/dist/agent/host/tui-renderer.js.map +1 -0
  27. package/dist/agent/host/web-renderer.d.ts +71 -0
  28. package/dist/agent/host/web-renderer.js +185 -0
  29. package/dist/agent/host/web-renderer.js.map +1 -0
  30. package/dist/agent/kernel-builder.d.ts +3 -1
  31. package/dist/agent/kernel-builder.js +4 -1
  32. package/dist/agent/kernel-builder.js.map +1 -1
  33. package/dist/agent/kernel.d.ts +22 -1
  34. package/dist/agent/kernel.js +294 -22
  35. package/dist/agent/kernel.js.map +1 -1
  36. package/dist/agent/memory/schema.d.ts +1 -1
  37. package/dist/agent/memory/schema.js +67 -1
  38. package/dist/agent/memory/schema.js.map +1 -1
  39. package/dist/agent/merchant/intelligence/backend.d.ts +40 -0
  40. package/dist/agent/merchant/intelligence/backend.js +2 -0
  41. package/dist/agent/merchant/intelligence/backend.js.map +1 -0
  42. package/dist/agent/merchant/intelligence/default-backend.d.ts +38 -0
  43. package/dist/agent/merchant/intelligence/default-backend.js +454 -0
  44. package/dist/agent/merchant/intelligence/default-backend.js.map +1 -0
  45. package/dist/agent/merchant/intelligence/http-analytics-source.d.ts +55 -0
  46. package/dist/agent/merchant/intelligence/http-analytics-source.js +193 -0
  47. package/dist/agent/merchant/intelligence/http-analytics-source.js.map +1 -0
  48. package/dist/agent/merchant/intelligence/types.d.ts +109 -0
  49. package/dist/agent/merchant/intelligence/types.js +2 -0
  50. package/dist/agent/merchant/intelligence/types.js.map +1 -0
  51. package/dist/agent/merchant/merchant-enrichment.d.ts +10 -0
  52. package/dist/agent/merchant/merchant-enrichment.js +38 -0
  53. package/dist/agent/merchant/merchant-enrichment.js.map +1 -0
  54. package/dist/agent/merchant/merchant-grounding.d.ts +5 -0
  55. package/dist/agent/merchant/merchant-grounding.js +76 -0
  56. package/dist/agent/merchant/merchant-grounding.js.map +1 -0
  57. package/dist/agent/merchant/merchant-presentations.d.ts +8 -0
  58. package/dist/agent/merchant/merchant-presentations.js +184 -0
  59. package/dist/agent/merchant/merchant-presentations.js.map +1 -0
  60. package/dist/agent/merchant/merchant-tools.d.ts +8 -0
  61. package/dist/agent/merchant/merchant-tools.js +208 -9
  62. package/dist/agent/merchant/merchant-tools.js.map +1 -1
  63. package/dist/agent/presentation/registry.d.ts +14 -0
  64. package/dist/agent/presentation/registry.js +24 -0
  65. package/dist/agent/presentation/registry.js.map +1 -0
  66. package/dist/agent/presentation/runner.d.ts +11 -0
  67. package/dist/agent/presentation/runner.js +17 -0
  68. package/dist/agent/presentation/runner.js.map +1 -0
  69. package/dist/agent/presentation/sanitize.d.ts +16 -0
  70. package/dist/agent/presentation/sanitize.js +37 -0
  71. package/dist/agent/presentation/sanitize.js.map +1 -0
  72. package/dist/agent/presentation/types.d.ts +28 -0
  73. package/dist/agent/presentation/types.js +8 -0
  74. package/dist/agent/presentation/types.js.map +1 -0
  75. package/dist/agent/session.d.ts +1 -1
  76. package/dist/agent/session.js +2 -2
  77. package/dist/agent/session.js.map +1 -1
  78. package/dist/agent/skills/registry.d.ts +11 -0
  79. package/dist/agent/skills/registry.js +119 -0
  80. package/dist/agent/skills/registry.js.map +1 -0
  81. package/dist/agent/skills/tools.d.ts +6 -0
  82. package/dist/agent/skills/tools.js +36 -0
  83. package/dist/agent/skills/tools.js.map +1 -0
  84. package/dist/agent/skills/types.d.ts +9 -0
  85. package/dist/agent/skills/types.js +2 -0
  86. package/dist/agent/skills/types.js.map +1 -0
  87. package/dist/agent/supplier/scheduler.d.ts +86 -0
  88. package/dist/agent/supplier/scheduler.js +618 -0
  89. package/dist/agent/supplier/scheduler.js.map +1 -0
  90. package/dist/agent/supplier/store.d.ts +173 -0
  91. package/dist/agent/supplier/store.js +387 -0
  92. package/dist/agent/supplier/store.js.map +1 -0
  93. package/dist/agent/system-prompt.d.ts +5 -1
  94. package/dist/agent/system-prompt.js +20 -3
  95. package/dist/agent/system-prompt.js.map +1 -1
  96. package/dist/cli.d.ts +5 -0
  97. package/dist/cli.js +177 -12
  98. package/dist/cli.js.map +1 -1
  99. package/dist/config/profile.d.ts +21 -0
  100. package/dist/config/profile.js +59 -0
  101. package/dist/config/profile.js.map +1 -1
  102. package/dist/discovery/catalog-source/kiwi-record.d.ts +2 -0
  103. package/dist/discovery/catalog-source/kiwi-record.js.map +1 -1
  104. package/dist/discovery/catalog-source/kiwi-source.js +2 -0
  105. package/dist/discovery/catalog-source/kiwi-source.js.map +1 -1
  106. package/dist/handoff/authorization.js +1 -1
  107. package/dist/http/merchant-server.d.ts +65 -0
  108. package/dist/http/merchant-server.js +346 -0
  109. package/dist/http/merchant-server.js.map +1 -0
  110. package/dist/merchant/stats-store.d.ts +7 -0
  111. package/dist/merchant/stats-store.js +11 -0
  112. package/dist/merchant/stats-store.js.map +1 -1
  113. package/dist/negotiation/action-candidate.js +1 -1
  114. package/dist/operator/types.d.ts +1 -1
  115. package/dist/product-cli.d.ts +2 -2
  116. package/dist/product-cli.js +14 -2
  117. package/dist/product-cli.js.map +1 -1
  118. package/dist/product-supplier.d.ts +148 -0
  119. package/dist/product-supplier.js +452 -0
  120. package/dist/product-supplier.js.map +1 -0
  121. package/dist/runtime/fake-model.d.ts +1 -1
  122. package/dist/trust/identity/jwk.d.ts +11 -0
  123. package/dist/trust/identity/jwk.js +2 -0
  124. package/dist/trust/identity/jwk.js.map +1 -0
  125. package/dist/trust/identity/jws.d.ts +2 -1
  126. package/dist/trust/identity/jws.js.map +1 -1
  127. package/dist/trust/identity/keys.d.ts +2 -1
  128. package/dist/trust/identity/keys.js.map +1 -1
  129. package/dist/trust/identity/message-signature.d.ts +1 -14
  130. package/dist/trust/identity/message-signature.js.map +1 -1
  131. package/dist/weixin/channel.d.ts +3 -0
  132. package/dist/weixin/channel.js +18 -2
  133. package/dist/weixin/channel.js.map +1 -1
  134. package/examples/profiles/merchant.deepseek.yaml +6 -0
  135. package/examples/profiles/merchant.fake.yaml +6 -0
  136. package/examples/profiles/merchant.local.yaml +6 -0
  137. package/package.json +7 -6
  138. package/skills/kiwi-buyer/SKILL.md +66 -0
  139. package/skills/merchant/catalog-operations/SKILL.md +17 -0
  140. package/skills/merchant/change-approval/SKILL.md +16 -0
  141. package/skills/merchant/human-review/SKILL.md +17 -0
  142. package/skills/merchant/inventory-operations/SKILL.md +17 -0
  143. package/skills/merchant/negotiation-review/SKILL.md +18 -0
  144. package/skills/merchant/performance-insights/SKILL.md +19 -0
  145. package/contracts/candidate-agent-dto-1.0.README.md +0 -43
  146. package/contracts/conformance/python-service/README.md +0 -19
@@ -0,0 +1,148 @@
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 SupplierRelationshipType } from "./agent/supplier/store.js";
17
+ export interface SupplierCommandOptions {
18
+ dataDir?: string;
19
+ agentId?: string;
20
+ }
21
+ export interface SupplierSummary {
22
+ relationship_id: string;
23
+ merchant_id: string;
24
+ canonical_domain: string;
25
+ relationship_type: SupplierRelationshipType;
26
+ status: string;
27
+ consent_source: string;
28
+ scope: Record<string, unknown>;
29
+ policy: Record<string, unknown>;
30
+ created_at: string;
31
+ updated_at: string;
32
+ expires_at?: string;
33
+ }
34
+ export interface SupplierSaveOptions extends SupplierCommandOptions {
35
+ merchantId: string;
36
+ catalogUrl?: string;
37
+ }
38
+ /** `kiwi buyer supplier save <merchant-id>`:保存身份,不轮询(§2.1)。 */
39
+ export declare function supplierSave(options: SupplierSaveOptions): Promise<SupplierSummary>;
40
+ export interface SupplierWatchOptions extends SupplierCommandOptions {
41
+ merchantId: string;
42
+ catalogUrl?: string;
43
+ query?: string;
44
+ region?: string;
45
+ /** 轮询间隔(秒);缺省 6h,下限 1h(§8:不做分钟级轮询)。 */
46
+ intervalSeconds?: number;
47
+ /** 如 "90d";缺省 90d,主动观察关系不允许无限期。 */
48
+ expires?: string;
49
+ yes?: boolean;
50
+ confirm?: () => Promise<boolean>;
51
+ }
52
+ /** `kiwi buyer supplier watch <merchant-id>`:建立主动观察规则(§2.2)。 */
53
+ export declare function supplierWatch(options: SupplierWatchOptions): Promise<SupplierSummary>;
54
+ export interface SupplierPreferOptions extends SupplierCommandOptions {
55
+ merchantId: string;
56
+ catalogUrl?: string;
57
+ scope?: string;
58
+ /** 如 "90d"(§11 CLI 形式)。 */
59
+ expires?: string;
60
+ yes?: boolean;
61
+ confirm?: () => Promise<boolean>;
62
+ }
63
+ /** `kiwi buyer supplier prefer <merchant-id>`:采购范围内的软偏好(§2.3)。 */
64
+ export declare function supplierPrefer(options: SupplierPreferOptions): Promise<SupplierSummary>;
65
+ /** `kiwi buyer supplier list`。 */
66
+ export declare function supplierList(options: SupplierCommandOptions): Promise<SupplierSummary[]>;
67
+ export interface SupplierIdOptions extends SupplierCommandOptions {
68
+ relationshipId: string;
69
+ }
70
+ /** `kiwi buyer supplier pause <relationship-id>`。 */
71
+ export declare function supplierPause(options: SupplierIdOptions): Promise<SupplierSummary>;
72
+ /**
73
+ * `kiwi buyer supplier remove <relationship-id>`:软删——立即停止后续拉取并
74
+ * 清除未来调度(§11)。M3 之前 receipt_status 恒为 none,无需远端 revoke;
75
+ * 若将来存在有效 receipt,先 best-effort revoke 但远端不可达不阻塞本地删除。
76
+ */
77
+ export declare function supplierRemove(options: SupplierIdOptions): Promise<SupplierSummary>;
78
+ export interface SupplierMetricsOptions extends SupplierCommandOptions {
79
+ /** 测试注入时钟;缺省真实时间。 */
80
+ now?: () => string;
81
+ }
82
+ /** 比率指标:永远给出分子/分母;分母为 0 时 value=null(不虚报 0 或 1)。 */
83
+ export interface RatioMetric {
84
+ value: number | null;
85
+ numerator: number;
86
+ denominator: number;
87
+ note?: string;
88
+ }
89
+ export interface SupplierMetricsReport {
90
+ generated_at: string;
91
+ principal_id: string;
92
+ /** Qualified RFQ 的可计算代理口径(仓库内无更严格定义)。 */
93
+ qualified_rfq_definition: string;
94
+ successful_rfqs: number;
95
+ failed_rfqs: number;
96
+ /** §14 save-after-RFQ conversion:7 天内同 merchant 建立关系的建议占比。 */
97
+ save_after_rfq: RatioMetric;
98
+ /** §14 active watched/preferred relationships + 全量 type×status 分布。 */
99
+ relationships_by_type_status: {
100
+ total: number;
101
+ active_watched_preferred: number;
102
+ buckets: {
103
+ relationship_type: string;
104
+ status: string;
105
+ count: number;
106
+ }[];
107
+ };
108
+ /** §14 7/30 天关系复用率(分母=建立已满窗口的关系,避免新关系虚低)。 */
109
+ reuse_7d: RatioMetric;
110
+ reuse_30d: RatioMetric;
111
+ /** §14 relationship-assisted Qualified RFQ。 */
112
+ relationship_assisted_rfq: RatioMetric;
113
+ /** §14 重复 Merchant / Buyer(单 principal 本地视角,buyer 恒为 1)。 */
114
+ repeat_merchants: {
115
+ merchants_with_successful_rfq: number;
116
+ merchants_with_repeat_rfq: number;
117
+ successful_rfqs: number;
118
+ unidentified_merchant_rfqs: number;
119
+ };
120
+ observations: {
121
+ total: number;
122
+ by_kind: Record<string, number>;
123
+ /** 可计算代理:observation 对应关系当前仍是 active watched 的占比。 */
124
+ on_active_watched: RatioMetric;
125
+ /** 严格通知命中率本地无记录,恒 null。 */
126
+ notification_hit_rate: {
127
+ value: null;
128
+ note: string;
129
+ };
130
+ };
131
+ /** §14 暂停率和删除率(占全部关系,含 deleted)。 */
132
+ lifecycle: {
133
+ paused: RatioMetric;
134
+ deleted: RatioMetric;
135
+ };
136
+ /** §14 identity-change review 与 stale/unreachable 代理。 */
137
+ health: {
138
+ review_required: RatioMetric;
139
+ degraded_sources: RatioMetric;
140
+ };
141
+ }
142
+ /**
143
+ * `kiwi buyer supplier metrics`(§13 M0 / §14):Buyer 本地只读指标。全部数据
144
+ * 来自本机 state.sqlite(supplier_relationships / supplier_observations /
145
+ * supplier_observation_state / task_events),单 principal 视角。算不出来的
146
+ * 指标如实给 null + 原因,不编造。
147
+ */
148
+ export declare function supplierMetrics(options?: SupplierMetricsOptions): Promise<SupplierMetricsReport>;
@@ -0,0 +1,452 @@
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 supplier` 命令实现(pull-relationship 设计 v0.1 §11,M1)。
18
+ *
19
+ * 关系是 Buyer Core 本地私有状态:save/watch/prefer 通过 kiwi-catalog 解析
20
+ * Merchant 公开 record(canonical_domain / agent_card_url / ucp_profile_url),
21
+ * 写入本地 supplier_relationships;Merchant 侧无任何写入通道。
22
+ *
23
+ * watched / preferred 默认要求人类明确确认(consent_source = human_explicit):
24
+ * 非交互环境必须显式传 --yes,否则拒绝。
25
+ */
26
+ import { existsSync } from "node:fs";
27
+ import path from "node:path";
28
+ import { agentDataDir, openAgentDatabase } from "./agent/agent-db.js";
29
+ import { SupplierRelationshipStore, assertSupplierEndpointAuthority, } from "./agent/supplier/store.js";
30
+ import { KiwiCatalogSource } from "./discovery/catalog-source/kiwi-source.js";
31
+ import { DEFAULT_CATALOG_URL } from "./product-cli.js";
32
+ function openSupplierStore(options) {
33
+ const dataDir = options.dataDir ?? agentDataDir(options.agentId ?? "kiwi-assistant");
34
+ const dbPath = path.join(dataDir, "state.sqlite");
35
+ if (!existsSync(dbPath)) {
36
+ throw new Error(`没有 Buyer 数据(${dbPath} 不存在)——先运行 \`kiwi buyer start\` 初始化本地 Buyer Core`);
37
+ }
38
+ const db = openAgentDatabase(dbPath);
39
+ try {
40
+ const principal = db
41
+ .prepare("SELECT principal_id FROM principals WHERE role = 'buyer' ORDER BY created_at LIMIT 1")
42
+ .get();
43
+ if (principal === undefined) {
44
+ throw new Error("本地 Buyer principal 不存在——先运行 `kiwi buyer start` 完成初始化");
45
+ }
46
+ const store = new SupplierRelationshipStore({ db, principalId: principal.principal_id });
47
+ return { db, store, principalId: principal.principal_id };
48
+ }
49
+ catch (err) {
50
+ db.close();
51
+ throw err;
52
+ }
53
+ }
54
+ /** 从 kiwi-catalog 解析 Merchant 公开 record(save/watch/prefer 共用的身份来源)。 */
55
+ async function resolveMerchant(catalogUrl, merchantId) {
56
+ const source = new KiwiCatalogSource({ baseUrl: catalogUrl });
57
+ const record = await source.getRecord(merchantId);
58
+ if (record.agent_card_url === undefined) {
59
+ throw new Error(`catalog record ${merchantId} 没有 agent_card_url,无法建立供应商关系`);
60
+ }
61
+ if (record.administrative_state !== "active" ||
62
+ record.freshness_state === "unreachable" ||
63
+ record.verification_level === "discovered") {
64
+ throw new Error(`catalog record ${merchantId} 当前不可建立自动供应商关系` +
65
+ `(admin=${record.administrative_state}, freshness=${record.freshness_state}, verification=${record.verification_level})`);
66
+ }
67
+ assertSupplierEndpointAuthority(record.canonical_domain, record.agent_card_url);
68
+ if (record.ucp_profile_url !== undefined) {
69
+ assertSupplierEndpointAuthority(record.canonical_domain, record.ucp_profile_url);
70
+ }
71
+ return {
72
+ merchant_id: record.merchant_id ?? record.catalog_agent_id,
73
+ catalog_agent_id: record.catalog_agent_id,
74
+ canonical_domain: record.canonical_domain,
75
+ agent_card_url: record.agent_card_url,
76
+ ...(record.ucp_profile_url !== undefined ? { ucp_profile_url: record.ucp_profile_url } : {}),
77
+ };
78
+ }
79
+ /**
80
+ * watched/preferred 的明确同意门(§11:创建 watched/preferred 默认要求人类
81
+ * 明确确认)。--yes 或交互确认通过才返回;否则抛错拒绝。
82
+ */
83
+ async function requireExplicitConsent(options) {
84
+ if (options.yes === true)
85
+ return;
86
+ if (options.confirm !== undefined && (await options.confirm()))
87
+ return;
88
+ throw new Error(`${options.action} 需要人类明确确认:交互终端请确认提示,非交互环境请显式加 --yes`);
89
+ }
90
+ function summarize(rel) {
91
+ const out = {
92
+ relationship_id: rel.relationship_id,
93
+ merchant_id: rel.merchant_id,
94
+ canonical_domain: rel.canonical_domain,
95
+ relationship_type: rel.relationship_type,
96
+ status: rel.status,
97
+ consent_source: rel.consent_source,
98
+ scope: rel.scope,
99
+ policy: rel.policy,
100
+ created_at: rel.created_at,
101
+ updated_at: rel.updated_at,
102
+ };
103
+ if (rel.expires_at !== undefined)
104
+ out.expires_at = rel.expires_at;
105
+ return out;
106
+ }
107
+ function parseExpiresDays(value) {
108
+ const match = /^(\d+)d$/.exec(value);
109
+ if (match === null) {
110
+ throw new Error("--expires 只支持 <N>d 形式(如 90d)");
111
+ }
112
+ const days = Number(match[1]);
113
+ if (!Number.isInteger(days) || days <= 0) {
114
+ throw new Error("--expires 天数必须是正整数");
115
+ }
116
+ return new Date(Date.now() + days * 24 * 3600 * 1000).toISOString();
117
+ }
118
+ const DEFAULT_ACTIVE_RELATIONSHIP_EXPIRY = "90d";
119
+ /** `kiwi buyer supplier save <merchant-id>`:保存身份,不轮询(§2.1)。 */
120
+ export async function supplierSave(options) {
121
+ const resolved = await resolveMerchant(options.catalogUrl ?? DEFAULT_CATALOG_URL, options.merchantId);
122
+ const { db, store } = openSupplierStore(options);
123
+ try {
124
+ return summarize(store.saveRelationship({
125
+ merchant_id: resolved.merchant_id,
126
+ canonical_domain: resolved.canonical_domain,
127
+ agent_card_url: resolved.agent_card_url,
128
+ ...(resolved.ucp_profile_url !== undefined
129
+ ? { ucp_profile_url: resolved.ucp_profile_url }
130
+ : {}),
131
+ relationship_type: "saved",
132
+ scope: { catalog_agent_id: resolved.catalog_agent_id },
133
+ consent_source: "human_explicit",
134
+ }));
135
+ }
136
+ finally {
137
+ db.close();
138
+ }
139
+ }
140
+ /** `kiwi buyer supplier watch <merchant-id>`:建立主动观察规则(§2.2)。 */
141
+ export async function supplierWatch(options) {
142
+ await requireExplicitConsent({ yes: options.yes, confirm: options.confirm, action: "watch" });
143
+ if (options.intervalSeconds !== undefined &&
144
+ (!Number.isInteger(options.intervalSeconds) || options.intervalSeconds < 3600)) {
145
+ throw new Error("--interval 必须是 ≥3600 的整数秒(供应商观察不做分钟级轮询)");
146
+ }
147
+ const resolved = await resolveMerchant(options.catalogUrl ?? DEFAULT_CATALOG_URL, options.merchantId);
148
+ const { db, store } = openSupplierStore(options);
149
+ try {
150
+ return summarize(store.saveRelationship({
151
+ merchant_id: resolved.merchant_id,
152
+ canonical_domain: resolved.canonical_domain,
153
+ agent_card_url: resolved.agent_card_url,
154
+ ...(resolved.ucp_profile_url !== undefined
155
+ ? { ucp_profile_url: resolved.ucp_profile_url }
156
+ : {}),
157
+ relationship_type: "watched",
158
+ scope: {
159
+ catalog_agent_id: resolved.catalog_agent_id,
160
+ ...(options.query !== undefined ? { query: options.query } : {}),
161
+ ...(options.region !== undefined ? { region: options.region } : {}),
162
+ },
163
+ policy: options.intervalSeconds !== undefined
164
+ ? { interval_seconds: options.intervalSeconds }
165
+ : {},
166
+ consent_source: "human_explicit",
167
+ expires_at: parseExpiresDays(options.expires ?? DEFAULT_ACTIVE_RELATIONSHIP_EXPIRY),
168
+ }));
169
+ }
170
+ finally {
171
+ db.close();
172
+ }
173
+ }
174
+ /** `kiwi buyer supplier prefer <merchant-id>`:采购范围内的软偏好(§2.3)。 */
175
+ export async function supplierPrefer(options) {
176
+ await requireExplicitConsent({ yes: options.yes, confirm: options.confirm, action: "prefer" });
177
+ const resolved = await resolveMerchant(options.catalogUrl ?? DEFAULT_CATALOG_URL, options.merchantId);
178
+ const { db, store } = openSupplierStore(options);
179
+ try {
180
+ return summarize(store.saveRelationship({
181
+ merchant_id: resolved.merchant_id,
182
+ canonical_domain: resolved.canonical_domain,
183
+ agent_card_url: resolved.agent_card_url,
184
+ ...(resolved.ucp_profile_url !== undefined
185
+ ? { ucp_profile_url: resolved.ucp_profile_url }
186
+ : {}),
187
+ relationship_type: "preferred",
188
+ scope: {
189
+ catalog_agent_id: resolved.catalog_agent_id,
190
+ ...(options.scope !== undefined ? { procurement_scope: options.scope } : {}),
191
+ },
192
+ expires_at: parseExpiresDays(options.expires ?? DEFAULT_ACTIVE_RELATIONSHIP_EXPIRY),
193
+ consent_source: "human_explicit",
194
+ }));
195
+ }
196
+ finally {
197
+ db.close();
198
+ }
199
+ }
200
+ /** `kiwi buyer supplier list`。 */
201
+ export async function supplierList(options) {
202
+ const { db, store } = openSupplierStore(options);
203
+ try {
204
+ return store.listRelationships().map(summarize);
205
+ }
206
+ finally {
207
+ db.close();
208
+ }
209
+ }
210
+ /** `kiwi buyer supplier pause <relationship-id>`。 */
211
+ export async function supplierPause(options) {
212
+ const { db, store } = openSupplierStore(options);
213
+ try {
214
+ return summarize(store.updateStatus(options.relationshipId, "paused"));
215
+ }
216
+ finally {
217
+ db.close();
218
+ }
219
+ }
220
+ /**
221
+ * `kiwi buyer supplier remove <relationship-id>`:软删——立即停止后续拉取并
222
+ * 清除未来调度(§11)。M3 之前 receipt_status 恒为 none,无需远端 revoke;
223
+ * 若将来存在有效 receipt,先 best-effort revoke 但远端不可达不阻塞本地删除。
224
+ */
225
+ export async function supplierRemove(options) {
226
+ const { db, store } = openSupplierStore(options);
227
+ try {
228
+ const rel = store.getRelationship(options.relationshipId);
229
+ if (rel === undefined) {
230
+ throw new Error(`没有供应商关系 ${options.relationshipId}`);
231
+ }
232
+ if (rel.receipt_status !== "none") {
233
+ // M3 预留:当前版本不会进入该分支(无 receipt 发送面)。
234
+ throw new Error(`关系 ${options.relationshipId} 存在有效 relationship receipt(${rel.receipt_status}),` +
235
+ "当前版本请先等待 receipt 过期后再删除");
236
+ }
237
+ return summarize(store.updateStatus(options.relationshipId, "deleted"));
238
+ }
239
+ finally {
240
+ db.close();
241
+ }
242
+ }
243
+ // ---- M0 指标(pull-relationship 设计 v0.1 §13/§14) ------------------------------
244
+ const DAY_MS = 24 * 3600 * 1000;
245
+ function ratio(numerator, denominator, note) {
246
+ const m = {
247
+ value: denominator === 0 ? null : numerator / denominator,
248
+ numerator,
249
+ denominator,
250
+ };
251
+ if (note !== undefined)
252
+ m.note = note;
253
+ return m;
254
+ }
255
+ /**
256
+ * a2a_negotiated 事件没有 merchant_id 字段——用 catalog_agent_id(对
257
+ * relationship.merchant_id 或 scope.catalog_agent_id)或 agent_card_url 匹配
258
+ * merchant(代理口径,§14 注明)。
259
+ */
260
+ function rfqMatchesRelationship(payload, rel) {
261
+ const caid = payload.catalog_agent_id;
262
+ if (typeof caid === "string" &&
263
+ caid !== "" &&
264
+ (rel.merchant_id === caid || rel.scope.catalog_agent_id === caid)) {
265
+ return true;
266
+ }
267
+ const cardUrl = payload.agent_card_url;
268
+ return typeof cardUrl === "string" && cardUrl !== "" && rel.agent_card_url === cardUrl;
269
+ }
270
+ /**
271
+ * `kiwi buyer supplier metrics`(§13 M0 / §14):Buyer 本地只读指标。全部数据
272
+ * 来自本机 state.sqlite(supplier_relationships / supplier_observations /
273
+ * supplier_observation_state / task_events),单 principal 视角。算不出来的
274
+ * 指标如实给 null + 原因,不编造。
275
+ */
276
+ export async function supplierMetrics(options = {}) {
277
+ const { db, store, principalId } = openSupplierStore(options);
278
+ try {
279
+ const now = new Date(Date.parse(options.now !== undefined ? options.now() : new Date().toISOString())).toISOString();
280
+ const nowMs = Date.parse(now);
281
+ const relationships = store.listRelationships({ includeDeleted: true });
282
+ const eventRows = db
283
+ .prepare(`SELECT e.type AS type, e.payload_json AS payload_json, e.created_at AS created_at
284
+ FROM task_events e JOIN buyer_tasks t ON t.task_id = e.task_id
285
+ WHERE t.principal_id = ? AND e.type IN ('a2a_negotiated', 'supplier_save_suggested')
286
+ ORDER BY e.created_at, e.event_id`)
287
+ .all(principalId);
288
+ const successfulRfqs = [];
289
+ let failedRfqs = 0;
290
+ const suggestions = [];
291
+ for (const row of eventRows) {
292
+ const payload = JSON.parse(row.payload_json);
293
+ if (row.type === "supplier_save_suggested") {
294
+ suggestions.push({ created_at: row.created_at, payload });
295
+ }
296
+ else if (payload.ok === true) {
297
+ successfulRfqs.push({ created_at: row.created_at, payload });
298
+ }
299
+ else {
300
+ failedRfqs += 1;
301
+ }
302
+ }
303
+ // a. save-after-RFQ conversion:建议后 7 天内同 merchant 建立关系(含已删除,
304
+ // 转化是历史事实;created_at 严格晚于建议时间)。
305
+ let converted = 0;
306
+ for (const s of suggestions) {
307
+ const merchant = s.payload.merchant_id;
308
+ if (typeof merchant !== "string")
309
+ continue;
310
+ const t = Date.parse(s.created_at);
311
+ const hit = relationships.some((r) => r.merchant_id === merchant &&
312
+ Date.parse(r.created_at) > t &&
313
+ Date.parse(r.created_at) <= t + 7 * DAY_MS);
314
+ if (hit)
315
+ converted += 1;
316
+ }
317
+ const saveAfterRfq = ratio(converted, suggestions.length, "窗口=建议事件后 7 天");
318
+ // b. type × status 分布。
319
+ const bucketMap = new Map();
320
+ let activeWatchedPreferred = 0;
321
+ for (const r of relationships) {
322
+ const key = `${r.relationship_type}/${r.status}`;
323
+ bucketMap.set(key, (bucketMap.get(key) ?? 0) + 1);
324
+ if (r.status === "active" &&
325
+ (r.relationship_type === "watched" || r.relationship_type === "preferred")) {
326
+ activeWatchedPreferred += 1;
327
+ }
328
+ }
329
+ const buckets = [...bucketMap.entries()]
330
+ .map(([key, count]) => {
331
+ const [relationship_type, status] = key.split("/");
332
+ return { relationship_type, status, count };
333
+ })
334
+ .sort((a, b) => `${a.relationship_type}/${a.status}`.localeCompare(`${b.relationship_type}/${b.status}`));
335
+ // c. 7/30 天复用:分母=建立已满窗口的关系(含非 active,复用是历史事实)。
336
+ const reuse = (days) => {
337
+ const eligible = relationships.filter((r) => Date.parse(r.created_at) + days * DAY_MS <= nowMs);
338
+ let reused = 0;
339
+ for (const r of eligible) {
340
+ const t0 = Date.parse(r.created_at);
341
+ const hit = successfulRfqs.some((e) => {
342
+ const t = Date.parse(e.created_at);
343
+ return t >= t0 && t <= t0 + days * DAY_MS && rfqMatchesRelationship(e.payload, r);
344
+ });
345
+ if (hit)
346
+ reused += 1;
347
+ }
348
+ return ratio(reused, eligible.length, "merchant 经 catalog_agent_id/agent_card_url 匹配(a2a_negotiated 无 merchant_id,代理口径)");
349
+ };
350
+ // d. relationship-assisted:RFQ 发生前已建立且当前仍 active 的同 merchant 关系。
351
+ // 历史状态不可重建,用当前 status='active' 代理(口径文档注明)。
352
+ let assisted = 0;
353
+ for (const e of successfulRfqs) {
354
+ const t = Date.parse(e.created_at);
355
+ const hit = relationships.some((r) => r.status === "active" &&
356
+ Date.parse(r.created_at) <= t &&
357
+ rfqMatchesRelationship(e.payload, r));
358
+ if (hit)
359
+ assisted += 1;
360
+ }
361
+ const assistedMetric = ratio(assisted, successfulRfqs.length, "active 取当前状态(历史状态不可重建,代理口径)");
362
+ // e. 重复 Merchant:按 catalog_agent_id(缺省 agent_card_url)分组成功 RFQ。
363
+ const byMerchant = new Map();
364
+ let unidentified = 0;
365
+ for (const e of successfulRfqs) {
366
+ const id = e.payload.catalog_agent_id ?? e.payload.agent_card_url;
367
+ if (typeof id === "string" && id !== "") {
368
+ byMerchant.set(id, (byMerchant.get(id) ?? 0) + 1);
369
+ }
370
+ else {
371
+ unidentified += 1;
372
+ }
373
+ }
374
+ let repeatMerchants = 0;
375
+ for (const n of byMerchant.values()) {
376
+ if (n >= 2)
377
+ repeatMerchants += 1;
378
+ }
379
+ // f. observation 面。
380
+ const obsRows = db
381
+ .prepare(`SELECT o.kind AS kind, r.relationship_type AS relationship_type, r.status AS status
382
+ FROM supplier_observations o
383
+ JOIN supplier_relationships r ON r.relationship_id = o.relationship_id
384
+ WHERE r.principal_id = ?`)
385
+ .all(principalId);
386
+ const byKind = {};
387
+ let onActiveWatched = 0;
388
+ for (const o of obsRows) {
389
+ byKind[o.kind] = (byKind[o.kind] ?? 0) + 1;
390
+ if (o.status === "active" && o.relationship_type === "watched")
391
+ onActiveWatched += 1;
392
+ }
393
+ // g. lifecycle(分母含 deleted)。
394
+ const total = relationships.length;
395
+ const paused = relationships.filter((r) => r.status === "paused").length;
396
+ const deleted = relationships.filter((r) => r.status === "deleted").length;
397
+ // h. health。
398
+ const reviewRequired = relationships.filter((r) => r.status === "review_required").length;
399
+ const stateRows = db
400
+ .prepare(`SELECT s.failure_count AS failure_count, s.backoff_until AS backoff_until
401
+ FROM supplier_observation_state s
402
+ JOIN supplier_relationships r ON r.relationship_id = s.relationship_id
403
+ WHERE r.principal_id = ?`)
404
+ .all(principalId);
405
+ const degraded = stateRows.filter((s) => s.failure_count > 0 ||
406
+ (s.backoff_until !== null && Date.parse(s.backoff_until) > nowMs)).length;
407
+ return {
408
+ generated_at: now,
409
+ principal_id: principalId,
410
+ qualified_rfq_definition: "代理口径:task_events 中 type='a2a_negotiated' 且 payload.ok=true 的成功终态事件" +
411
+ "(仓库内无更严格的 Qualified RFQ 定义)",
412
+ successful_rfqs: successfulRfqs.length,
413
+ failed_rfqs: failedRfqs,
414
+ save_after_rfq: saveAfterRfq,
415
+ relationships_by_type_status: {
416
+ total,
417
+ active_watched_preferred: activeWatchedPreferred,
418
+ buckets,
419
+ },
420
+ reuse_7d: reuse(7),
421
+ reuse_30d: reuse(30),
422
+ relationship_assisted_rfq: assistedMetric,
423
+ repeat_merchants: {
424
+ merchants_with_successful_rfq: byMerchant.size,
425
+ merchants_with_repeat_rfq: repeatMerchants,
426
+ successful_rfqs: successfulRfqs.length,
427
+ unidentified_merchant_rfqs: unidentified,
428
+ },
429
+ observations: {
430
+ total: obsRows.length,
431
+ by_kind: byKind,
432
+ on_active_watched: ratio(onActiveWatched, obsRows.length, "代理口径:observation 对应关系当前仍是 active watched 的占比"),
433
+ notification_hit_rate: {
434
+ value: null,
435
+ note: "严格命中率不可计算:本地不记录通知是否触达/被用户采纳",
436
+ },
437
+ },
438
+ lifecycle: {
439
+ paused: ratio(paused, total),
440
+ deleted: ratio(deleted, total),
441
+ },
442
+ health: {
443
+ review_required: ratio(reviewRequired, total),
444
+ degraded_sources: ratio(degraded, stateRows.length, "stale/unreachable 代理:failure_count>0 或 backoff_until>now"),
445
+ },
446
+ };
447
+ }
448
+ finally {
449
+ db.close();
450
+ }
451
+ }
452
+ //# sourceMappingURL=product-supplier.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"product-supplier.js","sourceRoot":"","sources":["../src/product-supplier.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH;;;;;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K,EAAE,IAAI;oBACX,IAAI,EAAE,6BAA6B;iBACpC;aACF;YACD,SAAS,EAAE;gBACT,MAAM,EAAE,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC;gBAC5B,OAAO,EAAE,KAAK,CAAC,OAAO,EAAE,KAAK,CAAC;aAC/B;YACD,MAAM,EAAE;gBACN,eAAe,EAAE,KAAK,CAAC,cAAc,EAAE,KAAK,CAAC;gBAC7C,gBAAgB,EAAE,KAAK,CACrB,QAAQ,EACR,SAAS,CAAC,MAAM,EAChB,0DAA0D,CAC3D;aACF;SACF,CAAC;IACJ,CAAC;YAAS,CAAC;QACT,EAAE,CAAC,KAAK,EAAE,CAAC;IACb,CAAC;AACH,CAAC"}
@@ -35,7 +35,7 @@ export interface ScriptedFake {
35
35
  export declare function createScriptedFakeStreamFn(responses: FauxResponseStep[]): ScriptedFake;
36
36
  /**
37
37
  * Structured influence of applied operator strategy directives on candidate
38
- * generation (docs/operator-tui-v0.2.md §7). Compiled by the operator runner
38
+ * generation (operator control-plane design §7). Compiled by the operator runner
39
39
  * from the session's directive list; never widens HardPolicy by itself — the
40
40
  * authoritative policy gates still run on the profile at submit time.
41
41
  */
@@ -0,0 +1,11 @@
1
+ /**
2
+ * JWK(RFC 7517)结构类型。
3
+ *
4
+ * @types/node ≥26 不再从 `node:crypto` 顶层导出 `JsonWebKey`,改为
5
+ * `crypto.webcrypto` 命名空间下的 `webcrypto.JsonWebKey`。此处集中 re-export,
6
+ * 并补 RFC 7517 的 `kid`(W3C JsonWebKey 未含,JWKS 接缝按 kid 匹配需要它)。
7
+ */
8
+ import type { webcrypto } from "node:crypto";
9
+ export type JsonWebKey = webcrypto.JsonWebKey & {
10
+ kid?: string;
11
+ };
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=jwk.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jwk.js","sourceRoot":"","sources":["../../../src/trust/identity/jwk.ts"],"names":[],"mappings":""}
@@ -24,7 +24,8 @@
24
24
  * 是否强制 JWS 由 TrustPolicy.requireCardJws(level) 决定(§31),本模块只提供
25
25
  * 「验签 + 卡片绑定」能力,不做强制决策。
26
26
  */
27
- import { KeyObject, type JsonWebKey } from "node:crypto";
27
+ import { KeyObject } from "node:crypto";
28
+ import type { JsonWebKey } from "./jwk.js";
28
29
  import type { AgentCard } from "../../discovery/agent-card/index.js";
29
30
  import { type KeyResolver, type SigningKey } from "./keys.js";
30
31
  export type JwsErrorCode = "malformed" | "unsupported_algorithm" | "missing_key" | "invalid_signature";