openpond-code 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/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ # openpond-code
2
+
3
+ ## 0.1.0
4
+
5
+ - Initial release of the API key CLI.
package/README.md ADDED
@@ -0,0 +1,121 @@
1
+ # openpond-code
2
+
3
+ API-key CLI + local TUI client for OpenPond.
4
+
5
+ ## API key CLI (openpond/op)
6
+
7
+ Install:
8
+
9
+ ```bash
10
+ npm i -g openpond-code
11
+ # or
12
+ npx --package openpond-code openpond tool list handle/repo
13
+ # or (curl installer)
14
+ curl -fsSL https://openpond.ai/install.sh | bash
15
+ ```
16
+
17
+ Login (stores key in `~/.openpond/config.json`):
18
+
19
+ ```bash
20
+ openpond login
21
+ # or (non-interactive)
22
+ openpond login --api-key opk_...
23
+ ```
24
+
25
+ Commands:
26
+
27
+ ```bash
28
+ openpond tool list <handle>/<repo>
29
+ openpond tool run <handle>/<repo> <tool> --body '{"foo":"bar"}'
30
+ openpond deploy watch <handle>/<repo> --branch main
31
+ openpond template status <handle>/<repo>
32
+ openpond template branches <handle>/<repo>
33
+ openpond template update <handle>/<repo> --env production
34
+ openpond repo create --name my-repo --path .
35
+ openpond repo push --path . --branch main
36
+ openpond apps list [--handle <handle>] [--refresh]
37
+ openpond apps tools
38
+ openpond apps deploy <handle>/<repo> --env production --watch
39
+ openpond apps env get <handle>/<repo>
40
+ openpond apps env set <handle>/<repo> --env '{"OPENTOOL_PUBLIC_HL_SIGNAL_BOT_CONFIG":"..."}'
41
+ openpond apps performance [--app-id <id>]
42
+ openpond apps agent create --prompt "Build a daily digest agent"
43
+ openpond apps tools execute <appId> <deploymentId> <tool> --body '{"foo":"bar"}'
44
+ openpond apps positions tx --method GET --params '{"status":"open"}'
45
+ openpond opentool init --dir .
46
+ ```
47
+
48
+ Command reference:
49
+
50
+ - `openpond login`: prompt for API key and save to `~/.openpond/config.json`.
51
+ - `openpond login --api-key <key>`: save the API key without prompting.
52
+ - `openpond tool list <handle>/<repo>`: list tools for the latest deployment.
53
+ - `openpond tool run <handle>/<repo> <tool> [--body <json>] [--method <METHOD>]`: run a tool on the latest deployment.
54
+ - `openpond deploy watch <handle>/<repo> [--branch <branch>]`: stream deployment logs for the latest deployment.
55
+ - `openpond template status <handle>/<repo>`: check whether a template update is available.
56
+ - `openpond template branches <handle>/<repo>`: list available template branches.
57
+ - `openpond template update <handle>/<repo> [--env preview|production]`: deploy the latest template commit.
58
+ - `openpond repo create --name <name> [--path <dir>] [--empty|--opentool] [--deploy-on-push]`: create an internal repo and attach the git remote.
59
+ - `openpond repo push [--path <dir>] [--branch <branch>]`: push the current git branch using a tokenized remote (non-interactive, restores origin after push).
60
+ - `openpond apps list [--handle <handle>] [--refresh]`: list apps for your account, optionally filtered by handle.
61
+ - `openpond apps tools`: list tools for your account (public API).
62
+ - `openpond apps deploy <handle>/<repo> [--env preview|production] [--watch]`: trigger a deployment for an app.
63
+ - `openpond apps env get <handle>/<repo>`: get OPENTOOL_PUBLIC_* env vars for an app.
64
+ - `openpond apps env set <handle>/<repo> --env <json>`: set OPENTOOL_PUBLIC_* env vars for an app.
65
+ - `openpond apps performance [--app-id <id>]`: fetch performance summary, optionally scoped to an app.
66
+ - `openpond apps agent create --prompt <text> [--template-id <id>]`: create an agent from a prompt (streams deploy logs by default).
67
+ - `openpond apps tools execute <appId> <deploymentId> <tool> [--body <json>] [--method <METHOD>] [--headers <json>]`: execute a tool for a specific deployment.
68
+ - `openpond apps positions tx [--method <GET|POST>] [--body <json>] [--params <json>]`: read or submit positions.
69
+ - `openpond opentool <init|validate|build> [args]`: run OpenTool CLI commands via `npx opentool`.
70
+
71
+ ## TypeScript package
72
+
73
+ Programmatic API that mirrors the CLI command surface:
74
+
75
+ ```ts
76
+ import { createClient } from "openpond-code";
77
+
78
+ const client = createClient({ apiKey: process.env.OPENPOND_API_KEY! });
79
+
80
+ const { tools } = await client.tool.list("handle/repo");
81
+ const result = await client.tool.run("handle/repo", "myTool", {
82
+ body: { foo: "bar" },
83
+ });
84
+
85
+ const apps = await client.apps.list();
86
+ const accountTools = await client.apps.tools();
87
+ const performance = await client.apps.performance({ appId: "app_123" });
88
+ const repo = await client.repo.create({ name: "my-repo", repoInit: "empty" });
89
+
90
+ await client.apps.agentCreate(
91
+ { prompt: "Build a daily digest agent" },
92
+ {
93
+ onItems: (items) => {
94
+ for (const item of items) {
95
+ console.log(item);
96
+ }
97
+ },
98
+ }
99
+ );
100
+ ```
101
+
102
+ You can override hosts with `baseUrl`, `apiUrl`, and `toolUrl` in `createClient`, or
103
+ via `OPENPOND_BASE_URL`, `OPENPOND_API_URL`, and `OPENPOND_TOOL_URL`.
104
+
105
+ Examples live in `openpond-code/examples`.
106
+
107
+ ## Local TUI
108
+
109
+ Minimal terminal client for OpenPond chat + history. This is a standalone folder intended
110
+ to be extracted into its own repo later.
111
+
112
+ ## Run
113
+
114
+ ```bash
115
+ bun install
116
+ bun run dev
117
+ ```
118
+
119
+ Cache:
120
+
121
+ - `~/.openpond/cache.json` caches app/tool lists for 1 hour and refreshes automatically on next use.
package/RELEASE.md ADDED
@@ -0,0 +1,24 @@
1
+ # Release Workflow
2
+
3
+ This package uses [Changesets](https://github.com/changesets/changesets) for version management and publishing to npm.
4
+
5
+ ## Setup required
6
+
7
+ ### 1) npm trusted publisher
8
+ Configure npm trusted publishing for this GitHub repository/workflow.
9
+
10
+ ### 2) GitHub token
11
+ `GITHUB_TOKEN` is provided by GitHub Actions.
12
+
13
+ ## Development workflow
14
+
15
+ 1) Make your changes
16
+ 2) Create a changeset:
17
+ ```bash
18
+ npm run changeset
19
+ ```
20
+ 3) Commit code + changeset
21
+ 4) Open a PR to `master`
22
+
23
+ When changesets are merged into `master`, the release workflow will open a Version Packages PR.
24
+ Merging that PR publishes to npm and updates `CHANGELOG.md`.
package/dist/api.d.ts ADDED
@@ -0,0 +1,247 @@
1
+ import type { ChatRequestBody } from "./types";
2
+ export type DeviceStartResponse = {
3
+ deviceCode: string;
4
+ userCode: string;
5
+ verificationUrl: string;
6
+ expiresAt: string;
7
+ };
8
+ export type DevicePollResponse = {
9
+ accessToken?: string;
10
+ };
11
+ export type ToolManifest = {
12
+ version?: string;
13
+ tools: Array<{
14
+ type: "function";
15
+ function: {
16
+ name: string;
17
+ description?: string;
18
+ parameters?: unknown;
19
+ };
20
+ }>;
21
+ };
22
+ export declare function apiFetch(baseUrl: string, token: string | null, path: string, init?: RequestInit): Promise<Response>;
23
+ export declare function startDeviceLogin(baseUrl: string): Promise<DeviceStartResponse>;
24
+ export declare function pollDeviceLogin(baseUrl: string, deviceCode?: string, userCode?: string): Promise<DevicePollResponse>;
25
+ export type CreateLocalProjectInput = {
26
+ name: string;
27
+ templateId?: string;
28
+ templateRepoUrl?: string;
29
+ templateBranch?: string;
30
+ envVars?: Record<string, string>;
31
+ };
32
+ export type CreateRepoRequest = {
33
+ name: string;
34
+ description?: string;
35
+ repoInit?: "opentool" | "empty";
36
+ templateRepoUrl?: string;
37
+ templateBranch?: string;
38
+ envVars?: Record<string, string>;
39
+ deployOnPush?: boolean;
40
+ autoScheduleMigration?: boolean;
41
+ };
42
+ export type CreateRepoResponse = {
43
+ appId: string;
44
+ gitOwner?: string | null;
45
+ gitRepo?: string | null;
46
+ gitHost?: string | null;
47
+ repoUrl?: string | null;
48
+ defaultBranch?: string;
49
+ };
50
+ export type HeadlessAppRequest = {
51
+ name?: string;
52
+ description?: string;
53
+ templateId?: string;
54
+ templateRepoUrl?: string;
55
+ templateBranch?: string;
56
+ templateName?: string;
57
+ envVars?: Record<string, string>;
58
+ visibility?: "private" | "public";
59
+ };
60
+ export type HeadlessAppResponse = {
61
+ status: "ok" | "error";
62
+ appId?: string;
63
+ deploymentId?: string;
64
+ conversationId?: string;
65
+ error?: string;
66
+ };
67
+ export type HeadlessAppsResponse = {
68
+ items: HeadlessAppResponse[];
69
+ };
70
+ export type TemplateStatusResponse = {
71
+ templateRepoUrl: string;
72
+ templateBranch: string;
73
+ remoteSha: string;
74
+ lastAppliedSha: string | null;
75
+ updateAvailable: boolean;
76
+ };
77
+ export type TemplateBranchesResponse = {
78
+ templateRepoUrl: string;
79
+ templateBranch: string;
80
+ defaultBranch: string;
81
+ branches: string[];
82
+ };
83
+ export type TemplateDeployLatestRequest = {
84
+ environment: "preview" | "production";
85
+ };
86
+ export type TemplateDeployLatestResponse = {
87
+ deploymentId: string;
88
+ version: number;
89
+ templateCommitSha: string;
90
+ };
91
+ export type AppEnvironmentUpdateRequest = {
92
+ envVars: Record<string, string>;
93
+ };
94
+ export type AppEnvironmentUpdateResponse = {
95
+ environment: Record<string, string>;
96
+ };
97
+ export type AppEnvironmentGetResponse = {
98
+ environment: Record<string, string>;
99
+ };
100
+ export type AppListItem = {
101
+ id: string;
102
+ name: string;
103
+ description: string | null;
104
+ appType: string | null;
105
+ visibility: "public" | "private";
106
+ gitOwner: string | null;
107
+ gitRepo: string | null;
108
+ gitProvider: string | null;
109
+ gitHost: string | null;
110
+ internalToolName: string | null;
111
+ defaultBranch: string | null;
112
+ createdAt: string;
113
+ updatedAt: string;
114
+ teamId: string | null;
115
+ teamName: string | null;
116
+ handle: string | null;
117
+ repo: string | null;
118
+ latestDeployment: {
119
+ id: string;
120
+ status: string;
121
+ deploymentDomain: string | null;
122
+ internalUrl: string | null;
123
+ createdAt: string;
124
+ isProduction: boolean | null;
125
+ gitBranch: string | null;
126
+ } | null;
127
+ };
128
+ export declare function listApps(apiBase: string, token: string, options?: {
129
+ handle?: string;
130
+ }): Promise<AppListItem[]>;
131
+ export declare function createLocalProject(baseUrl: string, token: string, input: CreateLocalProjectInput): Promise<{
132
+ appId: string;
133
+ }>;
134
+ export declare function createRepo(apiBase: string, apiKey: string, input: CreateRepoRequest): Promise<CreateRepoResponse>;
135
+ export declare function createHeadlessApps(baseUrl: string, token: string, items: HeadlessAppRequest[]): Promise<HeadlessAppsResponse>;
136
+ export declare function getTemplateStatus(apiBase: string, token: string, appId: string): Promise<TemplateStatusResponse>;
137
+ export declare function listTemplateBranches(apiBase: string, token: string, appId: string): Promise<TemplateBranchesResponse>;
138
+ export declare function deployLatestTemplate(apiBase: string, token: string, appId: string, input: TemplateDeployLatestRequest): Promise<TemplateDeployLatestResponse>;
139
+ export declare function updateAppEnvironment(apiBase: string, token: string, appId: string, input: AppEnvironmentUpdateRequest): Promise<AppEnvironmentUpdateResponse>;
140
+ export declare function getAppEnvironment(apiBase: string, token: string, appId: string): Promise<AppEnvironmentGetResponse>;
141
+ export declare function fetchToolManifest(baseUrl: string, token: string): Promise<ToolManifest>;
142
+ export declare function listUserTools(baseUrl: string, token: string): Promise<{
143
+ tools?: unknown[];
144
+ }>;
145
+ export type AgentCreateRequest = {
146
+ prompt: string;
147
+ template?: {
148
+ name?: string;
149
+ description?: string;
150
+ templateId?: string;
151
+ templateRepoUrl?: string;
152
+ templateBranch?: string;
153
+ envVars?: Record<string, string>;
154
+ };
155
+ deployEnvironment?: "preview" | "production";
156
+ deployDisabled?: boolean;
157
+ autoDeployOnFinish?: boolean;
158
+ streamDeployLogs?: boolean;
159
+ };
160
+ export declare function createAgentFromPrompt(baseUrl: string, token: string, payload: AgentCreateRequest): Promise<Response>;
161
+ export declare function getUserPerformance(baseUrl: string, token: string, options?: {
162
+ appId?: string;
163
+ }): Promise<unknown>;
164
+ export declare function postAgentDigest(baseUrl: string, token: string, body: {
165
+ content: string;
166
+ runAt?: string;
167
+ metadata?: Record<string, unknown>;
168
+ }): Promise<unknown>;
169
+ export declare function executeUserTool(baseUrl: string, token: string, body: {
170
+ appId: string;
171
+ deploymentId: string;
172
+ toolName: string;
173
+ scheduleId?: string;
174
+ method?: "GET" | "POST" | "PUT" | "DELETE";
175
+ body?: unknown;
176
+ headers?: Record<string, string>;
177
+ notifyEmail?: boolean;
178
+ }): Promise<{
179
+ ok: boolean;
180
+ status: number;
181
+ data?: unknown;
182
+ error?: string;
183
+ }>;
184
+ export declare function submitPositionsTx(baseUrl: string, token: string, params: {
185
+ method: "GET" | "POST";
186
+ body?: unknown;
187
+ query?: Record<string, string>;
188
+ }): Promise<unknown>;
189
+ export declare function chatRequest(baseUrl: string, token: string, body: ChatRequestBody): Promise<Response>;
190
+ export declare function commitFiles(baseUrl: string, token: string, appId: string, files: Record<string, string>, commitMessage: string): Promise<{
191
+ commitSha: string;
192
+ }>;
193
+ export declare function deployApp(baseUrl: string, token: string, appId: string, input?: {
194
+ environment?: "preview" | "production";
195
+ commitSha?: string;
196
+ branch?: string;
197
+ }): Promise<{
198
+ deploymentId: string;
199
+ environment?: "preview" | "production";
200
+ url?: string;
201
+ version?: number;
202
+ commitSha?: string;
203
+ }>;
204
+ export type DeploymentLogEntry = {
205
+ id: string;
206
+ type?: string;
207
+ message: string;
208
+ createdAt: string;
209
+ };
210
+ export declare function getDeploymentLogs(apiBase: string, token: string, deploymentId: string): Promise<DeploymentLogEntry[]>;
211
+ export declare function getDeploymentStatus(apiBase: string, token: string, deploymentId: string): Promise<{
212
+ status?: string;
213
+ }>;
214
+ export declare function getLatestDeploymentForApp(apiBase: string, token: string, appId: string, options?: {
215
+ status?: string[];
216
+ createdAfter?: string;
217
+ branch?: string;
218
+ }): Promise<{
219
+ id?: string;
220
+ status?: string;
221
+ } | null>;
222
+ export type DeploymentDetail = {
223
+ id: string;
224
+ appId: string;
225
+ status: string;
226
+ createdAt: string;
227
+ gitBranch: string | null;
228
+ toolsJson?: unknown;
229
+ metadataJson?: unknown;
230
+ };
231
+ export declare function getDeploymentDetail(apiBase: string, token: string, deploymentId: string): Promise<DeploymentDetail | null>;
232
+ export type ToolExecuteRequest = {
233
+ appId: string;
234
+ deploymentId: string;
235
+ toolName: string;
236
+ method?: "GET" | "POST" | "PUT" | "DELETE";
237
+ body?: unknown;
238
+ headers?: Record<string, string>;
239
+ };
240
+ export type ToolExecuteResponse = {
241
+ ok: boolean;
242
+ status: number;
243
+ data?: unknown;
244
+ error?: string;
245
+ };
246
+ export declare function resolveWorkerBaseUrl(baseUrl: string): string;
247
+ export declare function executeHostedTool(baseUrl: string, token: string, payload: ToolExecuteRequest): Promise<ToolExecuteResponse>;
@@ -0,0 +1,22 @@
1
+ import type { AppListItem } from "./api";
2
+ export declare const DEFAULT_CACHE_TTL_MS: number;
3
+ export declare function getCachedApps(params: {
4
+ apiBase: string;
5
+ apiKey: string;
6
+ ttlMs?: number;
7
+ }): Promise<AppListItem[] | null>;
8
+ export declare function setCachedApps(params: {
9
+ apiBase: string;
10
+ apiKey: string;
11
+ apps: AppListItem[];
12
+ }): Promise<void>;
13
+ export declare function getCachedTools(params: {
14
+ apiBase: string;
15
+ apiKey: string;
16
+ ttlMs?: number;
17
+ }): Promise<unknown[] | null>;
18
+ export declare function setCachedTools(params: {
19
+ apiBase: string;
20
+ apiKey: string;
21
+ tools: unknown[];
22
+ }): Promise<void>;