@codeworksh/cli 0.0.1-dev.20260918040208
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 +21 -0
- package/README.md +134 -0
- package/catalog-DobwC9tt.mjs +31 -0
- package/catalog-DobwC9tt.mjs.map +1 -0
- package/error-Cr8LvfEq.mjs +12928 -0
- package/error-Cr8LvfEq.mjs.map +1 -0
- package/generate-BMJEbGEP.mjs +35 -0
- package/generate-BMJEbGEP.mjs.map +1 -0
- package/harness-hle7yBVs.mjs +18 -0
- package/harness-hle7yBVs.mjs.map +1 -0
- package/index.d.mts +23 -0
- package/index.mjs +24 -0
- package/index.mjs.map +1 -0
- package/list-crXAfyCe.mjs +28 -0
- package/list-crXAfyCe.mjs.map +1 -0
- package/package.json +72 -0
- package/providers-BcJ_s8zf.mjs +15 -0
- package/providers-BcJ_s8zf.mjs.map +1 -0
- package/run-B4mqUQsS.mjs +144 -0
- package/run-B4mqUQsS.mjs.map +1 -0
- package/runtime-DuL-GGrx.mjs +163 -0
- package/runtime-DuL-GGrx.mjs.map +1 -0
- package/serve-CRUpKDkt.mjs +220 -0
- package/serve-CRUpKDkt.mjs.map +1 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Sanchit Kudari <0xsanchit@gmail.com> & Contributors
|
|
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,134 @@
|
|
|
1
|
+
# @codeworksh/cli
|
|
2
|
+
|
|
3
|
+
Run coding-agent sessions in your repo or a sandbox.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pnpm add -g @codeworksh/cli
|
|
9
|
+
# or run directly
|
|
10
|
+
pnpm dlx @codeworksh/cli <command>
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
After install, every command is `codework <command>`.
|
|
14
|
+
|
|
15
|
+
## Development
|
|
16
|
+
|
|
17
|
+
From `packages/codework`, or `pnpm cli` at the repo root:
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
pnpm start -- --help
|
|
21
|
+
pnpm start -- models
|
|
22
|
+
pnpm start -- run "Inspect the failing tests"
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
`start` runs `src/index.ts` with `--conditions=development` so workspace packages resolve to source. The published `codework` binary is the packed `dist` build.
|
|
26
|
+
|
|
27
|
+
---
|
|
28
|
+
|
|
29
|
+
## Commands
|
|
30
|
+
|
|
31
|
+
### `codework run`
|
|
32
|
+
|
|
33
|
+
Run an agent session with a prompt.
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
# Start a new session
|
|
37
|
+
codework run "Inspect and fix the failing tests"
|
|
38
|
+
|
|
39
|
+
# Create a session with explicit provider and model
|
|
40
|
+
codework run --provider openai --model gpt-5.5 --thinking high "Plan database migration"
|
|
41
|
+
|
|
42
|
+
# Continue an existing session
|
|
43
|
+
codework run --session ses_01a070f0 "Now implement the migration script"
|
|
44
|
+
|
|
45
|
+
# Run in an isolated sandbox (local, daytona, vercel, memory, sqldb)
|
|
46
|
+
codework run --sandbox-driver daytona "Inspect repository"
|
|
47
|
+
codework run --sandbox-driver daytona --sandbox-provider-id <remote-id> "Continue in sandbox"
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
#### Flags:
|
|
51
|
+
|
|
52
|
+
- `--server <url>` — Connect to a running RPC server, e.g. `ws://127.0.0.1:7433/rpc`.
|
|
53
|
+
- `-s, --session <id>` — Continue an existing session.
|
|
54
|
+
- `-C, --cwd <path>` — Working directory for a new session.
|
|
55
|
+
- `--sandbox-driver <driver>` — Sandbox driver (`local`, `daytona`, `vercel`, `memory`, `sqldb`). Default: `local`.
|
|
56
|
+
- `--sandbox-id <id>` — Reuse an existing sandbox instance; mutually exclusive with driver/provider coordinates.
|
|
57
|
+
- `--sandbox-provider-id <id>` — Provider ID of an existing remote sandbox.
|
|
58
|
+
- `--provider <id>` — Model catalog provider ID.
|
|
59
|
+
- `--model <id>` — Model ID.
|
|
60
|
+
- `--thinking <level>` — Reasoning effort the model uses before answering (`off`, `minimal`, `low`, `medium`, `high`, `xhigh`, `max`).
|
|
61
|
+
|
|
62
|
+
Global flags: `--user-config-dir`, `--home`, `--database`.
|
|
63
|
+
|
|
64
|
+
---
|
|
65
|
+
|
|
66
|
+
### `codework serve`
|
|
67
|
+
|
|
68
|
+
Start a persistent server that owns sessions and sandboxes:
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
codework serve --host 127.0.0.1 --port 7433
|
|
72
|
+
codework run --server ws://127.0.0.1:7433/rpc "Inspect the failing tests"
|
|
73
|
+
codework run --server ws://127.0.0.1:7433/rpc --session <id> "Now fix them"
|
|
74
|
+
codework run --server ws://127.0.0.1:7433/rpc --sandbox-id <sandbox-id> "Start another session in this sandbox"
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
The default address is `127.0.0.1:7433`; `--port 0` picks an available port and prints the actual URL. Set `--home`, `--database`, and `--user-config-dir` on the server. Model credentials, plugins, and working directories are resolved by the server. A remote run does not boot a local harness.
|
|
78
|
+
|
|
79
|
+
Events are live and not replayed. The client subscribes before admitting its prompt and waits for execution completion after rendering. Lost connections and overflow fail the command; disconnecting leaves server work running. Ctrl-C sends `session.interrupt`, which interrupts the shared session. Remote runs print the sandbox ID for reuse. `session.interrupt` returns `{ interrupted }` as soon as the stop is accepted; `session.wait` is the separate cleanup barrier. A busy period reports itself as `session.execution.started` followed by exactly one of `succeeded`, `failed`, or `interrupted` -- a failure carries a namespaced category (`provider.auth`, `model.not-found`, `sandbox.mount`, ...) that the client renders, and an interruption carries whether it was the user or a server shutdown. Managed sandboxes remain available until explicitly stopped or server shutdown; external sandboxes are not stopped.
|
|
80
|
+
|
|
81
|
+
The v0 endpoint has no authentication; its default binding is loopback. Plugins publish their own event types by declaring them (`Plugin.define({ events: [...] })`, namespaced `plugin.<plugin-id>.*`); the feed carries those and skips types nothing declared. Invalid payloads for declared types fail with a typed encoding error.
|
|
82
|
+
|
|
83
|
+
---
|
|
84
|
+
|
|
85
|
+
### `codework models`
|
|
86
|
+
|
|
87
|
+
List catalog models as `provider/model`, one per line.
|
|
88
|
+
|
|
89
|
+
```bash
|
|
90
|
+
# List all models across all providers
|
|
91
|
+
codework models
|
|
92
|
+
|
|
93
|
+
# List models for a specific provider
|
|
94
|
+
codework models --provider openai
|
|
95
|
+
|
|
96
|
+
# List all supported provider IDs
|
|
97
|
+
codework models providers
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
---
|
|
101
|
+
|
|
102
|
+
### `codework models generate`
|
|
103
|
+
|
|
104
|
+
Generate or update the `models.gen.json` catalog from model registries.
|
|
105
|
+
|
|
106
|
+
```bash
|
|
107
|
+
# Generate to CODEWORK_MODELS_FILE or ./models.gen.json
|
|
108
|
+
codework models generate
|
|
109
|
+
|
|
110
|
+
# Generate into a specific directory (resolves to ./models.gen.json)
|
|
111
|
+
codework models generate .
|
|
112
|
+
|
|
113
|
+
# Generate to an explicit file path
|
|
114
|
+
codework models generate ./path/to/custom-models.json
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
---
|
|
118
|
+
|
|
119
|
+
## Environment Variables
|
|
120
|
+
|
|
121
|
+
| Variable | Description |
|
|
122
|
+
| :----------------------------- | :--------------------------------------------------- |
|
|
123
|
+
| `CODEWORK_MODELS_FILE` | Path to the generated `models.gen.json` catalog file |
|
|
124
|
+
| `OPENAI_API_KEY` | API key for OpenAI models |
|
|
125
|
+
| `ANTHROPIC_API_KEY` | API key for Anthropic models |
|
|
126
|
+
| `OPENROUTER_API_KEY` | API key for OpenRouter models |
|
|
127
|
+
| `GOOGLE_GENERATIVE_AI_API_KEY` | API key for Google models |
|
|
128
|
+
| `XAI_API_KEY` | API key for xAI models |
|
|
129
|
+
|
|
130
|
+
---
|
|
131
|
+
|
|
132
|
+
## License
|
|
133
|
+
|
|
134
|
+
MIT
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { M as ModelCatalogError } from "./error-Cr8LvfEq.mjs";
|
|
2
|
+
import { Effect } from "effect";
|
|
3
|
+
import { Model } from "@codeworksh/aikit";
|
|
4
|
+
//#region src/cli/cmd/handlers/models/catalog.ts
|
|
5
|
+
const catalogError = (cause) => {
|
|
6
|
+
if (typeof cause === "object" && cause !== null && "name" in cause && cause.name === "ModelCatalogLoadError" && "data" in cause && typeof cause.data === "object" && cause.data !== null) {
|
|
7
|
+
const data = cause.data;
|
|
8
|
+
if ("path" in data && typeof data.path === "string" && "message" in data && typeof data.message === "string" && "reason" in data && (data.reason === "missing" || data.reason === "unreadable" || data.reason === "empty" || data.reason === "invalid")) return new ModelCatalogError({
|
|
9
|
+
path: data.path,
|
|
10
|
+
reason: data.reason,
|
|
11
|
+
detail: data.message
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
return new ModelCatalogError({
|
|
15
|
+
path: "",
|
|
16
|
+
reason: "unreadable",
|
|
17
|
+
detail: cause instanceof Error ? cause.message : "failed to load the model catalog"
|
|
18
|
+
});
|
|
19
|
+
};
|
|
20
|
+
const loadCatalog = Effect.tryPromise({
|
|
21
|
+
try: () => Model.getBuiltInModels(),
|
|
22
|
+
catch: catalogError
|
|
23
|
+
});
|
|
24
|
+
const loadProviders = Effect.tryPromise({
|
|
25
|
+
try: () => Model.getProviders(),
|
|
26
|
+
catch: catalogError
|
|
27
|
+
});
|
|
28
|
+
//#endregion
|
|
29
|
+
export { loadProviders as n, loadCatalog as t };
|
|
30
|
+
|
|
31
|
+
//# sourceMappingURL=catalog-DobwC9tt.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"catalog-DobwC9tt.mjs","names":["Runner.ModelCatalogError"],"sources":["../../src/cli/cmd/handlers/models/catalog.ts"],"sourcesContent":["import { Model } from \"@codeworksh/aikit\";\nimport { Runner } from \"@codeworksh/harness/effect\";\nimport { Effect } from \"effect\";\n\nconst catalogError = (cause: unknown): Runner.ModelCatalogError => {\n\tif (\n\t\ttypeof cause === \"object\" &&\n\t\tcause !== null &&\n\t\t\"name\" in cause &&\n\t\tcause.name === \"ModelCatalogLoadError\" &&\n\t\t\"data\" in cause &&\n\t\ttypeof cause.data === \"object\" &&\n\t\tcause.data !== null\n\t) {\n\t\tconst data = cause.data;\n\t\tif (\n\t\t\t\"path\" in data &&\n\t\t\ttypeof data.path === \"string\" &&\n\t\t\t\"message\" in data &&\n\t\t\ttypeof data.message === \"string\" &&\n\t\t\t\"reason\" in data &&\n\t\t\t(data.reason === \"missing\" ||\n\t\t\t\tdata.reason === \"unreadable\" ||\n\t\t\t\tdata.reason === \"empty\" ||\n\t\t\t\tdata.reason === \"invalid\")\n\t\t) {\n\t\t\treturn new Runner.ModelCatalogError({\n\t\t\t\tpath: data.path,\n\t\t\t\treason: data.reason,\n\t\t\t\tdetail: data.message,\n\t\t\t});\n\t\t}\n\t}\n\treturn new Runner.ModelCatalogError({\n\t\tpath: \"\",\n\t\treason: \"unreadable\",\n\t\tdetail: cause instanceof Error ? cause.message : \"failed to load the model catalog\",\n\t});\n};\n\nexport const loadCatalog = Effect.tryPromise({\n\ttry: () => Model.getBuiltInModels(),\n\tcatch: catalogError,\n});\n\nexport const loadProviders = Effect.tryPromise({\n\ttry: () => Model.getProviders(),\n\tcatch: catalogError,\n});\n"],"mappings":";;;;AAIA,MAAM,gBAAgB,UAA6C;CAClE,IACC,OAAO,UAAU,YACjB,UAAU,QACV,UAAU,SACV,MAAM,SAAS,2BACf,UAAU,SACV,OAAO,MAAM,SAAS,YACtB,MAAM,SAAS,MACd;EACD,MAAM,OAAO,MAAM;EACnB,IACC,UAAU,QACV,OAAO,KAAK,SAAS,YACrB,aAAa,QACb,OAAO,KAAK,YAAY,YACxB,YAAY,SACX,KAAK,WAAW,aAChB,KAAK,WAAW,gBAChB,KAAK,WAAW,WAChB,KAAK,WAAW,YAEjB,OAAO,IAAIA,kBAAyB;GACnC,MAAM,KAAK;GACX,QAAQ,KAAK;GACb,QAAQ,KAAK;EACd,CAAC;CAEH;CACA,OAAO,IAAIA,kBAAyB;EACnC,MAAM;EACN,QAAQ;EACR,QAAQ,iBAAiB,QAAQ,MAAM,UAAU;CAClD,CAAC;AACF;AAEA,MAAa,cAAc,OAAO,WAAW;CAC5C,WAAW,MAAM,iBAAiB;CAClC,OAAO;AACR,CAAC;AAED,MAAa,gBAAgB,OAAO,WAAW;CAC9C,WAAW,MAAM,aAAa;CAC9B,OAAO;AACR,CAAC"}
|