{"_id":"@agent-harbor/rest-client","name":"@agent-harbor/rest-client","dist-tags":{"bootstrap":"0.0.0","latest":"0.0.0"},"versions":{"0.0.0":{"name":"@agent-harbor/rest-client","version":"0.0.0","description":"Shared REST API client for Agent Harbor","type":"module","main":"dist/index.js","types":"dist/index.d.ts","exports":{".":{"types":"./dist/index.d.ts","default":"./dist/index.js"}},"scripts":{"build":"tsc","watch":"tsc --watch","test":"vitest","test:run":"vitest run","typecheck":"tsc --noEmit","clean":"rm -rf dist"},"keywords":["agent-harbor","rest-client","api-client"],"author":{"name":"Schelling Point Labs Inc"},"license":"Apache-2.0","publishConfig":{"access":"public","registry":"https://registry.npmjs.org/"},"repository":{"type":"git","url":"git+https://github.com/agent-harbor/agent-harbor.git","directory":"packages/rest-client"},"homepage":"https://docs.agent-harbor.com","bugs":{"url":"https://github.com/agent-harbor/agent-harbor/issues"},"devDependencies":{"@types/node":"^24.10.1","typescript":"5.9.3","vitest":"^3.1.4"},"engines":{"node":">=20.0.0"},"_id":"@agent-harbor/rest-client@0.0.0","_nodeVersion":"24.14.1","_npmVersion":"11.11.0","dist":{"integrity":"sha512-bEC5RoZ+1b6eNnVXNi+JbOcfD5mRyVfxtCtxWdelvw31FphIULJKqRQFz8l5aW7tXa4F8Yfcg25r8wr5n4SfkQ==","shasum":"45d68a5076047cf7961fb6f98e0d1d28649d10cf","tarball":"https://registry.npmjs.org/@agent-harbor/rest-client/-/rest-client-0.0.0.tgz","fileCount":23,"unpackedSize":712996,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQDKjQ5EKm8+3243CjZobplpufUYJLB9bEKLQ4ia4uwTJwIhAKWER6RDb8onWsJLW3meZ1FnJ8giI1FC7XyXLMHHvGh5"}]},"_npmUser":{"name":"zahary-agent-harbor","email":"zahary@agent-harbor.com"},"directories":{},"maintainers":[{"name":"zahary-agent-harbor","email":"zahary@agent-harbor.com"},{"name":"zombinedev","email":"zombinedev.no.reply@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/rest-client_0.0.0_1781677820577_0.4654491325388501"},"_hasShrinkwrap":false}},"time":{"created":"2026-06-17T06:30:20.310Z","0.0.0":"2026-06-17T06:30:20.744Z","modified":"2026-06-17T06:30:21.059Z"},"maintainers":[{"name":"zahary-agent-harbor","email":"zahary@agent-harbor.com"},{"name":"zombinedev","email":"zombinedev.no.reply@gmail.com"}],"description":"Shared REST API client for Agent Harbor","homepage":"https://docs.agent-harbor.com","keywords":["agent-harbor","rest-client","api-client"],"repository":{"type":"git","url":"git+https://github.com/agent-harbor/agent-harbor.git","directory":"packages/rest-client"},"author":{"name":"Schelling Point Labs Inc"},"bugs":{"url":"https://github.com/agent-harbor/agent-harbor/issues"},"license":"Apache-2.0","readme":"# @agent-harbor/rest-client\n\nShared REST API client for Agent Harbor.\n\n## Installation\n\n```bash\nyarn add @agent-harbor/rest-client\n```\n\n## Usage\n\n### Creating a Client\n\n```typescript\nimport { createApiClient } from '@agent-harbor/rest-client';\n\n// Simple usage with just a base URL\nconst client = createApiClient('http://localhost:8080/api/v1');\n\n// With custom options\nconst client = createApiClient({\n  baseUrl: 'http://localhost:8080/api/v1',\n  headers: {\n    Authorization: 'Bearer your-token',\n  },\n});\n```\n\n### Creating a Task\n\n```typescript\nimport { createApiClient, CreateTaskRequest } from '@agent-harbor/rest-client';\n\nconst client = createApiClient('http://localhost:8080/api/v1');\n\nconst taskRequest: CreateTaskRequest = {\n  prompt: 'Fix the bug in main.ts',\n  repo: {\n    mode: 'git',\n    url: 'https://github.com/example/repo',\n    branch: 'main',\n  },\n  runtime: {\n    type: 'devcontainer',\n  },\n  agent: {\n    type: 'claude-code',\n    version: 'latest',\n  },\n  output: {\n    format: 'stream-json',\n    flavor: 'ah',\n  },\n};\n\nconst response = await client.createTask(taskRequest);\nconsole.log('Created sessions:', response.session_ids);\n```\n\n### Managing Sessions\n\n```typescript\n// List sessions\nconst sessions = await client.listSessions({ status: 'running' });\n\n// Get a specific session\nconst session = await client.getSession(sessionId);\n\n// Stop a session gracefully\nawait client.stopSession(sessionId);\n\n// Cancel a session immediately\nawait client.cancelSession(sessionId);\n\n// Pause and resume\nawait client.pauseSession(sessionId);\nawait client.resumeSession(sessionId);\n\n// Get session logs\nconst logs = await client.getSessionLogs(sessionId, 100); // Last 100 lines\n```\n\n### Error Handling\n\n```typescript\nimport { createApiClient, ApiClientError } from '@agent-harbor/rest-client';\n\nconst client = createApiClient('http://localhost:8080/api/v1');\n\ntry {\n  await client.getSession('non-existent-id');\n} catch (error) {\n  if (error instanceof ApiClientError) {\n    console.error(`API Error: ${error.message}`);\n    console.error(`Status: ${error.status}`);\n\n    if (error.isNotFound()) {\n      console.error('Session not found');\n    }\n\n    if (error.hasValidationErrors()) {\n      console.error('Validation errors:', error.apiError?.errors);\n    }\n  }\n}\n```\n\n### SSE Events (Browser)\n\nFor browser environments, you can use the built-in EventSource support:\n\n```typescript\nconst eventSource = client.subscribeToSessionEvents(sessionId, event => {\n  switch (event.type) {\n    case 'status':\n      console.log('Status changed:', event.status);\n      break;\n    case 'tool_execution':\n      console.log('Tool executed:', event.tool_name);\n      break;\n    case 'thinking':\n      console.log('Agent thinking:', event.thought);\n      break;\n  }\n});\n\n// Later: close the connection\neventSource.close();\n```\n\nFor Node.js environments, use the `@agent-harbor/sse-client` package for more robust SSE handling.\n\n## API Reference\n\n### Client Methods\n\n| Method                                  | Description                            |\n| --------------------------------------- | -------------------------------------- |\n| `createTask(data)`                      | Create a new task                      |\n| `listSessions(params?)`                 | List sessions with optional filtering  |\n| `getSession(id)`                        | Get a specific session                 |\n| `stopSession(id)`                       | Stop a session gracefully              |\n| `cancelSession(id)`                     | Cancel a session immediately           |\n| `pauseSession(id)`                      | Pause a running session                |\n| `resumeSession(id)`                     | Resume a paused session                |\n| `getSessionLogs(id, tail?)`             | Get session logs                       |\n| `sendMessage(id, message)`              | Send a message to a session            |\n| `getSessionEventsUrl(id)`               | Get SSE events URL                     |\n| `subscribeToSessionEvents(id, onEvent)` | Subscribe to SSE events (browser only) |\n| `listAgents()`                          | List available agent types             |\n| `listRuntimes()`                        | List available runtime types           |\n| `listRepositories(params?)`             | List repositories                      |\n| `getRepository(id)`                     | Get a specific repository              |\n| `listDrafts()`                          | List draft tasks                       |\n| `createDraft(draft)`                    | Create a draft task                    |\n| `updateDraft(id, updates)`              | Update a draft task                    |\n| `deleteDraft(id)`                       | Delete a draft task                    |\n\n### Types\n\nThe package exports all types needed for working with the API:\n\n- Configuration: `Repository`, `Runtime`, `Agent`, `Delivery`, `OutputConfig`\n- Tasks: `CreateTaskRequest`, `CreateTaskResponse`\n- Sessions: `Session`, `SessionStatus`, `SessionsListResponse`\n- Events: `SessionEvent`, `StatusEvent`, `LogEvent`, `ThinkingEvent`, `ToolExecutionEvent`, `FileEditEvent`\n- Metadata: `AgentType`, `RuntimeType`, `RepositoryItem`\n- Drafts: `DraftCreate`, `DraftTask`, `DraftUpdate`\n- Feedback: `FeedbackRequest`, `FeedbackResponse`, `FeedbackOption`\n- Errors: `ApiError`, `ApiClientError`\n\n## License\n\nApache-2.0\n","readmeFilename":"README.md","_rev":"1-f0b528e7d8298e3c0fac323912d1676b"}