@jungjaehoon/mama-os 0.59.1 → 0.60.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/CHANGELOG.md +39 -1
- package/README.md +1 -1
- package/dist/api/code-act-actions.d.ts +12 -2
- package/dist/api/code-act-actions.d.ts.map +1 -1
- package/dist/api/code-act-actions.js +82 -18
- package/dist/api/code-act-actions.js.map +1 -1
- package/dist/api/owner-message-actions.d.ts +21 -0
- package/dist/api/owner-message-actions.d.ts.map +1 -0
- package/dist/api/owner-message-actions.js +100 -0
- package/dist/api/owner-message-actions.js.map +1 -0
- package/dist/api/viewer-server.d.ts.map +1 -1
- package/dist/api/viewer-server.js +1 -14
- package/dist/api/viewer-server.js.map +1 -1
- package/dist/api/wiki-actions.d.ts.map +1 -1
- package/dist/api/wiki-actions.js +5 -3
- package/dist/api/wiki-actions.js.map +1 -1
- package/dist/api/work-actions.d.ts +13 -4
- package/dist/api/work-actions.d.ts.map +1 -1
- package/dist/api/work-actions.js +293 -8
- package/dist/api/work-actions.js.map +1 -1
- package/dist/cli/commands/daemon.d.ts.map +1 -1
- package/dist/cli/commands/daemon.js +10 -0
- package/dist/cli/commands/daemon.js.map +1 -1
- package/dist/operator/board-slot-instructions.d.ts.map +1 -1
- package/dist/operator/board-slot-instructions.js +1 -2
- package/dist/operator/board-slot-instructions.js.map +1 -1
- package/dist/runtime/action-surface.d.ts +4 -1
- package/dist/runtime/action-surface.d.ts.map +1 -1
- package/dist/runtime/action-surface.js +6 -0
- package/dist/runtime/action-surface.js.map +1 -1
- package/dist/runtime/config.d.ts +2 -0
- package/dist/runtime/config.d.ts.map +1 -1
- package/dist/runtime/config.js +2 -1
- package/dist/runtime/config.js.map +1 -1
- package/dist/runtime/owner-runtime.d.ts.map +1 -1
- package/dist/runtime/owner-runtime.js +10 -1
- package/dist/runtime/owner-runtime.js.map +1 -1
- package/dist/runtime/owner-system-prompt.d.ts.map +1 -1
- package/dist/runtime/owner-system-prompt.js +31 -5
- package/dist/runtime/owner-system-prompt.js.map +1 -1
- package/dist/runtime/report-scheduler.d.ts +8 -1
- package/dist/runtime/report-scheduler.d.ts.map +1 -1
- package/dist/runtime/report-scheduler.js +48 -17
- package/dist/runtime/report-scheduler.js.map +1 -1
- package/dist/runtime/session-start-context.d.ts +12 -0
- package/dist/runtime/session-start-context.d.ts.map +1 -1
- package/dist/runtime/session-start-context.js +22 -0
- package/dist/runtime/session-start-context.js.map +1 -1
- package/dist/runtime/turn-orders.d.ts +3 -1
- package/dist/runtime/turn-orders.d.ts.map +1 -1
- package/dist/runtime/turn-orders.js +19 -5
- package/dist/runtime/turn-orders.js.map +1 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -5,7 +5,45 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
-
## [
|
|
8
|
+
## [0.60.1] - 2026-09-30
|
|
9
|
+
|
|
10
|
+
### Changed
|
|
11
|
+
|
|
12
|
+
- `code_act`: plain data a script leaves on `globalThis` is handed to the same model run's next
|
|
13
|
+
script, also after the script threw, and the result lists it in `kept`. A full report that
|
|
14
|
+
failed on one row was written again from the start, up to four times in one turn; now the
|
|
15
|
+
failed part is fixed and the rest is kept. The worker still lives for one call only.
|
|
16
|
+
- `report.publish`: the contract no longer asks for slots under 6 KB (the host accepts 512 KB).
|
|
17
|
+
The model measured every slot against it, and one report failed on `TextEncoder`, which the
|
|
18
|
+
sandbox lacks, and was written again. The line repeating what the pipeline is was removed.
|
|
19
|
+
The full-report procedure says to keep each built section on `globalThis` and fix the part
|
|
20
|
+
that failed.
|
|
21
|
+
|
|
22
|
+
### Fixed
|
|
23
|
+
|
|
24
|
+
- `code_act`: a single line of several statements ran only its first one, because any line not
|
|
25
|
+
starting with a keyword was returned as one expression. Code is returned only when it parses
|
|
26
|
+
as one expression.
|
|
27
|
+
|
|
28
|
+
## [0.60.0] - 2026-09-30
|
|
29
|
+
|
|
30
|
+
### Added
|
|
31
|
+
|
|
32
|
+
- `work.link`: link a work item to another item, a record, a person, an observation, or a link it
|
|
33
|
+
corrects, with the reason the agent judged. It writes no revision, so the item does not count
|
|
34
|
+
as changed.
|
|
35
|
+
- `work.list` view `links`: every link from or to any revision of an item, with its reason,
|
|
36
|
+
writer, evidence, correction and the other end's title and status.
|
|
37
|
+
- Help topic `cases`, indexed by the question (did something like this happen before, how did it
|
|
38
|
+
end): read the item's links first, search on the kind of problem when there are none, and link
|
|
39
|
+
a confirmed earlier case with its reason.
|
|
40
|
+
|
|
41
|
+
### Changed
|
|
42
|
+
|
|
43
|
+
- Turn lessons rank on the turn's own text and do not take records a search reached through a
|
|
44
|
+
link (`includeRelated: false`).
|
|
45
|
+
- The viewer graph draws stored edges only; revisions of one item are no longer joined by a host
|
|
46
|
+
edge, and the viewer's "Earlier records" block, which read no edges, is removed.
|
|
9
47
|
|
|
10
48
|
## [0.58.1] - 2026-09-29
|
|
11
49
|
|
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@ One owner agent on Claude or Codex watches connected work, keeps task revisions
|
|
|
4
4
|
answers on Telegram, publishes reports and a board, and recalls corrections.
|
|
5
5
|
[mama-core](../mama-core/README.md) supplies the shared engine.
|
|
6
6
|
|
|
7
|
-
Current manifest: **0.
|
|
7
|
+
Current manifest: **0.60.1**. This README describes the unreleased `rebuild/owner-flow` source.
|
|
8
8
|
Use [owner setup](../../docs/start/owner-setup.md) with Node.js 22.13+ and pnpm.
|
|
9
9
|
|
|
10
10
|
## Start and operate
|
|
@@ -16,13 +16,23 @@ export interface CodeActResult {
|
|
|
16
16
|
logs: string[];
|
|
17
17
|
hostCallCount: number;
|
|
18
18
|
durationMs: number;
|
|
19
|
+
/** The names of the values the code left on globalThis for the run's next code_act. */
|
|
20
|
+
kept?: string[];
|
|
19
21
|
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
+
type CarriedValues = Record<string, unknown>;
|
|
23
|
+
/**
|
|
24
|
+
* Run the code in a fresh worker process; host calls are answered by `host.call`. `carried` is
|
|
25
|
+
* what the run's earlier scripts left on globalThis; the result's `carried` is what this one
|
|
26
|
+
* leaves. A worker that dies or times out leaves what it was given.
|
|
27
|
+
*/
|
|
28
|
+
export declare function runCodeAct(code: string, host: CodeActHost, timeoutMs?: number, carried?: CarriedValues): Promise<CodeActResult & {
|
|
29
|
+
carried: CarriedValues;
|
|
30
|
+
}>;
|
|
22
31
|
export declare const CODE_ACT_CONTRACT: ActionContract;
|
|
23
32
|
/**
|
|
24
33
|
* The code_act action over a dispatcher built after it: the functions are the actions the
|
|
25
34
|
* caller is granted, and each call is dispatched with the caller's own context.
|
|
26
35
|
*/
|
|
27
36
|
export declare function codeActRegistration(dispatcher: () => ActionDispatcher): ActionRegistration;
|
|
37
|
+
export {};
|
|
28
38
|
//# sourceMappingURL=code-act-actions.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"code-act-actions.d.ts","sourceRoot":"","sources":["../../src/api/code-act-actions.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"code-act-actions.d.ts","sourceRoot":"","sources":["../../src/api/code-act-actions.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAEV,cAAc,EACd,gBAAgB,EAChB,kBAAkB,EACnB,MAAM,wBAAwB,CAAC;AAqFhC,MAAM,WAAW,WAAW;IAC1B,4DAA4D;IAC5D,SAAS,EAAE,SAAS;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;IACvC,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;CACtD;AAED,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,KAAK,CAAC,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC;IAC1C,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,aAAa,EAAE,MAAM,CAAC;IACtB,UAAU,EAAE,MAAM,CAAC;IACnB,uFAAuF;IACvF,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;CACjB;AAED,KAAK,aAAa,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAK7C;;;;GAIG;AACH,wBAAgB,UAAU,CACxB,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,WAAW,EACjB,SAAS,SAAqB,EAC9B,OAAO,GAAE,aAAkB,GAC1B,OAAO,CAAC,aAAa,GAAG;IAAE,OAAO,EAAE,aAAa,CAAA;CAAE,CAAC,CA4GrD;AAED,eAAO,MAAM,iBAAiB,EAAE,cAiB/B,CAAC;AAEF;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,UAAU,EAAE,MAAM,gBAAgB,GAAG,kBAAkB,CA+D1F"}
|
|
@@ -12,6 +12,9 @@ exports.codeActRegistration = codeActRegistration;
|
|
|
12
12
|
* with the calling turn's own context, so the grant, session and traces are the caller's.
|
|
13
13
|
* The worker runs under Node's permission model: `vm` gives the code a clean namespace but
|
|
14
14
|
* is not a boundary, and an escaped script must reach no files, processes or network.
|
|
15
|
+
* The process does not outlive the call: what a script leaves on globalThis goes back to the
|
|
16
|
+
* host as data and is handed to the same model run's next script, so a failed step is fixed
|
|
17
|
+
* in place instead of being written again.
|
|
15
18
|
*/
|
|
16
19
|
const node_child_process_1 = require("node:child_process");
|
|
17
20
|
const WORKER_SOURCE = `
|
|
@@ -55,20 +58,41 @@ process.on('message', async (msg) => {
|
|
|
55
58
|
else sandbox[name] = proxy;
|
|
56
59
|
}
|
|
57
60
|
sandbox.globalThis = sandbox;
|
|
61
|
+
// The names above are the host's; everything else on globalThis is what the run's scripts left.
|
|
62
|
+
const reserved = new Set(Object.keys(sandbox));
|
|
63
|
+
for (const [key, value] of Object.entries(msg.carried || {})) if (!reserved.has(key)) sandbox[key] = value;
|
|
64
|
+
// Plain data left on globalThis goes back for the run's next script, whether this one returned
|
|
65
|
+
// or threw: a step that failed is fixed in place, not written again. Functions do not carry, and
|
|
66
|
+
// a value JSON cannot hold (a cycle) is not carried; the result's kept names show what did.
|
|
67
|
+
const carried = () => {
|
|
68
|
+
const kept = {};
|
|
69
|
+
for (const key of Object.keys(sandbox)) {
|
|
70
|
+
if (reserved.has(key)) continue;
|
|
71
|
+
let json;
|
|
72
|
+
try {
|
|
73
|
+
json = JSON.stringify(sandbox[key]);
|
|
74
|
+
} catch (notJson) {
|
|
75
|
+
continue;
|
|
76
|
+
}
|
|
77
|
+
if (json !== undefined) kept[key] = JSON.parse(json);
|
|
78
|
+
}
|
|
79
|
+
return kept;
|
|
80
|
+
};
|
|
58
81
|
try {
|
|
59
|
-
|
|
60
|
-
// A
|
|
61
|
-
const expression =
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
82
|
+
// Code that parses as one expression is returned, its closing semicolon dropped; anything
|
|
83
|
+
// else is a function body. A line of several statements is a body, so it runs to the end.
|
|
84
|
+
const expression = msg.code.trim().replace(/;$/, '');
|
|
85
|
+
let script;
|
|
86
|
+
try {
|
|
87
|
+
script = new vm.Script('(async () => { return (' + expression + '\\n); })()', { filename: 'code_act.js' });
|
|
88
|
+
} catch (notOneExpression) {
|
|
89
|
+
script = new vm.Script('(async () => { ' + msg.code + '\\n})()', { filename: 'code_act.js' });
|
|
90
|
+
}
|
|
67
91
|
const value = await script.runInContext(vm.createContext(sandbox), { timeout: msg.timeoutMs });
|
|
68
|
-
process.send({ type: 'result', success: true, value, logs }, () => process.exit(0));
|
|
92
|
+
process.send({ type: 'result', success: true, value, logs, carried: carried() }, () => process.exit(0));
|
|
69
93
|
} catch (error) {
|
|
70
94
|
process.send(
|
|
71
|
-
{ type: 'result', success: false, logs, error: { name: error && error.name ? error.name : 'Error', message: error && error.message ? error.message : String(error) } },
|
|
95
|
+
{ type: 'result', success: false, logs, carried: carried(), error: { name: error && error.name ? error.name : 'Error', message: error && error.message ? error.message : String(error) } },
|
|
72
96
|
() => process.exit(0)
|
|
73
97
|
);
|
|
74
98
|
}
|
|
@@ -76,8 +100,13 @@ process.on('message', async (msg) => {
|
|
|
76
100
|
process.send({ type: 'ready' });
|
|
77
101
|
`;
|
|
78
102
|
const DEFAULT_TIMEOUT_MS = 300_000;
|
|
79
|
-
|
|
80
|
-
|
|
103
|
+
const CARRIED_RUNS = 4;
|
|
104
|
+
/**
|
|
105
|
+
* Run the code in a fresh worker process; host calls are answered by `host.call`. `carried` is
|
|
106
|
+
* what the run's earlier scripts left on globalThis; the result's `carried` is what this one
|
|
107
|
+
* leaves. A worker that dies or times out leaves what it was given.
|
|
108
|
+
*/
|
|
109
|
+
function runCodeAct(code, host, timeoutMs = DEFAULT_TIMEOUT_MS, carried = {}) {
|
|
81
110
|
const startedAt = Date.now();
|
|
82
111
|
let hostCallCount = 0;
|
|
83
112
|
return new Promise((resolve) => {
|
|
@@ -89,13 +118,20 @@ function runCodeAct(code, host, timeoutMs = DEFAULT_TIMEOUT_MS) {
|
|
|
89
118
|
});
|
|
90
119
|
let stderr = '';
|
|
91
120
|
let settled = false;
|
|
92
|
-
const settle = (result) => {
|
|
121
|
+
const settle = (result, left = carried) => {
|
|
93
122
|
if (settled)
|
|
94
123
|
return;
|
|
95
124
|
settled = true;
|
|
96
125
|
clearTimeout(timer);
|
|
97
126
|
child.kill('SIGKILL');
|
|
98
|
-
|
|
127
|
+
const kept = Object.keys(left);
|
|
128
|
+
resolve({
|
|
129
|
+
...result,
|
|
130
|
+
hostCallCount,
|
|
131
|
+
durationMs: Date.now() - startedAt,
|
|
132
|
+
...(kept.length > 0 ? { kept } : {}),
|
|
133
|
+
carried: left,
|
|
134
|
+
});
|
|
99
135
|
};
|
|
100
136
|
const timer = setTimeout(() => settle({
|
|
101
137
|
success: false,
|
|
@@ -113,6 +149,7 @@ function runCodeAct(code, host, timeoutMs = DEFAULT_TIMEOUT_MS) {
|
|
|
113
149
|
code,
|
|
114
150
|
functionNames: host.functions.map((fn) => fn.name),
|
|
115
151
|
timeoutMs,
|
|
152
|
+
carried,
|
|
116
153
|
});
|
|
117
154
|
return;
|
|
118
155
|
}
|
|
@@ -139,7 +176,7 @@ function runCodeAct(code, host, timeoutMs = DEFAULT_TIMEOUT_MS) {
|
|
|
139
176
|
if (msg.type === 'result') {
|
|
140
177
|
settle(msg.success
|
|
141
178
|
? { success: true, value: msg.value, logs: msg.logs ?? [] }
|
|
142
|
-
: { success: false, error: msg.error, logs: msg.logs ?? [] });
|
|
179
|
+
: { success: false, error: msg.error, logs: msg.logs ?? [] }, msg.carried ?? {});
|
|
143
180
|
}
|
|
144
181
|
});
|
|
145
182
|
child.on('error', (error) => settle({ success: false, error: { name: 'WorkerError', message: error.message }, logs: [] }));
|
|
@@ -160,7 +197,7 @@ function runCodeAct(code, host, timeoutMs = DEFAULT_TIMEOUT_MS) {
|
|
|
160
197
|
}
|
|
161
198
|
exports.CODE_ACT_CONTRACT = {
|
|
162
199
|
name: 'code_act',
|
|
163
|
-
summary: 'Run JavaScript that calls MAMA actions and returns only what the turn needs. Every action is an async function by its name, e.g. `return (await work.list({ view: "items", text: "asset" })).tasks.map((task) => [task.title, task.status])`; a failed action throws with its error; independent calls go together with `Promise.all`; `help({ actions: ["work.revise"] })` returns an action\'s argument types and examples; a name with a colon is called as `memory["read:provenance"]({...})`. The code runs in a separate process with no file or process access and an empty environment; its return value, console.log lines and any error come back.',
|
|
200
|
+
summary: 'Run JavaScript that calls MAMA actions and returns only what the turn needs. Every action is an async function by its name, e.g. `return (await work.list({ view: "items", text: "asset" })).tasks.map((task) => [task.title, task.status])`; a failed action throws with its error; independent calls go together with `Promise.all`; `help({ actions: ["work.revise"] })` returns an action\'s argument types and examples; a name with a colon is called as `memory["read:provenance"]({...})`. The code runs in a separate process with no file or process access and an empty environment; its return value, console.log lines and any error come back. Plain data you assign to globalThis (strings, numbers, arrays, objects; not functions) is there again in your next code_act of this turn, even when the script threw, and the result lists it in kept: when a script fails, fix the part that failed instead of sending the whole script again.',
|
|
164
201
|
inputSchema: {
|
|
165
202
|
type: 'object',
|
|
166
203
|
additionalProperties: false,
|
|
@@ -179,6 +216,10 @@ exports.CODE_ACT_CONTRACT = {
|
|
|
179
216
|
* caller is granted, and each call is dispatched with the caller's own context.
|
|
180
217
|
*/
|
|
181
218
|
function codeActRegistration(dispatcher) {
|
|
219
|
+
// What each run's scripts left on globalThis. Runs are serial in one owner runtime, so the
|
|
220
|
+
// latest run is the one that continues; the daemon is long-lived and a script can hold a whole
|
|
221
|
+
// ledger, so only the latest few runs keep theirs.
|
|
222
|
+
const carriedByRun = new Map();
|
|
182
223
|
return {
|
|
183
224
|
contract: exports.CODE_ACT_CONTRACT,
|
|
184
225
|
exec: async (input, context) => {
|
|
@@ -193,7 +234,9 @@ function codeActRegistration(dispatcher) {
|
|
|
193
234
|
throw new Error('code_act requires an operation id');
|
|
194
235
|
const callable = new Set(functions.map((fn) => fn.name));
|
|
195
236
|
let calls = 0;
|
|
196
|
-
|
|
237
|
+
const runId = context.session?.modelRunId;
|
|
238
|
+
const before = runId === undefined ? {} : (carriedByRun.get(runId) ?? {});
|
|
239
|
+
const { carried: after, ...result } = await runCodeAct(input.code, {
|
|
197
240
|
functions,
|
|
198
241
|
call: async (name, params) => {
|
|
199
242
|
// callTool() takes any name; code_act itself would start a worker inside a worker.
|
|
@@ -209,7 +252,28 @@ function codeActRegistration(dispatcher) {
|
|
|
209
252
|
return result.data;
|
|
210
253
|
throw new Error(`${result.error.code}: ${result.error.message}`);
|
|
211
254
|
},
|
|
212
|
-
});
|
|
255
|
+
}, DEFAULT_TIMEOUT_MS, before);
|
|
256
|
+
if (runId === undefined)
|
|
257
|
+
return result;
|
|
258
|
+
// One model message can carry several code_act calls, each started from the same values:
|
|
259
|
+
// apply only what this call changed, so it does not replace what the others left.
|
|
260
|
+
const current = { ...(carriedByRun.get(runId) ?? {}) };
|
|
261
|
+
for (const key of Object.keys(before))
|
|
262
|
+
if (!(key in after))
|
|
263
|
+
delete current[key];
|
|
264
|
+
for (const [key, value] of Object.entries(after))
|
|
265
|
+
if (JSON.stringify(value) !== JSON.stringify(before[key]))
|
|
266
|
+
current[key] = value;
|
|
267
|
+
carriedByRun.delete(runId);
|
|
268
|
+
carriedByRun.set(runId, current);
|
|
269
|
+
for (const oldest of carriedByRun.keys()) {
|
|
270
|
+
if (carriedByRun.size <= CARRIED_RUNS)
|
|
271
|
+
break;
|
|
272
|
+
carriedByRun.delete(oldest);
|
|
273
|
+
}
|
|
274
|
+
const { kept: _ownView, ...rest } = result;
|
|
275
|
+
const kept = Object.keys(current);
|
|
276
|
+
return kept.length > 0 ? { ...rest, kept } : rest;
|
|
213
277
|
},
|
|
214
278
|
};
|
|
215
279
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"code-act-actions.js","sourceRoot":"","sources":["../../src/api/code-act-actions.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"code-act-actions.js","sourceRoot":"","sources":["../../src/api/code-act-actions.ts"],"names":[],"mappings":";;;AAmIA,gCAiHC;AAyBD,kDA+DC;AA5UD;;;;;;;;;;;;GAYG;AACH,2DAA2C;AAQ3C,MAAM,aAAa,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAiFrB,CAAC;AAqBF,MAAM,kBAAkB,GAAG,OAAO,CAAC;AACnC,MAAM,YAAY,GAAG,CAAC,CAAC;AAEvB;;;;GAIG;AACH,SAAgB,UAAU,CACxB,IAAY,EACZ,IAAiB,EACjB,SAAS,GAAG,kBAAkB,EAC9B,UAAyB,EAAE;IAE3B,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;IAC7B,IAA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';
|
|
2
|
+
export interface OwnerExchange {
|
|
3
|
+
/** When the owner sent the message, epoch ms. */
|
|
4
|
+
at: number;
|
|
5
|
+
owner: string;
|
|
6
|
+
/** Your reply as the turn produced it; null while the turn has none. */
|
|
7
|
+
reply: string | null;
|
|
8
|
+
}
|
|
9
|
+
export interface OwnerMessagePorts {
|
|
10
|
+
/** The owner's messages in [since, before), oldest first, each with your reply. */
|
|
11
|
+
exchanges(since: number, before: number): readonly OwnerExchange[];
|
|
12
|
+
/** How long owner messages are kept; older conversation is gone. */
|
|
13
|
+
retentionMs: number;
|
|
14
|
+
now?(): number;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* The owner conversation for a span, read by the agent when a turn needs it: a daily page's
|
|
18
|
+
* "what the owner decided" is spread over that day's exchanges, and nothing else reads them.
|
|
19
|
+
*/
|
|
20
|
+
export declare function ownerMessageActionRegistrations(ports: OwnerMessagePorts): ActionRegistration[];
|
|
21
|
+
//# sourceMappingURL=owner-message-actions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"owner-message-actions.d.ts","sourceRoot":"","sources":["../../src/api/owner-message-actions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAGjE,MAAM,WAAW,aAAa;IAC5B,iDAAiD;IACjD,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,wEAAwE;IACxE,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;CACtB;AAED,MAAM,WAAW,iBAAiB;IAChC,mFAAmF;IACnF,SAAS,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,SAAS,aAAa,EAAE,CAAC;IACnE,oEAAoE;IACpE,WAAW,EAAE,MAAM,CAAC;IACpB,GAAG,CAAC,IAAI,MAAM,CAAC;CAChB;AA0BD;;;GAGG;AACH,wBAAgB,+BAA+B,CAAC,KAAK,EAAE,iBAAiB,GAAG,kBAAkB,EAAE,CA+E9F"}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ownerMessageActionRegistrations = ownerMessageActionRegistrations;
|
|
4
|
+
const work_actions_js_1 = require("./work-actions.js");
|
|
5
|
+
const DEFAULT_CHARS = 400;
|
|
6
|
+
const MAX_CHARS = 4_000;
|
|
7
|
+
const DEFAULT_LIMIT = 20;
|
|
8
|
+
const MAX_LIMIT = 50;
|
|
9
|
+
function invalidInput(message) {
|
|
10
|
+
const error = new Error(message);
|
|
11
|
+
error.name = 'invalid_input';
|
|
12
|
+
return error;
|
|
13
|
+
}
|
|
14
|
+
function time(value, field) {
|
|
15
|
+
const parsed = (0, work_actions_js_1.offsetIsoTime)(value);
|
|
16
|
+
if (parsed !== undefined)
|
|
17
|
+
return parsed;
|
|
18
|
+
if (Number.isSafeInteger(value) && value >= 0)
|
|
19
|
+
return value;
|
|
20
|
+
throw invalidInput(`owner.messages ${field} must be epoch milliseconds or an ISO time with its offset`);
|
|
21
|
+
}
|
|
22
|
+
function clip(text, chars) {
|
|
23
|
+
return text.length > chars ? `${text.slice(0, chars - 1)}…` : text;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* The owner conversation for a span, read by the agent when a turn needs it: a daily page's
|
|
27
|
+
* "what the owner decided" is spread over that day's exchanges, and nothing else reads them.
|
|
28
|
+
*/
|
|
29
|
+
function ownerMessageActionRegistrations(ports) {
|
|
30
|
+
return [
|
|
31
|
+
{
|
|
32
|
+
contract: {
|
|
33
|
+
name: 'owner.messages',
|
|
34
|
+
summary: "Read your conversation with the owner in a time span: each owner message with your reply, oldest first, in pages of 20 (50 max). A line longer than chars (400 by default) ends with …; read that span again with a larger chars. Messages are kept for seven days; for earlier days the owner's decisions are in the ledger, the lessons and the sources.",
|
|
35
|
+
inputSchema: {
|
|
36
|
+
type: 'object',
|
|
37
|
+
additionalProperties: false,
|
|
38
|
+
required: ['since'],
|
|
39
|
+
properties: {
|
|
40
|
+
since: {
|
|
41
|
+
oneOf: [
|
|
42
|
+
{ type: 'integer', minimum: 0 },
|
|
43
|
+
{ type: 'string', minLength: 1 },
|
|
44
|
+
],
|
|
45
|
+
description: 'Start of the span (epoch ms or ISO with offset), e.g. the day at 00:00.',
|
|
46
|
+
},
|
|
47
|
+
before: {
|
|
48
|
+
oneOf: [
|
|
49
|
+
{ type: 'integer', minimum: 0 },
|
|
50
|
+
{ type: 'string', minLength: 1 },
|
|
51
|
+
],
|
|
52
|
+
description: 'End of the span, exclusive; defaults to now.',
|
|
53
|
+
},
|
|
54
|
+
offset: { type: 'integer', minimum: 0, description: 'Skip this many exchanges.' },
|
|
55
|
+
limit: { type: 'integer', minimum: 1, maximum: MAX_LIMIT },
|
|
56
|
+
chars: {
|
|
57
|
+
type: 'integer',
|
|
58
|
+
minimum: 100,
|
|
59
|
+
maximum: MAX_CHARS,
|
|
60
|
+
description: 'Longest message or reply text returned; longer text is cut.',
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
examples: [
|
|
65
|
+
{
|
|
66
|
+
title: 'One day of conversation',
|
|
67
|
+
input: { since: '2026-01-01T00:00:00+09:00', before: '2026-01-02T00:00:00+09:00' },
|
|
68
|
+
},
|
|
69
|
+
],
|
|
70
|
+
},
|
|
71
|
+
exec: (input) => {
|
|
72
|
+
const body = input;
|
|
73
|
+
const now = ports.now?.() ?? Date.now();
|
|
74
|
+
const since = time(body.since, 'since');
|
|
75
|
+
const before = body.before === undefined ? now : time(body.before, 'before');
|
|
76
|
+
const offset = typeof body.offset === 'number' ? body.offset : 0;
|
|
77
|
+
const limit = typeof body.limit === 'number' ? body.limit : DEFAULT_LIMIT;
|
|
78
|
+
const chars = typeof body.chars === 'number' ? body.chars : DEFAULT_CHARS;
|
|
79
|
+
const all = ports.exchanges(since, before);
|
|
80
|
+
const page = all.slice(offset, offset + limit);
|
|
81
|
+
const next = offset + page.length;
|
|
82
|
+
return {
|
|
83
|
+
total: all.length,
|
|
84
|
+
messages: page.map((exchange) => ({
|
|
85
|
+
at: exchange.at,
|
|
86
|
+
owner: clip(exchange.owner, chars),
|
|
87
|
+
reply: exchange.reply === null ? null : clip(exchange.reply, chars),
|
|
88
|
+
})),
|
|
89
|
+
nextOffset: next < all.length ? next : null,
|
|
90
|
+
...(since < now - ports.retentionMs
|
|
91
|
+
? {
|
|
92
|
+
retention: 'Owner messages are kept for seven days; this span starts earlier, so older conversation is missing.',
|
|
93
|
+
}
|
|
94
|
+
: {}),
|
|
95
|
+
};
|
|
96
|
+
},
|
|
97
|
+
},
|
|
98
|
+
];
|
|
99
|
+
}
|
|
100
|
+
//# sourceMappingURL=owner-message-actions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"owner-message-actions.js","sourceRoot":"","sources":["../../src/api/owner-message-actions.ts"],"names":[],"mappings":";;AA+CA,0EA+EC;AA7HD,uDAAkD;AAkBlD,MAAM,aAAa,GAAG,GAAG,CAAC;AAC1B,MAAM,SAAS,GAAG,KAAK,CAAC;AACxB,MAAM,aAAa,GAAG,EAAE,CAAC;AACzB,MAAM,SAAS,GAAG,EAAE,CAAC;AAErB,SAAS,YAAY,CAAC,OAAe;IACnC,MAAM,KAAK,GAAG,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC;IACjC,KAAK,CAAC,IAAI,GAAG,eAAe,CAAC;IAC7B,OAAO,KAAK,CAAC;AACf,CAAC;AAED,SAAS,IAAI,CAAC,KAAc,EAAE,KAAa;IACzC,MAAM,MAAM,GAAG,IAAA,+BAAa,EAAC,KAAK,CAAC,CAAC;IACpC,IAAI,MAAM,KAAK,SAAS;QAAE,OAAO,MAAM,CAAC;IACxC,IAAI,MAAM,CAAC,aAAa,CAAC,KAAK,CAAC,IAAK,KAAgB,IAAI,CAAC;QAAE,OAAO,KAAe,CAAC;IAClF,MAAM,YAAY,CAChB,kBAAk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CAC3B;AAED,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACvB,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACvB;AA+FD,wBAAsB,iBAAiB,CACrC,MAAM,EAAE,eAAe,EACvB,UAAU,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,OAAO,CAAC,OAAO,CAAC,GAC/E,OAAO,CAAC,OAAO,CAAC,CAkBlB;AAoQD,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,mBAAmB,GAAG,YAAY,CA+lB7E"}
|
|
@@ -244,12 +244,6 @@ function archiveGraphPage(pages, nextCursor) {
|
|
|
244
244
|
function localStamp(ms, timeZone) {
|
|
245
245
|
return `${new Date(ms).toLocaleString('ko-KR', { timeZone })} (${timeZone})`;
|
|
246
246
|
}
|
|
247
|
-
function edgeLabelSummary(node, timeZone) {
|
|
248
|
-
if (node.data.kind !== 'memory')
|
|
249
|
-
return node.label;
|
|
250
|
-
const at = node.data.recordedAt ? localStamp(node.data.recordedAt, timeZone) : '';
|
|
251
|
-
return `${at} ${node.data.topic}: ${node.data.summary}`;
|
|
252
|
-
}
|
|
253
247
|
function graphNodeKey(node) {
|
|
254
248
|
return `${node.ref.kind}:${node.ref.id}`;
|
|
255
249
|
}
|
|
@@ -480,7 +474,7 @@ function createViewerServer(options) {
|
|
|
480
474
|
missing: [
|
|
481
475
|
{
|
|
482
476
|
kind: 'revision_chain',
|
|
483
|
-
message:
|
|
477
|
+
message: "Revisions are linked only where the agent stated a relation; the order of an item's revisions is in work.show history all.",
|
|
484
478
|
},
|
|
485
479
|
],
|
|
486
480
|
};
|
|
@@ -581,17 +575,10 @@ function createViewerServer(options) {
|
|
|
581
575
|
const provenance = (await callAction('memory.read:provenance', {
|
|
582
576
|
memory_id: node.ref.id,
|
|
583
577
|
}));
|
|
584
|
-
const earlier = page.edges
|
|
585
|
-
.filter((edge) => `${edge.resolvedFrom.kind}:${edge.resolvedFrom.id}` === id &&
|
|
586
|
-
edge.resolvedTo.kind === 'memory')
|
|
587
|
-
.map((edge) => page.nodes.find((candidate) => graphNodeKey(candidate) === `${edge.resolvedTo.kind}:${edge.resolvedTo.id}`))
|
|
588
|
-
.filter((candidate) => candidate !== undefined && candidate.data.kind === 'memory')
|
|
589
|
-
.map((candidate) => `- ${edgeLabelSummary(candidate, options.timeZone.get())}`);
|
|
590
578
|
const evidence = (provenance.events ?? []).map((event) => `- ${event.observedAt ?? ''} ${event.channel ?? ''}: ${event.excerpt}`);
|
|
591
579
|
const sections = [
|
|
592
580
|
mapped.reasoning ?? '',
|
|
593
581
|
evidence.length > 0 ? `**Evidence**\n${evidence.join('\n')}` : '',
|
|
594
|
-
earlier.length > 0 ? `**Earlier records**\n${earlier.join('\n')}` : '',
|
|
595
582
|
].filter((section) => section !== '');
|
|
596
583
|
return { node: { ...mapped, reasoning: sections.join('\n\n') } };
|
|
597
584
|
}
|