@ai-setting/roy-agent-core 1.7.88 → 1.7.89

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 (38) hide show
  1. package/dist/env/event-source/event-source-handlers.js +6 -6
  2. package/dist/env/event-source/index.js +7 -7
  3. package/dist/env/event-source/wecom-session-card-sender.js +2 -2
  4. package/dist/env/index.js +12 -11
  5. package/dist/env/task/backend/index.d.ts +3 -0
  6. package/dist/env/task/backend/index.js +151 -3
  7. package/dist/env/task/backend/remote-task-port.d.ts +85 -0
  8. package/dist/env/task/backend/types.d.ts +5 -0
  9. package/dist/env/task/index.d.ts +1 -1
  10. package/dist/env/task/index.js +20 -4
  11. package/dist/env/task/mcp/index.js +1 -1
  12. package/dist/env/task/plugins/index.js +3 -3
  13. package/dist/env/task/plugins/lark-card-patch-notifier.js +2 -2
  14. package/dist/env/task/plugins/wecom-session-card-store.js +2 -2
  15. package/dist/env/task/storage/index.d.ts +1 -0
  16. package/dist/env/task/storage/index.js +23 -3
  17. package/dist/env/task/storage/migrations/006_add_task_owner.d.ts +24 -0
  18. package/dist/env/task/storage/remote-task-store.d.ts +186 -0
  19. package/dist/env/task/task-component.d.ts +7 -0
  20. package/dist/env/task/tools/index.js +1 -1
  21. package/dist/env/task/tools/task-types.d.ts +7 -0
  22. package/dist/env/task/types.d.ts +17 -0
  23. package/dist/env/workflow/plugins/index.js +3 -3
  24. package/dist/index.d.ts +1 -1
  25. package/dist/index.js +17 -11
  26. package/dist/shared/@ai-setting/{roy-agent-core-vpcxv1ty.js → roy-agent-core-05z35shp.js} +1 -1
  27. package/dist/shared/@ai-setting/{roy-agent-core-shb1qsyg.js → roy-agent-core-0n1wwndq.js} +1 -1
  28. package/dist/shared/@ai-setting/{roy-agent-core-fan8g0z1.js → roy-agent-core-49qcpqwg.js} +46 -11
  29. package/dist/shared/@ai-setting/{roy-agent-core-gr5h1dyr.js → roy-agent-core-4b38m749.js} +4 -4
  30. package/dist/shared/@ai-setting/{roy-agent-core-wr1qexzq.js → roy-agent-core-5dhvfgaw.js} +1 -1
  31. package/dist/shared/@ai-setting/{roy-agent-core-qwd2dq5q.js → roy-agent-core-9cen1jvg.js} +8 -4
  32. package/dist/shared/@ai-setting/{roy-agent-core-7kvpc0w5.js → roy-agent-core-age3qseb.js} +1 -1
  33. package/dist/shared/@ai-setting/{roy-agent-core-an35dzbf.js → roy-agent-core-dvec4nn2.js} +1 -1
  34. package/dist/shared/@ai-setting/{roy-agent-core-ra66sf50.js → roy-agent-core-k3h8t4q1.js} +4 -3
  35. package/dist/shared/@ai-setting/{roy-agent-core-6k8mb7zx.js → roy-agent-core-m66ysky0.js} +53 -5
  36. package/dist/shared/@ai-setting/{roy-agent-core-yh68z1bg.js → roy-agent-core-m7d1t3db.js} +1 -1
  37. package/dist/shared/@ai-setting/roy-agent-core-zhwcje5a.js +352 -0
  38. package/package.json +1 -1
@@ -0,0 +1,24 @@
1
+ /**
2
+ * @fileoverview Task Migration 006: Add owner column
3
+ *
4
+ * Migration ID: 006_add_task_owner
5
+ * Description: 给 task 表加 `owner` 列(负责人,可空)。
6
+ * Task #5440 —— roy-agent 接入 task-service 时,service 后端
7
+ * (Task #5443)已扩展 owner 字段,core 侧必须同源,
8
+ * 否则 remote 模式的 owner 写不进去、读不回来。
9
+ *
10
+ * 语义:
11
+ * - `owner TEXT`(NULL 表示未指派)—— 刻意**不**加 NOT NULL DEFAULT '',
12
+ * 因为「未指派」与「指派给空字符串」在业务上是两件事,null 更准确。
13
+ * - 加索引 `idx_task_owner`(按负责人筛任务是主要用法)。
14
+ *
15
+ * 幂等:重复执行安全(列已存在则跳过)。
16
+ *
17
+ * Date: 2026-11-13
18
+ */
19
+ /**
20
+ * Run migration 006 on the given database file.
21
+ *
22
+ * @param dbPath SQLite database file path
23
+ */
24
+ export declare function runMigration(dbPath: string): void;
@@ -0,0 +1,186 @@
1
+ /**
2
+ * @fileoverview RemoteTaskStore — 把 `TaskStore` 做成一个 HTTP 客户端
3
+ *
4
+ * Task #5440(方案 v3 §4.2 / M2)。roy-agent 的 task 存储除了本地 SQLite,
5
+ * 还可以指向常驻的 **task-service**(`/home/dzk/work/codework/personal/roy_world/roy-task-service`)。
6
+ *
7
+ * ## 契约
8
+ *
9
+ * - 服务端 `POST /store/<method>`:`TaskStore` 方法 **1:1 映射**,body 为
10
+ * `{ "args": [...] }`(多参方法按位置透传),响应体就是方法的返回值。
11
+ * - 鉴权:`Authorization: Bearer <token>`。
12
+ * - 幂等:**写方法**带 `Idempotency-Key`。同一逻辑调用重试时**复用同一个 key**
13
+ * (服务端重放缓存,避免重试造成重复写入);不同调用必须用不同 key。
14
+ * - 握手:首次调用前 `GET /version` 校验 `protocol.major`,不匹配即明确报错
15
+ * (不静默降级 —— 方案 §1.3 非目标:**无本地 fallback**)。
16
+ *
17
+ * ## 故障语义(方案 §5.3)
18
+ *
19
+ * | 情况 | 处理 |
20
+ * |---|---|
21
+ * | 401 | `RemoteAuthError`,**不重试**(token 错,重试无用) |
22
+ * | 409 IDEMPOTENCY_CONFLICT | `RemoteIdempotencyConflictError`,**不重试** |
23
+ * | 400 VALIDATION | 明确报错(payload 错) |
24
+ * | 404 METHOD_NOT_FOUND | `RemoteProtocolError`(服务端版本过旧) |
25
+ * | 503 BUSY | sqlite 单连接 batch 事务占用 → 有界重试,超限 `RemoteBatchBusyError` |
26
+ * | 5xx / 超时 / 网络错 | 有界重试(写方法靠幂等 key 保证重放安全) |
27
+ *
28
+ * 所有错误信息都带 endpoint 与排障指引,绝不悄悄退回本地库。
29
+ */
30
+ import type { TaskStore } from "./sqlite-task-store";
31
+ import type { ListTagsOptions, SearchTagsOptions } from "../tag-service";
32
+ import type { CreateOperationOptions, CreateTaskOptions, ListOperationsOptions, ListTasksOptions, SearchTasksOptions, Task, TaskListResult, TaskOperation, TaskTag, UpdateTaskOptions } from "../types";
33
+ /** 远端 task-service 的基础错误(带 endpoint,便于排障)。 */
34
+ export declare class RemoteTaskStoreError extends Error {
35
+ readonly endpoint: string;
36
+ readonly cause?: unknown | undefined;
37
+ constructor(message: string, endpoint: string, cause?: unknown | undefined);
38
+ }
39
+ /** Bearer token 缺失/失效(401)。**不重试**。 */
40
+ export declare class RemoteAuthError extends RemoteTaskStoreError {
41
+ }
42
+ /** 幂等 key 被不同 payload 复用(409 IDEMPOTENCY_CONFLICT)。**不重试**。 */
43
+ export declare class RemoteIdempotencyConflictError extends RemoteTaskStoreError {
44
+ }
45
+ /**
46
+ * sqlite 后端的 batch 事务独占单连接,期间普通请求被拒(503 BUSY)。
47
+ *
48
+ * 重试后仍失败才抛这个 —— 调用方可以据此选择「稍后再试」还是报错。
49
+ */
50
+ export declare class RemoteBatchBusyError extends RemoteTaskStoreError {
51
+ }
52
+ /** 协议不兼容(major 版本不一致 / 服务端不认识该方法)。**不重试**。 */
53
+ export declare class RemoteProtocolError extends RemoteTaskStoreError {
54
+ }
55
+ /**
56
+ * 服务端 `TASK_STORE_METHODS` 白名单的**本地副本**。
57
+ *
58
+ * 用途:握手时对齐协议面(服务端白名单变化 = 协议变化),以及让
59
+ * `RemoteTaskStore` 的方法集有单一可断言的来源(测试可对照)。
60
+ * ⚠️ 与 roy-task-service `packages/backend/src/types.ts` 的
61
+ * `TASK_STORE_METHODS` 必须保持一致。
62
+ */
63
+ export declare const REMOTE_TASK_STORE_METHODS: readonly ["createTask", "getTask", "updateTask", "deleteTask", "listTasks", "getTaskIdBySessionId", "getTaskIdsBySessionId", "createOperation", "getOperation", "updateOperation", "deleteOperation", "listOperations", "listOperationsFresh", "invalidateOperationsCache", "createTag", "getTag", "getTagByName", "listTags", "searchTags", "deleteTag", "addTagsToTask", "removeTagsFromTask", "getTagsForTask", "getTaskIdsByTags", "updateTaskTags", "searchTasksByKeywords", "findSimilarTasksByKeywords", "getTaskTree", "getChildTasks", "findSimilarTasks", "searchTasks", "findTasksByContextValue"];
64
+ /** 本 client 支持的协议 major(与服务端 `PROTOCOL_VERSION.major` 对齐)。 */
65
+ export declare const REMOTE_PROTOCOL_MAJOR = 1;
66
+ /**
67
+ * 裁掉参数数组**尾部**的 `null` / `undefined`。
68
+ *
69
+ * 为什么只裁尾部:位置参数中间的空位有语义(`updateTask(7, null)` 的 null 是
70
+ * 「要改的那个值」),只有尾部才是「调用方没传」的表达。裁掉后服务端才会
71
+ * 用它自己的默认参数。
72
+ *
73
+ * ⚠️ 不能按 falsy 裁:`limit: 0` / `offset: 0` / `""` 都是调用方的显式意图。
74
+ */
75
+ export declare function trimTrailingNullish(args: unknown[]): unknown[];
76
+ /** 只用到 warning/debug 两档(避免把整个 logger 类型泄漏到公开 API)。 */
77
+ export interface RemoteLogger {
78
+ warn?(message: string): void;
79
+ debug?(message: string): void;
80
+ }
81
+ export interface RemoteTaskStoreOptions {
82
+ /** service 地址,如 `http://127.0.0.1:7820`(末尾斜杠可有可无)。 */
83
+ endpoint: string;
84
+ /** Bearer token;service 未配置 token 时留空。 */
85
+ authToken?: string;
86
+ /** 单请求超时(毫秒),默认 5000。 */
87
+ timeoutMs?: number;
88
+ /** 可重试失败的最大**重试**次数(不含首次),默认 3。 */
89
+ maxRetries?: number;
90
+ /** 重试退避基数(毫秒),第 n 次重试等 `base * 2^n`,默认 200。 */
91
+ retryBaseDelayMs?: number;
92
+ /** 注入 fetch(测试/自定义传输)。 */
93
+ fetchImpl?: typeof fetch;
94
+ /** 注入 logger(默认用 core logger)。 */
95
+ log?: RemoteLogger;
96
+ }
97
+ export interface RemoteTaskStoreStats {
98
+ /** /version 握手次数(正常为 1;重连后可增加)。 */
99
+ handshakes: number;
100
+ /** 累计请求数(含重试)。 */
101
+ requests: number;
102
+ /** 累计重试次数。 */
103
+ retries: number;
104
+ }
105
+ export declare class RemoteTaskStore implements TaskStore {
106
+ private readonly endpoint;
107
+ private readonly authToken?;
108
+ private readonly timeoutMs;
109
+ private readonly maxRetries;
110
+ private readonly retryBaseDelayMs;
111
+ private readonly fetchImpl;
112
+ private readonly log;
113
+ private readonly stats;
114
+ private handshake?;
115
+ private closed;
116
+ constructor(options: RemoteTaskStoreOptions);
117
+ /** 诊断用统计(联调/健康检查)。 */
118
+ getStats(): Readonly<RemoteTaskStoreStats>;
119
+ private ensureOpen;
120
+ /** `/version` 握手(只做一次;失败则下次调用重试)。 */
121
+ private ensureHandshake;
122
+ private doHandshake;
123
+ private fetchWithTimeout;
124
+ /** 分类:该错误值得重试吗? */
125
+ private isRetryableStatus;
126
+ /**
127
+ * 一次逻辑调用 = 一次 `POST /store/<method>`,内含**有界重试**。
128
+ *
129
+ * @param method TaskStore 方法名
130
+ * @param args 按位置透传的实参
131
+ */
132
+ private call;
133
+ createTask(options: CreateTaskOptions): Promise<Task>;
134
+ getTask(id: number): Promise<Task | undefined>;
135
+ updateTask(id: number, options: UpdateTaskOptions): Promise<Task | undefined>;
136
+ deleteTask(id: number): Promise<boolean>;
137
+ listTasks(options?: ListTasksOptions): Promise<TaskListResult>;
138
+ getTaskIdBySessionId(sessionId: string): Promise<number | undefined>;
139
+ getTaskIdsBySessionId(sessionId: string): Promise<number[]>;
140
+ createOperation(options: CreateOperationOptions): Promise<TaskOperation>;
141
+ getOperation(id: number): Promise<TaskOperation | undefined>;
142
+ updateOperation(id: number, updates: Parameters<TaskStore["updateOperation"]>[1]): Promise<TaskOperation | undefined>;
143
+ deleteOperation(id: number): Promise<boolean>;
144
+ listOperations(options: ListOperationsOptions): Promise<TaskOperation[]>;
145
+ /** optional — 绕过缓存直读(跨进程写入可见)。 */
146
+ listOperationsFresh(options: ListOperationsOptions): Promise<TaskOperation[]>;
147
+ /**
148
+ * optional — 失效 operations 缓存。
149
+ *
150
+ * 接口签名是**同步 void**,而远端失效必然是一次网络调用:这里
151
+ * fire-and-forget(不阻塞调用方,失败仅 WARN)。服务端缓存只在 service
152
+ * 进程内,失效语义"尽力而为"即可 —— 真正需要新鲜数据时用
153
+ * `listOperationsFresh`。
154
+ */
155
+ invalidateOperationsCache(taskId: number): void;
156
+ createTag(name: string): Promise<TaskTag>;
157
+ getTag(id: number): Promise<TaskTag | undefined>;
158
+ getTagByName(name: string): Promise<TaskTag | undefined>;
159
+ listTags(options?: ListTagsOptions): Promise<TaskTag[]>;
160
+ searchTags(options: SearchTagsOptions): Promise<TaskTag[]>;
161
+ deleteTag(id: number): Promise<boolean>;
162
+ addTagsToTask(taskId: number, tagIds: number[]): Promise<void>;
163
+ removeTagsFromTask(taskId: number, tagIds: number[]): Promise<void>;
164
+ getTagsForTask(taskId: number): Promise<TaskTag[]>;
165
+ getTaskIdsByTags(tagNames: string[]): Promise<number[]>;
166
+ updateTaskTags(taskId: number, tagNames: string[]): Promise<void>;
167
+ searchTasksByKeywords(keywords: string[], options?: SearchTasksOptions): Promise<TaskListResult>;
168
+ findSimilarTasksByKeywords(keywords: string[], options?: {
169
+ limit?: number;
170
+ excludeTaskId?: number;
171
+ }): Promise<Task[]>;
172
+ getTaskTree(taskId: number, depth?: number): Promise<Task[]>;
173
+ getChildTasks(taskId: number, options?: ListTasksOptions): Promise<TaskListResult>;
174
+ findSimilarTasks(taskId: number, limit?: number): Promise<Task[]>;
175
+ searchTasks(query: string, limit?: number): Promise<Task[]>;
176
+ findTasksByContextValue(value: string, limit?: number): Promise<Task[]>;
177
+ /**
178
+ * 关闭 client(幂等)。
179
+ *
180
+ * 与本地 store 不同:**没有连接需要释放**,只是把实例标记为已关闭,
181
+ * 后续调用立即报错(避免组件被 dispose 后仍有请求飞出去)。
182
+ */
183
+ close(): void;
184
+ }
185
+ /** 便捷工厂(与 `createSQLiteTaskPort` 对称)。 */
186
+ export declare function createRemoteTaskStore(options: RemoteTaskStoreOptions): RemoteTaskStore;
@@ -115,6 +115,13 @@ export declare class TaskComponent extends BaseComponent {
115
115
  * 根据配置初始化 store
116
116
  */
117
117
  private initStore;
118
+ /**
119
+ * 按配置**构造**(不安装)一个 store。
120
+ *
121
+ * 单独抽出来是为了让 `initStore` 能「先构造后安装」——构造失败时旧 store
122
+ * 保持原样(CV MAJOR-2)。
123
+ */
124
+ private buildStore;
118
125
  /**
119
126
  * 将配置对象展平为点号路径
120
127
  */
@@ -11,7 +11,7 @@ import {
11
11
  searchTasksTool,
12
12
  treeTasksTool,
13
13
  updateTaskTool
14
- } from "../../../shared/@ai-setting/roy-agent-core-qwd2dq5q.js";
14
+ } from "../../../shared/@ai-setting/roy-agent-core-9cen1jvg.js";
15
15
  import"../../../shared/@ai-setting/roy-agent-core-d6zdbgtc.js";
16
16
  import"../../../shared/@ai-setting/roy-agent-core-m46fe3x4.js";
17
17
  import"../../../shared/@ai-setting/roy-agent-core-4rtg69cn.js";
@@ -29,6 +29,7 @@ export declare const CreateTaskToolSchema: z.ZodObject<{
29
29
  project_path: z.ZodDefault<z.ZodString>;
30
30
  parent_task_id: z.ZodOptional<z.ZodUnion<[z.ZodNumber, z.ZodNull]>>;
31
31
  context: z.ZodDefault<z.ZodString>;
32
+ owner: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNull]>>;
32
33
  }, "strip", z.ZodTypeAny, {
33
34
  type: "normal" | "cycle" | "longterm";
34
35
  title: string;
@@ -40,6 +41,7 @@ export declare const CreateTaskToolSchema: z.ZodObject<{
40
41
  goals_and_expected_deliverables?: string | undefined;
41
42
  due_date?: string | undefined;
42
43
  parent_task_id?: number | null | undefined;
44
+ owner?: string | null | undefined;
43
45
  }, {
44
46
  title: string;
45
47
  type?: "normal" | "cycle" | "longterm" | undefined;
@@ -51,6 +53,7 @@ export declare const CreateTaskToolSchema: z.ZodObject<{
51
53
  project_path?: string | undefined;
52
54
  parent_task_id?: number | null | undefined;
53
55
  context?: string | undefined;
56
+ owner?: string | null | undefined;
54
57
  }>;
55
58
  export type CreateTaskToolParams = z.infer<typeof CreateTaskToolSchema>;
56
59
  /**
@@ -166,6 +169,7 @@ export declare const UpdateTaskToolSchema: z.ZodEffects<z.ZodObject<{
166
169
  project_path: z.ZodOptional<z.ZodString>;
167
170
  context: z.ZodOptional<z.ZodString>;
168
171
  parent_task_id: z.ZodOptional<z.ZodUnion<[z.ZodNumber, z.ZodNull]>>;
172
+ owner: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNull]>>;
169
173
  }, "strip", z.ZodTypeAny, {
170
174
  task_id: number;
171
175
  type?: "normal" | "cycle" | "longterm" | undefined;
@@ -180,6 +184,7 @@ export declare const UpdateTaskToolSchema: z.ZodEffects<z.ZodObject<{
180
184
  project_path?: string | undefined;
181
185
  parent_task_id?: number | null | undefined;
182
186
  context?: string | undefined;
187
+ owner?: string | null | undefined;
183
188
  current_status?: string | undefined;
184
189
  }, {
185
190
  task_id: number;
@@ -195,6 +200,7 @@ export declare const UpdateTaskToolSchema: z.ZodEffects<z.ZodObject<{
195
200
  project_path?: string | undefined;
196
201
  parent_task_id?: number | null | undefined;
197
202
  context?: string | undefined;
203
+ owner?: string | null | undefined;
198
204
  current_status?: string | undefined;
199
205
  }>, {
200
206
  task_id: number;
@@ -210,6 +216,7 @@ export declare const UpdateTaskToolSchema: z.ZodEffects<z.ZodObject<{
210
216
  project_path?: string | undefined;
211
217
  parent_task_id?: number | null | undefined;
212
218
  context?: string | undefined;
219
+ owner?: string | null | undefined;
213
220
  current_status?: string | undefined;
214
221
  }, unknown>;
215
222
  export type UpdateTaskToolParams = z.infer<typeof UpdateTaskToolSchema>;
@@ -59,6 +59,16 @@ export interface Task {
59
59
  project_path: string;
60
60
  /** JSON string with time-space positioning info (worktree, branch, etc.) */
61
61
  context: string;
62
+ /**
63
+ * 负责人(Task #5440)。
64
+ *
65
+ * 语义:这个任务的**人**(open_id / 用户名 / 邮箱,字符串,core 不解释格式)。
66
+ * - 可空:`null` 表示未指派(新建任务的默认值)
67
+ * - 多人协作场景下用来区分「谁在负责推进」,与 `sessionId`(谁在操作)
68
+ * 和 `project_path`(在哪个项目)正交
69
+ * - 与 task-service 后端的 `owner` 列同源,remote 模式下原样落库
70
+ */
71
+ owner?: string | null;
62
72
  }
63
73
  /**
64
74
  * TaskOperation entity — 双维度操作记录(Task #2211 重构后版本)
@@ -171,6 +181,8 @@ export interface CreateTaskOptions {
171
181
  * Must be a valid JSON string.
172
182
  */
173
183
  context: string;
184
+ /** 负责人(可选,不传即 null;参见 Task.owner)。 */
185
+ owner?: string | null;
174
186
  }
175
187
  export interface UpdateTaskOptions {
176
188
  title?: string;
@@ -187,6 +199,11 @@ export interface UpdateTaskOptions {
187
199
  project_path?: string;
188
200
  /** 任务上下文信息,用于存储额外上下文 */
189
201
  context?: string;
202
+ /**
203
+ * 负责人(可选)。传 `null` 或 `""` 表示清空;传字符串表示改为该负责人;
204
+ * **字段省略**表示不改(与 status/progress 等字段语义一致)。
205
+ */
206
+ owner?: string | null;
190
207
  /** 父任务 ID,null = 设为根任务(无父任务) */
191
208
  parent_task_id?: number | null;
192
209
  }
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  LarkCliWorkflowNotifyHook,
3
3
  createLarkCliWorkflowNotifyHook
4
- } from "../../../shared/@ai-setting/roy-agent-core-wr1qexzq.js";
5
- import"../../../shared/@ai-setting/roy-agent-core-shb1qsyg.js";
4
+ } from "../../../shared/@ai-setting/roy-agent-core-5dhvfgaw.js";
5
+ import"../../../shared/@ai-setting/roy-agent-core-0n1wwndq.js";
6
6
  import"../../../shared/@ai-setting/roy-agent-core-418zc9ha.js";
7
- import"../../../shared/@ai-setting/roy-agent-core-6k8mb7zx.js";
7
+ import"../../../shared/@ai-setting/roy-agent-core-m66ysky0.js";
8
8
  import"../../../shared/@ai-setting/roy-agent-core-h83zdsrq.js";
9
9
  import"../../../shared/@ai-setting/roy-agent-core-smf94h73.js";
10
10
  import"../../../shared/@ai-setting/roy-agent-core-yet36q5k.js";
package/dist/index.d.ts CHANGED
@@ -31,7 +31,7 @@ export { cascadeStopSessionTree, type CascadeStopOptions, type CascadeStopResult
31
31
  export { createMemoryAgentTools, } from "./env/memory/tools/memory-agent-tools";
32
32
  export type { SearchSessionsParams, GetSessionParams, WriteMemoryParams, } from "./env/memory/tools/memory-agent-tools";
33
33
  export { getBuiltInPrompt, getBuiltInPromptNames, } from "./env/prompt/prompts-index";
34
- export { TaskComponent, SQLiteTaskStore, getDefaultTaskDbPath, TASK_COMPLETED_STATUS_WORD, TASK_CANCELLED_STATUS_WORD, TASK_ARCHIVED_STATUS_WORD, TASK_DELIVERABLE_RECORDED, } from "./env/task";
34
+ export { TaskComponent, SQLiteTaskStore, RemoteTaskStore, createRemoteTaskStore, getDefaultTaskDbPath, TASK_COMPLETED_STATUS_WORD, TASK_CANCELLED_STATUS_WORD, TASK_ARCHIVED_STATUS_WORD, TASK_DELIVERABLE_RECORDED, } from "./env/task";
35
35
  export type { Task, TaskOperation, TaskStatus, TaskPriority, ActionType, CreateTaskOptions, UpdateTaskOptions, ListTasksOptions, CreateOperationOptions, ListOperationsOptions, TaskConfig, } from "./env/task/types";
36
36
  export { TaskTagPlugin, createAutoTaskPlugin, type AutoTaskPluginConfig, } from "./env/task/plugins";
37
37
  export { TaskHookPoints, type TaskHookPoint, } from "./env/task/hooks";
package/dist/index.js CHANGED
@@ -62,21 +62,25 @@ import {
62
62
  BaseEnvironment,
63
63
  generateDescendingId,
64
64
  generateId
65
- } from "./shared/@ai-setting/roy-agent-core-an35dzbf.js";
65
+ } from "./shared/@ai-setting/roy-agent-core-dvec4nn2.js";
66
66
  import {
67
67
  TaskComponent
68
- } from "./shared/@ai-setting/roy-agent-core-fan8g0z1.js";
68
+ } from "./shared/@ai-setting/roy-agent-core-49qcpqwg.js";
69
69
  import"./shared/@ai-setting/roy-agent-core-2akfd64z.js";
70
70
  import"./shared/@ai-setting/roy-agent-core-jm136jzh.js";
71
71
  import"./shared/@ai-setting/roy-agent-core-0sbmdz8d.js";
72
72
  import"./shared/@ai-setting/roy-agent-core-fttgm52a.js";
73
- import"./shared/@ai-setting/roy-agent-core-vpcxv1ty.js";
73
+ import"./shared/@ai-setting/roy-agent-core-05z35shp.js";
74
+ import {
75
+ RemoteTaskStore,
76
+ createRemoteTaskStore
77
+ } from "./shared/@ai-setting/roy-agent-core-zhwcje5a.js";
74
78
  import"./shared/@ai-setting/roy-agent-core-8gxth0eh.js";
75
- import"./shared/@ai-setting/roy-agent-core-qwd2dq5q.js";
79
+ import"./shared/@ai-setting/roy-agent-core-9cen1jvg.js";
76
80
  import"./shared/@ai-setting/roy-agent-core-p5cz9m8v.js";
77
81
  import {
78
82
  EventSourceComponent
79
- } from "./shared/@ai-setting/roy-agent-core-yh68z1bg.js";
83
+ } from "./shared/@ai-setting/roy-agent-core-m7d1t3db.js";
80
84
  import {
81
85
  BountyIMInstance,
82
86
  COMMAND_PREFIX,
@@ -131,7 +135,7 @@ import {
131
135
  translateCardActionToCommand,
132
136
  wecomCliHandler,
133
137
  writeFallbackModelList
134
- } from "./shared/@ai-setting/roy-agent-core-gr5h1dyr.js";
138
+ } from "./shared/@ai-setting/roy-agent-core-4b38m749.js";
135
139
  import {
136
140
  BUILT_IN_EVENT_SOURCE_TYPES,
137
141
  BUILT_IN_EVENT_SOURCE_TYPE_LIST,
@@ -148,7 +152,7 @@ import {
148
152
  cliCommandHandler,
149
153
  parseCliSessionChatId
150
154
  } from "./shared/@ai-setting/roy-agent-core-v0hf14bj.js";
151
- import"./shared/@ai-setting/roy-agent-core-7kvpc0w5.js";
155
+ import"./shared/@ai-setting/roy-agent-core-age3qseb.js";
152
156
  import {
153
157
  LogTraceComponent,
154
158
  LogTraceConfigSchema
@@ -157,7 +161,7 @@ import"./shared/@ai-setting/roy-agent-core-2stt4rp5.js";
157
161
  import {
158
162
  TaskTagPlugin,
159
163
  createAutoTaskPlugin
160
- } from "./shared/@ai-setting/roy-agent-core-ra66sf50.js";
164
+ } from "./shared/@ai-setting/roy-agent-core-k3h8t4q1.js";
161
165
  import"./shared/@ai-setting/roy-agent-core-h1e1fm9b.js";
162
166
  import"./shared/@ai-setting/roy-agent-core-c4ec7k0p.js";
163
167
  import {
@@ -187,13 +191,13 @@ import {
187
191
  TASK_COMPLETED_STATUS_WORD,
188
192
  TASK_DELIVERABLE_RECORDED
189
193
  } from "./shared/@ai-setting/roy-agent-core-4rtg69cn.js";
190
- import"./shared/@ai-setting/roy-agent-core-wr1qexzq.js";
191
- import"./shared/@ai-setting/roy-agent-core-shb1qsyg.js";
194
+ import"./shared/@ai-setting/roy-agent-core-5dhvfgaw.js";
195
+ import"./shared/@ai-setting/roy-agent-core-0n1wwndq.js";
192
196
  import"./shared/@ai-setting/roy-agent-core-418zc9ha.js";
193
197
  import {
194
198
  SQLiteTaskStore,
195
199
  getDefaultTaskDbPath
196
- } from "./shared/@ai-setting/roy-agent-core-6k8mb7zx.js";
200
+ } from "./shared/@ai-setting/roy-agent-core-m66ysky0.js";
197
201
  import {
198
202
  WorkflowComponent
199
203
  } from "./shared/@ai-setting/roy-agent-core-n197medr.js";
@@ -688,6 +692,7 @@ export {
688
692
  embedParamFilter,
689
693
  editFileTool,
690
694
  createWorkflowFromClass,
695
+ createRemoteTaskStore,
691
696
  createPriorityHook,
692
697
  createMemoryPlugin,
693
698
  createMemoryAgentTools,
@@ -749,6 +754,7 @@ export {
749
754
  SQLiteSpanStorage,
750
755
  RoyError,
751
756
  ReplFormatter,
757
+ RemoteTaskStore,
752
758
  ProviderConfigSchema,
753
759
  ProviderCapabilitiesSchema,
754
760
  PromptStore,
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  init_sqlite_task_store
3
- } from "./roy-agent-core-6k8mb7zx.js";
3
+ } from "./roy-agent-core-m66ysky0.js";
4
4
 
5
5
  // src/env/task/storage/index.ts
6
6
  init_sqlite_task_store();
@@ -5,7 +5,7 @@ import {
5
5
  import {
6
6
  createCompatibleDatabase,
7
7
  init_sqlite_task_store
8
- } from "./roy-agent-core-6k8mb7zx.js";
8
+ } from "./roy-agent-core-m66ysky0.js";
9
9
  import {
10
10
  TracedAs,
11
11
  init_decorator
@@ -10,6 +10,9 @@ import {
10
10
  BackgroundTaskManager,
11
11
  createDelegateTool
12
12
  } from "./roy-agent-core-0sbmdz8d.js";
13
+ import {
14
+ RemoteTaskStore
15
+ } from "./roy-agent-core-zhwcje5a.js";
13
16
  import {
14
17
  TaskEntityEventTypes
15
18
  } from "./roy-agent-core-8gxth0eh.js";
@@ -26,7 +29,7 @@ import {
26
29
  searchTasksTool,
27
30
  treeTasksTool,
28
31
  updateTaskTool
29
- } from "./roy-agent-core-qwd2dq5q.js";
32
+ } from "./roy-agent-core-9cen1jvg.js";
30
33
  import {
31
34
  createOperationTool,
32
35
  deleteOperationTool,
@@ -50,7 +53,7 @@ import {
50
53
  import {
51
54
  SQLiteTaskStore,
52
55
  getDefaultTaskDbPath
53
- } from "./roy-agent-core-6k8mb7zx.js";
56
+ } from "./roy-agent-core-m66ysky0.js";
54
57
  import {
55
58
  envKeyToConfigKey
56
59
  } from "./roy-agent-core-7hh0brvs.js";
@@ -83,7 +86,9 @@ init_logger();
83
86
  // src/env/task/task-config-registration.ts
84
87
  var TASK_DEFAULTS = {
85
88
  "task.storage.type": "sqlite",
86
- "task.storage.dbPath": undefined
89
+ "task.storage.dbPath": undefined,
90
+ "task.storage.endpoint": undefined,
91
+ "task.storage.authToken": undefined
87
92
  };
88
93
  var TASK_CONFIG_REGISTRATION = {
89
94
  name: "task",
@@ -92,7 +97,9 @@ var TASK_CONFIG_REGISTRATION = {
92
97
  ],
93
98
  keys: [
94
99
  { key: "task.storage.type", sources: ["env", "file"] },
95
- { key: "task.storage.dbPath", sources: ["env", "file"] }
100
+ { key: "task.storage.dbPath", sources: ["env", "file"] },
101
+ { key: "task.storage.endpoint", sources: ["env", "file"] },
102
+ { key: "task.storage.authToken", sources: ["env", "file"] }
96
103
  ]
97
104
  };
98
105
 
@@ -305,14 +312,40 @@ class TaskComponent extends BaseComponent {
305
312
  return;
306
313
  const storageType = configComponent.get("task.storage.type") ?? "sqlite";
307
314
  const dbPath = configComponent.get("task.storage.dbPath");
308
- if (storageType === "sqlite") {
309
- this.store = new SQLiteTaskStore(dbPath);
315
+ const previous = this.store;
316
+ const nextStore = this.buildStore(storageType, dbPath);
317
+ if (previous) {
318
+ try {
319
+ previous.close();
320
+ } catch (e) {
321
+ logger2.warn(`[TaskComponent] Failed to close previous store: ${e instanceof Error ? e.message : String(e)}`);
322
+ }
323
+ }
324
+ this.store = nextStore;
325
+ this.tagService = new DefaultTagService(this.store);
326
+ if (storageType === "remote") {
327
+ const endpoint = configComponent.get("task.storage.endpoint");
328
+ logger2.info(`[TaskComponent] Using remote task-service: ${endpoint}` + `${configComponent.get("task.storage.authToken") ? " (with bearer token)" : " (no auth token)"}`);
329
+ } else if (storageType === "sqlite") {
310
330
  logger2.info(`[TaskComponent] Using SQLite storage: ${dbPath || "default path"}`);
311
- } else {
312
- this.store = new SQLiteTaskStore;
313
- logger2.info("[TaskComponent] Using SQLite storage (default)");
314
331
  }
315
332
  }
333
+ buildStore(storageType, dbPath) {
334
+ const configComponent = this.configComponent;
335
+ if (storageType === "remote") {
336
+ const endpoint = configComponent?.get("task.storage.endpoint");
337
+ const authToken = configComponent?.get("task.storage.authToken");
338
+ if (!endpoint) {
339
+ throw new Error("[TaskComponent] task.storage.type=remote requires task.storage.endpoint " + "(e.g. http://127.0.0.1:7820). Set task.storage.endpoint and task.storage.authToken " + "to match the running roy-task-service. No local fallback is performed by design.");
340
+ }
341
+ return new RemoteTaskStore({ endpoint, authToken });
342
+ }
343
+ if (storageType === "sqlite") {
344
+ return new SQLiteTaskStore(dbPath);
345
+ }
346
+ logger2.warn(`[TaskComponent] Unknown task.storage.type="${String(storageType)}", ` + `falling back to default SQLite storage. Supported: "sqlite" | "remote".`);
347
+ return new SQLiteTaskStore;
348
+ }
316
349
  flattenConfig(obj, prefix = "task") {
317
350
  const result = {};
318
351
  for (const [key, value] of Object.entries(obj)) {
@@ -338,8 +371,10 @@ class TaskComponent extends BaseComponent {
338
371
  oldValue: event.oldValue,
339
372
  newValue: event.newValue
340
373
  });
341
- if (event.key === "task.storage.type" || event.key === "task.storage.dbPath") {
342
- this.initStore();
374
+ if (event.key === "task.storage.type" || event.key === "task.storage.dbPath" || event.key === "task.storage.endpoint" || event.key === "task.storage.authToken") {
375
+ Promise.resolve(this.initStore()).catch((e) => {
376
+ logger2.error(`[TaskComponent] Failed to re-init store after ${event.key} change: ` + `${e instanceof Error ? e.message : String(e)} (keeping previous store)`);
377
+ });
343
378
  }
344
379
  }
345
380
  configWatcher;
@@ -6,7 +6,7 @@ import {
6
6
  } from "./roy-agent-core-v0hf14bj.js";
7
7
  import {
8
8
  getSharedWecomSessionCardStore
9
- } from "./roy-agent-core-7kvpc0w5.js";
9
+ } from "./roy-agent-core-age3qseb.js";
10
10
  import {
11
11
  guardConfigWrite
12
12
  } from "./roy-agent-core-2stt4rp5.js";
@@ -19,7 +19,7 @@ import {
19
19
  createWecomTaskNotifyHook,
20
20
  deleteGroupChatViaLarkCli,
21
21
  handleCardAction
22
- } from "./roy-agent-core-ra66sf50.js";
22
+ } from "./roy-agent-core-k3h8t4q1.js";
23
23
  import {
24
24
  registerWecomRespondTarget,
25
25
  sendWecomCliMarkdown,
@@ -37,12 +37,12 @@ import {
37
37
  } from "./roy-agent-core-4t3yskp8.js";
38
38
  import {
39
39
  createLarkCliWorkflowNotifyHook
40
- } from "./roy-agent-core-wr1qexzq.js";
40
+ } from "./roy-agent-core-5dhvfgaw.js";
41
41
  import {
42
42
  DEFAULT_APP_LINK_BASE,
43
43
  getSharedLarkCardNotifier,
44
44
  getSharedLarkCardStateStore
45
- } from "./roy-agent-core-shb1qsyg.js";
45
+ } from "./roy-agent-core-0n1wwndq.js";
46
46
  import {
47
47
  RECENT_MESSAGE_LIMIT,
48
48
  createActivityProbe,
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  LarkCardPatchNotifier,
3
3
  formatDurationMs
4
- } from "./roy-agent-core-shb1qsyg.js";
4
+ } from "./roy-agent-core-0n1wwndq.js";
5
5
  import {
6
6
  WorkflowHookPoints,
7
7
  init_workflow_hook_points
@@ -62,7 +62,8 @@ var CreateTaskToolSchema = z.object({
62
62
  ` + ` C. 新建根任务 → 省略 parent_task_id(让树根 ≤10)
63
63
  ` + `如何找到 parent_task_id:使用 task_tree(depth=2) 获取的树形结构,
64
64
  ` + "根据节点 id 选择合适的父任务 ID(来自 tree 输出,**不要硬编码**数字)。"),
65
- context: z.string().default('{"type":"unknown"}').describe("JSON string with time-space positioning information for task continuity. " + "This field is crucial for Agent task handoff. " + "Core fields: worktree_path (git worktree path), branch (current branch), type (feature/bug/refactor/chore). " + 'Example for coding: {"worktree_path": "/path/worktree", "branch": "feature/xyz", "type": "feature"}. ' + 'Example for other: {"type": "general"}. ' + `If unknown, use '{}' or '{"type":"unknown"}'. ` + "IMPORTANT: Must be a valid JSON string! " + "**Task #4467 — similar_task_ids (REQUIRED)**: array of existing task ids that " + "cover the same ground as this request, used by the task:before.create decision " + "check to suggest reusing/reopening instead of creating a duplicate. " + "Search first (task_search / task_get), then pass the ids. " + "It may be an empty array [] if you searched and found nothing related — " + "but the field itself must be present. " + 'Example: {"type":"feature", "similar_task_ids": [4433, 4445]}')
65
+ context: z.string().default('{"type":"unknown"}').describe("JSON string with time-space positioning information for task continuity. " + "This field is crucial for Agent task handoff. " + "Core fields: worktree_path (git worktree path), branch (current branch), type (feature/bug/refactor/chore). " + 'Example for coding: {"worktree_path": "/path/worktree", "branch": "feature/xyz", "type": "feature"}. ' + 'Example for other: {"type": "general"}. ' + `If unknown, use '{}' or '{"type":"unknown"}'. ` + "IMPORTANT: Must be a valid JSON string! " + "**Task #4467 — similar_task_ids (REQUIRED)**: array of existing task ids that " + "cover the same ground as this request, used by the task:before.create decision " + "check to suggest reusing/reopening instead of creating a duplicate. " + "Search first (task_search / task_get), then pass the ids. " + "It may be an empty array [] if you searched and found nothing related — " + "but the field itself must be present. " + 'Example: {"type":"feature", "similar_task_ids": [4433, 4445]}'),
66
+ owner: z.union([z.string(), z.null()]).optional().describe("负责人(owner):这个任务由**谁**负责推进,可空(不传 / 传 null 即未指派)。" + "取值为自由字符串(open_id / 用户名 / 邮箱均可,core 不解释格式);" + "多人协作场景下用它区分负责人,与 sessionId(谁在操作)、project_path(哪个项目)正交。" + "向后兼容:省略该字段时任务以 owner=null 创建。")
66
67
  });
67
68
  var GetTaskToolSchema = withLegacyTaskId({
68
69
  include_operations: z.boolean().optional().default(true).describe("Include operation records (milestones / process log) with the task. " + "Defaults to true — the task's operation history is part of its detail. " + "Pass false for a lean task-only response.")
@@ -100,7 +101,8 @@ var UpdateTaskToolSchema = withLegacyTaskId({
100
101
  tags: z.array(z.string()).optional(),
101
102
  project_path: z.string().optional().describe("Project path, identifies which project this task belongs to"),
102
103
  context: z.string().optional().describe("Task context information for storing additional context"),
103
- parent_task_id: z.union([z.number(), z.null()]).optional().describe("Parent task ID (set to null to make it a root task)")
104
+ parent_task_id: z.union([z.number(), z.null()]).optional().describe("Parent task ID (set to null to make it a root task)"),
105
+ owner: z.union([z.string(), z.null()]).optional().describe("负责人(owner):可空。传字符串 = 指派/改派该负责人;传 null 或空字符串 = 清空(未指派);" + "**省略该字段** = 不改动(与 status / progress 等字段语义一致)。" + "用于多人协作场景标注任务负责人。")
104
106
  });
105
107
  var DeleteTaskToolSchema = z.object({
106
108
  task_id: z.number().describe("Task ID")
@@ -518,7 +520,8 @@ function createTaskTool(taskComponent) {
518
520
  tags: inheritedTags,
519
521
  sessionId,
520
522
  project_path: inheritedProjectPath ?? (callerProjectPathIsExplicit ? callerProjectPath : UNKNOWN_PROJECT_PATH),
521
- context: enrichedContext
523
+ context: enrichedContext,
524
+ owner: params.owner ?? null
522
525
  });
523
526
  setCurrentTaskId(task.id);
524
527
  logger2.info(`[createTask] Trace: Task #${task.id} created, currentTaskId=${task.id} set in EnvContext`);
@@ -877,7 +880,8 @@ function updateTaskTool(taskComponent) {
877
880
  tags: params.tags,
878
881
  project_path: params.project_path,
879
882
  context: params.context,
880
- parent_task_id: params.parent_task_id
883
+ parent_task_id: params.parent_task_id,
884
+ owner: params.owner
881
885
  });
882
886
  if (!task) {
883
887
  return {