@ainecto/cli 0.14.0-next.11 → 0.14.0-next.12
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 +190 -95
- package/dist/bin/ainecto.js.map +1 -1
- package/dist/bin/mcp.js +2 -2
- package/package.json +2 -2
package/dist/bin/ainecto.js
CHANGED
|
@@ -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.12" : UNBUNDLED_VERSION;
|
|
5690
|
+
var CLI_BUILD = true ? "d070964" : void 0;
|
|
5691
5691
|
function cliVersionLabel(version, build, release) {
|
|
5692
5692
|
return release || build === void 0 ? version : `${version}-dev+${build}`;
|
|
5693
5693
|
}
|
|
@@ -10587,6 +10587,47 @@ var DAEMON_START_ATTEMPTS = 3;
|
|
|
10587
10587
|
var DAEMON_LOG_MAX_BYTES = 10 * 1024 * 1024;
|
|
10588
10588
|
var TERM_STRING_HOLD_MAX_CHARS = 1048576;
|
|
10589
10589
|
|
|
10590
|
+
// src/core/term/paths.ts
|
|
10591
|
+
import { createHash as createHash5 } from "crypto";
|
|
10592
|
+
import { homedir as homedir2 } from "os";
|
|
10593
|
+
import { isAbsolute, join as join6, posix, win32 } from "path";
|
|
10594
|
+
function appHome(platform = process.platform, env = process.env, home = homedir2()) {
|
|
10595
|
+
if (platform === "darwin") return posix.join(home, "Library", "Application Support", "ainecto");
|
|
10596
|
+
if (platform === "win32") return win32.join(env.LOCALAPPDATA || win32.join(home, "AppData", "Local"), "ainecto");
|
|
10597
|
+
const xdg = env.XDG_DATA_HOME;
|
|
10598
|
+
return posix.join(xdg && isAbsolute(xdg) ? xdg : posix.join(home, ".local", "share"), "ainecto");
|
|
10599
|
+
}
|
|
10600
|
+
function isUuid(value) {
|
|
10601
|
+
return /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/.test(value);
|
|
10602
|
+
}
|
|
10603
|
+
function webSessionFolder(app, projectUuid, requestId) {
|
|
10604
|
+
if (!isUuid(requestId)) {
|
|
10605
|
+
throw new TermError("TERM_BAD_REQUEST", `The create request id "${requestId}" is not a UUID, so no session folder was made.`);
|
|
10606
|
+
}
|
|
10607
|
+
if (projectUuid === void 0) return join6(app, "sessions", requestId);
|
|
10608
|
+
if (!isUuid(projectUuid)) {
|
|
10609
|
+
throw new TermError("TERM_BAD_REQUEST", `The project "${projectUuid}" is not a UUID, so no session folder was made.`);
|
|
10610
|
+
}
|
|
10611
|
+
return join6(app, "projects", projectUuid, "sessions", requestId);
|
|
10612
|
+
}
|
|
10613
|
+
function termPaths(home = homedir2()) {
|
|
10614
|
+
const dir = join6(home, ".ainecto", "term");
|
|
10615
|
+
return {
|
|
10616
|
+
dir,
|
|
10617
|
+
socket: join6(dir, "ctl.sock"),
|
|
10618
|
+
lockFile: join6(dir, "daemon.lock"),
|
|
10619
|
+
// ★설계는 `\0ainecto-term-<uid>.lock` 이다. 추상 이름은 홈 폴더와 무관하게 기기 전체에 하나라서, 홈이 다른
|
|
10620
|
+
// 두 폴더(시험·다른 HOME)가 서로의 잠금을 막는다. 잠금이 지키는 것은 «이 폴더의 소켓»이므로 폴더 경로를 넣는다.
|
|
10621
|
+
abstractLockName: `\0ainecto-term-${process.getuid?.() ?? "na"}-${createHash5("sha256").update(dir).digest("hex")}.lock`,
|
|
10622
|
+
daemonInfo: join6(dir, "daemon.json"),
|
|
10623
|
+
manifest: join6(dir, "sessions.json"),
|
|
10624
|
+
log: join6(dir, "daemon.log"),
|
|
10625
|
+
previousLog: join6(dir, "daemon.log.1"),
|
|
10626
|
+
remoteLog: join6(dir, "remote.log"),
|
|
10627
|
+
previousRemoteLog: join6(dir, "remote.log.1")
|
|
10628
|
+
};
|
|
10629
|
+
}
|
|
10630
|
+
|
|
10590
10631
|
// src/core/term/protocol.ts
|
|
10591
10632
|
var RETRY_CODE = "TERM_DAEMON_RETRY";
|
|
10592
10633
|
function encodeLine(message2) {
|
|
@@ -10643,7 +10684,8 @@ function parseClientMessage(line) {
|
|
|
10643
10684
|
command: record3.command === null ? null : stringArrayField(record3, "command"),
|
|
10644
10685
|
env: stringMapField(record3, "env"),
|
|
10645
10686
|
cols: optionalSize(record3, "cols"),
|
|
10646
|
-
rows: optionalSize(record3, "rows")
|
|
10687
|
+
rows: optionalSize(record3, "rows"),
|
|
10688
|
+
...record3.project === void 0 ? {} : { project: projectField(record3, "project") }
|
|
10647
10689
|
};
|
|
10648
10690
|
case "ls":
|
|
10649
10691
|
case "kill-server":
|
|
@@ -10775,6 +10817,13 @@ function sizeField(record3, key) {
|
|
|
10775
10817
|
}
|
|
10776
10818
|
return value;
|
|
10777
10819
|
}
|
|
10820
|
+
function projectField(record3, key) {
|
|
10821
|
+
const value = stringField(record3, key);
|
|
10822
|
+
if (!isUuid(value)) {
|
|
10823
|
+
throw new TermProtocolError(`"${key}" must be a lowercase UUID.`);
|
|
10824
|
+
}
|
|
10825
|
+
return value;
|
|
10826
|
+
}
|
|
10778
10827
|
function optionalSize(record3, key) {
|
|
10779
10828
|
return record3[key] === void 0 ? void 0 : sizeField(record3, key);
|
|
10780
10829
|
}
|
|
@@ -11072,7 +11121,7 @@ function isEntry(value) {
|
|
|
11072
11121
|
return false;
|
|
11073
11122
|
}
|
|
11074
11123
|
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"));
|
|
11124
|
+
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
11125
|
}
|
|
11077
11126
|
|
|
11078
11127
|
// src/core/term/sessionName.ts
|
|
@@ -11635,6 +11684,7 @@ var TermSession = class _TermSession {
|
|
|
11635
11684
|
rows: this.pty.rows,
|
|
11636
11685
|
clients: this.attached.size,
|
|
11637
11686
|
...this.label !== void 0 ? { label: this.label } : {},
|
|
11687
|
+
...this.spec.project !== void 0 ? { project: this.spec.project } : {},
|
|
11638
11688
|
...this.lastOutputAt !== void 0 ? { lastOutputAt: this.lastOutputAt } : {}
|
|
11639
11689
|
};
|
|
11640
11690
|
}
|
|
@@ -12027,7 +12077,13 @@ var TermDaemon = class {
|
|
|
12027
12077
|
switch (request.op) {
|
|
12028
12078
|
case "new": {
|
|
12029
12079
|
assertSessionName(request.name);
|
|
12030
|
-
const entry = {
|
|
12080
|
+
const entry = {
|
|
12081
|
+
name: request.name,
|
|
12082
|
+
cwd: request.cwd,
|
|
12083
|
+
command: request.command,
|
|
12084
|
+
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
12085
|
+
...request.project !== void 0 ? { project: request.project } : {}
|
|
12086
|
+
};
|
|
12031
12087
|
const session = await this.startSession(entry, request.env, request.cols, request.rows);
|
|
12032
12088
|
this.updateManifest((entries2) => [...entries2.filter((item) => item.name !== entry.name), entry]);
|
|
12033
12089
|
return { data: session.info() };
|
|
@@ -12300,37 +12356,6 @@ var DetachKeyScanner = class {
|
|
|
12300
12356
|
}
|
|
12301
12357
|
};
|
|
12302
12358
|
|
|
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
12359
|
// src/core/term/wait.ts
|
|
12335
12360
|
async function waitForMatch(paths, name, pattern, range, timeoutMs) {
|
|
12336
12361
|
const client = await openTermClient(paths, { start: false });
|
|
@@ -12819,12 +12844,18 @@ var DEFAULT_AGENT = "claude-code";
|
|
|
12819
12844
|
function isAgentId(value) {
|
|
12820
12845
|
return typeof value === "string" && AGENT_IDS.includes(value);
|
|
12821
12846
|
}
|
|
12822
|
-
|
|
12847
|
+
var REPLY_KEYS = ["reply", "openDocumentUuids", "openCardUuids"];
|
|
12848
|
+
function agentReplySchema(textMaxCharacters, documentsMax) {
|
|
12849
|
+
const ids = (description) => ({ type: "array", maxItems: documentsMax, items: { type: "string", pattern: "^[0-9a-f]{32}$" }, description });
|
|
12823
12850
|
return {
|
|
12824
12851
|
type: "object",
|
|
12825
12852
|
additionalProperties: false,
|
|
12826
|
-
required: [
|
|
12827
|
-
properties: {
|
|
12853
|
+
required: [...REPLY_KEYS],
|
|
12854
|
+
properties: {
|
|
12855
|
+
reply: { type: "string", minLength: 1, maxLength: textMaxCharacters },
|
|
12856
|
+
openDocumentUuids: ids("AiNecto documents you found or worked on in this turn that the user should open (documentUuid). May be empty."),
|
|
12857
|
+
openCardUuids: ids("AiNecto kanban cards you found or worked on in this turn that the user should open (cardUuid). May be empty.")
|
|
12858
|
+
}
|
|
12828
12859
|
};
|
|
12829
12860
|
}
|
|
12830
12861
|
var AINECTO_MCP_SERVER = "ainecto";
|
|
@@ -12961,6 +12992,7 @@ function createAgentHttp(input) {
|
|
|
12961
12992
|
}
|
|
12962
12993
|
|
|
12963
12994
|
// src/core/agent/prompt.ts
|
|
12995
|
+
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
12996
|
function agentPromptText(text2, context) {
|
|
12965
12997
|
const parts = [];
|
|
12966
12998
|
const p = context?.project;
|
|
@@ -12971,12 +13003,16 @@ function agentPromptText(text2, context) {
|
|
|
12971
13003
|
if (d && typeof d.uuid === "string") {
|
|
12972
13004
|
parts.push(`open document \xAB${str(d.title)}\xBB (documentUuid ${d.uuid}${typeof d.type === "string" ? `, ${d.type}` : ""})`);
|
|
12973
13005
|
}
|
|
13006
|
+
const c = context?.card;
|
|
13007
|
+
if (c && typeof c.uuid === "string") {
|
|
13008
|
+
parts.push(`card \xAB${str(c.title)}\xBB (${typeof c.key === "string" ? `${c.key}, ` : ""}cardUuid ${c.uuid})`);
|
|
13009
|
+
}
|
|
12974
13010
|
const files = Array.isArray(context?.attachments) ? context.attachments.map((f) => str(f?.filename)).filter((name) => name !== "") : [];
|
|
12975
13011
|
if (files.length > 0) {
|
|
12976
13012
|
parts.push(`attached files ${files.map((name) => `\xAB${name}\xBB`).join(", ")} (names only \u2014 the files are not available on this machine)`);
|
|
12977
13013
|
}
|
|
12978
|
-
|
|
12979
|
-
return
|
|
13014
|
+
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 ")}`];
|
|
13015
|
+
return `${head.join("\n")}
|
|
12980
13016
|
|
|
12981
13017
|
${text2}`;
|
|
12982
13018
|
}
|
|
@@ -13000,10 +13036,9 @@ ${outcome.stderrTail}` : ""));
|
|
|
13000
13036
|
return failed("AGENT_ERROR", `${agentName} \uAC00 \uC2E4\uD328\uD588\uC5B4\uC694(${result.subtype ?? "error"}).` + (result.resultText ? `
|
|
13001
13037
|
${result.resultText}` : ""));
|
|
13002
13038
|
}
|
|
13003
|
-
const
|
|
13004
|
-
|
|
13005
|
-
|
|
13006
|
-
return { status: "DONE", reply, ...attached };
|
|
13039
|
+
const answer = schemaAnswer(result.structuredOutput, limits.textMaxCharacters);
|
|
13040
|
+
if (answer) {
|
|
13041
|
+
return { status: "DONE", reply: answer.reply, ...attachedWork(outcome, limits, answer) };
|
|
13007
13042
|
}
|
|
13008
13043
|
const raw = result.structuredOutput !== void 0 ? JSON.stringify(result.structuredOutput) : result.resultText ?? "";
|
|
13009
13044
|
return failed("SCHEMA_VIOLATION", `\uB2F5 \uD615\uC2DD\uC774 \uC5B4\uAE0B\uB0AC\uC5B4\uC694.
|
|
@@ -13018,17 +13053,35 @@ function stoppedReply(outcome, limits) {
|
|
|
13018
13053
|
...outcome ? attachedWork(outcome, limits) : { documentUuids: [] }
|
|
13019
13054
|
};
|
|
13020
13055
|
}
|
|
13021
|
-
function
|
|
13056
|
+
function schemaAnswer(value, textMaxCharacters) {
|
|
13057
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) return void 0;
|
|
13058
|
+
const keys = Object.keys(value);
|
|
13059
|
+
if (keys.length !== REPLY_KEYS.length || !REPLY_KEYS.every((key) => keys.includes(key))) return void 0;
|
|
13060
|
+
const { reply, openDocumentUuids, openCardUuids } = value;
|
|
13061
|
+
if (typeof reply !== "string" || reply.trim().length === 0 || codePoints(reply) > textMaxCharacters) return void 0;
|
|
13062
|
+
if (!isStringArray2(openDocumentUuids) || !isStringArray2(openCardUuids)) return void 0;
|
|
13063
|
+
return { reply, openDocumentUuids, openCardUuids };
|
|
13064
|
+
}
|
|
13065
|
+
function attachedWork(outcome, limits, open2) {
|
|
13022
13066
|
const facts = outcome.kind === "result" ? outcome.facts : void 0;
|
|
13023
|
-
const
|
|
13024
|
-
const
|
|
13025
|
-
const
|
|
13067
|
+
const seen = (uuids) => (uuids ?? []).filter((uuid) => facts?.seen.includes(uuid));
|
|
13068
|
+
const documentUuids = unique([...facts?.documents ?? [], ...seen(open2?.openDocumentUuids)]).slice(0, limits.documentsMax);
|
|
13069
|
+
const createdDocumentUuids = (facts?.createdDocuments ?? []).filter((uuid) => documentUuids.includes(uuid));
|
|
13070
|
+
const foundDocumentUuids = documentUuids.filter((uuid) => !facts?.documents.includes(uuid));
|
|
13071
|
+
const cardUuids = unique([...facts?.cards ?? [], ...seen(open2?.openCardUuids)]).slice(0, limits.documentsMax);
|
|
13026
13072
|
return {
|
|
13027
13073
|
documentUuids,
|
|
13028
13074
|
...createdDocumentUuids.length > 0 ? { createdDocumentUuids } : {},
|
|
13075
|
+
...foundDocumentUuids.length > 0 ? { foundDocumentUuids } : {},
|
|
13029
13076
|
...cardUuids.length > 0 ? { cardUuids } : {}
|
|
13030
13077
|
};
|
|
13031
13078
|
}
|
|
13079
|
+
function isStringArray2(value) {
|
|
13080
|
+
return Array.isArray(value) && value.every((item) => typeof item === "string");
|
|
13081
|
+
}
|
|
13082
|
+
function unique(items) {
|
|
13083
|
+
return [...new Set(items)];
|
|
13084
|
+
}
|
|
13032
13085
|
function codePoints(text2) {
|
|
13033
13086
|
return Array.from(text2).length;
|
|
13034
13087
|
}
|
|
@@ -13628,6 +13681,7 @@ async function runAgentServe(deps) {
|
|
|
13628
13681
|
conversationUuid,
|
|
13629
13682
|
resumeRef: deps.sessions.get(conversationUuid, adapter.id),
|
|
13630
13683
|
textMaxCharacters: limits.textMaxCharacters,
|
|
13684
|
+
documentsMax: limits.documentsMax,
|
|
13631
13685
|
...agentName ? { agentName } : {}
|
|
13632
13686
|
});
|
|
13633
13687
|
live.set(adapter.id, session);
|
|
@@ -13670,7 +13724,8 @@ async function runAgentServe(deps) {
|
|
|
13670
13724
|
}
|
|
13671
13725
|
current = { key: offer.key, session };
|
|
13672
13726
|
try {
|
|
13673
|
-
|
|
13727
|
+
const text2 = offer.todoId === void 0 ? agentPromptText(offer.text, offer.context) : offer.text;
|
|
13728
|
+
outcome = await session.send(text2, deps.turnTimeoutMs ?? AGENT_TURN_TIMEOUT_MS);
|
|
13674
13729
|
} finally {
|
|
13675
13730
|
current = void 0;
|
|
13676
13731
|
}
|
|
@@ -13705,6 +13760,7 @@ async function runAgentServe(deps) {
|
|
|
13705
13760
|
sessionId: session?.sessionRef,
|
|
13706
13761
|
documents: reply?.documentUuids.length ?? 0,
|
|
13707
13762
|
createdDocuments: reply?.createdDocumentUuids?.length ?? 0,
|
|
13763
|
+
foundDocuments: reply?.foundDocumentUuids?.length ?? 0,
|
|
13708
13764
|
cards: reply?.cardUuids?.length ?? 0,
|
|
13709
13765
|
numTurns: result?.numTurns,
|
|
13710
13766
|
costUsd: result?.costUsd
|
|
@@ -13723,6 +13779,7 @@ async function runAgentServe(deps) {
|
|
|
13723
13779
|
reply: reply.reply,
|
|
13724
13780
|
documentUuids: reply.documentUuids,
|
|
13725
13781
|
...reply.createdDocumentUuids ? { createdDocumentUuids: reply.createdDocumentUuids } : {},
|
|
13782
|
+
...reply.foundDocumentUuids ? { foundDocumentUuids: reply.foundDocumentUuids } : {},
|
|
13726
13783
|
...reply.cardUuids ? { cardUuids: reply.cardUuids } : {},
|
|
13727
13784
|
...reply.errorCode ? { errorCode: reply.errorCode } : {}
|
|
13728
13785
|
}, { turnUuid: offer.turnUuid, signal: stopController.signal });
|
|
@@ -14001,6 +14058,7 @@ function wireSessions(listed2, exclude) {
|
|
|
14001
14058
|
return listed2.filter((session) => !exclude.includes(session.name)).map((session) => ({
|
|
14002
14059
|
name: session.name,
|
|
14003
14060
|
...session.label !== void 0 ? { label: session.label } : {},
|
|
14061
|
+
...session.project !== void 0 ? { project: session.project } : {},
|
|
14004
14062
|
cols: session.cols,
|
|
14005
14063
|
rows: session.rows,
|
|
14006
14064
|
...session.lastOutputAt !== void 0 ? { lastOutputAt: session.lastOutputAt } : {}
|
|
@@ -14192,7 +14250,6 @@ var RemoteViewer = class {
|
|
|
14192
14250
|
// src/core/term/remote.ts
|
|
14193
14251
|
import { existsSync } from "fs";
|
|
14194
14252
|
import { rmdir as rmdir2 } from "fs/promises";
|
|
14195
|
-
import { join as join8 } from "path";
|
|
14196
14253
|
|
|
14197
14254
|
// src/core/pc/pcUpgrade.ts
|
|
14198
14255
|
var STABLE = /^\d+\.\d+\.\d+$/;
|
|
@@ -14558,14 +14615,11 @@ var CommandRunner = class {
|
|
|
14558
14615
|
/** 여러 바이트 글자가 poll 경계에서 갈려도 잇는다 — 세션마다(바이트는 그대로, 글자로 바꾸는 곳만 한 곳). */
|
|
14559
14616
|
decoders = /* @__PURE__ */ new Map();
|
|
14560
14617
|
/**
|
|
14561
|
-
* 웹이 폴더를 비운 만들기 —
|
|
14562
|
-
* 세션마다 새 폴더가 되고, remote_command 로그 줄(같은 requestId)로 어느 만들기의 폴더인지 잇는다.
|
|
14618
|
+
* 웹이 폴더를 비운 만들기 — {@link webSessionFolder}(꼬리표가 있으면 프로젝트 아래)를 만든다. requestId 는 서버가 만들기마다 새로
|
|
14619
|
+
* 뽑는 UUID 라 세션마다 새 폴더가 되고, remote_command 로그 줄(같은 requestId)로 어느 만들기의 폴더인지 잇는다.
|
|
14563
14620
|
*/
|
|
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);
|
|
14621
|
+
async sessionFolder(projectUuid, requestId) {
|
|
14622
|
+
const folder = webSessionFolder(this.deps.appHome, projectUuid, requestId);
|
|
14569
14623
|
const made = !existsSync(folder);
|
|
14570
14624
|
await ensurePrivateDir(folder);
|
|
14571
14625
|
return { folder, made };
|
|
@@ -14658,25 +14712,34 @@ var CommandRunner = class {
|
|
|
14658
14712
|
return true;
|
|
14659
14713
|
}
|
|
14660
14714
|
case "create": {
|
|
14715
|
+
const project = command.projectUuid;
|
|
14716
|
+
if (project !== void 0 && !isUuid(project)) {
|
|
14717
|
+
throw new TermError("TERM_BAD_REQUEST", `The project "${project}" is not a UUID, so the session was not made.`);
|
|
14718
|
+
}
|
|
14661
14719
|
let cwd = command.cwd;
|
|
14662
14720
|
let made;
|
|
14663
14721
|
if (cwd === void 0) {
|
|
14664
|
-
const fresh = await this.sessionFolder(command.requestId);
|
|
14722
|
+
const fresh = await this.sessionFolder(project, command.requestId);
|
|
14665
14723
|
cwd = fresh.folder;
|
|
14666
14724
|
if (fresh.made) made = fresh.folder;
|
|
14667
14725
|
}
|
|
14726
|
+
let created;
|
|
14668
14727
|
try {
|
|
14669
|
-
await this.control.request({
|
|
14728
|
+
created = await this.control.request({
|
|
14670
14729
|
op: "new",
|
|
14671
14730
|
name: command.name,
|
|
14672
14731
|
cwd,
|
|
14673
14732
|
command: command.command === void 0 ? null : shellLineCommand(command.command, this.deps.sessionEnv),
|
|
14674
|
-
env: this.deps.sessionEnv
|
|
14733
|
+
env: this.deps.sessionEnv,
|
|
14734
|
+
...project !== void 0 ? { project } : {}
|
|
14675
14735
|
});
|
|
14676
14736
|
} catch (error) {
|
|
14677
14737
|
if (made) await this.dropSessionFolder(command.requestId, made);
|
|
14678
14738
|
throw error;
|
|
14679
14739
|
}
|
|
14740
|
+
if (project !== void 0 && createdProject(created) !== project) {
|
|
14741
|
+
this.deps.log.write({ event: "remote_create_project_dropped", requestId: command.requestId, session: command.name });
|
|
14742
|
+
}
|
|
14680
14743
|
return true;
|
|
14681
14744
|
}
|
|
14682
14745
|
case "kill":
|
|
@@ -14700,6 +14763,9 @@ function answerSummary(body) {
|
|
|
14700
14763
|
...typeof body.version === "number" ? { version: body.version } : {}
|
|
14701
14764
|
};
|
|
14702
14765
|
}
|
|
14766
|
+
function createdProject(data) {
|
|
14767
|
+
return data && typeof data === "object" && "project" in data && typeof data.project === "string" ? data.project : void 0;
|
|
14768
|
+
}
|
|
14703
14769
|
function serverLimits2(value) {
|
|
14704
14770
|
if (!value || typeof value !== "object") return void 0;
|
|
14705
14771
|
const pollHoldSeconds = "pollHoldSeconds" in value ? value.pollHoldSeconds : void 0;
|
|
@@ -14735,10 +14801,18 @@ function remoteCommands(answer) {
|
|
|
14735
14801
|
}
|
|
14736
14802
|
case "create": {
|
|
14737
14803
|
const name = text(c.get("name"));
|
|
14804
|
+
const projectUuid = text(c.get("projectUuid"));
|
|
14738
14805
|
const cwd = text(c.get("cwd"));
|
|
14739
14806
|
const command = c.get("command");
|
|
14740
14807
|
if (!requestId || !name) return [];
|
|
14741
|
-
return [{
|
|
14808
|
+
return [{
|
|
14809
|
+
type: "create",
|
|
14810
|
+
requestId,
|
|
14811
|
+
name,
|
|
14812
|
+
...projectUuid ? { projectUuid } : {},
|
|
14813
|
+
...cwd ? { cwd } : {},
|
|
14814
|
+
...typeof command === "string" ? { command } : {}
|
|
14815
|
+
}];
|
|
14742
14816
|
}
|
|
14743
14817
|
case "kill":
|
|
14744
14818
|
return requestId && session ? [{ type: "kill", requestId, session }] : [];
|
|
@@ -15146,7 +15220,7 @@ function print2(deps, data, human) {
|
|
|
15146
15220
|
// src/adapters/cli/pcSwap.ts
|
|
15147
15221
|
import { randomUUID as randomUUID5 } from "crypto";
|
|
15148
15222
|
import { writeFile as writeFile7 } from "fs/promises";
|
|
15149
|
-
import { join as
|
|
15223
|
+
import { join as join8 } from "path";
|
|
15150
15224
|
var Refused = class extends Error {
|
|
15151
15225
|
constructor(reason, detail) {
|
|
15152
15226
|
super(detail);
|
|
@@ -15220,7 +15294,7 @@ async function checkRuns(deps) {
|
|
|
15220
15294
|
async function checkProvenance(deps) {
|
|
15221
15295
|
const dir = await deps.makeTempDir();
|
|
15222
15296
|
try {
|
|
15223
|
-
await writeFile7(
|
|
15297
|
+
await writeFile7(join8(dir, "package.json"), `${JSON.stringify({ name: "ainecto-upgrade-check", private: true })}
|
|
15224
15298
|
`);
|
|
15225
15299
|
const run = deps.runner(dir);
|
|
15226
15300
|
const spec = `${deps.packageName}@${deps.to}`;
|
|
@@ -15341,7 +15415,7 @@ function swapArgsOf(argv) {
|
|
|
15341
15415
|
|
|
15342
15416
|
// src/adapters/cli/ainectoCli.ts
|
|
15343
15417
|
import { mkdtemp, rm as rm3 } from "fs/promises";
|
|
15344
|
-
import { join as
|
|
15418
|
+
import { join as join10 } from "path";
|
|
15345
15419
|
|
|
15346
15420
|
// src/adapters/cli/pcStatus.ts
|
|
15347
15421
|
import { readFile as readFile11 } from "fs/promises";
|
|
@@ -15349,16 +15423,16 @@ import { hostname } from "os";
|
|
|
15349
15423
|
|
|
15350
15424
|
// src/core/agent/paths.ts
|
|
15351
15425
|
import { homedir as homedir4 } from "os";
|
|
15352
|
-
import { join as
|
|
15426
|
+
import { join as join9 } from "path";
|
|
15353
15427
|
function agentPaths(home = homedir4()) {
|
|
15354
|
-
const dir =
|
|
15428
|
+
const dir = join9(home, ".ainecto", "agent");
|
|
15355
15429
|
return {
|
|
15356
15430
|
dir,
|
|
15357
|
-
work:
|
|
15358
|
-
sessions:
|
|
15359
|
-
runs:
|
|
15360
|
-
log:
|
|
15361
|
-
previousLog:
|
|
15431
|
+
work: join9(dir, "work"),
|
|
15432
|
+
sessions: join9(dir, "sessions.json"),
|
|
15433
|
+
runs: join9(dir, "runs.json"),
|
|
15434
|
+
log: join9(dir, "agent.log"),
|
|
15435
|
+
previousLog: join9(dir, "agent.log.1")
|
|
15362
15436
|
};
|
|
15363
15437
|
}
|
|
15364
15438
|
|
|
@@ -15591,16 +15665,28 @@ function writeResultFacts(content) {
|
|
|
15591
15665
|
}
|
|
15592
15666
|
return { documents, createdDocuments: documents.filter((uuid) => created.has(uuid)), cards };
|
|
15593
15667
|
}
|
|
15594
|
-
|
|
15595
|
-
|
|
15596
|
-
|
|
15668
|
+
function seenIdsIn(content) {
|
|
15669
|
+
const out = documentUuidsIn(content);
|
|
15670
|
+
for (const value of jsonObjectsIn(content)) collectHexValues(value, out);
|
|
15671
|
+
return out;
|
|
15672
|
+
}
|
|
15673
|
+
var TurnFactsCollector = class {
|
|
15674
|
+
facts = { documents: [], createdDocuments: [], cards: [], seen: [] };
|
|
15675
|
+
add(content, write) {
|
|
15676
|
+
appendUnique(this.facts.seen, seenIdsIn(content));
|
|
15677
|
+
if (!write) return;
|
|
15597
15678
|
const next = writeResultFacts(content);
|
|
15598
15679
|
appendUnique(this.facts.documents, next.documents);
|
|
15599
15680
|
appendUnique(this.facts.createdDocuments, next.createdDocuments);
|
|
15600
15681
|
appendUnique(this.facts.cards, next.cards);
|
|
15601
15682
|
}
|
|
15602
15683
|
snapshot() {
|
|
15603
|
-
return {
|
|
15684
|
+
return {
|
|
15685
|
+
documents: [...this.facts.documents],
|
|
15686
|
+
createdDocuments: [...this.facts.createdDocuments],
|
|
15687
|
+
cards: [...this.facts.cards],
|
|
15688
|
+
seen: [...this.facts.seen]
|
|
15689
|
+
};
|
|
15604
15690
|
}
|
|
15605
15691
|
};
|
|
15606
15692
|
function writeToolNames(tools) {
|
|
@@ -15636,6 +15722,15 @@ function collectCards(value, out) {
|
|
|
15636
15722
|
}
|
|
15637
15723
|
}
|
|
15638
15724
|
}
|
|
15725
|
+
function collectHexValues(value, out) {
|
|
15726
|
+
if (typeof value === "string") {
|
|
15727
|
+
if (HEX32.test(value) && !out.includes(value)) out.push(value);
|
|
15728
|
+
} else if (Array.isArray(value)) {
|
|
15729
|
+
for (const item of value) collectHexValues(item, out);
|
|
15730
|
+
} else if (value && typeof value === "object") {
|
|
15731
|
+
for (const child of Object.values(value)) collectHexValues(child, out);
|
|
15732
|
+
}
|
|
15733
|
+
}
|
|
15639
15734
|
function appendUnique(target, items) {
|
|
15640
15735
|
for (const item of items) {
|
|
15641
15736
|
if (!target.includes(item)) target.push(item);
|
|
@@ -15661,11 +15756,11 @@ function claudeCodeAdapter(deps) {
|
|
|
15661
15756
|
}
|
|
15662
15757
|
return claudeAuthFromJson(run.stdout, run.code, run.stderrTail, hasApiKeyVariable(deps.env));
|
|
15663
15758
|
},
|
|
15664
|
-
open: ({ conversationUuid, resumeRef, textMaxCharacters, agentName }) => new ClaudeCodeSession(
|
|
15759
|
+
open: ({ conversationUuid, resumeRef, textMaxCharacters, documentsMax, agentName }) => new ClaudeCodeSession(
|
|
15665
15760
|
conversationUuid,
|
|
15666
15761
|
resumeRef,
|
|
15667
15762
|
agentName,
|
|
15668
|
-
deps.args({ textMaxCharacters, resumeSessionId: resumeRef, agentName }),
|
|
15763
|
+
deps.args({ textMaxCharacters, documentsMax, resumeSessionId: resumeRef, agentName }),
|
|
15669
15764
|
deps
|
|
15670
15765
|
)
|
|
15671
15766
|
};
|
|
@@ -15724,7 +15819,7 @@ var ClaudeCodeSession = class {
|
|
|
15724
15819
|
const exit = this.child.exit;
|
|
15725
15820
|
if (exit) return { kind: "exited", ...exit };
|
|
15726
15821
|
const outcome = new Promise((resolve4) => {
|
|
15727
|
-
this.pending = { resolve: resolve4, facts: new
|
|
15822
|
+
this.pending = { resolve: resolve4, facts: new TurnFactsCollector() };
|
|
15728
15823
|
});
|
|
15729
15824
|
this.child.writeLine({ type: "user", message: { role: "user", content: text2 } });
|
|
15730
15825
|
try {
|
|
@@ -15782,10 +15877,10 @@ var ClaudeCodeSession = class {
|
|
|
15782
15877
|
}
|
|
15783
15878
|
if (event.type === "user" && Array.isArray(content) && this.pending) {
|
|
15784
15879
|
for (const part of content) {
|
|
15785
|
-
if (part.type !== "tool_result" || typeof part.tool_use_id !== "string") continue;
|
|
15880
|
+
if (part.type !== "tool_result" || typeof part.tool_use_id !== "string" || part.is_error === true) continue;
|
|
15786
15881
|
const name = this.toolNames.get(part.tool_use_id);
|
|
15787
|
-
if (!name?.startsWith(AINECTO_TOOL_PREFIX)
|
|
15788
|
-
this.pending.facts.add(part.content);
|
|
15882
|
+
if (!name?.startsWith(AINECTO_TOOL_PREFIX)) continue;
|
|
15883
|
+
this.pending.facts.add(part.content, this.deps.writeTools.has(name.slice(AINECTO_TOOL_PREFIX.length)));
|
|
15789
15884
|
}
|
|
15790
15885
|
return;
|
|
15791
15886
|
}
|
|
@@ -15793,7 +15888,7 @@ var ClaudeCodeSession = class {
|
|
|
15793
15888
|
if (typeof event.session_id === "string") this.sessionRef = event.session_id;
|
|
15794
15889
|
this.finish({
|
|
15795
15890
|
kind: "result",
|
|
15796
|
-
facts: this.pending?.facts.snapshot() ?? { documents: [], createdDocuments: [], cards: [] },
|
|
15891
|
+
facts: this.pending?.facts.snapshot() ?? { documents: [], createdDocuments: [], cards: [], seen: [] },
|
|
15797
15892
|
result: {
|
|
15798
15893
|
subtype: typeof event.subtype === "string" ? event.subtype : void 0,
|
|
15799
15894
|
isError: event.is_error === true,
|
|
@@ -15921,7 +16016,7 @@ function codexAdapter(deps) {
|
|
|
15921
16016
|
await server.child.stop();
|
|
15922
16017
|
}
|
|
15923
16018
|
},
|
|
15924
|
-
open: ({ conversationUuid, resumeRef, textMaxCharacters, agentName }) => new CodexSession(conversationUuid, resumeRef, textMaxCharacters, agentName, deps)
|
|
16019
|
+
open: ({ conversationUuid, resumeRef, textMaxCharacters, documentsMax, agentName }) => new CodexSession(conversationUuid, resumeRef, agentReplySchema(textMaxCharacters, documentsMax), agentName, deps)
|
|
15925
16020
|
};
|
|
15926
16021
|
}
|
|
15927
16022
|
var CodexRpc = class {
|
|
@@ -16021,9 +16116,9 @@ function startAppServer(deps, args, hooks) {
|
|
|
16021
16116
|
return { child, rpc };
|
|
16022
16117
|
}
|
|
16023
16118
|
var CodexSession = class {
|
|
16024
|
-
constructor(conversationUuid, resumeRef,
|
|
16119
|
+
constructor(conversationUuid, resumeRef, replySchema, agentName, deps) {
|
|
16025
16120
|
this.conversationUuid = conversationUuid;
|
|
16026
|
-
this.
|
|
16121
|
+
this.replySchema = replySchema;
|
|
16027
16122
|
this.agentName = agentName;
|
|
16028
16123
|
this.deps = deps;
|
|
16029
16124
|
this.resumed = resumeRef !== void 0;
|
|
@@ -16037,7 +16132,7 @@ var CodexSession = class {
|
|
|
16037
16132
|
this.started = this.start(resumeRef).then(() => void 0, toError);
|
|
16038
16133
|
}
|
|
16039
16134
|
conversationUuid;
|
|
16040
|
-
|
|
16135
|
+
replySchema;
|
|
16041
16136
|
agentName;
|
|
16042
16137
|
deps;
|
|
16043
16138
|
agent = "codex";
|
|
@@ -16072,7 +16167,7 @@ var CodexSession = class {
|
|
|
16072
16167
|
const exit = this.child.exit;
|
|
16073
16168
|
if (exit || !this.sessionRef) return { kind: "exited", code: exit?.code ?? null, signal: exit?.signal ?? null, stderrTail: exit?.stderrTail ?? "" };
|
|
16074
16169
|
const turn = { resolve: () => {
|
|
16075
|
-
}, facts: new
|
|
16170
|
+
}, facts: new TurnFactsCollector() };
|
|
16076
16171
|
const outcome = new Promise((resolve4) => {
|
|
16077
16172
|
turn.resolve = resolve4;
|
|
16078
16173
|
});
|
|
@@ -16080,7 +16175,7 @@ var CodexSession = class {
|
|
|
16080
16175
|
try {
|
|
16081
16176
|
const started = await this.rpc.request(
|
|
16082
16177
|
"turn/start",
|
|
16083
|
-
codexTurnStartParams(this.sessionRef, text2,
|
|
16178
|
+
codexTurnStartParams(this.sessionRef, text2, this.replySchema)
|
|
16084
16179
|
);
|
|
16085
16180
|
const id = started.turn?.id;
|
|
16086
16181
|
if (typeof id === "string") {
|
|
@@ -16175,8 +16270,8 @@ var CodexSession = class {
|
|
|
16175
16270
|
const item = params.item && typeof params.item === "object" ? params.item : {};
|
|
16176
16271
|
if (item.type === "agentMessage" && typeof item.text === "string") {
|
|
16177
16272
|
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);
|
|
16273
|
+
} else if (item.type === "mcpToolCall" && item.server === AINECTO_MCP_SERVER && typeof item.tool === "string" && item.status !== "failed") {
|
|
16274
|
+
turn.facts.add(item.result?.content, this.deps.writeTools.has(item.tool));
|
|
16180
16275
|
}
|
|
16181
16276
|
}
|
|
16182
16277
|
};
|
|
@@ -16408,7 +16503,7 @@ async function pcRemoteSetup(input) {
|
|
|
16408
16503
|
pcId: settings.pcId,
|
|
16409
16504
|
hostName,
|
|
16410
16505
|
remoteEnabled: userId !== void 0 && settings.accounts[accountKey(input.endpoint, userId)]?.remoteTerminal === true,
|
|
16411
|
-
|
|
16506
|
+
appHome: input.appHome ?? appHome(),
|
|
16412
16507
|
env: input.env ?? stringEnv()
|
|
16413
16508
|
};
|
|
16414
16509
|
}
|
|
@@ -16435,7 +16530,7 @@ async function runPcRemote(setup, signal, onAnswer) {
|
|
|
16435
16530
|
remoteEnabled: setup.remoteEnabled,
|
|
16436
16531
|
exclude: [PC_SESSION_NAME],
|
|
16437
16532
|
sessionEnv: setup.env,
|
|
16438
|
-
|
|
16533
|
+
appHome: setup.appHome,
|
|
16439
16534
|
signal,
|
|
16440
16535
|
print: (line) => setup.io.stderr.write(`${line}
|
|
16441
16536
|
`),
|
|
@@ -16489,7 +16584,7 @@ async function executeAgentServe(input) {
|
|
|
16489
16584
|
const bridge = (agentName) => ainectoBridge(process.execPath, cliScript, input.endpoint, agentName);
|
|
16490
16585
|
const shared = { spawnImpl: spawnAgent, cwd: paths.work, env: agentEnv(process.env), log, writeTools };
|
|
16491
16586
|
const all = [
|
|
16492
|
-
claudeCodeAdapter({ ...shared, args: ({ textMaxCharacters, resumeSessionId, agentName }) => claudeAgentArgs({ schema: agentReplySchema(textMaxCharacters), mcpConfig: claudeMcpConfig(bridge(agentName)), resumeSessionId }) }),
|
|
16587
|
+
claudeCodeAdapter({ ...shared, args: ({ textMaxCharacters, documentsMax, resumeSessionId, agentName }) => claudeAgentArgs({ schema: agentReplySchema(textMaxCharacters, documentsMax), mcpConfig: claudeMcpConfig(bridge(agentName)), resumeSessionId }) }),
|
|
16493
16588
|
codexAdapter({ ...shared, appServerArgs: (agentName) => codexAppServerArgs(bridge(agentName), writeTools), clientVersion: CLI_VERSION })
|
|
16494
16589
|
];
|
|
16495
16590
|
const checks = await checkAgents(all, log);
|
|
@@ -16763,7 +16858,7 @@ async function runAinectoCli(argv, io) {
|
|
|
16763
16858
|
if (!response.ok) throw new Error(`HTTP ${response.status}`);
|
|
16764
16859
|
return await response.json();
|
|
16765
16860
|
},
|
|
16766
|
-
makeTempDir: () => mkdtemp(
|
|
16861
|
+
makeTempDir: () => mkdtemp(join10(tmpdir(), "ainecto-upgrade-")),
|
|
16767
16862
|
removeDir: (path) => rm3(path, { recursive: true, force: true }),
|
|
16768
16863
|
home: homedir5(),
|
|
16769
16864
|
log: openAgentLog(swapPaths)
|