#39 Phase 1.2: store.ts 统一 thread 存储,去掉 history prefix #41

Closed
opened 2026-06-04 06:04:50 +00:00 by xiaoju · 0 comments
Owner

Parent: #39
Depends on: #40

目标

所有 thread 统一存 @uwf/thread/<id>,用 tag 表达 status,去掉 @uwf/history/* prefix。

改动

packages/cli/src/store.ts

删除:

  • HISTORY_VAR_PREFIX
  • ThreadHistoryLine type
  • loadAllHistory()
  • findHistoryEntry()
  • addHistoryEntry()
  • parseHistoryJsonlLine()

修改 entryFromVariable()

function entryFromVariable(v: { value: string; tags: Record<string, string> }): ThreadIndexEntry {
  const status = v.tags.status ?? "idle";
  return {
    head: v.value as CasRef,
    status: status as ThreadIndexEntry["status"],
    suspendedRole: v.tags.suspendedRole ?? null,
    suspendMessage: v.tags.suspendMessage ?? null,
    completedAt: v.tags.completedAt !== undefined ? Number(v.tags.completedAt) : null,
  };
}

修改 setThread()

  • 写入 status tag
  • 写入 completedAt tag(如果非 null)
  • 保持 suspendedRole/suspendMessage 逻辑

新增:

  • loadActiveThreads(varStore) — 返回 status 不是 completed/cancelled 的 thread
  • loadHistoryThreads(varStore) — 返回 status 是 completed/cancelled 的 thread
  • completeThread(varStore, threadId, reason) — 设置 status + completedAt,不删除 entry

删除 deleteThread() — 不再需要删除 thread entry,完成时只改 status tag

迁移:

  • migrateHistoryToThreadVars() — 读 @uwf/history/*,写到 @uwf/thread/*(加 status tag),然后删除旧变量
  • createUwfStore() 中调用
  • 保留 jsonl → history 迁移作为第一级 fallback

注意

  • thread.ts 的适配在下一个 issue
  • proman build && proman test 通过
Parent: #39 Depends on: #40 ## 目标 所有 thread 统一存 `@uwf/thread/<id>`,用 tag 表达 status,去掉 `@uwf/history/*` prefix。 ## 改动 ### `packages/cli/src/store.ts` **删除:** - `HISTORY_VAR_PREFIX` - `ThreadHistoryLine` type - `loadAllHistory()` - `findHistoryEntry()` - `addHistoryEntry()` - `parseHistoryJsonlLine()` **修改 `entryFromVariable()`:** ```typescript function entryFromVariable(v: { value: string; tags: Record<string, string> }): ThreadIndexEntry { const status = v.tags.status ?? "idle"; return { head: v.value as CasRef, status: status as ThreadIndexEntry["status"], suspendedRole: v.tags.suspendedRole ?? null, suspendMessage: v.tags.suspendMessage ?? null, completedAt: v.tags.completedAt !== undefined ? Number(v.tags.completedAt) : null, }; } ``` **修改 `setThread()`:** - 写入 `status` tag - 写入 `completedAt` tag(如果非 null) - 保持 suspendedRole/suspendMessage 逻辑 **新增:** - `loadActiveThreads(varStore)` — 返回 status 不是 completed/cancelled 的 thread - `loadHistoryThreads(varStore)` — 返回 status 是 completed/cancelled 的 thread - `completeThread(varStore, threadId, reason)` — 设置 status + completedAt,不删除 entry **删除 `deleteThread()`** — 不再需要删除 thread entry,完成时只改 status tag **迁移:** - `migrateHistoryToThreadVars()` — 读 `@uwf/history/*`,写到 `@uwf/thread/*`(加 status tag),然后删除旧变量 - 在 `createUwfStore()` 中调用 - 保留 jsonl → history 迁移作为第一级 fallback ### 注意 - thread.ts 的适配在下一个 issue - `proman build && proman test` 通过
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: shazhou/united-workforce#41