@insmind/cli 1.3.0
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/LICENSE +21 -0
- package/README.md +11 -0
- package/contracts/operations/agent.send/input.schema.json +335 -0
- package/contracts/operations/agent.send/output.schema.json +248 -0
- package/contracts/operations/auth.status/input.schema.json +7 -0
- package/contracts/operations/auth.status/output.schema.json +119 -0
- package/contracts/operations/dam.copy/input.schema.json +42 -0
- package/contracts/operations/dam.copy/output.schema.json +43 -0
- package/contracts/operations/dam.delete/input.schema.json +24 -0
- package/contracts/operations/dam.delete/output.schema.json +5 -0
- package/contracts/operations/dam.download/input.schema.json +28 -0
- package/contracts/operations/dam.download/output.schema.json +51 -0
- package/contracts/operations/dam.folder.list/input.schema.json +36 -0
- package/contracts/operations/dam.folder.list/output.schema.json +104 -0
- package/contracts/operations/dam.get/input.schema.json +16 -0
- package/contracts/operations/dam.get/output.schema.json +107 -0
- package/contracts/operations/dam.list/input.schema.json +73 -0
- package/contracts/operations/dam.list/output.schema.json +145 -0
- package/contracts/operations/dam.move/input.schema.json +42 -0
- package/contracts/operations/dam.move/output.schema.json +40 -0
- package/contracts/operations/dam.rename/input.schema.json +42 -0
- package/contracts/operations/dam.rename/output.schema.json +43 -0
- package/contracts/operations/dam.repository.list/input.schema.json +7 -0
- package/contracts/operations/dam.repository.list/output.schema.json +65 -0
- package/contracts/operations/dam.search/input.schema.json +79 -0
- package/contracts/operations/dam.search/output.schema.json +145 -0
- package/contracts/operations/dam.tag.list/input.schema.json +21 -0
- package/contracts/operations/dam.tag.list/output.schema.json +52 -0
- package/contracts/operations/dam.upload/input.schema.json +43 -0
- package/contracts/operations/dam.upload/output.schema.json +107 -0
- package/contracts/operations/editor.apply/input.schema.json +177 -0
- package/contracts/operations/editor.apply/output.schema.json +15 -0
- package/contracts/operations/editor.connect/input.schema.json +13 -0
- package/contracts/operations/editor.connect/output.schema.json +17 -0
- package/contracts/operations/editor.disconnect/input.schema.json +7 -0
- package/contracts/operations/editor.disconnect/output.schema.json +14 -0
- package/contracts/operations/editor.save/input.schema.json +7 -0
- package/contracts/operations/editor.save/output.schema.json +23 -0
- package/contracts/operations/editor.screenshot/input.schema.json +7 -0
- package/contracts/operations/editor.screenshot/output.schema.json +16 -0
- package/contracts/operations/editor.snapshot/input.schema.json +7 -0
- package/contracts/operations/editor.snapshot/output.schema.json +148 -0
- package/contracts/operations/model.get/input.schema.json +16 -0
- package/contracts/operations/model.get/output.schema.json +167 -0
- package/contracts/operations/model.list/input.schema.json +13 -0
- package/contracts/operations/model.list/output.schema.json +97 -0
- package/contracts/operations/task.get/input.schema.json +14 -0
- package/contracts/operations/task.get/output.schema.json +103 -0
- package/contracts/operations/task.list/input.schema.json +18 -0
- package/contracts/operations/task.list/output.schema.json +53 -0
- package/contracts/operations/tool.call/input.schema.json +31 -0
- package/contracts/operations/tool.call/output.schema.json +115 -0
- package/contracts/operations/tool.list/input.schema.json +6 -0
- package/contracts/operations/tool.list/output.schema.json +40 -0
- package/dist/bin/agent-worker.js +41 -0
- package/dist/bin/insmind-cli.js +60 -0
- package/dist/bin/postinstall.js +69 -0
- package/dist/src/bootstrap/create-cli.js +124 -0
- package/dist/src/bootstrap/create-runtime.js +451 -0
- package/dist/src/bootstrap/run-agent-worker.js +37 -0
- package/dist/src/bootstrap/validators.js +169 -0
- package/dist/src/cli/action-binding.js +109 -0
- package/dist/src/cli/agent-commands.js +75 -0
- package/dist/src/cli/auth-commands.js +58 -0
- package/dist/src/cli/credits-command.js +23 -0
- package/dist/src/cli/dam-commands.js +470 -0
- package/dist/src/cli/editor-commands.js +74 -0
- package/dist/src/cli/errors.js +208 -0
- package/dist/src/cli/model-commands.js +62 -0
- package/dist/src/cli/org-commands.js +58 -0
- package/dist/src/cli/presenter.js +123 -0
- package/dist/src/cli/prompt.js +30 -0
- package/dist/src/cli/task-commands.js +48 -0
- package/dist/src/cli/tool-commands.js +101 -0
- package/dist/src/cli/update-command.js +15 -0
- package/dist/src/contracts/schema.js +4 -0
- package/dist/src/features/agent/creative-agent-adapter.js +42 -0
- package/dist/src/features/agent/creative-protocol.js +421 -0
- package/dist/src/features/agent/creative-stream.js +138 -0
- package/dist/src/features/agent/filems-resource-auth-key-provider.js +23 -0
- package/dist/src/features/agent/resource-authorizer.js +47 -0
- package/dist/src/features/agent/result-reader.js +30 -0
- package/dist/src/features/agent/use-cases.js +153 -0
- package/dist/src/features/auth/access-policy.js +101 -0
- package/dist/src/features/auth/credential-store.js +62 -0
- package/dist/src/features/auth/sso-service.js +196 -0
- package/dist/src/features/auth/state.js +129 -0
- package/dist/src/features/auth/use-cases.js +162 -0
- package/dist/src/features/credits/use-cases.js +52 -0
- package/dist/src/features/dam/asset-projection.js +278 -0
- package/dist/src/features/dam/dam-api-adapter.js +562 -0
- package/dist/src/features/dam/file-downloader.js +242 -0
- package/dist/src/features/dam/object-storage.js +193 -0
- package/dist/src/features/dam/operation-executor.js +72 -0
- package/dist/src/features/dam/registered-uploader.js +247 -0
- package/dist/src/features/dam/repository-catalog.js +127 -0
- package/dist/src/features/dam/storage-upload.js +141 -0
- package/dist/src/features/dam/transient-uploader.js +17 -0
- package/dist/src/features/dam/use-cases.js +470 -0
- package/dist/src/features/editor/bridge-client.js +109 -0
- package/dist/src/features/editor/bridge-process.js +229 -0
- package/dist/src/features/editor/bridge-server.js +337 -0
- package/dist/src/features/editor/protocol.js +1 -0
- package/dist/src/features/editor/public-url.js +36 -0
- package/dist/src/features/editor/session-state.js +78 -0
- package/dist/src/features/editor/session.js +213 -0
- package/dist/src/features/editor/use-cases.js +88 -0
- package/dist/src/features/org/org-service.js +76 -0
- package/dist/src/features/org/use-cases.js +163 -0
- package/dist/src/features/skill/bundled-skills.js +63 -0
- package/dist/src/features/skill/installer.js +271 -0
- package/dist/src/features/task/agent-background.js +63 -0
- package/dist/src/features/task/store.js +97 -0
- package/dist/src/features/task/types.js +1 -0
- package/dist/src/features/task/use-cases.js +139 -0
- package/dist/src/features/tool/catalog.js +83 -0
- package/dist/src/features/tool/dynamic-schema.js +128 -0
- package/dist/src/features/tool/mns-catalog-adapter.js +265 -0
- package/dist/src/features/tool/tool-api-adapter.js +369 -0
- package/dist/src/features/tool/use-cases.js +180 -0
- package/dist/src/features/update/latest-version.js +37 -0
- package/dist/src/features/update/update-notification.js +271 -0
- package/dist/src/features/update/update-service.js +226 -0
- package/dist/src/platform/installation-owner.js +81 -0
- package/dist/src/platform/json-input.js +67 -0
- package/dist/src/platform/local-json-file.js +59 -0
- package/dist/src/platform/open-browser.js +8 -0
- package/dist/src/platform/redact.js +80 -0
- package/dist/src/platform/remote-error-evidence.js +80 -0
- package/dist/src/platform/remote-protocol.js +10 -0
- package/dist/src/platform/resource-auth-key.js +1 -0
- package/dist/src/platform/safe-upload-file.js +146 -0
- package/dist/src/platform/signature.js +20 -0
- package/dist/src/platform/signed-http-transport.js +144 -0
- package/dist/src/platform/task-observer.js +1 -0
- package/dist/src/platform/url-safety.js +100 -0
- package/dist/src/product/billing.js +47 -0
- package/dist/src/product/config.js +85 -0
- package/dist/src/product/locale.js +38 -0
- package/dist/src/product/text.js +3 -0
- package/dist/src/telemetry/invocation.js +156 -0
- package/dist/src/telemetry/sls-sink.js +30 -0
- package/package.json +53 -0
- package/skills/insmind-cli/SKILL.md +15 -0
- package/skills/insmind-cli/references/agent.md +34 -0
- package/skills/insmind-cli/references/auth.md +8 -0
- package/skills/insmind-cli/references/creation.md +40 -0
- package/skills/insmind-cli/references/dam.md +51 -0
- package/skills/insmind-cli/references/editor.md +184 -0
- package/skills/insmind-cli/references/errors.md +29 -0
- package/skills/insmind-cli/references/generation-constraints.md +36 -0
- package/skills/insmind-cli/references/tool.md +31 -0
- package/skills/insmind-cli/references/update.md +11 -0
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
export function withAgentBillingUnit(source, unit) {
|
|
2
|
+
if (unit === "gaodou")
|
|
3
|
+
return source;
|
|
4
|
+
return {
|
|
5
|
+
async send(input) {
|
|
6
|
+
return agentOutputWithBillingUnit(await source.send(input), unit);
|
|
7
|
+
}
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
export function withToolBillingUnit(source, unit) {
|
|
11
|
+
if (unit === "gaodou")
|
|
12
|
+
return source;
|
|
13
|
+
const model = (value) => (value.cost ? { ...value, cost: { ...value.cost, unit } } : value);
|
|
14
|
+
return {
|
|
15
|
+
listTools: (input) => source.listTools(input),
|
|
16
|
+
async listModels(input) {
|
|
17
|
+
const output = await source.listModels(input);
|
|
18
|
+
return { ...output, models: output.models.map(model) };
|
|
19
|
+
},
|
|
20
|
+
async getModel(input) {
|
|
21
|
+
return model(await source.getModel(input));
|
|
22
|
+
},
|
|
23
|
+
getArgumentsSchema: (input) => source.getArgumentsSchema(input),
|
|
24
|
+
submit: (input) => source.submit(input),
|
|
25
|
+
async call(input) {
|
|
26
|
+
return toolOutputWithBillingUnit(await source.call(input), unit);
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
export function agentOutputWithBillingUnit(output, unit) {
|
|
31
|
+
return {
|
|
32
|
+
...output,
|
|
33
|
+
usage: {
|
|
34
|
+
...output.usage,
|
|
35
|
+
cost: { ...output.usage.cost, unit },
|
|
36
|
+
items: output.usage.items.map(item => ({ ...item, cost: { ...item.cost, unit } }))
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
export function toolOutputWithBillingUnit(output, unit) {
|
|
41
|
+
return {
|
|
42
|
+
...output,
|
|
43
|
+
usage: output.usage.cost
|
|
44
|
+
? { ...output.usage, cost: { ...output.usage.cost, unit } }
|
|
45
|
+
: output.usage
|
|
46
|
+
};
|
|
47
|
+
}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { defaultToolDefinitions } from "../features/tool/catalog.js";
|
|
2
|
+
function freezeProduct(config) {
|
|
3
|
+
Object.freeze(config.endpoints);
|
|
4
|
+
for (const tool of config.tools)
|
|
5
|
+
Object.freeze(tool);
|
|
6
|
+
Object.freeze(config.tools);
|
|
7
|
+
return Object.freeze(config);
|
|
8
|
+
}
|
|
9
|
+
const gaodingApi = new URL("https://gdcli.gaoding.com/api");
|
|
10
|
+
export const gaodingProduct = freezeProduct({
|
|
11
|
+
id: "gaoding",
|
|
12
|
+
displayName: "GaoDing",
|
|
13
|
+
commandName: "gd-cli",
|
|
14
|
+
description: "稿定命令行工具",
|
|
15
|
+
npmPackage: "@gaoding/cli",
|
|
16
|
+
skillName: "gd-cli",
|
|
17
|
+
stateDirectory: ".gd",
|
|
18
|
+
billingUnit: "gaodou",
|
|
19
|
+
deviceClientId: "gdhub-cli",
|
|
20
|
+
pricingUrl: new URL("https://www.gaoding.art/pricing"),
|
|
21
|
+
telemetryUrl: new URL("https://gaoding-log-ai-gpu.cn-hangzhou.log.aliyuncs.com/logstores/gd-cli/track?APIVersion=0.6.0"),
|
|
22
|
+
defaultEditorCreateUrl: new URL("https://www.gaoding.art/editor/canvas?mode=create&type=board"),
|
|
23
|
+
editorWorkUrl: new URL("https://www.gaoding.art/editor/canvas"),
|
|
24
|
+
restrictEditorTargets: false,
|
|
25
|
+
endpoints: {
|
|
26
|
+
orgApi: gaodingApi,
|
|
27
|
+
creditsApi: gaodingApi,
|
|
28
|
+
agentApi: gaodingApi,
|
|
29
|
+
mnsApi: gaodingApi,
|
|
30
|
+
toolApi: gaodingApi,
|
|
31
|
+
damApi: gaodingApi,
|
|
32
|
+
filemsApi: gaodingApi,
|
|
33
|
+
ssoApi: new URL("https://www.gaoding.com/api/sso"),
|
|
34
|
+
authPageOrigin: new URL("https://www.gaoding.art")
|
|
35
|
+
},
|
|
36
|
+
exposesOrganizations: true,
|
|
37
|
+
tools: defaultToolDefinitions
|
|
38
|
+
});
|
|
39
|
+
const insmindApi = new URL("https://gdcli.insmind.com/api");
|
|
40
|
+
export const insmindProduct = freezeProduct({
|
|
41
|
+
id: "insmind",
|
|
42
|
+
displayName: "insMind",
|
|
43
|
+
commandName: "insmind-cli",
|
|
44
|
+
description: "insMind command-line interface",
|
|
45
|
+
npmPackage: "@insmind/cli",
|
|
46
|
+
skillName: "insmind-cli",
|
|
47
|
+
stateDirectory: ".insmind",
|
|
48
|
+
billingUnit: "credit",
|
|
49
|
+
deviceClientId: "gdhub-cli",
|
|
50
|
+
pricingUrl: new URL("https://www.insmind.com/pricing"),
|
|
51
|
+
telemetryUrl: new URL("https://gaoding-log-ai-gpu-use.us-east-1.log.aliyuncs.com/logstores/gd-cli/track?APIVersion=0.6.0"),
|
|
52
|
+
defaultEditorCreateUrl: new URL("https://www.insmind.com/editor/canvas?mode=create&type=board"),
|
|
53
|
+
editorWorkUrl: new URL("https://www.insmind.com/editor/canvas"),
|
|
54
|
+
restrictEditorTargets: true,
|
|
55
|
+
endpoints: {
|
|
56
|
+
orgApi: insmindApi,
|
|
57
|
+
creditsApi: insmindApi,
|
|
58
|
+
agentApi: insmindApi,
|
|
59
|
+
mnsApi: insmindApi,
|
|
60
|
+
toolApi: insmindApi,
|
|
61
|
+
damApi: insmindApi,
|
|
62
|
+
filemsApi: insmindApi,
|
|
63
|
+
ssoApi: new URL("https://www.insmind.com/api/sso"),
|
|
64
|
+
authPageOrigin: new URL("https://www.insmind.com")
|
|
65
|
+
},
|
|
66
|
+
exposesOrganizations: false,
|
|
67
|
+
localeEnvironmentVariable: "INSMIND_CLI_LOCALE",
|
|
68
|
+
tools: [
|
|
69
|
+
{
|
|
70
|
+
name: "image.generate",
|
|
71
|
+
title: "Image generation and editing",
|
|
72
|
+
description: "Generate or edit images with published image models using text and optional reference images."
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
name: "video.generate",
|
|
76
|
+
title: "Video generation",
|
|
77
|
+
description: "Generate videos with published video models using text and optional images, video, or audio."
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
name: "text.generate",
|
|
81
|
+
title: "Text generation",
|
|
82
|
+
description: "Generate text with published text models using text and optional images."
|
|
83
|
+
}
|
|
84
|
+
]
|
|
85
|
+
});
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
const SUPPORTED_LOCALES = [
|
|
2
|
+
"de-DE", "en-US", "es-ES", "fr-FR", "id-ID", "it-IT", "ja-JP", "ko-KR",
|
|
3
|
+
"nl-NL", "pl-PL", "pt-BR", "ru-RU", "th-TH", "tr-TR", "vi-VN", "zh-CN", "zh-TW"
|
|
4
|
+
];
|
|
5
|
+
export function localeOption(argv) {
|
|
6
|
+
const index = argv.indexOf("--locale");
|
|
7
|
+
if (index >= 0)
|
|
8
|
+
return argv[index + 1];
|
|
9
|
+
return argv.find((value) => value.startsWith("--locale="))?.slice("--locale=".length);
|
|
10
|
+
}
|
|
11
|
+
export function resolveProductLocale(options) {
|
|
12
|
+
const requested = options.explicit ?? options.environment ?? options.system ?? "en-US";
|
|
13
|
+
let canonical;
|
|
14
|
+
try {
|
|
15
|
+
canonical = Intl.getCanonicalLocales(requested.replace(/_/gu, "-"))[0] ?? "en-US";
|
|
16
|
+
}
|
|
17
|
+
catch {
|
|
18
|
+
canonical = "en-US";
|
|
19
|
+
}
|
|
20
|
+
const exact = SUPPORTED_LOCALES.find((value) => value.toLowerCase() === canonical.toLowerCase());
|
|
21
|
+
const language = canonical.split("-")[0]?.toLowerCase() ?? "en";
|
|
22
|
+
const matched = exact ?? SUPPORTED_LOCALES.find((value) => value.toLowerCase().startsWith(`${language}-`)) ?? "en-US";
|
|
23
|
+
const [normalizedLanguage, region = "US"] = matched.split("-");
|
|
24
|
+
return {
|
|
25
|
+
locale: matched,
|
|
26
|
+
language: normalizedLanguage,
|
|
27
|
+
market: region,
|
|
28
|
+
legalRegion: region
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
export function systemLocale() {
|
|
32
|
+
try {
|
|
33
|
+
return Intl.DateTimeFormat().resolvedOptions().locale;
|
|
34
|
+
}
|
|
35
|
+
catch {
|
|
36
|
+
return undefined;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
const detailedStages = {
|
|
2
|
+
"auth.login": new Set(["authorize", "wait", "identity", "bind"]),
|
|
3
|
+
"org.switch": new Set(["list", "bind"]),
|
|
4
|
+
"agent.send:execute": new Set(["catalog", "upload", "execute", "result"]),
|
|
5
|
+
"tool.call:execute": new Set(["catalog", "upload", "intent", "submit", "wait"]),
|
|
6
|
+
"dam.upload": new Set(["inspect", "repository", "prepare", "upload", "persist", "wait"]),
|
|
7
|
+
update: new Set(["registry", "install", "sync", "verify"])
|
|
8
|
+
};
|
|
9
|
+
export function createTelemetryInvocation(options) {
|
|
10
|
+
const traceId = options.traceIdFactory();
|
|
11
|
+
const startedAt = options.now();
|
|
12
|
+
let definition;
|
|
13
|
+
const context = {};
|
|
14
|
+
const stages = [];
|
|
15
|
+
return {
|
|
16
|
+
traceId,
|
|
17
|
+
get selected() {
|
|
18
|
+
return definition !== undefined;
|
|
19
|
+
},
|
|
20
|
+
traceparent() {
|
|
21
|
+
return `00-${traceId}-${options.spanIdFactory()}-${traceFlags(definition)}`;
|
|
22
|
+
},
|
|
23
|
+
select(nextDefinition) {
|
|
24
|
+
definition = nextDefinition;
|
|
25
|
+
},
|
|
26
|
+
annotate(annotation) {
|
|
27
|
+
if (annotation.account_id !== undefined)
|
|
28
|
+
context.account_id = annotation.account_id;
|
|
29
|
+
if (annotation.organization_id !== undefined) {
|
|
30
|
+
context.organization_id = annotation.organization_id;
|
|
31
|
+
}
|
|
32
|
+
if (annotation.tool_name !== undefined)
|
|
33
|
+
context.tool_name = annotation.tool_name;
|
|
34
|
+
if (annotation.model_id !== undefined)
|
|
35
|
+
context.model_id = annotation.model_id;
|
|
36
|
+
if (annotation.content_id !== undefined)
|
|
37
|
+
context.content_id = annotation.content_id;
|
|
38
|
+
if (annotation.task_id !== undefined)
|
|
39
|
+
context.task_id = annotation.task_id;
|
|
40
|
+
if (annotation.dify_task_id !== undefined) {
|
|
41
|
+
context.dify_task_id = annotation.dify_task_id;
|
|
42
|
+
}
|
|
43
|
+
if (annotation.parameters !== undefined) {
|
|
44
|
+
context.parameters = { ...annotation.parameters };
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
async stage(name, run) {
|
|
48
|
+
const stageStartedAt = options.now();
|
|
49
|
+
try {
|
|
50
|
+
const result = await run();
|
|
51
|
+
stages.push({
|
|
52
|
+
name,
|
|
53
|
+
durationMs: elapsed(options.now(), stageStartedAt),
|
|
54
|
+
outcome: "success"
|
|
55
|
+
});
|
|
56
|
+
return result;
|
|
57
|
+
}
|
|
58
|
+
catch (error) {
|
|
59
|
+
const classification = options.classifyError(error);
|
|
60
|
+
stages.push({
|
|
61
|
+
name,
|
|
62
|
+
durationMs: elapsed(options.now(), stageStartedAt),
|
|
63
|
+
outcome: classification.outcome,
|
|
64
|
+
error,
|
|
65
|
+
...(classification.errorCode === undefined
|
|
66
|
+
? {}
|
|
67
|
+
: { errorCode: classification.errorCode }),
|
|
68
|
+
...(classification.httpStatus === undefined
|
|
69
|
+
? {}
|
|
70
|
+
: { httpStatus: classification.httpStatus })
|
|
71
|
+
});
|
|
72
|
+
throw error;
|
|
73
|
+
}
|
|
74
|
+
},
|
|
75
|
+
finish(completion) {
|
|
76
|
+
if (!definition)
|
|
77
|
+
return [];
|
|
78
|
+
const selectedDefinition = definition;
|
|
79
|
+
const mode = selectedDefinition.mode?.();
|
|
80
|
+
const allowedStages = detailedStages[stageKey(selectedDefinition.operation, mode)];
|
|
81
|
+
const stageEvents = allowedStages
|
|
82
|
+
? stages
|
|
83
|
+
.filter((stage) => allowedStages.has(stage.name))
|
|
84
|
+
.map((stage) => ({
|
|
85
|
+
schema_version: "2",
|
|
86
|
+
event_name: "stage_finished",
|
|
87
|
+
trace_id: traceId,
|
|
88
|
+
operation: selectedDefinition.operation,
|
|
89
|
+
stage: stage.name,
|
|
90
|
+
outcome: stage.outcome,
|
|
91
|
+
duration_ms: stage.durationMs,
|
|
92
|
+
...(stage.errorCode === undefined ? {} : { error_code: stage.errorCode }),
|
|
93
|
+
...(stage.httpStatus === undefined ? {} : { http_status: stage.httpStatus })
|
|
94
|
+
}))
|
|
95
|
+
: [];
|
|
96
|
+
const command = {
|
|
97
|
+
schema_version: "2",
|
|
98
|
+
event_name: "command_finished",
|
|
99
|
+
trace_id: traceId,
|
|
100
|
+
operation: selectedDefinition.operation,
|
|
101
|
+
...(mode === undefined ? {} : { mode }),
|
|
102
|
+
outcome: completion.outcome,
|
|
103
|
+
duration_ms: elapsed(options.now(), startedAt),
|
|
104
|
+
cli_version: options.cliVersion,
|
|
105
|
+
os: options.runtime.os,
|
|
106
|
+
arch: options.runtime.arch,
|
|
107
|
+
node_major: options.runtime.nodeMajor,
|
|
108
|
+
...(context.account_id === undefined ? {} : { account_id: context.account_id }),
|
|
109
|
+
...(context.organization_id === undefined
|
|
110
|
+
? {}
|
|
111
|
+
: { organization_id: context.organization_id }),
|
|
112
|
+
...(context.tool_name === undefined ? {} : { tool_name: context.tool_name }),
|
|
113
|
+
...(context.model_id === undefined ? {} : { model_id: context.model_id }),
|
|
114
|
+
...(context.content_id === undefined ? {} : { content_id: context.content_id }),
|
|
115
|
+
...(context.task_id === undefined ? {} : { task_id: context.task_id }),
|
|
116
|
+
...(context.dify_task_id === undefined
|
|
117
|
+
? {}
|
|
118
|
+
: { dify_task_id: context.dify_task_id }),
|
|
119
|
+
...(context.parameters === undefined
|
|
120
|
+
? {}
|
|
121
|
+
: { parameters: { ...context.parameters } }),
|
|
122
|
+
...(completion.outcome === "failure"
|
|
123
|
+
? {
|
|
124
|
+
error_code: completion.errorCode,
|
|
125
|
+
error_message: completion.errorMessage,
|
|
126
|
+
failure_stage: stages.find((stage) => stage.error === completion.error)?.name
|
|
127
|
+
?? "unknown",
|
|
128
|
+
...(completion.httpStatus === undefined
|
|
129
|
+
? {}
|
|
130
|
+
: { http_status: completion.httpStatus }),
|
|
131
|
+
...(completion.remoteErrorCode === undefined
|
|
132
|
+
? {}
|
|
133
|
+
: { remote_error_code: completion.remoteErrorCode }),
|
|
134
|
+
...(completion.remoteErrorBody === undefined
|
|
135
|
+
? {}
|
|
136
|
+
: { remote_error_body: completion.remoteErrorBody })
|
|
137
|
+
}
|
|
138
|
+
: {})
|
|
139
|
+
};
|
|
140
|
+
return [...stageEvents, command];
|
|
141
|
+
}
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
function traceFlags(definition) {
|
|
145
|
+
if (definition === undefined)
|
|
146
|
+
return "00";
|
|
147
|
+
const paidExecution = (definition.operation === "agent.send"
|
|
148
|
+
|| definition.operation === "tool.call") && definition.mode?.() === "execute";
|
|
149
|
+
return paidExecution ? "01" : "00";
|
|
150
|
+
}
|
|
151
|
+
function stageKey(operation, mode) {
|
|
152
|
+
return mode === undefined ? operation : `${operation}:${mode}`;
|
|
153
|
+
}
|
|
154
|
+
function elapsed(now, startedAt) {
|
|
155
|
+
return Math.max(0, now - startedAt);
|
|
156
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
const TIMEOUT_MS = 2_000;
|
|
2
|
+
export function createSlsTelemetrySink(options) {
|
|
3
|
+
return {
|
|
4
|
+
async send(events) {
|
|
5
|
+
if (events.length === 0)
|
|
6
|
+
return;
|
|
7
|
+
try {
|
|
8
|
+
await options.fetch(options.trackingUrl, {
|
|
9
|
+
method: "POST",
|
|
10
|
+
headers: { "Content-Type": "application/json" },
|
|
11
|
+
body: JSON.stringify({ __logs__: events.map(wireEvent) }),
|
|
12
|
+
redirect: "error",
|
|
13
|
+
signal: AbortSignal.timeout(TIMEOUT_MS)
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
catch {
|
|
17
|
+
// Telemetry must never change command behavior.
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
function wireEvent(event) {
|
|
23
|
+
const wire = {};
|
|
24
|
+
for (const [key, value] of Object.entries(event)) {
|
|
25
|
+
if (value === undefined)
|
|
26
|
+
continue;
|
|
27
|
+
wire[key] = key === "parameters" ? JSON.stringify(value) : String(value);
|
|
28
|
+
}
|
|
29
|
+
return wire;
|
|
30
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@insmind/cli",
|
|
3
|
+
"version": "1.3.0",
|
|
4
|
+
"description": "insMind command-line interface for agents and people.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"publishConfig": {
|
|
8
|
+
"access": "public",
|
|
9
|
+
"registry": "https://registry.npmjs.org/",
|
|
10
|
+
"tag": "latest"
|
|
11
|
+
},
|
|
12
|
+
"engines": {
|
|
13
|
+
"node": ">=20.0.0"
|
|
14
|
+
},
|
|
15
|
+
"bin": {
|
|
16
|
+
"insmind-cli": "dist/bin/insmind-cli.js"
|
|
17
|
+
},
|
|
18
|
+
"files": [
|
|
19
|
+
"contracts",
|
|
20
|
+
"dist",
|
|
21
|
+
"skills",
|
|
22
|
+
"README.md",
|
|
23
|
+
"LICENSE"
|
|
24
|
+
],
|
|
25
|
+
"scripts": {
|
|
26
|
+
"clean": "node -e \"for (const p of ['contracts', 'dist']) require('node:fs').rmSync(p, { recursive: true, force: true })\"",
|
|
27
|
+
"build": "pnpm --filter @gaoding/cli build && pnpm clean && node scripts/assemble-package.mjs",
|
|
28
|
+
"test": "pnpm build && node --test tests/*.test.mjs",
|
|
29
|
+
"typecheck": "pnpm --filter @gaoding/cli typecheck",
|
|
30
|
+
"check": "pnpm test && pnpm typecheck",
|
|
31
|
+
"prepack": "pnpm check",
|
|
32
|
+
"postinstall": "node -e \"const p='./dist/bin/postinstall.js'; if (require('node:fs').existsSync(p)) import(p)\""
|
|
33
|
+
},
|
|
34
|
+
"dependencies": {
|
|
35
|
+
"ajv": "8.20.0",
|
|
36
|
+
"ajv-formats": "3.0.1",
|
|
37
|
+
"ali-oss": "6.23.0",
|
|
38
|
+
"commander": "14.0.3",
|
|
39
|
+
"open": "11.0.0",
|
|
40
|
+
"qrcode": "1.5.4",
|
|
41
|
+
"semver": "7.8.5",
|
|
42
|
+
"sharp": "0.35.4",
|
|
43
|
+
"ws": "8.21.1"
|
|
44
|
+
},
|
|
45
|
+
"devDependencies": {
|
|
46
|
+
"@gaoding/cli": "workspace:*"
|
|
47
|
+
},
|
|
48
|
+
"gaodingRelease": {
|
|
49
|
+
"sourceCommit": "fd3b79fa383db10da13e3afd029f43524d5c8d2e",
|
|
50
|
+
"pipelineId": "181902",
|
|
51
|
+
"pipelineUrl": "https://git.intra.gaoding.com/gtt/gaoding-cli/-/pipelines/181902"
|
|
52
|
+
}
|
|
53
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: insmind-cli
|
|
3
|
+
description: Use when creating images, videos or text with insMind CLI, operating the focused insMind editor, or managing insMind DAM assets.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# insMind CLI
|
|
7
|
+
|
|
8
|
+
Read only the reference for the user's goal:
|
|
9
|
+
|
|
10
|
+
- Choose Agent or Tool creation, discover models, and generate images, videos or text: [Creation](references/creation.md)
|
|
11
|
+
- Operate the current AI+ Editor work: [Editor](references/editor.md)
|
|
12
|
+
- Discover repositories, folders and tags; find, upload, download or manage DAM assets: [Asset management](references/dam.md)
|
|
13
|
+
- Sign in or inspect account credits: [Authentication](references/auth.md)
|
|
14
|
+
- Handle output, warnings, failures, interruptions or missing results: [Errors](references/errors.md)
|
|
15
|
+
- Update the CLI and bundled Agent Skill: [Update](references/update.md)
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# Agent creation
|
|
2
|
+
|
|
3
|
+
For long creation work, submit once with `--async`, then query the returned `taskId` with `insmind-cli task get <taskId>`. Repeat queries while running; read `result` only when completed. An empty response, query timeout, unknown state, or host session ending is not a reason to generate again. If the ID is missing, use `task list` to locate the original task. The default command still waits for its result; keep waiting on that same process. See [status handling](errors.md).
|
|
4
|
+
|
|
5
|
+
Read the input schema first. When specifying a model, also read its live detail:
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
insmind-cli agent send --schema
|
|
9
|
+
insmind-cli model list --tool <tool>
|
|
10
|
+
insmind-cli model get <model>
|
|
11
|
+
insmind-cli agent send --input request.json --async
|
|
12
|
+
insmind-cli task get <taskId>
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
For continued planning, generation or edits, copy `message.contextId` from the preceding result into the next request. Omit it for a new creation:
|
|
16
|
+
|
|
17
|
+
```json
|
|
18
|
+
{
|
|
19
|
+
"message": {
|
|
20
|
+
"contextId": "<message.contextId from the preceding result>",
|
|
21
|
+
"parts": [{ "text": "<the user's follow-up request>" }]
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
Put the user's request and confirmed information in Text Parts. Distinguish visible features from inferred materials or functions. Mark unverified details as pending confirmation and clarify when necessary. A previous model description is not automatically a user-confirmed fact. Keep the same factual boundaries in delivery copy; present style, audience and scene ideas as suggestions.
|
|
27
|
+
|
|
28
|
+
Before specifying a model, generation parameters or first/last frames, read [Generation constraints and media roles](generation-constraints.md).
|
|
29
|
+
|
|
30
|
+
Use `--input -` to read JSON from stdin. The synchronous output (or result of a completed async task) contains `message` and actual credit usage for this `agent send`, excluding other tasks. Deliver text, resources, the continuation identifier and usage. When reporting totals, sum only distinct tasks whose usage you actually received. Repeated queries of one task report the same usage; do not add them again. Identify the task when quoting one charge and do not guess missing usage.
|
|
31
|
+
|
|
32
|
+
Keep each URL Part's `url`, `filename`, local path and display name together as one record. Preserve that association through downloads, renames and reordering; do not pair results by request order. Before delivery, check that each final link's content matches its name. View the resource when its name is insufficient to identify it.
|
|
33
|
+
|
|
34
|
+
Each follow-up turn has a new taskId; reuse result.message.contextId for the conversation. Async Agent creation continues in a temporary local background process and is queried on the same machine. Ending the foreground wait does not cancel it. If the background process stops or the machine shuts down, the state may remain unknown; do not automatically submit again through another mode.
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
# Authentication and credits
|
|
2
|
+
|
|
3
|
+
1. Check `insmind-cli auth status`; add `--json` for machine-readable status.
|
|
4
|
+
2. If signed out, run `insmind-cli auth login` and follow browser authorization. Use `--no-browser` when the browser cannot open automatically.
|
|
5
|
+
3. Read the current balance with `insmind-cli credits`.
|
|
6
|
+
4. If the user requests sign-out, run `insmind-cli auth logout`. For expired authentication, sign out and sign in again.
|
|
7
|
+
|
|
8
|
+
insMind uses the identity context supplied at login; it does not expose organization-selection commands. Do not invent organization IDs or use another product's credentials. Never ask the user for, or echo, Bearer tokens, cookies, access keys, secret keys or signatures.
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# Creation
|
|
2
|
+
|
|
3
|
+
## Choose a route
|
|
4
|
+
|
|
5
|
+
Choose the Creation Route before selecting or validating a Model. Both Agent and Tool accept models and parameters; `model list` and `model get` provide shared, live discovery.
|
|
6
|
+
|
|
7
|
+
- Agent: a business deliverable, clarification, planning, multiple steps or outputs, or continuation of existing work. The service selects its Business Skill.
|
|
8
|
+
- Tool: one atomic image, video or text operation without business orchestration, or an explicit request to call a Tool directly.
|
|
9
|
+
|
|
10
|
+
Match these business intents by meaning:
|
|
11
|
+
|
|
12
|
+
| Intent | Typical requests | Inputs and boundaries |
|
|
13
|
+
| --- | --- | --- |
|
|
14
|
+
| Ecommerce main images | Product images, a set of main images, product-image design | Usually includes a product photo; distinguish scene images, posters, detail pages, packaging and multiple angles |
|
|
15
|
+
| Ecommerce detail page | Product detail page, long image, selling points, parameters, features, comparisons, reasons to buy | Usually includes a product photo; a detail page is distinct from a main-image set |
|
|
16
|
+
| Product retouching | Retouch, restore, white background, remove signs of use | Requires an actual product photo; adding text, watermark removal, cutouts, local edits, posters and reference-layout imitation are different intents |
|
|
17
|
+
| Ecommerce models | Try-on, wearing, replace model, pose or background | Product photo optional; model-only generation is possible |
|
|
18
|
+
| Product scene image | Create a scene, change a background, combine products in a setting | Requires a product photo; portraits, landscapes, design drafts and text-led main images are different intents |
|
|
19
|
+
| Themed portrait | Themed photo, stylized portrait | Portrait input optional |
|
|
20
|
+
| Professional portrait | Headshot, professional profile | Portrait input optional |
|
|
21
|
+
| ID photo | ID/application photo, change background or dimensions | Portrait input optional |
|
|
22
|
+
| Ecommerce image prompts | Write prompts for product or main images | Subject to current service availability |
|
|
23
|
+
| Ecommerce video prompts | Product promotion or sales video prompts | Subject to current service availability |
|
|
24
|
+
|
|
25
|
+
These examples select the route, not a specific server Skill or a guarantee of service availability. Missing required media does not change a business task into a Tool task: use Agent and ask for the media. A specified model, resolution, aspect ratio or duration does not change the route either.
|
|
26
|
+
|
|
27
|
+
For example, a main-image set using a named model still uses Agent; planning three styles and generating each uses Agent; a single cat image using a named model uses Tool. Follow an explicit user request to use a Tool directly.
|
|
28
|
+
|
|
29
|
+
Never guess tool names, model names or parameters. For recommendations, capabilities, parameters or credit prices, first filter with `model list`, then inspect `model get`.
|
|
30
|
+
|
|
31
|
+
## Read the selected route
|
|
32
|
+
|
|
33
|
+
- Before an Agent request, read [Agent creation](agent.md) for new work, continuation, waiting and delivery.
|
|
34
|
+
- Before a Tool call, read [Tool creation](tool.md) and build arguments from the selected model detail.
|
|
35
|
+
|
|
36
|
+
## Local media
|
|
37
|
+
|
|
38
|
+
Use the attachment, named file or prior result explicitly selected in this turn. Otherwise choose the most recent relevant result in the current creation. When building or reusing request JSON, check every resource URL/path, name and role against the current target; updating only the text is insufficient. Preserve the matching `message.contextId` when continuing an Agent creation.
|
|
39
|
+
|
|
40
|
+
For Agent, put each local media file in a separate `file://` URL Part. For Tool, use the media parameter defined in model detail. The CLI uploads local media through DAM internally and sends the resulting URL to the creation service. Do not invent URLs or read paths the user has not authorized.
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
# DAM asset management
|
|
2
|
+
|
|
3
|
+
## Discover before acting
|
|
4
|
+
|
|
5
|
+
Before repository-scoped reads or writes, run:
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
insmind-cli dam repository list --json
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
Use only returned `repositories[].repository_id` values. Do not guess IDs from names, frontend URLs, entity IDs or old results. There is no repository-switch command.
|
|
12
|
+
|
|
13
|
+
Discover folders and tags when needed:
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
insmind-cli dam folder list --repository-id <id> --json
|
|
17
|
+
insmind-cli dam tag list --repository-id <id> --json
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
Folders accept `--parent-id`, `--query`, `--page` and `--page-size`; tags accept `--query`. The root folder ID is `0`; explicitly pass `--target-folder-id 0` for a root destination rather than relying on omission.
|
|
21
|
+
|
|
22
|
+
## Find and download
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
insmind-cli dam list --repository-id <id> --json
|
|
26
|
+
insmind-cli dam search <query> --repository-id <id> --json
|
|
27
|
+
insmind-cli dam get <asset-id> --json
|
|
28
|
+
insmind-cli dam download <asset-id> --repository-id <id> --output-dir ./downloads --json
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
Use `--all-repositories` only when the user explicitly requests a cross-repository query. Apply folder, type, format, tag, limit or cursor filters as needed. Download supports one asset, not folders, and never overwrites an existing same-named file.
|
|
32
|
+
|
|
33
|
+
## Single-entry changes
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
insmind-cli dam upload ./asset.png --repository-id <id> --folder-id <folder-id> --tag-ids <tag-id> --json
|
|
37
|
+
insmind-cli dam rename <entry-id> --kind asset --title <new-title> --repository-id <id> --json
|
|
38
|
+
insmind-cli dam copy <entry-id> --kind asset --repository-id <source-id> --target-repository-id <target-id> --target-folder-id <folder-id> --json
|
|
39
|
+
insmind-cli dam move <entry-id> --kind asset --repository-id <source-id> --target-repository-id <target-id> --target-folder-id <folder-id> --json
|
|
40
|
+
insmind-cli dam delete <asset-id> --repository-id <id>
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
- For rename, move and copy, `--kind` is `asset` or `folder`.
|
|
44
|
+
- Process one entry per operation; do not simulate batch operations.
|
|
45
|
+
- Use `--allow-sensitive-path` for protected uploads only with explicit user authorization. Use `--wait-analysis` when analysis must finish.
|
|
46
|
+
- A successful copy can omit `copied_entry_id`. Discover the copy in the destination; do not guess its ID or copy again.
|
|
47
|
+
- If move, copy or rename was submitted but remains unconfirmed, inspect the destination and report its diagnostic ID before considering further action.
|
|
48
|
+
- Delete moves an asset to the recycle bin by default. Use `--permanent` only when explicitly requested.
|
|
49
|
+
- Recycle-bin listing and restoration are unavailable; there is no `dam recycle` command.
|
|
50
|
+
|
|
51
|
+
Before writing, establish the repository, entry ID, kind and destination from current output and user intent. Do not substitute guessed IDs from local login state or old results.
|