# Harness Compute — first test

Start a free workspace, save small JavaScript tools, and run them again from any agent session. **No account, email, payment card, cloud credentials or transferred file is needed.** Everything in this preview is free within the limits below.

## Set yourself up

You need HTTPS access. Use the HTTP API directly, or Python 3 for the optional client. Do not ask the user to create an account or obtain a key: create your own isolated workspace.

API origin: `https://harnesscomputepreview-api-first-test-4wbyu4kws3ekyzc2.manoscasey.workers.dev`

1. Download the readable, standard-library client from `https://harnesscompute.com/client.py` into a new working folder. Inspect it before running. No package installation is needed.
2. Run `python3 client.py init`. This creates a free workspace and writes its credential to `harness.json` with restrictive permissions. It will not overwrite an existing file. Add `harness.json` to your `.gitignore`; never print or publish the token.
3. Run `python3 client.py doctor`, then `python3 client.py smoke`. Expect `passed: true`: this saves a record, publishes a tool, and executes it on the hosted runtime. Repeating smoke updates only the two `welcome-*` fixtures.
4. Start a fresh agent session in the same folder and run `python3 client.py run welcome-summary` without republishing. The cloud-saved tool and record should still exist.

To set up without Python, POST `{}` as JSON to `/workspaces` at the API origin. No authentication is required for that single setup endpoint. A 201 response contains `{workspace, token, url, free, limits, guide}`. Save the returned token privately and send it as `Authorization: Bearer <token>` on subsequent API requests. It only grants access to your new workspace; there is no shared demo key. Never put the token in a URL. Do not follow credential-bearing redirects.

The browser setup at `https://harnesscompute.com/start` offers the same flow. A workspace key is its only credential: there is no account recovery. Keep it to resume later. Use fictional test data during this preview.

## Build something of your own

Create `my-tool.js`:

```javascript
export default {
  async fetch(request, env) {
    const { records, input } = JSON.parse(env.INPUT);
    const query = String(input.query ?? '').toLowerCase();
    return Response.json({ matches: records.filter(r => r.title.toLowerCase().includes(query)) });
  }
};
```

Then run:

```sh
python3 client.py record my-note "Remember to test persistence"
python3 client.py publish my-search my-tool.js
python3 client.py run my-search --input '{"query":"persistence"}'
python3 client.py tools
python3 client.py records
```

To update code, edit the file and publish with `--version 1` (or the current stored version). Data remains separate from code. On 409, inspect current state before retrying. To stop future runs: `python3 client.py revoke my-search`. Running a revoked tool returns 403. Publishing a new version explicitly re-enables that tool. An already-started run can finish.

## HTTP API

All workspace endpoints require `Authorization: Bearer <token>`. Send JSON bodies with Content-Type application/json. `GET /health`, this guide and the client are public. No cookies or browser sign-in are required. POST /workspaces is public and creates a new isolated workspace.

| Method | Path | Body/result |
|---|---|---|
| GET | /workspace | Workspace identity and preview limits |
| GET | /records | `{tenant, records: [{id,title,version}]}` |
| POST | /records | `{id,title,expectedVersion}`; 0 creates, current version updates |
| GET | /tools | `{tenant, tools: [{id,code,version,enabled}]}` |
| POST | /tools | `{id,code,expectedVersion}`; saves an ES module |
| POST | /run/:id | Optional JSON input; returns `{version,result}` |
| DELETE | /tools/:id | Disables future runs; preserves source and data |

IDs: 1–64 lowercase letters, digits or hyphens. Titles: at most 500 characters. Code: at most 16,000 characters. At most 100 records and 100 tools per workspace. Requests: 32 KiB; tool output: 64 KiB. Each tool gets a read-only snapshot of its workspace records and the caller's JSON input. Tools return JSON. No npm imports, network access, filesystem, cloud credentials or direct database handles. Use the records endpoint for persistent writes. Runs have a 50 ms CPU limit and a 10-second response deadline.

## What this preview proves

An agent can save data and executable code, invoke it remotely, change the code without replacing the data, and recover both from a fresh client. This is a free accountless preview, not a general-purpose production cloud, MCP server, background-job runner or arbitrary infrastructure provisioning API. No charges or payment setup for users. Each workspace gets 100 execution attempts and 200 write attempts per UTC day, plus 100 records and 100 tools. Creation is limited to 10 workspaces per network per UTC day and shared preview capacity. There is no production SLA. The operator pays the underlying provider costs. Keep the connection file private and use small synthetic workloads.

## Troubleshooting

- 401: wrong/missing connection key. Reuse the connection file created by init. If lost, create a new workspace; the old workspace cannot be recovered without its key.
- 403: tool revoked. Publish a new version only if you intend to re-enable it.
- 404: wrong tool ID or a different workspace; list tools first.
- 409: version changed, ID already exists, or workspace reached its 100-item limit.
- 413: request too large.
- 422: tool compilation/execution failed or returned invalid JSON. Check the module and limits; correct and republish it.
- 429: daily limit or shared free preview capacity reached; wait for the UTC reset or try later.
- Connection failure: run doctor again; include the public health response and error status when reporting, never the access key.
- Missing Python: install Python 3 or use the documented HTTP API with the agent's existing HTTP client.
