@layernorm/overlay-agent-host 0.5.0 → 0.7.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/README.md +13 -6
- package/dist/cli.js +10 -3
- package/dist/cli.js.map +1 -1
- package/dist/host-capabilities.d.ts +1 -1
- package/dist/host-capabilities.js +1 -1
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -1
- package/dist/private-threads-context.d.ts +30 -0
- package/dist/private-threads-context.d.ts.map +1 -0
- package/dist/private-threads-context.js +75 -0
- package/dist/private-threads-context.js.map +1 -0
- package/dist/private-threads-ipc.d.ts +7 -0
- package/dist/private-threads-ipc.d.ts.map +1 -0
- package/dist/private-threads-ipc.js +45 -0
- package/dist/private-threads-ipc.js.map +1 -0
- package/dist/private-threads-models.d.ts +11 -0
- package/dist/private-threads-models.d.ts.map +1 -0
- package/dist/private-threads-models.js +44 -0
- package/dist/private-threads-models.js.map +1 -0
- package/dist/private-threads-overlay-tools.d.ts +27 -0
- package/dist/private-threads-overlay-tools.d.ts.map +1 -0
- package/dist/private-threads-overlay-tools.js +56 -0
- package/dist/private-threads-overlay-tools.js.map +1 -0
- package/dist/private-threads-protocol.d.ts +187 -0
- package/dist/private-threads-protocol.d.ts.map +1 -0
- package/dist/private-threads-protocol.js +66 -0
- package/dist/private-threads-protocol.js.map +1 -0
- package/dist/private-threads-store.d.ts +22 -0
- package/dist/private-threads-store.d.ts.map +1 -0
- package/dist/private-threads-store.js +113 -0
- package/dist/private-threads-store.js.map +1 -0
- package/dist/private-threads-tools.d.ts +18 -0
- package/dist/private-threads-tools.d.ts.map +1 -0
- package/dist/private-threads-tools.js +150 -0
- package/dist/private-threads-tools.js.map +1 -0
- package/dist/private-threads.d.ts +49 -0
- package/dist/private-threads.d.ts.map +1 -0
- package/dist/private-threads.js +287 -0
- package/dist/private-threads.js.map +1 -0
- package/package.json +10 -3
- package/systemd/overlay-agent-host.service +1 -1
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
import type { UIMessage, UIMessageChunk } from 'ai';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
/**
|
|
4
|
+
* The private-thread service speaks this protocol with Overlay Desktop over the
|
|
5
|
+
* Node.js IPC channel of `overlay-agent-host private`. Nothing here goes to the network:
|
|
6
|
+
* the only outbound calls are to the model provider the person chose.
|
|
7
|
+
*/
|
|
8
|
+
export declare const PRIVATE_THREADS_PROTOCOL_VERSION: 1;
|
|
9
|
+
export type PrivateUIMessage = UIMessage;
|
|
10
|
+
export type PrivateThreadOwner = {
|
|
11
|
+
userId: string;
|
|
12
|
+
workspaceId: string;
|
|
13
|
+
};
|
|
14
|
+
export type PrivateThread = PrivateThreadOwner & {
|
|
15
|
+
id: string;
|
|
16
|
+
agentId: string;
|
|
17
|
+
title: string;
|
|
18
|
+
folder: string | null;
|
|
19
|
+
/** `provider/model`, for example `anthropic/claude-sonnet-4-5`. */
|
|
20
|
+
model: string | null;
|
|
21
|
+
createdAt: number;
|
|
22
|
+
updatedAt: number;
|
|
23
|
+
};
|
|
24
|
+
export declare const privateModelProviders: readonly ["anthropic", "openai", "google", "openrouter"];
|
|
25
|
+
export type PrivateModelProvider = (typeof privateModelProviders)[number];
|
|
26
|
+
export declare const privateRequestSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
27
|
+
method: z.ZodLiteral<"list">;
|
|
28
|
+
owner: z.ZodObject<{
|
|
29
|
+
userId: z.ZodString;
|
|
30
|
+
workspaceId: z.ZodString;
|
|
31
|
+
}, z.core.$strict>;
|
|
32
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
33
|
+
method: z.ZodLiteral<"get">;
|
|
34
|
+
owner: z.ZodObject<{
|
|
35
|
+
userId: z.ZodString;
|
|
36
|
+
workspaceId: z.ZodString;
|
|
37
|
+
}, z.core.$strict>;
|
|
38
|
+
threadId: z.ZodString;
|
|
39
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
40
|
+
method: z.ZodLiteral<"create">;
|
|
41
|
+
owner: z.ZodObject<{
|
|
42
|
+
userId: z.ZodString;
|
|
43
|
+
workspaceId: z.ZodString;
|
|
44
|
+
}, z.core.$strict>;
|
|
45
|
+
threadId: z.ZodString;
|
|
46
|
+
agentId: z.ZodString;
|
|
47
|
+
title: z.ZodString;
|
|
48
|
+
folder: z.ZodNullable<z.ZodString>;
|
|
49
|
+
model: z.ZodNullable<z.ZodString>;
|
|
50
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
51
|
+
method: z.ZodLiteral<"send">;
|
|
52
|
+
owner: z.ZodObject<{
|
|
53
|
+
userId: z.ZodString;
|
|
54
|
+
workspaceId: z.ZodString;
|
|
55
|
+
}, z.core.$strict>;
|
|
56
|
+
threadId: z.ZodString;
|
|
57
|
+
turnId: z.ZodString;
|
|
58
|
+
messages: z.ZodArray<z.ZodCustom<PrivateUIMessage, PrivateUIMessage>>;
|
|
59
|
+
model: z.ZodObject<{
|
|
60
|
+
provider: z.ZodEnum<{
|
|
61
|
+
anthropic: "anthropic";
|
|
62
|
+
openai: "openai";
|
|
63
|
+
google: "google";
|
|
64
|
+
openrouter: "openrouter";
|
|
65
|
+
}>;
|
|
66
|
+
modelId: z.ZodString;
|
|
67
|
+
apiKey: z.ZodString;
|
|
68
|
+
}, z.core.$strict>;
|
|
69
|
+
agent: z.ZodObject<{
|
|
70
|
+
name: z.ZodString;
|
|
71
|
+
instructions: z.ZodOptional<z.ZodString>;
|
|
72
|
+
}, z.core.$strict>;
|
|
73
|
+
roots: z.ZodArray<z.ZodString>;
|
|
74
|
+
approvalMode: z.ZodDefault<z.ZodEnum<{
|
|
75
|
+
auto: "auto";
|
|
76
|
+
ask: "ask";
|
|
77
|
+
}>>;
|
|
78
|
+
overlay: z.ZodOptional<z.ZodObject<{
|
|
79
|
+
url: z.ZodString;
|
|
80
|
+
token: z.ZodString;
|
|
81
|
+
}, z.core.$strict>>;
|
|
82
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
83
|
+
method: z.ZodLiteral<"stop">;
|
|
84
|
+
owner: z.ZodObject<{
|
|
85
|
+
userId: z.ZodString;
|
|
86
|
+
workspaceId: z.ZodString;
|
|
87
|
+
}, z.core.$strict>;
|
|
88
|
+
threadId: z.ZodString;
|
|
89
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
90
|
+
method: z.ZodLiteral<"update">;
|
|
91
|
+
owner: z.ZodObject<{
|
|
92
|
+
userId: z.ZodString;
|
|
93
|
+
workspaceId: z.ZodString;
|
|
94
|
+
}, z.core.$strict>;
|
|
95
|
+
threadId: z.ZodString;
|
|
96
|
+
title: z.ZodOptional<z.ZodString>;
|
|
97
|
+
folder: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
98
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
99
|
+
method: z.ZodLiteral<"delete">;
|
|
100
|
+
owner: z.ZodObject<{
|
|
101
|
+
userId: z.ZodString;
|
|
102
|
+
workspaceId: z.ZodString;
|
|
103
|
+
}, z.core.$strict>;
|
|
104
|
+
threadId: z.ZodString;
|
|
105
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
106
|
+
method: z.ZodLiteral<"models">;
|
|
107
|
+
provider: z.ZodEnum<{
|
|
108
|
+
anthropic: "anthropic";
|
|
109
|
+
openai: "openai";
|
|
110
|
+
google: "google";
|
|
111
|
+
openrouter: "openrouter";
|
|
112
|
+
}>;
|
|
113
|
+
apiKey: z.ZodString;
|
|
114
|
+
}, z.core.$strict>], "method">;
|
|
115
|
+
export type PrivateRequest = z.input<typeof privateRequestSchema>;
|
|
116
|
+
export type ParsedPrivateRequest = z.output<typeof privateRequestSchema>;
|
|
117
|
+
export type PrivateResults = {
|
|
118
|
+
list: {
|
|
119
|
+
threads: PrivateThread[];
|
|
120
|
+
running: string[];
|
|
121
|
+
};
|
|
122
|
+
get: {
|
|
123
|
+
thread: PrivateThread;
|
|
124
|
+
messages: PrivateUIMessage[];
|
|
125
|
+
running: boolean;
|
|
126
|
+
};
|
|
127
|
+
create: {
|
|
128
|
+
thread: PrivateThread;
|
|
129
|
+
};
|
|
130
|
+
send: {
|
|
131
|
+
turnId: string;
|
|
132
|
+
};
|
|
133
|
+
stop: {
|
|
134
|
+
stopped: boolean;
|
|
135
|
+
};
|
|
136
|
+
update: {
|
|
137
|
+
thread: PrivateThread;
|
|
138
|
+
};
|
|
139
|
+
delete: {
|
|
140
|
+
deleted: boolean;
|
|
141
|
+
};
|
|
142
|
+
models: {
|
|
143
|
+
models: {
|
|
144
|
+
id: string;
|
|
145
|
+
name: string;
|
|
146
|
+
}[];
|
|
147
|
+
};
|
|
148
|
+
};
|
|
149
|
+
export type PrivateTurnState = 'running' | 'finished' | 'stopped' | 'error';
|
|
150
|
+
export type PrivateEvent = {
|
|
151
|
+
kind: 'chunk';
|
|
152
|
+
threadId: string;
|
|
153
|
+
turnId: string;
|
|
154
|
+
chunk: UIMessageChunk;
|
|
155
|
+
} | {
|
|
156
|
+
kind: 'turn';
|
|
157
|
+
threadId: string;
|
|
158
|
+
turnId: string;
|
|
159
|
+
state: PrivateTurnState;
|
|
160
|
+
error?: string;
|
|
161
|
+
} | {
|
|
162
|
+
kind: 'threads';
|
|
163
|
+
owner: PrivateThreadOwner;
|
|
164
|
+
};
|
|
165
|
+
export type PrivateIpcInbound = {
|
|
166
|
+
type: 'request';
|
|
167
|
+
id: number;
|
|
168
|
+
request: PrivateRequest;
|
|
169
|
+
};
|
|
170
|
+
export type PrivateIpcOutbound = {
|
|
171
|
+
type: 'ready';
|
|
172
|
+
protocolVersion: typeof PRIVATE_THREADS_PROTOCOL_VERSION;
|
|
173
|
+
} | {
|
|
174
|
+
type: 'response';
|
|
175
|
+
id: number;
|
|
176
|
+
ok: true;
|
|
177
|
+
result: unknown;
|
|
178
|
+
} | {
|
|
179
|
+
type: 'response';
|
|
180
|
+
id: number;
|
|
181
|
+
ok: false;
|
|
182
|
+
error: string;
|
|
183
|
+
} | {
|
|
184
|
+
type: 'event';
|
|
185
|
+
event: PrivateEvent;
|
|
186
|
+
};
|
|
187
|
+
//# sourceMappingURL=private-threads-protocol.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"private-threads-protocol.d.ts","sourceRoot":"","sources":["../src/private-threads-protocol.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,IAAI,CAAA;AAEnD,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB;;;;GAIG;AACH,eAAO,MAAM,gCAAgC,EAAG,CAAU,CAAA;AAE1D,MAAM,MAAM,gBAAgB,GAAG,SAAS,CAAA;AACxC,MAAM,MAAM,kBAAkB,GAAG;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,MAAM,CAAA;CAAE,CAAA;AACxE,MAAM,MAAM,aAAa,GAAG,kBAAkB,GAAG;IAC/C,EAAE,EAAE,MAAM,CAAA;IACV,OAAO,EAAE,MAAM,CAAA;IACf,KAAK,EAAE,MAAM,CAAA;IACb,MAAM,EAAE,MAAM,GAAG,IAAI,CAAA;IACrB,mEAAmE;IACnE,KAAK,EAAE,MAAM,GAAG,IAAI,CAAA;IACpB,SAAS,EAAE,MAAM,CAAA;IACjB,SAAS,EAAE,MAAM,CAAA;CAClB,CAAA;AAED,eAAO,MAAM,qBAAqB,0DAA2D,CAAA;AAC7F,MAAM,MAAM,oBAAoB,GAAG,CAAC,OAAO,qBAAqB,CAAC,CAAC,MAAM,CAAC,CAAA;AAMzE,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;8BAoD/B,CAAA;AACF,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAA;AACjE,MAAM,MAAM,oBAAoB,GAAG,CAAC,C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AAE,CAAA;AAElD,MAAM,MAAM,iBAAiB,GAAG;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,EAAE,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,cAAc,CAAA;CAAE,CAAA;AACxF,MAAM,MAAM,kBAAkB,GAC1B;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,eAAe,EAAE,OAAO,gCAAgC,CAAA;CAAE,GAC3E;IAAE,IAAI,EAAE,UAAU,CAAC;IAAC,EAAE,EAAE,MAAM,CAAC;IAAC,EAAE,EAAE,IAAI,CAAC;IAAC,MAAM,EAAE,OAAO,CAAA;CAAE,GAC3D;IAAE,IAAI,EAAE,UAAU,CAAC;IAAC,EAAE,EAAE,MAAM,CAAC;IAAC,EAAE,EAAE,KAAK,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GAC1D;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,KAAK,EAAE,YAAY,CAAA;CAAE,CAAA"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { isAbsolute } from 'node:path';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
/**
|
|
4
|
+
* The private-thread service speaks this protocol with Overlay Desktop over the
|
|
5
|
+
* Node.js IPC channel of `overlay-agent-host private`. Nothing here goes to the network:
|
|
6
|
+
* the only outbound calls are to the model provider the person chose.
|
|
7
|
+
*/
|
|
8
|
+
export const PRIVATE_THREADS_PROTOCOL_VERSION = 1;
|
|
9
|
+
export const privateModelProviders = ['anthropic', 'openai', 'google', 'openrouter'];
|
|
10
|
+
const id = z.string().trim().min(1).max(200);
|
|
11
|
+
const owner = z.object({ userId: id, workspaceId: id }).strict();
|
|
12
|
+
const folder = z.string().trim().min(1).max(4096).refine(isAbsolute, 'Folders must be absolute paths.');
|
|
13
|
+
export const privateRequestSchema = z.discriminatedUnion('method', [
|
|
14
|
+
z.object({ method: z.literal('list'), owner }).strict(),
|
|
15
|
+
z.object({ method: z.literal('get'), owner, threadId: id }).strict(),
|
|
16
|
+
z.object({
|
|
17
|
+
method: z.literal('create'),
|
|
18
|
+
owner,
|
|
19
|
+
threadId: id,
|
|
20
|
+
agentId: id,
|
|
21
|
+
title: z.string().trim().min(1).max(200),
|
|
22
|
+
folder: folder.nullable(),
|
|
23
|
+
model: z.string().trim().min(1).max(200).nullable(),
|
|
24
|
+
}).strict(),
|
|
25
|
+
z.object({
|
|
26
|
+
method: z.literal('send'),
|
|
27
|
+
owner,
|
|
28
|
+
threadId: id,
|
|
29
|
+
turnId: id,
|
|
30
|
+
/** The whole transcript as the page holds it, ending with the new user message or approval answers. */
|
|
31
|
+
messages: z.array(z.custom(value => Boolean(value && typeof value === 'object'))).min(1).max(2_000),
|
|
32
|
+
model: z.object({
|
|
33
|
+
provider: z.enum(privateModelProviders),
|
|
34
|
+
modelId: z.string().trim().min(1).max(200),
|
|
35
|
+
/** Read from the Keychain by Overlay Desktop for this run; never stored by the host. */
|
|
36
|
+
apiKey: z.string().min(1).max(4_096),
|
|
37
|
+
}).strict(),
|
|
38
|
+
agent: z.object({
|
|
39
|
+
name: z.string().trim().min(1).max(200),
|
|
40
|
+
instructions: z.string().max(50_000).optional(),
|
|
41
|
+
}).strict(),
|
|
42
|
+
/** The folders this run may use: the thread's folder, or the person's work folder. */
|
|
43
|
+
roots: z.array(folder).min(1).max(20),
|
|
44
|
+
approvalMode: z.enum(['ask', 'auto']).default('ask'),
|
|
45
|
+
/**
|
|
46
|
+
* The agent's Overlay tools for this turn: Overlay's MCP server and a short-lived token Overlay Desktop got for
|
|
47
|
+
* this person, workspace and agent. Absent when the desktop could not get one; the turn then has only this
|
|
48
|
+
* computer's tools.
|
|
49
|
+
*/
|
|
50
|
+
overlay: z.object({
|
|
51
|
+
url: z.string().url().max(2_048).refine(value => /^https:\/\/|^http:\/\/(localhost|127\.0\.0\.1)(:|\/)/.test(value), 'Overlay tools need https.'),
|
|
52
|
+
token: z.string().min(1).max(4_096),
|
|
53
|
+
}).strict().optional(),
|
|
54
|
+
}).strict(),
|
|
55
|
+
z.object({ method: z.literal('stop'), owner, threadId: id }).strict(),
|
|
56
|
+
z.object({
|
|
57
|
+
method: z.literal('update'), owner, threadId: id,
|
|
58
|
+
title: z.string().trim().min(1).max(200).optional(),
|
|
59
|
+
/** Only before the first message; null works in the person's work folder. */
|
|
60
|
+
folder: folder.nullable().optional(),
|
|
61
|
+
}).strict(),
|
|
62
|
+
z.object({ method: z.literal('delete'), owner, threadId: id }).strict(),
|
|
63
|
+
/** Checks a key and lists the chat models it can use. */
|
|
64
|
+
z.object({ method: z.literal('models'), provider: z.enum(privateModelProviders), apiKey: z.string().min(1).max(4_096) }).strict(),
|
|
65
|
+
]);
|
|
66
|
+
//# sourceMappingURL=private-threads-protocol.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"private-threads-protocol.js","sourceRoot":"","sources":["../src/private-threads-protocol.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAA;AACtC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB;;;;GAIG;AACH,MAAM,CAAC,MAAM,gCAAgC,GAAG,CAAU,CAAA;AAe1D,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,WAAW,EAAE,QAAQ,EAAE,QAAQ,EAAE,YAAY,CAAU,CAAA;AAG7F,MAAM,EAAE,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;AAC5C,MAAM,KAAK,GAAG,CAAC,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,WAAW,EAAE,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE,CAAA;AAChE,MAAM,MAAM,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,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C,GAAG,CAAC,KAAK,CAAC;SACpC,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;KACvB,CAAC,CAAC,MAAM,EAAE;IACX,CAAC,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE;IACrE,CAAC,CAAC,MAAM,CAAC;QACP,MAAM,EAAE,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE;QAChD,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE;QACnD,6EAA6E;QAC7E,MAAM,EAAE,MAAM,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE;KACrC,CAAC,CAAC,MAAM,EAAE;IACX,CAAC,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE;IACvE,yDAAyD;IACzD,CAAC,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,QAAQ,EAAE,CAAC,CAAC,IAAI,CAAC,qBAAqB,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,MAAM,EAAE;CAClI,CAAC,CAAA"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { ThreadSummary } from './private-threads-context.js';
|
|
2
|
+
import type { PrivateThread, PrivateThreadOwner, PrivateUIMessage } from './private-threads-protocol.js';
|
|
3
|
+
/**
|
|
4
|
+
* Private threads are stored only on this computer, in one SQLite file in the
|
|
5
|
+
* app's support folder. Messages are AI SDK UI messages, saved after every step.
|
|
6
|
+
*/
|
|
7
|
+
export declare class PrivateThreadStore {
|
|
8
|
+
private readonly db;
|
|
9
|
+
constructor(path: string);
|
|
10
|
+
summary(id: string): ThreadSummary | null;
|
|
11
|
+
saveSummary(id: string, summary: ThreadSummary): void;
|
|
12
|
+
list(owner: PrivateThreadOwner): PrivateThread[];
|
|
13
|
+
get(owner: PrivateThreadOwner, id: string): PrivateThread | null;
|
|
14
|
+
create(thread: PrivateThread): PrivateThread;
|
|
15
|
+
update(owner: PrivateThreadOwner, id: string, patch: Partial<Pick<PrivateThread, 'title' | 'model' | 'folder'>>): PrivateThread | null;
|
|
16
|
+
delete(owner: PrivateThreadOwner, id: string): boolean;
|
|
17
|
+
messages(id: string): PrivateUIMessage[];
|
|
18
|
+
/** Replaces the whole transcript in one transaction, so a crash leaves the last complete step. */
|
|
19
|
+
saveMessages(id: string, messages: PrivateUIMessage[]): void;
|
|
20
|
+
close(): void;
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=private-threads-store.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"private-threads-store.d.ts","sourceRoot":"","sources":["../src/private-threads-store.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAA;AACjE,OAAO,KAAK,EAAE,aAAa,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAA;AAExG;;;GAGG;AACH,qBAAa,kBAAkB;IAC7B,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAc;gBAErB,IAAI,EAAE,MAAM;IAgCxB,OAAO,CAAC,EAAE,EAAE,MAAM,GAAG,aAAa,GAAG,IAAI;IAMzC,WAAW,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,aAAa,GAAG,IAAI;IAIrD,IAAI,CAAC,KAAK,EAAE,kBAAkB,GAAG,aAAa,EAAE;IAMhD,GAAG,CAAC,KAAK,EAAE,kBAAkB,EAAE,EAAE,EAAE,MAAM,GAAG,aAAa,GAAG,IAAI;IAMhE,MAAM,CAAC,MAAM,EAAE,aAAa,GAAG,aAAa;IAS5C,MAAM,CAAC,KAAK,EAAE,kBAAkB,EAAE,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,CAAC,IAAI,CAAC,aAAa,EAAE,OAAO,GAAG,OAAO,GAAG,QAAQ,CAAC,CAAC,GAAG,aAAa,GAAG,IAAI;IAStI,MAAM,CAAC,KAAK,EAAE,kBAAkB,EAAE,EAAE,EAAE,MAAM,GAAG,OAAO;IAKtD,QAAQ,CAAC,EAAE,EAAE,MAAM,GAAG,gBAAgB,EAAE;IAKxC,kGAAkG;IAClG,YAAY,CAAC,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,gBAAgB,EAAE,GAAG,IAAI;IAc5D,KAAK,IAAI,IAAI;CAGd"}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { mkdirSync } from 'node:fs';
|
|
2
|
+
import { dirname } from 'node:path';
|
|
3
|
+
import { DatabaseSync } from 'node:sqlite';
|
|
4
|
+
/**
|
|
5
|
+
* Private threads are stored only on this computer, in one SQLite file in the
|
|
6
|
+
* app's support folder. Messages are AI SDK UI messages, saved after every step.
|
|
7
|
+
*/
|
|
8
|
+
export class PrivateThreadStore {
|
|
9
|
+
db;
|
|
10
|
+
constructor(path) {
|
|
11
|
+
if (path !== ':memory:')
|
|
12
|
+
mkdirSync(dirname(path), { recursive: true, mode: 0o700 });
|
|
13
|
+
this.db = new DatabaseSync(path);
|
|
14
|
+
this.db.exec(`
|
|
15
|
+
PRAGMA journal_mode = WAL;
|
|
16
|
+
PRAGMA foreign_keys = ON;
|
|
17
|
+
CREATE TABLE IF NOT EXISTS threads (
|
|
18
|
+
id TEXT PRIMARY KEY,
|
|
19
|
+
user_id TEXT NOT NULL,
|
|
20
|
+
workspace_id TEXT NOT NULL,
|
|
21
|
+
agent_id TEXT NOT NULL,
|
|
22
|
+
title TEXT NOT NULL,
|
|
23
|
+
folder TEXT,
|
|
24
|
+
model TEXT,
|
|
25
|
+
created_at INTEGER NOT NULL,
|
|
26
|
+
updated_at INTEGER NOT NULL
|
|
27
|
+
);
|
|
28
|
+
CREATE INDEX IF NOT EXISTS threads_owner ON threads (user_id, workspace_id, updated_at);
|
|
29
|
+
CREATE TABLE IF NOT EXISTS messages (
|
|
30
|
+
thread_id TEXT NOT NULL REFERENCES threads(id) ON DELETE CASCADE,
|
|
31
|
+
position INTEGER NOT NULL,
|
|
32
|
+
id TEXT NOT NULL,
|
|
33
|
+
body TEXT NOT NULL,
|
|
34
|
+
PRIMARY KEY (thread_id, position)
|
|
35
|
+
);
|
|
36
|
+
`);
|
|
37
|
+
// Added in 0.7.0: the summary of a thread's older messages (private-threads-context.ts).
|
|
38
|
+
const columns = new Set(this.db.prepare('PRAGMA table_info(threads)').all().map(column => column.name));
|
|
39
|
+
if (!columns.has('summary'))
|
|
40
|
+
this.db.exec('ALTER TABLE threads ADD COLUMN summary TEXT');
|
|
41
|
+
if (!columns.has('summary_through'))
|
|
42
|
+
this.db.exec('ALTER TABLE threads ADD COLUMN summary_through TEXT');
|
|
43
|
+
}
|
|
44
|
+
summary(id) {
|
|
45
|
+
const row = this.db.prepare('SELECT summary, summary_through FROM threads WHERE id = ?').get(id);
|
|
46
|
+
return row?.summary ? { summary: row.summary, throughMessageId: row.summary_through } : null;
|
|
47
|
+
}
|
|
48
|
+
saveSummary(id, summary) {
|
|
49
|
+
this.db.prepare('UPDATE threads SET summary = ?, summary_through = ? WHERE id = ?').run(summary.summary, summary.throughMessageId, id);
|
|
50
|
+
}
|
|
51
|
+
list(owner) {
|
|
52
|
+
return this.db.prepare('SELECT * FROM threads WHERE user_id = ? AND workspace_id = ? ORDER BY updated_at DESC LIMIT 500').all(owner.userId, owner.workspaceId).map(toThread);
|
|
53
|
+
}
|
|
54
|
+
get(owner, id) {
|
|
55
|
+
const row = this.db.prepare('SELECT * FROM threads WHERE id = ? AND user_id = ? AND workspace_id = ?')
|
|
56
|
+
.get(id, owner.userId, owner.workspaceId);
|
|
57
|
+
return row ? toThread(row) : null;
|
|
58
|
+
}
|
|
59
|
+
create(thread) {
|
|
60
|
+
this.db.prepare(`INSERT INTO threads (id, user_id, workspace_id, agent_id, title, folder, model, created_at, updated_at)
|
|
61
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)`).run(thread.id, thread.userId, thread.workspaceId, thread.agentId, thread.title, thread.folder, thread.model, thread.createdAt, thread.updatedAt);
|
|
62
|
+
return thread;
|
|
63
|
+
}
|
|
64
|
+
update(owner, id, patch) {
|
|
65
|
+
const current = this.get(owner, id);
|
|
66
|
+
if (!current)
|
|
67
|
+
return null;
|
|
68
|
+
const next = { ...current, ...patch, updatedAt: Date.now() };
|
|
69
|
+
this.db.prepare('UPDATE threads SET title = ?, model = ?, folder = ?, updated_at = ? WHERE id = ?')
|
|
70
|
+
.run(next.title, next.model, next.folder, next.updatedAt, id);
|
|
71
|
+
return next;
|
|
72
|
+
}
|
|
73
|
+
delete(owner, id) {
|
|
74
|
+
return Number(this.db.prepare('DELETE FROM threads WHERE id = ? AND user_id = ? AND workspace_id = ?')
|
|
75
|
+
.run(id, owner.userId, owner.workspaceId).changes) > 0;
|
|
76
|
+
}
|
|
77
|
+
messages(id) {
|
|
78
|
+
return this.db.prepare('SELECT body FROM messages WHERE thread_id = ? ORDER BY position').all(id)
|
|
79
|
+
.map(row => JSON.parse(row.body));
|
|
80
|
+
}
|
|
81
|
+
/** Replaces the whole transcript in one transaction, so a crash leaves the last complete step. */
|
|
82
|
+
saveMessages(id, messages) {
|
|
83
|
+
this.db.exec('BEGIN IMMEDIATE');
|
|
84
|
+
try {
|
|
85
|
+
this.db.prepare('DELETE FROM messages WHERE thread_id = ?').run(id);
|
|
86
|
+
const insert = this.db.prepare('INSERT INTO messages (thread_id, position, id, body) VALUES (?, ?, ?, ?)');
|
|
87
|
+
messages.forEach((message, position) => insert.run(id, position, message.id, JSON.stringify(message)));
|
|
88
|
+
this.db.prepare('UPDATE threads SET updated_at = ? WHERE id = ?').run(Date.now(), id);
|
|
89
|
+
this.db.exec('COMMIT');
|
|
90
|
+
}
|
|
91
|
+
catch (error) {
|
|
92
|
+
this.db.exec('ROLLBACK');
|
|
93
|
+
throw error;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
close() {
|
|
97
|
+
this.db.close();
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
function toThread(row) {
|
|
101
|
+
return {
|
|
102
|
+
id: row.id,
|
|
103
|
+
userId: row.user_id,
|
|
104
|
+
workspaceId: row.workspace_id,
|
|
105
|
+
agentId: row.agent_id,
|
|
106
|
+
title: row.title,
|
|
107
|
+
folder: row.folder,
|
|
108
|
+
model: row.model,
|
|
109
|
+
createdAt: Number(row.created_at),
|
|
110
|
+
updatedAt: Number(row.updated_at),
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
//# sourceMappingURL=private-threads-store.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"private-threads-store.js","sourceRoot":"","sources":["../src/private-threads-store.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA;AACnC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAI1C;;;GAGG;AACH,MAAM,OAAO,kBAAkB;IACZ,EAAE,CAAc;IAEjC,YAAY,IAAY;QACtB,IAAI,IAAI,KAAK,UAAU;YAAE,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAA;QACnF,IAAI,CAAC,EAAE,GAAG,IAAI,YAAY,CAAC,IAAI,CAAC,CAAA;QA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AAK,CAAA;QACb,CAAC;IACH,CAAC;IAED,KAAK;QACH,IAAI,CAAC,EAAE,CAAC,KAAK,EAAE,CAAA;IACjB,CAAC;CACF;AAcD,SAAS,QAAQ,CAAC,GAAc;IAC9B,OAAO;QACL,EAAE,EAAE,GAAG,CAAC,EAAE;QACV,MAAM,EAAE,GAAG,CAAC,OAAO;QACnB,WAAW,EAAE,GAAG,CAAC,YAAY;QAC7B,OAAO,EAAE,GAAG,CAAC,QAAQ;QACrB,KAAK,EAAE,GAAG,CAAC,KAAK;QAChB,MAAM,EAAE,GAAG,CAAC,MAAM;QAClB,KAAK,EAAE,GAAG,CAAC,KAAK;QAChB,SAAS,EAAE,MAAM,CAAC,GAAG,CAAC,UAAU,CAAC;QACjC,SAAS,EAAE,MAAM,CAAC,GAAG,CAAC,UAAU,CAAC;KAClC,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { type ToolSet } from 'ai';
|
|
2
|
+
import type { LocalToolExecutor } from './local-tools.js';
|
|
3
|
+
/**
|
|
4
|
+
* The computer tools of a private thread. Names, inputs, approval rules and browser result text come from the bridge
|
|
5
|
+
* protocol (`computer-tools.ts`), which the cloud tools use too, so tool rows and approval cards look the same; the
|
|
6
|
+
* calls run in this process through the same LocalToolExecutor that serves synced threads on this computer.
|
|
7
|
+
*
|
|
8
|
+
* Screen control (screenshots and input) is macOS only, like the host's driver; the browser needs Chrome, Chromium,
|
|
9
|
+
* Brave or Edge on macOS or Linux.
|
|
10
|
+
*/
|
|
11
|
+
export declare function privateComputerTools(options: {
|
|
12
|
+
executor: LocalToolExecutor;
|
|
13
|
+
approvalMode: 'ask' | 'auto';
|
|
14
|
+
abortSignal: AbortSignal;
|
|
15
|
+
platform?: NodeJS.Platform;
|
|
16
|
+
}): ToolSet;
|
|
17
|
+
export declare const SCREENSHOT_NOT_KEPT = "An earlier screenshot; its image is not kept. Take a new one to see the screen.";
|
|
18
|
+
//# sourceMappingURL=private-threads-tools.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"private-threads-tools.d.ts","sourceRoot":"","sources":["../src/private-threads-tools.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,KAAK,OAAO,EAAE,MAAM,IAAI,CAAA;AAmBvC,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAA;AAEzD;;;;;;;GAOG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE;IAC5C,QAAQ,EAAE,iBAAiB,CAAA;IAC3B,YAAY,EAAE,KAAK,GAAG,MAAM,CAAA;IAC5B,WAAW,EAAE,WAAW,CAAA;IACxB,QAAQ,CAAC,EAAE,MAAM,CAAC,QAAQ,CAAA;CAC3B,GAAG,OAAO,CAiJV;AAED,eAAO,MAAM,mBAAmB,oFAAoF,CAAA"}
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import { tool } from 'ai';
|
|
2
|
+
import { z } from 'zod/v3';
|
|
3
|
+
import { browserActionText, computerBrowserFields, computerBrowserUrlSchema, computerBrowserVariants, computerInputDriverCommand, computerInputFields, computerInputVariants, computerTerminalFields, computerTerminalVariants, computerToolInputSchema, computerToolRequiresApproval, } from '@layernorm/overlay-agent-bridge-protocol';
|
|
4
|
+
/**
|
|
5
|
+
* The computer tools of a private thread. Names, inputs, approval rules and browser result text come from the bridge
|
|
6
|
+
* protocol (`computer-tools.ts`), which the cloud tools use too, so tool rows and approval cards look the same; the
|
|
7
|
+
* calls run in this process through the same LocalToolExecutor that serves synced threads on this computer.
|
|
8
|
+
*
|
|
9
|
+
* Screen control (screenshots and input) is macOS only, like the host's driver; the browser needs Chrome, Chromium,
|
|
10
|
+
* Brave or Edge on macOS or Linux.
|
|
11
|
+
*/
|
|
12
|
+
export function privateComputerTools(options) {
|
|
13
|
+
const platform = options.platform ?? process.platform;
|
|
14
|
+
const needsApproval = (toolName) => (input) => options.approvalMode === 'ask' && computerToolRequiresApproval(toolName, input);
|
|
15
|
+
const run = async (request, timeoutMs = 120_000) => {
|
|
16
|
+
const now = Date.now();
|
|
17
|
+
const call = {
|
|
18
|
+
protocolVersion: 1,
|
|
19
|
+
callId: `private-${now.toString(36)}-${Math.random().toString(36).slice(2, 10)}`,
|
|
20
|
+
environmentId: 'private',
|
|
21
|
+
workspaceId: 'private',
|
|
22
|
+
issuedAt: now,
|
|
23
|
+
deadlineAt: now + timeoutMs,
|
|
24
|
+
request,
|
|
25
|
+
};
|
|
26
|
+
const outcome = await options.executor.execute(call, AbortSignal.any([options.abortSignal, AbortSignal.timeout(timeoutMs)]));
|
|
27
|
+
return outcome.ok ? outcome.result : { error: outcome.error.code, message: outcome.error.message };
|
|
28
|
+
};
|
|
29
|
+
const driver = async (command, args = {}) => await run({ kind: 'driver', command, args });
|
|
30
|
+
const tools = {
|
|
31
|
+
computer_exec: tool({
|
|
32
|
+
description: 'Run a shell command on this computer, in the thread\'s folder unless cwd says otherwise. ' +
|
|
33
|
+
'Use for builds, scripts, tests, git and package installs. Output is truncated; prefer targeted commands over dumps.',
|
|
34
|
+
inputSchema: z.object({
|
|
35
|
+
command: z.string().min(1).max(100_000).describe('Full shell command to run'),
|
|
36
|
+
cwd: z.string().max(4096).optional().describe('Absolute working directory for the command'),
|
|
37
|
+
timeoutMs: z.number().int().min(5_000).max(300_000).optional().describe('Max run time in ms (default 60s, max 5m)'),
|
|
38
|
+
}),
|
|
39
|
+
needsApproval: needsApproval('computer_exec'),
|
|
40
|
+
execute: async ({ command, cwd, timeoutMs }) => {
|
|
41
|
+
const limit = timeoutMs ?? 60_000;
|
|
42
|
+
return await run({ kind: 'exec', command, ...(cwd ? { cwd } : {}), timeoutMs: limit }, limit + 5_000);
|
|
43
|
+
},
|
|
44
|
+
}),
|
|
45
|
+
computer_read_file: tool({
|
|
46
|
+
description: 'Read a text file on this computer (up to 256KB).',
|
|
47
|
+
inputSchema: z.object({ path: z.string().min(1).max(4096).describe('Absolute path of the file to read') }),
|
|
48
|
+
execute: async ({ path }) => await run({ kind: 'read_file', path, maxBytes: 256 * 1024 }),
|
|
49
|
+
}),
|
|
50
|
+
computer_write_file: tool({
|
|
51
|
+
description: 'Write text contents to a file on this computer, creating or overwriting it.',
|
|
52
|
+
inputSchema: z.object({
|
|
53
|
+
path: z.string().min(1).max(4096).describe('Absolute path of the file to write'),
|
|
54
|
+
contents: z.string().describe('Full text contents to write'),
|
|
55
|
+
}),
|
|
56
|
+
execute: async ({ path, contents }) => await run({ kind: 'write_file', path, contentsBase64: Buffer.from(contents, 'utf8').toString('base64') }),
|
|
57
|
+
}),
|
|
58
|
+
computer_list_files: tool({
|
|
59
|
+
description: 'List directory entries on this computer.',
|
|
60
|
+
inputSchema: z.object({ path: z.string().min(1).max(4096).describe('Absolute path of the folder to list') }),
|
|
61
|
+
execute: async ({ path }) => await run({ kind: 'list_files', path }),
|
|
62
|
+
}),
|
|
63
|
+
computer_terminal: tool({
|
|
64
|
+
description: 'Run long-running commands on this computer, such as servers, watchers or long builds. ' +
|
|
65
|
+
'Start a session, poll its output with read, and cancel it when done. Starting a command may require approval.',
|
|
66
|
+
inputSchema: computerToolInputSchema(computerTerminalFields, computerTerminalVariants),
|
|
67
|
+
needsApproval: needsApproval('computer_terminal'),
|
|
68
|
+
execute: async (input) => {
|
|
69
|
+
const { action, ...args } = input;
|
|
70
|
+
return await driver(`terminal_${action}`, args);
|
|
71
|
+
},
|
|
72
|
+
}),
|
|
73
|
+
};
|
|
74
|
+
if (platform === 'darwin' || platform === 'linux') {
|
|
75
|
+
tools.computer_open_url = tool({
|
|
76
|
+
description: 'Open a URL in the browser on this computer, where the person can see it. ' +
|
|
77
|
+
'Serve local HTML over HTTP(S); file:// URLs are unsupported.',
|
|
78
|
+
inputSchema: z.object({ url: computerBrowserUrlSchema.describe('The HTTP or HTTPS URL to open') }),
|
|
79
|
+
execute: async ({ url }) => await driver('open_url', { url }),
|
|
80
|
+
});
|
|
81
|
+
tools.computer_browser = tool({
|
|
82
|
+
description: 'Control a browser on this computer, in its own Overlay profile that keeps its sign-ins. Prefer this tool for websites: ' +
|
|
83
|
+
'take a snapshot, then act using its element refs. Typing, focus and navigation can replace page elements; take a fresh ' +
|
|
84
|
+
'snapshot after page changes and before reusing refs. If stale_browser_ref is returned, no action occurred: take a new ' +
|
|
85
|
+
'snapshot and choose the current target. For a potentially consequential click, call click with confirm: true so the ' +
|
|
86
|
+
'person can approve it.' + (platform === 'darwin' ? ' Use computer_screenshot and computer_input for other apps.' : ''),
|
|
87
|
+
inputSchema: computerToolInputSchema(computerBrowserFields, computerBrowserVariants),
|
|
88
|
+
needsApproval: needsApproval('computer_browser'),
|
|
89
|
+
execute: async (input) => {
|
|
90
|
+
const { action, ...args } = computerBrowserVariants.parse(input);
|
|
91
|
+
const ensured = await driver('browser_ensure');
|
|
92
|
+
if (typeof ensured.error === 'string')
|
|
93
|
+
return ensured;
|
|
94
|
+
const result = await driver('browser', { ...args, action });
|
|
95
|
+
if (typeof result.error === 'string')
|
|
96
|
+
return result;
|
|
97
|
+
return { success: true, action, text: browserActionText(action, args, result) };
|
|
98
|
+
},
|
|
99
|
+
toModelOutput: ({ output }) => ({
|
|
100
|
+
type: 'text',
|
|
101
|
+
value: typeof output?.text === 'string' ? output.text
|
|
102
|
+
: typeof output?.message === 'string' ? output.message
|
|
103
|
+
: typeof output?.error === 'string' ? output.error : 'Browser action failed.',
|
|
104
|
+
}),
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
if (platform === 'darwin') {
|
|
108
|
+
tools.computer_screenshot = tool({
|
|
109
|
+
description: 'Capture the visible screen on this computer and return it as an image.',
|
|
110
|
+
inputSchema: z.object({}).strict(),
|
|
111
|
+
execute: async () => await driver('screenshot'),
|
|
112
|
+
toModelOutput: ({ output }) => {
|
|
113
|
+
if (typeof output?.imageBase64 !== 'string') {
|
|
114
|
+
return { type: 'text', value: typeof output?.message === 'string' ? output.message : SCREENSHOT_NOT_KEPT };
|
|
115
|
+
}
|
|
116
|
+
return {
|
|
117
|
+
type: 'content',
|
|
118
|
+
value: [
|
|
119
|
+
{ type: 'text', text: `Screenshot captured at ${String(output.width)} by ${String(output.height)} pixels.` },
|
|
120
|
+
{
|
|
121
|
+
type: 'file',
|
|
122
|
+
data: { type: 'data', data: output.imageBase64 },
|
|
123
|
+
mediaType: typeof output.mediaType === 'string' ? output.mediaType : 'image/jpeg',
|
|
124
|
+
},
|
|
125
|
+
],
|
|
126
|
+
};
|
|
127
|
+
},
|
|
128
|
+
});
|
|
129
|
+
tools.computer_input = tool({
|
|
130
|
+
description: 'Interact with the visible screen using coordinates from the latest computer_screenshot. ' +
|
|
131
|
+
'Take a screenshot before choosing coordinates and after each action to verify the result. ' +
|
|
132
|
+
'Risky coordinate clicks require confirm: true so the person can approve them. ' +
|
|
133
|
+
'click, double_click, right_click and move require x and y; drag requires from and to; ' +
|
|
134
|
+
'type requires text; key requires keys; scroll requires direction and amount with optional x and y; wait requires ms.',
|
|
135
|
+
inputSchema: computerToolInputSchema(computerInputFields, computerInputVariants),
|
|
136
|
+
needsApproval: needsApproval('computer_input'),
|
|
137
|
+
execute: async (input) => {
|
|
138
|
+
const action = computerInputVariants.parse(input);
|
|
139
|
+
const { command, args } = computerInputDriverCommand(action);
|
|
140
|
+
const result = await driver(command, args);
|
|
141
|
+
if (typeof result.error === 'string')
|
|
142
|
+
return result;
|
|
143
|
+
return { success: true, acknowledgement: `${action.action.replace('_', ' ')} completed.` };
|
|
144
|
+
},
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
return tools;
|
|
148
|
+
}
|
|
149
|
+
export const SCREENSHOT_NOT_KEPT = 'An earlier screenshot; its image is not kept. Take a new one to see the screen.';
|
|
150
|
+
//# sourceMappingURL=private-threads-tools.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"private-threads-tools.js","sourceRoot":"","sources":["../src/private-threads-tools.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAgB,MAAM,IAAI,CAAA;AACvC,OAAO,EA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