computer-agents 0.2.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Testbase
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,184 @@
1
+ # computer-agents
2
+
3
+ [![npm version](https://badge.fury.io/js/computer-agents.svg)](https://www.npmjs.com/package/computer-agents)
4
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
5
+
6
+ Build computer-use agents that write code, run tests, and deploy apps. Seamless local and cloud execution with automatic session continuity.
7
+
8
+ ## Installation
9
+
10
+ ```bash
11
+ npm install computer-agents
12
+ ```
13
+
14
+ ## Quick Start
15
+
16
+ ```typescript
17
+ import { Agent, run, LocalRuntime } from 'computer-agents';
18
+
19
+ const agent = new Agent({
20
+ agentType: 'computer',
21
+ runtime: new LocalRuntime(),
22
+ instructions: 'You are an expert developer.'
23
+ });
24
+
25
+ const result = await run(agent, "Create a Python script that prints 'Hello World'");
26
+ console.log(result.finalOutput);
27
+ ```
28
+
29
+ ## Features
30
+
31
+ - **🎯 Two Agent Types** - `'llm'` for reasoning, `'computer'` for execution
32
+ - **🔄 Runtime Abstraction** - Seamless local ↔ cloud switching
33
+ - **⚡️ Automatic Session Continuity** - Multi-turn conversations work automatically
34
+ - **🔌 Unified MCP Config** - Single configuration for all agent types
35
+ - **📦 Manual Composition** - Build custom workflows explicitly
36
+ - **☁️ Cloud Execution** - GCE-based with workspace sync
37
+ - **✨ Professional** - Zero type assertions, clean abstractions
38
+
39
+ ## Agent Types
40
+
41
+ ### Computer Agent (Local)
42
+
43
+ ```typescript
44
+ import { Agent, run, LocalRuntime } from 'computer-agents';
45
+
46
+ const agent = new Agent({
47
+ agentType: 'computer',
48
+ runtime: new LocalRuntime(),
49
+ workspace: './my-project',
50
+ instructions: 'You are an expert developer.'
51
+ });
52
+
53
+ const result = await run(agent, 'Add a README to the project');
54
+ ```
55
+
56
+ ### Computer Agent (Cloud)
57
+
58
+ ```typescript
59
+ import { Agent, run, CloudRuntime } from 'computer-agents';
60
+
61
+ const agent = new Agent({
62
+ agentType: 'computer',
63
+ runtime: new CloudRuntime({ debug: true }),
64
+ workspace: './my-project'
65
+ });
66
+
67
+ const result = await run(agent, 'Run the tests');
68
+ ```
69
+
70
+ ### LLM Agent
71
+
72
+ ```typescript
73
+ import { Agent, run } from 'computer-agents';
74
+
75
+ const agent = new Agent({
76
+ agentType: 'llm',
77
+ model: 'gpt-4o',
78
+ instructions: 'You create detailed implementation plans.'
79
+ });
80
+
81
+ const result = await run(agent, 'Plan how to add user authentication');
82
+ ```
83
+
84
+ ## Multi-Agent Workflows
85
+
86
+ ```typescript
87
+ import { Agent, run, LocalRuntime } from 'computer-agents';
88
+
89
+ // LLM creates plan
90
+ const planner = new Agent({
91
+ agentType: 'llm',
92
+ model: 'gpt-4o',
93
+ instructions: 'Create detailed implementation plans.'
94
+ });
95
+
96
+ // Computer agent executes plan
97
+ const executor = new Agent({
98
+ agentType: 'computer',
99
+ runtime: new LocalRuntime(),
100
+ instructions: 'Execute implementation plans.'
101
+ });
102
+
103
+ // LLM reviews result
104
+ const reviewer = new Agent({
105
+ agentType: 'llm',
106
+ model: 'gpt-4o',
107
+ instructions: 'Review implementations for quality.'
108
+ });
109
+
110
+ // Manual workflow
111
+ const task = "Add user authentication";
112
+ const plan = await run(planner, `Plan: ${task}`);
113
+ const code = await run(executor, plan.finalOutput);
114
+ const review = await run(reviewer, `Review: ${code.finalOutput}`);
115
+ ```
116
+
117
+ ## Session Continuity
118
+
119
+ Multiple `run()` calls automatically maintain context:
120
+
121
+ ```typescript
122
+ const agent = new Agent({
123
+ agentType: 'computer',
124
+ runtime: new LocalRuntime()
125
+ });
126
+
127
+ await run(agent, 'Create app.py'); // New session
128
+ await run(agent, 'Add error handling'); // Continues same session!
129
+ await run(agent, 'Add tests'); // Still same session!
130
+
131
+ agent.resetSession(); // Start fresh
132
+ await run(agent, 'Start new project'); // New session
133
+ ```
134
+
135
+ ## Configuration
136
+
137
+ ### Environment Variables
138
+
139
+ ```bash
140
+ # Required - Codex SDK and OpenAI both need this
141
+ OPENAI_API_KEY=your-openai-key
142
+ ```
143
+
144
+ ### MCP Server Integration
145
+
146
+ ```typescript
147
+ import type { McpServerConfig } from 'computer-agents';
148
+
149
+ const mcpServers: McpServerConfig[] = [
150
+ {
151
+ type: 'stdio',
152
+ name: 'filesystem',
153
+ command: 'npx',
154
+ args: ['@modelcontextprotocol/server-filesystem', '/workspace']
155
+ },
156
+ {
157
+ type: 'http',
158
+ name: 'notion',
159
+ url: 'https://notion-mcp.example.com/mcp',
160
+ bearerToken: process.env.NOTION_TOKEN
161
+ }
162
+ ];
163
+
164
+ const agent = new Agent({
165
+ agentType: 'computer',
166
+ runtime: new LocalRuntime(),
167
+ mcpServers // Works for both LLM and computer agents!
168
+ });
169
+ ```
170
+
171
+ ## Documentation
172
+
173
+ - [GitHub Repository](https://github.com/testbasehq/computer-agents)
174
+ - [Examples](https://github.com/testbasehq/computer-agents/tree/main/examples)
175
+ - [API Reference](https://github.com/testbasehq/computer-agents/blob/main/docs)
176
+
177
+ ## License
178
+
179
+ MIT
180
+
181
+ ## Credits
182
+
183
+ - Built on [OpenAI Agents SDK](https://github.com/openai/openai-agents-js)
184
+ - Integrates with [@openai/codex-sdk](https://www.npmjs.com/package/@openai/codex-sdk)
@@ -0,0 +1,3 @@
1
+ import type * as CoreTypes from '@testbase/agents-core';
2
+ export declare function run<TAgent extends CoreTypes.Agent<any, any>, TContext = undefined>(agent: TAgent, input: string | CoreTypes.AgentInputItem[] | CoreTypes.RunState<TContext, TAgent>, options?: CoreTypes.StreamRunOptions<TContext> | CoreTypes.NonStreamRunOptions<TContext>): Promise<CoreTypes.RunResult<TContext, TAgent> | CoreTypes.StreamedRunResult<TContext, TAgent>>;
3
+ export * from '@testbase/agents-core';
package/dist/index.js ADDED
@@ -0,0 +1,73 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.run = run;
18
+ const node_url_1 = require("node:url");
19
+ const node_path_1 = require("node:path");
20
+ const dynamicImport = new Function('specifier', 'return import(specifier);');
21
+ let coreModule;
22
+ function getCore() {
23
+ if (coreModule) {
24
+ return coreModule;
25
+ }
26
+ try {
27
+ coreModule = require('@testbase/agents-core');
28
+ }
29
+ catch {
30
+ const localPath = (0, node_path_1.resolve)(__dirname, '../../agents-core/dist/index.js');
31
+ coreModule = require(localPath);
32
+ }
33
+ return coreModule;
34
+ }
35
+ let openAIProviderCtorPromise;
36
+ async function loadOpenAIProvider() {
37
+ if (openAIProviderCtorPromise) {
38
+ return openAIProviderCtorPromise;
39
+ }
40
+ openAIProviderCtorPromise = (async () => {
41
+ try {
42
+ const mod = await dynamicImport('@testbase/agents-openai');
43
+ return mod.OpenAIProvider;
44
+ }
45
+ catch {
46
+ const localUrl = (0, node_url_1.pathToFileURL)((0, node_path_1.resolve)(__dirname, '../../agents-openai/dist/index.mjs')).href;
47
+ const mod = await dynamicImport(localUrl);
48
+ return mod.OpenAIProvider;
49
+ }
50
+ })();
51
+ return openAIProviderCtorPromise;
52
+ }
53
+ let llmProvider;
54
+ async function ensureProviderForAgent(agent) {
55
+ const Core = getCore();
56
+ const agentType = agent.agentType ?? 'llm';
57
+ if (agentType === 'llm') {
58
+ if (!llmProvider) {
59
+ const OpenAIProviderCtor = await loadOpenAIProvider();
60
+ llmProvider = new OpenAIProviderCtor();
61
+ }
62
+ Core.setDefaultModelProvider(llmProvider);
63
+ }
64
+ // Computer agents bypass the model provider entirely
65
+ // They execute directly via runtime.execute() in run.ts
66
+ }
67
+ const coreRun = getCore().run;
68
+ async function run(agent, input, options) {
69
+ await ensureProviderForAgent(agent);
70
+ return coreRun(agent, input, options);
71
+ }
72
+ __exportStar(require("@testbase/agents-core"), exports);
73
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAwEA,kBAcC;AAtFD,uCAAyC;AACzC,yCAAoC;AAQpC,MAAM,aAAa,GAAG,IAAI,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,CAAC;QACxB,IAAI,CAAC,WAAW,EAAE,CAAC;YACjB,MAAM,kBAAkB,GAAG,MAAM,kBAAkB,EAAE,CAAC;YACtD,WAAW,GAAG,IAAI,kBAAkB,EAAE,CAAC;QACzC,CAAC;QACD,IAAI,CAAC,uBAAuB,CAAC,WAAW,CAAC,CAAC;IAC5C,CAAC;IACD,qDAAqD;IACrD,wDAAwD;AAC1D,CAAC;AAED,MAAM,OAAO,GAAG,OAAO,EAAE,CAAC,GAAG,CAAC;AAEvB,KAAK,UAAU,GAAG,CAIvB,KAAa,EACb,KAAiF,EACjF,OAE2C;IAI3C,MAAM,sBAAsB,CAAC,KAAK,CAAC,CAAC;IACpC,OAAO,OAAO,CAAC,KAAK,EAAE,KAAK,EAAE,OAAc,CAAC,CAAC;AAC/C,CAAC;AAED,wDAAsC"}
package/dist/index.mjs ADDED
@@ -0,0 +1,57 @@
1
+ import { pathToFileURL } from 'node:url';
2
+ import { resolve } from 'node:path';
3
+ import { fileURLToPath } from 'node:url';
4
+ import * as CoreModule from '@testbase/agents-core';
5
+ const __dirname = fileURLToPath(new URL('.', import.meta.url));
6
+ const dynamicImport = new Function('specifier', 'return import(specifier);');
7
+ function getCore() {
8
+ return CoreModule;
9
+ }
10
+ let openAIProviderCtorPromise;
11
+ async function loadOpenAIProvider() {
12
+ if (openAIProviderCtorPromise) {
13
+ return openAIProviderCtorPromise;
14
+ }
15
+ openAIProviderCtorPromise = (async () => {
16
+ try {
17
+ const mod = await dynamicImport('@testbase/agents-openai');
18
+ return mod.OpenAIProvider;
19
+ }
20
+ catch {
21
+ const localUrl = pathToFileURL(resolve(__dirname, '../../agents-openai/dist/index.mjs')).href;
22
+ const mod = await dynamicImport(localUrl);
23
+ return mod.OpenAIProvider;
24
+ }
25
+ })();
26
+ return openAIProviderCtorPromise;
27
+ }
28
+ let llmProvider;
29
+ let codexProvider;
30
+ async function ensureProviderForAgent(agent) {
31
+ const Core = getCore();
32
+ const agentType = agent.agentType ?? 'llm';
33
+ if (agentType === 'llm') {
34
+ if (!llmProvider) {
35
+ const OpenAIProviderCtor = await loadOpenAIProvider();
36
+ llmProvider = new OpenAIProviderCtor();
37
+ }
38
+ Core.setDefaultModelProvider(llmProvider);
39
+ }
40
+ else {
41
+ if (!codexProvider) {
42
+ codexProvider = new Core.CodexModelProvider();
43
+ }
44
+ Core.setDefaultModelProvider(codexProvider);
45
+ }
46
+ }
47
+ // Lazy getter for coreRun to avoid calling getCore() at module init time
48
+ function getCoreRun() {
49
+ return getCore().run;
50
+ }
51
+ export async function run(agent, input, options) {
52
+ await ensureProviderForAgent(agent);
53
+ const coreRun = getCoreRun();
54
+ return coreRun(agent, input, options);
55
+ }
56
+ export * from '@testbase/agents-core';
57
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,8 @@
1
+ export declare const METADATA: {
2
+ name: string;
3
+ version: string;
4
+ versions: {
5
+ "@testbase/agents": string;
6
+ };
7
+ };
8
+ export default METADATA;
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ // This file is automatically generated
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.METADATA = void 0;
5
+ exports.METADATA = {
6
+ "name": "@testbase/agents",
7
+ "version": "0.1.0",
8
+ "versions": {
9
+ "@testbase/agents": "0.1.0"
10
+ }
11
+ };
12
+ exports.default = exports.METADATA;
13
+ //# sourceMappingURL=metadata.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"metadata.js","sourceRoot":"","sources":["../src/metadata.ts"],"names":[],"mappings":";AACA,uCAAuC;;;AAE1B,QAAA,QAAQ,GAAG;IACtB,MAAM,EAAE,kBAAkB;IAC1B,SAAS,EAAE,OAAO;IAClB,UAAU,EAAE;QACV,kBAAkB,EAAE,OAAO;KAC5B;CACF,CAAC;AAEF,kBAAe,gBAAQ,CAAC"}
@@ -0,0 +1,10 @@
1
+ // This file is automatically generated
2
+ export const METADATA = {
3
+ "name": "@testbase/agents",
4
+ "version": "0.1.0",
5
+ "versions": {
6
+ "@testbase/agents": "0.1.0"
7
+ }
8
+ };
9
+ export default METADATA;
10
+ //# sourceMappingURL=metadata.js.map
package/package.json ADDED
@@ -0,0 +1,50 @@
1
+ {
2
+ "name": "computer-agents",
3
+ "repository": "https://github.com/testbasehq/computer-agents",
4
+ "homepage": "https://github.com/testbasehq/computer-agents",
5
+ "version": "0.2.0",
6
+ "description": "Build computer-use agents that write code, run tests, and deploy apps. Seamless local and cloud execution with automatic session continuity.",
7
+ "author": "Testbase",
8
+ "main": "dist/index.js",
9
+ "types": "dist/index.d.ts",
10
+ "exports": {
11
+ ".": {
12
+ "types": "./dist/index.d.ts",
13
+ "require": "./dist/index.js",
14
+ "import": "./dist/index.mjs"
15
+ }
16
+ },
17
+ "dependencies": {
18
+ "computer-agents-openai": "0.2.0",
19
+ "computer-agents-core": "0.2.0"
20
+ },
21
+ "keywords": [
22
+ "computer-agents",
23
+ "codex",
24
+ "agents",
25
+ "ai",
26
+ "automation",
27
+ "code-generation",
28
+ "computer-use",
29
+ "openai"
30
+ ],
31
+ "license": "MIT",
32
+ "devDependencies": {
33
+ "zod": "^3.25.40"
34
+ },
35
+ "peerDependencies": {
36
+ "zod": "^3.25.40"
37
+ },
38
+ "files": [
39
+ "dist"
40
+ ],
41
+ "typesVersions": {},
42
+ "publishConfig": {
43
+ "access": "public"
44
+ },
45
+ "scripts": {
46
+ "prebuild": "tsx ../../scripts/embedMeta.ts",
47
+ "build": "tsc",
48
+ "build-check": "tsc --noEmit -p ./tsconfig.test.json"
49
+ }
50
+ }