ainecto 0.14.0-next.3 → 0.14.0-next.4
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 +58 -15
- package/dist/bin/ainecto.js.map +1 -1
- package/dist/bin/mcp.js +1 -1
- package/package.json +1 -1
package/dist/bin/ainecto.js
CHANGED
|
@@ -5678,7 +5678,7 @@ function legacyRoleInput(flag, envVars = process.env) {
|
|
|
5678
5678
|
|
|
5679
5679
|
// src/core/version.ts
|
|
5680
5680
|
var UNBUNDLED_VERSION = "dev";
|
|
5681
|
-
var CLI_VERSION = true ? "0.14.0-next.
|
|
5681
|
+
var CLI_VERSION = true ? "0.14.0-next.4" : UNBUNDLED_VERSION;
|
|
5682
5682
|
var PACKAGE_NAME = "@ainecto/mcp";
|
|
5683
5683
|
var CLI_USER_AGENT = `${PACKAGE_NAME} ${CLI_VERSION}`;
|
|
5684
5684
|
function bridgePackageSpec(version = CLI_VERSION) {
|
|
@@ -13571,15 +13571,7 @@ function str(value) {
|
|
|
13571
13571
|
|
|
13572
13572
|
// src/core/agent/reply.ts
|
|
13573
13573
|
function replyForOutcome(outcome, limits, agentName) {
|
|
13574
|
-
const
|
|
13575
|
-
const documentUuids = facts ? facts.documents.slice(0, limits.documentsMax) : [];
|
|
13576
|
-
const createdDocumentUuids = facts ? facts.createdDocuments.filter((uuid) => documentUuids.includes(uuid)) : [];
|
|
13577
|
-
const cardUuids = facts ? facts.cards.slice(0, limits.documentsMax) : [];
|
|
13578
|
-
const attached = {
|
|
13579
|
-
documentUuids,
|
|
13580
|
-
...createdDocumentUuids.length > 0 ? { createdDocumentUuids } : {},
|
|
13581
|
-
...cardUuids.length > 0 ? { cardUuids } : {}
|
|
13582
|
-
};
|
|
13574
|
+
const attached = attachedWork(outcome, limits);
|
|
13583
13575
|
const failed = (errorCode2, text) => ({ status: "FAILED", errorCode: errorCode2, reply: clip(text, limits.textMaxCharacters), ...attached });
|
|
13584
13576
|
switch (outcome.kind) {
|
|
13585
13577
|
case "timeout":
|
|
@@ -13604,6 +13596,24 @@ ${raw}`);
|
|
|
13604
13596
|
}
|
|
13605
13597
|
}
|
|
13606
13598
|
}
|
|
13599
|
+
function stoppedReply(outcome, limits) {
|
|
13600
|
+
return {
|
|
13601
|
+
status: "STOPPED",
|
|
13602
|
+
reply: clip("\uC911\uB2E8\uD588\uC5B4\uC694. \uADF8\uB54C\uAE4C\uC9C0 \uD55C \uC77C(\uBB38\uC11C\xB7\uCE74\uB4DC)\uC740 \uB0A8\uC544 \uC788\uC5B4\uC694.", limits.textMaxCharacters),
|
|
13603
|
+
...outcome ? attachedWork(outcome, limits) : { documentUuids: [] }
|
|
13604
|
+
};
|
|
13605
|
+
}
|
|
13606
|
+
function attachedWork(outcome, limits) {
|
|
13607
|
+
const facts = outcome.kind === "result" ? outcome.facts : void 0;
|
|
13608
|
+
const documentUuids = facts ? facts.documents.slice(0, limits.documentsMax) : [];
|
|
13609
|
+
const createdDocumentUuids = facts ? facts.createdDocuments.filter((uuid) => documentUuids.includes(uuid)) : [];
|
|
13610
|
+
const cardUuids = facts ? facts.cards.slice(0, limits.documentsMax) : [];
|
|
13611
|
+
return {
|
|
13612
|
+
documentUuids,
|
|
13613
|
+
...createdDocumentUuids.length > 0 ? { createdDocumentUuids } : {},
|
|
13614
|
+
...cardUuids.length > 0 ? { cardUuids } : {}
|
|
13615
|
+
};
|
|
13616
|
+
}
|
|
13607
13617
|
function codePoints(text) {
|
|
13608
13618
|
return Array.from(text).length;
|
|
13609
13619
|
}
|
|
@@ -13613,8 +13623,9 @@ function clip(text, max) {
|
|
|
13613
13623
|
}
|
|
13614
13624
|
|
|
13615
13625
|
// src/core/agent/serve.ts
|
|
13626
|
+
var PC_FEATURES = ["stop"];
|
|
13616
13627
|
async function runAgentServe(deps) {
|
|
13617
|
-
const opened = await
|
|
13628
|
+
const opened = await openLink(deps);
|
|
13618
13629
|
const linkId = String(opened.linkId);
|
|
13619
13630
|
deps.http.useLinkToken(String(opened.linkToken));
|
|
13620
13631
|
const limits = serverLimits(opened.limits);
|
|
@@ -13627,6 +13638,15 @@ async function runAgentServe(deps) {
|
|
|
13627
13638
|
const live = /* @__PURE__ */ new Map();
|
|
13628
13639
|
const received = /* @__PURE__ */ new Set();
|
|
13629
13640
|
const queue = [];
|
|
13641
|
+
const stopping = /* @__PURE__ */ new Set();
|
|
13642
|
+
let current;
|
|
13643
|
+
const requestStop = (turnUuid) => {
|
|
13644
|
+
if (stopping.has(turnUuid)) return;
|
|
13645
|
+
stopping.add(turnUuid);
|
|
13646
|
+
const running = current?.turnUuid === turnUuid;
|
|
13647
|
+
deps.log.write({ event: "stop_request", turnUuid, running, queued: queue.some((o) => o.turnUuid === turnUuid) });
|
|
13648
|
+
if (running) void current?.session.interrupt();
|
|
13649
|
+
};
|
|
13630
13650
|
const stop = (reason, code, message) => {
|
|
13631
13651
|
if (stopReason) return;
|
|
13632
13652
|
stopReason = reason;
|
|
@@ -13664,6 +13684,7 @@ async function runAgentServe(deps) {
|
|
|
13664
13684
|
queue.push(offer);
|
|
13665
13685
|
wakeWorker?.();
|
|
13666
13686
|
}
|
|
13687
|
+
for (const turnUuid of stopsIn(res)) requestStop(turnUuid);
|
|
13667
13688
|
} catch (error) {
|
|
13668
13689
|
if (stopReason) return;
|
|
13669
13690
|
if (error instanceof AgentCallError && !error.retryable) {
|
|
@@ -13710,6 +13731,10 @@ async function runAgentServe(deps) {
|
|
|
13710
13731
|
textLength: offer.text.length
|
|
13711
13732
|
});
|
|
13712
13733
|
}
|
|
13734
|
+
if (stopping.has(offer.turnUuid)) {
|
|
13735
|
+
reply = stoppedReply(void 0, limits);
|
|
13736
|
+
return reply;
|
|
13737
|
+
}
|
|
13713
13738
|
if (!adapter || !session) {
|
|
13714
13739
|
failure2 = "agent not installed";
|
|
13715
13740
|
reply = {
|
|
@@ -13720,7 +13745,12 @@ async function runAgentServe(deps) {
|
|
|
13720
13745
|
};
|
|
13721
13746
|
return reply;
|
|
13722
13747
|
}
|
|
13723
|
-
|
|
13748
|
+
current = { turnUuid: offer.turnUuid, session };
|
|
13749
|
+
try {
|
|
13750
|
+
outcome = await session.send(agentPromptText(offer.text, offer.context), deps.turnTimeoutMs ?? AGENT_TURN_TIMEOUT_MS);
|
|
13751
|
+
} finally {
|
|
13752
|
+
current = void 0;
|
|
13753
|
+
}
|
|
13724
13754
|
if (outcome.kind === "timeout") {
|
|
13725
13755
|
await session.interrupt();
|
|
13726
13756
|
await session.close();
|
|
@@ -13731,7 +13761,7 @@ async function runAgentServe(deps) {
|
|
|
13731
13761
|
} else if (session.sessionRef) {
|
|
13732
13762
|
await deps.sessions.set(offer.conversationUuid, adapter.id, session.sessionRef);
|
|
13733
13763
|
}
|
|
13734
|
-
reply = replyForOutcome(outcome, limits, adapter.displayName);
|
|
13764
|
+
reply = stopping.has(offer.turnUuid) ? stoppedReply(outcome, limits) : replyForOutcome(outcome, limits, adapter.displayName);
|
|
13735
13765
|
return reply;
|
|
13736
13766
|
} catch (error) {
|
|
13737
13767
|
failure2 = error instanceof Error ? error.message : String(error);
|
|
@@ -13820,6 +13850,19 @@ function serverLimits(value) {
|
|
|
13820
13850
|
};
|
|
13821
13851
|
return { pollHoldSeconds: num("pollHoldSeconds"), textMaxCharacters: num("textMaxCharacters"), documentsMax: num("documentsMax") };
|
|
13822
13852
|
}
|
|
13853
|
+
async function openLink(deps) {
|
|
13854
|
+
const base = { hostName: deps.hostName, cliVersion: deps.cliVersion, agents: deps.agents };
|
|
13855
|
+
try {
|
|
13856
|
+
return await deps.http.call("open", { ...base, features: [...PC_FEATURES] });
|
|
13857
|
+
} catch (error) {
|
|
13858
|
+
if (!(error instanceof AgentCallError) || error.status !== 400 || error.code !== "INVALID") throw error;
|
|
13859
|
+
deps.log.write({ event: "open_without_features", features: [...PC_FEATURES] });
|
|
13860
|
+
return await deps.http.call("open", base);
|
|
13861
|
+
}
|
|
13862
|
+
}
|
|
13863
|
+
function stopsIn(res) {
|
|
13864
|
+
return Array.isArray(res.stops) ? res.stops.filter((t) => typeof t === "string") : [];
|
|
13865
|
+
}
|
|
13823
13866
|
function offersIn(res) {
|
|
13824
13867
|
if (!Array.isArray(res.offers)) return [];
|
|
13825
13868
|
return res.offers.flatMap((o) => {
|
|
@@ -13968,8 +14011,8 @@ async function executeAgentServe(input) {
|
|
|
13968
14011
|
const name = all.find((adapter) => adapter.id === check.id)?.displayName ?? check.id;
|
|
13969
14012
|
if (!check.installed) continue;
|
|
13970
14013
|
if (check.ready) {
|
|
13971
|
-
input.io.stderr.write(check.auth === "apiKey" ? `${name}: runs on your own API key (billed to your ${BILLED_TO[check.id]} API account).
|
|
13972
|
-
` : `${name}: runs on your subscription login (uses your plan's limits).
|
|
14014
|
+
input.io.stderr.write(check.auth === "apiKey" ? `${name}: runs on your own API key (billed to your ${BILLED_TO[check.id]} API account; AiNecto credits are not used).
|
|
14015
|
+
` : `${name}: runs on your subscription login (uses your plan's limits; AiNecto credits are not used).
|
|
13973
14016
|
`);
|
|
13974
14017
|
} else {
|
|
13975
14018
|
input.io.stderr.write(`${name} is installed but not signed in${check.detail ? ` (${check.detail})` : ""}. Requests to ${name} will be refused until you sign in and run \`ainecto agent serve\` again.
|