@bazaar.ai/mcp-human-agents 0.1.0 → 0.1.1
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/.env.example +1 -0
- package/README.md +35 -28
- package/dist/mcp-server/src/cli/setup.d.ts.map +1 -1
- package/dist/mcp-server/src/cli/setup.js +14 -6
- package/dist/mcp-server/src/cli/setup.js.map +1 -1
- package/dist/mcp-server/src/config/env.d.ts +8 -0
- package/dist/mcp-server/src/config/env.d.ts.map +1 -1
- package/dist/mcp-server/src/config/env.js +7 -4
- package/dist/mcp-server/src/config/env.js.map +1 -1
- package/dist/mcp-server/src/platform-client/client.d.ts.map +1 -1
- package/dist/mcp-server/src/platform-client/client.js +5 -4
- package/dist/mcp-server/src/platform-client/client.js.map +1 -1
- package/dist/mcp-server/src/tools/summon-human.d.ts.map +1 -1
- package/dist/mcp-server/src/tools/summon-human.js +1 -1
- package/dist/mcp-server/src/tools/summon-human.js.map +1 -1
- package/package.json +1 -1
- package/src/cli/setup.ts +72 -61
- package/src/config/env.ts +15 -12
- package/src/platform-client/client.ts +42 -40
- package/src/tools/summon-human.ts +6 -5
package/.env.example
CHANGED
package/README.md
CHANGED
|
@@ -18,14 +18,18 @@ the web terminal — no ngrok or public IP needed.
|
|
|
18
18
|
|
|
19
19
|
### 2. Run the setup script
|
|
20
20
|
|
|
21
|
-
```bash
|
|
22
|
-
npx @bazaar.ai/mcp-human-agents --setup --api-key=bzr_live_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
|
23
|
-
```
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
21
|
+
```bash
|
|
22
|
+
npx @bazaar.ai/mcp-human-agents --setup --api-key=bzr_live_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
On the hosted Bazaar dashboard, use the copy-paste command from the
|
|
26
|
+
**Setup** page. It includes the correct public HTTP and WebSocket
|
|
27
|
+
endpoints for that deployment.
|
|
28
|
+
|
|
29
|
+
The setup script will:
|
|
30
|
+
- Check for prerequisites (sshd, tmux, git) and offer to install them
|
|
31
|
+
- Validate your API key against the platform
|
|
32
|
+
- Configure sudo permissions for contractor provisioning
|
|
29
33
|
- Register the MCP server with Claude Code
|
|
30
34
|
|
|
31
35
|
### 3. Restart Claude Code
|
|
@@ -80,12 +84,13 @@ Contractor (anywhere) ├── gig notifications
|
|
|
80
84
|
The setup script handles configuration automatically. For reference,
|
|
81
85
|
these are the environment variables used:
|
|
82
86
|
|
|
83
|
-
| Variable | Default | Description |
|
|
84
|
-
|----------|---------|-------------|
|
|
85
|
-
| `PLATFORM_API_URL` | `http://localhost:3000` | Bazaar platform API endpoint |
|
|
86
|
-
| `
|
|
87
|
-
| `
|
|
88
|
-
| `
|
|
87
|
+
| Variable | Default | Description |
|
|
88
|
+
|----------|---------|-------------|
|
|
89
|
+
| `PLATFORM_API_URL` | `http://localhost:3000` | Bazaar platform API endpoint |
|
|
90
|
+
| `PLATFORM_WS_URL` | derived from `PLATFORM_API_URL` | Optional explicit WebSocket endpoint for reverse tunnels |
|
|
91
|
+
| `PLATFORM_API_KEY` | _(required)_ | Your Bazaar API key |
|
|
92
|
+
| `USE_MOCK_PLATFORM` | `false` | Set `true` for offline testing with mock data |
|
|
93
|
+
| `TUNNEL_ENABLED` | `true` | Reverse tunnel mode (no ngrok needed) |
|
|
89
94
|
| `PROVISIONING_USE_SUDO` | `false` | Use sudo for privileged commands |
|
|
90
95
|
| `VM_EXTERNAL_IP` | `auto` | Only needed when `TUNNEL_ENABLED=false` |
|
|
91
96
|
| `VM_EXTERNAL_SSH_PORT` | `22` | Only needed when `TUNNEL_ENABLED=false` |
|
|
@@ -125,13 +130,14 @@ sudo visudo -c # Must print "parsed OK"
|
|
|
125
130
|
|
|
126
131
|
### 3. Register with Claude Code
|
|
127
132
|
|
|
128
|
-
```bash
|
|
129
|
-
claude mcp add bazaar \
|
|
130
|
-
-e PLATFORM_API_URL=http://localhost:3000 \
|
|
131
|
-
-e
|
|
132
|
-
-e
|
|
133
|
-
-e
|
|
134
|
-
-e
|
|
133
|
+
```bash
|
|
134
|
+
claude mcp add bazaar \
|
|
135
|
+
-e PLATFORM_API_URL=http://localhost:3000 \
|
|
136
|
+
-e PLATFORM_WS_URL=ws://localhost:3000 \
|
|
137
|
+
-e PLATFORM_API_KEY=bzr_live_xxxx \
|
|
138
|
+
-e USE_MOCK_PLATFORM=false \
|
|
139
|
+
-e TUNNEL_ENABLED=true \
|
|
140
|
+
-e PROVISIONING_USE_SUDO=true \
|
|
135
141
|
-- npx @bazaar.ai/mcp-human-agents
|
|
136
142
|
```
|
|
137
143
|
|
|
@@ -140,13 +146,14 @@ claude mcp add bazaar \
|
|
|
140
146
|
If you need contractors to SSH directly (e.g., for debugging), disable
|
|
141
147
|
the tunnel and provide a public endpoint:
|
|
142
148
|
|
|
143
|
-
```bash
|
|
144
|
-
claude mcp add bazaar \
|
|
145
|
-
-e PLATFORM_API_URL=http://localhost:3000 \
|
|
146
|
-
-e
|
|
147
|
-
-e
|
|
148
|
-
-e
|
|
149
|
-
-e
|
|
149
|
+
```bash
|
|
150
|
+
claude mcp add bazaar \
|
|
151
|
+
-e PLATFORM_API_URL=http://localhost:3000 \
|
|
152
|
+
-e PLATFORM_WS_URL=ws://localhost:3000 \
|
|
153
|
+
-e PLATFORM_API_KEY=bzr_live_xxxx \
|
|
154
|
+
-e USE_MOCK_PLATFORM=false \
|
|
155
|
+
-e TUNNEL_ENABLED=false \
|
|
156
|
+
-e VM_EXTERNAL_IP=0.tcp.ngrok.io \
|
|
150
157
|
-e VM_EXTERNAL_SSH_PORT=17832 \
|
|
151
158
|
-e PROVISIONING_USE_SUDO=true \
|
|
152
159
|
-- npx @bazaar.ai/mcp-human-agents
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"setup.d.ts","sourceRoot":"","sources":["../../../../src/cli/setup.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"setup.d.ts","sourceRoot":"","sources":["../../../../src/cli/setup.ts"],"names":[],"mappings":"AAkOA,wBAAsB,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC,CAqG9C"}
|
|
@@ -4,9 +4,7 @@ exports.runSetup = runSetup;
|
|
|
4
4
|
const promises_1 = require("node:readline/promises");
|
|
5
5
|
const node_child_process_1 = require("node:child_process");
|
|
6
6
|
const node_process_1 = require("node:process");
|
|
7
|
-
|
|
8
|
-
// (e.g. https://api.bazaar.ai) before public launch.
|
|
9
|
-
const PLATFORM_API_URL_DEFAULT = "https://ingrid-hypocycloidal-kaliyah.ngrok-free.dev";
|
|
7
|
+
const PLATFORM_API_URL_DEFAULT = "http://localhost:3000";
|
|
10
8
|
// ── Helpers ──────────────────────────────────────────────────────────
|
|
11
9
|
function log(msg) {
|
|
12
10
|
node_process_1.stderr.write(`${msg}\n`);
|
|
@@ -92,9 +90,16 @@ async function promptPlatformUrl(rl) {
|
|
|
92
90
|
const url = await rl.question(`Platform API URL [${PLATFORM_API_URL_DEFAULT}]: `);
|
|
93
91
|
return url.trim() || PLATFORM_API_URL_DEFAULT;
|
|
94
92
|
}
|
|
93
|
+
function getPlatformWsUrl(platformUrl) {
|
|
94
|
+
const urlArg = process.argv.find((a) => a.startsWith("--platform-ws-url="));
|
|
95
|
+
if (urlArg) {
|
|
96
|
+
return urlArg.split("=").slice(1).join("=");
|
|
97
|
+
}
|
|
98
|
+
return platformUrl.replace(/^http/, "ws");
|
|
99
|
+
}
|
|
95
100
|
async function validateApiKey(apiKey, platformUrl) {
|
|
96
101
|
try {
|
|
97
|
-
const res = await fetch(`${platformUrl}/api/
|
|
102
|
+
const res = await fetch(`${platformUrl}/api/auth/me`, {
|
|
98
103
|
headers: { Authorization: `Bearer ${apiKey}` },
|
|
99
104
|
});
|
|
100
105
|
if (res.ok) {
|
|
@@ -152,11 +157,12 @@ function createStateDir() {
|
|
|
152
157
|
warn("Could not create /var/lib/human-agents — state will use fallback");
|
|
153
158
|
}
|
|
154
159
|
}
|
|
155
|
-
function registerMcpServer(apiKey, platformUrl) {
|
|
160
|
+
function registerMcpServer(apiKey, platformUrl, platformWsUrl) {
|
|
156
161
|
const isRoot = run("whoami") === "root";
|
|
157
162
|
// Build the env vars for claude mcp add
|
|
158
163
|
const envFlags = [
|
|
159
164
|
`-e PLATFORM_API_URL=${platformUrl}`,
|
|
165
|
+
`-e PLATFORM_WS_URL=${platformWsUrl}`,
|
|
160
166
|
`-e PLATFORM_API_KEY=${apiKey}`,
|
|
161
167
|
`-e USE_MOCK_PLATFORM=false`,
|
|
162
168
|
`-e TUNNEL_ENABLED=true`,
|
|
@@ -214,6 +220,7 @@ async function runSetup() {
|
|
|
214
220
|
const apiKey = await promptApiKey(rl);
|
|
215
221
|
// 4. Get platform URL
|
|
216
222
|
const platformUrl = await promptPlatformUrl(rl);
|
|
223
|
+
const platformWsUrl = getPlatformWsUrl(platformUrl);
|
|
217
224
|
// 5. Validate API key
|
|
218
225
|
log("");
|
|
219
226
|
log("Validating API key...");
|
|
@@ -237,7 +244,7 @@ async function runSetup() {
|
|
|
237
244
|
log("");
|
|
238
245
|
log("Registering MCP server with Claude Code...");
|
|
239
246
|
if (hasClaude) {
|
|
240
|
-
registerMcpServer(apiKey, platformUrl);
|
|
247
|
+
registerMcpServer(apiKey, platformUrl, platformWsUrl);
|
|
241
248
|
}
|
|
242
249
|
else {
|
|
243
250
|
warn("Claude CLI not found — showing manual command:");
|
|
@@ -245,6 +252,7 @@ async function runSetup() {
|
|
|
245
252
|
const isRoot = run("whoami") === "root";
|
|
246
253
|
const envFlags = [
|
|
247
254
|
`-e PLATFORM_API_URL=${platformUrl}`,
|
|
255
|
+
`-e PLATFORM_WS_URL=${platformWsUrl}`,
|
|
248
256
|
`-e PLATFORM_API_KEY=${apiKey}`,
|
|
249
257
|
`-e USE_MOCK_PLATFORM=false`,
|
|
250
258
|
`-e TUNNEL_ENABLED=true`,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"setup.js","sourceRoot":"","sources":["../../../../src/cli/setup.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"setup.js","sourceRoot":"","sources":["../../../../src/cli/setup.ts"],"names":[],"mappings":";;AAkOA,4BAqGC;AAvUD,qDAAyD;AACzD,2DAAoE;AACpE,+CAAqD;AAErD,MAAM,wBAAwB,GAAG,uBAAuB,CAAC;AAEzD,wEAAwE;AAExE,SAAS,GAAG,CAAC,GAAW;IACtB,qBAAM,CAAC,KAAK,CAAC,GAAG,GAAG,IAAI,CAAC,CAAC;AAC3B,CAAC;AAED,SAAS,OAAO,CAAC,GAAW;IAC1B,qBAAM,CAAC,KAAK,CAAC,oBAAoB,GAAG,IAAI,CAAC,CAAC;AAC5C,CAAC;AAED,SAAS,IAAI,CAAC,GAAW;IACvB,qBAAM,CAAC,KAAK,CAAC,oBAAoB,GAAG,IAAI,CAAC,CAAC;AAC5C,CAAC;AAED,SAAS,IAAI,CAAC,GAAW;IACvB,qBAAM,CAAC,KAAK,CAAC,oBAAoB,GAAG,IAAI,CAAC,CAAC;AAC5C,CAAC;AAED,SAAS,GAAG,CAAC,GAAW,EAAE,IAAsB;IAC9C,MAAM,MAAM,GAAG,IAAA,6BAAQ,EAAC,GAAG,EAAE,EAAE,QAAQ,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,GAAG,IAAI,EAAE,CAAC,CAAC;IAC9F,OAAO,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,CAAC;AAC/B,CAAC;AAED,SAAS,MAAM,CAAC,GAAW;IACzB,IAAI,CAAC;QACH,GAAG,CAAC,GAAG,CAAC,CAAC;QACT,OAAO,IAAI,CAAC;IACd,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC;AAED,wEAAwE;AAExE,KAAK,UAAU,W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,EAAE,CAAC;IACb,CAAC;AACH,CAAC"}
|
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
declare const EnvSchema: z.ZodObject<{
|
|
3
3
|
PLATFORM_API_URL: z.ZodDefault<z.ZodString>;
|
|
4
|
+
/**
|
|
5
|
+
* Optional explicit WebSocket endpoint. Use this when HTTP requests go
|
|
6
|
+
* through a proxy path but the reverse tunnel must connect directly to the
|
|
7
|
+
* human-layer WebSocket server.
|
|
8
|
+
*/
|
|
9
|
+
PLATFORM_WS_URL: z.ZodOptional<z.ZodString>;
|
|
4
10
|
PLATFORM_API_KEY: z.ZodDefault<z.ZodString>;
|
|
5
11
|
/**
|
|
6
12
|
* Hostname or IP the contractor will SSH into. Only needed when
|
|
@@ -50,9 +56,11 @@ declare const EnvSchema: z.ZodObject<{
|
|
|
50
56
|
STATE_FILE_PATH: string;
|
|
51
57
|
PROVISIONING_USE_SUDO: boolean;
|
|
52
58
|
TUNNEL_ENABLED: boolean;
|
|
59
|
+
PLATFORM_WS_URL?: string | undefined;
|
|
53
60
|
PLATFORM_PROJECT_ID?: string | undefined;
|
|
54
61
|
}, {
|
|
55
62
|
PLATFORM_API_URL?: string | undefined;
|
|
63
|
+
PLATFORM_WS_URL?: string | undefined;
|
|
56
64
|
PLATFORM_API_KEY?: string | undefined;
|
|
57
65
|
VM_EXTERNAL_IP?: string | undefined;
|
|
58
66
|
VM_EXTERNAL_SSH_PORT?: number | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"env.d.ts","sourceRoot":"","sources":["../../../../src/config/env.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"env.d.ts","sourceRoot":"","sources":["../../../../src/config/env.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,QAAA,MAAM,SAAS;;IAEb;;;;OAIG;;;IAGH;;;;;;OAMG;;IAEH;;OAEG;;IAEH;;;OAGG;;;;;;;IAYH;;;;;OAKG;;IAKH;;;;;OAKG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAKH,CAAC;AAEH,MAAM,MAAM,GAAG,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,SAAS,CAAC,CAAC;AAI5C,wBAAgB,MAAM,IAAI,GAAG,CAK5B;AAED,4CAA4C;AAC5C,wBAAgB,MAAM,CAAC,GAAG,EAAE,GAAG,GAAG,IAAI,CAErC"}
|
|
@@ -3,12 +3,15 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.getEnv = getEnv;
|
|
4
4
|
exports.setEnv = setEnv;
|
|
5
5
|
const zod_1 = require("zod");
|
|
6
|
-
|
|
7
|
-
// founder's account. This is fine for early testing but must be replaced with
|
|
8
|
-
// a proper cloud deployment (e.g. https://api.bazaar.ai) before public launch.
|
|
9
|
-
const DEFAULT_PLATFORM_URL = "https://ingrid-hypocycloidal-kaliyah.ngrok-free.dev";
|
|
6
|
+
const DEFAULT_PLATFORM_URL = "http://localhost:3000";
|
|
10
7
|
const EnvSchema = zod_1.z.object({
|
|
11
8
|
PLATFORM_API_URL: zod_1.z.string().url().default(DEFAULT_PLATFORM_URL),
|
|
9
|
+
/**
|
|
10
|
+
* Optional explicit WebSocket endpoint. Use this when HTTP requests go
|
|
11
|
+
* through a proxy path but the reverse tunnel must connect directly to the
|
|
12
|
+
* human-layer WebSocket server.
|
|
13
|
+
*/
|
|
14
|
+
PLATFORM_WS_URL: zod_1.z.string().url().optional(),
|
|
12
15
|
PLATFORM_API_KEY: zod_1.z.string().default(""),
|
|
13
16
|
/**
|
|
14
17
|
* Hostname or IP the contractor will SSH into. Only needed when
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"env.js","sourceRoot":"","sources":["../../../../src/config/env.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"env.js","sourceRoot":"","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C5D,WAAW,CAAC,OAAO,EAAE,kBAAkB,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAAC;CACxE;
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../../src/platform-client/client.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,gBAAgB,EAChB,iBAAiB,EACjB,iBAAiB,EACjB,kBAAkB,EAClB,mBAAmB,EACpB,MAAM,YAAY,CAAC;AAEpB,MAAM,WAAW,cAAc;IAC7B,SAAS,CAAC,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC;IACjE,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC;IACxD,SAAS,CAAC,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC5D,WAAW,CAAC,OAAO,EAAE,kBAAkB,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAAC;CACxE;AAID,qBAAa,kBAAmB,YAAW,cAAc;IACvD,OAAO,CAAC,IAAI,CAAgB;gBAEhB,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;IAWrC,SAAS,CAAC,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAahE,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAWvD,SAAS,CAAC,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAS3D,WAAW,CACf,OAAO,EAAE,kBAAkB,GAC1B,OAAO,CAAC,mBAAmB,CAAC;IAgB/B,OAAO,CAAC,SAAS;CASlB"}
|
|
@@ -7,6 +7,7 @@ exports.HttpPlatformClient = void 0;
|
|
|
7
7
|
const axios_1 = __importDefault(require("axios"));
|
|
8
8
|
const errors_js_1 = require("../utils/errors.js");
|
|
9
9
|
const logger_js_1 = require("../utils/logger.js");
|
|
10
|
+
const API_PREFIX = "/api";
|
|
10
11
|
class HttpPlatformClient {
|
|
11
12
|
http;
|
|
12
13
|
constructor(baseUrl, apiKey) {
|
|
@@ -21,7 +22,7 @@ class HttpPlatformClient {
|
|
|
21
22
|
}
|
|
22
23
|
async createGig(request) {
|
|
23
24
|
try {
|
|
24
|
-
const { data } = await this.http.post(
|
|
25
|
+
const { data } = await this.http.post(`${API_PREFIX}/gigs`, request);
|
|
25
26
|
logger_js_1.logger.info("Gig created on platform", { gigId: data.gigId });
|
|
26
27
|
return data;
|
|
27
28
|
}
|
|
@@ -31,7 +32,7 @@ class HttpPlatformClient {
|
|
|
31
32
|
}
|
|
32
33
|
async getGigStatus(gigId) {
|
|
33
34
|
try {
|
|
34
|
-
const { data } = await this.http.get(
|
|
35
|
+
const { data } = await this.http.get(`${API_PREFIX}/gigs/${gigId}/status`);
|
|
35
36
|
return data;
|
|
36
37
|
}
|
|
37
38
|
catch (error) {
|
|
@@ -40,7 +41,7 @@ class HttpPlatformClient {
|
|
|
40
41
|
}
|
|
41
42
|
async markReady(gigId, sshCommand) {
|
|
42
43
|
try {
|
|
43
|
-
await this.http.post(
|
|
44
|
+
await this.http.post(`${API_PREFIX}/gigs/${gigId}/ready`, { sshCommand });
|
|
44
45
|
logger_js_1.logger.info("Gig marked as ready", { gigId });
|
|
45
46
|
}
|
|
46
47
|
catch (error) {
|
|
@@ -49,7 +50,7 @@ class HttpPlatformClient {
|
|
|
49
50
|
}
|
|
50
51
|
async completeGig(request) {
|
|
51
52
|
try {
|
|
52
|
-
const { data } = await this.http.post(
|
|
53
|
+
const { data } = await this.http.post(`${API_PREFIX}/gigs/${request.gigId}/complete`, request);
|
|
53
54
|
logger_js_1.logger.info("Gig completed on platform", { gigId: request.gigId });
|
|
54
55
|
return data;
|
|
55
56
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../../../src/platform-client/client.ts"],"names":[],"mappings":";;;;;;AAAA,kDAAkD;AAClD,kDAAsD;AACtD,kDAA4C;AAgB5C,MAAa,kBAAkB;IACrB,IAAI,CAAgB;IAE5B,YAAY,OAAe,EAAE,MAAc;QACzC,IAAI,CAAC,IAAI,GAAG,eAAK,CAAC,MAAM,CAAC;YACvB,OAAO,EAAE,OAAO;YAChB,OAAO,EAAE;gBACP,aAAa,EAAE,UAAU,MAAM,EAAE;gBACjC,cAAc,EAAE,kBAAkB;aACnC;YACD,OAAO,EAAE,MAAM;SAChB,CAAC,CAAC;IACL,CAAC;IAED,KAAK,CAAC,SAAS,CAAC,OAAyB;QACvC,IAAI,CAAC;YACH,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,IAAI,CACnC,OAAO,
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../../../src/platform-client/client.ts"],"names":[],"mappings":";;;;;;AAAA,kDAAkD;AAClD,kDAAsD;AACtD,kDAA4C;AAgB5C,MAAM,UAAU,GAAG,MAAM,CAAC;AAE1B,MAAa,kBAAkB;IACrB,IAAI,CAAgB;IAE5B,YAAY,OAAe,EAAE,MAAc;QACzC,IAAI,CAAC,IAAI,GAAG,eAAK,CAAC,MAAM,CAAC;YACvB,OAAO,EAAE,OAAO;YAChB,OAAO,EAAE;gBACP,aAAa,EAAE,UAAU,MAAM,EAAE;gBACjC,cAAc,EAAE,kBAAkB;aACnC;YACD,OAAO,EAAE,MAAM;SAChB,CAAC,CAAC;IACL,CAAC;IAED,KAAK,CAAC,SAAS,CAAC,OAAyB;QACvC,IAAI,CAAC;YACH,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,IAAI,CACnC,GAAG,UAAU,OAAO,EACpB,OAAO,CACR,CAAC;YACF,kBAAM,CAAC,IAAI,CAAC,yBAAyB,EAAE,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC;YAC9D,OAAO,IAA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AAE,CAAC;YACf,MAAM,IAAI,CAAC,SAAS,CAClB,2BAA2B,OAAO,CAAC,KAAK,EAAE,EAC1C,KAAK,CACN,CAAC;QACJ,CAAC;IACH,CAAC;IAEO,SAAS,CAAC,OAAe,EAAE,KAAc;QAC/C,IAAI,eAAK,CAAC,YAAY,CAAC,KAAK,CAAC,EAAE,CAAC;YAC9B,OAAO,IAAI,4BAAgB,CACzB,GAAG,OAAO,KAAK,KAAK,CAAC,OAAO,EAAE,EAC9B,KAAK,CAAC,QAAQ,EAAE,MAAM,CACvB,CAAC;QACJ,CAAC;QACD,OAAO,IAAI,4BAAgB,CAAC,OAAO,CAAC,CAAC;IACvC,CAAC;CACF;AA1ED,gDA0EC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"summon-human.d.ts","sourceRoot":"","sources":["../../../../src/tools/summon-human.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAYnE,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAK7C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AAGzE,MAAM,WAAW,eAAe;IAC9B,cAAc,EAAE,cAAc,CAAC;IAC/B,QAAQ,EAAE,QAAQ,CAAC;CACpB;AAED,MAAM,WAAW,iBAAiB;IAChC,KAAK,EAAE,MAAM,CAAC;IACd,cAAc,EAAE,MAAM,CAAC;IACvB,UAAU,EAAE,MAAM,CAAC;IACnB,cAAc,EAAE,QAAQ,GAAG,QAAQ,CAAC;IACpC,MAAM,EAAE,wBAAwB,CAAC;CAClC;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,WAAW,CAC/B,KAAK,EAAE,gBAAgB,EACvB,IAAI,EAAE,eAAe,GACpB,OAAO,CAAC,iBAAiB,CAAC,
|
|
1
|
+
{"version":3,"file":"summon-human.d.ts","sourceRoot":"","sources":["../../../../src/tools/summon-human.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAYnE,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAK7C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AAGzE,MAAM,WAAW,eAAe;IAC9B,cAAc,EAAE,cAAc,CAAC;IAC/B,QAAQ,EAAE,QAAQ,CAAC;CACpB;AAED,MAAM,WAAW,iBAAiB;IAChC,KAAK,EAAE,MAAM,CAAC;IACd,cAAc,EAAE,MAAM,CAAC;IACvB,UAAU,EAAE,MAAM,CAAC;IACnB,cAAc,EAAE,QAAQ,GAAG,QAAQ,CAAC;IACpC,MAAM,EAAE,wBAAwB,CAAC;CAClC;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,WAAW,CAC/B,KAAK,EAAE,gBAAgB,EACvB,IAAI,EAAE,eAAe,GACpB,OAAO,CAAC,iBAAiB,CAAC,CAiI5B"}
|
|
@@ -93,7 +93,7 @@ async function summonHuman(input, deps) {
|
|
|
93
93
|
let sshCommand;
|
|
94
94
|
if (useTunnel) {
|
|
95
95
|
// Open reverse tunnel — platform routes contractor traffic through it
|
|
96
|
-
const platformWsUrl = env.PLATFORM_API_URL.replace(/^http/, "ws");
|
|
96
|
+
const platformWsUrl = env.PLATFORM_WS_URL ?? env.PLATFORM_API_URL.replace(/^http/, "ws");
|
|
97
97
|
const handle = (0, index_js_4.openTunnel)(platformWsUrl, env.PLATFORM_API_KEY, gigId);
|
|
98
98
|
(0, index_js_4.storeTunnel)(gigId, handle);
|
|
99
99
|
sshCommand = `(via tunnel to platform)`;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"summon-human.js","sourceRoot":"","sources":["../../../../src/tools/summon-human.ts"],"names":[],"mappings":";;AAgDA,
|
|
1
|
+
{"version":3,"file":"summon-human.js","sourceRoot":"","sources":["../../../../src/tools/summon-human.ts"],"names":[],"mappings":";;AAgDA,kCAoIC;A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;QAChB,YAAY,EAAE,SAAS;KACxB,CAAC,CAAC;IAEH,kBAAM,CAAC,IAAI,CAAC,wCAAwC,EAAE;QACpD,KAAK;QACL,cAAc,EAAE,UAAU,CAAC,IAAI;QAC/B,cAAc,EAAE,SAAS,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,QAAQ;KAChD,CAAC,CAAC;IAEH,OAAO;QACL,KAAK;QACL,cAAc,EAAE,UAAU,CAAC,IAAI;QAC/B,UAAU;QACV,cAAc,EAAE,SAAS,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,QAAQ;QAC/C,MAAM,EAAE,wBAAwB;KACjC,CAAC;AACJ,CAAC"}
|
package/package.json
CHANGED
package/src/cli/setup.ts
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
import { createInterface } from "node:readline/promises";
|
|
2
|
-
import { execSync, type ExecSyncOptions } from "node:child_process";
|
|
3
|
-
import { stdin, stdout, stderr } from "node:process";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
// (e.g. https://api.bazaar.ai) before public launch.
|
|
7
|
-
const PLATFORM_API_URL_DEFAULT = "https://ingrid-hypocycloidal-kaliyah.ngrok-free.dev";
|
|
1
|
+
import { createInterface } from "node:readline/promises";
|
|
2
|
+
import { execSync, type ExecSyncOptions } from "node:child_process";
|
|
3
|
+
import { stdin, stdout, stderr } from "node:process";
|
|
4
|
+
|
|
5
|
+
const PLATFORM_API_URL_DEFAULT = "http://localhost:3000";
|
|
8
6
|
|
|
9
7
|
// ── Helpers ──────────────────────────────────────────────────────────
|
|
10
8
|
|
|
@@ -93,31 +91,40 @@ async function promptApiKey(rl: ReturnType<typeof createInterface>): Promise<str
|
|
|
93
91
|
}
|
|
94
92
|
}
|
|
95
93
|
|
|
96
|
-
async function promptPlatformUrl(rl: ReturnType<typeof createInterface>): Promise<string> {
|
|
97
|
-
// Check CLI args
|
|
98
|
-
const urlArg = process.argv.find((a) => a.startsWith("--platform-url="));
|
|
99
|
-
if (urlArg) {
|
|
100
|
-
return urlArg.split("=").slice(1).join("=");
|
|
94
|
+
async function promptPlatformUrl(rl: ReturnType<typeof createInterface>): Promise<string> {
|
|
95
|
+
// Check CLI args
|
|
96
|
+
const urlArg = process.argv.find((a) => a.startsWith("--platform-url="));
|
|
97
|
+
if (urlArg) {
|
|
98
|
+
return urlArg.split("=").slice(1).join("=");
|
|
101
99
|
}
|
|
102
100
|
|
|
103
101
|
log("");
|
|
104
102
|
const url = await rl.question(
|
|
105
103
|
`Platform API URL [${PLATFORM_API_URL_DEFAULT}]: `,
|
|
106
104
|
);
|
|
107
|
-
return url.trim() || PLATFORM_API_URL_DEFAULT;
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
)
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
105
|
+
return url.trim() || PLATFORM_API_URL_DEFAULT;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
function getPlatformWsUrl(platformUrl: string): string {
|
|
109
|
+
const urlArg = process.argv.find((a) => a.startsWith("--platform-ws-url="));
|
|
110
|
+
if (urlArg) {
|
|
111
|
+
return urlArg.split("=").slice(1).join("=");
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
return platformUrl.replace(/^http/, "ws");
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
async function validateApiKey(
|
|
118
|
+
apiKey: string,
|
|
119
|
+
platformUrl: string,
|
|
120
|
+
): Promise<boolean> {
|
|
121
|
+
try {
|
|
122
|
+
const res = await fetch(`${platformUrl}/api/auth/me`, {
|
|
123
|
+
headers: { Authorization: `Bearer ${apiKey}` },
|
|
124
|
+
});
|
|
125
|
+
if (res.ok) {
|
|
126
|
+
const data = (await res.json()) as Record<string, string>;
|
|
127
|
+
success(`Authenticated as ${data.email || data.name || "user"}`);
|
|
121
128
|
return true;
|
|
122
129
|
}
|
|
123
130
|
fail(`API key validation failed: ${res.status}`);
|
|
@@ -179,19 +186,21 @@ function createStateDir(): void {
|
|
|
179
186
|
}
|
|
180
187
|
}
|
|
181
188
|
|
|
182
|
-
function registerMcpServer(
|
|
183
|
-
apiKey: string,
|
|
184
|
-
platformUrl: string,
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
`-e
|
|
192
|
-
`-e
|
|
193
|
-
`-e
|
|
194
|
-
|
|
189
|
+
function registerMcpServer(
|
|
190
|
+
apiKey: string,
|
|
191
|
+
platformUrl: string,
|
|
192
|
+
platformWsUrl: string,
|
|
193
|
+
): boolean {
|
|
194
|
+
const isRoot = run("whoami") === "root";
|
|
195
|
+
|
|
196
|
+
// Build the env vars for claude mcp add
|
|
197
|
+
const envFlags = [
|
|
198
|
+
`-e PLATFORM_API_URL=${platformUrl}`,
|
|
199
|
+
`-e PLATFORM_WS_URL=${platformWsUrl}`,
|
|
200
|
+
`-e PLATFORM_API_KEY=${apiKey}`,
|
|
201
|
+
`-e USE_MOCK_PLATFORM=false`,
|
|
202
|
+
`-e TUNNEL_ENABLED=true`,
|
|
203
|
+
isRoot ? "" : `-e PROVISIONING_USE_SUDO=true`,
|
|
195
204
|
]
|
|
196
205
|
.filter(Boolean)
|
|
197
206
|
.join(" ");
|
|
@@ -253,13 +262,14 @@ export async function runSetup(): Promise<void> {
|
|
|
253
262
|
// 3. Get API key
|
|
254
263
|
const apiKey = await promptApiKey(rl);
|
|
255
264
|
|
|
256
|
-
// 4. Get platform URL
|
|
257
|
-
const platformUrl = await promptPlatformUrl(rl);
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
log("
|
|
262
|
-
|
|
265
|
+
// 4. Get platform URL
|
|
266
|
+
const platformUrl = await promptPlatformUrl(rl);
|
|
267
|
+
const platformWsUrl = getPlatformWsUrl(platformUrl);
|
|
268
|
+
|
|
269
|
+
// 5. Validate API key
|
|
270
|
+
log("");
|
|
271
|
+
log("Validating API key...");
|
|
272
|
+
const valid = await validateApiKey(apiKey, platformUrl);
|
|
263
273
|
if (!valid) {
|
|
264
274
|
warn("Continuing anyway — you can fix the API key later");
|
|
265
275
|
}
|
|
@@ -278,21 +288,22 @@ export async function runSetup(): Promise<void> {
|
|
|
278
288
|
warn("Could not start sshd — contractor SSH access may not work");
|
|
279
289
|
}
|
|
280
290
|
|
|
281
|
-
// 9. Register MCP server
|
|
282
|
-
log("");
|
|
283
|
-
log("Registering MCP server with Claude Code...");
|
|
284
|
-
if (hasClaude) {
|
|
285
|
-
registerMcpServer(apiKey, platformUrl);
|
|
286
|
-
} else {
|
|
287
|
-
warn("Claude CLI not found — showing manual command:");
|
|
288
|
-
log("");
|
|
289
|
-
const isRoot = run("whoami") === "root";
|
|
290
|
-
const envFlags = [
|
|
291
|
-
`-e PLATFORM_API_URL=${platformUrl}`,
|
|
292
|
-
`-e
|
|
293
|
-
`-e
|
|
294
|
-
`-e
|
|
295
|
-
|
|
291
|
+
// 9. Register MCP server
|
|
292
|
+
log("");
|
|
293
|
+
log("Registering MCP server with Claude Code...");
|
|
294
|
+
if (hasClaude) {
|
|
295
|
+
registerMcpServer(apiKey, platformUrl, platformWsUrl);
|
|
296
|
+
} else {
|
|
297
|
+
warn("Claude CLI not found — showing manual command:");
|
|
298
|
+
log("");
|
|
299
|
+
const isRoot = run("whoami") === "root";
|
|
300
|
+
const envFlags = [
|
|
301
|
+
`-e PLATFORM_API_URL=${platformUrl}`,
|
|
302
|
+
`-e PLATFORM_WS_URL=${platformWsUrl}`,
|
|
303
|
+
`-e PLATFORM_API_KEY=${apiKey}`,
|
|
304
|
+
`-e USE_MOCK_PLATFORM=false`,
|
|
305
|
+
`-e TUNNEL_ENABLED=true`,
|
|
306
|
+
isRoot ? "" : `-e PROVISIONING_USE_SUDO=true`,
|
|
296
307
|
]
|
|
297
308
|
.filter(Boolean)
|
|
298
309
|
.join(" ");
|
package/src/config/env.ts
CHANGED
|
@@ -1,15 +1,18 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
|
|
3
|
+
const DEFAULT_PLATFORM_URL = "http://localhost:3000";
|
|
4
|
+
|
|
5
|
+
const EnvSchema = z.object({
|
|
6
|
+
PLATFORM_API_URL: z.string().url().default(DEFAULT_PLATFORM_URL),
|
|
7
|
+
/**
|
|
8
|
+
* Optional explicit WebSocket endpoint. Use this when HTTP requests go
|
|
9
|
+
* through a proxy path but the reverse tunnel must connect directly to the
|
|
10
|
+
* human-layer WebSocket server.
|
|
11
|
+
*/
|
|
12
|
+
PLATFORM_WS_URL: z.string().url().optional(),
|
|
13
|
+
PLATFORM_API_KEY: z.string().default(""),
|
|
14
|
+
/**
|
|
15
|
+
* Hostname or IP the contractor will SSH into. Only needed when
|
|
13
16
|
* TUNNEL_ENABLED=false (legacy direct-SSH mode). When the dev box is
|
|
14
17
|
* exposed via `ngrok tcp`, set this to the ngrok host (e.g.
|
|
15
18
|
* `0.tcp.ngrok.io`). Default `"auto"` triggers cloud metadata + local
|
|
@@ -9,15 +9,17 @@ import type {
|
|
|
9
9
|
CompleteGigResponse,
|
|
10
10
|
} from "./types.js";
|
|
11
11
|
|
|
12
|
-
export interface PlatformClient {
|
|
13
|
-
createGig(request: CreateGigRequest): Promise<CreateGigResponse>;
|
|
14
|
-
getGigStatus(gigId: string): Promise<GigStatusResponse>;
|
|
15
|
-
markReady(gigId: string, sshCommand: string): Promise<void>;
|
|
16
|
-
completeGig(request: CompleteGigRequest): Promise<CompleteGigResponse>;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
12
|
+
export interface PlatformClient {
|
|
13
|
+
createGig(request: CreateGigRequest): Promise<CreateGigResponse>;
|
|
14
|
+
getGigStatus(gigId: string): Promise<GigStatusResponse>;
|
|
15
|
+
markReady(gigId: string, sshCommand: string): Promise<void>;
|
|
16
|
+
completeGig(request: CompleteGigRequest): Promise<CompleteGigResponse>;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const API_PREFIX = "/api";
|
|
20
|
+
|
|
21
|
+
export class HttpPlatformClient implements PlatformClient {
|
|
22
|
+
private http: AxiosInstance;
|
|
21
23
|
|
|
22
24
|
constructor(baseUrl: string, apiKey: string) {
|
|
23
25
|
this.http = axios.create({
|
|
@@ -30,48 +32,48 @@ export class HttpPlatformClient implements PlatformClient {
|
|
|
30
32
|
});
|
|
31
33
|
}
|
|
32
34
|
|
|
33
|
-
async createGig(request: CreateGigRequest): Promise<CreateGigResponse> {
|
|
34
|
-
try {
|
|
35
|
-
const { data } = await this.http.post<CreateGigResponse>(
|
|
36
|
-
|
|
37
|
-
request,
|
|
38
|
-
);
|
|
39
|
-
logger.info("Gig created on platform", { gigId: data.gigId });
|
|
40
|
-
return data;
|
|
35
|
+
async createGig(request: CreateGigRequest): Promise<CreateGigResponse> {
|
|
36
|
+
try {
|
|
37
|
+
const { data } = await this.http.post<CreateGigResponse>(
|
|
38
|
+
`${API_PREFIX}/gigs`,
|
|
39
|
+
request,
|
|
40
|
+
);
|
|
41
|
+
logger.info("Gig created on platform", { gigId: data.gigId });
|
|
42
|
+
return data;
|
|
41
43
|
} catch (error) {
|
|
42
44
|
throw this.wrapError("Failed to create gig", error);
|
|
43
45
|
}
|
|
44
46
|
}
|
|
45
47
|
|
|
46
|
-
async getGigStatus(gigId: string): Promise<GigStatusResponse> {
|
|
47
|
-
try {
|
|
48
|
-
const { data } = await this.http.get<GigStatusResponse>(
|
|
49
|
-
|
|
50
|
-
);
|
|
51
|
-
return data;
|
|
52
|
-
} catch (error) {
|
|
53
|
-
throw this.wrapError(`Failed to get gig status: ${gigId}`, error);
|
|
48
|
+
async getGigStatus(gigId: string): Promise<GigStatusResponse> {
|
|
49
|
+
try {
|
|
50
|
+
const { data } = await this.http.get<GigStatusResponse>(
|
|
51
|
+
`${API_PREFIX}/gigs/${gigId}/status`,
|
|
52
|
+
);
|
|
53
|
+
return data;
|
|
54
|
+
} catch (error) {
|
|
55
|
+
throw this.wrapError(`Failed to get gig status: ${gigId}`, error);
|
|
54
56
|
}
|
|
55
57
|
}
|
|
56
58
|
|
|
57
|
-
async markReady(gigId: string, sshCommand: string): Promise<void> {
|
|
58
|
-
try {
|
|
59
|
-
await this.http.post(
|
|
60
|
-
logger.info("Gig marked as ready", { gigId });
|
|
61
|
-
} catch (error) {
|
|
62
|
-
throw this.wrapError(`Failed to mark gig ready: ${gigId}`, error);
|
|
59
|
+
async markReady(gigId: string, sshCommand: string): Promise<void> {
|
|
60
|
+
try {
|
|
61
|
+
await this.http.post(`${API_PREFIX}/gigs/${gigId}/ready`, { sshCommand });
|
|
62
|
+
logger.info("Gig marked as ready", { gigId });
|
|
63
|
+
} catch (error) {
|
|
64
|
+
throw this.wrapError(`Failed to mark gig ready: ${gigId}`, error);
|
|
63
65
|
}
|
|
64
66
|
}
|
|
65
67
|
|
|
66
|
-
async completeGig(
|
|
67
|
-
request: CompleteGigRequest,
|
|
68
|
-
): Promise<CompleteGigResponse> {
|
|
69
|
-
try {
|
|
70
|
-
const { data } = await this.http.post<CompleteGigResponse>(
|
|
71
|
-
|
|
72
|
-
request,
|
|
73
|
-
);
|
|
74
|
-
logger.info("Gig completed on platform", { gigId: request.gigId });
|
|
68
|
+
async completeGig(
|
|
69
|
+
request: CompleteGigRequest,
|
|
70
|
+
): Promise<CompleteGigResponse> {
|
|
71
|
+
try {
|
|
72
|
+
const { data } = await this.http.post<CompleteGigResponse>(
|
|
73
|
+
`${API_PREFIX}/gigs/${request.gigId}/complete`,
|
|
74
|
+
request,
|
|
75
|
+
);
|
|
76
|
+
logger.info("Gig completed on platform", { gigId: request.gigId });
|
|
75
77
|
return data;
|
|
76
78
|
} catch (error) {
|
|
77
79
|
throw this.wrapError(
|
|
@@ -130,11 +130,12 @@ export async function summonHuman(
|
|
|
130
130
|
const useTunnel = env.TUNNEL_ENABLED;
|
|
131
131
|
let sshCommand: string;
|
|
132
132
|
|
|
133
|
-
if (useTunnel) {
|
|
134
|
-
// Open reverse tunnel — platform routes contractor traffic through it
|
|
135
|
-
const platformWsUrl =
|
|
136
|
-
|
|
137
|
-
|
|
133
|
+
if (useTunnel) {
|
|
134
|
+
// Open reverse tunnel — platform routes contractor traffic through it
|
|
135
|
+
const platformWsUrl =
|
|
136
|
+
env.PLATFORM_WS_URL ?? env.PLATFORM_API_URL.replace(/^http/, "ws");
|
|
137
|
+
const handle = openTunnel(platformWsUrl, env.PLATFORM_API_KEY, gigId);
|
|
138
|
+
storeTunnel(gigId, handle);
|
|
138
139
|
|
|
139
140
|
sshCommand = `(via tunnel to platform)`;
|
|
140
141
|
|