@finddatatechnology/yongyi-client 0.1.5 → 0.1.7

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.
package/dist/ladder.d.ts CHANGED
@@ -53,6 +53,8 @@ export interface ReadPagesFilter {
53
53
  export interface ClusterClientOptions {
54
54
  url: string;
55
55
  token: string;
56
+ /** 记忆入口 key(feed key):存在时仅用于读路径(/digest /pages /mcp),写仍用 token。 */
57
+ feedKey?: string;
56
58
  fetchImpl?: FetchLike;
57
59
  /** digest 读死线(毫秒);缺省读 env.CELL_MEMORY_DIGEST_TIMEOUT_MS,默认 9000。 */
58
60
  timeoutMs?: number;
package/dist/ladder.js CHANGED
@@ -31,13 +31,15 @@ export function digestTimeoutMs(env = process.env) {
31
31
  }
32
32
  // 从 cell 配置构建的客户端三面(clusterMemoryFor 的 faces 移植)。
33
33
  export function createClusterMemoryClient(opts) {
34
- const { url, token } = opts;
34
+ const { url, token, feedKey } = opts;
35
35
  const fetchImpl = opts.fetchImpl ?? fetch;
36
36
  const env = opts.env ?? process.env;
37
+ // 读路径用 feedKey(若提供),写路径用 person token
38
+ const readToken = feedKey ?? token;
37
39
  return {
38
40
  async readShared(project, limit = 5) {
39
41
  // 出站纪律:共享死线包装(默认 env 界);fetchImpl 保持测试缝。
40
- const r = await fetchWithTimeout(`${url}/pages?project=${encodeURIComponent(project)}&limit=${limit}`, { headers: { authorization: `Bearer ${token}` } }, { fetchImpl });
42
+ const r = await fetchWithTimeout(`${url}/pages?project=${encodeURIComponent(project)}&limit=${limit}`, { headers: { authorization: `Bearer ${readToken}` } }, { fetchImpl });
41
43
  if (!r.ok)
42
44
  throw new Error(`pages HTTP ${r.status}`);
43
45
  const doc = await r.json();
@@ -77,7 +79,7 @@ export function createClusterMemoryClient(opts) {
77
79
  qs.append("meta", `${k}:${typeof v === "string" ? v : JSON.stringify(v)}`);
78
80
  }
79
81
  const r = await fetchWithTimeout(`${url}/pages?${qs.toString()}`, {
80
- headers: { authorization: `Bearer ${token}` },
82
+ headers: { authorization: `Bearer ${readToken}` },
81
83
  }, { fetchImpl });
82
84
  if (!r.ok)
83
85
  throw new Error(`pages HTTP ${r.status}`);
@@ -100,7 +102,7 @@ export function createClusterMemoryClient(opts) {
100
102
  const controller = new AbortController();
101
103
  const timer = setTimeout(() => controller.abort(), opts.timeoutMs ?? digestTimeoutMs(env));
102
104
  try {
103
- const r = await fetchImpl(u, { headers: { authorization: `Bearer ${token}` }, signal: controller.signal });
105
+ const r = await fetchImpl(u, { headers: { authorization: `Bearer ${readToken}` }, signal: controller.signal });
104
106
  if (!r.ok)
105
107
  throw new Error(`digest HTTP ${r.status}`);
106
108
  return await r.json();
@@ -120,7 +122,7 @@ export async function clusterMemoryFor(env, ownerEmail, fetchImpl = fetch) {
120
122
  return null;
121
123
  try {
122
124
  const token = await personTokenFor(cfg, ownerEmail, fetchImpl);
123
- return createClusterMemoryClient({ url: cfg.url, token, fetchImpl, env });
125
+ return createClusterMemoryClient({ url: cfg.url, token, feedKey: cfg.feedKey, fetchImpl, env });
124
126
  }
125
127
  catch (e) {
126
128
  console.warn(`[cluster-memory] unavailable (degrade open): ${e?.message || e}`);
package/dist/tokens.d.ts CHANGED
@@ -6,6 +6,8 @@ export interface CellMemoryConfig {
6
6
  url: string;
7
7
  platformToken: string;
8
8
  dataRoot: string;
9
+ /** 记忆入口 key(feed key):存在时仅用于读路径(/digest /pages /mcp),写/捕获仍用 person 令牌。 */
10
+ feedKey?: string;
9
11
  }
10
12
  export declare function cellMemoryConfig(env?: EnvLike): CellMemoryConfig | null;
11
13
  export declare function personTokenFor(cfg: CellMemoryConfig, ownerEmail: string, fetchImpl?: FetchLike): Promise<string>;
package/dist/tokens.js CHANGED
@@ -19,7 +19,8 @@ export function cellMemoryConfig(env = process.env) {
19
19
  const url = String(env.CELL_MEMORY_URL || "").replace(/\/+$/, "");
20
20
  const platformToken = String(env.CELL_MEMORY_PLATFORM_TOKEN || "");
21
21
  const dataRoot = String(env.CELL_MEMORY_DATA || "");
22
- return enabled && url && platformToken && dataRoot ? { url, platformToken, dataRoot } : null;
22
+ const feedKey = String(env.CELL_MEMORY_FEED || "") || undefined;
23
+ return enabled && url && platformToken && dataRoot ? { url, platformToken, dataRoot, feedKey } : null;
23
24
  }
24
25
  function cachePath(dataRoot, ownerEmail) {
25
26
  const safe = String(ownerEmail || "unknown").replace(/[^a-zA-Z0-9@._-]/g, "_");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@finddatatechnology/yongyi-client",
3
- "version": "0.1.5",
3
+ "version": "0.1.7",
4
4
  "type": "module",
5
5
  "description": "永忆(YongYi / fd-memory)客户端 SDK:召回注入阶梯、纪律文本单源、五类事实捕获、令牌铸造缓存、/observe 上报。零运行时依赖,只以 fetch 打内核 HTTP 面。",
6
6
  "main": "./dist/index.js",