@kvell007/embed-labs-cli 0.1.0-alpha.7 → 0.1.0-alpha.9
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/dist/index.js +108 -0
- package/dist/index.js.map +1 -1
- package/dist/local-toolchain.js +7 -2
- package/dist/local-toolchain.js.map +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -98,6 +98,7 @@ const SERVICE_MODES_USAGE = "Usage: embed service modes [--json]";
|
|
|
98
98
|
const AGENT_RUN_USAGE = "Usage: embed agent run --prompt <request> [--account <account_id>] [--workspace <workspace_id>] [--provider stub|openai|bai|cc|claude-code] [--model <model>] [--max-tool-calls 6] [--host <ip>] [--ports 22,15301] [--artifact <local_file>|--artifact-id <artifact_id>|--artifact-task <task_id>] [--artifact-output <path>] [--remote-path <path>] [--run] [--approve] [--json]";
|
|
99
99
|
const TOOL_LIST_USAGE = "Usage: embed tool list [--json]";
|
|
100
100
|
const TOOL_CALL_USAGE = "Usage: embed tool call <capability_id> [--input-json '<json>'] [--approve] [--json]";
|
|
101
|
+
const MCP_TOOL_EVENT_USAGE = "Usage: embed mcp log --tool <tool_name> [--client codex|opencode] [--mode local_ai|server_ai] [--server-model-used true|false] [--success true|false] [--request-id <id>] [--duration-ms <ms>] [--input-summary <text>] [--output-summary <text>] [--json]";
|
|
101
102
|
const BOARD_DEPLOY_TAISHANPI_USAGE = "Usage: embed deploy taishanpi --host <ip> --artifact <local_file> --approve [--user root] [--remote-path /userdata/embed-labs/apps/app] [--run] [--timeout 30] [--json]";
|
|
102
103
|
const CLOUD_TASK_EVENT_APPEND_USAGE = "Usage: embed cloud task event append <task_id> [--state <state>] [--progress-stage <stage>|--stage <stage>] [--progress-text <text>|--message <text>] [--progress-percent 0-100] [--severity info|warning|error] [--type <event_type>] [--artifact-json '<json>'] [--evidence-json '<json>'] [--json]";
|
|
103
104
|
const TASK_STATES = new Set([
|
|
@@ -367,6 +368,16 @@ async function main(argv) {
|
|
|
367
368
|
USAGE_EVENTS_USAGE
|
|
368
369
|
].join("\n")), undefined, 2);
|
|
369
370
|
}
|
|
371
|
+
if (area === "mcp") {
|
|
372
|
+
if (action === "log" || action === "tool-event") {
|
|
373
|
+
const body = mcpToolEventBody(parsed);
|
|
374
|
+
if (typeof body === "string") {
|
|
375
|
+
return output(parsed, fail("invalid_args", body), undefined, 2);
|
|
376
|
+
}
|
|
377
|
+
return output(parsed, await cloudPost("/v1/mcp/tool-events", body), renderMcpToolEvent);
|
|
378
|
+
}
|
|
379
|
+
return output(parsed, fail("invalid_args", MCP_TOOL_EVENT_USAGE), undefined, 2);
|
|
380
|
+
}
|
|
370
381
|
if (area === "billing") {
|
|
371
382
|
if (action === "statement") {
|
|
372
383
|
const request = billingStatementRequest(parsed);
|
|
@@ -3716,6 +3727,73 @@ function usageRecordBody(parsed) {
|
|
|
3716
3727
|
created_at: createdAtResult.value
|
|
3717
3728
|
});
|
|
3718
3729
|
}
|
|
3730
|
+
function mcpToolEventBody(parsed) {
|
|
3731
|
+
const unknownFlag = firstUnknownFlag(parsed, [
|
|
3732
|
+
"json",
|
|
3733
|
+
"account",
|
|
3734
|
+
"account-id",
|
|
3735
|
+
"tool",
|
|
3736
|
+
"client",
|
|
3737
|
+
"mode",
|
|
3738
|
+
"server-model-used",
|
|
3739
|
+
"success",
|
|
3740
|
+
"request-id",
|
|
3741
|
+
"duration-ms",
|
|
3742
|
+
"input-summary",
|
|
3743
|
+
"output-summary"
|
|
3744
|
+
]);
|
|
3745
|
+
if (unknownFlag) {
|
|
3746
|
+
return `Unknown flag --${unknownFlag}. ${MCP_TOOL_EVENT_USAGE}`;
|
|
3747
|
+
}
|
|
3748
|
+
const extra = parsed.command.slice(2);
|
|
3749
|
+
if (extra.length > 0) {
|
|
3750
|
+
return `Unexpected argument: ${extra[0]}. ${MCP_TOOL_EVENT_USAGE}`;
|
|
3751
|
+
}
|
|
3752
|
+
const toolResult = optionalTrimmedStringFlag(parsed, "tool");
|
|
3753
|
+
if (toolResult.error)
|
|
3754
|
+
return toolResult.error;
|
|
3755
|
+
if (!toolResult.value)
|
|
3756
|
+
return MCP_TOOL_EVENT_USAGE;
|
|
3757
|
+
const accountResult = optionalTrimmedStringAliasFlag(parsed, ["account", "account-id"], "account or account-id");
|
|
3758
|
+
if (accountResult.error)
|
|
3759
|
+
return accountResult.error;
|
|
3760
|
+
const clientResult = optionalTrimmedStringFlag(parsed, "client");
|
|
3761
|
+
if (clientResult.error)
|
|
3762
|
+
return clientResult.error;
|
|
3763
|
+
const modeResult = optionalTrimmedStringFlag(parsed, "mode");
|
|
3764
|
+
if (modeResult.error)
|
|
3765
|
+
return modeResult.error;
|
|
3766
|
+
const requestIdResult = optionalTrimmedStringFlag(parsed, "request-id");
|
|
3767
|
+
if (requestIdResult.error)
|
|
3768
|
+
return requestIdResult.error;
|
|
3769
|
+
const inputSummaryResult = optionalTrimmedStringFlag(parsed, "input-summary");
|
|
3770
|
+
if (inputSummaryResult.error)
|
|
3771
|
+
return inputSummaryResult.error;
|
|
3772
|
+
const outputSummaryResult = optionalTrimmedStringFlag(parsed, "output-summary");
|
|
3773
|
+
if (outputSummaryResult.error)
|
|
3774
|
+
return outputSummaryResult.error;
|
|
3775
|
+
const durationResult = optionalNonNegativeIntegerFlag(parsed, "duration-ms");
|
|
3776
|
+
if (durationResult.error)
|
|
3777
|
+
return durationResult.error;
|
|
3778
|
+
const serverModelUsed = optionalBooleanFlag(parsed, "server-model-used");
|
|
3779
|
+
if (typeof serverModelUsed === "string")
|
|
3780
|
+
return serverModelUsed;
|
|
3781
|
+
const success = optionalBooleanFlag(parsed, "success");
|
|
3782
|
+
if (typeof success === "string")
|
|
3783
|
+
return success;
|
|
3784
|
+
return compactBody({
|
|
3785
|
+
account_id: accountResult.value,
|
|
3786
|
+
tool_name: toolResult.value,
|
|
3787
|
+
client: clientResult.value,
|
|
3788
|
+
mode: modeResult.value,
|
|
3789
|
+
server_model_used: serverModelUsed,
|
|
3790
|
+
success,
|
|
3791
|
+
request_id: requestIdResult.value,
|
|
3792
|
+
duration_ms: durationResult.value,
|
|
3793
|
+
input_summary: inputSummaryResult.value,
|
|
3794
|
+
output_summary: outputSummaryResult.value
|
|
3795
|
+
});
|
|
3796
|
+
}
|
|
3719
3797
|
function usageSummaryRequest(parsed) {
|
|
3720
3798
|
const unknownFlag = firstUnknownFlag(parsed, ["json", "account", "account-id", "api-key-id", "from", "to"]);
|
|
3721
3799
|
if (unknownFlag) {
|
|
@@ -4737,6 +4815,20 @@ function renderUsageRecord(record) {
|
|
|
4737
4815
|
`created_at=${record.created_at}`
|
|
4738
4816
|
].filter(Boolean).join(" ");
|
|
4739
4817
|
}
|
|
4818
|
+
function renderMcpToolEvent(event) {
|
|
4819
|
+
return [
|
|
4820
|
+
`${event.event_id} tool=${event.tool_name}`,
|
|
4821
|
+
event.account_id ? `account=${event.account_id}` : "",
|
|
4822
|
+
event.api_key_id ? `api_key=${event.api_key_id}` : "",
|
|
4823
|
+
`client=${event.client}`,
|
|
4824
|
+
`mode=${event.mode}`,
|
|
4825
|
+
`server_model_used=${event.server_model_used}`,
|
|
4826
|
+
`success=${event.success}`,
|
|
4827
|
+
event.request_id ? `request=${event.request_id}` : "",
|
|
4828
|
+
event.duration_ms !== undefined ? `duration_ms=${event.duration_ms}` : "",
|
|
4829
|
+
`created_at=${event.created_at}`
|
|
4830
|
+
].filter(Boolean).join(" ");
|
|
4831
|
+
}
|
|
4740
4832
|
function renderUsageSummary(summary) {
|
|
4741
4833
|
const lines = [
|
|
4742
4834
|
summary.account_id ? `account=${summary.account_id}` : "",
|
|
@@ -5785,6 +5877,22 @@ function stringFlag(parsed, name) {
|
|
|
5785
5877
|
function booleanFlag(parsed, name) {
|
|
5786
5878
|
return parsed.flags[name] === true;
|
|
5787
5879
|
}
|
|
5880
|
+
function optionalBooleanFlag(parsed, name) {
|
|
5881
|
+
const values = flagValues(parsed, name);
|
|
5882
|
+
if (values.length === 0)
|
|
5883
|
+
return undefined;
|
|
5884
|
+
const value = values[values.length - 1];
|
|
5885
|
+
if (value === true)
|
|
5886
|
+
return true;
|
|
5887
|
+
if (typeof value !== "string")
|
|
5888
|
+
return `--${name} must be true or false.`;
|
|
5889
|
+
const normalized = value.trim().toLowerCase();
|
|
5890
|
+
if (["1", "true", "yes", "y", "on"].includes(normalized))
|
|
5891
|
+
return true;
|
|
5892
|
+
if (["0", "false", "no", "n", "off"].includes(normalized))
|
|
5893
|
+
return false;
|
|
5894
|
+
return `--${name} must be true or false.`;
|
|
5895
|
+
}
|
|
5788
5896
|
function switchFlag(parsed, name) {
|
|
5789
5897
|
const values = flagValues(parsed, name);
|
|
5790
5898
|
for (const value of values) {
|