visionclaw 0.1.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 +116 -0
- package/dist/agent/context.d.ts +56 -0
- package/dist/agent/context.d.ts.map +1 -0
- package/dist/agent/context.js +142 -0
- package/dist/agent/context.js.map +1 -0
- package/dist/agent/loop.d.ts +18 -0
- package/dist/agent/loop.d.ts.map +1 -0
- package/dist/agent/loop.js +323 -0
- package/dist/agent/loop.js.map +1 -0
- package/dist/agent/session.d.ts +49 -0
- package/dist/agent/session.d.ts.map +1 -0
- package/dist/agent/session.js +200 -0
- package/dist/agent/session.js.map +1 -0
- package/dist/agent/system-prompt.d.ts +10 -0
- package/dist/agent/system-prompt.d.ts.map +1 -0
- package/dist/agent/system-prompt.js +167 -0
- package/dist/agent/system-prompt.js.map +1 -0
- package/dist/calendar/google-calendar.d.ts +46 -0
- package/dist/calendar/google-calendar.d.ts.map +1 -0
- package/dist/calendar/google-calendar.js +132 -0
- package/dist/calendar/google-calendar.js.map +1 -0
- package/dist/calendar/scheduler.d.ts +7 -0
- package/dist/calendar/scheduler.d.ts.map +1 -0
- package/dist/calendar/scheduler.js +33 -0
- package/dist/calendar/scheduler.js.map +1 -0
- package/dist/channels/discord.d.ts +19 -0
- package/dist/channels/discord.d.ts.map +1 -0
- package/dist/channels/discord.js +169 -0
- package/dist/channels/discord.js.map +1 -0
- package/dist/channels/gmail.d.ts +31 -0
- package/dist/channels/gmail.d.ts.map +1 -0
- package/dist/channels/gmail.js +300 -0
- package/dist/channels/gmail.js.map +1 -0
- package/dist/channels/interface.d.ts +45 -0
- package/dist/channels/interface.d.ts.map +1 -0
- package/dist/channels/interface.js +2 -0
- package/dist/channels/interface.js.map +1 -0
- package/dist/channels/manager.d.ts +36 -0
- package/dist/channels/manager.d.ts.map +1 -0
- package/dist/channels/manager.js +108 -0
- package/dist/channels/manager.js.map +1 -0
- package/dist/channels/queue.d.ts +17 -0
- package/dist/channels/queue.d.ts.map +1 -0
- package/dist/channels/queue.js +85 -0
- package/dist/channels/queue.js.map +1 -0
- package/dist/channels/slack.d.ts +17 -0
- package/dist/channels/slack.d.ts.map +1 -0
- package/dist/channels/slack.js +142 -0
- package/dist/channels/slack.js.map +1 -0
- package/dist/channels/sms.d.ts +19 -0
- package/dist/channels/sms.d.ts.map +1 -0
- package/dist/channels/sms.js +111 -0
- package/dist/channels/sms.js.map +1 -0
- package/dist/channels/telegram.d.ts +28 -0
- package/dist/channels/telegram.d.ts.map +1 -0
- package/dist/channels/telegram.js +246 -0
- package/dist/channels/telegram.js.map +1 -0
- package/dist/channels/whatsapp.d.ts +28 -0
- package/dist/channels/whatsapp.d.ts.map +1 -0
- package/dist/channels/whatsapp.js +292 -0
- package/dist/channels/whatsapp.js.map +1 -0
- package/dist/config/index.d.ts +24 -0
- package/dist/config/index.d.ts.map +1 -0
- package/dist/config/index.js +104 -0
- package/dist/config/index.js.map +1 -0
- package/dist/config/types.d.ts +227 -0
- package/dist/config/types.d.ts.map +1 -0
- package/dist/config/types.js +45 -0
- package/dist/config/types.js.map +1 -0
- package/dist/files.d.ts +20 -0
- package/dist/files.d.ts.map +1 -0
- package/dist/files.js +82 -0
- package/dist/files.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +54 -0
- package/dist/index.js.map +1 -0
- package/dist/logger.d.ts +76 -0
- package/dist/logger.d.ts.map +1 -0
- package/dist/logger.js +384 -0
- package/dist/logger.js.map +1 -0
- package/dist/memory/store.d.ts +24 -0
- package/dist/memory/store.d.ts.map +1 -0
- package/dist/memory/store.js +71 -0
- package/dist/memory/store.js.map +1 -0
- package/dist/obs/server.d.ts +10 -0
- package/dist/obs/server.d.ts.map +1 -0
- package/dist/obs/server.js +406 -0
- package/dist/obs/server.js.map +1 -0
- package/dist/onboarding/google-auth.d.ts +11 -0
- package/dist/onboarding/google-auth.d.ts.map +1 -0
- package/dist/onboarding/google-auth.js +113 -0
- package/dist/onboarding/google-auth.js.map +1 -0
- package/dist/onboarding/index.d.ts +2 -0
- package/dist/onboarding/index.d.ts.map +1 -0
- package/dist/onboarding/index.js +213 -0
- package/dist/onboarding/index.js.map +1 -0
- package/dist/onboarding/macos-permissions.d.ts +37 -0
- package/dist/onboarding/macos-permissions.d.ts.map +1 -0
- package/dist/onboarding/macos-permissions.js +207 -0
- package/dist/onboarding/macos-permissions.js.map +1 -0
- package/dist/skills/install.d.ts +7 -0
- package/dist/skills/install.d.ts.map +1 -0
- package/dist/skills/install.js +63 -0
- package/dist/skills/install.js.map +1 -0
- package/dist/tools/browser.d.ts +7 -0
- package/dist/tools/browser.d.ts.map +1 -0
- package/dist/tools/browser.js +202 -0
- package/dist/tools/browser.js.map +1 -0
- package/dist/tools/calendar.d.ts +12 -0
- package/dist/tools/calendar.d.ts.map +1 -0
- package/dist/tools/calendar.js +210 -0
- package/dist/tools/calendar.js.map +1 -0
- package/dist/tools/computer-use.d.ts +28 -0
- package/dist/tools/computer-use.d.ts.map +1 -0
- package/dist/tools/computer-use.js +311 -0
- package/dist/tools/computer-use.js.map +1 -0
- package/dist/tools/coordinate-resolver.d.ts +26 -0
- package/dist/tools/coordinate-resolver.d.ts.map +1 -0
- package/dist/tools/coordinate-resolver.js +157 -0
- package/dist/tools/coordinate-resolver.js.map +1 -0
- package/dist/tools/desktop-executor.d.ts +52 -0
- package/dist/tools/desktop-executor.d.ts.map +1 -0
- package/dist/tools/desktop-executor.js +202 -0
- package/dist/tools/desktop-executor.js.map +1 -0
- package/dist/tools/finish.d.ts +5 -0
- package/dist/tools/finish.d.ts.map +1 -0
- package/dist/tools/finish.js +18 -0
- package/dist/tools/finish.js.map +1 -0
- package/dist/tools/index.d.ts +7 -0
- package/dist/tools/index.d.ts.map +1 -0
- package/dist/tools/index.js +37 -0
- package/dist/tools/index.js.map +1 -0
- package/dist/tools/memory.d.ts +14 -0
- package/dist/tools/memory.d.ts.map +1 -0
- package/dist/tools/memory.js +269 -0
- package/dist/tools/memory.js.map +1 -0
- package/dist/tools/notify.d.ts +12 -0
- package/dist/tools/notify.d.ts.map +1 -0
- package/dist/tools/notify.js +108 -0
- package/dist/tools/notify.js.map +1 -0
- package/dist/tools/screenshot.d.ts +7 -0
- package/dist/tools/screenshot.d.ts.map +1 -0
- package/dist/tools/screenshot.js +189 -0
- package/dist/tools/screenshot.js.map +1 -0
- package/dist/tools/skill.d.ts +8 -0
- package/dist/tools/skill.d.ts.map +1 -0
- package/dist/tools/skill.js +133 -0
- package/dist/tools/skill.js.map +1 -0
- package/dist/tools/upgrade.d.ts +5 -0
- package/dist/tools/upgrade.d.ts.map +1 -0
- package/dist/tools/upgrade.js +89 -0
- package/dist/tools/upgrade.js.map +1 -0
- package/dist/tools/wait.d.ts +5 -0
- package/dist/tools/wait.d.ts.map +1 -0
- package/dist/tools/wait.js +21 -0
- package/dist/tools/wait.js.map +1 -0
- package/package.json +61 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loop.js","sourceRoot":"","sources":["../../src/agent/loop.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,EAAE,gBAAgB,EAAE,qBAAqB,EAAsB,MAAM,cAAc,CAAC;AAC3F,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAC9D,OAAO,EAAE,sBAAsB,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AACvE,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAYtC,4CAA4C;AAC5C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,GAAG,EAAE,CAAC;YACb,0CAA0C;YAC1C,OAAO,CAAC,UAAU,EAAE,CAAC;YACrB,MAAM,CAAC,GAAG,CACR,qBAAqB,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,EACvE,EAAE,KAAK,EAAE,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,EAAE,CACxD,CAAC;YACF,wDAAwD;YACxD,MAAM,IAAI,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,UAAU,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC;QAChD,CAAC;IACH,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { type Query, type SDKMessage, type SDKUserMessage, type McpServerConfig } from "@anthropic-ai/claude-agent-sdk";
|
|
2
|
+
import type { VisionClawConfig } from "../config/types.js";
|
|
3
|
+
export type { SDKMessage, SDKUserMessage };
|
|
4
|
+
export declare const CLAUDE_MODEL = "claude-sonnet-4-6";
|
|
5
|
+
/**
|
|
6
|
+
* Wraps the V1 query() API with a long-lived async generator for streaming
|
|
7
|
+
* input. This allows injecting additional user messages while the agent is
|
|
8
|
+
* processing (interrupt messages), instead of waiting for the query to
|
|
9
|
+
* finish before sending the next message.
|
|
10
|
+
*/
|
|
11
|
+
export declare class AgentSession {
|
|
12
|
+
private config;
|
|
13
|
+
private systemPrompt;
|
|
14
|
+
private mcpServers;
|
|
15
|
+
private currentQuery;
|
|
16
|
+
private sessionId;
|
|
17
|
+
/**
|
|
18
|
+
* Pending message queue for the long-lived generator.
|
|
19
|
+
* When a message is injected, it's pushed here and the waiting
|
|
20
|
+
* generator is woken up via the resolver.
|
|
21
|
+
*/
|
|
22
|
+
private pendingMessages;
|
|
23
|
+
private messageResolver;
|
|
24
|
+
private generatorClosed;
|
|
25
|
+
constructor(config: VisionClawConfig, systemPrompt: string, mcpServers: Record<string, McpServerConfig>);
|
|
26
|
+
/**
|
|
27
|
+
* Send the initial user message and return the query generator to stream
|
|
28
|
+
* responses. The underlying async generator stays open so that additional
|
|
29
|
+
* messages can be injected via injectMessage().
|
|
30
|
+
*/
|
|
31
|
+
sendAndStream(content: SDKUserMessage["message"]["content"]): Query;
|
|
32
|
+
/**
|
|
33
|
+
* Inject a new user message into the running query stream.
|
|
34
|
+
* The agent will see this as a follow-up user message in the conversation.
|
|
35
|
+
* Only works while a query is active (between sendAndStream and closeInput).
|
|
36
|
+
*/
|
|
37
|
+
injectMessage(content: SDKUserMessage["message"]["content"]): void;
|
|
38
|
+
/**
|
|
39
|
+
* Signal the input generator to close. Call this when the agent calls
|
|
40
|
+
* finish or when we want the query to complete naturally.
|
|
41
|
+
*/
|
|
42
|
+
closeInput(): void;
|
|
43
|
+
/**
|
|
44
|
+
* Update the persisted session ID.
|
|
45
|
+
*/
|
|
46
|
+
captureSessionId(id: string | undefined): void;
|
|
47
|
+
getSessionId(): string | null;
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=session.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../../src/agent/session.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,KAAK,EACV,KAAK,UAAU,EACf,KAAK,cAAc,EACnB,KAAK,eAAe,EACrB,MAAM,gCAAgC,CAAC;AAGxC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAI3D,YAAY,EAAE,UAAU,EAAE,cAAc,EAAE,CAAC;AAE3C,eAAO,MAAM,YAAY,sBAAsB,CAAC;AAEhD;;;;;GAKG;AACH,qBAAa,YAAY;IACvB,OAAO,CAAC,MAAM,CAAmB;IACjC,OAAO,CAAC,YAAY,CAAS;IAC7B,OAAO,CAAC,UAAU,CAAkC;IACpD,OAAO,CAAC,YAAY,CAAsB;IAC1C,OAAO,CAAC,SAAS,CAAgB;IAEjC;;;;OAIG;IACH,OAAO,CAAC,eAAe,CAAwB;IAC/C,OAAO,CAAC,eAAe,CAA6B;IACpD,OAAO,CAAC,eAAe,CAAQ;gBAG7B,MAAM,EAAE,gBAAgB,EACxB,YAAY,EAAE,MAAM,EACpB,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC;IAQ7C;;;;OAIG;IACH,aAAa,CAAC,OAAO,EAAE,cAAc,CAAC,SAAS,CAAC,CAAC,SAAS,CAAC,GAAG,KAAK;IA8HnE;;;;OAIG;IACH,aAAa,CAAC,OAAO,EAAE,cAAc,CAAC,SAAS,CAAC,CAAC,SAAS,CAAC,GAAG,IAAI;IAuBlE;;;OAGG;IACH,UAAU,IAAI,IAAI;IASlB;;OAEG;IACH,gBAAgB,CAAC,EAAE,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI;IAO9C,YAAY,IAAI,MAAM,GAAG,IAAI;CAG9B"}
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
import { query, } from "@anthropic-ai/claude-agent-sdk";
|
|
2
|
+
import { loadSessionId, saveSessionId, getConfigDir } from "../config/index.js";
|
|
3
|
+
import { logger } from "../logger.js";
|
|
4
|
+
import { createRequire } from "module";
|
|
5
|
+
import path from "path";
|
|
6
|
+
export const CLAUDE_MODEL = "claude-sonnet-4-6";
|
|
7
|
+
/**
|
|
8
|
+
* Wraps the V1 query() API with a long-lived async generator for streaming
|
|
9
|
+
* input. This allows injecting additional user messages while the agent is
|
|
10
|
+
* processing (interrupt messages), instead of waiting for the query to
|
|
11
|
+
* finish before sending the next message.
|
|
12
|
+
*/
|
|
13
|
+
export class AgentSession {
|
|
14
|
+
config;
|
|
15
|
+
systemPrompt;
|
|
16
|
+
mcpServers;
|
|
17
|
+
currentQuery = null;
|
|
18
|
+
sessionId;
|
|
19
|
+
/**
|
|
20
|
+
* Pending message queue for the long-lived generator.
|
|
21
|
+
* When a message is injected, it's pushed here and the waiting
|
|
22
|
+
* generator is woken up via the resolver.
|
|
23
|
+
*/
|
|
24
|
+
pendingMessages = [];
|
|
25
|
+
messageResolver = null;
|
|
26
|
+
generatorClosed = true;
|
|
27
|
+
constructor(config, systemPrompt, mcpServers) {
|
|
28
|
+
this.config = config;
|
|
29
|
+
this.systemPrompt = systemPrompt;
|
|
30
|
+
this.mcpServers = mcpServers;
|
|
31
|
+
this.sessionId = loadSessionId();
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Send the initial user message and return the query generator to stream
|
|
35
|
+
* responses. The underlying async generator stays open so that additional
|
|
36
|
+
* messages can be injected via injectMessage().
|
|
37
|
+
*/
|
|
38
|
+
sendAndStream(content) {
|
|
39
|
+
const savedSessionId = this.sessionId;
|
|
40
|
+
// Resolve the SDK's cli.js path so it works both in dev and bundled mode
|
|
41
|
+
const _require = createRequire(import.meta.url);
|
|
42
|
+
const sdkCliPath = path.resolve(path.dirname(_require.resolve("@anthropic-ai/claude-agent-sdk")), "cli.js");
|
|
43
|
+
const options = {
|
|
44
|
+
model: CLAUDE_MODEL,
|
|
45
|
+
pathToClaudeCodeExecutable: sdkCliPath,
|
|
46
|
+
systemPrompt: this.systemPrompt,
|
|
47
|
+
permissionMode: "bypassPermissions",
|
|
48
|
+
allowDangerouslySkipPermissions: true,
|
|
49
|
+
cwd: getConfigDir(),
|
|
50
|
+
settingSources: ["project"],
|
|
51
|
+
// allowedTools: [
|
|
52
|
+
// // SDK built-in tools
|
|
53
|
+
// "Bash",
|
|
54
|
+
// "Read",
|
|
55
|
+
// "Write",
|
|
56
|
+
// "Edit",
|
|
57
|
+
// "Glob",
|
|
58
|
+
// "Grep",
|
|
59
|
+
// "WebSearch",
|
|
60
|
+
// "WebFetch",
|
|
61
|
+
// "Task",
|
|
62
|
+
// "Skill",
|
|
63
|
+
// // Custom MCP tools (format: mcp__{server}__{tool})
|
|
64
|
+
// "mcp__visionclaw__wait",
|
|
65
|
+
// "mcp__visionclaw__notify_user",
|
|
66
|
+
// "mcp__visionclaw__finish",
|
|
67
|
+
// "mcp__visionclaw__take_screenshot",
|
|
68
|
+
// "mcp__visionclaw__manage_skills",
|
|
69
|
+
// "mcp__visionclaw__upgrade",
|
|
70
|
+
// "mcp__visionclaw__manage_calendar",
|
|
71
|
+
// "mcp__visionclaw__memory",
|
|
72
|
+
// "mcp__visionclaw__computer_use_click",
|
|
73
|
+
// "mcp__visionclaw__computer_use_scroll",
|
|
74
|
+
// "mcp__visionclaw__computer_use_drag",
|
|
75
|
+
// "mcp__visionclaw__computer_use_type",
|
|
76
|
+
// "mcp__visionclaw__computer_use_key",
|
|
77
|
+
// "mcp__visionclaw__computer_use_screenshot",
|
|
78
|
+
// // Playwright MCP tools (browser automation via accessibility snapshots)
|
|
79
|
+
// "mcp__playwright__browser_navigate",
|
|
80
|
+
// "mcp__playwright__browser_click",
|
|
81
|
+
// "mcp__playwright__browser_fill_form",
|
|
82
|
+
// "mcp__playwright__browser_snapshot",
|
|
83
|
+
// "mcp__playwright__browser_take_screenshot",
|
|
84
|
+
// "mcp__playwright__browser_hover",
|
|
85
|
+
// "mcp__playwright__browser_drag",
|
|
86
|
+
// "mcp__playwright__browser_press_key",
|
|
87
|
+
// "mcp__playwright__browser_evaluate",
|
|
88
|
+
// "mcp__playwright__browser_handle_dialog",
|
|
89
|
+
// "mcp__playwright__browser_file_upload",
|
|
90
|
+
// "mcp__playwright__browser_tabs",
|
|
91
|
+
// "mcp__playwright__browser_close",
|
|
92
|
+
// "mcp__playwright__browser_console_messages",
|
|
93
|
+
// "mcp__playwright__browser_resize",
|
|
94
|
+
// "mcp__playwright__browser_wait",
|
|
95
|
+
// "mcp__playwright__browser_network_requests",
|
|
96
|
+
// ],
|
|
97
|
+
mcpServers: this.mcpServers,
|
|
98
|
+
env: {
|
|
99
|
+
...process.env,
|
|
100
|
+
ANTHROPIC_API_KEY: this.config.anthropicApiKey,
|
|
101
|
+
},
|
|
102
|
+
...(savedSessionId ? { resume: savedSessionId } : {}),
|
|
103
|
+
};
|
|
104
|
+
// Seed the generator with the initial message
|
|
105
|
+
const initialMessage = {
|
|
106
|
+
type: "user",
|
|
107
|
+
session_id: savedSessionId ?? "",
|
|
108
|
+
message: { role: "user", content },
|
|
109
|
+
parent_tool_use_id: null,
|
|
110
|
+
};
|
|
111
|
+
this.pendingMessages = [initialMessage];
|
|
112
|
+
this.generatorClosed = false;
|
|
113
|
+
// Create a long-lived async generator that yields the initial message
|
|
114
|
+
// and then waits for additional messages injected via injectMessage().
|
|
115
|
+
// We capture references to the session's pending queue and resolver
|
|
116
|
+
// so the generator can read from them without aliasing `this`.
|
|
117
|
+
const pending = this.pendingMessages;
|
|
118
|
+
const setResolver = (r) => {
|
|
119
|
+
this.messageResolver = r;
|
|
120
|
+
};
|
|
121
|
+
const isClosed = () => this.generatorClosed;
|
|
122
|
+
const shiftPending = () => pending.shift();
|
|
123
|
+
async function* messageStream() {
|
|
124
|
+
while (!isClosed()) {
|
|
125
|
+
// Yield all pending messages
|
|
126
|
+
let next = shiftPending();
|
|
127
|
+
while (next) {
|
|
128
|
+
yield next;
|
|
129
|
+
next = shiftPending();
|
|
130
|
+
}
|
|
131
|
+
// If generator is still open, wait for the next message
|
|
132
|
+
if (!isClosed()) {
|
|
133
|
+
await new Promise((resolve) => {
|
|
134
|
+
setResolver(resolve);
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
if (savedSessionId) {
|
|
140
|
+
logger.system(`Resuming session: ${savedSessionId}`);
|
|
141
|
+
}
|
|
142
|
+
else {
|
|
143
|
+
logger.system("Creating new session...");
|
|
144
|
+
}
|
|
145
|
+
this.currentQuery = query({
|
|
146
|
+
prompt: messageStream(),
|
|
147
|
+
options,
|
|
148
|
+
});
|
|
149
|
+
return this.currentQuery;
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Inject a new user message into the running query stream.
|
|
153
|
+
* The agent will see this as a follow-up user message in the conversation.
|
|
154
|
+
* Only works while a query is active (between sendAndStream and closeInput).
|
|
155
|
+
*/
|
|
156
|
+
injectMessage(content) {
|
|
157
|
+
if (this.generatorClosed) {
|
|
158
|
+
logger.warn("Cannot inject message: generator is closed");
|
|
159
|
+
return;
|
|
160
|
+
}
|
|
161
|
+
const msg = {
|
|
162
|
+
type: "user",
|
|
163
|
+
session_id: this.sessionId ?? "",
|
|
164
|
+
message: { role: "user", content },
|
|
165
|
+
parent_tool_use_id: null,
|
|
166
|
+
};
|
|
167
|
+
this.pendingMessages.push(msg);
|
|
168
|
+
logger.info("Injected interrupt message into active session");
|
|
169
|
+
// Wake the generator if it's waiting
|
|
170
|
+
if (this.messageResolver) {
|
|
171
|
+
this.messageResolver();
|
|
172
|
+
this.messageResolver = null;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* Signal the input generator to close. Call this when the agent calls
|
|
177
|
+
* finish or when we want the query to complete naturally.
|
|
178
|
+
*/
|
|
179
|
+
closeInput() {
|
|
180
|
+
this.generatorClosed = true;
|
|
181
|
+
// Wake the generator so it can exit its loop
|
|
182
|
+
if (this.messageResolver) {
|
|
183
|
+
this.messageResolver();
|
|
184
|
+
this.messageResolver = null;
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* Update the persisted session ID.
|
|
189
|
+
*/
|
|
190
|
+
captureSessionId(id) {
|
|
191
|
+
if (id) {
|
|
192
|
+
this.sessionId = id;
|
|
193
|
+
saveSessionId(id);
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
getSessionId() {
|
|
197
|
+
return this.sessionId;
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
//# sourceMappingURL=session.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session.js","sourceRoot":"","sources":["../../src/agent/session.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,GAKN,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAE,a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AAI,CAAC,eAAe,EAAE,CAAC;YACzB,MAAM,CAAC,IAAI,CAAC,4CAA4C,CAAC,CAAC;YAC1D,OAAO;QACT,CAAC;QAED,MAAM,GAAG,GAAmB;YAC1B,IAAI,EAAE,MAAM;YACZ,UAAU,EAAE,IAAI,CAAC,SAAS,IAAI,EAAE;YAChC,OAAO,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE;YAClC,kBAAkB,EAAE,IAAI;SACzB,CAAC;QAEF,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAC/B,MAAM,CAAC,IAAI,CAAC,gDAAgD,CAAC,CAAC;QAE9D,qCAAqC;QACrC,IAAI,IAAI,CAAC,eAAe,EAAE,CAAC;YACzB,IAAI,CAAC,eAAe,EAAE,CAAC;YACvB,IAAI,CAAC,eAAe,GAAG,IAAI,CAAC;QAC9B,CAAC;IACH,CAAC;IAED;;;OAGG;IACH,UAAU;QACR,IAAI,CAAC,eAAe,GAAG,IAAI,CAAC;QAC5B,6CAA6C;QAC7C,IAAI,IAAI,CAAC,eAAe,EAAE,CAAC;YACzB,IAAI,CAAC,eAAe,EAAE,CAAC;YACvB,IAAI,CAAC,eAAe,GAAG,IAAI,CAAC;QAC9B,CAAC;IACH,CAAC;IAED;;OAEG;IACH,gBAAgB,CAAC,EAAsB;QACrC,IAAI,EAAE,EAAE,CAAC;YACP,IAAI,CAAC,SAAS,GAAG,EAAE,CAAC;YACpB,aAAa,CAAC,EAAE,CAAC,CAAC;QACpB,CAAC;IACH,CAAC;IAED,YAAY;QACV,OAAO,IAAI,CAAC,SAAS,CAAC;IACxB,CAAC;CACF"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { VisionClawConfig } from "../config/types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Build the system prompt that establishes the agent's identity,
|
|
4
|
+
* capabilities, and self-awareness.
|
|
5
|
+
*
|
|
6
|
+
* Skills are no longer injected here -- they are discovered and
|
|
7
|
+
* invoked at runtime by the SDK's native Skill tool.
|
|
8
|
+
*/
|
|
9
|
+
export declare function buildSystemPrompt(config: VisionClawConfig): string;
|
|
10
|
+
//# sourceMappingURL=system-prompt.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"system-prompt.d.ts","sourceRoot":"","sources":["../../src/agent/system-prompt.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAE3D;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,gBAAgB,GAAG,MAAM,CAgJlE"}
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Build the system prompt that establishes the agent's identity,
|
|
3
|
+
* capabilities, and self-awareness.
|
|
4
|
+
*
|
|
5
|
+
* Skills are no longer injected here -- they are discovered and
|
|
6
|
+
* invoked at runtime by the SDK's native Skill tool.
|
|
7
|
+
*/
|
|
8
|
+
export function buildSystemPrompt(config) {
|
|
9
|
+
const channelList = getEnabledChannels(config);
|
|
10
|
+
const tz = Intl.DateTimeFormat().resolvedOptions().timeZone;
|
|
11
|
+
const now = new Date().toLocaleString("en-US", {
|
|
12
|
+
timeZone: tz,
|
|
13
|
+
dateStyle: "full",
|
|
14
|
+
timeStyle: "long",
|
|
15
|
+
});
|
|
16
|
+
return `# Identity
|
|
17
|
+
|
|
18
|
+
You are ${config.agentName}, a personal desktop assistant. You are a long-running autonomous agent that owns and fully controls a computer (${process.platform === "darwin" ? "macOS" : "Windows"}).
|
|
19
|
+
|
|
20
|
+
## Your Identity
|
|
21
|
+
- **Name**: ${config.agentName}
|
|
22
|
+
- **Email**: ${config.gmail} (this is YOUR email address — you send and receive emails as yourself)
|
|
23
|
+
- **Calendar**: Google Calendar associated with ${config.gmail} (this is YOUR calendar)
|
|
24
|
+
${config.phoneNumber ? `- **Phone**: ${config.phoneNumber}` : "- **Phone**: Not configured"}
|
|
25
|
+
|
|
26
|
+
## Your Owner
|
|
27
|
+
${config.ownerName ? `- **Name**: ${config.ownerName}` : "- Owner name not configured"}
|
|
28
|
+
${config.ownerEmail ? `- **Personal Email**: ${config.ownerEmail}` : ""}
|
|
29
|
+
${config.phoneNumber ? `- **Phone**: ${config.phoneNumber}` : ""}
|
|
30
|
+
${config.channels.telegram?.enabled && config.channels.telegram.allowedChatIds.length > 0 ? `- **Telegram Chat IDs**: ${config.channels.telegram.allowedChatIds.join(", ")}` : ""}
|
|
31
|
+
|
|
32
|
+
All messages from enabled channels come from your owner (or people your owner has authorized). When someone messages you on Telegram, Gmail, or Discord — they are your owner giving you commands. Always respond helpfully and promptly.
|
|
33
|
+
|
|
34
|
+
## Self-Awareness
|
|
35
|
+
- You are a program running on this computer. You are always on as long as the computer is on.
|
|
36
|
+
- You have full control of this computer: you can run terminal commands, use GUI applications, take screenshots, control the mouse and keyboard, browse the web, read and write files.
|
|
37
|
+
- You can upgrade yourself when new versions are available.
|
|
38
|
+
- You can manage your skills using the \`manage_skills\` tool (create, update, delete, list), and invoke them via the \`Skill\` tool.
|
|
39
|
+
- You persist across restarts — your session and memory carry over.
|
|
40
|
+
|
|
41
|
+
## Communication Channels
|
|
42
|
+
You receive "Command Messages" from your user through these enabled channels:
|
|
43
|
+
${channelList}
|
|
44
|
+
|
|
45
|
+
When you need to communicate results, answer questions, or ask for help, use the \`notify_user\` tool. Always respond through the same channel the user messaged you on, unless otherwise appropriate.
|
|
46
|
+
|
|
47
|
+
## Behavior
|
|
48
|
+
|
|
49
|
+
### Wake Cycle
|
|
50
|
+
You are triggered by:
|
|
51
|
+
1. **New messages** from any enabled channel
|
|
52
|
+
2. **Heartbeat events** every ${config.heartbeatIntervalMs / 1000} seconds
|
|
53
|
+
|
|
54
|
+
Every time you wake up:
|
|
55
|
+
- You receive a screenshot of the current desktop state
|
|
56
|
+
- You receive a summary of upcoming Google Calendar events
|
|
57
|
+
- You receive any queued messages
|
|
58
|
+
- You decide what to do based on the context
|
|
59
|
+
|
|
60
|
+
### Single-Threaded Execution
|
|
61
|
+
You can only do one thing at a time:
|
|
62
|
+
- If you are working on a task and a new message arrives, it will be appended to your context. You decide whether to continue the current task, switch, or briefly respond and continue.
|
|
63
|
+
- Heartbeat events are skipped if you are already busy.
|
|
64
|
+
|
|
65
|
+
### Memory & Context Management
|
|
66
|
+
- Proactively save important information to memory so it survives context compaction.
|
|
67
|
+
- Retrieve relevant memories when starting new tasks.
|
|
68
|
+
- Your conversation session is infinite — context compaction will automatically summarize old turns. Important details should be saved to memory before they get compacted.
|
|
69
|
+
|
|
70
|
+
### Task Completion
|
|
71
|
+
- When you have nothing left to do, call the \`finish\` tool to go back to sleep.
|
|
72
|
+
- When tasks are completed, notify the user through the appropriate channel.
|
|
73
|
+
- For recurring tasks, create Google Calendar events so you are reminded to execute them.
|
|
74
|
+
|
|
75
|
+
### Proactive Behavior
|
|
76
|
+
During heartbeat wakes (no new messages), review your calendar, check for pending tasks, and take initiative:
|
|
77
|
+
- Check for calendar events that need action
|
|
78
|
+
- Follow up on pending tasks
|
|
79
|
+
- Perform maintenance (check for updates, clean up, etc.)
|
|
80
|
+
|
|
81
|
+
## Available Tools
|
|
82
|
+
|
|
83
|
+
### SDK Built-in Tools
|
|
84
|
+
- **Bash**: Run terminal commands
|
|
85
|
+
- **Read/Write/Edit**: File operations
|
|
86
|
+
- **Glob/Grep**: File search
|
|
87
|
+
- **WebSearch/WebFetch**: Web research
|
|
88
|
+
- **Task**: Spawn sub-agents for complex tasks
|
|
89
|
+
- **Skill**: Invoke learned skills (auto-discovered from your skills directory)
|
|
90
|
+
|
|
91
|
+
### System Tools
|
|
92
|
+
|
|
93
|
+
- **wait**: Pause for a specified duration
|
|
94
|
+
- **notify_user**: Send a message to the user via a channel
|
|
95
|
+
- **finish**: Signal that you are done and ready to sleep
|
|
96
|
+
- **take_screenshot**: Capture the current screen
|
|
97
|
+
- **manage_skills**: Create, update, delete, or list your skills (SKILL.md files invoked by the Skill tool)
|
|
98
|
+
- **upgrade**: Check for and install updates to yourself
|
|
99
|
+
- **manage_calendar**: Create, update, delete, list Google Calendar events
|
|
100
|
+
- **memory**: Persistent memory storage (view, create, str_replace, insert, delete, rename files in /memories)
|
|
101
|
+
|
|
102
|
+
### Browser Tools (Playwright MCP)
|
|
103
|
+
|
|
104
|
+
For all web browser interactions, use the Playwright browser tools. They use **accessibility snapshots** — a structured representation of the page with element refs — for fast, precise, deterministic interaction without screenshots.
|
|
105
|
+
|
|
106
|
+
**Workflow**: \`browser_navigate\` to open a URL, then \`browser_snapshot\` to get the page structure with element \`ref\` IDs, then use those refs with \`browser_click\`, \`browser_fill_form\`, etc.
|
|
107
|
+
|
|
108
|
+
- **browser_navigate**: Open a URL in the browser
|
|
109
|
+
- **browser_snapshot**: Get an accessibility snapshot of the current page (returns element tree with \`ref\` IDs for interaction)
|
|
110
|
+
- **browser_click**: Click an element using its \`ref\` from a snapshot
|
|
111
|
+
- **browser_fill_form**: Fill multiple form fields at once using \`ref\`s
|
|
112
|
+
- **browser_hover**: Hover over an element
|
|
113
|
+
- **browser_drag**: Drag from one element to another
|
|
114
|
+
- **browser_press_key**: Press keyboard keys
|
|
115
|
+
- **browser_evaluate**: Execute JavaScript on the page
|
|
116
|
+
- **browser_take_screenshot**: Take a visual screenshot of the page
|
|
117
|
+
- **browser_handle_dialog**: Handle alert/confirm/prompt dialogs
|
|
118
|
+
- **browser_file_upload**: Upload files
|
|
119
|
+
- **browser_tabs**: List or switch between browser tabs
|
|
120
|
+
- **browser_close**: Close the browser
|
|
121
|
+
- **browser_console_messages**: Get console messages
|
|
122
|
+
- **browser_resize**: Resize the browser viewport
|
|
123
|
+
- **browser_wait**: Wait for a condition or timeout
|
|
124
|
+
- **browser_network_requests**: Get network request logs
|
|
125
|
+
|
|
126
|
+
**Prefer Playwright browser tools** for all in-browser interactions (clicking links, filling forms, reading pages). Use **computer_use_*** only for desktop apps, situations outside the browser or as a fallback.
|
|
127
|
+
|
|
128
|
+
### Desktop Computer Use Tools
|
|
129
|
+
|
|
130
|
+
For interacting with desktop applications and any visible UI outside the browser. These tools use AI-powered coordinate resolution — describe what you want to interact with in natural language.
|
|
131
|
+
|
|
132
|
+
- **computer_use_click**: Click on UI elements by natural language (e.g. "the Chrome icon", "the submit button"). Left/right/double-click.
|
|
133
|
+
- **computer_use_scroll**: Scroll at a target location (up/down/left/right).
|
|
134
|
+
- **computer_use_drag**: Drag from one element to another.
|
|
135
|
+
- **computer_use_type**: Type text into the focused field; optionally replace existing text and/or press Enter after.
|
|
136
|
+
- **computer_use_key**: Press key combos (e.g. enter, escape, cmd+s, ctrl+shift+t).
|
|
137
|
+
- **computer_use_screenshot**: Take a desktop screenshot
|
|
138
|
+
|
|
139
|
+
## Memory Protocol
|
|
140
|
+
|
|
141
|
+
IMPORTANT: ALWAYS VIEW YOUR MEMORY DIRECTORY BEFORE DOING ANYTHING ELSE.
|
|
142
|
+
1. Use the \`memory\` tool with command \`view\` and path \`/memories\` to check for earlier progress or context.
|
|
143
|
+
2. Work on the task as needed.
|
|
144
|
+
3. As you make progress, record status, progress, and important information in your memory.
|
|
145
|
+
|
|
146
|
+
ASSUME INTERRUPTION: Your context window might be compacted at any moment, so you risk losing any progress that is not recorded in your memory directory. Keep memory content up-to-date, coherent, and organized. Delete files that are no longer relevant.
|
|
147
|
+
|
|
148
|
+
## Current Time
|
|
149
|
+
${now} (${tz})
|
|
150
|
+
`;
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Build a human-readable list of enabled channels.
|
|
154
|
+
*/
|
|
155
|
+
function getEnabledChannels(config) {
|
|
156
|
+
const channels = [];
|
|
157
|
+
// Gmail is always enabled (it's the agent's identity)
|
|
158
|
+
channels.push("- **Gmail** (always enabled — your primary email identity)");
|
|
159
|
+
if (config.channels.telegram?.enabled) {
|
|
160
|
+
channels.push("- **Telegram**");
|
|
161
|
+
}
|
|
162
|
+
if (config.channels.discord?.enabled) {
|
|
163
|
+
channels.push("- **Discord**");
|
|
164
|
+
}
|
|
165
|
+
return channels.join("\n");
|
|
166
|
+
}
|
|
167
|
+
//# sourceMappingURL=system-prompt.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"system-prompt.js","sourceRoot":"","sources":["../../src/agent/system-prompt.ts"],"names":[],"mappings":"AAEA;;;;;;GAMG;AACH,MAAM,UAAU,iBAAiB,CAAC,MAAwB;IACxD,MAAM,WAAW,GAAG,kBAAkB,CAAC,MAAM,CAAC,CAAC;IAC/C,MAAM,EAAE,GAAG,IAAI,CAAC,cAAc,EAAE,CAAC,eAAe,EAAE,CAAC,QAAQ,CAAC;IAC5D,MAAM,GAAG,GAAG,IAAI,IAAI,EAAE,CAAC,cAAc,CAAC,OAAO,EAAE;QAC7C,QAAQ,EAAE,EAAE;QACZ,SAAS,EAAE,MAAM;QACjB,SAAS,EAAE,MAAM;KAClB,CAAC,CAAC;IAEH,OAAO;;UAEC,MAAM,CAAC,SAAS,oHAAoH,OAAO,CAAC,QAAQ,KAAK,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS;;;cAGnL,MAAM,CAAC,SAAS;eACf,MAAM,CAAC,KAAK;kDACuB,MAAM,CAAC,KAAK;EAC5D,MAAM,CAAC,WAAW,CAAC,CAAC,CAAC,gBAAgB,MAAM,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,6BAA6B;;;EAGzF,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,eAAe,MAAM,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC,6BAA6B;EACpF,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC,yBAAyB,MAAM,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC,EAAE;EACrE,MAAM,CAAC,WAAW,CAAC,CAAC,CAAC,gBAAgB,MAAM,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,EAAE;EAC9D,MAAM,CAAC,QAAQ,CAAC,QAAQ,EAAE,OAAO,IAAI,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,cAAc,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,4BAA4B,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE;;;;;;;;;;;;;EAa/K,WAAW;;;;;;;;;gCASmB,MAAM,CAAC,mBAAmB,GAAG,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAiG/D,GAAG,KAAK,EAAE;CACX,CAAC;AACF,CAAC;AAED;;GAEG;AACH,SAAS,kBAAkB,CAAC,MAAwB;IAClD,MAAM,QAAQ,GAAa,EAAE,CAAC;IAE9B,sDAAsD;IACtD,QAAQ,CAAC,IAAI,CAAC,4DAA4D,CAAC,CAAC;IAE5E,IAAI,MAAM,CAAC,QAAQ,CAAC,QAAQ,EAAE,OAAO,EAAE,CAAC;QACtC,QAAQ,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC;IAClC,CAAC;IACD,IAAI,MAAM,CAAC,QAAQ,CAAC,OAAO,EAAE,OAAO,EAAE,CAAC;QACrC,QAAQ,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;IACjC,CAAC;IAED,OAAO,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC7B,CAAC"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { type calendar_v3 } from "googleapis";
|
|
2
|
+
import type { VisionClawConfig } from "../config/types.js";
|
|
3
|
+
/**
|
|
4
|
+
* Wrapper around Google Calendar API.
|
|
5
|
+
* Uses OAuth tokens from onboarding to read/write events on the agent's calendar.
|
|
6
|
+
*/
|
|
7
|
+
export declare class GoogleCalendarClient {
|
|
8
|
+
private calendar;
|
|
9
|
+
private config;
|
|
10
|
+
constructor(config: VisionClawConfig);
|
|
11
|
+
/**
|
|
12
|
+
* List events between timeMin and timeMax.
|
|
13
|
+
*/
|
|
14
|
+
listUpcomingEvents(timeMin: Date, timeMax: Date, maxResults?: number): Promise<calendar_v3.Schema$Event[]>;
|
|
15
|
+
/**
|
|
16
|
+
* Create a new calendar event.
|
|
17
|
+
*/
|
|
18
|
+
createEvent(options: {
|
|
19
|
+
summary: string;
|
|
20
|
+
description?: string;
|
|
21
|
+
start: Date;
|
|
22
|
+
end: Date;
|
|
23
|
+
recurrence?: string[];
|
|
24
|
+
}): Promise<calendar_v3.Schema$Event>;
|
|
25
|
+
/**
|
|
26
|
+
* Update an existing event.
|
|
27
|
+
*/
|
|
28
|
+
updateEvent(eventId: string, updates: Partial<{
|
|
29
|
+
summary: string;
|
|
30
|
+
description: string;
|
|
31
|
+
start: Date;
|
|
32
|
+
end: Date;
|
|
33
|
+
}>): Promise<calendar_v3.Schema$Event>;
|
|
34
|
+
/**
|
|
35
|
+
* Delete an event.
|
|
36
|
+
*/
|
|
37
|
+
deleteEvent(eventId: string): Promise<void>;
|
|
38
|
+
/**
|
|
39
|
+
* Find free time slots in a given range.
|
|
40
|
+
*/
|
|
41
|
+
findFreeTime(timeMin: Date, timeMax: Date): Promise<{
|
|
42
|
+
start: string;
|
|
43
|
+
end: string;
|
|
44
|
+
}[]>;
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=google-calendar.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"google-calendar.d.ts","sourceRoot":"","sources":["../../src/calendar/google-calendar.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,KAAK,WAAW,EAAE,MAAM,YAAY,CAAC;AAEtD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAE3D;;;GAGG;AACH,qBAAa,oBAAoB;IAC/B,OAAO,CAAC,QAAQ,CAAuB;IACvC,OAAO,CAAC,MAAM,CAAmB;gBAErB,MAAM,EAAE,gBAAgB;IA4BpC;;OAEG;IACG,kBAAkB,CACtB,OAAO,EAAE,IAAI,EACb,OAAO,EAAE,IAAI,EACb,UAAU,SAAK,GACd,OAAO,CAAC,WAAW,CAAC,YAAY,EAAE,CAAC;IAYtC;;OAEG;IACG,WAAW,CAAC,OAAO,EAAE;QACzB,OAAO,EAAE,MAAM,CAAC;QAChB,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,KAAK,EAAE,IAAI,CAAC;QACZ,GAAG,EAAE,IAAI,CAAC;QACV,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;KACvB,GAAG,OAAO,CAAC,WAAW,CAAC,YAAY,CAAC;IAoBrC;;OAEG;IACG,WAAW,CACf,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,OAAO,CAAC;QACf,OAAO,EAAE,MAAM,CAAC;QAChB,WAAW,EAAE,MAAM,CAAC;QACpB,KAAK,EAAE,IAAI,CAAC;QACZ,GAAG,EAAE,IAAI,CAAC;KACX,CAAC,GACD,OAAO,CAAC,WAAW,CAAC,YAAY,CAAC;IAyBpC;;OAEG;IACG,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAOjD;;OAEG;IACG,YAAY,CAChB,OAAO,EAAE,IAAI,EACb,OAAO,EAAE,IAAI,GACZ,OAAO,CAAC;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;CA6B7C"}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import { google } from "googleapis";
|
|
2
|
+
import { loadGoogleTokens, saveGoogleTokens } from "../config/index.js";
|
|
3
|
+
/**
|
|
4
|
+
* Wrapper around Google Calendar API.
|
|
5
|
+
* Uses OAuth tokens from onboarding to read/write events on the agent's calendar.
|
|
6
|
+
*/
|
|
7
|
+
export class GoogleCalendarClient {
|
|
8
|
+
calendar;
|
|
9
|
+
config;
|
|
10
|
+
constructor(config) {
|
|
11
|
+
this.config = config;
|
|
12
|
+
const tokens = loadGoogleTokens();
|
|
13
|
+
const oauth2Client = new google.auth.OAuth2(config.googleClientId, config.googleClientSecret);
|
|
14
|
+
oauth2Client.setCredentials({
|
|
15
|
+
access_token: tokens.access_token,
|
|
16
|
+
refresh_token: tokens.refresh_token,
|
|
17
|
+
token_type: tokens.token_type,
|
|
18
|
+
expiry_date: tokens.expiry_date,
|
|
19
|
+
});
|
|
20
|
+
// Auto-refresh tokens
|
|
21
|
+
oauth2Client.on("tokens", (newTokens) => {
|
|
22
|
+
const existing = loadGoogleTokens();
|
|
23
|
+
saveGoogleTokens({
|
|
24
|
+
...existing,
|
|
25
|
+
access_token: newTokens.access_token ?? existing.access_token,
|
|
26
|
+
expiry_date: newTokens.expiry_date ?? existing.expiry_date,
|
|
27
|
+
});
|
|
28
|
+
});
|
|
29
|
+
this.calendar = google.calendar({ version: "v3", auth: oauth2Client });
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* List events between timeMin and timeMax.
|
|
33
|
+
*/
|
|
34
|
+
async listUpcomingEvents(timeMin, timeMax, maxResults = 20) {
|
|
35
|
+
const res = await this.calendar.events.list({
|
|
36
|
+
calendarId: "primary",
|
|
37
|
+
timeMin: timeMin.toISOString(),
|
|
38
|
+
timeMax: timeMax.toISOString(),
|
|
39
|
+
maxResults,
|
|
40
|
+
singleEvents: true,
|
|
41
|
+
orderBy: "startTime",
|
|
42
|
+
});
|
|
43
|
+
return res.data.items ?? [];
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Create a new calendar event.
|
|
47
|
+
*/
|
|
48
|
+
async createEvent(options) {
|
|
49
|
+
const res = await this.calendar.events.insert({
|
|
50
|
+
calendarId: "primary",
|
|
51
|
+
requestBody: {
|
|
52
|
+
summary: options.summary,
|
|
53
|
+
description: options.description,
|
|
54
|
+
start: {
|
|
55
|
+
dateTime: options.start.toISOString(),
|
|
56
|
+
timeZone: Intl.DateTimeFormat().resolvedOptions().timeZone,
|
|
57
|
+
},
|
|
58
|
+
end: {
|
|
59
|
+
dateTime: options.end.toISOString(),
|
|
60
|
+
timeZone: Intl.DateTimeFormat().resolvedOptions().timeZone,
|
|
61
|
+
},
|
|
62
|
+
recurrence: options.recurrence,
|
|
63
|
+
},
|
|
64
|
+
});
|
|
65
|
+
return res.data;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Update an existing event.
|
|
69
|
+
*/
|
|
70
|
+
async updateEvent(eventId, updates) {
|
|
71
|
+
const requestBody = {};
|
|
72
|
+
if (updates.summary)
|
|
73
|
+
requestBody.summary = updates.summary;
|
|
74
|
+
if (updates.description)
|
|
75
|
+
requestBody.description = updates.description;
|
|
76
|
+
if (updates.start) {
|
|
77
|
+
requestBody.start = {
|
|
78
|
+
dateTime: updates.start.toISOString(),
|
|
79
|
+
timeZone: Intl.DateTimeFormat().resolvedOptions().timeZone,
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
if (updates.end) {
|
|
83
|
+
requestBody.end = {
|
|
84
|
+
dateTime: updates.end.toISOString(),
|
|
85
|
+
timeZone: Intl.DateTimeFormat().resolvedOptions().timeZone,
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
const res = await this.calendar.events.patch({
|
|
89
|
+
calendarId: "primary",
|
|
90
|
+
eventId,
|
|
91
|
+
requestBody,
|
|
92
|
+
});
|
|
93
|
+
return res.data;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Delete an event.
|
|
97
|
+
*/
|
|
98
|
+
async deleteEvent(eventId) {
|
|
99
|
+
await this.calendar.events.delete({
|
|
100
|
+
calendarId: "primary",
|
|
101
|
+
eventId,
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Find free time slots in a given range.
|
|
106
|
+
*/
|
|
107
|
+
async findFreeTime(timeMin, timeMax) {
|
|
108
|
+
const res = await this.calendar.freebusy.query({
|
|
109
|
+
requestBody: {
|
|
110
|
+
timeMin: timeMin.toISOString(),
|
|
111
|
+
timeMax: timeMax.toISOString(),
|
|
112
|
+
items: [{ id: "primary" }],
|
|
113
|
+
},
|
|
114
|
+
});
|
|
115
|
+
const primaryCal = res.data.calendars?.primary;
|
|
116
|
+
const busySlots = primaryCal?.busy ?? [];
|
|
117
|
+
// Compute free slots from busy slots
|
|
118
|
+
const freeSlots = [];
|
|
119
|
+
let cursor = timeMin.toISOString();
|
|
120
|
+
for (const busy of busySlots) {
|
|
121
|
+
if (busy.start && cursor < busy.start) {
|
|
122
|
+
freeSlots.push({ start: cursor, end: busy.start });
|
|
123
|
+
}
|
|
124
|
+
cursor = busy.end ?? cursor;
|
|
125
|
+
}
|
|
126
|
+
if (cursor < timeMax.toISOString()) {
|
|
127
|
+
freeSlots.push({ start: cursor, end: timeMax.toISOString() });
|
|
128
|
+
}
|
|
129
|
+
return freeSlots;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
//# sourceMappingURL=google-calendar.js.map
|