cortico-world-memory-core 0.4.4 → 0.12.1

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/src/tools.ts CHANGED
@@ -1,114 +1,88 @@
1
- /**
2
- * 四个工具的声明(只给模型看的 schema)。handler 在 world.ts 里按名字分发。
3
- * 压缩 token 的地方在这里:四个工具覆盖写、查、状态、日程,description 一律短句。
4
- */
5
- import type { ToolSpec } from 'cortico/core/types.ts';
6
-
7
- const obj = (properties: Record<string, unknown>, required: string[]): Record<string, unknown> => ({
8
- type: 'object',
9
- additionalProperties: false,
10
- properties,
11
- required,
12
- });
13
-
14
- export const TOOL_SPECS: ToolSpec[] = [
15
- {
16
- name: 'mcore_write',
17
- description:
18
- '写一条记忆。kind:fact=关于对方的事实,self=关于你自己的,episode=会改变你怎么看她的一件事(别记流水账),'
19
- + 'promise=答应过的事(必须写 dueAt),note=过几天就没用的临时信息。能写成 fact 就别写成 episode。'
20
- + '一条只写一件事,40-80 字,写具体。同一件事不要重复写;把旧记录传进 closes 表示它已完成或作废。',
21
- parameters: obj(
22
- {
23
- kind: {
24
- type: 'string',
25
- enum: ['fact', 'self', 'episode', 'promise', 'note'],
26
- description: '记忆类型',
27
- },
28
- text: { type: 'string', description: '这条记忆的内容,40-80 字' },
29
- weight: {
30
- type: 'number',
31
- minimum: 0,
32
- maximum: 1,
33
- description: '在心里有多重:0.3 琐事 / 0.5 一般 / 0.8 重要。默认 0.5',
34
- },
35
- tags: { type: 'array', items: { type: 'string' }, description: '关键词,最多 6 个' },
36
- dueAt: {
37
- type: 'string',
38
- description: '仅 promise 用:什么时候该做,ISO 或 YYYY-MM-DD HH:MM;确实没有截止时间就写 none',
39
- },
40
- closes: { type: 'string', description: '要关掉的旧记录 id(已完成/已失效)' },
41
- },
42
- ['kind', 'text'],
43
- ),
44
- tags: ['write'],
45
- },
46
- {
47
- name: 'mcore_recall',
48
- description:
49
- '查记忆。不传 query 就是最近几条;传 query 按内容搜,最近 7 天的对话原文和工作区的笔记文件也会一起搜;'
50
- + 'mode=open 看还没做完的承诺与今天的安排;mode=archive 翻归档里的旧对话(要带 query)。'
51
- + '对方提到人、事、日期、旧约定,或问「你还记得吗」时先查再答。',
52
- parameters: obj(
53
- {
54
- query: { type: 'string', description: '要查的内容,几个关键词就够' },
55
- kind: { type: 'string', enum: ['fact', 'self', 'episode', 'promise', 'note'], description: '只看某一类' },
56
- mode: {
57
- type: 'string',
58
- enum: ['search', 'recent', 'open', 'archive'],
59
- description: '默认 search;没给 query 按 recent 处理',
60
- },
61
- days: { type: 'integer', minimum: 1, maximum: 3650, description: '只看最近这么多天' },
62
- limit: { type: 'integer', minimum: 1, maximum: 12, description: '最多几条,默认 5' },
63
- },
64
- [],
65
- ),
66
- tags: ['read'],
67
- },
68
- {
69
- name: 'mcore_state',
70
- description:
71
- '你自己的状态:精力、心情、正在做什么、在哪、睡没睡。action=get 读取;update 只改传入的字段;'
72
- + 'rest 去睡一会儿。这是你自己的,不要念成清单给对方听。',
73
- parameters: obj(
74
- {
75
- action: { type: 'string', enum: ['get', 'update', 'rest'], description: 'get 读,update 改,rest 睡' },
76
- energy: { type: 'number', minimum: 0, maximum: 100, description: '精力 0-100' },
77
- mood: { type: 'number', minimum: 0, maximum: 100, description: '心情 0-100' },
78
- activity: { type: 'string', description: '正在做什么,例如「翻旧照片」' },
79
- location: { type: 'string', description: '在哪,例如「窗台」' },
80
- sleeping: { type: 'boolean', description: '是否在睡' },
81
- },
82
- ['action'],
83
- ),
84
- tags: ['read', 'write', 'snapshot'],
85
- },
86
- {
87
- name: 'mcore_plan',
88
- description:
89
- '你今天的安排。action=list 看;add 加一条(time 用 HH:MM,title 写做什么,place 可省);'
90
- + 'done 标完成(传 id);clear 清空。日程是你开口的由头,不用讲给对方听。',
91
- parameters: obj(
92
- {
93
- action: { type: 'string', enum: ['list', 'add', 'done', 'clear'] },
94
- items: {
95
- type: 'array',
96
- description: 'add 用第一项',
97
- items: {
98
- type: 'object',
99
- additionalProperties: false,
100
- properties: {
101
- time: { type: 'string', description: 'HH:MM' },
102
- title: { type: 'string', description: '做什么' },
103
- place: { type: 'string', description: '在哪,可省略' },
104
- },
105
- required: ['time', 'title'],
106
- },
107
- },
108
- id: { type: 'string', description: 'done 用的日程 id' },
109
- },
110
- ['action'],
111
- ),
112
- tags: ['read', 'write'],
113
- },
114
- ];
1
+ /**
2
+ * 四个工具的声明(只给模型看的 schema)。handler 在 world.ts 里按名字分发。
3
+ *
4
+ * 这里的每一个字都要每一轮付一次钱,所以只留「模型必须知道才用得对」的东西:
5
+ * 参数含义、枚举值、边界。写法和分寸放在 ENV_PROMPT 里,两边不重复。
6
+ */
7
+ import type { ToolSpec } from 'cortico/core/types.ts';
8
+
9
+ const obj = (properties: Record<string, unknown>, required: string[]): Record<string, unknown> => ({
10
+ type: 'object',
11
+ additionalProperties: false,
12
+ properties,
13
+ required,
14
+ });
15
+
16
+ export const TOOL_SPECS: ToolSpec[] = [
17
+ {
18
+ name: 'mcore_write',
19
+ description:
20
+ '写一条记忆。kind:fact=关于对方的事实,self=关于你自己的,episode=会改变你判断的一件事(别记流水账),'
21
+ + 'promise=答应过的事(必须写 dueAt),note=临时信息。一条只写一件事,40-80 字。旧记录用 closes 关掉。',
22
+ parameters: obj(
23
+ {
24
+ kind: {
25
+ type: 'string',
26
+ enum: ['fact', 'self', 'episode', 'promise', 'note'],
27
+ description: '记忆类型',
28
+ },
29
+ text: { type: 'string', description: '内容,40-80 字' },
30
+ weight: { type: 'number', description: '0-1,0.3 琐事 / 0.8 重要' },
31
+ tags: { type: 'array', items: { type: 'string' }, description: '最多 6 个' },
32
+ dueAt: { type: 'string', description: 'promise 用:ISO 或 YYYY-MM-DD HH:MM;没有截止时间写 none' },
33
+ closes: { type: 'string', description: '要关掉的旧 id' },
34
+ },
35
+ ['kind', 'text'],
36
+ ),
37
+ tags: ['write'],
38
+ },
39
+ {
40
+ name: 'mcore_recall',
41
+ description:
42
+ '查记忆。给 query 按内容搜(同时搜最近 7 天原文和工作区笔记),不给就看最近几条;'
43
+ + 'mode=open 看没做完的承诺和今天的安排,mode=archive 翻归档(要 query)。'
44
+ + '对方提到人或旧事、问「你还记得吗」时先查再答。',
45
+ parameters: obj(
46
+ {
47
+ query: { type: 'string', description: '关键词就够' },
48
+ kind: { type: 'string', enum: ['fact', 'self', 'episode', 'promise', 'note'], description: '只看某一类' },
49
+ mode: { type: 'string', enum: ['search', 'recent', 'open', 'archive'], description: '默认 search' },
50
+ days: { type: 'integer', description: '只看最近这么多天' },
51
+ limit: { type: 'integer', description: '最多几条,默认 5' },
52
+ },
53
+ [],
54
+ ),
55
+ tags: ['read'],
56
+ },
57
+ {
58
+ name: 'mcore_state',
59
+ description: '你自己的状态:精力、心情、在做什么、在哪、睡没睡。这是你自己的,不要念成清单给对方听。',
60
+ parameters: obj(
61
+ {
62
+ action: { type: 'string', enum: ['get', 'update', 'rest'], description: 'get 读 / update 改 / rest 睡' },
63
+ energy: { type: 'number', description: '精力 0-100' },
64
+ mood: { type: 'number', description: '心情 0-100' },
65
+ activity: { type: 'string', description: '正在做什么' },
66
+ location: { type: 'string', description: '在哪' },
67
+ sleeping: { type: 'boolean', description: '在睡' },
68
+ },
69
+ ['action'],
70
+ ),
71
+ tags: ['read', 'write', 'snapshot'],
72
+ },
73
+ {
74
+ name: 'mcore_plan',
75
+ description: '你今天的安排。日程是你开口的由头,不用讲给对方听。',
76
+ parameters: obj(
77
+ {
78
+ action: { type: 'string', enum: ['list', 'add', 'done', 'clear'], description: 'list 看 / add 加 / done 完成 / clear 清空' },
79
+ time: { type: 'string', description: 'add 用,HH:MM' },
80
+ title: { type: 'string', description: 'add 用,做什么' },
81
+ place: { type: 'string', description: 'add 用,在哪(可省)' },
82
+ id: { type: 'string', description: 'done 用,日程 id' },
83
+ },
84
+ ['action'],
85
+ ),
86
+ tags: ['read', 'write'],
87
+ },
88
+ ];