@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,86 @@
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 { KiwiCatalogSource } from "../../discovery/catalog-source/kiwi-source.js";
17
+ import type { TrustRecordStore } from "../../trust/records/store.js";
18
+ import type { SupplierObservation, SupplierRelationshipStore } from "./store.js";
19
+ export interface SupplierSchedulerOptions {
20
+ store: SupplierRelationshipStore;
21
+ catalogSource?: KiwiCatalogSource;
22
+ trustStore?: TrustRecordStore;
23
+ now?: () => string;
24
+ /** 可注入 fake fetch(测试);缺省 globalThis.fetch。 */
25
+ fetchFn?: typeof fetch;
26
+ /** 本地开发放行字面 loopback(不可信 Card 默认 false)。 */
27
+ allowLoopback?: boolean;
28
+ skipDnsCheck?: boolean;
29
+ resolveIp?: (hostname: string) => Promise<string[]>;
30
+ /** 退避 jitter 随机源(±10%),可注入固定值做确定性测试。 */
31
+ random?: () => number;
32
+ timeoutMs?: number;
33
+ }
34
+ export interface SupplierTickBudget {
35
+ max_requests?: number;
36
+ max_relationships?: number;
37
+ }
38
+ export interface SupplierTickNotification {
39
+ relationship_id: string;
40
+ merchant_id: string;
41
+ summary: string;
42
+ }
43
+ export interface SupplierTickResult {
44
+ checked: number;
45
+ requests_used: number;
46
+ observations: SupplierObservation[];
47
+ notified: SupplierTickNotification[];
48
+ errors: string[];
49
+ }
50
+ export declare class SupplierScheduler {
51
+ private readonly store;
52
+ private readonly catalogSource?;
53
+ private readonly trustStore?;
54
+ private readonly now;
55
+ private readonly fetchFn;
56
+ private readonly allowLoopback;
57
+ private readonly skipDnsCheck?;
58
+ private readonly resolveIp?;
59
+ private readonly random;
60
+ private readonly timeoutMs;
61
+ constructor(options: SupplierSchedulerOptions);
62
+ tick(budget?: SupplierTickBudget): Promise<SupplierTickResult>;
63
+ /**
64
+ * 拉取一个关系的所有配置来源。返回 true 表示预算耗尽应中断整个 tick。
65
+ * Agent Card 指纹变化 → review_required 并跳过后续来源(§8 第 5 步)。
66
+ */
67
+ private checkRelationship;
68
+ private checkCatalog;
69
+ private requireReview;
70
+ private diffCatalogSnapshot;
71
+ /** 返回 false 表示指纹变化已置 review_required,调用方停止该关系后续拉取。 */
72
+ private checkAgentCard;
73
+ private checkUcpProfile;
74
+ private intervalSeconds;
75
+ /** 成功后下次检查:连续无变化 interval×1.5 逐步放慢,封顶 24h(§8)。 */
76
+ private scheduleAfterSuccess;
77
+ /**
78
+ * 失败退避(§8 第 9 步):transient 指数退避 2^min(n-1,5)×interval 封顶
79
+ * 24h + ±10% jitter;permanent(4xx/SSRF 拒绝/schema 拒绝)直接 24h。
80
+ * 同时写 unreachable observation(content_digest 去重,持续失败不刷屏)。
81
+ * 例外:本地安全策略拒绝(SSRF/redirect,observeUnreachable=false)不是
82
+ * 远程事实,只退避、不写 observation。
83
+ */
84
+ private recordFailure;
85
+ private getJson;
86
+ }