ainecto 0.14.0-next.11 → 0.14.0-next.13
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/bin/ainecto.js +620 -352
- package/dist/bin/ainecto.js.map +1 -1
- package/dist/bin/mcp.js +165 -17
- package/dist/bin/mcp.js.map +1 -1
- package/package.json +2 -2
package/dist/bin/ainecto.js
CHANGED
|
@@ -5542,7 +5542,7 @@ function tokenKey(endpoint) {
|
|
|
5542
5542
|
}
|
|
5543
5543
|
|
|
5544
5544
|
// src/core/auth/oauth.ts
|
|
5545
|
-
import { createHash as
|
|
5545
|
+
import { createHash as createHash3, randomBytes } from "crypto";
|
|
5546
5546
|
import { createServer } from "http";
|
|
5547
5547
|
import { spawn } from "child_process";
|
|
5548
5548
|
import { URLSearchParams } from "url";
|
|
@@ -5686,8 +5686,8 @@ function legacyRoleInput(flag, envVars = process.env) {
|
|
|
5686
5686
|
|
|
5687
5687
|
// src/core/version.ts
|
|
5688
5688
|
var UNBUNDLED_VERSION = "dev";
|
|
5689
|
-
var CLI_VERSION = true ? "0.14.0-next.
|
|
5690
|
-
var CLI_BUILD = true ? "
|
|
5689
|
+
var CLI_VERSION = true ? "0.14.0-next.13" : UNBUNDLED_VERSION;
|
|
5690
|
+
var CLI_BUILD = true ? "3a78293" : void 0;
|
|
5691
5691
|
function cliVersionLabel(version, build, release) {
|
|
5692
5692
|
return release || build === void 0 ? version : `${version}-dev+${build}`;
|
|
5693
5693
|
}
|
|
@@ -5699,6 +5699,296 @@ function bridgePackageSpec(version = CLI_VERSION) {
|
|
|
5699
5699
|
return version === UNBUNDLED_VERSION ? PACKAGE_NAME : `${PACKAGE_NAME}@${version}`;
|
|
5700
5700
|
}
|
|
5701
5701
|
|
|
5702
|
+
// src/core/catalog/generator.ts
|
|
5703
|
+
import { createHash as createHash2 } from "crypto";
|
|
5704
|
+
var LEGACY_PREFIX = "mcp__ainecto__";
|
|
5705
|
+
function bareToolName(name) {
|
|
5706
|
+
return name.startsWith(LEGACY_PREFIX) ? name.slice(LEGACY_PREFIX.length) : name;
|
|
5707
|
+
}
|
|
5708
|
+
var DESTRUCTIVE_PREFIXES = [
|
|
5709
|
+
"delete_",
|
|
5710
|
+
"remove_",
|
|
5711
|
+
"archive_",
|
|
5712
|
+
"unarchive_",
|
|
5713
|
+
"restore_",
|
|
5714
|
+
"move_",
|
|
5715
|
+
"erd_delete_",
|
|
5716
|
+
"erd_remove_",
|
|
5717
|
+
"testcase_delete_"
|
|
5718
|
+
];
|
|
5719
|
+
function generateCatalog(tools, sourceCatalog) {
|
|
5720
|
+
return tools.map((tool) => normalizeTool(tool, sourceCatalog)).sort((a, b) => a.mcpName.localeCompare(b.mcpName));
|
|
5721
|
+
}
|
|
5722
|
+
function normalizeTool(tool, sourceCatalog) {
|
|
5723
|
+
if (!tool.name) {
|
|
5724
|
+
throw new Error("Unsupported tool name: empty.");
|
|
5725
|
+
}
|
|
5726
|
+
const stripped = bareToolName(tool.name);
|
|
5727
|
+
const group = inferGroup(stripped);
|
|
5728
|
+
const inputSchema = normalizeSchema(tool.inputSchema ?? { type: "object", properties: {} });
|
|
5729
|
+
const required = Array.isArray(inputSchema.required) ? inputSchema.required.filter((value) => typeof value === "string").sort() : [];
|
|
5730
|
+
const definition = {
|
|
5731
|
+
mcpName: tool.name,
|
|
5732
|
+
commandPath: generateCommandPath(stripped, group),
|
|
5733
|
+
group,
|
|
5734
|
+
description: tool.description ?? "",
|
|
5735
|
+
inputSchema,
|
|
5736
|
+
required,
|
|
5737
|
+
payloadMode: inferPayloadMode(stripped, inputSchema),
|
|
5738
|
+
destructive: inferDestructive(stripped, tool),
|
|
5739
|
+
sourceCatalog,
|
|
5740
|
+
schemaHash: ""
|
|
5741
|
+
};
|
|
5742
|
+
return { ...definition, schemaHash: computeSchemaHash(definition) };
|
|
5743
|
+
}
|
|
5744
|
+
function inferGroup(strippedName) {
|
|
5745
|
+
if (strippedName.startsWith("erd_")) return "erd";
|
|
5746
|
+
if (strippedName.startsWith("flow_")) return "flow";
|
|
5747
|
+
if (strippedName.startsWith("testcase_")) return "testcase";
|
|
5748
|
+
if (strippedName.startsWith("markdown_")) return "markdown";
|
|
5749
|
+
if (strippedName.includes("attachment") || strippedName.includes("upload")) return "attachment";
|
|
5750
|
+
if (strippedName.startsWith("kanban_")) return "kanban";
|
|
5751
|
+
if (strippedName.includes("workspace")) return "workspace";
|
|
5752
|
+
if (strippedName.includes("document")) return "document";
|
|
5753
|
+
return "generic";
|
|
5754
|
+
}
|
|
5755
|
+
function generateCommandPath(strippedName, group) {
|
|
5756
|
+
if (group !== "generic" && strippedName.startsWith(`${group}_`)) {
|
|
5757
|
+
return [group, snakeToKebab(strippedName.slice(group.length + 1))];
|
|
5758
|
+
}
|
|
5759
|
+
const [verb, ...rest] = strippedName.split("_");
|
|
5760
|
+
if (verb && rest.length > 0 && isVerb(verb)) {
|
|
5761
|
+
return [rest.join("-"), verb];
|
|
5762
|
+
}
|
|
5763
|
+
return ["tools", "run", snakeToKebab(strippedName)];
|
|
5764
|
+
}
|
|
5765
|
+
function inferPayloadMode(strippedName, inputSchema) {
|
|
5766
|
+
if (strippedName.includes("upload") || strippedName.includes("attachment_upload")) {
|
|
5767
|
+
return "binary-upload";
|
|
5768
|
+
}
|
|
5769
|
+
const properties = inputSchema.properties;
|
|
5770
|
+
if (!isRecord3(properties)) {
|
|
5771
|
+
return "flags";
|
|
5772
|
+
}
|
|
5773
|
+
const values = Object.values(properties);
|
|
5774
|
+
if (values.length === 0) {
|
|
5775
|
+
return "flags";
|
|
5776
|
+
}
|
|
5777
|
+
if (values.every(isScalarSchema)) {
|
|
5778
|
+
return "flags";
|
|
5779
|
+
}
|
|
5780
|
+
return "file-json";
|
|
5781
|
+
}
|
|
5782
|
+
function inferDestructive(strippedName, tool) {
|
|
5783
|
+
if (tool.annotations?.destructiveHint === true) {
|
|
5784
|
+
return true;
|
|
5785
|
+
}
|
|
5786
|
+
return DESTRUCTIVE_PREFIXES.some((prefix) => strippedName.startsWith(prefix));
|
|
5787
|
+
}
|
|
5788
|
+
function computeSchemaHash(tool) {
|
|
5789
|
+
return createHash2("sha256").update(stableStringify({
|
|
5790
|
+
name: tool.mcpName,
|
|
5791
|
+
description: tool.description,
|
|
5792
|
+
inputSchema: tool.inputSchema
|
|
5793
|
+
})).digest("hex").slice(0, 16);
|
|
5794
|
+
}
|
|
5795
|
+
function stableStringify(value) {
|
|
5796
|
+
if (Array.isArray(value)) {
|
|
5797
|
+
return `[${value.map(stableStringify).join(",")}]`;
|
|
5798
|
+
}
|
|
5799
|
+
if (isRecord3(value)) {
|
|
5800
|
+
return `{${Object.keys(value).sort().map((key) => `${JSON.stringify(key)}:${stableStringify(value[key])}`).join(",")}}`;
|
|
5801
|
+
}
|
|
5802
|
+
return JSON.stringify(value);
|
|
5803
|
+
}
|
|
5804
|
+
function normalizeSchema(schema) {
|
|
5805
|
+
return JSON.parse(stableStringify(schema));
|
|
5806
|
+
}
|
|
5807
|
+
function isScalarSchema(value) {
|
|
5808
|
+
if (!isRecord3(value)) {
|
|
5809
|
+
return false;
|
|
5810
|
+
}
|
|
5811
|
+
const type = value.type;
|
|
5812
|
+
return type === "string" || type === "number" || type === "integer" || type === "boolean";
|
|
5813
|
+
}
|
|
5814
|
+
function isVerb(value) {
|
|
5815
|
+
return [
|
|
5816
|
+
"list",
|
|
5817
|
+
"get",
|
|
5818
|
+
"create",
|
|
5819
|
+
"update",
|
|
5820
|
+
"delete",
|
|
5821
|
+
"move",
|
|
5822
|
+
"restore",
|
|
5823
|
+
"archive",
|
|
5824
|
+
"unarchive",
|
|
5825
|
+
"search"
|
|
5826
|
+
].includes(value);
|
|
5827
|
+
}
|
|
5828
|
+
function snakeToKebab(value) {
|
|
5829
|
+
return value.replaceAll("_", "-");
|
|
5830
|
+
}
|
|
5831
|
+
function isRecord3(value) {
|
|
5832
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
5833
|
+
}
|
|
5834
|
+
|
|
5835
|
+
// src/core/mcp/toolPayload.ts
|
|
5836
|
+
function unwrapMcpToolPayload(value) {
|
|
5837
|
+
if (!isRecord4(value) || !Array.isArray(value.content)) {
|
|
5838
|
+
return value;
|
|
5839
|
+
}
|
|
5840
|
+
const text2 = value.content.map((item) => isRecord4(item) && typeof item.text === "string" ? item.text : "").find((itemText) => itemText.trim().startsWith("{"));
|
|
5841
|
+
if (!text2) {
|
|
5842
|
+
return value;
|
|
5843
|
+
}
|
|
5844
|
+
try {
|
|
5845
|
+
return JSON.parse(text2);
|
|
5846
|
+
} catch {
|
|
5847
|
+
return value;
|
|
5848
|
+
}
|
|
5849
|
+
}
|
|
5850
|
+
function toolErrorText(value) {
|
|
5851
|
+
if (!isRecord4(value) || !Array.isArray(value.content)) {
|
|
5852
|
+
return "The tool returned an error.";
|
|
5853
|
+
}
|
|
5854
|
+
const text2 = value.content.map((item) => isRecord4(item) && typeof item.text === "string" ? item.text : "").filter(Boolean).join("\n");
|
|
5855
|
+
return text2 || "The tool returned an error.";
|
|
5856
|
+
}
|
|
5857
|
+
function isRecord4(value) {
|
|
5858
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
5859
|
+
}
|
|
5860
|
+
function extractProjects(value) {
|
|
5861
|
+
const candidates = Array.isArray(value) ? value : isRecord4(value) ? ["projects", "items", "created", "data", "hits"].flatMap((key) => {
|
|
5862
|
+
const nested = value[key];
|
|
5863
|
+
return Array.isArray(nested) ? nested : [];
|
|
5864
|
+
}) : [];
|
|
5865
|
+
const projects = [];
|
|
5866
|
+
for (const candidate of candidates) {
|
|
5867
|
+
if (isRecord4(candidate) && typeof candidate.uuid === "string") {
|
|
5868
|
+
projects.push({
|
|
5869
|
+
uuid: candidate.uuid,
|
|
5870
|
+
name: typeof candidate.name === "string" ? candidate.name : candidate.uuid
|
|
5871
|
+
});
|
|
5872
|
+
}
|
|
5873
|
+
}
|
|
5874
|
+
return projects;
|
|
5875
|
+
}
|
|
5876
|
+
|
|
5877
|
+
// src/core/mcp/operations.ts
|
|
5878
|
+
var SEARCH_TOOL = "search";
|
|
5879
|
+
var OperationError = class extends Error {
|
|
5880
|
+
constructor(message2, code, operation, details) {
|
|
5881
|
+
super(message2);
|
|
5882
|
+
this.code = code;
|
|
5883
|
+
this.operation = operation;
|
|
5884
|
+
this.details = details;
|
|
5885
|
+
this.name = "OperationError";
|
|
5886
|
+
}
|
|
5887
|
+
code;
|
|
5888
|
+
operation;
|
|
5889
|
+
details;
|
|
5890
|
+
};
|
|
5891
|
+
function searchPayload(asked, operation, result) {
|
|
5892
|
+
if (isRecord5(result) && result.isError === true) throw toolRefusal(asked, operation, result);
|
|
5893
|
+
return unwrapMcpToolPayload(result);
|
|
5894
|
+
}
|
|
5895
|
+
function parseOperationPage(result) {
|
|
5896
|
+
const payload = searchPayload("the operation list", SEARCH_TOOL, result);
|
|
5897
|
+
if (!isRecord5(payload) || !Array.isArray(payload.items)) {
|
|
5898
|
+
throw new OperationError("search did not return an items array.", "MCP_PROTOCOL_ERROR", SEARCH_TOOL);
|
|
5899
|
+
}
|
|
5900
|
+
const items = payload.items.flatMap((item) => isRecord5(item) && typeof item.operation === "string" ? [{ operation: item.operation, summary: typeof item.summary === "string" ? item.summary : "" }] : []);
|
|
5901
|
+
const nextCursor = typeof payload.nextCursor === "string" && payload.nextCursor ? payload.nextCursor : void 0;
|
|
5902
|
+
return { items, ...nextCursor ? { nextCursor } : {} };
|
|
5903
|
+
}
|
|
5904
|
+
function parseOperationDetail(operation, result) {
|
|
5905
|
+
const payload = searchPayload(`the detail of ${operation}`, operation, result);
|
|
5906
|
+
if (!isRecord5(payload) || payload.operation !== operation) {
|
|
5907
|
+
throw new OperationError(`search did not return the detail of ${operation}.`, "MCP_PROTOCOL_ERROR", operation);
|
|
5908
|
+
}
|
|
5909
|
+
const executor = payload.executor;
|
|
5910
|
+
if (typeof executor !== "string" || executor.trim() === "") {
|
|
5911
|
+
throw new OperationError(
|
|
5912
|
+
`search detail of ${operation} has no valid executor (${JSON.stringify(executor)}).`,
|
|
5913
|
+
"MCP_PROTOCOL_ERROR",
|
|
5914
|
+
operation
|
|
5915
|
+
);
|
|
5916
|
+
}
|
|
5917
|
+
const hints = isRecord5(payload.annotations) ? payload.annotations : {};
|
|
5918
|
+
return {
|
|
5919
|
+
operation,
|
|
5920
|
+
summary: typeof payload.summary === "string" ? payload.summary : "",
|
|
5921
|
+
executor,
|
|
5922
|
+
annotations: {
|
|
5923
|
+
...typeof hints.readOnlyHint === "boolean" ? { readOnlyHint: hints.readOnlyHint } : {},
|
|
5924
|
+
...typeof hints.destructiveHint === "boolean" ? { destructiveHint: hints.destructiveHint } : {},
|
|
5925
|
+
...typeof hints.idempotentHint === "boolean" ? { idempotentHint: hints.idempotentHint } : {},
|
|
5926
|
+
...typeof hints.openWorldHint === "boolean" ? { openWorldHint: hints.openWorldHint } : {}
|
|
5927
|
+
},
|
|
5928
|
+
inputSchema: isRecord5(payload.inputSchema) ? payload.inputSchema : { type: "object", properties: {} }
|
|
5929
|
+
};
|
|
5930
|
+
}
|
|
5931
|
+
var SEARCH_PAGE_MAX = 50;
|
|
5932
|
+
var MAX_PAGES = 20;
|
|
5933
|
+
function searchVocabulary(searchTool) {
|
|
5934
|
+
const props = isRecord5(searchTool) && isRecord5(searchTool.inputSchema) && isRecord5(searchTool.inputSchema.properties) ? searchTool.inputSchema.properties : {};
|
|
5935
|
+
const values = (facet) => {
|
|
5936
|
+
const prop = props[facet];
|
|
5937
|
+
const items = isRecord5(prop) && isRecord5(prop.items) ? prop.items : {};
|
|
5938
|
+
return Array.isArray(items.enum) ? items.enum.filter((value) => typeof value === "string") : [];
|
|
5939
|
+
};
|
|
5940
|
+
const vocabulary = { action: values("action"), object: values("object") };
|
|
5941
|
+
if (vocabulary.action.length === 0 || vocabulary.object.length === 0) {
|
|
5942
|
+
throw new OperationError("tools/list has no search tool with action/object vocabularies.", "MCP_PROTOCOL_ERROR", SEARCH_TOOL);
|
|
5943
|
+
}
|
|
5944
|
+
return vocabulary;
|
|
5945
|
+
}
|
|
5946
|
+
async function listAllOperations(input) {
|
|
5947
|
+
const vocabulary = searchVocabulary((await input.toolsList()).find((tool) => isRecord5(tool) && tool.name === SEARCH_TOOL));
|
|
5948
|
+
const byName = /* @__PURE__ */ new Map();
|
|
5949
|
+
let cursor;
|
|
5950
|
+
for (let page = 0; page < MAX_PAGES; page += 1) {
|
|
5951
|
+
const result = parseOperationPage(await input.callPublic(SEARCH_TOOL, { ...vocabulary, limit: SEARCH_PAGE_MAX, ...cursor ? { cursor } : {} }));
|
|
5952
|
+
for (const line of result.items) if (!byName.has(line.operation)) byName.set(line.operation, line);
|
|
5953
|
+
cursor = result.nextCursor;
|
|
5954
|
+
if (!cursor) return [...byName.values()].sort((a, b) => a.operation.localeCompare(b.operation));
|
|
5955
|
+
}
|
|
5956
|
+
throw new OperationError(`search kept returning a next page after ${MAX_PAGES} pages.`, "MCP_PROTOCOL_ERROR", SEARCH_TOOL);
|
|
5957
|
+
}
|
|
5958
|
+
var OperationCaller = class {
|
|
5959
|
+
constructor(callPublic) {
|
|
5960
|
+
this.callPublic = callPublic;
|
|
5961
|
+
}
|
|
5962
|
+
callPublic;
|
|
5963
|
+
details = /* @__PURE__ */ new Map();
|
|
5964
|
+
detail(operation) {
|
|
5965
|
+
let found = this.details.get(operation);
|
|
5966
|
+
if (!found) {
|
|
5967
|
+
found = this.callPublic(SEARCH_TOOL, { operation }).then((result) => parseOperationDetail(operation, result));
|
|
5968
|
+
found.catch(() => this.details.delete(operation));
|
|
5969
|
+
this.details.set(operation, found);
|
|
5970
|
+
}
|
|
5971
|
+
return found;
|
|
5972
|
+
}
|
|
5973
|
+
async call(operation, args) {
|
|
5974
|
+
const detail = await this.detail(operation);
|
|
5975
|
+
return this.callPublic(detail.executor, { operation, args });
|
|
5976
|
+
}
|
|
5977
|
+
};
|
|
5978
|
+
function toolRefusal(asked, operation, result) {
|
|
5979
|
+
const text2 = toolErrorText(result);
|
|
5980
|
+
let code = "MCP_TOOL_ERROR";
|
|
5981
|
+
try {
|
|
5982
|
+
const parsed = JSON.parse(text2);
|
|
5983
|
+
if (isRecord5(parsed) && typeof parsed.code === "string" && parsed.code) code = parsed.code;
|
|
5984
|
+
} catch {
|
|
5985
|
+
}
|
|
5986
|
+
return new OperationError(`search refused ${asked}: ${text2}`, code, operation, result);
|
|
5987
|
+
}
|
|
5988
|
+
function isRecord5(value) {
|
|
5989
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
5990
|
+
}
|
|
5991
|
+
|
|
5702
5992
|
// src/core/mcp/rpcClient.ts
|
|
5703
5993
|
var CHANNEL_HEADER = "X-AiNecto-Channel";
|
|
5704
5994
|
var AGENT_HEADER = "X-AiNecto-Agent";
|
|
@@ -5725,11 +6015,16 @@ var McpRpcClient = class {
|
|
|
5725
6015
|
constructor(options) {
|
|
5726
6016
|
this.options = options;
|
|
5727
6017
|
this.fetchImpl = options.fetchImpl ?? fetch;
|
|
6018
|
+
this.operations = new OperationCaller((tool, args) => this.request("tools/call", { name: tool, arguments: args }));
|
|
5728
6019
|
}
|
|
5729
6020
|
options;
|
|
5730
6021
|
fetchImpl;
|
|
5731
6022
|
nextId = 1;
|
|
5732
6023
|
agent;
|
|
6024
|
+
/** operation → 실행 도구 — 상세(executor)는 이 연결에서 한 번만 묻는다. */
|
|
6025
|
+
operations;
|
|
6026
|
+
/** 서버가 공개한 도구 이름 — 진실원은 tools/list. 연결당 한 번(실패는 기억하지 않는다). */
|
|
6027
|
+
publicTools;
|
|
5733
6028
|
/**
|
|
5734
6029
|
* 브리지 전용 — 호스트 에이전트가 보낸 {@code initialize} 의 {@code clientInfo.name}(프로그램 고정 이름).
|
|
5735
6030
|
* 이후 모든 요청의 {@code X-AiNecto-Agent} 헤더로 싣는다. 직접 명령은 부르지 않는다(누가 셸을 돌렸는지 모른다).
|
|
@@ -5746,13 +6041,41 @@ var McpRpcClient = class {
|
|
|
5746
6041
|
}
|
|
5747
6042
|
async toolsList() {
|
|
5748
6043
|
const result = await this.request("tools/list", {});
|
|
5749
|
-
if (!
|
|
6044
|
+
if (!isRecord6(result) || !Array.isArray(result.tools)) {
|
|
5750
6045
|
throw new McpRpcError("tools/list response did not include a tools array.", "MCP_PROTOCOL_ERROR", result);
|
|
5751
6046
|
}
|
|
6047
|
+
this.publicTools = Promise.resolve(toolNames(result.tools));
|
|
5752
6048
|
return result.tools;
|
|
5753
6049
|
}
|
|
6050
|
+
/** 공개 도구 이름 — 이 연결에서 아직 모르면 tools/list 를 한 번 부른다. */
|
|
6051
|
+
publicToolNames() {
|
|
6052
|
+
if (!this.publicTools) {
|
|
6053
|
+
const pending = this.toolsList().then(toolNames);
|
|
6054
|
+
pending.catch(() => {
|
|
6055
|
+
if (this.publicTools === pending) this.publicTools = void 0;
|
|
6056
|
+
});
|
|
6057
|
+
this.publicTools = pending;
|
|
6058
|
+
}
|
|
6059
|
+
return this.publicTools;
|
|
6060
|
+
}
|
|
6061
|
+
/**
|
|
6062
|
+
* ★CLI 안의 모든 도구 호출이 지나는 한 입구. 서버 tools/list 에 있는 공개 도구(search·execute_*·open_ainecto_panel)는
|
|
6063
|
+
* 자기 이름으로 한 번만, 그 밖의 이름은 operation 으로 보고 {@code <executor> {operation, args}} 로 바꿔 부른다(operations.ts)
|
|
6064
|
+
* — 서버는 옛 108개 이름을 거절한다. 공개 이름의 사본은 두지 않는다(리뷰 r1 P1-3).
|
|
6065
|
+
* 옛 {@code mcp__ainecto__} 앞머리는 뗀다. 브리지(sendRaw)는 이 길을 지나지 않는다 — 호스트가 고른 도구 그대로 간다.
|
|
6066
|
+
*/
|
|
5754
6067
|
async toolsCall(name, args) {
|
|
5755
|
-
|
|
6068
|
+
const bare = bareToolName(name);
|
|
6069
|
+
const payload = isRecord6(args) ? args : {};
|
|
6070
|
+
return (await this.publicToolNames()).has(bare) ? this.request("tools/call", { name: bare, arguments: payload }) : this.operations.call(bare, payload);
|
|
6071
|
+
}
|
|
6072
|
+
/**
|
|
6073
|
+
* {@link toolsCall} 가 이 이름을 부를 때 쓸 상세 — 공개 도구 이름이면 undefined(자기 이름으로 바로 간다).
|
|
6074
|
+
* 같은 연결의 상세라 뒤이은 toolsCall 이 똑같은 것을 쓴다(실행 전 판단과 실행이 같은 사실을 본다).
|
|
6075
|
+
*/
|
|
6076
|
+
async operationDetailFor(name) {
|
|
6077
|
+
const bare = bareToolName(name);
|
|
6078
|
+
return (await this.publicToolNames()).has(bare) ? void 0 : this.operations.detail(bare);
|
|
5756
6079
|
}
|
|
5757
6080
|
async request(method, params) {
|
|
5758
6081
|
const response = await this.sendRaw({
|
|
@@ -5839,7 +6162,7 @@ var McpRpcClient = class {
|
|
|
5839
6162
|
function rateLimitedResponse(text2, retryAfter) {
|
|
5840
6163
|
const envelope = rpcErrorEnvelope(text2);
|
|
5841
6164
|
if (envelope) {
|
|
5842
|
-
const data =
|
|
6165
|
+
const data = isRecord6(envelope.error.data) ? envelope.error.data : {};
|
|
5843
6166
|
const seconds = parseRetryAfter(retryAfter);
|
|
5844
6167
|
if (data.retryAfterSeconds === void 0 && seconds !== void 0) {
|
|
5845
6168
|
envelope.error.data = { ...data, retryAfterSeconds: seconds };
|
|
@@ -5851,7 +6174,7 @@ function rateLimitedResponse(text2, retryAfter) {
|
|
|
5851
6174
|
}
|
|
5852
6175
|
function rpcErrorEnvelope(text2) {
|
|
5853
6176
|
const parsed = parseJsonOrUndefined(text2);
|
|
5854
|
-
return isJsonRpcResponse(parsed) && "error" in parsed &&
|
|
6177
|
+
return isJsonRpcResponse(parsed) && "error" in parsed && isRecord6(parsed.error) ? parsed : void 0;
|
|
5855
6178
|
}
|
|
5856
6179
|
function parseJsonOrUndefined(text2) {
|
|
5857
6180
|
try {
|
|
@@ -5861,8 +6184,8 @@ function parseJsonOrUndefined(text2) {
|
|
|
5861
6184
|
}
|
|
5862
6185
|
}
|
|
5863
6186
|
function describeRpcError(error) {
|
|
5864
|
-
const data =
|
|
5865
|
-
const messages =
|
|
6187
|
+
const data = isRecord6(error.data) ? error.data : {};
|
|
6188
|
+
const messages = isRecord6(data.messages) ? data.messages : {};
|
|
5866
6189
|
const sentence = [error.message, data.message, messages.en, messages.ko].find((value) => typeof value === "string" && value.trim() !== "");
|
|
5867
6190
|
const code = typeof data.code === "string" && data.code.trim() ? data.code.trim() : void 0;
|
|
5868
6191
|
if (!code) {
|
|
@@ -5871,7 +6194,7 @@ function describeRpcError(error) {
|
|
|
5871
6194
|
return describeServerError({ error: code, description: sentence });
|
|
5872
6195
|
}
|
|
5873
6196
|
function isToolError(result) {
|
|
5874
|
-
return
|
|
6197
|
+
return isRecord6(result) && result.isError === true;
|
|
5875
6198
|
}
|
|
5876
6199
|
function agentHeaderValue(clientName) {
|
|
5877
6200
|
return printableHeaderValue(clientName);
|
|
@@ -5890,7 +6213,7 @@ function parseServerError(body) {
|
|
|
5890
6213
|
} catch {
|
|
5891
6214
|
return void 0;
|
|
5892
6215
|
}
|
|
5893
|
-
if (!
|
|
6216
|
+
if (!isRecord6(parsed) || typeof parsed.error !== "string" || !parsed.error.trim()) {
|
|
5894
6217
|
return void 0;
|
|
5895
6218
|
}
|
|
5896
6219
|
return {
|
|
@@ -5903,9 +6226,12 @@ function describeServerError(serverError) {
|
|
|
5903
6226
|
return line.replace(/\s+/g, " ").trim();
|
|
5904
6227
|
}
|
|
5905
6228
|
function isJsonRpcResponse(value) {
|
|
5906
|
-
return
|
|
6229
|
+
return isRecord6(value) && value.jsonrpc === "2.0" && ("result" in value || "error" in value);
|
|
5907
6230
|
}
|
|
5908
|
-
function
|
|
6231
|
+
function toolNames(tools) {
|
|
6232
|
+
return new Set(tools.flatMap((tool) => isRecord6(tool) && typeof tool.name === "string" ? [tool.name] : []));
|
|
6233
|
+
}
|
|
6234
|
+
function isRecord6(value) {
|
|
5909
6235
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
5910
6236
|
}
|
|
5911
6237
|
function httpErrorDetails(status, body, envVars) {
|
|
@@ -6036,7 +6362,7 @@ var OAuthClient = class {
|
|
|
6036
6362
|
};
|
|
6037
6363
|
function generatePkcePair() {
|
|
6038
6364
|
const codeVerifier = randomBytes(32).toString("base64url");
|
|
6039
|
-
const codeChallenge =
|
|
6365
|
+
const codeChallenge = createHash3("sha256").update(codeVerifier).digest("base64url");
|
|
6040
6366
|
return { codeVerifier, codeChallenge };
|
|
6041
6367
|
}
|
|
6042
6368
|
function generateOAuthState() {
|
|
@@ -6547,11 +6873,11 @@ Retries: send a unique clientMutationId with each write; if you retry the same c
|
|
|
6547
6873
|
{ "mcpName": "unfavorite_documents", "commandPath": ["tools", "run", "unfavorite-documents"], "group": "document", "description": "Remove documents from the signed-in user's favorites (favorite_documents). Works even for a document the user can no longer open, and a document that was not a favorite is returned the same way. The documents themselves are not changed. Targets are UUIDs only; names are never matched and may repeat. Look the UUID up first, and when more than one candidate fits what the user said, ask which one. Items run in order and each one commits on its own: the first failing item ends the call with an error, items before it stay applied (the error does not list them), and later items are not tried \u2014 re-read before retrying. Returns unfavorited: [{documentUuid, favorited: false}] and count.\n\nRetries: send a unique clientMutationId with each write; if you retry the same call (for example after a timeout or lost response), send the same clientMutationId and the server returns the first result instead of running it again.", "inputSchema": { "additionalProperties": false, "properties": { "clientMutationId": { "description": "Idempotency key for this call (visible ASCII, at most 128 characters). Reusing it with the same arguments returns the first result (marked idempotentReplay); reusing it with different arguments is rejected with 409.", "maxLength": 128, "minLength": 1, "pattern": "^[\\x21-\\x7E]{1,128}$", "type": "string" }, "uuids": { "description": "Document UUIDs to remove from favorites", "items": { "description": "Document UUID", "type": "string" }, "type": "array" } }, "required": ["uuids"], "type": "object" }, "required": ["uuids"], "payloadMode": "file-json", "destructive": true, "sourceCatalog": "prod", "schemaHash": "5464109984aa000d" },
|
|
6548
6874
|
{ "mcpName": "unsubscribe_documents", "commandPath": ["tools", "run", "unsubscribe-documents"], "group": "document", "description": "Stop the signed-in user's subscription to documents (subscribe_documents) \u2014 no more change notifications for them. Works even for a document the user can no longer open, and a document that was not subscribed is returned the same way. Notifications already received stay in the inbox. Targets are UUIDs only; names are never matched and may repeat. Look the UUID up first, and when more than one candidate fits what the user said, ask which one. Items run in order and each one commits on its own: the first failing item ends the call with an error, items before it stay applied (the error does not list them), and later items are not tried \u2014 re-read before retrying. Returns unsubscribed: [{documentUuid, subscribed: false}] and count.\n\nRetries: send a unique clientMutationId with each write; if you retry the same call (for example after a timeout or lost response), send the same clientMutationId and the server returns the first result instead of running it again.", "inputSchema": { "additionalProperties": false, "properties": { "clientMutationId": { "description": "Idempotency key for this call (visible ASCII, at most 128 characters). Reusing it with the same arguments returns the first result (marked idempotentReplay); reusing it with different arguments is rejected with 409.", "maxLength": 128, "minLength": 1, "pattern": "^[\\x21-\\x7E]{1,128}$", "type": "string" }, "uuids": { "description": "Document UUIDs to unsubscribe from", "items": { "description": "Document UUID", "type": "string" }, "type": "array" } }, "required": ["uuids"], "type": "object" }, "required": ["uuids"], "payloadMode": "file-json", "destructive": true, "sourceCatalog": "prod", "schemaHash": "3c032d27d8adc84d" },
|
|
6549
6875
|
{ "mcpName": "update_agent_todos", "commandPath": ["agent-todos", "update"], "group": "generic", "description": "Claim, renew, complete, release, or dismiss the signed-in user's agent to-dos. Only the session holding the current leaseToken may renew, release, or complete a claimed to-do \u2014 even another session of the same connection gets CLAIMED_BY_OTHER. Results are per item: {todoId, ok: true, state, leaseToken?, claimExpiresAt?} or {todoId, ok: false, error} with error one of CLAIMED_BY_OTHER, LEASE_LOST, ALREADY_DONE, CLOSED_BY_HUMAN, SUPERSEDED, ACCESS_LOST, BUSINESS_ACTION_REQUIRED, NOT_FOUND, INVALID \u2014 on CLOSED_BY_HUMAN or SUPERSEDED stop working on it. BUSINESS_ACTION_REQUIRED: card to-dos (CARD_*) cannot be completed here; doing the card action closes them. Retrying the same complete or dismiss returns ok again. To mark the person's notifications read (only when they ask), use mark_notifications_read.\n\nRetries: send a unique clientMutationId with each write; if you retry the same call (for example after a timeout or lost response), send the same clientMutationId and the server returns the first result instead of running it again.", "inputSchema": { "additionalProperties": false, "properties": { "clientMutationId": { "description": "Idempotency key for this call (visible ASCII, at most 128 characters). Reusing it with the same arguments returns the first result (marked idempotentReplay); reusing it with different arguments is rejected with 409.", "maxLength": 128, "minLength": 1, "pattern": "^[\\x21-\\x7E]{1,128}$", "type": "string" }, "items": { "description": "To-dos to update; each item is applied and reported on its own.", "items": { "additionalProperties": false, "properties": { "action": { "description": "claim: take it (returns leaseToken, valid 30 minutes). renew: extend your lease. complete: done (with leaseToken if you claimed it; without one only while it is still OPEN). release: give it back. dismiss: not a to-do.", "enum": ["claim", "renew", "complete", "release", "dismiss"], "type": "string" }, "leaseToken": { "description": "Required for renew and release, and for complete or dismiss of a to-do you claimed.", "type": "string" }, "note": { "description": "For complete or dismiss: one line on what you did (at most 500 characters, no document bodies). The person sees it in the inbox.", "maxLength": 500, "type": "string" }, "todoId": { "description": "todoId from list_agent_todos.", "type": "string" } }, "required": ["todoId", "action"], "type": "object" }, "maxItems": 50, "minItems": 1, "type": "array" } }, "required": ["items"], "type": "object" }, "required": ["items"], "payloadMode": "file-json", "destructive": true, "sourceCatalog": "prod", "schemaHash": "35cde49fba4c9f5f" },
|
|
6550
|
-
{ "mcpName": "update_agents", "commandPath": ["agents", "update"], "group": "generic", "description": "Rename, archive or unarchive the signed-in user's named agents (see list_agents), or set the project an agent works in (projectUuid; display only). Each item commits on its own and a failing item does not stop the others. Results are per item: {agentUuid, ok: true, agent, note?} or {agentUuid, ok: false, error: {code, message}} with code one of AGENT_NOT_FOUND, AGENT_NAME_INVALID, AGENT_NAME_TAKEN, AGENT_HAS_OPEN_WORK (open cards or to-dos still point at the agent \u2014 reassign them first; counts are in openCards and openTodos), PROJECT_NOT_FOUND (no such project, or you cannot read it), AGENT_INVALID. After a rename, change the name in that agent's folder connection settings too, or it connects with the old name again and a new agent appears.\n\nRetries: send a unique clientMutationId with each write; if you retry the same call (for example after a timeout or lost response), send the same clientMutationId and the server returns the first result instead of running it again.", "inputSchema": { "additionalProperties": false, "properties": { "clientMutationId": { "description": "Idempotency key for this call (visible ASCII, at most 128 characters). Reusing it with the same arguments returns the first result (marked idempotentReplay); reusing it with different arguments is rejected with 409.", "maxLength": 128, "minLength": 1, "pattern": "^[\\x21-\\x7E]{1,128}$", "type": "string" }, "items": { "description": "Agents to change; each item is applied and reported on its own.", "items": { "additionalProperties": false, "properties": { "agentUuid": { "description": "agentUuid from list_agents.", "type": "string" }, "archived": { "description": "true archives the agent (it disappears from pickers; its history stays), false brings it back. An archived agent that connects again with its name is brought back automatically.", "type": "boolean" }, "clientMutationId": { "description": "Optional id echoed back in this item's result.", "type": "string" }, "name": { "description": "New name \u2014 lowercase letters, digits, '.', '_' and '-', starting with a letter or digit (stored in lowercase).", "maxLength": 64, "type": "string" }, "projectUuid": { "description": "The project this agent works in (projectUuid from list_projects) \u2014 shown next to the agent in list_agents and when picking an agent for a card. Display only: it does not limit what the agent can do or which cards it can get. An empty string clears it. You must be able to read the project.", "type": "string" } }, "required": ["agentUuid"], "type": "object" }, "maxItems": 50, "minItems": 1, "type": "array" } }, "required": ["items"], "type": "object" }, "required": ["items"], "payloadMode": "file-json", "destructive":
|
|
6876
|
+
{ "mcpName": "update_agents", "commandPath": ["agents", "update"], "group": "generic", "description": "Rename, archive or unarchive the signed-in user's named agents (see list_agents), or set the project an agent works in (projectUuid; display only). Each item commits on its own and a failing item does not stop the others. Results are per item: {agentUuid, ok: true, agent, note?} or {agentUuid, ok: false, error: {code, message}} with code one of AGENT_NOT_FOUND, AGENT_NAME_INVALID, AGENT_NAME_TAKEN, AGENT_HAS_OPEN_WORK (open cards or to-dos still point at the agent \u2014 reassign them first; counts are in openCards and openTodos), PROJECT_NOT_FOUND (no such project, or you cannot read it), AGENT_INVALID. After a rename, change the name in that agent's folder connection settings too, or it connects with the old name again and a new agent appears.\n\nRetries: send a unique clientMutationId with each write; if you retry the same call (for example after a timeout or lost response), send the same clientMutationId and the server returns the first result instead of running it again.", "inputSchema": { "additionalProperties": false, "properties": { "clientMutationId": { "description": "Idempotency key for this call (visible ASCII, at most 128 characters). Reusing it with the same arguments returns the first result (marked idempotentReplay); reusing it with different arguments is rejected with 409.", "maxLength": 128, "minLength": 1, "pattern": "^[\\x21-\\x7E]{1,128}$", "type": "string" }, "items": { "description": "Agents to change; each item is applied and reported on its own.", "items": { "additionalProperties": false, "properties": { "agentUuid": { "description": "agentUuid from list_agents.", "type": "string" }, "archived": { "description": "true archives the agent (it disappears from pickers; its history stays), false brings it back. An archived agent that connects again with its name is brought back automatically.", "type": "boolean" }, "clientMutationId": { "description": "Optional id echoed back in this item's result.", "type": "string" }, "name": { "description": "New name \u2014 lowercase letters, digits, '.', '_' and '-', starting with a letter or digit (stored in lowercase).", "maxLength": 64, "type": "string" }, "projectUuid": { "description": "The project this agent works in (projectUuid from list_projects) \u2014 shown next to the agent in list_agents and when picking an agent for a card. Display only: it does not limit what the agent can do or which cards it can get. An empty string clears it. You must be able to read the project.", "type": "string" } }, "required": ["agentUuid"], "type": "object" }, "maxItems": 50, "minItems": 1, "type": "array" } }, "required": ["items"], "type": "object" }, "required": ["items"], "payloadMode": "file-json", "destructive": true, "sourceCatalog": "prod", "schemaHash": "04b7bb798d169034" },
|
|
6551
6877
|
{ "mcpName": "update_comments", "commandPath": ["comments", "update"], "group": "generic", "description": "Edit your own comments on a document or a kanban card (cardUuid). Only the author can edit, and only while they can still read it. A resolved question and a top-level comment that already has replies are locked. Items are applied in order and each one commits on its own; results report each item.\n\nRetries: send a unique clientMutationId with each write; if you retry the same call (for example after a timeout or lost response), send the same clientMutationId and the server returns the first result instead of running it again.", "inputSchema": { "additionalProperties": false, "properties": { "cardUuid": { "description": "Kanban card UUID the comments belong to (from kanban_list_cards). Anyone who can read the card's board may comment. Give this or documentUuid, not both.", "type": "string" }, "clientMutationId": { "description": "Idempotency key for this call (visible ASCII, at most 128 characters). Reusing it with the same arguments returns the first result (marked idempotentReplay); reusing it with different arguments is rejected with 409.", "maxLength": 128, "minLength": 1, "pattern": "^[\\x21-\\x7E]{1,128}$", "type": "string" }, "documentUuid": { "description": "Document UUID the comments belong to. Give this or cardUuid, not both.", "type": "string" }, "items": { "description": "Edits, applied in order", "items": { "additionalProperties": false, "properties": { "body": { "description": "New comment text (replaces the old text).", "maxLength": 1e4, "minLength": 1, "type": "string" }, "clientMutationId": { "description": "Idempotency key (visible ASCII, at most 128 characters). Required when mentionUserIds is not empty; reuse the same value when retrying the same item so the mention email is not sent twice.", "maxLength": 128, "type": "string" }, "id": { "description": "Comment id (from mcp__ainecto__list_comments)", "minimum": 1, "type": "integer" }, "mentionUserIds": { "description": "The complete set of userIds mentioned after the edit; omit to remove all mentions. Each one's @<displayName> must appear in body. Only people who were not mentioned before get a notification email.", "items": { "type": "string" }, "maxItems": 20, "type": "array", "uniqueItems": true } }, "required": ["id", "body"], "type": "object" }, "minItems": 1, "type": "array" }, "mailLanguage": { "description": "Language of the comment notification email (mention or reply). Defaults to en.", "enum": ["en", "ko"], "type": "string" } }, "required": ["items"], "type": "object" }, "required": ["items"], "payloadMode": "file-json", "destructive": true, "sourceCatalog": "prod", "schemaHash": "04ef0a3cecca04ee" },
|
|
6552
6878
|
{ "mcpName": "update_documents", "commandPath": ["documents", "update"], "group": "document", "description": "Update documents: the title and/or the whole body. A body you send replaces the current body entirely \u2014 it is not a patch, so read the document first and send the full new text. The document type decides the body field (see body and typePayload): file documents can only be renamed, ERD content changes through erd_apply_changes, diagram nodes and edges through diagram_apply_changes, and board documents are refused. Every body change is kept in version history, so list_versions and restore_versions can undo it. Needs edit access. Items run in order and each one commits on its own: the first failing item ends the call with an error, items before it stay applied (the error does not list them), and later items are not tried \u2014 re-read before retrying. Returns updated (document rows) and count. Fails with 409 when the document is in the trash or its folder, project or workspace is archived. If a replacement body is tens of KB or more, prefer request_upload_token (purpose=document.update) and upload the body with curl. While you write a document, people who open it see that an AI agent is writing it (with your agent name and the time of your last write). When the document is complete, call finish_documents; otherwise the notice ends 10 minutes after your last write.\n\nRetries: send a unique clientMutationId with each write; if you retry the same call (for example after a timeout or lost response), send the same clientMutationId and the server returns the first result instead of running it again.", "inputSchema": { "additionalProperties": false, "properties": { "clientMutationId": { "description": "Idempotency key for this call (visible ASCII, at most 128 characters). Reusing it with the same arguments returns the first result (marked idempotentReplay); reusing it with different arguments is rejected with 409.", "maxLength": 128, "minLength": 1, "pattern": "^[\\x21-\\x7E]{1,128}$", "type": "string" }, "items": { "description": "Updates", "items": { "additionalProperties": false, "properties": { "basedOn": { "description": "Documents this one is based on (at most 50). Put only documents you actually used as a basis as TRACK; leave out sibling documents written alongside this one, or add them as REFERENCE. kind TRACK (default) records the source version and tells this document's owner when the source is updated so they can review it; REFERENCE is a plain link. If you read the source with get_document (or get_version), pass its readVersion as version \u2014 if that version was overwritten after you read it you get 409, read again. If readVersion is null (changes not yet saved as a version, or a type whose get_document does not return the whole content) read it with get_version and pass that readVersion, or omit version (always omit it when get_version's readVersion is null too). Omitting version records the latest version at save time and does not prove what you read. An existing tracking relation is confirmed to that version; an existing reference is promoted to tracking; kind REFERENCE never demotes a tracking relation (use document_relations SET_KIND). Relations not listed are left as they are.", "items": { "additionalProperties": false, "properties": { "documentUuid": { "description": "Source document UUID", "type": "string" }, "kind": { "description": "TRACK (default) or REFERENCE", "enum": ["REFERENCE", "TRACK"], "type": "string" }, "version": { "additionalProperties": false, "description": "The readVersion you got from get_document or get_version, as given", "properties": { "hash": { "description": "Version hash from readVersion", "type": "string" }, "number": { "description": "Version number from readVersion", "type": "integer" } }, "required": ["number", "hash"], "type": "object" } }, "required": ["documentUuid"], "type": "object" }, "type": "array" }, "body": { "description": "Deprecated compatibility alias for typePayload.body when document type is markdown. \uBCF8\uBB38\uC774 \uC218\uC2ED KB \uC774\uC0C1\uC73C\uB85C \uD06C\uBA74 LLM \uD1A0\uD070 \uC808\uC57D\uC744 \uC704\uD574 `request_upload_token (purpose=document.update)` \uB97C \uD638\uCD9C\uD574 uploadUrl \uC744 \uBC1B\uACE0 curl \uB85C \uC9C1\uC811 PUT \uC73C\uB85C \uBCF4\uB0BC \uAC83.", "type": "string" }, "title": { "description": "New title", "type": "string" }, "typePayload": { "additionalProperties": true, "description": "Type-specific payload for enabled document types. markdown: {body}; diagram: {sourceLanguage,edgeStyle,isModule,metadata,diagramSource} \u2014 the canvas is drawn only from nodes/edges/groups made with diagram_apply_changes; diagramSource is optional text kept beside them, never converted, and refused while the diagram has no nodes; openapi: {content}; html: {content} (a full HTML page); file: {file:{filename,contentType,sizeBytes,viewerKind}} (+content for text/CSV, first 64 KB); kanban: no body \u2014 only the title can be updated; cards are changed with kanban_apply_changes and kanban_card_action; design: no body \u2014 only the title can be updated; the canvas is changed with design_apply_changes.", "type": "object" }, "uuid": { "description": "Document UUID", "type": "string" } }, "required": ["uuid"], "type": "object" }, "type": "array" } }, "required": ["items"], "type": "object" }, "required": ["items"], "payloadMode": "file-json", "destructive": true, "sourceCatalog": "prod", "schemaHash": "ef6e145a6a639575" },
|
|
6553
6879
|
{ "mcpName": "update_folders", "commandPath": ["folders", "update"], "group": "generic", "description": "Rename folders (only the name; move_folders moves them). Names do not have to be unique. Needs edit access to the folder. Targets are UUIDs only; names are never matched and may repeat. Look the UUID up first, and when more than one candidate fits what the user said, ask which one. Items run in order and each one commits on its own: the first failing item ends the call with an error, items before it stay applied (the error does not list them), and later items are not tried \u2014 re-read before retrying. Sends no email or inbox notification. Returns updated (folder rows) and count. Fails with 404, 403, or 409 when the folder or a parent folder is archived.\n\nRetries: send a unique clientMutationId with each write; if you retry the same call (for example after a timeout or lost response), send the same clientMutationId and the server returns the first result instead of running it again.", "inputSchema": { "additionalProperties": false, "properties": { "clientMutationId": { "description": "Idempotency key for this call (visible ASCII, at most 128 characters). Reusing it with the same arguments returns the first result (marked idempotentReplay); reusing it with different arguments is rejected with 409.", "maxLength": 128, "minLength": 1, "pattern": "^[\\x21-\\x7E]{1,128}$", "type": "string" }, "items": { "description": "Updates", "items": { "additionalProperties": false, "properties": { "name": { "description": "New name", "type": "string" }, "uuid": { "description": "Folder UUID", "type": "string" } }, "required": ["uuid", "name"], "type": "object" }, "type": "array" } }, "required": ["items"], "type": "object" }, "required": ["items"], "payloadMode": "file-json", "destructive": true, "sourceCatalog": "prod", "schemaHash": "a83ac73386dc3339" },
|
|
6554
|
-
{ "mcpName": "update_project_members", "commandPath": ["project-members", "update"], "group": "generic", "description": 'Change the role of one person who is already invited to or added to a project (a pending invitation too), with the same rules as the AiNecto app. role is required: if the user has not said which role to give, ask them first and never assume one (a call without role is refused with reason ROLE_REQUIRED). Only an owner or admin of the project can change roles; people outside the team can only be VIEWER. Refusals are error GRANT_NOT_ALLOWED with reason, a message to pass on to the user as is (message; messages.ko/en) and nextAction. If the person has no invitation or access on this project itself, the call fails with 404: invite them with invite_project_members instead. To add someone new, use invite_project_members. Targets are UUIDs only; names are never matched and may repeat. Look the UUID up first, and when more than one candidate fits what the user said, ask which one. Example: {"projectUuid":"<uuid>","email":"kim@example.com","role":"EDITOR"} returns {"status":"ROLE_CHANGED","previousRole":"VIEWER","grant":{...,"role":"EDITOR"},...}. Returns status, projectUuid, projectUrl, grant, previousRole and nextAction.\n\nRetries: send a unique clientMutationId with each write; if you retry the same call (for example after a timeout or lost response), send the same clientMutationId and the server returns the first result instead of running it again.', "inputSchema": { "additionalProperties": false, "properties": { "clientMutationId": { "description": "Idempotency key for this call (visible ASCII, at most 128 characters). Reusing it with the same arguments returns the first result (marked idempotentReplay); reusing it with different arguments is rejected with 409.", "maxLength": 128, "minLength": 1, "pattern": "^[\\x21-\\x7E]{1,128}$", "type": "string" }, "email": { "description": "Email address of the person. Give exactly one of email or userId.", "type": "string" }, "projectUuid": { "description": "Project UUID.", "type": "string" }, "role": { "description": "New role (required). If the user has not said which role, ask them first; never assume one. People outside the team can only be VIEWER.", "enum": ["ADMIN", "EDITOR", "VIEWER"], "type": "string" }, "userId": { "description": "User id of the person. Give exactly one of email or userId.", "type": "string" } }, "required": ["projectUuid"], "type": "object" }, "required": ["projectUuid"], "payloadMode": "flags", "destructive":
|
|
6880
|
+
{ "mcpName": "update_project_members", "commandPath": ["project-members", "update"], "group": "generic", "description": 'Change the role of one person who is already invited to or added to a project (a pending invitation too), with the same rules as the AiNecto app. role is required: if the user has not said which role to give, ask them first and never assume one (a call without role is refused with reason ROLE_REQUIRED). Only an owner or admin of the project can change roles; people outside the team can only be VIEWER. Refusals are error GRANT_NOT_ALLOWED with reason, a message to pass on to the user as is (message; messages.ko/en) and nextAction. If the person has no invitation or access on this project itself, the call fails with 404: invite them with invite_project_members instead. To add someone new, use invite_project_members. Targets are UUIDs only; names are never matched and may repeat. Look the UUID up first, and when more than one candidate fits what the user said, ask which one. Example: {"projectUuid":"<uuid>","email":"kim@example.com","role":"EDITOR"} returns {"status":"ROLE_CHANGED","previousRole":"VIEWER","grant":{...,"role":"EDITOR"},...}. Returns status, projectUuid, projectUrl, grant, previousRole and nextAction.\n\nRetries: send a unique clientMutationId with each write; if you retry the same call (for example after a timeout or lost response), send the same clientMutationId and the server returns the first result instead of running it again.', "inputSchema": { "additionalProperties": false, "properties": { "clientMutationId": { "description": "Idempotency key for this call (visible ASCII, at most 128 characters). Reusing it with the same arguments returns the first result (marked idempotentReplay); reusing it with different arguments is rejected with 409.", "maxLength": 128, "minLength": 1, "pattern": "^[\\x21-\\x7E]{1,128}$", "type": "string" }, "email": { "description": "Email address of the person. Give exactly one of email or userId.", "type": "string" }, "projectUuid": { "description": "Project UUID.", "type": "string" }, "role": { "description": "New role (required). If the user has not said which role, ask them first; never assume one. People outside the team can only be VIEWER.", "enum": ["ADMIN", "EDITOR", "VIEWER"], "type": "string" }, "userId": { "description": "User id of the person. Give exactly one of email or userId.", "type": "string" } }, "required": ["projectUuid"], "type": "object" }, "required": ["projectUuid"], "payloadMode": "flags", "destructive": true, "sourceCatalog": "prod", "schemaHash": "75c93f622e212416" },
|
|
6555
6881
|
{ "mcpName": "update_projects", "commandPath": ["projects", "update"], "group": "generic", "description": 'Rename projects or change their description (projectKey cannot be changed here). Omitted fields stay as they are, a blank name is ignored, and description "" clears it. Names do not have to be unique. Needs admin or owner rights on the project. Targets are UUIDs only; names are never matched and may repeat. Look the UUID up first, and when more than one candidate fits what the user said, ask which one. Items run in order and each one commits on its own: the first failing item ends the call with an error, items before it stay applied (the error does not list them), and later items are not tried \u2014 re-read before retrying. Sends no email or inbox notification. Returns updated (project rows) and count. Fails with 404 for an unknown UUID and 403 without rights or when the project or its workspace is archived.\n\nRetries: send a unique clientMutationId with each write; if you retry the same call (for example after a timeout or lost response), send the same clientMutationId and the server returns the first result instead of running it again.', "inputSchema": { "additionalProperties": false, "properties": { "clientMutationId": { "description": "Idempotency key for this call (visible ASCII, at most 128 characters). Reusing it with the same arguments returns the first result (marked idempotentReplay); reusing it with different arguments is rejected with 409.", "maxLength": 128, "minLength": 1, "pattern": "^[\\x21-\\x7E]{1,128}$", "type": "string" }, "items": { "description": "Updates", "items": { "additionalProperties": false, "properties": { "description": { "description": "New description", "type": "string" }, "name": { "description": "New name", "type": "string" }, "uuid": { "description": "Project UUID", "type": "string" } }, "required": ["uuid"], "type": "object" }, "type": "array" } }, "required": ["items"], "type": "object" }, "required": ["items"], "payloadMode": "file-json", "destructive": true, "sourceCatalog": "prod", "schemaHash": "1e87173984d15609" },
|
|
6556
6882
|
{ "mcpName": "update_workspaces", "commandPath": ["workspaces", "update"], "group": "workspace", "description": 'Rename workspaces or change their description. Omitted fields stay as they are, a blank name is ignored, and description "" clears it. Names do not have to be unique. Needs admin or owner rights. Targets are UUIDs only; names are never matched and may repeat. Look the UUID up first, and when more than one candidate fits what the user said, ask which one. Items run in order and each one commits on its own: the first failing item ends the call with an error, items before it stay applied (the error does not list them), and later items are not tried \u2014 re-read before retrying. Sends no email or inbox notification. Returns updated (workspace rows) and count. Fails with 404 for an unknown UUID and 403 without rights or when the workspace is archived.\n\nRetries: send a unique clientMutationId with each write; if you retry the same call (for example after a timeout or lost response), send the same clientMutationId and the server returns the first result instead of running it again.', "inputSchema": { "additionalProperties": false, "properties": { "clientMutationId": { "description": "Idempotency key for this call (visible ASCII, at most 128 characters). Reusing it with the same arguments returns the first result (marked idempotentReplay); reusing it with different arguments is rejected with 409.", "maxLength": 128, "minLength": 1, "pattern": "^[\\x21-\\x7E]{1,128}$", "type": "string" }, "items": { "description": "Updates", "items": { "additionalProperties": false, "properties": { "description": { "description": "New description", "type": "string" }, "name": { "description": "New name", "type": "string" }, "uuid": { "description": "Workspace UUID", "type": "string" } }, "required": ["uuid"], "type": "object" }, "type": "array" } }, "required": ["items"], "type": "object" }, "required": ["items"], "payloadMode": "file-json", "destructive": true, "sourceCatalog": "prod", "schemaHash": "95349c371bc644c8" },
|
|
6557
6883
|
{ "mcpName": "upload_attachments", "commandPath": ["tools", "run", "upload-attachments"], "group": "attachment", "description": "Register files you have already uploaded as attachments of documents. Steps: (1) request_upload_token with purpose=attachment.upload and {documentUuid, filename}; (2) PUT the file bytes with curl to the returned URL; (3) call this with the storageKey from step 1 \u2014 without step 2 it fails. sizeBytes, when given, must equal the uploaded size. A storageKey registers once (409 after that). Files over the server's attachment size limit or beyond the storage quota are refused, and the server decides the stored content type. File documents cannot take attachments. Needs edit access to the document. Items run in order and each one commits on its own: the first failing item ends the call with an error, items before it stay applied (the error does not list them), and later items are not tried \u2014 re-read before retrying. Sends no email or inbox notification. Returns uploaded (attachment rows) and count.\n\nRetries: send a unique clientMutationId with each write; if you retry the same call (for example after a timeout or lost response), send the same clientMutationId and the server returns the first result instead of running it again.", "inputSchema": { "additionalProperties": false, "properties": { "clientMutationId": { "description": "Idempotency key for this call (visible ASCII, at most 128 characters). Reusing it with the same arguments returns the first result (marked idempotentReplay); reusing it with different arguments is rejected with 409.", "maxLength": 128, "minLength": 1, "pattern": "^[\\x21-\\x7E]{1,128}$", "type": "string" }, "items": { "description": "Attachments to register", "items": { "additionalProperties": false, "properties": { "contentType": { "description": "MIME type", "type": "string" }, "documentUuid": { "description": "Parent document UUID", "type": "string" }, "filename": { "description": "Original file name", "type": "string" }, "sizeBytes": { "description": "Size in bytes", "type": "integer" }, "storageKey": { "description": "Storage key returned by request_upload_token purpose=attachment.upload", "type": "string" } }, "required": ["documentUuid", "filename", "storageKey"], "type": "object" }, "type": "array" } }, "required": ["items"], "type": "object" }, "required": ["items"], "payloadMode": "binary-upload", "destructive": false, "sourceCatalog": "prod", "schemaHash": "4b6b98cb4150bc28" }
|
|
@@ -6656,7 +6982,7 @@ Retries: send a unique clientMutationId with each write; if you retry the same c
|
|
|
6656
6982
|
{ "mcpName": "unfavorite_documents", "commandPath": ["tools", "run", "unfavorite-documents"], "group": "document", "description": "Remove documents from the signed-in user's favorites (favorite_documents). Works even for a document the user can no longer open, and a document that was not a favorite is returned the same way. The documents themselves are not changed. Targets are UUIDs only; names are never matched and may repeat. Look the UUID up first, and when more than one candidate fits what the user said, ask which one. Items run in order and each one commits on its own: the first failing item ends the call with an error, items before it stay applied (the error does not list them), and later items are not tried \u2014 re-read before retrying. Returns unfavorited: [{documentUuid, favorited: false}] and count.\n\nRetries: send a unique clientMutationId with each write; if you retry the same call (for example after a timeout or lost response), send the same clientMutationId and the server returns the first result instead of running it again.", "inputSchema": { "additionalProperties": false, "properties": { "clientMutationId": { "description": "Idempotency key for this call (visible ASCII, at most 128 characters). Reusing it with the same arguments returns the first result (marked idempotentReplay); reusing it with different arguments is rejected with 409.", "maxLength": 128, "minLength": 1, "pattern": "^[\\x21-\\x7E]{1,128}$", "type": "string" }, "uuids": { "description": "Document UUIDs to remove from favorites", "items": { "description": "Document UUID", "type": "string" }, "type": "array" } }, "required": ["uuids"], "type": "object" }, "required": ["uuids"], "payloadMode": "file-json", "destructive": true, "sourceCatalog": "dev", "schemaHash": "5464109984aa000d" },
|
|
6657
6983
|
{ "mcpName": "unsubscribe_documents", "commandPath": ["tools", "run", "unsubscribe-documents"], "group": "document", "description": "Stop the signed-in user's subscription to documents (subscribe_documents) \u2014 no more change notifications for them. Works even for a document the user can no longer open, and a document that was not subscribed is returned the same way. Notifications already received stay in the inbox. Targets are UUIDs only; names are never matched and may repeat. Look the UUID up first, and when more than one candidate fits what the user said, ask which one. Items run in order and each one commits on its own: the first failing item ends the call with an error, items before it stay applied (the error does not list them), and later items are not tried \u2014 re-read before retrying. Returns unsubscribed: [{documentUuid, subscribed: false}] and count.\n\nRetries: send a unique clientMutationId with each write; if you retry the same call (for example after a timeout or lost response), send the same clientMutationId and the server returns the first result instead of running it again.", "inputSchema": { "additionalProperties": false, "properties": { "clientMutationId": { "description": "Idempotency key for this call (visible ASCII, at most 128 characters). Reusing it with the same arguments returns the first result (marked idempotentReplay); reusing it with different arguments is rejected with 409.", "maxLength": 128, "minLength": 1, "pattern": "^[\\x21-\\x7E]{1,128}$", "type": "string" }, "uuids": { "description": "Document UUIDs to unsubscribe from", "items": { "description": "Document UUID", "type": "string" }, "type": "array" } }, "required": ["uuids"], "type": "object" }, "required": ["uuids"], "payloadMode": "file-json", "destructive": true, "sourceCatalog": "dev", "schemaHash": "3c032d27d8adc84d" },
|
|
6658
6984
|
{ "mcpName": "update_agent_todos", "commandPath": ["agent-todos", "update"], "group": "generic", "description": "Claim, renew, complete, release, or dismiss the signed-in user's agent to-dos. Only the session holding the current leaseToken may renew, release, or complete a claimed to-do \u2014 even another session of the same connection gets CLAIMED_BY_OTHER. Results are per item: {todoId, ok: true, state, leaseToken?, claimExpiresAt?} or {todoId, ok: false, error} with error one of CLAIMED_BY_OTHER, LEASE_LOST, ALREADY_DONE, CLOSED_BY_HUMAN, SUPERSEDED, ACCESS_LOST, BUSINESS_ACTION_REQUIRED, NOT_FOUND, INVALID \u2014 on CLOSED_BY_HUMAN or SUPERSEDED stop working on it. BUSINESS_ACTION_REQUIRED: card to-dos (CARD_*) cannot be completed here; doing the card action closes them. Retrying the same complete or dismiss returns ok again. To mark the person's notifications read (only when they ask), use mark_notifications_read.\n\nRetries: send a unique clientMutationId with each write; if you retry the same call (for example after a timeout or lost response), send the same clientMutationId and the server returns the first result instead of running it again.", "inputSchema": { "additionalProperties": false, "properties": { "clientMutationId": { "description": "Idempotency key for this call (visible ASCII, at most 128 characters). Reusing it with the same arguments returns the first result (marked idempotentReplay); reusing it with different arguments is rejected with 409.", "maxLength": 128, "minLength": 1, "pattern": "^[\\x21-\\x7E]{1,128}$", "type": "string" }, "items": { "description": "To-dos to update; each item is applied and reported on its own.", "items": { "additionalProperties": false, "properties": { "action": { "description": "claim: take it (returns leaseToken, valid 30 minutes). renew: extend your lease. complete: done (with leaseToken if you claimed it; without one only while it is still OPEN). release: give it back. dismiss: not a to-do.", "enum": ["claim", "renew", "complete", "release", "dismiss"], "type": "string" }, "leaseToken": { "description": "Required for renew and release, and for complete or dismiss of a to-do you claimed.", "type": "string" }, "note": { "description": "For complete or dismiss: one line on what you did (at most 500 characters, no document bodies). The person sees it in the inbox.", "maxLength": 500, "type": "string" }, "todoId": { "description": "todoId from list_agent_todos.", "type": "string" } }, "required": ["todoId", "action"], "type": "object" }, "maxItems": 50, "minItems": 1, "type": "array" } }, "required": ["items"], "type": "object" }, "required": ["items"], "payloadMode": "file-json", "destructive": true, "sourceCatalog": "dev", "schemaHash": "35cde49fba4c9f5f" },
|
|
6659
|
-
{ "mcpName": "update_agents", "commandPath": ["agents", "update"], "group": "generic", "description": "Rename, archive or unarchive the signed-in user's named agents (see list_agents), or set the project an agent works in (projectUuid; display only). Each item commits on its own and a failing item does not stop the others. Results are per item: {agentUuid, ok: true, agent, note?} or {agentUuid, ok: false, error: {code, message}} with code one of AGENT_NOT_FOUND, AGENT_NAME_INVALID, AGENT_NAME_TAKEN, AGENT_HAS_OPEN_WORK (open cards or to-dos still point at the agent \u2014 reassign them first; counts are in openCards and openTodos), PROJECT_NOT_FOUND (no such project, or you cannot read it), AGENT_INVALID. After a rename, change the name in that agent's folder connection settings too, or it connects with the old name again and a new agent appears.\n\nRetries: send a unique clientMutationId with each write; if you retry the same call (for example after a timeout or lost response), send the same clientMutationId and the server returns the first result instead of running it again.", "inputSchema": { "additionalProperties": false, "properties": { "clientMutationId": { "description": "Idempotency key for this call (visible ASCII, at most 128 characters). Reusing it with the same arguments returns the first result (marked idempotentReplay); reusing it with different arguments is rejected with 409.", "maxLength": 128, "minLength": 1, "pattern": "^[\\x21-\\x7E]{1,128}$", "type": "string" }, "items": { "description": "Agents to change; each item is applied and reported on its own.", "items": { "additionalProperties": false, "properties": { "agentUuid": { "description": "agentUuid from list_agents.", "type": "string" }, "archived": { "description": "true archives the agent (it disappears from pickers; its history stays), false brings it back. An archived agent that connects again with its name is brought back automatically.", "type": "boolean" }, "clientMutationId": { "description": "Optional id echoed back in this item's result.", "type": "string" }, "name": { "description": "New name \u2014 lowercase letters, digits, '.', '_' and '-', starting with a letter or digit (stored in lowercase).", "maxLength": 64, "type": "string" }, "projectUuid": { "description": "The project this agent works in (projectUuid from list_projects) \u2014 shown next to the agent in list_agents and when picking an agent for a card. Display only: it does not limit what the agent can do or which cards it can get. An empty string clears it. You must be able to read the project.", "type": "string" } }, "required": ["agentUuid"], "type": "object" }, "maxItems": 50, "minItems": 1, "type": "array" } }, "required": ["items"], "type": "object" }, "required": ["items"], "payloadMode": "file-json", "destructive":
|
|
6985
|
+
{ "mcpName": "update_agents", "commandPath": ["agents", "update"], "group": "generic", "description": "Rename, archive or unarchive the signed-in user's named agents (see list_agents), or set the project an agent works in (projectUuid; display only). Each item commits on its own and a failing item does not stop the others. Results are per item: {agentUuid, ok: true, agent, note?} or {agentUuid, ok: false, error: {code, message}} with code one of AGENT_NOT_FOUND, AGENT_NAME_INVALID, AGENT_NAME_TAKEN, AGENT_HAS_OPEN_WORK (open cards or to-dos still point at the agent \u2014 reassign them first; counts are in openCards and openTodos), PROJECT_NOT_FOUND (no such project, or you cannot read it), AGENT_INVALID. After a rename, change the name in that agent's folder connection settings too, or it connects with the old name again and a new agent appears.\n\nRetries: send a unique clientMutationId with each write; if you retry the same call (for example after a timeout or lost response), send the same clientMutationId and the server returns the first result instead of running it again.", "inputSchema": { "additionalProperties": false, "properties": { "clientMutationId": { "description": "Idempotency key for this call (visible ASCII, at most 128 characters). Reusing it with the same arguments returns the first result (marked idempotentReplay); reusing it with different arguments is rejected with 409.", "maxLength": 128, "minLength": 1, "pattern": "^[\\x21-\\x7E]{1,128}$", "type": "string" }, "items": { "description": "Agents to change; each item is applied and reported on its own.", "items": { "additionalProperties": false, "properties": { "agentUuid": { "description": "agentUuid from list_agents.", "type": "string" }, "archived": { "description": "true archives the agent (it disappears from pickers; its history stays), false brings it back. An archived agent that connects again with its name is brought back automatically.", "type": "boolean" }, "clientMutationId": { "description": "Optional id echoed back in this item's result.", "type": "string" }, "name": { "description": "New name \u2014 lowercase letters, digits, '.', '_' and '-', starting with a letter or digit (stored in lowercase).", "maxLength": 64, "type": "string" }, "projectUuid": { "description": "The project this agent works in (projectUuid from list_projects) \u2014 shown next to the agent in list_agents and when picking an agent for a card. Display only: it does not limit what the agent can do or which cards it can get. An empty string clears it. You must be able to read the project.", "type": "string" } }, "required": ["agentUuid"], "type": "object" }, "maxItems": 50, "minItems": 1, "type": "array" } }, "required": ["items"], "type": "object" }, "required": ["items"], "payloadMode": "file-json", "destructive": true, "sourceCatalog": "dev", "schemaHash": "04b7bb798d169034" },
|
|
6660
6986
|
{ "mcpName": "update_comments", "commandPath": ["comments", "update"], "group": "generic", "description": "Edit your own comments on a document or a kanban card (cardUuid). Only the author can edit, and only while they can still read it. A resolved question and a top-level comment that already has replies are locked. Items are applied in order and each one commits on its own; results report each item.\n\nRetries: send a unique clientMutationId with each write; if you retry the same call (for example after a timeout or lost response), send the same clientMutationId and the server returns the first result instead of running it again.", "inputSchema": { "additionalProperties": false, "properties": { "cardUuid": { "description": "Kanban card UUID the comments belong to (from kanban_list_cards). Anyone who can read the card's board may comment. Give this or documentUuid, not both.", "type": "string" }, "clientMutationId": { "description": "Idempotency key for this call (visible ASCII, at most 128 characters). Reusing it with the same arguments returns the first result (marked idempotentReplay); reusing it with different arguments is rejected with 409.", "maxLength": 128, "minLength": 1, "pattern": "^[\\x21-\\x7E]{1,128}$", "type": "string" }, "documentUuid": { "description": "Document UUID the comments belong to. Give this or cardUuid, not both.", "type": "string" }, "items": { "description": "Edits, applied in order", "items": { "additionalProperties": false, "properties": { "body": { "description": "New comment text (replaces the old text).", "maxLength": 1e4, "minLength": 1, "type": "string" }, "clientMutationId": { "description": "Idempotency key (visible ASCII, at most 128 characters). Required when mentionUserIds is not empty; reuse the same value when retrying the same item so the mention email is not sent twice.", "maxLength": 128, "type": "string" }, "id": { "description": "Comment id (from mcp__ainecto__list_comments)", "minimum": 1, "type": "integer" }, "mentionUserIds": { "description": "The complete set of userIds mentioned after the edit; omit to remove all mentions. Each one's @<displayName> must appear in body. Only people who were not mentioned before get a notification email.", "items": { "type": "string" }, "maxItems": 20, "type": "array", "uniqueItems": true } }, "required": ["id", "body"], "type": "object" }, "minItems": 1, "type": "array" }, "mailLanguage": { "description": "Language of the comment notification email (mention or reply). Defaults to en.", "enum": ["en", "ko"], "type": "string" } }, "required": ["items"], "type": "object" }, "required": ["items"], "payloadMode": "file-json", "destructive": true, "sourceCatalog": "dev", "schemaHash": "04ef0a3cecca04ee" },
|
|
6661
6987
|
{ "mcpName": "update_documents", "commandPath": ["documents", "update"], "group": "document", "description": "Update documents: the title and/or the whole body. A body you send replaces the current body entirely \u2014 it is not a patch, so read the document first and send the full new text. The document type decides the body field (see body and typePayload): file documents can only be renamed, ERD content changes through erd_apply_changes, diagram nodes and edges through diagram_apply_changes, and board documents are refused. Every body change is kept in version history, so list_versions and restore_versions can undo it. Needs edit access. Items run in order and each one commits on its own: the first failing item ends the call with an error, items before it stay applied (the error does not list them), and later items are not tried \u2014 re-read before retrying. Returns updated (document rows) and count. Fails with 409 when the document is in the trash or its folder, project or workspace is archived. If a replacement body is tens of KB or more, prefer request_upload_token (purpose=document.update) and upload the body with curl. While you write a document, people who open it see that an AI agent is writing it (with your agent name and the time of your last write). When the document is complete, call finish_documents; otherwise the notice ends 10 minutes after your last write.\n\nRetries: send a unique clientMutationId with each write; if you retry the same call (for example after a timeout or lost response), send the same clientMutationId and the server returns the first result instead of running it again.", "inputSchema": { "additionalProperties": false, "properties": { "clientMutationId": { "description": "Idempotency key for this call (visible ASCII, at most 128 characters). Reusing it with the same arguments returns the first result (marked idempotentReplay); reusing it with different arguments is rejected with 409.", "maxLength": 128, "minLength": 1, "pattern": "^[\\x21-\\x7E]{1,128}$", "type": "string" }, "items": { "description": "Updates", "items": { "additionalProperties": false, "properties": { "basedOn": { "description": "Documents this one is based on (at most 50). kind TRACK (default) records the source version and tells this document's owner when the source is updated so they can review it; REFERENCE is a plain link. If you read the source with get_document (or get_version), pass its readVersion as version \u2014 if that version was overwritten after you read it you get 409, read again. If readVersion is null (changes not yet saved as a version, or a type whose get_document does not return the whole content) read it with get_version and pass that readVersion, or omit version (always omit it when get_version's readVersion is null too). Omitting version records the latest version at save time and does not prove what you read. An existing tracking relation is confirmed to that version; an existing reference is promoted to tracking; kind REFERENCE never demotes a tracking relation (use document_relations SET_KIND). Relations not listed are left as they are.", "items": { "additionalProperties": false, "properties": { "documentUuid": { "description": "Source document UUID", "type": "string" }, "kind": { "description": "TRACK (default) or REFERENCE", "enum": ["REFERENCE", "TRACK"], "type": "string" }, "version": { "additionalProperties": false, "description": "The readVersion you got from get_document or get_version, as given", "properties": { "hash": { "description": "Version hash from readVersion", "type": "string" }, "number": { "description": "Version number from readVersion", "type": "integer" } }, "required": ["number", "hash"], "type": "object" } }, "required": ["documentUuid"], "type": "object" }, "type": "array" }, "body": { "description": "Deprecated compatibility alias for typePayload.body when document type is markdown. \uBCF8\uBB38\uC774 \uC218\uC2ED KB \uC774\uC0C1\uC73C\uB85C \uD06C\uBA74 LLM \uD1A0\uD070 \uC808\uC57D\uC744 \uC704\uD574 `request_upload_token (purpose=document.update)` \uB97C \uD638\uCD9C\uD574 uploadUrl \uC744 \uBC1B\uACE0 curl \uB85C \uC9C1\uC811 PUT \uC73C\uB85C \uBCF4\uB0BC \uAC83.", "type": "string" }, "title": { "description": "New title", "type": "string" }, "typePayload": { "additionalProperties": true, "description": "Type-specific payload for enabled document types. markdown: {body}; diagram: {sourceLanguage,edgeStyle,isModule,metadata,diagramSource} \u2014 the canvas is drawn only from nodes/edges/groups made with diagram_apply_changes; diagramSource is optional text kept beside them, never converted, and refused while the diagram has no nodes; openapi: {content}; html: {content} (a full HTML page); file: {file:{filename,contentType,sizeBytes,viewerKind}} (+content for text/CSV, first 64 KB); kanban: no body \u2014 only the title can be updated; cards are changed with kanban_apply_changes and kanban_card_action; design: no body \u2014 only the title can be updated; the canvas is changed with design_apply_changes.", "type": "object" }, "uuid": { "description": "Document UUID", "type": "string" } }, "required": ["uuid"], "type": "object" }, "type": "array" } }, "required": ["items"], "type": "object" }, "required": ["items"], "payloadMode": "file-json", "destructive": true, "sourceCatalog": "dev", "schemaHash": "1f2fb8cb13186980" },
|
|
6662
6988
|
{ "mcpName": "update_folders", "commandPath": ["folders", "update"], "group": "generic", "description": "Rename folders (only the name; move_folders moves them). Names do not have to be unique. Needs edit access to the folder. Targets are UUIDs only; names are never matched and may repeat. Look the UUID up first, and when more than one candidate fits what the user said, ask which one. Items run in order and each one commits on its own: the first failing item ends the call with an error, items before it stay applied (the error does not list them), and later items are not tried \u2014 re-read before retrying. Sends no email or inbox notification. Returns updated (folder rows) and count. Fails with 404, 403, or 409 when the folder or a parent folder is archived.\n\nRetries: send a unique clientMutationId with each write; if you retry the same call (for example after a timeout or lost response), send the same clientMutationId and the server returns the first result instead of running it again.", "inputSchema": { "additionalProperties": false, "properties": { "clientMutationId": { "description": "Idempotency key for this call (visible ASCII, at most 128 characters). Reusing it with the same arguments returns the first result (marked idempotentReplay); reusing it with different arguments is rejected with 409.", "maxLength": 128, "minLength": 1, "pattern": "^[\\x21-\\x7E]{1,128}$", "type": "string" }, "items": { "description": "Updates", "items": { "additionalProperties": false, "properties": { "name": { "description": "New name", "type": "string" }, "uuid": { "description": "Folder UUID", "type": "string" } }, "required": ["uuid", "name"], "type": "object" }, "type": "array" } }, "required": ["items"], "type": "object" }, "required": ["items"], "payloadMode": "file-json", "destructive": true, "sourceCatalog": "dev", "schemaHash": "a83ac73386dc3339" },
|
|
@@ -6665,145 +6991,17 @@ Retries: send a unique clientMutationId with each write; if you retry the same c
|
|
|
6665
6991
|
{ "mcpName": "upload_attachments", "commandPath": ["tools", "run", "upload-attachments"], "group": "attachment", "description": "Register files you have already uploaded as attachments of documents. Steps: (1) request_upload_token with purpose=attachment.upload and {documentUuid, filename}; (2) PUT the file bytes with curl to the returned URL; (3) call this with the storageKey from step 1 \u2014 without step 2 it fails. sizeBytes, when given, must equal the uploaded size. A storageKey registers once (409 after that). Files over the server's attachment size limit or beyond the storage quota are refused, and the server decides the stored content type. File documents cannot take attachments. Needs edit access to the document. Items run in order and each one commits on its own: the first failing item ends the call with an error, items before it stay applied (the error does not list them), and later items are not tried \u2014 re-read before retrying. Sends no email or inbox notification. Returns uploaded (attachment rows) and count.\n\nRetries: send a unique clientMutationId with each write; if you retry the same call (for example after a timeout or lost response), send the same clientMutationId and the server returns the first result instead of running it again.", "inputSchema": { "additionalProperties": false, "properties": { "clientMutationId": { "description": "Idempotency key for this call (visible ASCII, at most 128 characters). Reusing it with the same arguments returns the first result (marked idempotentReplay); reusing it with different arguments is rejected with 409.", "maxLength": 128, "minLength": 1, "pattern": "^[\\x21-\\x7E]{1,128}$", "type": "string" }, "items": { "description": "Attachments to register", "items": { "additionalProperties": false, "properties": { "contentType": { "description": "MIME type", "type": "string" }, "documentUuid": { "description": "Parent document UUID", "type": "string" }, "filename": { "description": "Original file name", "type": "string" }, "sizeBytes": { "description": "Size in bytes", "type": "integer" }, "storageKey": { "description": "Storage key returned by request_upload_token purpose=attachment.upload", "type": "string" } }, "required": ["documentUuid", "filename", "storageKey"], "type": "object" }, "type": "array" } }, "required": ["items"], "type": "object" }, "required": ["items"], "payloadMode": "binary-upload", "destructive": false, "sourceCatalog": "dev", "schemaHash": "4b6b98cb4150bc28" }
|
|
6666
6992
|
];
|
|
6667
6993
|
|
|
6668
|
-
// src/core/catalog/generator.ts
|
|
6669
|
-
import { createHash as createHash3 } from "crypto";
|
|
6670
|
-
var LEGACY_PREFIX = "mcp__ainecto__";
|
|
6671
|
-
function bareToolName(name) {
|
|
6672
|
-
return name.startsWith(LEGACY_PREFIX) ? name.slice(LEGACY_PREFIX.length) : name;
|
|
6673
|
-
}
|
|
6674
|
-
var DESTRUCTIVE_PREFIXES = [
|
|
6675
|
-
"delete_",
|
|
6676
|
-
"remove_",
|
|
6677
|
-
"archive_",
|
|
6678
|
-
"unarchive_",
|
|
6679
|
-
"restore_",
|
|
6680
|
-
"move_",
|
|
6681
|
-
"erd_delete_",
|
|
6682
|
-
"erd_remove_",
|
|
6683
|
-
"testcase_delete_"
|
|
6684
|
-
];
|
|
6685
|
-
function generateCatalog(tools, sourceCatalog) {
|
|
6686
|
-
return tools.map((tool) => normalizeTool(tool, sourceCatalog)).sort((a, b) => a.mcpName.localeCompare(b.mcpName));
|
|
6687
|
-
}
|
|
6688
|
-
function normalizeTool(tool, sourceCatalog) {
|
|
6689
|
-
if (!tool.name) {
|
|
6690
|
-
throw new Error("Unsupported tool name: empty.");
|
|
6691
|
-
}
|
|
6692
|
-
const stripped = bareToolName(tool.name);
|
|
6693
|
-
const group = inferGroup(stripped);
|
|
6694
|
-
const inputSchema = normalizeSchema(tool.inputSchema ?? { type: "object", properties: {} });
|
|
6695
|
-
const required = Array.isArray(inputSchema.required) ? inputSchema.required.filter((value) => typeof value === "string").sort() : [];
|
|
6696
|
-
const definition = {
|
|
6697
|
-
mcpName: tool.name,
|
|
6698
|
-
commandPath: generateCommandPath(stripped, group),
|
|
6699
|
-
group,
|
|
6700
|
-
description: tool.description ?? "",
|
|
6701
|
-
inputSchema,
|
|
6702
|
-
required,
|
|
6703
|
-
payloadMode: inferPayloadMode(stripped, inputSchema),
|
|
6704
|
-
destructive: inferDestructive(stripped, tool),
|
|
6705
|
-
sourceCatalog,
|
|
6706
|
-
schemaHash: ""
|
|
6707
|
-
};
|
|
6708
|
-
return { ...definition, schemaHash: computeSchemaHash(definition) };
|
|
6709
|
-
}
|
|
6710
|
-
function inferGroup(strippedName) {
|
|
6711
|
-
if (strippedName.startsWith("erd_")) return "erd";
|
|
6712
|
-
if (strippedName.startsWith("flow_")) return "flow";
|
|
6713
|
-
if (strippedName.startsWith("testcase_")) return "testcase";
|
|
6714
|
-
if (strippedName.startsWith("markdown_")) return "markdown";
|
|
6715
|
-
if (strippedName.includes("attachment") || strippedName.includes("upload")) return "attachment";
|
|
6716
|
-
if (strippedName.startsWith("kanban_")) return "kanban";
|
|
6717
|
-
if (strippedName.includes("workspace")) return "workspace";
|
|
6718
|
-
if (strippedName.includes("document")) return "document";
|
|
6719
|
-
return "generic";
|
|
6720
|
-
}
|
|
6721
|
-
function generateCommandPath(strippedName, group) {
|
|
6722
|
-
if (group !== "generic" && strippedName.startsWith(`${group}_`)) {
|
|
6723
|
-
return [group, snakeToKebab(strippedName.slice(group.length + 1))];
|
|
6724
|
-
}
|
|
6725
|
-
const [verb, ...rest] = strippedName.split("_");
|
|
6726
|
-
if (verb && rest.length > 0 && isVerb(verb)) {
|
|
6727
|
-
return [rest.join("-"), verb];
|
|
6728
|
-
}
|
|
6729
|
-
return ["tools", "run", snakeToKebab(strippedName)];
|
|
6730
|
-
}
|
|
6731
|
-
function inferPayloadMode(strippedName, inputSchema) {
|
|
6732
|
-
if (strippedName.includes("upload") || strippedName.includes("attachment_upload")) {
|
|
6733
|
-
return "binary-upload";
|
|
6734
|
-
}
|
|
6735
|
-
const properties = inputSchema.properties;
|
|
6736
|
-
if (!isRecord4(properties)) {
|
|
6737
|
-
return "flags";
|
|
6738
|
-
}
|
|
6739
|
-
const values = Object.values(properties);
|
|
6740
|
-
if (values.length === 0) {
|
|
6741
|
-
return "flags";
|
|
6742
|
-
}
|
|
6743
|
-
if (values.every(isScalarSchema)) {
|
|
6744
|
-
return "flags";
|
|
6745
|
-
}
|
|
6746
|
-
return "file-json";
|
|
6747
|
-
}
|
|
6748
|
-
function inferDestructive(strippedName, tool) {
|
|
6749
|
-
if (tool.annotations?.destructiveHint === true) {
|
|
6750
|
-
return true;
|
|
6751
|
-
}
|
|
6752
|
-
return DESTRUCTIVE_PREFIXES.some((prefix) => strippedName.startsWith(prefix));
|
|
6753
|
-
}
|
|
6754
|
-
function computeSchemaHash(tool) {
|
|
6755
|
-
return createHash3("sha256").update(stableStringify({
|
|
6756
|
-
name: tool.mcpName,
|
|
6757
|
-
description: tool.description,
|
|
6758
|
-
inputSchema: tool.inputSchema
|
|
6759
|
-
})).digest("hex").slice(0, 16);
|
|
6760
|
-
}
|
|
6761
|
-
function stableStringify(value) {
|
|
6762
|
-
if (Array.isArray(value)) {
|
|
6763
|
-
return `[${value.map(stableStringify).join(",")}]`;
|
|
6764
|
-
}
|
|
6765
|
-
if (isRecord4(value)) {
|
|
6766
|
-
return `{${Object.keys(value).sort().map((key) => `${JSON.stringify(key)}:${stableStringify(value[key])}`).join(",")}}`;
|
|
6767
|
-
}
|
|
6768
|
-
return JSON.stringify(value);
|
|
6769
|
-
}
|
|
6770
|
-
function normalizeSchema(schema) {
|
|
6771
|
-
return JSON.parse(stableStringify(schema));
|
|
6772
|
-
}
|
|
6773
|
-
function isScalarSchema(value) {
|
|
6774
|
-
if (!isRecord4(value)) {
|
|
6775
|
-
return false;
|
|
6776
|
-
}
|
|
6777
|
-
const type = value.type;
|
|
6778
|
-
return type === "string" || type === "number" || type === "integer" || type === "boolean";
|
|
6779
|
-
}
|
|
6780
|
-
function isVerb(value) {
|
|
6781
|
-
return [
|
|
6782
|
-
"list",
|
|
6783
|
-
"get",
|
|
6784
|
-
"create",
|
|
6785
|
-
"update",
|
|
6786
|
-
"delete",
|
|
6787
|
-
"move",
|
|
6788
|
-
"restore",
|
|
6789
|
-
"archive",
|
|
6790
|
-
"unarchive",
|
|
6791
|
-
"search"
|
|
6792
|
-
].includes(value);
|
|
6793
|
-
}
|
|
6794
|
-
function snakeToKebab(value) {
|
|
6795
|
-
return value.replaceAll("_", "-");
|
|
6796
|
-
}
|
|
6797
|
-
function isRecord4(value) {
|
|
6798
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
6799
|
-
}
|
|
6800
|
-
|
|
6801
6994
|
// src/core/catalog/index.ts
|
|
6802
6995
|
function getGeneratedTools(env) {
|
|
6803
6996
|
return env === "dev" ? generatedTools2 : generatedTools;
|
|
6804
6997
|
}
|
|
6805
6998
|
async function loadLiveTools(env, client) {
|
|
6806
|
-
|
|
6999
|
+
const lines = await listAllOperations({ toolsList: () => client.toolsList(), callPublic: (tool, args) => client.toolsCall(tool, args) });
|
|
7000
|
+
return generateCatalog(lines.map((line) => ({ name: line.operation, description: line.summary })), env);
|
|
7001
|
+
}
|
|
7002
|
+
async function loadLiveTool(env, client, operation) {
|
|
7003
|
+
const detail = await client.operations.detail(operation);
|
|
7004
|
+
return normalizeTool({ name: detail.operation, description: detail.summary, inputSchema: detail.inputSchema, annotations: detail.annotations }, env);
|
|
6807
7005
|
}
|
|
6808
7006
|
|
|
6809
7007
|
// src/core/mcp/stdioBridge.ts
|
|
@@ -6844,7 +7042,7 @@ var INVALID_REQUEST = -32600;
|
|
|
6844
7042
|
var INTERNAL_ERROR = -32603;
|
|
6845
7043
|
var RATE_LIMITED_CODE = 429;
|
|
6846
7044
|
function failure(id, code, error) {
|
|
6847
|
-
const data = error instanceof McpRpcError ? { code: error.code, ...
|
|
7045
|
+
const data = error instanceof McpRpcError ? { code: error.code, ...isRecord7(error.details) ? error.details : {} } : void 0;
|
|
6848
7046
|
return {
|
|
6849
7047
|
jsonrpc: "2.0",
|
|
6850
7048
|
id,
|
|
@@ -6860,7 +7058,7 @@ function writeLine(output, message2) {
|
|
|
6860
7058
|
}
|
|
6861
7059
|
function parseJsonRpcRequest(line) {
|
|
6862
7060
|
const parsed = JSON.parse(line);
|
|
6863
|
-
if (!
|
|
7061
|
+
if (!isRecord7(parsed) || parsed.jsonrpc !== "2.0" || typeof parsed.method !== "string") {
|
|
6864
7062
|
throw new Error("Invalid JSON-RPC request.");
|
|
6865
7063
|
}
|
|
6866
7064
|
return {
|
|
@@ -6871,9 +7069,9 @@ function parseJsonRpcRequest(line) {
|
|
|
6871
7069
|
};
|
|
6872
7070
|
}
|
|
6873
7071
|
function clientInfoName(params) {
|
|
6874
|
-
return
|
|
7072
|
+
return isRecord7(params) && isRecord7(params.clientInfo) ? params.clientInfo.name : void 0;
|
|
6875
7073
|
}
|
|
6876
|
-
function
|
|
7074
|
+
function isRecord7(value) {
|
|
6877
7075
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
6878
7076
|
}
|
|
6879
7077
|
|
|
@@ -6913,7 +7111,7 @@ function renderCodexConfig(entry) {
|
|
|
6913
7111
|
`;
|
|
6914
7112
|
}
|
|
6915
7113
|
function isOurEntry(entry, endpoint) {
|
|
6916
|
-
if (
|
|
7114
|
+
if (isRecord8(entry) && typeof entry.url === "string") {
|
|
6917
7115
|
const url = normalizedServerUrl(entry.url);
|
|
6918
7116
|
return url !== void 0 && (url === endpoint || isDefaultEndpoint(url));
|
|
6919
7117
|
}
|
|
@@ -6940,10 +7138,10 @@ function buildServerEntry(input = {}) {
|
|
|
6940
7138
|
return { command: "npx", args };
|
|
6941
7139
|
}
|
|
6942
7140
|
function entryCarriesRole(entry) {
|
|
6943
|
-
return
|
|
7141
|
+
return isRecord8(entry) && Array.isArray(entry.args) && entry.args.includes("--role");
|
|
6944
7142
|
}
|
|
6945
7143
|
function pinnedBridgeVersion(entry) {
|
|
6946
|
-
if (!
|
|
7144
|
+
if (!isRecord8(entry) || !Array.isArray(entry.args)) {
|
|
6947
7145
|
return void 0;
|
|
6948
7146
|
}
|
|
6949
7147
|
const pinned = entry.args.find((arg) => typeof arg === "string" && arg.startsWith(`${PACKAGE_NAME}@`));
|
|
@@ -6956,13 +7154,13 @@ function readServerEntry(existing) {
|
|
|
6956
7154
|
try {
|
|
6957
7155
|
const parsed = JSON.parse(existing);
|
|
6958
7156
|
const servers = parsed?.mcpServers;
|
|
6959
|
-
return
|
|
7157
|
+
return isRecord8(servers) ? servers[SERVER_NAME] : void 0;
|
|
6960
7158
|
} catch {
|
|
6961
7159
|
return void 0;
|
|
6962
7160
|
}
|
|
6963
7161
|
}
|
|
6964
7162
|
function isOurBridge(entry) {
|
|
6965
|
-
if (!
|
|
7163
|
+
if (!isRecord8(entry)) {
|
|
6966
7164
|
return false;
|
|
6967
7165
|
}
|
|
6968
7166
|
const { command, args } = entry;
|
|
@@ -7006,7 +7204,7 @@ function readServers(root) {
|
|
|
7006
7204
|
if (servers === void 0) {
|
|
7007
7205
|
return {};
|
|
7008
7206
|
}
|
|
7009
|
-
if (!
|
|
7207
|
+
if (!isRecord8(servers)) {
|
|
7010
7208
|
throw new Error(
|
|
7011
7209
|
'Existing MCP config has an "mcpServers" value that is not an object, so it was left untouched. Fix it by hand and run init again.'
|
|
7012
7210
|
);
|
|
@@ -7025,7 +7223,7 @@ function parseConfigObject(existing) {
|
|
|
7025
7223
|
`Existing MCP config is not valid JSON, so it was left untouched. Fix it by hand and run init again. (${error instanceof Error ? error.message : String(error)})`
|
|
7026
7224
|
);
|
|
7027
7225
|
}
|
|
7028
|
-
if (!
|
|
7226
|
+
if (!isRecord8(parsed)) {
|
|
7029
7227
|
throw new Error("Existing MCP config must be a JSON object; it was left untouched.");
|
|
7030
7228
|
}
|
|
7031
7229
|
return parsed;
|
|
@@ -7034,7 +7232,7 @@ function stringify(value) {
|
|
|
7034
7232
|
return `${JSON.stringify(value, null, 2)}
|
|
7035
7233
|
`;
|
|
7036
7234
|
}
|
|
7037
|
-
function
|
|
7235
|
+
function isRecord8(value) {
|
|
7038
7236
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
7039
7237
|
}
|
|
7040
7238
|
|
|
@@ -7089,14 +7287,16 @@ user's AiNecto permissions on the workspace, project, or document it touches \u2
|
|
|
7089
7287
|
what the user may not do. A refusal is an answer: report it to the user instead of looking for a
|
|
7090
7288
|
way around it.
|
|
7091
7289
|
|
|
7092
|
-
|
|
7093
|
-
\`
|
|
7290
|
+
AiNecto has two kinds of tools: \`search\` finds an operation and its input format, and the
|
|
7291
|
+
\`execute_*\` tools run it as \`{operation, args}\` \u2014 \`search\` with \`{"operation": "<name>"}\` says
|
|
7292
|
+
which \`execute_*\` runs it. Find the project and document for the task with the operations
|
|
7293
|
+
\`list_projects\`, \`search_documents\` and \`get_document\` \u2014 this repository is not bound to one project.
|
|
7094
7294
|
|
|
7095
|
-
## When
|
|
7295
|
+
## When an operation is missing
|
|
7096
7296
|
|
|
7097
|
-
|
|
7098
|
-
was added. Start a new session, or
|
|
7099
|
-
\`npx -y ainecto@latest tools call <
|
|
7297
|
+
Operations are listed by \`search\`, so a new one needs no new tool. If an \`execute_*\` tool is not in
|
|
7298
|
+
your tool list, this session started before it was added. Start a new session, or run the operation
|
|
7299
|
+
from the repository with \`npx -y ainecto@latest tools call <operation> '<json>'\`.
|
|
7100
7300
|
|
|
7101
7301
|
## Commands
|
|
7102
7302
|
|
|
@@ -7552,7 +7752,7 @@ var enrichments = [
|
|
|
7552
7752
|
// src/core/output/table.ts
|
|
7553
7753
|
function renderTable(data, options = {}) {
|
|
7554
7754
|
const rows = extractRows(data);
|
|
7555
|
-
if (!rows.length || !rows.every(
|
|
7755
|
+
if (!rows.length || !rows.every(isRecord9)) {
|
|
7556
7756
|
return void 0;
|
|
7557
7757
|
}
|
|
7558
7758
|
const columns = options.columns?.length ? options.columns : inferColumns(rows);
|
|
@@ -7569,7 +7769,7 @@ function extractRows(data) {
|
|
|
7569
7769
|
if (Array.isArray(data)) {
|
|
7570
7770
|
return data;
|
|
7571
7771
|
}
|
|
7572
|
-
if (
|
|
7772
|
+
if (isRecord9(data)) {
|
|
7573
7773
|
for (const key of ["items", "projects", "workspaces", "folders", "documents", "tasks", "attachments", "results", "data"]) {
|
|
7574
7774
|
const value = data[key];
|
|
7575
7775
|
if (Array.isArray(value)) {
|
|
@@ -7597,7 +7797,7 @@ function formatCell(value) {
|
|
|
7597
7797
|
}
|
|
7598
7798
|
return String(value);
|
|
7599
7799
|
}
|
|
7600
|
-
function
|
|
7800
|
+
function isRecord9(value) {
|
|
7601
7801
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
7602
7802
|
}
|
|
7603
7803
|
|
|
@@ -7650,7 +7850,7 @@ function payloadToArgs(value) {
|
|
|
7650
7850
|
if (value === void 0 || value === null) {
|
|
7651
7851
|
return {};
|
|
7652
7852
|
}
|
|
7653
|
-
if (!
|
|
7853
|
+
if (!isRecord10(value)) {
|
|
7654
7854
|
throw new CliCommandError("INVALID_PAYLOAD", "Generated command payload must be a JSON object.", { value });
|
|
7655
7855
|
}
|
|
7656
7856
|
return { ...value };
|
|
@@ -7754,12 +7954,12 @@ function coerceFlagValue(value, schema, key) {
|
|
|
7754
7954
|
}
|
|
7755
7955
|
function getSchemaProperties(schema) {
|
|
7756
7956
|
const properties = schema.properties;
|
|
7757
|
-
if (!
|
|
7957
|
+
if (!isRecord10(properties)) {
|
|
7758
7958
|
return {};
|
|
7759
7959
|
}
|
|
7760
7960
|
const result = {};
|
|
7761
7961
|
for (const [key, value] of Object.entries(properties)) {
|
|
7762
|
-
if (
|
|
7962
|
+
if (isRecord10(value)) {
|
|
7763
7963
|
result[key] = value;
|
|
7764
7964
|
}
|
|
7765
7965
|
}
|
|
@@ -7774,7 +7974,7 @@ function requireValue(flag, value) {
|
|
|
7774
7974
|
}
|
|
7775
7975
|
return value;
|
|
7776
7976
|
}
|
|
7777
|
-
function
|
|
7977
|
+
function isRecord10(value) {
|
|
7778
7978
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
7779
7979
|
}
|
|
7780
7980
|
|
|
@@ -7841,8 +8041,10 @@ async function executeGeneratedCommand(options) {
|
|
|
7841
8041
|
return 2;
|
|
7842
8042
|
}
|
|
7843
8043
|
const parsed = await parseGeneratedCommandArgs(route.tool, route.rest, options.io.stdin);
|
|
8044
|
+
const detail = await options.client.operationDetailFor(route.tool.mcpName);
|
|
8045
|
+
const destructive = detail && typeof detail.annotations.destructiveHint === "boolean" ? inferDestructive(bareToolName(route.tool.mcpName), { name: route.tool.mcpName, annotations: detail.annotations }) : route.tool.destructive;
|
|
7844
8046
|
await confirmDestructiveCommand({
|
|
7845
|
-
tool: route.tool,
|
|
8047
|
+
tool: { ...route.tool, destructive },
|
|
7846
8048
|
yes: parsed.yes,
|
|
7847
8049
|
json: options.json,
|
|
7848
8050
|
io: options.io
|
|
@@ -7902,50 +8104,6 @@ function findRestStart(argv, commandPath) {
|
|
|
7902
8104
|
// src/core/upload/attachmentUpload.ts
|
|
7903
8105
|
import { readFile as readFile4, stat as stat3 } from "fs/promises";
|
|
7904
8106
|
import { basename as basename2, extname } from "path";
|
|
7905
|
-
|
|
7906
|
-
// src/core/mcp/toolPayload.ts
|
|
7907
|
-
function unwrapMcpToolPayload(value) {
|
|
7908
|
-
if (!isRecord9(value) || !Array.isArray(value.content)) {
|
|
7909
|
-
return value;
|
|
7910
|
-
}
|
|
7911
|
-
const text2 = value.content.map((item) => isRecord9(item) && typeof item.text === "string" ? item.text : "").find((itemText) => itemText.trim().startsWith("{"));
|
|
7912
|
-
if (!text2) {
|
|
7913
|
-
return value;
|
|
7914
|
-
}
|
|
7915
|
-
try {
|
|
7916
|
-
return JSON.parse(text2);
|
|
7917
|
-
} catch {
|
|
7918
|
-
return value;
|
|
7919
|
-
}
|
|
7920
|
-
}
|
|
7921
|
-
function toolErrorText(value) {
|
|
7922
|
-
if (!isRecord9(value) || !Array.isArray(value.content)) {
|
|
7923
|
-
return "The tool returned an error.";
|
|
7924
|
-
}
|
|
7925
|
-
const text2 = value.content.map((item) => isRecord9(item) && typeof item.text === "string" ? item.text : "").filter(Boolean).join("\n");
|
|
7926
|
-
return text2 || "The tool returned an error.";
|
|
7927
|
-
}
|
|
7928
|
-
function isRecord9(value) {
|
|
7929
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
7930
|
-
}
|
|
7931
|
-
function extractProjects(value) {
|
|
7932
|
-
const candidates = Array.isArray(value) ? value : isRecord9(value) ? ["projects", "items", "created", "data", "hits"].flatMap((key) => {
|
|
7933
|
-
const nested = value[key];
|
|
7934
|
-
return Array.isArray(nested) ? nested : [];
|
|
7935
|
-
}) : [];
|
|
7936
|
-
const projects = [];
|
|
7937
|
-
for (const candidate of candidates) {
|
|
7938
|
-
if (isRecord9(candidate) && typeof candidate.uuid === "string") {
|
|
7939
|
-
projects.push({
|
|
7940
|
-
uuid: candidate.uuid,
|
|
7941
|
-
name: typeof candidate.name === "string" ? candidate.name : candidate.uuid
|
|
7942
|
-
});
|
|
7943
|
-
}
|
|
7944
|
-
}
|
|
7945
|
-
return projects;
|
|
7946
|
-
}
|
|
7947
|
-
|
|
7948
|
-
// src/core/upload/attachmentUpload.ts
|
|
7949
8107
|
var AttachmentUploadError = class extends Error {
|
|
7950
8108
|
constructor(code, message2, details) {
|
|
7951
8109
|
super(message2);
|
|
@@ -7975,8 +8133,8 @@ async function uploadAttachments(client, input) {
|
|
|
7975
8133
|
documentUuid: input.documentUuid,
|
|
7976
8134
|
maxBytes: input.maxBytes,
|
|
7977
8135
|
ttlSeconds: input.ttlSeconds,
|
|
7978
|
-
requestToolName: input.requestToolName ?? "
|
|
7979
|
-
commitToolName: input.commitToolName ?? "
|
|
8136
|
+
requestToolName: input.requestToolName ?? "request_upload_token",
|
|
8137
|
+
commitToolName: input.commitToolName ?? "upload_attachments",
|
|
7980
8138
|
fetchImpl,
|
|
7981
8139
|
onProgress: input.onProgress,
|
|
7982
8140
|
index,
|
|
@@ -8043,7 +8201,7 @@ async function requestUploadToken(client, metadata, context) {
|
|
|
8043
8201
|
requestArgs.ttlSeconds = context.ttlSeconds;
|
|
8044
8202
|
}
|
|
8045
8203
|
const response = unwrapMcpToolPayload(await client.toolsCall(context.requestToolName, requestArgs));
|
|
8046
|
-
if (!
|
|
8204
|
+
if (!isRecord11(response)) {
|
|
8047
8205
|
throw new AttachmentUploadError("UPLOAD_TOKEN_PROTOCOL_ERROR", "request_upload_token response was not an object.");
|
|
8048
8206
|
}
|
|
8049
8207
|
const token = response.token;
|
|
@@ -8129,7 +8287,7 @@ function parsePutResponse(text2) {
|
|
|
8129
8287
|
} catch {
|
|
8130
8288
|
throw new AttachmentUploadError("ATTACHMENT_UPLOAD_PROTOCOL_ERROR", "Attachment PUT response was not valid JSON.");
|
|
8131
8289
|
}
|
|
8132
|
-
if (!
|
|
8290
|
+
if (!isRecord11(parsed)) {
|
|
8133
8291
|
throw new AttachmentUploadError("ATTACHMENT_UPLOAD_PROTOCOL_ERROR", "Attachment PUT response was not an object.");
|
|
8134
8292
|
}
|
|
8135
8293
|
if (typeof parsed.storageKey !== "string") {
|
|
@@ -8193,7 +8351,7 @@ var MIME_BY_EXTENSION = {
|
|
|
8193
8351
|
".xlsx": "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
|
|
8194
8352
|
".zip": "application/zip"
|
|
8195
8353
|
};
|
|
8196
|
-
function
|
|
8354
|
+
function isRecord11(value) {
|
|
8197
8355
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
8198
8356
|
}
|
|
8199
8357
|
|
|
@@ -8321,8 +8479,8 @@ function renderAttachmentUploadResult(result, json) {
|
|
|
8321
8479
|
import { mkdir as mkdir3, open, readFile as readFile5, rename as rename3 } from "fs/promises";
|
|
8322
8480
|
import { dirname as dirname4 } from "path";
|
|
8323
8481
|
var EXIT_NOTHING_NEW = 3;
|
|
8324
|
-
var LIST_NOTIFICATIONS = "
|
|
8325
|
-
var LIST_AGENT_TODOS = "
|
|
8482
|
+
var LIST_NOTIFICATIONS = "list_notifications";
|
|
8483
|
+
var LIST_AGENT_TODOS = "list_agent_todos";
|
|
8326
8484
|
function isInboxPollCommand(domain, action) {
|
|
8327
8485
|
return [NOTIFICATIONS_POLL_COMMAND_PATH, NOTIFICATIONS_ACK_COMMAND_PATH, AGENT_TODOS_POLL_COMMAND_PATH].some(([d, a]) => d === domain && a === action);
|
|
8328
8486
|
}
|
|
@@ -8425,7 +8583,7 @@ async function agentTodosPoll(options) {
|
|
|
8425
8583
|
let after;
|
|
8426
8584
|
for (let page = 0; page < 20; page += 1) {
|
|
8427
8585
|
const result = await callTool(options.client, LIST_AGENT_TODOS, { state: ["OPEN"], ...scope, limit: 50, ...after ? { after } : {} });
|
|
8428
|
-
const pageItems = Array.isArray(result.items) ? result.items.filter(
|
|
8586
|
+
const pageItems = Array.isArray(result.items) ? result.items.filter(isRecord12) : [];
|
|
8429
8587
|
items.push(...pageItems);
|
|
8430
8588
|
const last = pageItems[pageItems.length - 1];
|
|
8431
8589
|
if (result.hasMore !== true || !last || typeof last.todoId !== "string") break;
|
|
@@ -8450,7 +8608,7 @@ async function callTool(client, name, args) {
|
|
|
8450
8608
|
throw new CliCommandError("TOOL_ERROR", toolErrorText(raw), { tool: name });
|
|
8451
8609
|
}
|
|
8452
8610
|
const payload = unwrapMcpToolPayload(raw);
|
|
8453
|
-
if (!
|
|
8611
|
+
if (!isRecord12(payload)) {
|
|
8454
8612
|
throw new CliCommandError("MCP_PROTOCOL_ERROR", `${name} did not return an object.`, { tool: name });
|
|
8455
8613
|
}
|
|
8456
8614
|
return payload;
|
|
@@ -8525,7 +8683,7 @@ async function readCursorFile(path) {
|
|
|
8525
8683
|
if (text2 === void 0 || !text2.trim()) return void 0;
|
|
8526
8684
|
try {
|
|
8527
8685
|
const parsed = JSON.parse(text2);
|
|
8528
|
-
if (parsed?.v !== 1 || !
|
|
8686
|
+
if (parsed?.v !== 1 || !isRecord12(parsed.filter)) throw new Error("shape");
|
|
8529
8687
|
return { ...parsed, filter: normalizeSavedFilter(parsed.filter) };
|
|
8530
8688
|
} catch {
|
|
8531
8689
|
throw new CliCommandError("INVALID_CURSOR_FILE", `${path} is not a cursor file written by ainecto notifications poll.`, { cursorFile: path });
|
|
@@ -8560,7 +8718,7 @@ async function writeJsonAtomic(path, value) {
|
|
|
8560
8718
|
}
|
|
8561
8719
|
await rename3(temp, path);
|
|
8562
8720
|
}
|
|
8563
|
-
function
|
|
8721
|
+
function isRecord12(value) {
|
|
8564
8722
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
8565
8723
|
}
|
|
8566
8724
|
|
|
@@ -9576,9 +9734,9 @@ async function applyPlan(root, plan, dryRun, snapshot, recordFirst = true) {
|
|
|
9576
9734
|
}
|
|
9577
9735
|
const applied = [];
|
|
9578
9736
|
try {
|
|
9579
|
-
const
|
|
9580
|
-
const recordWrites = plan.writes.filter((write) =>
|
|
9581
|
-
const recordDeletes = plan.deletes.filter((path) =>
|
|
9737
|
+
const isRecord15 = (path) => !recordFirst && path === HARNESS_RECORD_PATH;
|
|
9738
|
+
const recordWrites = plan.writes.filter((write) => isRecord15(write.path));
|
|
9739
|
+
const recordDeletes = plan.deletes.filter((path) => isRecord15(path));
|
|
9582
9740
|
const createdDirectories = [...plan.record?.createdDirectories ?? []];
|
|
9583
9741
|
const rememberDirectories = (directories) => {
|
|
9584
9742
|
for (const directory of directories) {
|
|
@@ -9620,8 +9778,8 @@ async function applyPlan(root, plan, dryRun, snapshot, recordFirst = true) {
|
|
|
9620
9778
|
};
|
|
9621
9779
|
try {
|
|
9622
9780
|
await apply(
|
|
9623
|
-
orderedWrites(plan.writes.filter((write) => !
|
|
9624
|
-
plan.deletes.filter((path) => !
|
|
9781
|
+
orderedWrites(plan.writes.filter((write) => !isRecord15(write.path)), recordFirst),
|
|
9782
|
+
plan.deletes.filter((path) => !isRecord15(path))
|
|
9625
9783
|
);
|
|
9626
9784
|
await recordDirectoriesOrExplain(false);
|
|
9627
9785
|
await apply(recordWrites, recordDeletes);
|
|
@@ -9692,7 +9850,7 @@ async function fileMode(absolutePath) {
|
|
|
9692
9850
|
try {
|
|
9693
9851
|
return (await stat4(absolutePath)).mode & 4095;
|
|
9694
9852
|
} catch (error) {
|
|
9695
|
-
if (
|
|
9853
|
+
if (isRecord13(error) && error.code === "ENOENT") {
|
|
9696
9854
|
return void 0;
|
|
9697
9855
|
}
|
|
9698
9856
|
throw error;
|
|
@@ -9735,7 +9893,7 @@ function parseInitArgs(argv) {
|
|
|
9735
9893
|
}
|
|
9736
9894
|
return args;
|
|
9737
9895
|
}
|
|
9738
|
-
function
|
|
9896
|
+
function isRecord13(value) {
|
|
9739
9897
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
9740
9898
|
}
|
|
9741
9899
|
|
|
@@ -10587,6 +10745,47 @@ var DAEMON_START_ATTEMPTS = 3;
|
|
|
10587
10745
|
var DAEMON_LOG_MAX_BYTES = 10 * 1024 * 1024;
|
|
10588
10746
|
var TERM_STRING_HOLD_MAX_CHARS = 1048576;
|
|
10589
10747
|
|
|
10748
|
+
// src/core/term/paths.ts
|
|
10749
|
+
import { createHash as createHash5 } from "crypto";
|
|
10750
|
+
import { homedir as homedir2 } from "os";
|
|
10751
|
+
import { isAbsolute, join as join6, posix, win32 } from "path";
|
|
10752
|
+
function appHome(platform = process.platform, env = process.env, home = homedir2()) {
|
|
10753
|
+
if (platform === "darwin") return posix.join(home, "Library", "Application Support", "ainecto");
|
|
10754
|
+
if (platform === "win32") return win32.join(env.LOCALAPPDATA || win32.join(home, "AppData", "Local"), "ainecto");
|
|
10755
|
+
const xdg = env.XDG_DATA_HOME;
|
|
10756
|
+
return posix.join(xdg && isAbsolute(xdg) ? xdg : posix.join(home, ".local", "share"), "ainecto");
|
|
10757
|
+
}
|
|
10758
|
+
function isUuid(value) {
|
|
10759
|
+
return /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/.test(value);
|
|
10760
|
+
}
|
|
10761
|
+
function webSessionFolder(app, projectUuid, requestId) {
|
|
10762
|
+
if (!isUuid(requestId)) {
|
|
10763
|
+
throw new TermError("TERM_BAD_REQUEST", `The create request id "${requestId}" is not a UUID, so no session folder was made.`);
|
|
10764
|
+
}
|
|
10765
|
+
if (projectUuid === void 0) return join6(app, "sessions", requestId);
|
|
10766
|
+
if (!isUuid(projectUuid)) {
|
|
10767
|
+
throw new TermError("TERM_BAD_REQUEST", `The project "${projectUuid}" is not a UUID, so no session folder was made.`);
|
|
10768
|
+
}
|
|
10769
|
+
return join6(app, "projects", projectUuid, "sessions", requestId);
|
|
10770
|
+
}
|
|
10771
|
+
function termPaths(home = homedir2()) {
|
|
10772
|
+
const dir = join6(home, ".ainecto", "term");
|
|
10773
|
+
return {
|
|
10774
|
+
dir,
|
|
10775
|
+
socket: join6(dir, "ctl.sock"),
|
|
10776
|
+
lockFile: join6(dir, "daemon.lock"),
|
|
10777
|
+
// ★설계는 `\0ainecto-term-<uid>.lock` 이다. 추상 이름은 홈 폴더와 무관하게 기기 전체에 하나라서, 홈이 다른
|
|
10778
|
+
// 두 폴더(시험·다른 HOME)가 서로의 잠금을 막는다. 잠금이 지키는 것은 «이 폴더의 소켓»이므로 폴더 경로를 넣는다.
|
|
10779
|
+
abstractLockName: `\0ainecto-term-${process.getuid?.() ?? "na"}-${createHash5("sha256").update(dir).digest("hex")}.lock`,
|
|
10780
|
+
daemonInfo: join6(dir, "daemon.json"),
|
|
10781
|
+
manifest: join6(dir, "sessions.json"),
|
|
10782
|
+
log: join6(dir, "daemon.log"),
|
|
10783
|
+
previousLog: join6(dir, "daemon.log.1"),
|
|
10784
|
+
remoteLog: join6(dir, "remote.log"),
|
|
10785
|
+
previousRemoteLog: join6(dir, "remote.log.1")
|
|
10786
|
+
};
|
|
10787
|
+
}
|
|
10788
|
+
|
|
10590
10789
|
// src/core/term/protocol.ts
|
|
10591
10790
|
var RETRY_CODE = "TERM_DAEMON_RETRY";
|
|
10592
10791
|
function encodeLine(message2) {
|
|
@@ -10643,7 +10842,8 @@ function parseClientMessage(line) {
|
|
|
10643
10842
|
command: record3.command === null ? null : stringArrayField(record3, "command"),
|
|
10644
10843
|
env: stringMapField(record3, "env"),
|
|
10645
10844
|
cols: optionalSize(record3, "cols"),
|
|
10646
|
-
rows: optionalSize(record3, "rows")
|
|
10845
|
+
rows: optionalSize(record3, "rows"),
|
|
10846
|
+
...record3.project === void 0 ? {} : { project: projectField(record3, "project") }
|
|
10647
10847
|
};
|
|
10648
10848
|
case "ls":
|
|
10649
10849
|
case "kill-server":
|
|
@@ -10775,6 +10975,13 @@ function sizeField(record3, key) {
|
|
|
10775
10975
|
}
|
|
10776
10976
|
return value;
|
|
10777
10977
|
}
|
|
10978
|
+
function projectField(record3, key) {
|
|
10979
|
+
const value = stringField(record3, key);
|
|
10980
|
+
if (!isUuid(value)) {
|
|
10981
|
+
throw new TermProtocolError(`"${key}" must be a lowercase UUID.`);
|
|
10982
|
+
}
|
|
10983
|
+
return value;
|
|
10984
|
+
}
|
|
10778
10985
|
function optionalSize(record3, key) {
|
|
10779
10986
|
return record3[key] === void 0 ? void 0 : sizeField(record3, key);
|
|
10780
10987
|
}
|
|
@@ -11072,7 +11279,7 @@ function isEntry(value) {
|
|
|
11072
11279
|
return false;
|
|
11073
11280
|
}
|
|
11074
11281
|
const entry = value;
|
|
11075
|
-
return typeof entry.name === "string" && typeof entry.cwd === "string" && typeof entry.createdAt === "string" && (entry.label === void 0 || typeof entry.label === "string") && (entry.command === null || Array.isArray(entry.command) && entry.command.every((item) => typeof item === "string"));
|
|
11282
|
+
return typeof entry.name === "string" && typeof entry.cwd === "string" && typeof entry.createdAt === "string" && (entry.label === void 0 || typeof entry.label === "string") && (entry.project === void 0 || typeof entry.project === "string") && (entry.command === null || Array.isArray(entry.command) && entry.command.every((item) => typeof item === "string"));
|
|
11076
11283
|
}
|
|
11077
11284
|
|
|
11078
11285
|
// src/core/term/sessionName.ts
|
|
@@ -11635,6 +11842,7 @@ var TermSession = class _TermSession {
|
|
|
11635
11842
|
rows: this.pty.rows,
|
|
11636
11843
|
clients: this.attached.size,
|
|
11637
11844
|
...this.label !== void 0 ? { label: this.label } : {},
|
|
11845
|
+
...this.spec.project !== void 0 ? { project: this.spec.project } : {},
|
|
11638
11846
|
...this.lastOutputAt !== void 0 ? { lastOutputAt: this.lastOutputAt } : {}
|
|
11639
11847
|
};
|
|
11640
11848
|
}
|
|
@@ -12027,7 +12235,13 @@ var TermDaemon = class {
|
|
|
12027
12235
|
switch (request.op) {
|
|
12028
12236
|
case "new": {
|
|
12029
12237
|
assertSessionName(request.name);
|
|
12030
|
-
const entry = {
|
|
12238
|
+
const entry = {
|
|
12239
|
+
name: request.name,
|
|
12240
|
+
cwd: request.cwd,
|
|
12241
|
+
command: request.command,
|
|
12242
|
+
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
12243
|
+
...request.project !== void 0 ? { project: request.project } : {}
|
|
12244
|
+
};
|
|
12031
12245
|
const session = await this.startSession(entry, request.env, request.cols, request.rows);
|
|
12032
12246
|
this.updateManifest((entries2) => [...entries2.filter((item) => item.name !== entry.name), entry]);
|
|
12033
12247
|
return { data: session.info() };
|
|
@@ -12300,37 +12514,6 @@ var DetachKeyScanner = class {
|
|
|
12300
12514
|
}
|
|
12301
12515
|
};
|
|
12302
12516
|
|
|
12303
|
-
// src/core/term/paths.ts
|
|
12304
|
-
import { createHash as createHash5 } from "crypto";
|
|
12305
|
-
import { homedir as homedir2 } from "os";
|
|
12306
|
-
import { isAbsolute, join as join6, posix, win32 } from "path";
|
|
12307
|
-
function appHome(platform = process.platform, env = process.env, home = homedir2()) {
|
|
12308
|
-
if (platform === "darwin") return posix.join(home, "Library", "Application Support", "ainecto");
|
|
12309
|
-
if (platform === "win32") return win32.join(env.LOCALAPPDATA || win32.join(home, "AppData", "Local"), "ainecto");
|
|
12310
|
-
const xdg = env.XDG_DATA_HOME;
|
|
12311
|
-
return posix.join(xdg && isAbsolute(xdg) ? xdg : posix.join(home, ".local", "share"), "ainecto");
|
|
12312
|
-
}
|
|
12313
|
-
function webSessionsDir(app = appHome()) {
|
|
12314
|
-
return join6(app, "sessions");
|
|
12315
|
-
}
|
|
12316
|
-
function termPaths(home = homedir2()) {
|
|
12317
|
-
const dir = join6(home, ".ainecto", "term");
|
|
12318
|
-
return {
|
|
12319
|
-
dir,
|
|
12320
|
-
socket: join6(dir, "ctl.sock"),
|
|
12321
|
-
lockFile: join6(dir, "daemon.lock"),
|
|
12322
|
-
// ★설계는 `\0ainecto-term-<uid>.lock` 이다. 추상 이름은 홈 폴더와 무관하게 기기 전체에 하나라서, 홈이 다른
|
|
12323
|
-
// 두 폴더(시험·다른 HOME)가 서로의 잠금을 막는다. 잠금이 지키는 것은 «이 폴더의 소켓»이므로 폴더 경로를 넣는다.
|
|
12324
|
-
abstractLockName: `\0ainecto-term-${process.getuid?.() ?? "na"}-${createHash5("sha256").update(dir).digest("hex")}.lock`,
|
|
12325
|
-
daemonInfo: join6(dir, "daemon.json"),
|
|
12326
|
-
manifest: join6(dir, "sessions.json"),
|
|
12327
|
-
log: join6(dir, "daemon.log"),
|
|
12328
|
-
previousLog: join6(dir, "daemon.log.1"),
|
|
12329
|
-
remoteLog: join6(dir, "remote.log"),
|
|
12330
|
-
previousRemoteLog: join6(dir, "remote.log.1")
|
|
12331
|
-
};
|
|
12332
|
-
}
|
|
12333
|
-
|
|
12334
12517
|
// src/core/term/wait.ts
|
|
12335
12518
|
async function waitForMatch(paths, name, pattern, range, timeoutMs) {
|
|
12336
12519
|
const client = await openTermClient(paths, { start: false });
|
|
@@ -12819,12 +13002,18 @@ var DEFAULT_AGENT = "claude-code";
|
|
|
12819
13002
|
function isAgentId(value) {
|
|
12820
13003
|
return typeof value === "string" && AGENT_IDS.includes(value);
|
|
12821
13004
|
}
|
|
12822
|
-
|
|
13005
|
+
var REPLY_KEYS = ["reply", "openDocumentUuids", "openCardUuids"];
|
|
13006
|
+
function agentReplySchema(textMaxCharacters, documentsMax) {
|
|
13007
|
+
const ids = (description) => ({ type: "array", maxItems: documentsMax, items: { type: "string", pattern: "^[0-9a-f]{32}$" }, description });
|
|
12823
13008
|
return {
|
|
12824
13009
|
type: "object",
|
|
12825
13010
|
additionalProperties: false,
|
|
12826
|
-
required: [
|
|
12827
|
-
properties: {
|
|
13011
|
+
required: [...REPLY_KEYS],
|
|
13012
|
+
properties: {
|
|
13013
|
+
reply: { type: "string", minLength: 1, maxLength: textMaxCharacters },
|
|
13014
|
+
openDocumentUuids: ids("AiNecto documents you found or worked on in this turn that the user should open (documentUuid). May be empty."),
|
|
13015
|
+
openCardUuids: ids("AiNecto kanban cards you found or worked on in this turn that the user should open (cardUuid). May be empty.")
|
|
13016
|
+
}
|
|
12828
13017
|
};
|
|
12829
13018
|
}
|
|
12830
13019
|
var AINECTO_MCP_SERVER = "ainecto";
|
|
@@ -12961,6 +13150,7 @@ function createAgentHttp(input) {
|
|
|
12961
13150
|
}
|
|
12962
13151
|
|
|
12963
13152
|
// src/core/agent/prompt.ts
|
|
13153
|
+
var AGENT_OPEN_RULE = "[AiNecto rule] You cannot change the user's AiNecto web screen \u2014 never say you opened, showed or switched to a document or card. When asked to open or show one, find it with the AiNecto tools and put it in openDocumentUuids / openCardUuids (the chat shows an \xAB\uC5F4\uAE30\xBB button for each), then say so truthfully, e.g. \xAB\uCC3E\uC558\uC2B5\uB2C8\uB2E4. \uC544\uB798 \uC5F4\uAE30 \uBC84\uD2BC\uC5D0\uC11C \uD655\uC778\uD560 \uC218 \uC788\uC2B5\uB2C8\uB2E4.\xBB";
|
|
12964
13154
|
function agentPromptText(text2, context) {
|
|
12965
13155
|
const parts = [];
|
|
12966
13156
|
const p = context?.project;
|
|
@@ -12971,12 +13161,16 @@ function agentPromptText(text2, context) {
|
|
|
12971
13161
|
if (d && typeof d.uuid === "string") {
|
|
12972
13162
|
parts.push(`open document \xAB${str(d.title)}\xBB (documentUuid ${d.uuid}${typeof d.type === "string" ? `, ${d.type}` : ""})`);
|
|
12973
13163
|
}
|
|
13164
|
+
const c = context?.card;
|
|
13165
|
+
if (c && typeof c.uuid === "string") {
|
|
13166
|
+
parts.push(`card \xAB${str(c.title)}\xBB (${typeof c.key === "string" ? `${c.key}, ` : ""}cardUuid ${c.uuid})`);
|
|
13167
|
+
}
|
|
12974
13168
|
const files = Array.isArray(context?.attachments) ? context.attachments.map((f) => str(f?.filename)).filter((name) => name !== "") : [];
|
|
12975
13169
|
if (files.length > 0) {
|
|
12976
13170
|
parts.push(`attached files ${files.map((name) => `\xAB${name}\xBB`).join(", ")} (names only \u2014 the files are not available on this machine)`);
|
|
12977
13171
|
}
|
|
12978
|
-
|
|
12979
|
-
return
|
|
13172
|
+
const head = parts.length === 0 ? [AGENT_OPEN_RULE] : [AGENT_OPEN_RULE, `[AiNecto context \u2014 "this project" / "this document" / "this card" mean these] ${parts.join(" \xB7 ")}`];
|
|
13173
|
+
return `${head.join("\n")}
|
|
12980
13174
|
|
|
12981
13175
|
${text2}`;
|
|
12982
13176
|
}
|
|
@@ -13000,10 +13194,9 @@ ${outcome.stderrTail}` : ""));
|
|
|
13000
13194
|
return failed("AGENT_ERROR", `${agentName} \uAC00 \uC2E4\uD328\uD588\uC5B4\uC694(${result.subtype ?? "error"}).` + (result.resultText ? `
|
|
13001
13195
|
${result.resultText}` : ""));
|
|
13002
13196
|
}
|
|
13003
|
-
const
|
|
13004
|
-
|
|
13005
|
-
|
|
13006
|
-
return { status: "DONE", reply, ...attached };
|
|
13197
|
+
const answer = schemaAnswer(result.structuredOutput, limits.textMaxCharacters);
|
|
13198
|
+
if (answer) {
|
|
13199
|
+
return { status: "DONE", reply: answer.reply, ...attachedWork(outcome, limits, answer) };
|
|
13007
13200
|
}
|
|
13008
13201
|
const raw = result.structuredOutput !== void 0 ? JSON.stringify(result.structuredOutput) : result.resultText ?? "";
|
|
13009
13202
|
return failed("SCHEMA_VIOLATION", `\uB2F5 \uD615\uC2DD\uC774 \uC5B4\uAE0B\uB0AC\uC5B4\uC694.
|
|
@@ -13018,17 +13211,35 @@ function stoppedReply(outcome, limits) {
|
|
|
13018
13211
|
...outcome ? attachedWork(outcome, limits) : { documentUuids: [] }
|
|
13019
13212
|
};
|
|
13020
13213
|
}
|
|
13021
|
-
function
|
|
13214
|
+
function schemaAnswer(value, textMaxCharacters) {
|
|
13215
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) return void 0;
|
|
13216
|
+
const keys = Object.keys(value);
|
|
13217
|
+
if (keys.length !== REPLY_KEYS.length || !REPLY_KEYS.every((key) => keys.includes(key))) return void 0;
|
|
13218
|
+
const { reply, openDocumentUuids, openCardUuids } = value;
|
|
13219
|
+
if (typeof reply !== "string" || reply.trim().length === 0 || codePoints(reply) > textMaxCharacters) return void 0;
|
|
13220
|
+
if (!isStringArray2(openDocumentUuids) || !isStringArray2(openCardUuids)) return void 0;
|
|
13221
|
+
return { reply, openDocumentUuids, openCardUuids };
|
|
13222
|
+
}
|
|
13223
|
+
function attachedWork(outcome, limits, open2) {
|
|
13022
13224
|
const facts = outcome.kind === "result" ? outcome.facts : void 0;
|
|
13023
|
-
const
|
|
13024
|
-
const
|
|
13025
|
-
const
|
|
13225
|
+
const seen = (uuids) => (uuids ?? []).filter((uuid) => facts?.seen.includes(uuid));
|
|
13226
|
+
const documentUuids = unique([...facts?.documents ?? [], ...seen(open2?.openDocumentUuids)]).slice(0, limits.documentsMax);
|
|
13227
|
+
const createdDocumentUuids = (facts?.createdDocuments ?? []).filter((uuid) => documentUuids.includes(uuid));
|
|
13228
|
+
const foundDocumentUuids = documentUuids.filter((uuid) => !facts?.documents.includes(uuid));
|
|
13229
|
+
const cardUuids = unique([...facts?.cards ?? [], ...seen(open2?.openCardUuids)]).slice(0, limits.documentsMax);
|
|
13026
13230
|
return {
|
|
13027
13231
|
documentUuids,
|
|
13028
13232
|
...createdDocumentUuids.length > 0 ? { createdDocumentUuids } : {},
|
|
13233
|
+
...foundDocumentUuids.length > 0 ? { foundDocumentUuids } : {},
|
|
13029
13234
|
...cardUuids.length > 0 ? { cardUuids } : {}
|
|
13030
13235
|
};
|
|
13031
13236
|
}
|
|
13237
|
+
function isStringArray2(value) {
|
|
13238
|
+
return Array.isArray(value) && value.every((item) => typeof item === "string");
|
|
13239
|
+
}
|
|
13240
|
+
function unique(items) {
|
|
13241
|
+
return [...new Set(items)];
|
|
13242
|
+
}
|
|
13032
13243
|
function codePoints(text2) {
|
|
13033
13244
|
return Array.from(text2).length;
|
|
13034
13245
|
}
|
|
@@ -13039,7 +13250,6 @@ function clip(text2, max) {
|
|
|
13039
13250
|
|
|
13040
13251
|
// src/core/agent/tools.ts
|
|
13041
13252
|
import { randomUUID as randomUUID4 } from "crypto";
|
|
13042
|
-
var TOOL_PREFIX = "mcp__ainecto__";
|
|
13043
13253
|
var AgentToolError = class extends Error {
|
|
13044
13254
|
constructor(message2, tool, code, retryable = false) {
|
|
13045
13255
|
super(message2);
|
|
@@ -13084,10 +13294,10 @@ function createAgentTools(input) {
|
|
|
13084
13294
|
return {
|
|
13085
13295
|
call(tool, args, options = {}) {
|
|
13086
13296
|
return logged(tool, Buffer.byteLength(JSON.stringify(args), "utf8"), async () => {
|
|
13087
|
-
const raw = await clientFor(options.as).toolsCall(
|
|
13297
|
+
const raw = await clientFor(options.as).toolsCall(tool, args);
|
|
13088
13298
|
if (isToolError(raw)) throw new AgentToolError(toolErrorText(raw), tool, codeInText(toolErrorText(raw)));
|
|
13089
13299
|
const payload = unwrapMcpToolPayload(raw);
|
|
13090
|
-
if (!
|
|
13300
|
+
if (!isRecord14(payload)) throw new AgentToolError(`${tool} did not return an object.`, tool, "MCP_PROTOCOL_ERROR");
|
|
13091
13301
|
return payload;
|
|
13092
13302
|
}, options.as);
|
|
13093
13303
|
},
|
|
@@ -13105,8 +13315,8 @@ function toolsAs(tools, identity) {
|
|
|
13105
13315
|
function toToolError(tool, error) {
|
|
13106
13316
|
if (error instanceof AgentToolError) return error;
|
|
13107
13317
|
if (error instanceof McpRpcError) {
|
|
13108
|
-
const details =
|
|
13109
|
-
const data =
|
|
13318
|
+
const details = isRecord14(error.details) ? error.details : {};
|
|
13319
|
+
const data = isRecord14(details.data) ? details.data : {};
|
|
13110
13320
|
const status = typeof details.status === "number" ? details.status : void 0;
|
|
13111
13321
|
const code = typeof data.code === "string" ? data.code : typeof details.error === "string" ? details.error : error.code;
|
|
13112
13322
|
const rpcCode = typeof details.code === "number" ? details.code : void 0;
|
|
@@ -13122,12 +13332,12 @@ function toToolError(tool, error) {
|
|
|
13122
13332
|
function codeInText(text2) {
|
|
13123
13333
|
try {
|
|
13124
13334
|
const parsed = JSON.parse(text2);
|
|
13125
|
-
return
|
|
13335
|
+
return isRecord14(parsed) && typeof parsed.code === "string" ? parsed.code : void 0;
|
|
13126
13336
|
} catch {
|
|
13127
13337
|
return void 0;
|
|
13128
13338
|
}
|
|
13129
13339
|
}
|
|
13130
|
-
function
|
|
13340
|
+
function isRecord14(value) {
|
|
13131
13341
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
13132
13342
|
}
|
|
13133
13343
|
|
|
@@ -13210,8 +13420,9 @@ function answerComments(listed2, commentId) {
|
|
|
13210
13420
|
var PROMPT_HEADS = {
|
|
13211
13421
|
CARD_ASSIGNED: "[AiNecto auto-run] The person handed you this kanban card with auto-run. Do the work with the AiNecto tools.",
|
|
13212
13422
|
DECISION_ANSWERED: "[AiNecto auto-run \u2014 continue] The person answered on this card (or asked for changes). Continue the same work.",
|
|
13213
|
-
RESUME: "[AiNecto auto-run \u2014 resume] This machine stopped while you were working this card. Continue the same work: first check what is already done with report_work_progress (CHECKPOINT)."
|
|
13423
|
+
RESUME: "[AiNecto auto-run \u2014 resume] This machine stopped while you were working this card. Continue the same work: first check what is already done with operation report_work_progress (CHECKPOINT)."
|
|
13214
13424
|
};
|
|
13425
|
+
var OPERATIONS_LINE = 'AiNecto names below are operations. Run one with the execute_* tool that `search {operation: "<name>"}` names, as `{operation: "<name>", args: {\u2026}}` \u2014 a wrong execute_* is refused with the one to use.';
|
|
13215
13426
|
function todoPromptText(input) {
|
|
13216
13427
|
const { card, workId } = input;
|
|
13217
13428
|
const owner = card.ownerUserId ?? "the card's assignee";
|
|
@@ -13219,7 +13430,8 @@ function todoPromptText(input) {
|
|
|
13219
13430
|
PROMPT_HEADS[input.kind],
|
|
13220
13431
|
"",
|
|
13221
13432
|
`Card \xAB${card.title}\xBB (${card.key ? `${card.key}, ` : ""}cardUuid ${card.uuid}${card.boardUuid ? `, boardUuid ${card.boardUuid}` : ""}) \xB7 status ${card.status}${card.blocked ? " \xB7 blocked" : ""}`,
|
|
13222
|
-
`AI work: workId ${workId} \u2014 send this workId with every AiNecto call for this card and report each step with report_work_progress (read each response before going on)
|
|
13433
|
+
`AI work: workId ${workId} \u2014 send this workId with every AiNecto call for this card and report each step with operation report_work_progress (read each response before going on).`,
|
|
13434
|
+
OPERATIONS_LINE
|
|
13223
13435
|
];
|
|
13224
13436
|
if (card.description) lines.push("", "Description:", card.description);
|
|
13225
13437
|
if (card.criteria.length > 0) {
|
|
@@ -13231,18 +13443,18 @@ function todoPromptText(input) {
|
|
|
13231
13443
|
"Comments to read (oldest first):",
|
|
13232
13444
|
...input.answers.map((a) => `- #${a.id} ${a.kind}${a.questionState ? ` (${a.questionState})` : ""} by ${a.author}: ${a.body}`)
|
|
13233
13445
|
);
|
|
13234
|
-
lines.push("", `First read them: report_work_progress (it lists the comments to read \u2014 send \`read\` with its checkId), resolve_comments for the questions that are answered, and if the card is blocked, kanban_card_action {cardUuid: "${card.uuid}", action: "unblock"}. Then continue the work.`);
|
|
13446
|
+
lines.push("", `First read them: operation report_work_progress (it lists the comments to read \u2014 send \`read\` with its checkId), resolve_comments for the questions that are answered, and if the card is blocked, kanban_card_action with args {cardUuid: "${card.uuid}", action: "unblock"}. Then continue the work.`);
|
|
13235
13447
|
}
|
|
13236
13448
|
lines.push(
|
|
13237
13449
|
"",
|
|
13238
|
-
"If you need the person's decision, do not guess. Ask and stop:",
|
|
13450
|
+
"If you need the person's decision, do not guess. Ask and stop (operation, then its args):",
|
|
13239
13451
|
`1) create_comments {cardUuid: "${card.uuid}", workId: "${workId}", items: [{kind: "QUESTION", body: <your question>}]}`,
|
|
13240
13452
|
`2) kanban_card_action {cardUuid: "${card.uuid}", action: "block", reason: <one line>, responderIds: ["${owner}"]}`,
|
|
13241
13453
|
`3) report_work_progress {workId: "${workId}", stepId: <the step>, status: "BLOCKED"}`,
|
|
13242
13454
|
"Then answer with what you asked. You will be called again on this card when they answer.",
|
|
13243
13455
|
"",
|
|
13244
13456
|
"Do not request review, approve, or finish the card yourself \u2014 this PC posts your answer as the result and asks the person to review it.",
|
|
13245
|
-
"Do not
|
|
13457
|
+
"Do not run operation finish_work: the AI work stays open until the person approves the result (finishing it early blocks the hand-over).",
|
|
13246
13458
|
"Your answer (reply) is shown to the person in this card's auto-run conversation: say what you did, or what you asked."
|
|
13247
13459
|
);
|
|
13248
13460
|
return lines.join("\n");
|
|
@@ -13628,6 +13840,7 @@ async function runAgentServe(deps) {
|
|
|
13628
13840
|
conversationUuid,
|
|
13629
13841
|
resumeRef: deps.sessions.get(conversationUuid, adapter.id),
|
|
13630
13842
|
textMaxCharacters: limits.textMaxCharacters,
|
|
13843
|
+
documentsMax: limits.documentsMax,
|
|
13631
13844
|
...agentName ? { agentName } : {}
|
|
13632
13845
|
});
|
|
13633
13846
|
live.set(adapter.id, session);
|
|
@@ -13670,7 +13883,8 @@ async function runAgentServe(deps) {
|
|
|
13670
13883
|
}
|
|
13671
13884
|
current = { key: offer.key, session };
|
|
13672
13885
|
try {
|
|
13673
|
-
|
|
13886
|
+
const text2 = offer.todoId === void 0 ? agentPromptText(offer.text, offer.context) : offer.text;
|
|
13887
|
+
outcome = await session.send(text2, deps.turnTimeoutMs ?? AGENT_TURN_TIMEOUT_MS);
|
|
13674
13888
|
} finally {
|
|
13675
13889
|
current = void 0;
|
|
13676
13890
|
}
|
|
@@ -13705,6 +13919,7 @@ async function runAgentServe(deps) {
|
|
|
13705
13919
|
sessionId: session?.sessionRef,
|
|
13706
13920
|
documents: reply?.documentUuids.length ?? 0,
|
|
13707
13921
|
createdDocuments: reply?.createdDocumentUuids?.length ?? 0,
|
|
13922
|
+
foundDocuments: reply?.foundDocumentUuids?.length ?? 0,
|
|
13708
13923
|
cards: reply?.cardUuids?.length ?? 0,
|
|
13709
13924
|
numTurns: result?.numTurns,
|
|
13710
13925
|
costUsd: result?.costUsd
|
|
@@ -13723,6 +13938,7 @@ async function runAgentServe(deps) {
|
|
|
13723
13938
|
reply: reply.reply,
|
|
13724
13939
|
documentUuids: reply.documentUuids,
|
|
13725
13940
|
...reply.createdDocumentUuids ? { createdDocumentUuids: reply.createdDocumentUuids } : {},
|
|
13941
|
+
...reply.foundDocumentUuids ? { foundDocumentUuids: reply.foundDocumentUuids } : {},
|
|
13726
13942
|
...reply.cardUuids ? { cardUuids: reply.cardUuids } : {},
|
|
13727
13943
|
...reply.errorCode ? { errorCode: reply.errorCode } : {}
|
|
13728
13944
|
}, { turnUuid: offer.turnUuid, signal: stopController.signal });
|
|
@@ -14001,6 +14217,7 @@ function wireSessions(listed2, exclude) {
|
|
|
14001
14217
|
return listed2.filter((session) => !exclude.includes(session.name)).map((session) => ({
|
|
14002
14218
|
name: session.name,
|
|
14003
14219
|
...session.label !== void 0 ? { label: session.label } : {},
|
|
14220
|
+
...session.project !== void 0 ? { project: session.project } : {},
|
|
14004
14221
|
cols: session.cols,
|
|
14005
14222
|
rows: session.rows,
|
|
14006
14223
|
...session.lastOutputAt !== void 0 ? { lastOutputAt: session.lastOutputAt } : {}
|
|
@@ -14192,7 +14409,6 @@ var RemoteViewer = class {
|
|
|
14192
14409
|
// src/core/term/remote.ts
|
|
14193
14410
|
import { existsSync } from "fs";
|
|
14194
14411
|
import { rmdir as rmdir2 } from "fs/promises";
|
|
14195
|
-
import { join as join8 } from "path";
|
|
14196
14412
|
|
|
14197
14413
|
// src/core/pc/pcUpgrade.ts
|
|
14198
14414
|
var STABLE = /^\d+\.\d+\.\d+$/;
|
|
@@ -14558,14 +14774,11 @@ var CommandRunner = class {
|
|
|
14558
14774
|
/** 여러 바이트 글자가 poll 경계에서 갈려도 잇는다 — 세션마다(바이트는 그대로, 글자로 바꾸는 곳만 한 곳). */
|
|
14559
14775
|
decoders = /* @__PURE__ */ new Map();
|
|
14560
14776
|
/**
|
|
14561
|
-
* 웹이 폴더를 비운 만들기 —
|
|
14562
|
-
* 세션마다 새 폴더가 되고, remote_command 로그 줄(같은 requestId)로 어느 만들기의 폴더인지 잇는다.
|
|
14777
|
+
* 웹이 폴더를 비운 만들기 — {@link webSessionFolder}(꼬리표가 있으면 프로젝트 아래)를 만든다. requestId 는 서버가 만들기마다 새로
|
|
14778
|
+
* 뽑는 UUID 라 세션마다 새 폴더가 되고, remote_command 로그 줄(같은 requestId)로 어느 만들기의 폴더인지 잇는다.
|
|
14563
14779
|
*/
|
|
14564
|
-
async sessionFolder(requestId) {
|
|
14565
|
-
|
|
14566
|
-
throw new TermError("TERM_BAD_REQUEST", `The create request id "${requestId}" is not a UUID, so no session folder was made.`);
|
|
14567
|
-
}
|
|
14568
|
-
const folder = join8(this.deps.sessionsDir, requestId);
|
|
14780
|
+
async sessionFolder(projectUuid, requestId) {
|
|
14781
|
+
const folder = webSessionFolder(this.deps.appHome, projectUuid, requestId);
|
|
14569
14782
|
const made = !existsSync(folder);
|
|
14570
14783
|
await ensurePrivateDir(folder);
|
|
14571
14784
|
return { folder, made };
|
|
@@ -14658,25 +14871,34 @@ var CommandRunner = class {
|
|
|
14658
14871
|
return true;
|
|
14659
14872
|
}
|
|
14660
14873
|
case "create": {
|
|
14874
|
+
const project = command.projectUuid;
|
|
14875
|
+
if (project !== void 0 && !isUuid(project)) {
|
|
14876
|
+
throw new TermError("TERM_BAD_REQUEST", `The project "${project}" is not a UUID, so the session was not made.`);
|
|
14877
|
+
}
|
|
14661
14878
|
let cwd = command.cwd;
|
|
14662
14879
|
let made;
|
|
14663
14880
|
if (cwd === void 0) {
|
|
14664
|
-
const fresh = await this.sessionFolder(command.requestId);
|
|
14881
|
+
const fresh = await this.sessionFolder(project, command.requestId);
|
|
14665
14882
|
cwd = fresh.folder;
|
|
14666
14883
|
if (fresh.made) made = fresh.folder;
|
|
14667
14884
|
}
|
|
14885
|
+
let created;
|
|
14668
14886
|
try {
|
|
14669
|
-
await this.control.request({
|
|
14887
|
+
created = await this.control.request({
|
|
14670
14888
|
op: "new",
|
|
14671
14889
|
name: command.name,
|
|
14672
14890
|
cwd,
|
|
14673
14891
|
command: command.command === void 0 ? null : shellLineCommand(command.command, this.deps.sessionEnv),
|
|
14674
|
-
env: this.deps.sessionEnv
|
|
14892
|
+
env: this.deps.sessionEnv,
|
|
14893
|
+
...project !== void 0 ? { project } : {}
|
|
14675
14894
|
});
|
|
14676
14895
|
} catch (error) {
|
|
14677
14896
|
if (made) await this.dropSessionFolder(command.requestId, made);
|
|
14678
14897
|
throw error;
|
|
14679
14898
|
}
|
|
14899
|
+
if (project !== void 0 && createdProject(created) !== project) {
|
|
14900
|
+
this.deps.log.write({ event: "remote_create_project_dropped", requestId: command.requestId, session: command.name });
|
|
14901
|
+
}
|
|
14680
14902
|
return true;
|
|
14681
14903
|
}
|
|
14682
14904
|
case "kill":
|
|
@@ -14700,6 +14922,9 @@ function answerSummary(body) {
|
|
|
14700
14922
|
...typeof body.version === "number" ? { version: body.version } : {}
|
|
14701
14923
|
};
|
|
14702
14924
|
}
|
|
14925
|
+
function createdProject(data) {
|
|
14926
|
+
return data && typeof data === "object" && "project" in data && typeof data.project === "string" ? data.project : void 0;
|
|
14927
|
+
}
|
|
14703
14928
|
function serverLimits2(value) {
|
|
14704
14929
|
if (!value || typeof value !== "object") return void 0;
|
|
14705
14930
|
const pollHoldSeconds = "pollHoldSeconds" in value ? value.pollHoldSeconds : void 0;
|
|
@@ -14735,10 +14960,18 @@ function remoteCommands(answer) {
|
|
|
14735
14960
|
}
|
|
14736
14961
|
case "create": {
|
|
14737
14962
|
const name = text(c.get("name"));
|
|
14963
|
+
const projectUuid = text(c.get("projectUuid"));
|
|
14738
14964
|
const cwd = text(c.get("cwd"));
|
|
14739
14965
|
const command = c.get("command");
|
|
14740
14966
|
if (!requestId || !name) return [];
|
|
14741
|
-
return [{
|
|
14967
|
+
return [{
|
|
14968
|
+
type: "create",
|
|
14969
|
+
requestId,
|
|
14970
|
+
name,
|
|
14971
|
+
...projectUuid ? { projectUuid } : {},
|
|
14972
|
+
...cwd ? { cwd } : {},
|
|
14973
|
+
...typeof command === "string" ? { command } : {}
|
|
14974
|
+
}];
|
|
14742
14975
|
}
|
|
14743
14976
|
case "kill":
|
|
14744
14977
|
return requestId && session ? [{ type: "kill", requestId, session }] : [];
|
|
@@ -15146,7 +15379,7 @@ function print2(deps, data, human) {
|
|
|
15146
15379
|
// src/adapters/cli/pcSwap.ts
|
|
15147
15380
|
import { randomUUID as randomUUID5 } from "crypto";
|
|
15148
15381
|
import { writeFile as writeFile7 } from "fs/promises";
|
|
15149
|
-
import { join as
|
|
15382
|
+
import { join as join8 } from "path";
|
|
15150
15383
|
var Refused = class extends Error {
|
|
15151
15384
|
constructor(reason, detail) {
|
|
15152
15385
|
super(detail);
|
|
@@ -15220,7 +15453,7 @@ async function checkRuns(deps) {
|
|
|
15220
15453
|
async function checkProvenance(deps) {
|
|
15221
15454
|
const dir = await deps.makeTempDir();
|
|
15222
15455
|
try {
|
|
15223
|
-
await writeFile7(
|
|
15456
|
+
await writeFile7(join8(dir, "package.json"), `${JSON.stringify({ name: "ainecto-upgrade-check", private: true })}
|
|
15224
15457
|
`);
|
|
15225
15458
|
const run = deps.runner(dir);
|
|
15226
15459
|
const spec = `${deps.packageName}@${deps.to}`;
|
|
@@ -15341,7 +15574,7 @@ function swapArgsOf(argv) {
|
|
|
15341
15574
|
|
|
15342
15575
|
// src/adapters/cli/ainectoCli.ts
|
|
15343
15576
|
import { mkdtemp, rm as rm3 } from "fs/promises";
|
|
15344
|
-
import { join as
|
|
15577
|
+
import { join as join10 } from "path";
|
|
15345
15578
|
|
|
15346
15579
|
// src/adapters/cli/pcStatus.ts
|
|
15347
15580
|
import { readFile as readFile11 } from "fs/promises";
|
|
@@ -15349,16 +15582,16 @@ import { hostname } from "os";
|
|
|
15349
15582
|
|
|
15350
15583
|
// src/core/agent/paths.ts
|
|
15351
15584
|
import { homedir as homedir4 } from "os";
|
|
15352
|
-
import { join as
|
|
15585
|
+
import { join as join9 } from "path";
|
|
15353
15586
|
function agentPaths(home = homedir4()) {
|
|
15354
|
-
const dir =
|
|
15587
|
+
const dir = join9(home, ".ainecto", "agent");
|
|
15355
15588
|
return {
|
|
15356
15589
|
dir,
|
|
15357
|
-
work:
|
|
15358
|
-
sessions:
|
|
15359
|
-
runs:
|
|
15360
|
-
log:
|
|
15361
|
-
previousLog:
|
|
15590
|
+
work: join9(dir, "work"),
|
|
15591
|
+
sessions: join9(dir, "sessions.json"),
|
|
15592
|
+
runs: join9(dir, "runs.json"),
|
|
15593
|
+
log: join9(dir, "agent.log"),
|
|
15594
|
+
previousLog: join9(dir, "agent.log.1")
|
|
15362
15595
|
};
|
|
15363
15596
|
}
|
|
15364
15597
|
|
|
@@ -15591,16 +15824,28 @@ function writeResultFacts(content) {
|
|
|
15591
15824
|
}
|
|
15592
15825
|
return { documents, createdDocuments: documents.filter((uuid) => created.has(uuid)), cards };
|
|
15593
15826
|
}
|
|
15594
|
-
|
|
15595
|
-
|
|
15596
|
-
|
|
15827
|
+
function seenIdsIn(content) {
|
|
15828
|
+
const out = documentUuidsIn(content);
|
|
15829
|
+
for (const value of jsonObjectsIn(content)) collectHexValues(value, out);
|
|
15830
|
+
return out;
|
|
15831
|
+
}
|
|
15832
|
+
var TurnFactsCollector = class {
|
|
15833
|
+
facts = { documents: [], createdDocuments: [], cards: [], seen: [] };
|
|
15834
|
+
add(content, write) {
|
|
15835
|
+
appendUnique(this.facts.seen, seenIdsIn(content));
|
|
15836
|
+
if (!write) return;
|
|
15597
15837
|
const next = writeResultFacts(content);
|
|
15598
15838
|
appendUnique(this.facts.documents, next.documents);
|
|
15599
15839
|
appendUnique(this.facts.createdDocuments, next.createdDocuments);
|
|
15600
15840
|
appendUnique(this.facts.cards, next.cards);
|
|
15601
15841
|
}
|
|
15602
15842
|
snapshot() {
|
|
15603
|
-
return {
|
|
15843
|
+
return {
|
|
15844
|
+
documents: [...this.facts.documents],
|
|
15845
|
+
createdDocuments: [...this.facts.createdDocuments],
|
|
15846
|
+
cards: [...this.facts.cards],
|
|
15847
|
+
seen: [...this.facts.seen]
|
|
15848
|
+
};
|
|
15604
15849
|
}
|
|
15605
15850
|
};
|
|
15606
15851
|
function writeToolNames(tools) {
|
|
@@ -15636,6 +15881,15 @@ function collectCards(value, out) {
|
|
|
15636
15881
|
}
|
|
15637
15882
|
}
|
|
15638
15883
|
}
|
|
15884
|
+
function collectHexValues(value, out) {
|
|
15885
|
+
if (typeof value === "string") {
|
|
15886
|
+
if (HEX32.test(value) && !out.includes(value)) out.push(value);
|
|
15887
|
+
} else if (Array.isArray(value)) {
|
|
15888
|
+
for (const item of value) collectHexValues(item, out);
|
|
15889
|
+
} else if (value && typeof value === "object") {
|
|
15890
|
+
for (const child of Object.values(value)) collectHexValues(child, out);
|
|
15891
|
+
}
|
|
15892
|
+
}
|
|
15639
15893
|
function appendUnique(target, items) {
|
|
15640
15894
|
for (const item of items) {
|
|
15641
15895
|
if (!target.includes(item)) target.push(item);
|
|
@@ -15661,11 +15915,11 @@ function claudeCodeAdapter(deps) {
|
|
|
15661
15915
|
}
|
|
15662
15916
|
return claudeAuthFromJson(run.stdout, run.code, run.stderrTail, hasApiKeyVariable(deps.env));
|
|
15663
15917
|
},
|
|
15664
|
-
open: ({ conversationUuid, resumeRef, textMaxCharacters, agentName }) => new ClaudeCodeSession(
|
|
15918
|
+
open: ({ conversationUuid, resumeRef, textMaxCharacters, documentsMax, agentName }) => new ClaudeCodeSession(
|
|
15665
15919
|
conversationUuid,
|
|
15666
15920
|
resumeRef,
|
|
15667
15921
|
agentName,
|
|
15668
|
-
deps.args({ textMaxCharacters, resumeSessionId: resumeRef, agentName }),
|
|
15922
|
+
deps.args({ textMaxCharacters, documentsMax, resumeSessionId: resumeRef, agentName }),
|
|
15669
15923
|
deps
|
|
15670
15924
|
)
|
|
15671
15925
|
};
|
|
@@ -15724,7 +15978,7 @@ var ClaudeCodeSession = class {
|
|
|
15724
15978
|
const exit = this.child.exit;
|
|
15725
15979
|
if (exit) return { kind: "exited", ...exit };
|
|
15726
15980
|
const outcome = new Promise((resolve4) => {
|
|
15727
|
-
this.pending = { resolve: resolve4, facts: new
|
|
15981
|
+
this.pending = { resolve: resolve4, facts: new TurnFactsCollector() };
|
|
15728
15982
|
});
|
|
15729
15983
|
this.child.writeLine({ type: "user", message: { role: "user", content: text2 } });
|
|
15730
15984
|
try {
|
|
@@ -15782,10 +16036,10 @@ var ClaudeCodeSession = class {
|
|
|
15782
16036
|
}
|
|
15783
16037
|
if (event.type === "user" && Array.isArray(content) && this.pending) {
|
|
15784
16038
|
for (const part of content) {
|
|
15785
|
-
if (part.type !== "tool_result" || typeof part.tool_use_id !== "string") continue;
|
|
16039
|
+
if (part.type !== "tool_result" || typeof part.tool_use_id !== "string" || part.is_error === true) continue;
|
|
15786
16040
|
const name = this.toolNames.get(part.tool_use_id);
|
|
15787
|
-
if (!name?.startsWith(AINECTO_TOOL_PREFIX)
|
|
15788
|
-
this.pending.facts.add(part.content);
|
|
16041
|
+
if (!name?.startsWith(AINECTO_TOOL_PREFIX)) continue;
|
|
16042
|
+
this.pending.facts.add(part.content, this.deps.writeTools.has(name.slice(AINECTO_TOOL_PREFIX.length)));
|
|
15789
16043
|
}
|
|
15790
16044
|
return;
|
|
15791
16045
|
}
|
|
@@ -15793,7 +16047,7 @@ var ClaudeCodeSession = class {
|
|
|
15793
16047
|
if (typeof event.session_id === "string") this.sessionRef = event.session_id;
|
|
15794
16048
|
this.finish({
|
|
15795
16049
|
kind: "result",
|
|
15796
|
-
facts: this.pending?.facts.snapshot() ?? { documents: [], createdDocuments: [], cards: [] },
|
|
16050
|
+
facts: this.pending?.facts.snapshot() ?? { documents: [], createdDocuments: [], cards: [], seen: [] },
|
|
15797
16051
|
result: {
|
|
15798
16052
|
subtype: typeof event.subtype === "string" ? event.subtype : void 0,
|
|
15799
16053
|
isError: event.is_error === true,
|
|
@@ -15921,7 +16175,7 @@ function codexAdapter(deps) {
|
|
|
15921
16175
|
await server.child.stop();
|
|
15922
16176
|
}
|
|
15923
16177
|
},
|
|
15924
|
-
open: ({ conversationUuid, resumeRef, textMaxCharacters, agentName }) => new CodexSession(conversationUuid, resumeRef, textMaxCharacters, agentName, deps)
|
|
16178
|
+
open: ({ conversationUuid, resumeRef, textMaxCharacters, documentsMax, agentName }) => new CodexSession(conversationUuid, resumeRef, agentReplySchema(textMaxCharacters, documentsMax), agentName, deps)
|
|
15925
16179
|
};
|
|
15926
16180
|
}
|
|
15927
16181
|
var CodexRpc = class {
|
|
@@ -16021,9 +16275,9 @@ function startAppServer(deps, args, hooks) {
|
|
|
16021
16275
|
return { child, rpc };
|
|
16022
16276
|
}
|
|
16023
16277
|
var CodexSession = class {
|
|
16024
|
-
constructor(conversationUuid, resumeRef,
|
|
16278
|
+
constructor(conversationUuid, resumeRef, replySchema, agentName, deps) {
|
|
16025
16279
|
this.conversationUuid = conversationUuid;
|
|
16026
|
-
this.
|
|
16280
|
+
this.replySchema = replySchema;
|
|
16027
16281
|
this.agentName = agentName;
|
|
16028
16282
|
this.deps = deps;
|
|
16029
16283
|
this.resumed = resumeRef !== void 0;
|
|
@@ -16037,7 +16291,7 @@ var CodexSession = class {
|
|
|
16037
16291
|
this.started = this.start(resumeRef).then(() => void 0, toError);
|
|
16038
16292
|
}
|
|
16039
16293
|
conversationUuid;
|
|
16040
|
-
|
|
16294
|
+
replySchema;
|
|
16041
16295
|
agentName;
|
|
16042
16296
|
deps;
|
|
16043
16297
|
agent = "codex";
|
|
@@ -16072,7 +16326,7 @@ var CodexSession = class {
|
|
|
16072
16326
|
const exit = this.child.exit;
|
|
16073
16327
|
if (exit || !this.sessionRef) return { kind: "exited", code: exit?.code ?? null, signal: exit?.signal ?? null, stderrTail: exit?.stderrTail ?? "" };
|
|
16074
16328
|
const turn = { resolve: () => {
|
|
16075
|
-
}, facts: new
|
|
16329
|
+
}, facts: new TurnFactsCollector() };
|
|
16076
16330
|
const outcome = new Promise((resolve4) => {
|
|
16077
16331
|
turn.resolve = resolve4;
|
|
16078
16332
|
});
|
|
@@ -16080,7 +16334,7 @@ var CodexSession = class {
|
|
|
16080
16334
|
try {
|
|
16081
16335
|
const started = await this.rpc.request(
|
|
16082
16336
|
"turn/start",
|
|
16083
|
-
codexTurnStartParams(this.sessionRef, text2,
|
|
16337
|
+
codexTurnStartParams(this.sessionRef, text2, this.replySchema)
|
|
16084
16338
|
);
|
|
16085
16339
|
const id = started.turn?.id;
|
|
16086
16340
|
if (typeof id === "string") {
|
|
@@ -16175,8 +16429,8 @@ var CodexSession = class {
|
|
|
16175
16429
|
const item = params.item && typeof params.item === "object" ? params.item : {};
|
|
16176
16430
|
if (item.type === "agentMessage" && typeof item.text === "string") {
|
|
16177
16431
|
turn.lastMessage = item.text;
|
|
16178
|
-
} else if (item.type === "mcpToolCall" && item.server === AINECTO_MCP_SERVER && typeof item.tool === "string" &&
|
|
16179
|
-
turn.facts.add(item.result?.content);
|
|
16432
|
+
} else if (item.type === "mcpToolCall" && item.server === AINECTO_MCP_SERVER && typeof item.tool === "string" && item.status !== "failed") {
|
|
16433
|
+
turn.facts.add(item.result?.content, this.deps.writeTools.has(item.tool));
|
|
16180
16434
|
}
|
|
16181
16435
|
}
|
|
16182
16436
|
};
|
|
@@ -16408,7 +16662,7 @@ async function pcRemoteSetup(input) {
|
|
|
16408
16662
|
pcId: settings.pcId,
|
|
16409
16663
|
hostName,
|
|
16410
16664
|
remoteEnabled: userId !== void 0 && settings.accounts[accountKey(input.endpoint, userId)]?.remoteTerminal === true,
|
|
16411
|
-
|
|
16665
|
+
appHome: input.appHome ?? appHome(),
|
|
16412
16666
|
env: input.env ?? stringEnv()
|
|
16413
16667
|
};
|
|
16414
16668
|
}
|
|
@@ -16435,7 +16689,7 @@ async function runPcRemote(setup, signal, onAnswer) {
|
|
|
16435
16689
|
remoteEnabled: setup.remoteEnabled,
|
|
16436
16690
|
exclude: [PC_SESSION_NAME],
|
|
16437
16691
|
sessionEnv: setup.env,
|
|
16438
|
-
|
|
16692
|
+
appHome: setup.appHome,
|
|
16439
16693
|
signal,
|
|
16440
16694
|
print: (line) => setup.io.stderr.write(`${line}
|
|
16441
16695
|
`),
|
|
@@ -16489,7 +16743,7 @@ async function executeAgentServe(input) {
|
|
|
16489
16743
|
const bridge = (agentName) => ainectoBridge(process.execPath, cliScript, input.endpoint, agentName);
|
|
16490
16744
|
const shared = { spawnImpl: spawnAgent, cwd: paths.work, env: agentEnv(process.env), log, writeTools };
|
|
16491
16745
|
const all = [
|
|
16492
|
-
claudeCodeAdapter({ ...shared, args: ({ textMaxCharacters, resumeSessionId, agentName }) => claudeAgentArgs({ schema: agentReplySchema(textMaxCharacters), mcpConfig: claudeMcpConfig(bridge(agentName)), resumeSessionId }) }),
|
|
16746
|
+
claudeCodeAdapter({ ...shared, args: ({ textMaxCharacters, documentsMax, resumeSessionId, agentName }) => claudeAgentArgs({ schema: agentReplySchema(textMaxCharacters, documentsMax), mcpConfig: claudeMcpConfig(bridge(agentName)), resumeSessionId }) }),
|
|
16493
16747
|
codexAdapter({ ...shared, appServerArgs: (agentName) => codexAppServerArgs(bridge(agentName), writeTools), clientVersion: CLI_VERSION })
|
|
16494
16748
|
];
|
|
16495
16749
|
const checks = await checkAgents(all, log);
|
|
@@ -16597,7 +16851,8 @@ async function runAinectoCli(argv, io) {
|
|
|
16597
16851
|
}
|
|
16598
16852
|
const tokenStore = new FileTokenStore();
|
|
16599
16853
|
const agentName = domain === "mcp" ? void 0 : await readAgentName(process.cwd());
|
|
16600
|
-
|
|
16854
|
+
let connection;
|
|
16855
|
+
const connect2 = () => connection ??= (() => {
|
|
16601
16856
|
const auth = new OAuthClient({
|
|
16602
16857
|
endpoint: resolved.endpoint,
|
|
16603
16858
|
tokenStore,
|
|
@@ -16615,7 +16870,7 @@ async function runAinectoCli(argv, io) {
|
|
|
16615
16870
|
});
|
|
16616
16871
|
const client2 = new McpRpcClient({ endpoint: resolved.endpoint, tokenProvider: auth, legacyRole, channel: "cli", agentName });
|
|
16617
16872
|
return { auth, client: client2 };
|
|
16618
|
-
};
|
|
16873
|
+
})();
|
|
16619
16874
|
if (domain === "mcp") {
|
|
16620
16875
|
const bridgeArgs = parseMcpArgs(parsed.positionals.slice(1));
|
|
16621
16876
|
await runConnector({
|
|
@@ -16763,7 +17018,7 @@ async function runAinectoCli(argv, io) {
|
|
|
16763
17018
|
if (!response.ok) throw new Error(`HTTP ${response.status}`);
|
|
16764
17019
|
return await response.json();
|
|
16765
17020
|
},
|
|
16766
|
-
makeTempDir: () => mkdtemp(
|
|
17021
|
+
makeTempDir: () => mkdtemp(join10(tmpdir(), "ainecto-upgrade-")),
|
|
16767
17022
|
removeDir: (path) => rm3(path, { recursive: true, force: true }),
|
|
16768
17023
|
home: homedir5(),
|
|
16769
17024
|
log: openAgentLog(swapPaths)
|
|
@@ -16782,9 +17037,10 @@ async function runAinectoCli(argv, io) {
|
|
|
16782
17037
|
let routeTools = getGeneratedTools(env);
|
|
16783
17038
|
let remote = isAttachmentsUploadCommand(domain, action) || isInboxPollCommand(domain, action) || domain === "tools" && (action === "list" || action === "call") || matchGeneratedCommand(routeTools, parsed.positionals) !== void 0;
|
|
16784
17039
|
if (!remote) {
|
|
16785
|
-
const live = await loadLiveTools(env, connect2().client).catch(
|
|
16786
|
-
|
|
16787
|
-
|
|
17040
|
+
const live = await loadLiveTools(env, connect2().client).catch(liveListFailure);
|
|
17041
|
+
const match = matchGeneratedCommand(live, parsed.positionals);
|
|
17042
|
+
if (match) {
|
|
17043
|
+
routeTools = [await loadLiveTool(env, connect2().client, match.tool.mcpName)];
|
|
16788
17044
|
remote = true;
|
|
16789
17045
|
}
|
|
16790
17046
|
}
|
|
@@ -16844,16 +17100,28 @@ async function printCatalog(parsed, io, endpoint, liveClient) {
|
|
|
16844
17100
|
const catalogEnv = parsed.env ?? "prod";
|
|
16845
17101
|
try {
|
|
16846
17102
|
const tools = await loadLiveTools(catalogEnv, await liveClient());
|
|
16847
|
-
io.stdout.write(renderSuccess(tools, { json: parsed.json }));
|
|
17103
|
+
io.stdout.write(renderSuccess(tools.map(catalogLine), { json: parsed.json, warnings: [CATALOG_DETAIL_HINT] }));
|
|
16848
17104
|
} catch (error) {
|
|
16849
17105
|
const reason = error instanceof Error ? error.message : String(error);
|
|
16850
|
-
io.stdout.write(renderSuccess(getGeneratedTools(catalogEnv), {
|
|
17106
|
+
io.stdout.write(renderSuccess(getGeneratedTools(catalogEnv).map(catalogLine), {
|
|
16851
17107
|
json: parsed.json,
|
|
16852
|
-
warnings: [`Could not read the live tool list from ${endpoint} (${reason}). Showing the ${catalogEnv} catalog checked in when this CLI version was built \u2014 a snapshot of that server's tools/list that may miss newer document types and tools. Run \`ainecto auth login\`, then retry.`]
|
|
17108
|
+
warnings: [CATALOG_DETAIL_HINT, `Could not read the live tool list from ${endpoint} (${reason}). Showing the ${catalogEnv} catalog checked in when this CLI version was built \u2014 a snapshot of that server's tools/list that may miss newer document types and tools. Run \`ainecto auth login\`, then retry.`]
|
|
16853
17109
|
}));
|
|
16854
17110
|
}
|
|
16855
17111
|
return 0;
|
|
16856
17112
|
}
|
|
17113
|
+
function liveListFailure(error) {
|
|
17114
|
+
const cause = error instanceof Error ? error : new Error(String(error));
|
|
17115
|
+
const failure2 = new Error(`This command is not in this CLI's catalog, and the server's operation list could not be read: ${cause.message}`);
|
|
17116
|
+
const source = cause;
|
|
17117
|
+
failure2.code = typeof source.code === "string" ? source.code : "LIVE_CATALOG_UNAVAILABLE";
|
|
17118
|
+
if (source.details !== void 0) failure2.details = source.details;
|
|
17119
|
+
throw failure2;
|
|
17120
|
+
}
|
|
17121
|
+
function catalogLine(tool) {
|
|
17122
|
+
return { operation: tool.mcpName, command: `ainecto ${tool.commandPath.join(" ")}`, description: tool.description };
|
|
17123
|
+
}
|
|
17124
|
+
var CATALOG_DETAIL_HINT = "Each line is an operation. For its input format, run `ainecto tools call search '{\"operation\":\"<operation>\"}'`; run it with its command or `ainecto tools call <operation> '<json>'`.";
|
|
16857
17125
|
async function handleTools(action, rest, parsed, client, io) {
|
|
16858
17126
|
if (action === "list") {
|
|
16859
17127
|
const tools = await client.toolsList();
|