@cmodjs/core 1.6.0 → 2.0.0
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/docs/commands.md +4 -4
- package/docs/index.md +12 -11
- package/docs/jobs.md +12 -16
- package/docs/mod.md +111 -36
- package/docs/permissions.md +14 -18
- package/docs/session.md +171 -82
- package/docs/state.md +5 -5
- package/docs/testing.md +57 -41
- package/docs/ui.md +9 -9
- package/jobs/permissions/decide-permission.d.ts.map +1 -1
- package/jobs/permissions/decide-permission.js +1 -1
- package/jobs/prompt.d.ts +1 -3
- package/jobs/prompt.d.ts.map +1 -1
- package/jobs/prompt.js +2 -21
- package/jobs/slash-command.d.ts +1 -1
- package/jobs/slash-command.d.ts.map +1 -1
- package/jobs/slash-command.js +1 -1
- package/jobs/status-line.d.ts +0 -1
- package/jobs/status-line.d.ts.map +1 -1
- package/jobs/status-line.js +3 -4
- package/mod.d.ts +53 -105
- package/mod.d.ts.map +1 -1
- package/mod.js +18 -80
- package/package.json +1 -1
- package/records.d.ts +1 -1
- package/records.js +1 -1
- package/register.d.ts.map +1 -1
- package/register.js +3 -1
- package/runtime/before.d.ts +5 -1
- package/runtime/before.d.ts.map +1 -1
- package/runtime/before.js +81 -39
- package/runtime/claude.d.ts +6 -1
- package/runtime/claude.d.ts.map +1 -1
- package/runtime/conversations.d.ts.map +1 -1
- package/runtime/conversations.js +45 -26
- package/runtime/deadline.d.ts +17 -0
- package/runtime/deadline.d.ts.map +1 -1
- package/runtime/deadline.js +34 -0
- package/runtime/dependencies.d.ts +2 -0
- package/runtime/dependencies.d.ts.map +1 -1
- package/runtime/dependencies.js +12 -0
- package/runtime/grants.d.ts.map +1 -1
- package/runtime/grants.js +13 -8
- package/runtime/hooks.d.ts +28 -11
- package/runtime/hooks.d.ts.map +1 -1
- package/runtime/hooks.js +20 -123
- package/runtime/lifecycle.d.ts +2 -1
- package/runtime/lifecycle.d.ts.map +1 -1
- package/runtime/lifecycle.js +66 -49
- package/runtime/sessions.d.ts +31 -5
- package/runtime/sessions.d.ts.map +1 -1
- package/runtime/sessions.js +342 -81
- package/runtime/tool-calls.d.ts +0 -1
- package/runtime/tool-calls.d.ts.map +1 -1
- package/runtime/tool-calls.js +0 -19
- package/session/context/turn/message/instruction-file.d.ts +9 -0
- package/session/context/turn/message/instruction-file.d.ts.map +1 -0
- package/session/context/turn/message/instruction-file.js +4 -0
- package/session/context/turn/message/message.d.ts +5 -4
- package/session/context/turn/message/message.d.ts.map +1 -1
- package/session/context/turn/message/message.js +7 -6
- package/session/context/turn/message/sender.d.ts +2 -1
- package/session/context/turn/message/sender.d.ts.map +1 -1
- package/session/context/turn/message/sender.js +4 -1
- package/session/context/turn/message/tool-call.d.ts +5 -0
- package/session/context/turn/message/tool-call.d.ts.map +1 -1
- package/session/context/turn/message/tool-result.d.ts +6 -1
- package/session/context/turn/message/tool-result.d.ts.map +1 -1
- package/session/context/turn/turn.d.ts +7 -0
- package/session/context/turn/turn.d.ts.map +1 -1
- package/session/conversation.d.ts +10 -3
- package/session/conversation.d.ts.map +1 -1
- package/session/conversation.js +14 -5
- package/session/goal/goal.d.ts +1 -1
- package/session/goal/goal.d.ts.map +1 -1
- package/session/goal/task.d.ts +2 -2
- package/session/goal/task.d.ts.map +1 -1
- package/session/session.d.ts +361 -26
- package/session/session.d.ts.map +1 -1
- package/session/session.js +40 -0
- package/src/jobs/permissions/decide-permission.ts +2 -1
- package/src/jobs/prompt.ts +3 -20
- package/src/jobs/slash-command.ts +2 -2
- package/src/jobs/status-line.ts +4 -7
- package/src/mod.ts +52 -147
- package/src/records.ts +1 -1
- package/src/register.ts +3 -1
- package/src/runtime/before.ts +90 -37
- package/src/runtime/claude.ts +5 -1
- package/src/runtime/conversations.ts +41 -25
- package/src/runtime/deadline.ts +38 -0
- package/src/runtime/dependencies.ts +12 -0
- package/src/runtime/grants.ts +11 -7
- package/src/runtime/hooks.ts +48 -116
- package/src/runtime/lifecycle.ts +65 -50
- package/src/runtime/sessions.ts +366 -90
- package/src/runtime/tool-calls.ts +0 -19
- package/src/session/context/turn/message/instruction-file.ts +13 -0
- package/src/session/context/turn/message/message.ts +11 -9
- package/src/session/context/turn/message/sender.ts +5 -2
- package/src/session/context/turn/message/tool-call.ts +3 -0
- package/src/session/context/turn/message/tool-result.ts +6 -1
- package/src/session/context/turn/turn.ts +4 -0
- package/src/session/conversation.ts +21 -8
- package/src/session/goal/goal.ts +1 -1
- package/src/session/goal/task.ts +2 -2
- package/src/session/session.ts +227 -24
- package/src/testing/claude-code.ts +23 -0
- package/src/testing/fake-claude.ts +5 -1
- package/src/testing/fake-sessions.ts +38 -24
- package/src/testing.ts +84 -16
- package/testing/claude-code.d.ts +12 -0
- package/testing/claude-code.d.ts.map +1 -0
- package/testing/claude-code.js +10 -0
- package/testing/fake-claude.d.ts +4 -0
- package/testing/fake-claude.d.ts.map +1 -1
- package/testing/fake-claude.js +4 -1
- package/testing/fake-sessions.d.ts +8 -6
- package/testing/fake-sessions.d.ts.map +1 -1
- package/testing/fake-sessions.js +35 -20
- package/testing.d.ts +38 -9
- package/testing.d.ts.map +1 -1
- package/testing.js +54 -5
- package/docs/hooks.md +0 -259
- package/session/context/turn/message/document.d.ts +0 -7
- package/session/context/turn/message/document.d.ts.map +0 -1
- package/session/context/turn/message/document.js +0 -1
- package/src/session/context/turn/message/document.ts +0 -8
package/runtime/tool-calls.js
CHANGED
|
@@ -2,11 +2,9 @@ export const reservedKeys = ['tool', 'tool_use_id', 'consent', 'agentId'];
|
|
|
2
2
|
export function toolInputOf(envelope) {
|
|
3
3
|
return Object.fromEntries(Object.entries(envelope).filter(([key]) => !reservedKeys.includes(key)));
|
|
4
4
|
}
|
|
5
|
-
const keptCalls = 100;
|
|
6
5
|
export function toolCalls(claude, router) {
|
|
7
6
|
let mainAgentType;
|
|
8
7
|
const agentIds = new Map();
|
|
9
|
-
const cwds = new Map();
|
|
10
8
|
const noteAgent = (e) => {
|
|
11
9
|
if (e.agent_id === undefined)
|
|
12
10
|
mainAgentType = e.agent_type;
|
|
@@ -20,12 +18,6 @@ export function toolCalls(claude, router) {
|
|
|
20
18
|
return next(e);
|
|
21
19
|
});
|
|
22
20
|
router.add('tool.call', async (e, next) => {
|
|
23
|
-
cwds.set(e.tool_use_id, await claude.session.cwd());
|
|
24
|
-
for (const oldest of cwds.keys()) {
|
|
25
|
-
if (cwds.size <= keptCalls)
|
|
26
|
-
break;
|
|
27
|
-
cwds.delete(oldest);
|
|
28
|
-
}
|
|
29
21
|
if (e.agentId === undefined)
|
|
30
22
|
return next(e);
|
|
31
23
|
agentIds.set(e.tool_use_id, e.agentId);
|
|
@@ -36,22 +28,11 @@ export function toolCalls(claude, router) {
|
|
|
36
28
|
agentIds.delete(e.tool_use_id);
|
|
37
29
|
}
|
|
38
30
|
});
|
|
39
|
-
for (const event of ['classic.PostToolUse', 'classic.PostToolUseFailure']) {
|
|
40
|
-
router.add(event, async (e, next) => {
|
|
41
|
-
try {
|
|
42
|
-
return await next(e);
|
|
43
|
-
}
|
|
44
|
-
finally {
|
|
45
|
-
cwds.delete(e.tool_use_id);
|
|
46
|
-
}
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
31
|
return {
|
|
50
32
|
async agentOf(toolUseId) {
|
|
51
33
|
const agentId = toolUseId === undefined ? undefined : agentIds.get(toolUseId);
|
|
52
34
|
const agentType = agentId === undefined ? mainAgentType : (await claude.agent.list()).find((agent) => agent.id === agentId)?.type;
|
|
53
35
|
return { ...(agentId === undefined ? {} : { agentId }), ...(agentType === undefined ? {} : { agentType }) };
|
|
54
36
|
},
|
|
55
|
-
cwdOf: (toolUseId) => cwds.get(toolUseId),
|
|
56
37
|
};
|
|
57
38
|
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { MessageOf } from './message.js';
|
|
2
|
+
export declare const InstructionFile = "instructionFile";
|
|
3
|
+
export type InstructionFile = MessageOf<typeof InstructionFile> & {
|
|
4
|
+
readonly path: string;
|
|
5
|
+
readonly text: string;
|
|
6
|
+
readonly isRule: boolean;
|
|
7
|
+
};
|
|
8
|
+
export declare function isRulePath(path: string): boolean;
|
|
9
|
+
//# sourceMappingURL=instruction-file.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"instruction-file.d.ts","sourceRoot":"","sources":["../../../../src/session/context/turn/message/instruction-file.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AAE7C,eAAO,MAAM,eAAe,oBAAoB,CAAA;AAEhD,MAAM,MAAM,eAAe,GAAG,SAAS,CAAC,OAAO,eAAe,CAAC,GAAG;IAChE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAA;CACzB,CAAA;AAED,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAEhD"}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { InstructionFile } from './instruction-file.js';
|
|
2
2
|
import { Note } from './note.js';
|
|
3
3
|
import { Notice } from './notice.js';
|
|
4
4
|
import { Prompt } from './prompt.js';
|
|
5
5
|
import { Reply } from './reply.js';
|
|
6
6
|
import { Skill } from './skill.js';
|
|
7
|
-
import { ToolCall } from './tool-call.js';
|
|
7
|
+
import { ToolCall, type CallFiles } from './tool-call.js';
|
|
8
8
|
import { ToolResult } from './tool-result.js';
|
|
9
9
|
export declare const Message = "message";
|
|
10
|
-
export type MessageType = typeof Prompt | typeof Note | typeof Reply | typeof ToolCall | typeof ToolResult | typeof Skill | typeof
|
|
10
|
+
export type MessageType = typeof Prompt | typeof Note | typeof Reply | typeof ToolCall | typeof ToolResult | typeof Skill | typeof InstructionFile | typeof Notice;
|
|
11
11
|
export type MessageOf<Type extends MessageType> = {
|
|
12
12
|
readonly id: string;
|
|
13
13
|
readonly type: Type;
|
|
@@ -17,7 +17,7 @@ export type MessageOf<Type extends MessageType> = {
|
|
|
17
17
|
readonly turn?: string;
|
|
18
18
|
readonly task?: string;
|
|
19
19
|
};
|
|
20
|
-
export type Message = Prompt | Note | Reply | ToolCall | ToolResult | Skill |
|
|
20
|
+
export type Message = Prompt | Note | Reply | ToolCall | ToolResult | Skill | InstructionFile | Notice;
|
|
21
21
|
export type Placed = 'session' | 'context' | 'turn' | 'task';
|
|
22
22
|
export type Unplaced<M extends Message = Message> = M extends Message ? Omit<M, Placed> : never;
|
|
23
23
|
export type Row = {
|
|
@@ -47,6 +47,7 @@ export declare function rowOfAppend(append: {
|
|
|
47
47
|
readonly content: readonly unknown[];
|
|
48
48
|
};
|
|
49
49
|
}, at: string, cwd: string): Row;
|
|
50
|
+
export declare const noFiles: CallFiles;
|
|
50
51
|
export declare function messagesOf(row: Row, isInTask: boolean): Unplaced[];
|
|
51
52
|
export declare function withTexts(row: Row, texts: ReadonlyMap<number, string>): readonly unknown[];
|
|
52
53
|
export declare function textOf(content: unknown): string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"message.d.ts","sourceRoot":"","sources":["../../../../src/session/context/turn/message/message.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"message.d.ts","sourceRoot":"","sources":["../../../../src/session/context/turn/message/message.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAc,MAAM,uBAAuB,CAAA;AACnE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAChC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AACpC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AACpC,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AAElC,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AAClC,OAAO,EAAE,QAAQ,EAAE,KAAK,SAAS,EAAE,MAAM,gBAAgB,CAAA;AACzD,OAAO,EAA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AS,CAAC,GAAG,EAAE,GAAG,EAAE,KAAK,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,SAAS,OAAO,EAAE,CA4B1F;AAUD,wBAAgB,MAAM,CAAC,OAAO,EAAE,OAAO,GAAG,MAAM,CAI/C;AAED,wBAAgB,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAEnE;AAID,wBAAgB,UAAU,CAAC,OAAO,EAAE,QAAQ,GAAG,MAAM,CAKpD"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { isObject } from '../../../../records.js';
|
|
2
2
|
import { Task } from '../../../goal/task.js';
|
|
3
|
-
import {
|
|
3
|
+
import { InstructionFile, isRulePath } from './instruction-file.js';
|
|
4
4
|
import { Note } from './note.js';
|
|
5
5
|
import { Notice } from './notice.js';
|
|
6
6
|
import { Prompt } from './prompt.js';
|
|
@@ -10,7 +10,7 @@ import { Skill } from './skill.js';
|
|
|
10
10
|
import { ToolCall } from './tool-call.js';
|
|
11
11
|
import { ToolResult } from './tool-result.js';
|
|
12
12
|
export const Message = 'message';
|
|
13
|
-
export const messageTypes = [Prompt, Note, Reply, ToolCall, ToolResult, Skill,
|
|
13
|
+
export const messageTypes = [Prompt, Note, Reply, ToolCall, ToolResult, Skill, InstructionFile, Notice];
|
|
14
14
|
export const skillPrefix = 'Base directory for this skill:';
|
|
15
15
|
const rowTypes = ['user', 'assistant', 'attachment', 'system'];
|
|
16
16
|
const memoryPath = /^Contents of (.+?) \(/;
|
|
@@ -55,6 +55,7 @@ export function rowOfAppend(append, at, cwd) {
|
|
|
55
55
|
...(model === undefined ? {} : { model }),
|
|
56
56
|
};
|
|
57
57
|
}
|
|
58
|
+
export const noFiles = { read: [], changed: [] };
|
|
58
59
|
export function messagesOf(row, isInTask) {
|
|
59
60
|
const found = unplacedOf(row, isInTask);
|
|
60
61
|
return found.length === 1 ? found : found.map((message, index) => ({ ...message, id: `${row.id}:${index}` }));
|
|
@@ -65,21 +66,21 @@ function unplacedOf(row, isInTask) {
|
|
|
65
66
|
if (row.type === 'system')
|
|
66
67
|
return row.name === 'turn_duration' || row.name === 'compact_boundary' || text === '' ? [] : [{ ...base, type: Notice, text }];
|
|
67
68
|
if (row.type === 'attachment')
|
|
68
|
-
return row.name === 'nested_memory' ? [{ ...base, type:
|
|
69
|
+
return row.name === 'nested_memory' ? [{ ...base, type: InstructionFile, path: row.path ?? '', text, isRule: isRulePath(row.path ?? '') }] : [];
|
|
69
70
|
if (row.type === 'assistant') {
|
|
70
71
|
return row.content.filter(isObject).flatMap((block) => {
|
|
71
72
|
if (block['type'] === 'text' && typeof block['text'] === 'string' && block['text'].trim() !== '')
|
|
72
73
|
return [{ ...base, type: Reply, text: block['text'].trim() }];
|
|
73
74
|
if (block['type'] !== 'tool_use' || typeof block['id'] !== 'string' || typeof block['name'] !== 'string')
|
|
74
75
|
return [];
|
|
75
|
-
return [{ ...base, type: ToolCall, callId: block['id'], name: block['name'], input: isObject(block['input']) ? block['input'] : {}, cwd: row.cwd ?? '' }];
|
|
76
|
+
return [{ ...base, type: ToolCall, callId: block['id'], name: block['name'], input: isObject(block['input']) ? block['input'] : {}, cwd: row.cwd ?? '', files: noFiles }];
|
|
76
77
|
});
|
|
77
78
|
}
|
|
78
79
|
if (row.isSummary)
|
|
79
80
|
return [];
|
|
80
81
|
const results = row.content.filter(isToolResultBlock);
|
|
81
82
|
if (results.length > 0)
|
|
82
|
-
return results.map((block) => ({ ...base, type: ToolResult, callId: block['tool_use_id'],
|
|
83
|
+
return results.map((block) => ({ ...base, type: ToolResult, callId: block['tool_use_id'], name: '', input: {}, cwd: row.cwd ?? '', files: noFiles, output: textOf(block['content']), isError: block['is_error'] === true }));
|
|
83
84
|
if (text === '')
|
|
84
85
|
return [];
|
|
85
86
|
if (text.startsWith(skillPrefix))
|
|
@@ -148,7 +149,7 @@ export function searchText(message) {
|
|
|
148
149
|
return [message.name, ...stringsIn(message.input).map((value) => value.slice(0, toolValueChars))].join('\n');
|
|
149
150
|
if (message.type === ToolResult)
|
|
150
151
|
return '';
|
|
151
|
-
if (message.type ===
|
|
152
|
+
if (message.type === InstructionFile)
|
|
152
153
|
return `${message.path}\n${message.text}`;
|
|
153
154
|
return message.text;
|
|
154
155
|
}
|
|
@@ -4,7 +4,8 @@ export declare const Mod = "mod";
|
|
|
4
4
|
export declare const Schedule = "schedule";
|
|
5
5
|
export declare const Channel = "channel";
|
|
6
6
|
export declare const Sdk = "sdk";
|
|
7
|
-
export
|
|
7
|
+
export declare const Engine = "engine";
|
|
8
|
+
export type SenderType = typeof Person | typeof Mod | 'session' | typeof Task | typeof Schedule | typeof Channel | typeof Sdk | typeof Engine;
|
|
8
9
|
export type Sender = {
|
|
9
10
|
readonly type: SenderType;
|
|
10
11
|
readonly name?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sender.d.ts","sourceRoot":"","sources":["../../../../src/session/context/turn/message/sender.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAA;AAE5C,eAAO,MAAM,MAAM,WAAW,CAAA;AAE9B,eAAO,MAAM,GAAG,QAAQ,CAAA;AAExB,eAAO,MAAM,QAAQ,aAAa,CAAA;AAElC,eAAO,MAAM,OAAO,YAAY,CAAA;AAEhC,eAAO,MAAM,GAAG,QAAQ,CAAA;AAExB,MAAM,MAAM,UAAU,GAAG,OAAO,MAAM,GAAG,OAAO,GAAG,GAAG,SAAS,GAAG,OAAO,IAAI,GAAG,OAAO,QAAQ,GAAG,OAAO,OAAO,GAAG,OAAO,GAAG,CAAA;
|
|
1
|
+
{"version":3,"file":"sender.d.ts","sourceRoot":"","sources":["../../../../src/session/context/turn/message/sender.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAA;AAE5C,eAAO,MAAM,MAAM,WAAW,CAAA;AAE9B,eAAO,MAAM,GAAG,QAAQ,CAAA;AAExB,eAAO,MAAM,QAAQ,aAAa,CAAA;AAElC,eAAO,MAAM,OAAO,YAAY,CAAA;AAEhC,eAAO,MAAM,GAAG,QAAQ,CAAA;AAExB,eAAO,MAAM,MAAM,WAAW,CAAA;AAE9B,MAAM,MAAM,UAAU,GAAG,OAAO,MAAM,GAAG,OAAO,GAAG,GAAG,SAAS,GAAG,OAAO,IAAI,GAAG,OAAO,QAAQ,GAAG,OAAO,OAAO,GAAG,OAAO,GAAG,GAAG,OAAO,MAAM,CAAA;AAE7I,MAAM,MAAM,MAAM,GAAG;IACnB,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAA;IACzB,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAA;IACtB,QAAQ,CAAC,EAAE,CAAC,EAAE,OAAO,MAAM,CAAA;CAC5B,CAAA;AAMD,wBAAgB,QAAQ,CAAC,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,OAAO,GAAG,MAAM,CAanE"}
|
|
@@ -5,7 +5,8 @@ export const Mod = 'mod';
|
|
|
5
5
|
export const Schedule = 'schedule';
|
|
6
6
|
export const Channel = 'channel';
|
|
7
7
|
export const Sdk = 'sdk';
|
|
8
|
-
const
|
|
8
|
+
export const Engine = 'engine';
|
|
9
|
+
const personOrigins = ['human', 'composer', 'bridge', 'slack-ping'];
|
|
9
10
|
const sessionOrigins = ['peer', 'peer-send-message', 'coordinator', 'projects-relay', 'observer', 'observer-activity'];
|
|
10
11
|
export function senderOf(origin, isInTask) {
|
|
11
12
|
const fields = isObject(origin) ? origin : {};
|
|
@@ -16,6 +17,8 @@ export function senderOf(origin, isInTask) {
|
|
|
16
17
|
return { type: Person };
|
|
17
18
|
if (sessionOrigins.includes(kind))
|
|
18
19
|
return { type: 'session' };
|
|
20
|
+
if (kind === 'auto-continuation')
|
|
21
|
+
return { type: Engine };
|
|
19
22
|
if (kind === 'plugin' && typeof fields['name'] === 'string')
|
|
20
23
|
return { type: Mod, name: fields['name'], ...(fields['asUser'] === true ? { as: Person } : {}) };
|
|
21
24
|
if (kind === 'scheduled-trigger')
|
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
import type { MessageOf } from './message.js';
|
|
2
2
|
export declare const ToolCall = "toolCall";
|
|
3
|
+
export type CallFiles = {
|
|
4
|
+
readonly read: readonly string[];
|
|
5
|
+
readonly changed: readonly string[];
|
|
6
|
+
};
|
|
3
7
|
export type ToolCall = MessageOf<typeof ToolCall> & {
|
|
4
8
|
readonly callId: string;
|
|
5
9
|
readonly name: string;
|
|
6
10
|
readonly input: Readonly<Record<string, unknown>>;
|
|
7
11
|
readonly cwd: string;
|
|
12
|
+
readonly files: CallFiles;
|
|
8
13
|
};
|
|
9
14
|
//# sourceMappingURL=tool-call.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tool-call.d.ts","sourceRoot":"","sources":["../../../../src/session/context/turn/message/tool-call.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AAE7C,eAAO,MAAM,QAAQ,aAAa,CAAA;AAElC,MAAM,MAAM,QAAQ,GAAG,SAAS,CAAC,OAAO,QAAQ,CAAC,GAAG;IAClD,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;IACvB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAA;IACjD,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAA;
|
|
1
|
+
{"version":3,"file":"tool-call.d.ts","sourceRoot":"","sources":["../../../../src/session/context/turn/message/tool-call.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AAE7C,eAAO,MAAM,QAAQ,aAAa,CAAA;AAElC,MAAM,MAAM,SAAS,GAAG;IAAE,QAAQ,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,CAAA;CAAE,CAAA;AAEjG,MAAM,MAAM,QAAQ,GAAG,SAAS,CAAC,OAAO,QAAQ,CAAC,GAAG;IAClD,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;IACvB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAA;IACjD,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAA;IACpB,QAAQ,CAAC,KAAK,EAAE,SAAS,CAAA;CAC1B,CAAA"}
|
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
import type { MessageOf } from './message.js';
|
|
2
|
+
import type { CallFiles } from './tool-call.js';
|
|
2
3
|
export declare const ToolResult = "toolResult";
|
|
3
4
|
export type ToolResult = MessageOf<typeof ToolResult> & {
|
|
4
5
|
readonly callId: string;
|
|
5
|
-
readonly
|
|
6
|
+
readonly name: string;
|
|
7
|
+
readonly input: Readonly<Record<string, unknown>>;
|
|
8
|
+
readonly cwd: string;
|
|
9
|
+
readonly files: CallFiles;
|
|
10
|
+
readonly output: unknown;
|
|
6
11
|
readonly isError: boolean;
|
|
7
12
|
};
|
|
8
13
|
//# sourceMappingURL=tool-result.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tool-result.d.ts","sourceRoot":"","sources":["../../../../src/session/context/turn/message/tool-result.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;
|
|
1
|
+
{"version":3,"file":"tool-result.d.ts","sourceRoot":"","sources":["../../../../src/session/context/turn/message/tool-result.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AAC7C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAE/C,eAAO,MAAM,UAAU,eAAe,CAAA;AAEtC,MAAM,MAAM,UAAU,GAAG,SAAS,CAAC,OAAO,UAAU,CAAC,GAAG;IACtD,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;IACvB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAA;IACjD,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAA;IACpB,QAAQ,CAAC,KAAK,EAAE,SAAS,CAAA;IACzB,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAA;IACxB,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAA;CAC1B,CAAA"}
|
|
@@ -8,6 +8,13 @@ export type Turn = RecordPart & {
|
|
|
8
8
|
readonly context: number;
|
|
9
9
|
readonly openedAt: string;
|
|
10
10
|
readonly closedAt?: string;
|
|
11
|
+
readonly answer?: string;
|
|
12
|
+
readonly reason?: 'answer' | 'error';
|
|
13
|
+
readonly failure?: {
|
|
14
|
+
readonly type: string;
|
|
15
|
+
readonly text: string;
|
|
16
|
+
};
|
|
11
17
|
messages(): Promise<Message[]>;
|
|
18
|
+
abort(): Promise<void>;
|
|
12
19
|
};
|
|
13
20
|
//# sourceMappingURL=turn.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"turn.d.ts","sourceRoot":"","sources":["../../../src/session/context/turn/turn.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAClD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAA;AACnD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAA;AAEjD,eAAO,MAAM,SAAS,cAAc,CAAA;AAEpC,eAAO,MAAM,OAAO,YAAY,CAAA;AAEhC,MAAM,MAAM,IAAI,GAAG,UAAU,GAAG;IAC9B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;IACvB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;IACxB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;IACzB,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;IAC1B,QAAQ,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC,CAAA;
|
|
1
|
+
{"version":3,"file":"turn.d.ts","sourceRoot":"","sources":["../../../src/session/context/turn/turn.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAClD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAA;AACnD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAA;AAEjD,eAAO,MAAM,SAAS,cAAc,CAAA;AAEpC,eAAO,MAAM,OAAO,YAAY,CAAA;AAEhC,MAAM,MAAM,IAAI,GAAG,UAAU,GAAG;IAC9B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;IACvB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;IACxB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;IACzB,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;IAC1B,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAA;IACxB,QAAQ,CAAC,MAAM,CAAC,EAAE,QAAQ,GAAG,OAAO,CAAA;IACpC,QAAQ,CAAC,OAAO,CAAC,EAAE;QAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAA;IACnE,QAAQ,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC,CAAA;IAC9B,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAA;CACvB,CAAA"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { ContextEnd, ContextStart, type Context } from './context/context.js';
|
|
2
2
|
import { Message, type Row } from './context/turn/message/message.js';
|
|
3
|
+
import { ToolCall } from './context/turn/message/tool-call.js';
|
|
3
4
|
import { TurnEnd, TurnStart, type Turn } from './context/turn/turn.js';
|
|
4
|
-
import { GoalChange
|
|
5
|
+
import { GoalChange } from './goal/goal.js';
|
|
5
6
|
import { Task, TaskEnd, TaskStart } from './goal/task.js';
|
|
6
7
|
import type { UsageChange, Usage } from './session.js';
|
|
7
8
|
export type SessionData = {
|
|
@@ -17,7 +18,8 @@ export type SessionData = {
|
|
|
17
18
|
readonly agentType?: string;
|
|
18
19
|
};
|
|
19
20
|
export type ContextData = Pick<Context, 'number' | 'openedAt' | 'closedAt' | 'task'>;
|
|
20
|
-
export type TurnData = Pick<Turn, 'prompt' | 'context' | 'openedAt' | 'closedAt'>;
|
|
21
|
+
export type TurnData = Pick<Turn, 'prompt' | 'context' | 'openedAt' | 'closedAt' | 'answer' | 'reason' | 'failure'>;
|
|
22
|
+
export type TurnEnding = Pick<Turn, 'answer' | 'reason' | 'failure'>;
|
|
21
23
|
export type TaskData = Pick<Task, 'id' | 'title' | 'openedBy' | 'openedAt' | 'closedAt'> & {
|
|
22
24
|
readonly agentType: string;
|
|
23
25
|
readonly model?: string;
|
|
@@ -27,7 +29,8 @@ export type RunningTask = TaskData & {
|
|
|
27
29
|
readonly context: number;
|
|
28
30
|
readonly contextOpenedAt?: string;
|
|
29
31
|
};
|
|
30
|
-
export type GoalData =
|
|
32
|
+
export type GoalData = {
|
|
33
|
+
readonly text: string;
|
|
31
34
|
readonly task?: string;
|
|
32
35
|
};
|
|
33
36
|
export type SessionChange = {
|
|
@@ -59,15 +62,19 @@ export type ConversationState = {
|
|
|
59
62
|
readonly endedCalls: Readonly<Record<string, string>>;
|
|
60
63
|
readonly tasks: Readonly<Record<string, RunningTask>>;
|
|
61
64
|
readonly taskTurns: Readonly<Record<string, TurnData>>;
|
|
65
|
+
readonly openCalls?: Readonly<Record<string, OpenCall>>;
|
|
62
66
|
};
|
|
67
|
+
type OpenCall = Pick<ToolCall, 'name' | 'input' | 'cwd'>;
|
|
63
68
|
export type Conversation = {
|
|
64
69
|
add(row: Row, task?: string): SessionChange[];
|
|
65
70
|
startTask(task: TaskData): SessionChange[];
|
|
66
71
|
startContext(at: string): SessionChange[];
|
|
72
|
+
endTurn(at: string, ending: TurnEnding, task?: string): SessionChange[];
|
|
67
73
|
changeGoal(text: string): SessionChange[];
|
|
68
74
|
readonly state: ConversationState;
|
|
69
75
|
};
|
|
70
76
|
export declare const searchLimit = 50;
|
|
71
77
|
export declare function emptyConversation(session: string): ConversationState;
|
|
72
78
|
export declare function createConversation(start: ConversationState): Conversation;
|
|
79
|
+
export {};
|
|
73
80
|
//# sourceMappingURL=conversation.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"conversation.d.ts","sourceRoot":"","sources":["../src/session/conversation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,KAAK,OAAO,EAAE,MAAM,sBAAsB,CAAA;AAC7E,OAAO,EAAE,OAAO,EAA6B,KAAK,GAAG,EAAE,MAAM,mCAAmC,CAAA;
|
|
1
|
+
{"version":3,"file":"conversation.d.ts","sourceRoot":"","sources":["../src/session/conversation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,KAAK,OAAO,EAAE,MAAM,sBAAsB,CAAA;AAC7E,OAAO,EAAE,OAAO,EAA6B,KAAK,GAAG,EAAE,MAAM,mCAAmC,CAAA;AAGhG,OAAO,EAAE,QAAQ,EAAE,MAAM,qCAAqC,CAAA;AAE9D,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,KAAK,IAAI,EAAE,MAAM,wBAAwB,CAAA;AACtE,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAC3C,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AACzD,OAAO,KAAK,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
|
19
19
|
const endedCalls = new Map(Object.entries(start.endedCalls));
|
|
20
20
|
const tasks = new Map(Object.entries(start.tasks));
|
|
21
21
|
const taskTurns = new Map(Object.entries(start.taskTurns));
|
|
22
|
-
const
|
|
22
|
+
const openCalls = new Map(Object.entries(start.openCalls ?? {}));
|
|
23
|
+
const endTaskTurn = (task, at, ending = {}) => {
|
|
23
24
|
const open = taskTurns.get(task);
|
|
24
25
|
if (open === undefined)
|
|
25
26
|
return [];
|
|
26
27
|
taskTurns.delete(task);
|
|
27
|
-
return open.closedAt === undefined ? [{ type: TurnEnd, turn: { ...open, closedAt: at } }] : [];
|
|
28
|
+
return open.closedAt === undefined ? [{ type: TurnEnd, turn: { ...open, ...ending, closedAt: at } }] : [];
|
|
28
29
|
};
|
|
29
30
|
const startContext = (at) => {
|
|
30
31
|
context += 1;
|
|
@@ -43,10 +44,10 @@ export function createConversation(start) {
|
|
|
43
44
|
{ type: ContextStart, context: { number: next.context, openedAt: at, task } },
|
|
44
45
|
];
|
|
45
46
|
};
|
|
46
|
-
const endTurn = (at) => {
|
|
47
|
+
const endTurn = (at, ending = {}) => {
|
|
47
48
|
if (turn === undefined)
|
|
48
49
|
return [];
|
|
49
|
-
const ended = { ...turn, closedAt: at };
|
|
50
|
+
const ended = { ...turn, ...ending, closedAt: at };
|
|
50
51
|
turn = undefined;
|
|
51
52
|
return [{ type: TurnEnd, turn: ended }];
|
|
52
53
|
};
|
|
@@ -95,8 +96,14 @@ export function createConversation(start) {
|
|
|
95
96
|
changes.push(...changeGoal(unplaced.text));
|
|
96
97
|
}
|
|
97
98
|
const open = task === undefined ? turn : taskTurns.get(task);
|
|
99
|
+
const call = unplaced.type === ToolResult ? openCalls.get(unplaced.callId) : undefined;
|
|
100
|
+
if (unplaced.type === ToolCall)
|
|
101
|
+
openCalls.set(unplaced.callId, { name: unplaced.name, input: unplaced.input, cwd: unplaced.cwd });
|
|
102
|
+
if (unplaced.type === ToolResult)
|
|
103
|
+
openCalls.delete(unplaced.callId);
|
|
98
104
|
const placed = {
|
|
99
105
|
...unplaced,
|
|
106
|
+
...call,
|
|
100
107
|
session: start.session,
|
|
101
108
|
context: placedIn,
|
|
102
109
|
...(open === undefined ? {} : { turn: open.prompt.id }),
|
|
@@ -105,7 +112,7 @@ export function createConversation(start) {
|
|
|
105
112
|
changes.push({ type: Message, message: placed });
|
|
106
113
|
if (placed.type === ToolCall && agentTools.includes(placed.name))
|
|
107
114
|
agentCalls.add(placed.callId);
|
|
108
|
-
if (placed.type === ToolResult && agentCalls.has(placed.callId) && !placed.
|
|
115
|
+
if (placed.type === ToolResult && agentCalls.has(placed.callId) && !String(placed.output).startsWith(asyncLaunch))
|
|
109
116
|
changes.push(...endTask(placed.callId, row.at));
|
|
110
117
|
if (placed.type === Note && placed.from.type === Task) {
|
|
111
118
|
const call = tagOf(textOf(row.content), 'tool-use-id');
|
|
@@ -128,6 +135,7 @@ export function createConversation(start) {
|
|
|
128
135
|
return changes;
|
|
129
136
|
},
|
|
130
137
|
startContext,
|
|
138
|
+
endTurn: (at, ending, task) => (task === undefined ? endTurn(at, ending) : endTaskTurn(task, at, ending)),
|
|
131
139
|
changeGoal,
|
|
132
140
|
get state() {
|
|
133
141
|
return {
|
|
@@ -140,6 +148,7 @@ export function createConversation(start) {
|
|
|
140
148
|
endedCalls: Object.fromEntries(endedCalls),
|
|
141
149
|
tasks: Object.fromEntries(tasks),
|
|
142
150
|
taskTurns: Object.fromEntries(taskTurns),
|
|
151
|
+
openCalls: Object.fromEntries(openCalls),
|
|
143
152
|
};
|
|
144
153
|
},
|
|
145
154
|
};
|
package/session/goal/goal.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import type { RecordPart } from '../session.js';
|
|
|
2
2
|
import type { Task } from './task.js';
|
|
3
3
|
export declare const GoalChange = "goalChange";
|
|
4
4
|
export type Goal = RecordPart & {
|
|
5
|
-
|
|
5
|
+
text(): Promise<string>;
|
|
6
6
|
tasks(): Promise<Task[]>;
|
|
7
7
|
update(change: {
|
|
8
8
|
readonly text: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"goal.d.ts","sourceRoot":"","sources":["../../src/session/goal/goal.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAC/C,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAErC,eAAO,MAAM,UAAU,eAAe,CAAA;AAEtC,MAAM,MAAM,IAAI,GAAG,UAAU,GAAG;IAC9B,
|
|
1
|
+
{"version":3,"file":"goal.d.ts","sourceRoot":"","sources":["../../src/session/goal/goal.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAC/C,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAErC,eAAO,MAAM,UAAU,eAAe,CAAA;AAEtC,MAAM,MAAM,IAAI,GAAG,UAAU,GAAG;IAC9B,IAAI,IAAI,OAAO,CAAC,MAAM,CAAC,CAAA;IACvB,KAAK,IAAI,OAAO,CAAC,IAAI,EAAE,CAAC,CAAA;IACxB,MAAM,CAAC,MAAM,EAAE;QAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;CACzD,CAAA"}
|
package/session/goal/task.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import type { Message } from '../context/turn/message/message.js';
|
|
2
|
-
import type { RecordPart,
|
|
2
|
+
import type { RecordPart, TaskOwner } from '../session.js';
|
|
3
3
|
export declare const Task = "task";
|
|
4
4
|
export declare const TaskStart = "taskStart";
|
|
5
5
|
export declare const TaskEnd = "taskEnd";
|
|
6
6
|
export type Task = RecordPart & {
|
|
7
7
|
readonly id: string;
|
|
8
8
|
readonly title: string;
|
|
9
|
-
readonly owner:
|
|
9
|
+
readonly owner: TaskOwner;
|
|
10
10
|
readonly openedBy: string;
|
|
11
11
|
readonly openedAt: string;
|
|
12
12
|
readonly closedAt?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"task.d.ts","sourceRoot":"","sources":["../../src/session/goal/task.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,oCAAoC,CAAA;AACjE,OAAO,KAAK,EAAE,UAAU,EAAE,
|
|
1
|
+
{"version":3,"file":"task.d.ts","sourceRoot":"","sources":["../../src/session/goal/task.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,oCAAoC,CAAA;AACjE,OAAO,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AAE1D,eAAO,MAAM,IAAI,SAAS,CAAA;AAE1B,eAAO,MAAM,SAAS,cAAc,CAAA;AAEpC,eAAO,MAAM,OAAO,YAAY,CAAA;AAEhC,MAAM,MAAM,IAAI,GAAG,UAAU,GAAG;IAC9B,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAA;IACnB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;IACtB,QAAQ,CAAC,KAAK,EAAE,SAAS,CAAA;IACzB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;IACzB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;IACzB,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;IAC1B,KAAK,IAAI,OAAO,CAAC,IAAI,EAAE,CAAC,CAAA;IACxB,QAAQ,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC,CAAA;CAC/B,CAAA"}
|