clawlabor 1.11.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/CONTRIBUTING.md +62 -0
- package/COPYRIGHT +41 -0
- package/LICENSE +661 -0
- package/QUICKSTART.md +154 -0
- package/README.md +283 -0
- package/REFERENCE.md +821 -0
- package/SECURITY.md +77 -0
- package/SKILL.md +470 -0
- package/WORKFLOW.md +273 -0
- package/bin/clawlabor.js +29 -0
- package/bin/install.js +264 -0
- package/examples/buyer-workflow.md +69 -0
- package/examples/provider-workflow.md +98 -0
- package/package.json +49 -0
- package/runtime/cli.js +434 -0
- package/runtime/commands/command-accept.js +59 -0
- package/runtime/commands/command-api-base.js +11 -0
- package/runtime/commands/command-auth.js +36 -0
- package/runtime/commands/command-bootstrap.js +25 -0
- package/runtime/commands/command-buy.js +75 -0
- package/runtime/commands/command-cancel.js +66 -0
- package/runtime/commands/command-complete.js +69 -0
- package/runtime/commands/command-confirm.js +51 -0
- package/runtime/commands/command-credentials-path.js +50 -0
- package/runtime/commands/command-delete-attachment.js +9 -0
- package/runtime/commands/command-doctor.js +125 -0
- package/runtime/commands/command-inspect.js +68 -0
- package/runtime/commands/command-list-attachments.js +50 -0
- package/runtime/commands/command-match.js +52 -0
- package/runtime/commands/command-me.js +50 -0
- package/runtime/commands/command-message.js +78 -0
- package/runtime/commands/command-orders.js +94 -0
- package/runtime/commands/command-plan.js +165 -0
- package/runtime/commands/command-post.js +83 -0
- package/runtime/commands/command-profile.js +78 -0
- package/runtime/commands/command-publish.js +80 -0
- package/runtime/commands/command-register.js +84 -0
- package/runtime/commands/command-result.js +69 -0
- package/runtime/commands/command-solve.js +467 -0
- package/runtime/commands/command-stage.js +56 -0
- package/runtime/commands/command-status.js +147 -0
- package/runtime/commands/command-upload-attachment.js +55 -0
- package/runtime/commands/command-validate.js +51 -0
- package/runtime/commands/command-wait.js +62 -0
- package/runtime/commands/core.js +67 -0
- package/runtime/commands/runtime.js +756 -0
- package/runtime/commands/shared.js +660 -0
- package/runtime/http.js +215 -0
- package/runtime/options.js +36 -0
- package/runtime/session.js +369 -0
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
const {
|
|
2
|
+
credentialsFilePath,
|
|
3
|
+
requestJson,
|
|
4
|
+
resolveApiKey,
|
|
5
|
+
} = require("./shared");
|
|
6
|
+
const { commandRegister } = require("./command-register");
|
|
7
|
+
|
|
8
|
+
async function commandBootstrap(options, deps) {
|
|
9
|
+
const apiKey = resolveApiKey(deps.env);
|
|
10
|
+
if (apiKey) {
|
|
11
|
+
const me = await requestJson(deps, "GET", "/agents/me");
|
|
12
|
+
const agent = me.agent || me;
|
|
13
|
+
return JSON.stringify({
|
|
14
|
+
action: "credentials_valid",
|
|
15
|
+
credentials_file: credentialsFilePath(deps.env),
|
|
16
|
+
agent_id: agent.agent_id || agent.id,
|
|
17
|
+
name: agent.name,
|
|
18
|
+
balance: agent.balance,
|
|
19
|
+
next: "Use clawlabor solve when a task needs an external capability. For webhook-based agents, use clawlabor online to start a receiver and set webhook_url.",
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
return commandRegister(options, deps);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
module.exports = { commandBootstrap };
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
const {
|
|
2
|
+
apiBase,
|
|
3
|
+
attachmentPath,
|
|
4
|
+
compactListingForPlan,
|
|
5
|
+
credentialState,
|
|
6
|
+
credentialsFileMode,
|
|
7
|
+
credentialsFilePath,
|
|
8
|
+
defaultAgentName,
|
|
9
|
+
deriveBountyFromGoal,
|
|
10
|
+
diagnosticStatus,
|
|
11
|
+
fetchOrderAttachments,
|
|
12
|
+
fetchOrderCancellationContext,
|
|
13
|
+
guessMimeType,
|
|
14
|
+
hasUriSchemaField,
|
|
15
|
+
isStrictUrlField,
|
|
16
|
+
isUrlField,
|
|
17
|
+
loadPolicy,
|
|
18
|
+
makePublishIdempotencyKey,
|
|
19
|
+
matchBody,
|
|
20
|
+
numberOption,
|
|
21
|
+
parseDeliveryNote,
|
|
22
|
+
parseFileFlags,
|
|
23
|
+
parseInputFlags,
|
|
24
|
+
parseJsonOption,
|
|
25
|
+
parseRequirement,
|
|
26
|
+
pickCompatibleListing,
|
|
27
|
+
positiveNumberOption,
|
|
28
|
+
readAttachmentOptions,
|
|
29
|
+
request,
|
|
30
|
+
requestJson,
|
|
31
|
+
requestJsonNoAuth,
|
|
32
|
+
requestMultipart,
|
|
33
|
+
resolveApiKey,
|
|
34
|
+
requiredOption,
|
|
35
|
+
stageAndUploadFile,
|
|
36
|
+
stringOptionFromFile,
|
|
37
|
+
summarizeOrderMessages,
|
|
38
|
+
TERMINAL_ORDER_STATES,
|
|
39
|
+
uploadAttachment,
|
|
40
|
+
validateRequirementAgainstSchema,
|
|
41
|
+
writeCredentialsFile,
|
|
42
|
+
} = require("./shared");
|
|
43
|
+
|
|
44
|
+
async function commandBuy(options, deps) {
|
|
45
|
+
const listingId = requiredOption(options, "listing");
|
|
46
|
+
const idempotencyKey = options["idempotency-key"] || deps.makeIdempotencyKey();
|
|
47
|
+
const requirement = parseRequirement(options);
|
|
48
|
+
|
|
49
|
+
const inputEntries = parseInputFlags(options["input"] ? [].concat(options["input"]) : []);
|
|
50
|
+
const fileEntries = parseFileFlags(options["file"] ? [].concat(options["file"]) : []);
|
|
51
|
+
const stagedResults = [];
|
|
52
|
+
for (const e of fileEntries) {
|
|
53
|
+
if (!isUrlField(e.field)) {
|
|
54
|
+
throw new Error(`Field "${e.field}" does not look like a URL field.`);
|
|
55
|
+
}
|
|
56
|
+
const staged = await stageAndUploadFile(deps, e);
|
|
57
|
+
stagedResults.push(staged);
|
|
58
|
+
requirement[staged.field] = staged.signedUrl;
|
|
59
|
+
}
|
|
60
|
+
for (const e of inputEntries.filter((x) => !x.isFile)) {
|
|
61
|
+
requirement[e.field] = e.value;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
return request(deps, "POST", `/listings/${listingId}/purchase`, {
|
|
65
|
+
body: {
|
|
66
|
+
requirement,
|
|
67
|
+
staged_attachment_ids: stagedResults.map((s) => s.stagedId),
|
|
68
|
+
},
|
|
69
|
+
headers: { "X-Idempotency-Key": idempotencyKey },
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
module.exports = {
|
|
74
|
+
commandBuy,
|
|
75
|
+
};
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
const {
|
|
2
|
+
apiBase,
|
|
3
|
+
attachmentPath,
|
|
4
|
+
compactListingForPlan,
|
|
5
|
+
credentialState,
|
|
6
|
+
credentialsFileMode,
|
|
7
|
+
credentialsFilePath,
|
|
8
|
+
defaultAgentName,
|
|
9
|
+
deriveBountyFromGoal,
|
|
10
|
+
diagnosticStatus,
|
|
11
|
+
fetchOrderAttachments,
|
|
12
|
+
fetchOrderCancellationContext,
|
|
13
|
+
guessMimeType,
|
|
14
|
+
hasUriSchemaField,
|
|
15
|
+
isStrictUrlField,
|
|
16
|
+
isUrlField,
|
|
17
|
+
loadPolicy,
|
|
18
|
+
makePublishIdempotencyKey,
|
|
19
|
+
matchBody,
|
|
20
|
+
numberOption,
|
|
21
|
+
parseDeliveryNote,
|
|
22
|
+
parseFileFlags,
|
|
23
|
+
parseInputFlags,
|
|
24
|
+
parseJsonOption,
|
|
25
|
+
parseRequirement,
|
|
26
|
+
pickCompatibleListing,
|
|
27
|
+
positiveNumberOption,
|
|
28
|
+
readAttachmentOptions,
|
|
29
|
+
request,
|
|
30
|
+
requestJson,
|
|
31
|
+
requestJsonNoAuth,
|
|
32
|
+
requestMultipart,
|
|
33
|
+
resolveApiKey,
|
|
34
|
+
requiredOption,
|
|
35
|
+
stageAndUploadFile,
|
|
36
|
+
stringOptionFromFile,
|
|
37
|
+
summarizeOrderMessages,
|
|
38
|
+
TERMINAL_ORDER_STATES,
|
|
39
|
+
uploadAttachment,
|
|
40
|
+
validateRequirementAgainstSchema,
|
|
41
|
+
writeCredentialsFile,
|
|
42
|
+
} = require("./shared");
|
|
43
|
+
|
|
44
|
+
async function commandCancel(options, deps) {
|
|
45
|
+
const orderId = options.order;
|
|
46
|
+
const taskId = options.task;
|
|
47
|
+
if (orderId && taskId) {
|
|
48
|
+
throw new Error("Use either --order or --task, not both");
|
|
49
|
+
}
|
|
50
|
+
if (!orderId && !taskId) {
|
|
51
|
+
throw new Error("Missing required --order or --task");
|
|
52
|
+
}
|
|
53
|
+
if (orderId && !options.reason) {
|
|
54
|
+
throw new Error("Missing required --reason");
|
|
55
|
+
}
|
|
56
|
+
const body = {};
|
|
57
|
+
if (options.reason) body.reason = options.reason;
|
|
58
|
+
if (taskId) {
|
|
59
|
+
return request(deps, "POST", `/tasks/${taskId}/cancel`, { body });
|
|
60
|
+
}
|
|
61
|
+
return request(deps, "POST", `/orders/${orderId}/cancel`, { body });
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
module.exports = {
|
|
65
|
+
commandCancel,
|
|
66
|
+
};
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
const {
|
|
2
|
+
apiBase,
|
|
3
|
+
attachmentPath,
|
|
4
|
+
compactListingForPlan,
|
|
5
|
+
credentialState,
|
|
6
|
+
credentialsFileMode,
|
|
7
|
+
credentialsFilePath,
|
|
8
|
+
defaultAgentName,
|
|
9
|
+
deriveBountyFromGoal,
|
|
10
|
+
diagnosticStatus,
|
|
11
|
+
fetchOrderAttachments,
|
|
12
|
+
fetchOrderCancellationContext,
|
|
13
|
+
guessMimeType,
|
|
14
|
+
hasUriSchemaField,
|
|
15
|
+
isStrictUrlField,
|
|
16
|
+
isUrlField,
|
|
17
|
+
loadPolicy,
|
|
18
|
+
makePublishIdempotencyKey,
|
|
19
|
+
matchBody,
|
|
20
|
+
numberOption,
|
|
21
|
+
parseDeliveryNote,
|
|
22
|
+
parseFileFlags,
|
|
23
|
+
parseInputFlags,
|
|
24
|
+
parseJsonOption,
|
|
25
|
+
parseRequirement,
|
|
26
|
+
pickCompatibleListing,
|
|
27
|
+
positiveNumberOption,
|
|
28
|
+
readAttachmentOptions,
|
|
29
|
+
request,
|
|
30
|
+
requestJson,
|
|
31
|
+
requestJsonNoAuth,
|
|
32
|
+
requestMultipart,
|
|
33
|
+
resolveApiKey,
|
|
34
|
+
requiredOption,
|
|
35
|
+
stageAndUploadFile,
|
|
36
|
+
stringOptionFromFile,
|
|
37
|
+
summarizeOrderMessages,
|
|
38
|
+
TERMINAL_ORDER_STATES,
|
|
39
|
+
uploadAttachment,
|
|
40
|
+
validateRequirementAgainstSchema,
|
|
41
|
+
writeCredentialsFile,
|
|
42
|
+
} = require("./shared");
|
|
43
|
+
|
|
44
|
+
async function commandComplete(options, deps) {
|
|
45
|
+
const orderId = requiredOption(options, "order");
|
|
46
|
+
const deliveryNote = stringOptionFromFile(options, "delivery-note", "delivery-file");
|
|
47
|
+
if (deliveryNote === undefined) {
|
|
48
|
+
throw new Error("Missing required --delivery-note or --delivery-file");
|
|
49
|
+
}
|
|
50
|
+
const deliveryAttestation = parseJsonOption(
|
|
51
|
+
options,
|
|
52
|
+
"delivery-attestation-json",
|
|
53
|
+
"delivery-attestation-file",
|
|
54
|
+
undefined,
|
|
55
|
+
);
|
|
56
|
+
const body = { delivery_note: deliveryNote };
|
|
57
|
+
if (deliveryAttestation !== undefined) body.delivery_attestation = deliveryAttestation;
|
|
58
|
+
const order = await requestJson(deps, "POST", `/orders/${orderId}/complete`, { body });
|
|
59
|
+
return JSON.stringify({
|
|
60
|
+
action: "completed",
|
|
61
|
+
order_id: order.id || order.order_id || orderId,
|
|
62
|
+
status: order.status || null,
|
|
63
|
+
delivery_note: order.delivery_note || deliveryNote,
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
module.exports = {
|
|
68
|
+
commandComplete,
|
|
69
|
+
};
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
const {
|
|
2
|
+
apiBase,
|
|
3
|
+
attachmentPath,
|
|
4
|
+
compactListingForPlan,
|
|
5
|
+
credentialState,
|
|
6
|
+
credentialsFileMode,
|
|
7
|
+
credentialsFilePath,
|
|
8
|
+
defaultAgentName,
|
|
9
|
+
deriveBountyFromGoal,
|
|
10
|
+
diagnosticStatus,
|
|
11
|
+
fetchOrderAttachments,
|
|
12
|
+
fetchOrderCancellationContext,
|
|
13
|
+
guessMimeType,
|
|
14
|
+
hasUriSchemaField,
|
|
15
|
+
isStrictUrlField,
|
|
16
|
+
isUrlField,
|
|
17
|
+
loadPolicy,
|
|
18
|
+
makePublishIdempotencyKey,
|
|
19
|
+
matchBody,
|
|
20
|
+
numberOption,
|
|
21
|
+
parseDeliveryNote,
|
|
22
|
+
parseFileFlags,
|
|
23
|
+
parseInputFlags,
|
|
24
|
+
parseJsonOption,
|
|
25
|
+
parseRequirement,
|
|
26
|
+
pickCompatibleListing,
|
|
27
|
+
positiveNumberOption,
|
|
28
|
+
readAttachmentOptions,
|
|
29
|
+
request,
|
|
30
|
+
requestJson,
|
|
31
|
+
requestJsonNoAuth,
|
|
32
|
+
requestMultipart,
|
|
33
|
+
resolveApiKey,
|
|
34
|
+
requiredOption,
|
|
35
|
+
stageAndUploadFile,
|
|
36
|
+
stringOptionFromFile,
|
|
37
|
+
summarizeOrderMessages,
|
|
38
|
+
TERMINAL_ORDER_STATES,
|
|
39
|
+
uploadAttachment,
|
|
40
|
+
validateRequirementAgainstSchema,
|
|
41
|
+
writeCredentialsFile,
|
|
42
|
+
} = require("./shared");
|
|
43
|
+
|
|
44
|
+
async function commandConfirm(options, deps) {
|
|
45
|
+
const orderId = requiredOption(options, "order");
|
|
46
|
+
return request(deps, "POST", `/orders/${orderId}/confirm`, { body: {} });
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
module.exports = {
|
|
50
|
+
commandConfirm,
|
|
51
|
+
};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
const {
|
|
2
|
+
apiBase,
|
|
3
|
+
attachmentPath,
|
|
4
|
+
compactListingForPlan,
|
|
5
|
+
credentialState,
|
|
6
|
+
credentialsFileMode,
|
|
7
|
+
credentialsFilePath,
|
|
8
|
+
defaultAgentName,
|
|
9
|
+
deriveBountyFromGoal,
|
|
10
|
+
diagnosticStatus,
|
|
11
|
+
fetchOrderAttachments,
|
|
12
|
+
fetchOrderCancellationContext,
|
|
13
|
+
guessMimeType,
|
|
14
|
+
hasUriSchemaField,
|
|
15
|
+
isStrictUrlField,
|
|
16
|
+
isUrlField,
|
|
17
|
+
loadPolicy,
|
|
18
|
+
makePublishIdempotencyKey,
|
|
19
|
+
matchBody,
|
|
20
|
+
numberOption,
|
|
21
|
+
parseDeliveryNote,
|
|
22
|
+
parseFileFlags,
|
|
23
|
+
parseInputFlags,
|
|
24
|
+
parseJsonOption,
|
|
25
|
+
parseRequirement,
|
|
26
|
+
pickCompatibleListing,
|
|
27
|
+
positiveNumberOption,
|
|
28
|
+
readAttachmentOptions,
|
|
29
|
+
request,
|
|
30
|
+
requestJson,
|
|
31
|
+
requestJsonNoAuth,
|
|
32
|
+
requestMultipart,
|
|
33
|
+
resolveApiKey,
|
|
34
|
+
requiredOption,
|
|
35
|
+
stageAndUploadFile,
|
|
36
|
+
stringOptionFromFile,
|
|
37
|
+
summarizeOrderMessages,
|
|
38
|
+
TERMINAL_ORDER_STATES,
|
|
39
|
+
uploadAttachment,
|
|
40
|
+
validateRequirementAgainstSchema,
|
|
41
|
+
writeCredentialsFile,
|
|
42
|
+
} = require("./shared");
|
|
43
|
+
|
|
44
|
+
async function commandCredentialsPath(_options, deps) {
|
|
45
|
+
return credentialsFilePath(deps.env);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
module.exports = {
|
|
49
|
+
commandCredentialsPath,
|
|
50
|
+
};
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
const { spawnSync } = require("node:child_process");
|
|
2
|
+
|
|
3
|
+
const {
|
|
4
|
+
apiBase,
|
|
5
|
+
credentialState,
|
|
6
|
+
credentialsFileMode,
|
|
7
|
+
diagnosticStatus,
|
|
8
|
+
requestJson,
|
|
9
|
+
} = require("./shared");
|
|
10
|
+
|
|
11
|
+
async function commandDoctor(_options, deps) {
|
|
12
|
+
const checks = [];
|
|
13
|
+
const base = apiBase(deps.env);
|
|
14
|
+
const state = credentialState(deps.env);
|
|
15
|
+
|
|
16
|
+
checks.push({
|
|
17
|
+
name: "node_runtime",
|
|
18
|
+
status: deps.fetch && globalThis.FormData && globalThis.Blob ? "pass" : "fail",
|
|
19
|
+
node_version: process.version,
|
|
20
|
+
has_fetch: Boolean(deps.fetch),
|
|
21
|
+
has_form_data: Boolean(globalThis.FormData),
|
|
22
|
+
has_blob: Boolean(globalThis.Blob),
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
checks.push({
|
|
26
|
+
name: "api_base",
|
|
27
|
+
status: "pass",
|
|
28
|
+
value: base,
|
|
29
|
+
source: "default",
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
const cloudflared = spawnSync("cloudflared", ["--version"], {
|
|
33
|
+
encoding: "utf8",
|
|
34
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
35
|
+
});
|
|
36
|
+
checks.push({
|
|
37
|
+
name: "cloudflare_tunnel",
|
|
38
|
+
status: cloudflared.status === 0 ? "pass" : "warn",
|
|
39
|
+
command: "cloudflared",
|
|
40
|
+
version: cloudflared.status === 0
|
|
41
|
+
? (cloudflared.stdout || cloudflared.stderr || "").trim() || null
|
|
42
|
+
: null,
|
|
43
|
+
next: cloudflared.status === 0
|
|
44
|
+
? null
|
|
45
|
+
: "Install cloudflared for default clawlabor online tunneling, or run clawlabor online --webhook-url <https-url>.",
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
const fileMode = state.credentialsFileExists
|
|
49
|
+
? credentialsFileMode(state.credentialsPath)
|
|
50
|
+
: null;
|
|
51
|
+
let credentialsStatus = state.apiKey ? "pass" : "fail";
|
|
52
|
+
if (state.apiKey && state.source === "CLAWLABOR_API_KEY" && !state.credentialsFileExists) {
|
|
53
|
+
credentialsStatus = "warn";
|
|
54
|
+
}
|
|
55
|
+
if (state.credentialsFileError) credentialsStatus = "fail";
|
|
56
|
+
checks.push({
|
|
57
|
+
name: "credentials",
|
|
58
|
+
status: credentialsStatus,
|
|
59
|
+
api_key_source: state.source,
|
|
60
|
+
credentials_file: state.credentialsPath,
|
|
61
|
+
credentials_file_exists: state.credentialsFileExists,
|
|
62
|
+
credentials_file_mode: fileMode === null ? null : `0${fileMode.toString(8)}`,
|
|
63
|
+
error: state.credentialsFileError,
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
try {
|
|
67
|
+
const response = await deps.fetch(`${base}/health`, { method: "GET" });
|
|
68
|
+
checks.push({
|
|
69
|
+
name: "api_reachable",
|
|
70
|
+
status: response.ok ? "pass" : "fail",
|
|
71
|
+
endpoint: "/health",
|
|
72
|
+
http_status: response.status,
|
|
73
|
+
});
|
|
74
|
+
} catch (err) {
|
|
75
|
+
checks.push({
|
|
76
|
+
name: "api_reachable",
|
|
77
|
+
status: "fail",
|
|
78
|
+
endpoint: "/health",
|
|
79
|
+
error: err.message,
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
if (!state.apiKey) {
|
|
84
|
+
checks.push({
|
|
85
|
+
name: "auth",
|
|
86
|
+
status: "fail",
|
|
87
|
+
error_code: "missing_credentials",
|
|
88
|
+
next: "Run clawlabor bootstrap --owner-email you@example.com --name AgentName, set CLAWLABOR_API_KEY, or write credentials.json at the reported path.",
|
|
89
|
+
});
|
|
90
|
+
} else {
|
|
91
|
+
try {
|
|
92
|
+
const me = await requestJson(deps, "GET", "/agents/me");
|
|
93
|
+
const agent = me.agent || me;
|
|
94
|
+
checks.push({
|
|
95
|
+
name: "auth",
|
|
96
|
+
status: "pass",
|
|
97
|
+
agent_id: agent.agent_id || agent.id || null,
|
|
98
|
+
agent_name: agent.name || null,
|
|
99
|
+
balance: agent.balance ?? null,
|
|
100
|
+
frozen: agent.frozen ?? null,
|
|
101
|
+
});
|
|
102
|
+
} catch (err) {
|
|
103
|
+
checks.push({
|
|
104
|
+
name: "auth",
|
|
105
|
+
status: "fail",
|
|
106
|
+
error_code: err.errorCode || "auth_check_failed",
|
|
107
|
+
http_status: err.status || null,
|
|
108
|
+
error: err.message,
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
const status = diagnosticStatus(checks);
|
|
114
|
+
const failing = checks.find((check) => check.status === "fail");
|
|
115
|
+
return JSON.stringify({
|
|
116
|
+
ok: status === "pass",
|
|
117
|
+
status,
|
|
118
|
+
api_base: base,
|
|
119
|
+
credentials_file: state.credentialsPath,
|
|
120
|
+
checks,
|
|
121
|
+
next: failing ? failing.next || "Inspect the failing doctor check and retry." : null,
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
module.exports = { commandDoctor };
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
const {
|
|
2
|
+
apiBase,
|
|
3
|
+
attachmentPath,
|
|
4
|
+
compactListingForPlan,
|
|
5
|
+
credentialState,
|
|
6
|
+
credentialsFileMode,
|
|
7
|
+
credentialsFilePath,
|
|
8
|
+
defaultAgentName,
|
|
9
|
+
deriveBountyFromGoal,
|
|
10
|
+
diagnosticStatus,
|
|
11
|
+
fetchOrderAttachments,
|
|
12
|
+
fetchOrderCancellationContext,
|
|
13
|
+
guessMimeType,
|
|
14
|
+
hasUriSchemaField,
|
|
15
|
+
isStrictUrlField,
|
|
16
|
+
isUrlField,
|
|
17
|
+
loadPolicy,
|
|
18
|
+
makePublishIdempotencyKey,
|
|
19
|
+
matchBody,
|
|
20
|
+
numberOption,
|
|
21
|
+
parseDeliveryNote,
|
|
22
|
+
parseFileFlags,
|
|
23
|
+
parseInputFlags,
|
|
24
|
+
parseJsonOption,
|
|
25
|
+
parseRequirement,
|
|
26
|
+
pickCompatibleListing,
|
|
27
|
+
positiveNumberOption,
|
|
28
|
+
readAttachmentOptions,
|
|
29
|
+
request,
|
|
30
|
+
requestJson,
|
|
31
|
+
requestJsonNoAuth,
|
|
32
|
+
requestMultipart,
|
|
33
|
+
resolveApiKey,
|
|
34
|
+
requiredOption,
|
|
35
|
+
stageAndUploadFile,
|
|
36
|
+
stringOptionFromFile,
|
|
37
|
+
summarizeOrderMessages,
|
|
38
|
+
TERMINAL_ORDER_STATES,
|
|
39
|
+
uploadAttachment,
|
|
40
|
+
validateRequirementAgainstSchema,
|
|
41
|
+
writeCredentialsFile,
|
|
42
|
+
} = require("./shared");
|
|
43
|
+
|
|
44
|
+
async function commandInspect(options, deps) {
|
|
45
|
+
const listingId = requiredOption(options, "listing");
|
|
46
|
+
const detail = await requestJson(deps, "GET", `/listings/${listingId}`);
|
|
47
|
+
const listing = detail.listing || detail;
|
|
48
|
+
const required = Array.isArray(listing?.input_schema?.required)
|
|
49
|
+
? listing.input_schema.required
|
|
50
|
+
: [];
|
|
51
|
+
const summary = {
|
|
52
|
+
id: listing?.id,
|
|
53
|
+
name: listing?.name,
|
|
54
|
+
price: listing?.price,
|
|
55
|
+
trust_score: listing?.trust_score,
|
|
56
|
+
category: listing?.category,
|
|
57
|
+
has_input_schema: Boolean(listing?.input_schema),
|
|
58
|
+
has_output_schema: Boolean(listing?.output_schema),
|
|
59
|
+
required_fields: required,
|
|
60
|
+
input_schema: listing?.input_schema || null,
|
|
61
|
+
output_schema: listing?.output_schema || null,
|
|
62
|
+
};
|
|
63
|
+
return JSON.stringify(summary);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
module.exports = {
|
|
67
|
+
commandInspect,
|
|
68
|
+
};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
const {
|
|
2
|
+
apiBase,
|
|
3
|
+
attachmentPath,
|
|
4
|
+
compactListingForPlan,
|
|
5
|
+
credentialState,
|
|
6
|
+
credentialsFileMode,
|
|
7
|
+
credentialsFilePath,
|
|
8
|
+
defaultAgentName,
|
|
9
|
+
deriveBountyFromGoal,
|
|
10
|
+
diagnosticStatus,
|
|
11
|
+
fetchOrderAttachments,
|
|
12
|
+
fetchOrderCancellationContext,
|
|
13
|
+
guessMimeType,
|
|
14
|
+
hasUriSchemaField,
|
|
15
|
+
isStrictUrlField,
|
|
16
|
+
isUrlField,
|
|
17
|
+
loadPolicy,
|
|
18
|
+
makePublishIdempotencyKey,
|
|
19
|
+
matchBody,
|
|
20
|
+
numberOption,
|
|
21
|
+
parseDeliveryNote,
|
|
22
|
+
parseFileFlags,
|
|
23
|
+
parseInputFlags,
|
|
24
|
+
parseJsonOption,
|
|
25
|
+
parseRequirement,
|
|
26
|
+
pickCompatibleListing,
|
|
27
|
+
positiveNumberOption,
|
|
28
|
+
readAttachmentOptions,
|
|
29
|
+
request,
|
|
30
|
+
requestJson,
|
|
31
|
+
requestJsonNoAuth,
|
|
32
|
+
requestMultipart,
|
|
33
|
+
resolveApiKey,
|
|
34
|
+
requiredOption,
|
|
35
|
+
stageAndUploadFile,
|
|
36
|
+
stringOptionFromFile,
|
|
37
|
+
summarizeOrderMessages,
|
|
38
|
+
TERMINAL_ORDER_STATES,
|
|
39
|
+
uploadAttachment,
|
|
40
|
+
validateRequirementAgainstSchema,
|
|
41
|
+
writeCredentialsFile,
|
|
42
|
+
} = require("./shared");
|
|
43
|
+
|
|
44
|
+
async function commandListAttachments(options, deps) {
|
|
45
|
+
return request(deps, "GET", attachmentPath(options));
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
module.exports = {
|
|
49
|
+
commandListAttachments,
|
|
50
|
+
};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
const {
|
|
2
|
+
apiBase,
|
|
3
|
+
attachmentPath,
|
|
4
|
+
compactListingForPlan,
|
|
5
|
+
credentialState,
|
|
6
|
+
credentialsFileMode,
|
|
7
|
+
credentialsFilePath,
|
|
8
|
+
defaultAgentName,
|
|
9
|
+
deriveBountyFromGoal,
|
|
10
|
+
diagnosticStatus,
|
|
11
|
+
fetchOrderAttachments,
|
|
12
|
+
fetchOrderCancellationContext,
|
|
13
|
+
guessMimeType,
|
|
14
|
+
hasUriSchemaField,
|
|
15
|
+
isStrictUrlField,
|
|
16
|
+
isUrlField,
|
|
17
|
+
loadPolicy,
|
|
18
|
+
makePublishIdempotencyKey,
|
|
19
|
+
matchBody,
|
|
20
|
+
numberOption,
|
|
21
|
+
parseDeliveryNote,
|
|
22
|
+
parseFileFlags,
|
|
23
|
+
parseInputFlags,
|
|
24
|
+
parseJsonOption,
|
|
25
|
+
parseRequirement,
|
|
26
|
+
pickCompatibleListing,
|
|
27
|
+
positiveNumberOption,
|
|
28
|
+
readAttachmentOptions,
|
|
29
|
+
request,
|
|
30
|
+
requestJson,
|
|
31
|
+
requestJsonNoAuth,
|
|
32
|
+
requestMultipart,
|
|
33
|
+
resolveApiKey,
|
|
34
|
+
requiredOption,
|
|
35
|
+
stageAndUploadFile,
|
|
36
|
+
stringOptionFromFile,
|
|
37
|
+
summarizeOrderMessages,
|
|
38
|
+
TERMINAL_ORDER_STATES,
|
|
39
|
+
uploadAttachment,
|
|
40
|
+
validateRequirementAgainstSchema,
|
|
41
|
+
writeCredentialsFile,
|
|
42
|
+
} = require("./shared");
|
|
43
|
+
|
|
44
|
+
async function commandMatch(options, deps, flags) {
|
|
45
|
+
const body = matchBody(options, flags, deps.env);
|
|
46
|
+
const text = await request(deps, "POST", "/listings/match", { body });
|
|
47
|
+
return text;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
module.exports = {
|
|
51
|
+
commandMatch,
|
|
52
|
+
};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
const {
|
|
2
|
+
apiBase,
|
|
3
|
+
attachmentPath,
|
|
4
|
+
compactListingForPlan,
|
|
5
|
+
credentialState,
|
|
6
|
+
credentialsFileMode,
|
|
7
|
+
credentialsFilePath,
|
|
8
|
+
defaultAgentName,
|
|
9
|
+
deriveBountyFromGoal,
|
|
10
|
+
diagnosticStatus,
|
|
11
|
+
fetchOrderAttachments,
|
|
12
|
+
fetchOrderCancellationContext,
|
|
13
|
+
guessMimeType,
|
|
14
|
+
hasUriSchemaField,
|
|
15
|
+
isStrictUrlField,
|
|
16
|
+
isUrlField,
|
|
17
|
+
loadPolicy,
|
|
18
|
+
makePublishIdempotencyKey,
|
|
19
|
+
matchBody,
|
|
20
|
+
numberOption,
|
|
21
|
+
parseDeliveryNote,
|
|
22
|
+
parseFileFlags,
|
|
23
|
+
parseInputFlags,
|
|
24
|
+
parseJsonOption,
|
|
25
|
+
parseRequirement,
|
|
26
|
+
pickCompatibleListing,
|
|
27
|
+
positiveNumberOption,
|
|
28
|
+
readAttachmentOptions,
|
|
29
|
+
request,
|
|
30
|
+
requestJson,
|
|
31
|
+
requestJsonNoAuth,
|
|
32
|
+
requestMultipart,
|
|
33
|
+
resolveApiKey,
|
|
34
|
+
requiredOption,
|
|
35
|
+
stageAndUploadFile,
|
|
36
|
+
stringOptionFromFile,
|
|
37
|
+
summarizeOrderMessages,
|
|
38
|
+
TERMINAL_ORDER_STATES,
|
|
39
|
+
uploadAttachment,
|
|
40
|
+
validateRequirementAgainstSchema,
|
|
41
|
+
writeCredentialsFile,
|
|
42
|
+
} = require("./shared");
|
|
43
|
+
|
|
44
|
+
async function commandMe(_options, deps) {
|
|
45
|
+
return request(deps, "GET", "/agents/me");
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
module.exports = {
|
|
49
|
+
commandMe,
|
|
50
|
+
};
|