@elizaos/plugin-todos 2.0.3-beta.5 → 2.0.3-beta.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/actions/todo.d.ts +17 -0
- package/dist/actions/todo.d.ts.map +1 -0
- package/dist/actions/todo.js +582 -0
- package/dist/actions/todo.js.map +1 -0
- package/dist/components/todos/TodosSpatialView.d.ts +46 -0
- package/dist/components/todos/TodosSpatialView.d.ts.map +1 -0
- package/dist/components/todos/TodosSpatialView.js +72 -0
- package/dist/components/todos/TodosSpatialView.js.map +1 -0
- package/dist/components/todos/TodosView.d.ts +41 -0
- package/dist/components/todos/TodosView.d.ts.map +1 -0
- package/dist/components/todos/TodosView.js +163 -0
- package/dist/components/todos/TodosView.js.map +1 -0
- package/dist/components/todos/todos-view-bundle.d.ts +2 -0
- package/dist/components/todos/todos-view-bundle.d.ts.map +1 -0
- package/dist/components/todos/todos-view-bundle.js +5 -0
- package/dist/components/todos/todos-view-bundle.js.map +1 -0
- package/dist/db/index.d.ts +2 -0
- package/dist/db/index.d.ts.map +1 -0
- package/dist/db/index.js +2 -0
- package/dist/db/index.js.map +1 -0
- package/dist/db/schema.d.ts +249 -0
- package/dist/db/schema.d.ts.map +1 -0
- package/dist/db/schema.js +45 -0
- package/dist/db/schema.js.map +1 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +68 -0
- package/dist/index.js.map +1 -0
- package/dist/providers/current-todos.d.ts +11 -0
- package/dist/providers/current-todos.d.ts.map +1 -0
- package/dist/providers/current-todos.js +45 -0
- package/dist/providers/current-todos.js.map +1 -0
- package/dist/register-terminal-view.d.ts +15 -0
- package/dist/register-terminal-view.d.ts.map +1 -0
- package/dist/register-terminal-view.js +26 -0
- package/dist/register-terminal-view.js.map +1 -0
- package/dist/register.d.ts +9 -0
- package/dist/register.d.ts.map +1 -0
- package/dist/register.js +5 -0
- package/dist/register.js.map +1 -0
- package/dist/service.d.ts +70 -0
- package/dist/service.d.ts.map +1 -0
- package/dist/service.js +189 -0
- package/dist/service.js.map +1 -0
- package/dist/types.d.ts +35 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +31 -0
- package/dist/types.js.map +1 -0
- package/dist/views/bundle.js +266 -0
- package/dist/views/bundle.js.map +1 -0
- package/package.json +8 -8
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/db/schema.ts"],"names":[],"mappings":"AAUA,eAAO,MAAM,WAAW,iDAAoB,CAAC;AAE7C,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA6BtB,CAAC;AAEF,MAAM,MAAM,OAAO,GAAG,OAAO,UAAU,CAAC,YAAY,CAAC;AACrD,MAAM,MAAM,UAAU,GAAG,OAAO,UAAU,CAAC,YAAY,CAAC"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { sql } from "drizzle-orm";
|
|
2
|
+
import {
|
|
3
|
+
index,
|
|
4
|
+
jsonb,
|
|
5
|
+
pgSchema,
|
|
6
|
+
text,
|
|
7
|
+
timestamp,
|
|
8
|
+
uuid
|
|
9
|
+
} from "drizzle-orm/pg-core";
|
|
10
|
+
const todosSchema = pgSchema("todos");
|
|
11
|
+
const todosTable = todosSchema.table(
|
|
12
|
+
"todos",
|
|
13
|
+
{
|
|
14
|
+
id: uuid("id").primaryKey().defaultRandom(),
|
|
15
|
+
agentId: uuid("agent_id").notNull(),
|
|
16
|
+
entityId: uuid("entity_id").notNull(),
|
|
17
|
+
roomId: uuid("room_id"),
|
|
18
|
+
worldId: uuid("world_id"),
|
|
19
|
+
content: text("content").notNull(),
|
|
20
|
+
activeForm: text("active_form").notNull(),
|
|
21
|
+
status: text("status").notNull(),
|
|
22
|
+
parentTodoId: uuid("parent_todo_id"),
|
|
23
|
+
parentTrajectoryStepId: text("parent_trajectory_step_id"),
|
|
24
|
+
metadata: jsonb("metadata").default("{}").notNull(),
|
|
25
|
+
createdAt: timestamp("created_at").default(sql`now()`).notNull(),
|
|
26
|
+
updatedAt: timestamp("updated_at").default(sql`now()`).notNull(),
|
|
27
|
+
completedAt: timestamp("completed_at")
|
|
28
|
+
},
|
|
29
|
+
(table) => ({
|
|
30
|
+
entityStatusIdx: index("idx_todos_entity_status").on(
|
|
31
|
+
table.entityId,
|
|
32
|
+
table.status
|
|
33
|
+
),
|
|
34
|
+
agentEntityIdx: index("idx_todos_agent_entity").on(
|
|
35
|
+
table.agentId,
|
|
36
|
+
table.entityId
|
|
37
|
+
),
|
|
38
|
+
roomIdx: index("idx_todos_room").on(table.roomId)
|
|
39
|
+
})
|
|
40
|
+
);
|
|
41
|
+
export {
|
|
42
|
+
todosSchema,
|
|
43
|
+
todosTable
|
|
44
|
+
};
|
|
45
|
+
//# sourceMappingURL=schema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/db/schema.ts"],"sourcesContent":["import { sql } from \"drizzle-orm\";\nimport {\n index,\n jsonb,\n pgSchema,\n text,\n timestamp,\n uuid,\n} from \"drizzle-orm/pg-core\";\n\nexport const todosSchema = pgSchema(\"todos\");\n\nexport const todosTable = todosSchema.table(\n \"todos\",\n {\n id: uuid(\"id\").primaryKey().defaultRandom(),\n agentId: uuid(\"agent_id\").notNull(),\n entityId: uuid(\"entity_id\").notNull(),\n roomId: uuid(\"room_id\"),\n worldId: uuid(\"world_id\"),\n content: text(\"content\").notNull(),\n activeForm: text(\"active_form\").notNull(),\n status: text(\"status\").notNull(),\n parentTodoId: uuid(\"parent_todo_id\"),\n parentTrajectoryStepId: text(\"parent_trajectory_step_id\"),\n metadata: jsonb(\"metadata\").default(\"{}\").notNull(),\n createdAt: timestamp(\"created_at\").default(sql`now()`).notNull(),\n updatedAt: timestamp(\"updated_at\").default(sql`now()`).notNull(),\n completedAt: timestamp(\"completed_at\"),\n },\n (table) => ({\n entityStatusIdx: index(\"idx_todos_entity_status\").on(\n table.entityId,\n table.status,\n ),\n agentEntityIdx: index(\"idx_todos_agent_entity\").on(\n table.agentId,\n table.entityId,\n ),\n roomIdx: index(\"idx_todos_room\").on(table.roomId),\n }),\n);\n\nexport type TodoRow = typeof todosTable.$inferSelect;\nexport type TodoInsert = typeof todosTable.$inferInsert;\n"],"mappings":"AAAA,SAAS,WAAW;AACpB;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEA,MAAM,cAAc,SAAS,OAAO;AAEpC,MAAM,aAAa,YAAY;AAAA,EACpC;AAAA,EACA;AAAA,IACE,IAAI,KAAK,IAAI,EAAE,WAAW,EAAE,cAAc;AAAA,IAC1C,SAAS,KAAK,UAAU,EAAE,QAAQ;AAAA,IAClC,UAAU,KAAK,WAAW,EAAE,QAAQ;AAAA,IACpC,QAAQ,KAAK,SAAS;AAAA,IACtB,SAAS,KAAK,UAAU;AAAA,IACxB,SAAS,KAAK,SAAS,EAAE,QAAQ;AAAA,IACjC,YAAY,KAAK,aAAa,EAAE,QAAQ;AAAA,IACxC,QAAQ,KAAK,QAAQ,EAAE,QAAQ;AAAA,IAC/B,cAAc,KAAK,gBAAgB;AAAA,IACnC,wBAAwB,KAAK,2BAA2B;AAAA,IACxD,UAAU,MAAM,UAAU,EAAE,QAAQ,IAAI,EAAE,QAAQ;AAAA,IAClD,WAAW,UAAU,YAAY,EAAE,QAAQ,UAAU,EAAE,QAAQ;AAAA,IAC/D,WAAW,UAAU,YAAY,EAAE,QAAQ,UAAU,EAAE,QAAQ;AAAA,IAC/D,aAAa,UAAU,cAAc;AAAA,EACvC;AAAA,EACA,CAAC,WAAW;AAAA,IACV,iBAAiB,MAAM,yBAAyB,EAAE;AAAA,MAChD,MAAM;AAAA,MACN,MAAM;AAAA,IACR;AAAA,IACA,gBAAgB,MAAM,wBAAwB,EAAE;AAAA,MAC9C,MAAM;AAAA,MACN,MAAM;AAAA,IACR;AAAA,IACA,SAAS,MAAM,gBAAgB,EAAE,GAAG,MAAM,MAAM;AAAA,EAClD;AACF;","names":[]}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { Plugin } from "@elizaos/core";
|
|
2
|
+
export declare const todosPlugin: Plugin;
|
|
3
|
+
export default todosPlugin;
|
|
4
|
+
export { todoAction } from "./actions/todo.js";
|
|
5
|
+
export { type TodoInsert, type TodoRow, todosSchema, todosTable, } from "./db/schema.js";
|
|
6
|
+
export { currentTodosProvider } from "./providers/current-todos.js";
|
|
7
|
+
export { type CreateTodoInput, getTodosService, type TodoFilter, TodosService, type UpdateTodoInput, } from "./service.js";
|
|
8
|
+
export * from "./types.js";
|
|
9
|
+
export { TodosView } from "./components/todos/TodosView.js";
|
|
10
|
+
export { type LaneId, type TodoCard, type TodosSnapshot, TodosSpatialView, type TodosViewState, } from "./components/todos/TodosSpatialView.js";
|
|
11
|
+
export { registerTodosTerminalView, setTodosTerminalSnapshot, } from "./register-terminal-view.js";
|
|
12
|
+
import "./register.js";
|
|
13
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAO5C,eAAO,MAAM,WAAW,EAAE,MA4BzB,CAAC;AAEF,eAAe,WAAW,CAAC;AAE3B,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EACL,KAAK,UAAU,EACf,KAAK,OAAO,EACZ,WAAW,EACX,UAAU,GACX,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AACpE,OAAO,EACL,KAAK,eAAe,EACpB,eAAe,EACf,KAAK,UAAU,EACf,YAAY,EACZ,KAAK,eAAe,GACrB,MAAM,cAAc,CAAC;AACtB,cAAc,YAAY,CAAC;AAE3B,OAAO,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AAC5D,OAAO,EACL,KAAK,MAAM,EACX,KAAK,QAAQ,EACb,KAAK,aAAa,EAClB,gBAAgB,EAChB,KAAK,cAAc,GACpB,MAAM,wCAAwC,CAAC;AAChD,OAAO,EACL,yBAAyB,EACzB,wBAAwB,GACzB,MAAM,6BAA6B,CAAC;AAIrC,OAAO,eAAe,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { todoAction } from "./actions/todo.js";
|
|
2
|
+
import * as dbSchema from "./db/index.js";
|
|
3
|
+
import { currentTodosProvider } from "./providers/current-todos.js";
|
|
4
|
+
import { TodosService } from "./service.js";
|
|
5
|
+
const todosPlugin = {
|
|
6
|
+
name: "todos",
|
|
7
|
+
description: "User-scoped persistent todos with CRUD. Single `TODO` umbrella action with action-based dispatch (write/create/update/complete/cancel/delete/list/clear). The currentTodosProvider surfaces the user's pending + in-progress todos to the planner each turn. Backed by a drizzle pgSchema('todos') table; requires @elizaos/plugin-sql.",
|
|
8
|
+
dependencies: ["@elizaos/plugin-sql"],
|
|
9
|
+
actions: [todoAction],
|
|
10
|
+
providers: [currentTodosProvider],
|
|
11
|
+
services: [TodosService],
|
|
12
|
+
schema: dbSchema,
|
|
13
|
+
views: [
|
|
14
|
+
{
|
|
15
|
+
id: "todos",
|
|
16
|
+
label: "Todos",
|
|
17
|
+
description: "Three-lane todo board: Today / Upcoming / Someday",
|
|
18
|
+
icon: "ListChecks",
|
|
19
|
+
path: "/todos",
|
|
20
|
+
modalities: ["gui", "xr", "tui"],
|
|
21
|
+
bundlePath: "dist/views/bundle.js",
|
|
22
|
+
componentExport: "TodosView",
|
|
23
|
+
tags: ["todos", "tasks", "productivity"],
|
|
24
|
+
visibleInManager: true,
|
|
25
|
+
desktopTabEnabled: true
|
|
26
|
+
}
|
|
27
|
+
],
|
|
28
|
+
async dispose(runtime) {
|
|
29
|
+
const svc = runtime.getService(TodosService.serviceType);
|
|
30
|
+
await svc?.stop();
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
var index_default = todosPlugin;
|
|
34
|
+
import { todoAction as todoAction2 } from "./actions/todo.js";
|
|
35
|
+
import {
|
|
36
|
+
todosSchema,
|
|
37
|
+
todosTable
|
|
38
|
+
} from "./db/schema.js";
|
|
39
|
+
import { currentTodosProvider as currentTodosProvider2 } from "./providers/current-todos.js";
|
|
40
|
+
import {
|
|
41
|
+
getTodosService,
|
|
42
|
+
TodosService as TodosService2
|
|
43
|
+
} from "./service.js";
|
|
44
|
+
export * from "./types.js";
|
|
45
|
+
import { TodosView } from "./components/todos/TodosView.js";
|
|
46
|
+
import {
|
|
47
|
+
TodosSpatialView
|
|
48
|
+
} from "./components/todos/TodosSpatialView.js";
|
|
49
|
+
import {
|
|
50
|
+
registerTodosTerminalView,
|
|
51
|
+
setTodosTerminalSnapshot
|
|
52
|
+
} from "./register-terminal-view.js";
|
|
53
|
+
import "./register.js";
|
|
54
|
+
export {
|
|
55
|
+
TodosService2 as TodosService,
|
|
56
|
+
TodosSpatialView,
|
|
57
|
+
TodosView,
|
|
58
|
+
currentTodosProvider2 as currentTodosProvider,
|
|
59
|
+
index_default as default,
|
|
60
|
+
getTodosService,
|
|
61
|
+
registerTodosTerminalView,
|
|
62
|
+
setTodosTerminalSnapshot,
|
|
63
|
+
todoAction2 as todoAction,
|
|
64
|
+
todosPlugin,
|
|
65
|
+
todosSchema,
|
|
66
|
+
todosTable
|
|
67
|
+
};
|
|
68
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import type { Plugin } from \"@elizaos/core\";\n\nimport { todoAction } from \"./actions/todo.js\";\nimport * as dbSchema from \"./db/index.js\";\nimport { currentTodosProvider } from \"./providers/current-todos.js\";\nimport { TodosService } from \"./service.js\";\n\nexport const todosPlugin: Plugin = {\n name: \"todos\",\n description:\n \"User-scoped persistent todos with CRUD. Single `TODO` umbrella action with action-based dispatch (write/create/update/complete/cancel/delete/list/clear). The currentTodosProvider surfaces the user's pending + in-progress todos to the planner each turn. Backed by a drizzle pgSchema('todos') table; requires @elizaos/plugin-sql.\",\n dependencies: [\"@elizaos/plugin-sql\"],\n actions: [todoAction],\n providers: [currentTodosProvider],\n services: [TodosService],\n schema: dbSchema,\n views: [\n {\n id: \"todos\",\n label: \"Todos\",\n description: \"Three-lane todo board: Today / Upcoming / Someday\",\n icon: \"ListChecks\",\n path: \"/todos\",\n modalities: [\"gui\", \"xr\", \"tui\"],\n bundlePath: \"dist/views/bundle.js\",\n componentExport: \"TodosView\",\n tags: [\"todos\", \"tasks\", \"productivity\"],\n visibleInManager: true,\n desktopTabEnabled: true,\n },\n ],\n async dispose(runtime) {\n const svc = runtime.getService<TodosService>(TodosService.serviceType);\n await svc?.stop();\n },\n};\n\nexport default todosPlugin;\n\nexport { todoAction } from \"./actions/todo.js\";\nexport {\n type TodoInsert,\n type TodoRow,\n todosSchema,\n todosTable,\n} from \"./db/schema.js\";\nexport { currentTodosProvider } from \"./providers/current-todos.js\";\nexport {\n type CreateTodoInput,\n getTodosService,\n type TodoFilter,\n TodosService,\n type UpdateTodoInput,\n} from \"./service.js\";\nexport * from \"./types.js\";\n\nexport { TodosView } from \"./components/todos/TodosView.js\";\nexport {\n type LaneId,\n type TodoCard,\n type TodosSnapshot,\n TodosSpatialView,\n type TodosViewState,\n} from \"./components/todos/TodosSpatialView.js\";\nexport {\n registerTodosTerminalView,\n setTodosTerminalSnapshot,\n} from \"./register-terminal-view.js\";\n\n// Side-effect: in a terminal host (Node agent, no DOM) this registers the todos\n// terminal view. DOM-guarded so the terminal engine stays out of browser bundles.\nimport \"./register.js\";\n"],"mappings":"AAEA,SAAS,kBAAkB;AAC3B,YAAY,cAAc;AAC1B,SAAS,4BAA4B;AACrC,SAAS,oBAAoB;AAEtB,MAAM,cAAsB;AAAA,EACjC,MAAM;AAAA,EACN,aACE;AAAA,EACF,cAAc,CAAC,qBAAqB;AAAA,EACpC,SAAS,CAAC,UAAU;AAAA,EACpB,WAAW,CAAC,oBAAoB;AAAA,EAChC,UAAU,CAAC,YAAY;AAAA,EACvB,QAAQ;AAAA,EACR,OAAO;AAAA,IACL;AAAA,MACE,IAAI;AAAA,MACJ,OAAO;AAAA,MACP,aAAa;AAAA,MACb,MAAM;AAAA,MACN,MAAM;AAAA,MACN,YAAY,CAAC,OAAO,MAAM,KAAK;AAAA,MAC/B,YAAY;AAAA,MACZ,iBAAiB;AAAA,MACjB,MAAM,CAAC,SAAS,SAAS,cAAc;AAAA,MACvC,kBAAkB;AAAA,MAClB,mBAAmB;AAAA,IACrB;AAAA,EACF;AAAA,EACA,MAAM,QAAQ,SAAS;AACrB,UAAM,MAAM,QAAQ,WAAyB,aAAa,WAAW;AACrE,UAAM,KAAK,KAAK;AAAA,EAClB;AACF;AAEA,IAAO,gBAAQ;AAEf,SAAS,cAAAA,mBAAkB;AAC3B;AAAA,EAGE;AAAA,EACA;AAAA,OACK;AACP,SAAS,wBAAAC,6BAA4B;AACrC;AAAA,EAEE;AAAA,EAEA,gBAAAC;AAAA,OAEK;AACP,cAAc;AAEd,SAAS,iBAAiB;AAC1B;AAAA,EAIE;AAAA,OAEK;AACP;AAAA,EACE;AAAA,EACA;AAAA,OACK;AAIP,OAAO;","names":["todoAction","currentTodosProvider","TodosService"]}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Provider } from "@elizaos/core";
|
|
2
|
+
/**
|
|
3
|
+
* Surface the user's current todo list to the planner each turn.
|
|
4
|
+
* Mirrors how Claude Code keeps the TodoWrite list in the model's context.
|
|
5
|
+
* Returns empty text when the user has no active todos.
|
|
6
|
+
*
|
|
7
|
+
* Scoping: by `entityId` (user) — todos persist across rooms for the same user.
|
|
8
|
+
* Pending + in_progress are always shown; completed/cancelled are excluded.
|
|
9
|
+
*/
|
|
10
|
+
export declare const currentTodosProvider: Provider;
|
|
11
|
+
//# sourceMappingURL=current-todos.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"current-todos.d.ts","sourceRoot":"","sources":["../../src/providers/current-todos.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAGV,QAAQ,EAGT,MAAM,eAAe,CAAC;AAkBvB;;;;;;;GAOG;AACH,eAAO,MAAM,oBAAoB,EAAE,QA+BlC,CAAC"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { TODOS_CONTEXTS, TODOS_SERVICE_TYPE } from "../types.js";
|
|
2
|
+
function checkboxFor(status) {
|
|
3
|
+
switch (status) {
|
|
4
|
+
case "completed":
|
|
5
|
+
return "[x]";
|
|
6
|
+
case "in_progress":
|
|
7
|
+
return "[\u2192]";
|
|
8
|
+
case "cancelled":
|
|
9
|
+
return "[-]";
|
|
10
|
+
default:
|
|
11
|
+
return "[ ]";
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
const currentTodosProvider = {
|
|
15
|
+
name: "CURRENT_TODOS",
|
|
16
|
+
description: "The user's current pending and in-progress todos.",
|
|
17
|
+
position: -5,
|
|
18
|
+
contexts: [...TODOS_CONTEXTS],
|
|
19
|
+
contextGate: { anyOf: [...TODOS_CONTEXTS] },
|
|
20
|
+
get: async (runtime, message, _state) => {
|
|
21
|
+
const entityId = message.entityId;
|
|
22
|
+
if (!entityId) return { text: "", data: { todos: [] } };
|
|
23
|
+
const service = runtime.getService(TODOS_SERVICE_TYPE);
|
|
24
|
+
if (!service) return { text: "", data: { todos: [] } };
|
|
25
|
+
const todos = await service.list({
|
|
26
|
+
entityId: String(entityId),
|
|
27
|
+
agentId: String(runtime.agentId),
|
|
28
|
+
includeCompleted: false
|
|
29
|
+
});
|
|
30
|
+
if (todos.length === 0) return { text: "", data: { todos: [] } };
|
|
31
|
+
const lines = [
|
|
32
|
+
"# Current todos",
|
|
33
|
+
"",
|
|
34
|
+
...todos.map((t) => `- ${checkboxFor(t.status)} ${t.content}`)
|
|
35
|
+
];
|
|
36
|
+
return {
|
|
37
|
+
text: lines.join("\n"),
|
|
38
|
+
data: { todos }
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
export {
|
|
43
|
+
currentTodosProvider
|
|
44
|
+
};
|
|
45
|
+
//# sourceMappingURL=current-todos.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/providers/current-todos.ts"],"sourcesContent":["import type {\n IAgentRuntime,\n Memory,\n Provider,\n ProviderResult,\n State,\n} from \"@elizaos/core\";\n\nimport type { TodosService } from \"../service.js\";\nimport { TODOS_CONTEXTS, TODOS_SERVICE_TYPE, type Todo } from \"../types.js\";\n\nfunction checkboxFor(status: Todo[\"status\"]): string {\n switch (status) {\n case \"completed\":\n return \"[x]\";\n case \"in_progress\":\n return \"[→]\";\n case \"cancelled\":\n return \"[-]\";\n default:\n return \"[ ]\";\n }\n}\n\n/**\n * Surface the user's current todo list to the planner each turn.\n * Mirrors how Claude Code keeps the TodoWrite list in the model's context.\n * Returns empty text when the user has no active todos.\n *\n * Scoping: by `entityId` (user) — todos persist across rooms for the same user.\n * Pending + in_progress are always shown; completed/cancelled are excluded.\n */\nexport const currentTodosProvider: Provider = {\n name: \"CURRENT_TODOS\",\n description: \"The user's current pending and in-progress todos.\",\n position: -5,\n contexts: [...TODOS_CONTEXTS],\n contextGate: { anyOf: [...TODOS_CONTEXTS] },\n get: async (\n runtime: IAgentRuntime,\n message: Memory,\n _state?: State,\n ): Promise<ProviderResult> => {\n const entityId = message.entityId;\n if (!entityId) return { text: \"\", data: { todos: [] } };\n const service = runtime.getService<TodosService>(TODOS_SERVICE_TYPE);\n if (!service) return { text: \"\", data: { todos: [] } };\n const todos = await service.list({\n entityId: String(entityId),\n agentId: String(runtime.agentId),\n includeCompleted: false,\n });\n if (todos.length === 0) return { text: \"\", data: { todos: [] } };\n const lines = [\n \"# Current todos\",\n \"\",\n ...todos.map((t) => `- ${checkboxFor(t.status)} ${t.content}`),\n ];\n return {\n text: lines.join(\"\\n\"),\n data: { todos },\n };\n },\n};\n"],"mappings":"AASA,SAAS,gBAAgB,0BAAqC;AAE9D,SAAS,YAAY,QAAgC;AACnD,UAAQ,QAAQ;AAAA,IACd,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,IACT;AACE,aAAO;AAAA,EACX;AACF;AAUO,MAAM,uBAAiC;AAAA,EAC5C,MAAM;AAAA,EACN,aAAa;AAAA,EACb,UAAU;AAAA,EACV,UAAU,CAAC,GAAG,cAAc;AAAA,EAC5B,aAAa,EAAE,OAAO,CAAC,GAAG,cAAc,EAAE;AAAA,EAC1C,KAAK,OACH,SACA,SACA,WAC4B;AAC5B,UAAM,WAAW,QAAQ;AACzB,QAAI,CAAC,SAAU,QAAO,EAAE,MAAM,IAAI,MAAM,EAAE,OAAO,CAAC,EAAE,EAAE;AACtD,UAAM,UAAU,QAAQ,WAAyB,kBAAkB;AACnE,QAAI,CAAC,QAAS,QAAO,EAAE,MAAM,IAAI,MAAM,EAAE,OAAO,CAAC,EAAE,EAAE;AACrD,UAAM,QAAQ,MAAM,QAAQ,KAAK;AAAA,MAC/B,UAAU,OAAO,QAAQ;AAAA,MACzB,SAAS,OAAO,QAAQ,OAAO;AAAA,MAC/B,kBAAkB;AAAA,IACpB,CAAC;AACD,QAAI,MAAM,WAAW,EAAG,QAAO,EAAE,MAAM,IAAI,MAAM,EAAE,OAAO,CAAC,EAAE,EAAE;AAC/D,UAAM,QAAQ;AAAA,MACZ;AAAA,MACA;AAAA,MACA,GAAG,MAAM,IAAI,CAAC,MAAM,KAAK,YAAY,EAAE,MAAM,CAAC,IAAI,EAAE,OAAO,EAAE;AAAA,IAC/D;AACA,WAAO;AAAA,MACL,MAAM,MAAM,KAAK,IAAI;AAAA,MACrB,MAAM,EAAE,MAAM;AAAA,IAChB;AAAA,EACF;AACF;","names":[]}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Register the todos view for terminal rendering.
|
|
3
|
+
*
|
|
4
|
+
* The agent terminal mounts plugin views by id from the `@elizaos/tui` terminal
|
|
5
|
+
* registry. This makes the todos `tui` modality render for real in the terminal
|
|
6
|
+
* (the unified {@link TodosSpatialView}) rather than only navigating a GUI
|
|
7
|
+
* shell. A module-level snapshot lets a host push live board data; absent a
|
|
8
|
+
* push it defaults to the loading state.
|
|
9
|
+
*/
|
|
10
|
+
import { type TodosSnapshot } from "./components/todos/TodosSpatialView.tsx";
|
|
11
|
+
/** Update the snapshot the registered terminal view renders from. */
|
|
12
|
+
export declare function setTodosTerminalSnapshot(next: TodosSnapshot): void;
|
|
13
|
+
/** Register the todos terminal view; returns an unregister function. */
|
|
14
|
+
export declare function registerTodosTerminalView(): () => void;
|
|
15
|
+
//# sourceMappingURL=register-terminal-view.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"register-terminal-view.d.ts","sourceRoot":"","sources":["../src/register-terminal-view.tsx"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAIH,OAAO,EAEL,KAAK,aAAa,EAEnB,MAAM,yCAAyC,CAAC;AASjD,qEAAqE;AACrE,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,aAAa,GAAG,IAAI,CAElE;AAED,wEAAwE;AACxE,wBAAgB,yBAAyB,IAAI,MAAM,IAAI,CAItD"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { registerSpatialTerminalView } from "@elizaos/ui/spatial/tui";
|
|
2
|
+
import { createElement } from "react";
|
|
3
|
+
import {
|
|
4
|
+
EMPTY_LANES,
|
|
5
|
+
TodosSpatialView
|
|
6
|
+
} from "./components/todos/TodosSpatialView.js";
|
|
7
|
+
const EMPTY = {
|
|
8
|
+
state: "loading",
|
|
9
|
+
lanes: EMPTY_LANES,
|
|
10
|
+
overdue: 0
|
|
11
|
+
};
|
|
12
|
+
let current = EMPTY;
|
|
13
|
+
function setTodosTerminalSnapshot(next) {
|
|
14
|
+
current = next;
|
|
15
|
+
}
|
|
16
|
+
function registerTodosTerminalView() {
|
|
17
|
+
return registerSpatialTerminalView(
|
|
18
|
+
"todos",
|
|
19
|
+
() => createElement(TodosSpatialView, { snapshot: current })
|
|
20
|
+
);
|
|
21
|
+
}
|
|
22
|
+
export {
|
|
23
|
+
registerTodosTerminalView,
|
|
24
|
+
setTodosTerminalSnapshot
|
|
25
|
+
};
|
|
26
|
+
//# sourceMappingURL=register-terminal-view.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/register-terminal-view.tsx"],"sourcesContent":["/**\n * Register the todos view for terminal rendering.\n *\n * The agent terminal mounts plugin views by id from the `@elizaos/tui` terminal\n * registry. This makes the todos `tui` modality render for real in the terminal\n * (the unified {@link TodosSpatialView}) rather than only navigating a GUI\n * shell. A module-level snapshot lets a host push live board data; absent a\n * push it defaults to the loading state.\n */\n\nimport { registerSpatialTerminalView } from \"@elizaos/ui/spatial/tui\";\nimport { createElement } from \"react\";\nimport {\n EMPTY_LANES,\n type TodosSnapshot,\n TodosSpatialView,\n} from \"./components/todos/TodosSpatialView.js\";\n\nconst EMPTY: TodosSnapshot = {\n state: \"loading\",\n lanes: EMPTY_LANES,\n overdue: 0,\n};\nlet current: TodosSnapshot = EMPTY;\n\n/** Update the snapshot the registered terminal view renders from. */\nexport function setTodosTerminalSnapshot(next: TodosSnapshot): void {\n current = next;\n}\n\n/** Register the todos terminal view; returns an unregister function. */\nexport function registerTodosTerminalView(): () => void {\n return registerSpatialTerminalView(\"todos\", () =>\n createElement(TodosSpatialView, { snapshot: current }),\n );\n}\n"],"mappings":"AAUA,SAAS,mCAAmC;AAC5C,SAAS,qBAAqB;AAC9B;AAAA,EACE;AAAA,EAEA;AAAA,OACK;AAEP,MAAM,QAAuB;AAAA,EAC3B,OAAO;AAAA,EACP,OAAO;AAAA,EACP,SAAS;AACX;AACA,IAAI,UAAyB;AAGtB,SAAS,yBAAyB,MAA2B;AAClE,YAAU;AACZ;AAGO,SAAS,4BAAwC;AACtD,SAAO;AAAA,IAA4B;AAAA,IAAS,MAC1C,cAAc,kBAAkB,EAAE,UAAU,QAAQ,CAAC;AAAA,EACvD;AACF;","names":[]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Side-effect entry point — registers the Todos view for terminal rendering.
|
|
3
|
+
*
|
|
4
|
+
* In a terminal host (the Node agent, no DOM), register the todos view so it
|
|
5
|
+
* renders inline in the terminal. Lazy + DOM-guarded so the terminal engine
|
|
6
|
+
* stays out of browser/mobile bundles. Web, iOS, desktop, and Android leave
|
|
7
|
+
* this a no-op (a DOM is present), so the same import is safe everywhere.
|
|
8
|
+
*/
|
|
9
|
+
//# sourceMappingURL=register.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"register.d.ts","sourceRoot":"","sources":["../src/register.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG"}
|
package/dist/register.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/register.ts"],"sourcesContent":["/**\n * Side-effect entry point — registers the Todos view for terminal rendering.\n *\n * In a terminal host (the Node agent, no DOM), register the todos view so it\n * renders inline in the terminal. Lazy + DOM-guarded so the terminal engine\n * stays out of browser/mobile bundles. Web, iOS, desktop, and Android leave\n * this a no-op (a DOM is present), so the same import is safe everywhere.\n */\n\nif (typeof window === \"undefined\") {\n void import(\"./register-terminal-view.js\")\n .then((m) => m.registerTodosTerminalView())\n .catch(() => {\n // Terminal rendering is best-effort; never block plugin load.\n });\n}\n"],"mappings":"AASA,IAAI,OAAO,WAAW,aAAa;AACjC,OAAK,OAAO,6BAA6B,EACtC,KAAK,CAAC,MAAM,EAAE,0BAA0B,CAAC,EACzC,MAAM,MAAM;AAAA,EAEb,CAAC;AACL;","names":[]}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { type IAgentRuntime, Service } from "@elizaos/core";
|
|
2
|
+
import { type Todo, type TodoStatus } from "./types.js";
|
|
3
|
+
export interface TodoFilter {
|
|
4
|
+
entityId: string;
|
|
5
|
+
agentId?: string;
|
|
6
|
+
roomId?: string | null;
|
|
7
|
+
status?: TodoStatus | TodoStatus[];
|
|
8
|
+
includeCompleted?: boolean;
|
|
9
|
+
limit?: number;
|
|
10
|
+
}
|
|
11
|
+
export interface CreateTodoInput {
|
|
12
|
+
entityId: string;
|
|
13
|
+
agentId: string;
|
|
14
|
+
roomId?: string | null;
|
|
15
|
+
worldId?: string | null;
|
|
16
|
+
content: string;
|
|
17
|
+
activeForm?: string;
|
|
18
|
+
status?: TodoStatus;
|
|
19
|
+
parentTodoId?: string | null;
|
|
20
|
+
parentTrajectoryStepId?: string | null;
|
|
21
|
+
metadata?: Record<string, unknown>;
|
|
22
|
+
}
|
|
23
|
+
export interface UpdateTodoInput {
|
|
24
|
+
content?: string;
|
|
25
|
+
activeForm?: string;
|
|
26
|
+
status?: TodoStatus;
|
|
27
|
+
parentTodoId?: string | null;
|
|
28
|
+
metadata?: Record<string, unknown>;
|
|
29
|
+
}
|
|
30
|
+
export declare class TodosService extends Service {
|
|
31
|
+
static readonly serviceType = "todos";
|
|
32
|
+
capabilityDescription: string;
|
|
33
|
+
private getDb;
|
|
34
|
+
static start(runtime: IAgentRuntime): Promise<TodosService>;
|
|
35
|
+
stop(): Promise<void>;
|
|
36
|
+
create(input: CreateTodoInput): Promise<Todo>;
|
|
37
|
+
get(id: string): Promise<Todo | null>;
|
|
38
|
+
list(filter: TodoFilter): Promise<Todo[]>;
|
|
39
|
+
update(id: string, patch: UpdateTodoInput): Promise<Todo | null>;
|
|
40
|
+
delete(id: string): Promise<boolean>;
|
|
41
|
+
/**
|
|
42
|
+
* Bulk-replace the user's todo list for a given (entityId, roomId) scope.
|
|
43
|
+
* Mirrors Claude Code's TodoWrite contract: the caller passes the full
|
|
44
|
+
* desired list, and the store reconciles. Existing rows are matched by id;
|
|
45
|
+
* absent rows are deleted; new rows are inserted.
|
|
46
|
+
*/
|
|
47
|
+
writeList(args: {
|
|
48
|
+
entityId: string;
|
|
49
|
+
agentId: string;
|
|
50
|
+
roomId: string | null;
|
|
51
|
+
worldId: string | null;
|
|
52
|
+
parentTrajectoryStepId: string | null;
|
|
53
|
+
todos: Array<{
|
|
54
|
+
id?: string;
|
|
55
|
+
content: string;
|
|
56
|
+
status: TodoStatus;
|
|
57
|
+
activeForm?: string;
|
|
58
|
+
}>;
|
|
59
|
+
}): Promise<{
|
|
60
|
+
before: Todo[];
|
|
61
|
+
after: Todo[];
|
|
62
|
+
}>;
|
|
63
|
+
clear(filter: {
|
|
64
|
+
entityId: string;
|
|
65
|
+
agentId?: string;
|
|
66
|
+
roomId?: string | null;
|
|
67
|
+
}): Promise<number>;
|
|
68
|
+
}
|
|
69
|
+
export declare function getTodosService(runtime: IAgentRuntime): TodosService;
|
|
70
|
+
//# sourceMappingURL=service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../src/service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,aAAa,EAAU,OAAO,EAAa,MAAM,eAAe,CAAC;AAK/E,OAAO,EAGL,KAAK,IAAI,EACT,KAAK,UAAU,EAChB,MAAM,YAAY,CAAC;AAEpB,MAAM,WAAW,UAAU;IACzB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,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,CAAC,MAAM,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC;IA4BzC,MAAM,CAAC,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,GAAG,IAAI,CAAC;IAmBhE,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAS1C;;;;;OAKG;IACG,SAAS,CAAC,IAAI,EAAE;QACpB,QAAQ,EAAE,MAAM,CAAC;QACjB,OAAO,EAAE,MAAM,CAAC;QAChB,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;QACtB,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;QACvB,sBAAsB,EAAE,MAAM,GAAG,IAAI,CAAC;QACtC,KAAK,EAAE,KAAK,CAAC;YACX,EAAE,CAAC,EAAE,MAAM,CAAC;YACZ,OAAO,EAAE,MAAM,CAAC;YAChB,MAAM,EAAE,UAAU,CAAC;YACnB,UAAU,CAAC,EAAE,MAAM,CAAC;SACrB,CAAC,CAAC;KACJ,GAAG,OAAO,CAAC;QAAE,MAAM,EAAE,IAAI,EAAE,CAAC;QAAC,KAAK,EAAE,IAAI,EAAE,CAAA;KAAE,CAAC;IA0DxC,KAAK,CAAC,MAAM,EAAE;QAClB,QAAQ,EAAE,MAAM,CAAC;QACjB,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;KACxB,GAAG,OAAO,CAAC,MAAM,CAAC;CAepB;AAED,wBAAgB,eAAe,CAAC,OAAO,EAAE,aAAa,GAAG,YAAY,CAQpE"}
|
package/dist/service.js
ADDED
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
import { logger, Service } from "@elizaos/core";
|
|
2
|
+
import { and, desc, eq, inArray } from "drizzle-orm";
|
|
3
|
+
import { todosTable } from "./db/schema.js";
|
|
4
|
+
import {
|
|
5
|
+
TODOS_LOG_PREFIX,
|
|
6
|
+
TODOS_SERVICE_TYPE
|
|
7
|
+
} from "./types.js";
|
|
8
|
+
function rowToTodo(row) {
|
|
9
|
+
const metadata = row.metadata && typeof row.metadata === "object" && !Array.isArray(row.metadata) ? row.metadata : {};
|
|
10
|
+
return {
|
|
11
|
+
id: row.id,
|
|
12
|
+
entityId: row.entityId,
|
|
13
|
+
agentId: row.agentId,
|
|
14
|
+
roomId: row.roomId ?? null,
|
|
15
|
+
worldId: row.worldId ?? null,
|
|
16
|
+
content: row.content,
|
|
17
|
+
activeForm: row.activeForm,
|
|
18
|
+
status: row.status,
|
|
19
|
+
parentTodoId: row.parentTodoId ?? null,
|
|
20
|
+
parentTrajectoryStepId: row.parentTrajectoryStepId ?? null,
|
|
21
|
+
metadata,
|
|
22
|
+
createdAt: row.createdAt,
|
|
23
|
+
updatedAt: row.updatedAt,
|
|
24
|
+
completedAt: row.completedAt ?? null
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
class TodosService extends Service {
|
|
28
|
+
static serviceType = TODOS_SERVICE_TYPE;
|
|
29
|
+
capabilityDescription = "User-scoped todo CRUD. Persistent (drizzle/postgres), keyed by (agentId, entityId).";
|
|
30
|
+
getDb() {
|
|
31
|
+
const db = this.runtime.db;
|
|
32
|
+
if (!db) {
|
|
33
|
+
throw new Error(
|
|
34
|
+
`${TODOS_LOG_PREFIX} runtime.db is not available \u2014 @elizaos/plugin-sql must be installed and initialized.`
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
return db;
|
|
38
|
+
}
|
|
39
|
+
static async start(runtime) {
|
|
40
|
+
logger.info(`${TODOS_LOG_PREFIX} starting TodosService`);
|
|
41
|
+
return new TodosService(runtime);
|
|
42
|
+
}
|
|
43
|
+
async stop() {
|
|
44
|
+
logger.info(`${TODOS_LOG_PREFIX} stopping TodosService`);
|
|
45
|
+
}
|
|
46
|
+
async create(input) {
|
|
47
|
+
const db = this.getDb();
|
|
48
|
+
const [row] = await db.insert(todosTable).values({
|
|
49
|
+
agentId: input.agentId,
|
|
50
|
+
entityId: input.entityId,
|
|
51
|
+
roomId: input.roomId ?? null,
|
|
52
|
+
worldId: input.worldId ?? null,
|
|
53
|
+
content: input.content,
|
|
54
|
+
activeForm: input.activeForm ?? input.content,
|
|
55
|
+
status: input.status ?? "pending",
|
|
56
|
+
parentTodoId: input.parentTodoId ?? null,
|
|
57
|
+
parentTrajectoryStepId: input.parentTrajectoryStepId ?? null,
|
|
58
|
+
metadata: input.metadata ?? {}
|
|
59
|
+
}).returning();
|
|
60
|
+
if (!row) throw new Error(`${TODOS_LOG_PREFIX} insert returned no row`);
|
|
61
|
+
return rowToTodo(row);
|
|
62
|
+
}
|
|
63
|
+
async get(id) {
|
|
64
|
+
const db = this.getDb();
|
|
65
|
+
const [row] = await db.select().from(todosTable).where(eq(todosTable.id, id)).limit(1);
|
|
66
|
+
return row ? rowToTodo(row) : null;
|
|
67
|
+
}
|
|
68
|
+
async list(filter) {
|
|
69
|
+
const db = this.getDb();
|
|
70
|
+
const conditions = [eq(todosTable.entityId, filter.entityId)];
|
|
71
|
+
if (filter.agentId) {
|
|
72
|
+
conditions.push(eq(todosTable.agentId, filter.agentId));
|
|
73
|
+
}
|
|
74
|
+
if (filter.roomId !== void 0 && filter.roomId !== null) {
|
|
75
|
+
conditions.push(eq(todosTable.roomId, filter.roomId));
|
|
76
|
+
}
|
|
77
|
+
if (filter.status) {
|
|
78
|
+
const statuses = Array.isArray(filter.status) ? filter.status : [filter.status];
|
|
79
|
+
conditions.push(inArray(todosTable.status, statuses));
|
|
80
|
+
} else if (filter.includeCompleted === false) {
|
|
81
|
+
conditions.push(
|
|
82
|
+
inArray(todosTable.status, ["pending", "in_progress"])
|
|
83
|
+
);
|
|
84
|
+
}
|
|
85
|
+
const query = db.select().from(todosTable).where(and(...conditions)).orderBy(desc(todosTable.updatedAt));
|
|
86
|
+
const rows = filter.limit ? await query.limit(filter.limit) : await query;
|
|
87
|
+
return rows.map(rowToTodo);
|
|
88
|
+
}
|
|
89
|
+
async update(id, patch) {
|
|
90
|
+
const db = this.getDb();
|
|
91
|
+
const set = { updatedAt: /* @__PURE__ */ new Date() };
|
|
92
|
+
if (patch.content !== void 0) set.content = patch.content;
|
|
93
|
+
if (patch.activeForm !== void 0) set.activeForm = patch.activeForm;
|
|
94
|
+
if (patch.status !== void 0) {
|
|
95
|
+
set.status = patch.status;
|
|
96
|
+
set.completedAt = patch.status === "completed" ? /* @__PURE__ */ new Date() : null;
|
|
97
|
+
}
|
|
98
|
+
if (patch.parentTodoId !== void 0) set.parentTodoId = patch.parentTodoId;
|
|
99
|
+
if (patch.metadata !== void 0) set.metadata = patch.metadata;
|
|
100
|
+
const [row] = await db.update(todosTable).set(set).where(eq(todosTable.id, id)).returning();
|
|
101
|
+
return row ? rowToTodo(row) : null;
|
|
102
|
+
}
|
|
103
|
+
async delete(id) {
|
|
104
|
+
const db = this.getDb();
|
|
105
|
+
const rows = await db.delete(todosTable).where(eq(todosTable.id, id)).returning({ id: todosTable.id });
|
|
106
|
+
return rows.length > 0;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Bulk-replace the user's todo list for a given (entityId, roomId) scope.
|
|
110
|
+
* Mirrors Claude Code's TodoWrite contract: the caller passes the full
|
|
111
|
+
* desired list, and the store reconciles. Existing rows are matched by id;
|
|
112
|
+
* absent rows are deleted; new rows are inserted.
|
|
113
|
+
*/
|
|
114
|
+
async writeList(args) {
|
|
115
|
+
const db = this.getDb();
|
|
116
|
+
const filter = {
|
|
117
|
+
entityId: args.entityId,
|
|
118
|
+
agentId: args.agentId
|
|
119
|
+
};
|
|
120
|
+
if (args.roomId !== null) {
|
|
121
|
+
filter.roomId = args.roomId;
|
|
122
|
+
}
|
|
123
|
+
const before = await this.list(filter);
|
|
124
|
+
const beforeById = new Map(before.map((t) => [t.id, t]));
|
|
125
|
+
const keepIds = /* @__PURE__ */ new Set();
|
|
126
|
+
const after = [];
|
|
127
|
+
for (const item of args.todos) {
|
|
128
|
+
const existing = item.id ? beforeById.get(item.id) : void 0;
|
|
129
|
+
if (existing) {
|
|
130
|
+
keepIds.add(existing.id);
|
|
131
|
+
const needsUpdate = existing.content !== item.content || existing.status !== item.status || existing.activeForm !== (item.activeForm ?? item.content);
|
|
132
|
+
if (needsUpdate) {
|
|
133
|
+
const updated = await this.update(existing.id, {
|
|
134
|
+
content: item.content,
|
|
135
|
+
activeForm: item.activeForm ?? item.content,
|
|
136
|
+
status: item.status
|
|
137
|
+
});
|
|
138
|
+
if (updated) after.push(updated);
|
|
139
|
+
} else {
|
|
140
|
+
after.push(existing);
|
|
141
|
+
}
|
|
142
|
+
} else {
|
|
143
|
+
const created = await this.create({
|
|
144
|
+
entityId: args.entityId,
|
|
145
|
+
agentId: args.agentId,
|
|
146
|
+
roomId: args.roomId,
|
|
147
|
+
worldId: args.worldId,
|
|
148
|
+
content: item.content,
|
|
149
|
+
activeForm: item.activeForm ?? item.content,
|
|
150
|
+
status: item.status,
|
|
151
|
+
parentTrajectoryStepId: args.parentTrajectoryStepId
|
|
152
|
+
});
|
|
153
|
+
keepIds.add(created.id);
|
|
154
|
+
after.push(created);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
const toDelete = before.filter((t) => !keepIds.has(t.id)).map((t) => t.id);
|
|
158
|
+
if (toDelete.length > 0) {
|
|
159
|
+
await db.delete(todosTable).where(inArray(todosTable.id, toDelete));
|
|
160
|
+
}
|
|
161
|
+
return { before, after };
|
|
162
|
+
}
|
|
163
|
+
async clear(filter) {
|
|
164
|
+
const db = this.getDb();
|
|
165
|
+
const conditions = [eq(todosTable.entityId, filter.entityId)];
|
|
166
|
+
if (filter.agentId) {
|
|
167
|
+
conditions.push(eq(todosTable.agentId, filter.agentId));
|
|
168
|
+
}
|
|
169
|
+
if (filter.roomId) {
|
|
170
|
+
conditions.push(eq(todosTable.roomId, filter.roomId));
|
|
171
|
+
}
|
|
172
|
+
const rows = await db.delete(todosTable).where(and(...conditions)).returning({ id: todosTable.id });
|
|
173
|
+
return rows.length;
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
function getTodosService(runtime) {
|
|
177
|
+
const service = runtime.getService(TODOS_SERVICE_TYPE);
|
|
178
|
+
if (!service) {
|
|
179
|
+
throw new Error(
|
|
180
|
+
`${TODOS_LOG_PREFIX} TodosService is not registered \u2014 ensure @elizaos/plugin-todos is enabled.`
|
|
181
|
+
);
|
|
182
|
+
}
|
|
183
|
+
return service;
|
|
184
|
+
}
|
|
185
|
+
export {
|
|
186
|
+
TodosService,
|
|
187
|
+
getTodosService
|
|
188
|
+
};
|
|
189
|
+
//# sourceMappingURL=service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/service.ts"],"sourcesContent":["import { type IAgentRuntime, logger, Service, type UUID } from \"@elizaos/core\";\nimport { and, desc, eq, inArray } from \"drizzle-orm\";\nimport type { NodePgDatabase } from \"drizzle-orm/node-postgres\";\n\nimport { type TodoRow, todosTable } from \"./db/schema.js\";\nimport {\n TODOS_LOG_PREFIX,\n TODOS_SERVICE_TYPE,\n type Todo,\n type TodoStatus,\n} from \"./types.js\";\n\nexport interface TodoFilter {\n entityId: string;\n agentId?: string;\n roomId?: string | null;\n status?: TodoStatus | TodoStatus[];\n includeCompleted?: boolean;\n limit?: number;\n}\n\nexport interface CreateTodoInput {\n entityId: string;\n agentId: string;\n roomId?: string | null;\n worldId?: string | null;\n content: string;\n activeForm?: string;\n status?: TodoStatus;\n parentTodoId?: string | null;\n parentTrajectoryStepId?: string | null;\n metadata?: Record<string, unknown>;\n}\n\nexport interface UpdateTodoInput {\n content?: string;\n activeForm?: string;\n status?: TodoStatus;\n parentTodoId?: string | null;\n metadata?: Record<string, unknown>;\n}\n\nfunction rowToTodo(row: TodoRow): Todo {\n const metadata =\n row.metadata &&\n typeof row.metadata === \"object\" &&\n !Array.isArray(row.metadata)\n ? (row.metadata as Record<string, unknown>)\n : {};\n return {\n id: row.id,\n entityId: row.entityId,\n agentId: row.agentId,\n roomId: row.roomId ?? null,\n worldId: row.worldId ?? null,\n content: row.content,\n activeForm: row.activeForm,\n status: row.status as TodoStatus,\n parentTodoId: row.parentTodoId ?? null,\n parentTrajectoryStepId: row.parentTrajectoryStepId ?? null,\n metadata,\n createdAt: row.createdAt,\n updatedAt: row.updatedAt,\n completedAt: row.completedAt ?? null,\n };\n}\n\nexport class TodosService extends Service {\n static override readonly serviceType = TODOS_SERVICE_TYPE;\n\n override capabilityDescription =\n \"User-scoped todo CRUD. Persistent (drizzle/postgres), keyed by (agentId, entityId).\";\n\n private getDb(): NodePgDatabase {\n const db = this.runtime.db as NodePgDatabase | undefined;\n if (!db) {\n throw new Error(\n `${TODOS_LOG_PREFIX} runtime.db is not available — @elizaos/plugin-sql must be installed and initialized.`,\n );\n }\n return db;\n }\n\n static async start(runtime: IAgentRuntime): Promise<TodosService> {\n logger.info(`${TODOS_LOG_PREFIX} starting TodosService`);\n return new TodosService(runtime);\n }\n\n override async stop(): Promise<void> {\n logger.info(`${TODOS_LOG_PREFIX} stopping TodosService`);\n }\n\n async create(input: CreateTodoInput): Promise<Todo> {\n const db = this.getDb();\n const [row] = await db\n .insert(todosTable)\n .values({\n agentId: input.agentId as UUID,\n entityId: input.entityId as UUID,\n roomId: (input.roomId ?? null) as UUID | null,\n worldId: (input.worldId ?? null) as UUID | null,\n content: input.content,\n activeForm: input.activeForm ?? input.content,\n status: input.status ?? \"pending\",\n parentTodoId: (input.parentTodoId ?? null) as UUID | null,\n parentTrajectoryStepId: input.parentTrajectoryStepId ?? null,\n metadata: input.metadata ?? {},\n })\n .returning();\n if (!row) throw new Error(`${TODOS_LOG_PREFIX} insert returned no row`);\n return rowToTodo(row);\n }\n\n async get(id: string): Promise<Todo | null> {\n const db = this.getDb();\n const [row] = await db\n .select()\n .from(todosTable)\n .where(eq(todosTable.id, id as UUID))\n .limit(1);\n return row ? rowToTodo(row) : null;\n }\n\n async list(filter: TodoFilter): Promise<Todo[]> {\n const db = this.getDb();\n const conditions = [eq(todosTable.entityId, filter.entityId as UUID)];\n if (filter.agentId) {\n conditions.push(eq(todosTable.agentId, filter.agentId as UUID));\n }\n if (filter.roomId !== undefined && filter.roomId !== null) {\n conditions.push(eq(todosTable.roomId, filter.roomId as UUID));\n }\n if (filter.status) {\n const statuses = Array.isArray(filter.status)\n ? filter.status\n : [filter.status];\n conditions.push(inArray(todosTable.status, statuses));\n } else if (filter.includeCompleted === false) {\n conditions.push(\n inArray(todosTable.status, [\"pending\", \"in_progress\"] as TodoStatus[]),\n );\n }\n const query = db\n .select()\n .from(todosTable)\n .where(and(...conditions))\n .orderBy(desc(todosTable.updatedAt));\n const rows = filter.limit ? await query.limit(filter.limit) : await query;\n return rows.map(rowToTodo);\n }\n\n async update(id: string, patch: UpdateTodoInput): Promise<Todo | null> {\n const db = this.getDb();\n const set: Record<string, unknown> = { updatedAt: new Date() };\n if (patch.content !== undefined) set.content = patch.content;\n if (patch.activeForm !== undefined) set.activeForm = patch.activeForm;\n if (patch.status !== undefined) {\n set.status = patch.status;\n set.completedAt = patch.status === \"completed\" ? new Date() : null;\n }\n if (patch.parentTodoId !== undefined) set.parentTodoId = patch.parentTodoId;\n if (patch.metadata !== undefined) set.metadata = patch.metadata;\n const [row] = await db\n .update(todosTable)\n .set(set)\n .where(eq(todosTable.id, id as UUID))\n .returning();\n return row ? rowToTodo(row) : null;\n }\n\n async delete(id: string): Promise<boolean> {\n const db = this.getDb();\n const rows = await db\n .delete(todosTable)\n .where(eq(todosTable.id, id as UUID))\n .returning({ id: todosTable.id });\n return rows.length > 0;\n }\n\n /**\n * Bulk-replace the user's todo list for a given (entityId, roomId) scope.\n * Mirrors Claude Code's TodoWrite contract: the caller passes the full\n * desired list, and the store reconciles. Existing rows are matched by id;\n * absent rows are deleted; new rows are inserted.\n */\n async writeList(args: {\n entityId: string;\n agentId: string;\n roomId: string | null;\n worldId: string | null;\n parentTrajectoryStepId: string | null;\n todos: Array<{\n id?: string;\n content: string;\n status: TodoStatus;\n activeForm?: string;\n }>;\n }): Promise<{ before: Todo[]; after: Todo[] }> {\n const db = this.getDb();\n const filter: TodoFilter = {\n entityId: args.entityId,\n agentId: args.agentId,\n };\n if (args.roomId !== null) {\n filter.roomId = args.roomId;\n }\n const before = await this.list(filter);\n const beforeById = new Map(before.map((t) => [t.id, t]));\n\n const keepIds = new Set<string>();\n const after: Todo[] = [];\n for (const item of args.todos) {\n const existing = item.id ? beforeById.get(item.id) : undefined;\n if (existing) {\n keepIds.add(existing.id);\n const needsUpdate =\n existing.content !== item.content ||\n existing.status !== item.status ||\n existing.activeForm !== (item.activeForm ?? item.content);\n if (needsUpdate) {\n const updated = await this.update(existing.id, {\n content: item.content,\n activeForm: item.activeForm ?? item.content,\n status: item.status,\n });\n if (updated) after.push(updated);\n } else {\n after.push(existing);\n }\n } else {\n const created = await this.create({\n entityId: args.entityId,\n agentId: args.agentId,\n roomId: args.roomId,\n worldId: args.worldId,\n content: item.content,\n activeForm: item.activeForm ?? item.content,\n status: item.status,\n parentTrajectoryStepId: args.parentTrajectoryStepId,\n });\n keepIds.add(created.id);\n after.push(created);\n }\n }\n\n const toDelete = before\n .filter((t) => !keepIds.has(t.id))\n .map((t) => t.id as UUID);\n if (toDelete.length > 0) {\n await db.delete(todosTable).where(inArray(todosTable.id, toDelete));\n }\n\n return { before, after };\n }\n\n async clear(filter: {\n entityId: string;\n agentId?: string;\n roomId?: string | null;\n }): Promise<number> {\n const db = this.getDb();\n const conditions = [eq(todosTable.entityId, filter.entityId as UUID)];\n if (filter.agentId) {\n conditions.push(eq(todosTable.agentId, filter.agentId as UUID));\n }\n if (filter.roomId) {\n conditions.push(eq(todosTable.roomId, filter.roomId as UUID));\n }\n const rows = await db\n .delete(todosTable)\n .where(and(...conditions))\n .returning({ id: todosTable.id });\n return rows.length;\n }\n}\n\nexport function getTodosService(runtime: IAgentRuntime): TodosService {\n const service = runtime.getService<TodosService>(TODOS_SERVICE_TYPE);\n if (!service) {\n throw new Error(\n `${TODOS_LOG_PREFIX} TodosService is not registered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,MAAM,CAAC,QAAQ,IAAI,EAAE,EAAE,CAAC,EAChC,IAAI,CAAC,MAAM,EAAE,EAAU;AAC1B,QAAI,SAAS,SAAS,GAAG;AACvB,YAAM,GAAG,OAAO,UAAU,EAAE,MAAM,QAAQ,WAAW,IAAI,QAAQ,CAAC;AAAA,IACpE;AAEA,WAAO,EAAE,QAAQ,MAAM;AAAA,EACzB;AAAA,EAEA,MAAM,MAAM,QAIQ;AAClB,UAAM,KAAK,KAAK,MAAM;AACtB,UAAM,aAAa,CAAC,GAAG,WAAW,UAAU,OAAO,QAAgB,CAAC;AACpE,QAAI,OAAO,SAAS;AAClB,iBAAW,KAAK,GAAG,WAAW,SAAS,OAAO,OAAe,CAAC;AAAA,IAChE;AACA,QAAI,OAAO,QAAQ;AACjB,iBAAW,KAAK,GAAG,WAAW,QAAQ,OAAO,MAAc,CAAC;AAAA,IAC9D;AACA,UAAM,OAAO,MAAM,GAChB,OAAO,UAAU,EACjB,MAAM,IAAI,GAAG,UAAU,CAAC,EACxB,UAAU,EAAE,IAAI,WAAW,GAAG,CAAC;AAClC,WAAO,KAAK;AAAA,EACd;AACF;AAEO,SAAS,gBAAgB,SAAsC;AACpE,QAAM,UAAU,QAAQ,WAAyB,kBAAkB;AACnE,MAAI,CAAC,SAAS;AACZ,UAAM,IAAI;AAAA,MACR,GAAG,gBAAgB;AAAA,IACrB;AAAA,EACF;AACA,SAAO;AACT;","names":[]}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
export declare const TODOS_LOG_PREFIX = "[Todos]";
|
|
2
|
+
export declare const TODOS_SERVICE_TYPE = "todos";
|
|
3
|
+
export declare const TODO_STATUSES: readonly ["pending", "in_progress", "completed", "cancelled"];
|
|
4
|
+
export type TodoStatus = (typeof TODO_STATUSES)[number];
|
|
5
|
+
export declare const TODO_ACTIONS: readonly ["write", "create", "update", "complete", "cancel", "delete", "list", "clear"];
|
|
6
|
+
export type TodoActionName = (typeof TODO_ACTIONS)[number];
|
|
7
|
+
export declare const TODO_OPS: readonly ["write", "create", "update", "complete", "cancel", "delete", "list", "clear"];
|
|
8
|
+
export type TodoOp = TodoActionName;
|
|
9
|
+
export interface Todo {
|
|
10
|
+
id: string;
|
|
11
|
+
entityId: string;
|
|
12
|
+
agentId: string;
|
|
13
|
+
roomId: string | null;
|
|
14
|
+
worldId: string | null;
|
|
15
|
+
content: string;
|
|
16
|
+
activeForm: string;
|
|
17
|
+
status: TodoStatus;
|
|
18
|
+
parentTodoId: string | null;
|
|
19
|
+
parentTrajectoryStepId: string | null;
|
|
20
|
+
metadata: Record<string, unknown>;
|
|
21
|
+
createdAt: Date;
|
|
22
|
+
updatedAt: Date;
|
|
23
|
+
completedAt: Date | null;
|
|
24
|
+
}
|
|
25
|
+
export interface TodoInput {
|
|
26
|
+
id?: string;
|
|
27
|
+
content: string;
|
|
28
|
+
status: TodoStatus;
|
|
29
|
+
activeForm?: string;
|
|
30
|
+
parentTodoId?: string | null;
|
|
31
|
+
}
|
|
32
|
+
export declare const TODOS_CONTEXTS: readonly ["tasks", "todos", "automation"];
|
|
33
|
+
export type TodosContext = (typeof TODOS_CONTEXTS)[number];
|
|
34
|
+
export declare const TODO_FAILURE_TEXT_PREFIX = "[Todos]";
|
|
35
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,gBAAgB,YAAY,CAAC;AAC1C,eAAO,MAAM,kBAAkB,UAAU,CAAC;AAE1C,eAAO,MAAM,aAAa,+DAKhB,CAAC;AACX,MAAM,MAAM,UAAU,GAAG,CAAC,OAAO,aAAa,CAAC,CAAC,MAAM,CAAC,CAAC;AAExD,eAAO,MAAM,YAAY,yFASf,CAAC;AACX,MAAM,MAAM,cAAc,GAAG,CAAC,OAAO,YAAY,CAAC,CAAC,MAAM,CAAC,CAAC;AAC3D,eAAO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