@powerhousedao/clint 0.0.0-stage → 6.2.3-dev.100
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +661 -0
- package/dist/build-skills-Cfj0OGnW.mjs +293 -0
- package/dist/build-skills-Cfj0OGnW.mjs.map +1 -0
- package/dist/dist-CUltriBW.mjs +1628 -0
- package/dist/dist-CUltriBW.mjs.map +1 -0
- package/dist/drive-BEshRPDR.mjs +84 -0
- package/dist/drive-BEshRPDR.mjs.map +1 -0
- package/dist/esm-C1DOsF1a.mjs +13140 -0
- package/dist/esm-C1DOsF1a.mjs.map +1 -0
- package/dist/events-BnwGFTjv.mjs +237 -0
- package/dist/events-BnwGFTjv.mjs.map +1 -0
- package/dist/folders-C-pFsTXT.mjs +256 -0
- package/dist/folders-C-pFsTXT.mjs.map +1 -0
- package/dist/index.d.mts +1005 -0
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +8 -0
- package/dist/local-signer-EFzJV3bn.mjs +128 -0
- package/dist/local-signer-EFzJV3bn.mjs.map +1 -0
- package/dist/markdown-D-sP2zw_.mjs +275 -0
- package/dist/markdown-D-sP2zw_.mjs.map +1 -0
- package/dist/proxy-BFR8GScT.mjs +302 -0
- package/dist/proxy-BFR8GScT.mjs.map +1 -0
- package/dist/proxy-routes-DP3ztsnS.mjs +215 -0
- package/dist/proxy-routes-DP3ztsnS.mjs.map +1 -0
- package/dist/reactor-C9VIUX1H.mjs +51 -0
- package/dist/reactor-C9VIUX1H.mjs.map +1 -0
- package/dist/rolldown-runtime-8H4AJuhK.mjs +14 -0
- package/dist/runners/clint-runner.d.mts +398 -0
- package/dist/runners/clint-runner.d.mts.map +1 -0
- package/dist/runners/clint-runner.mjs +522 -0
- package/dist/runners/clint-runner.mjs.map +1 -0
- package/dist/runners/mastra-runner.d.mts +300 -0
- package/dist/runners/mastra-runner.d.mts.map +1 -0
- package/dist/runners/mastra-runner.mjs +516 -0
- package/dist/runners/mastra-runner.mjs.map +1 -0
- package/dist/services-9E-r0nWl.mjs +999 -0
- package/dist/services-9E-r0nWl.mjs.map +1 -0
- package/dist/src-DD8PWpD5.mjs +4767 -0
- package/dist/src-DD8PWpD5.mjs.map +1 -0
- package/dist/start-b7Mn2cxB.mjs +1526 -0
- package/dist/start-b7Mn2cxB.mjs.map +1 -0
- package/dist/stdin-BjAO9gPK.mjs +17 -0
- package/dist/stdin-BjAO9gPK.mjs.map +1 -0
- package/dist/stream-DVuufwIj.mjs +148 -0
- package/dist/stream-DVuufwIj.mjs.map +1 -0
- package/dist/subscriptions-CfiflAsI.mjs +38 -0
- package/dist/subscriptions-CfiflAsI.mjs.map +1 -0
- package/dist/switchboard-CyvOavqL.mjs +57 -0
- package/dist/switchboard-CyvOavqL.mjs.map +1 -0
- package/dist/types-CRkoD-Mm.d.mts +1770 -0
- package/dist/types-CRkoD-Mm.d.mts.map +1 -0
- package/package.json +102 -3
- package/README.md +0 -3
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/core/pkg.ts","../src/core/command.ts","../src/core/errors.ts","../src/core/logger.ts","../src/core/cli.ts","../src/core/trigger.ts","../src/integrations/powerhouse/change-trigger.ts","../src/core/types-binding.ts","../src/core/schema.ts","../src/core/store.ts","../src/core/config.ts","../src/core/config-command.ts","../src/core/workdir.ts","../src/core/events.ts","../src/core/processes.ts","../src/core/services.ts","../src/core/service-command.ts","../src/core/project-mapping.ts","../src/core/preflight.ts","../src/core/help-command.ts","../src/core/init.ts","../src/core/skill-commands.ts","../src/core/templates.ts","../src/core/routine.ts","../src/core/routine-service.ts","../src/core/stream.ts","../src/core/proxy.ts","../src/interactive/types.ts","../src/interactive/session.ts","../src/interactive/router.ts","../src/interactive/completions.ts","../src/interactive/markdown.ts","../src/integrations/powerhouse/registry.ts","../src/integrations/powerhouse/ports.ts","../src/integrations/powerhouse/identity.ts","../src/integrations/powerhouse/switchboard.ts","../src/integrations/powerh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,GAAG,SAAS;;;;;;;;;;;;;;;;;wBAoBhB,qBACR,UAAU,cAAc,2BAC9B,SAAS,IAAI,cAAc;;;;;;;;wBClDb,YAAY,iBAAiB;;;;;;;;;wBAmBvB,YACpB,cACA,eACA,gBACC;;;;;;;;wBAqBa,uBACd,iBACA,QAAQ,KAAK;EACV,cAAc;EAAmB,UAAU;;;;;;;;;;;;;;;;;;;;;wBC/ChC,gBAAgB,iBAAiB;;;UCThC;;EAEf,eAAe;;EAEf;;EAEA;;EAEA;;EAEA;;;;;;EAMA;;;;;;;;;wBAmDoB,iBACpB,SAAS,0BACR,QAAQ;;;;;;;;;;;;;;;wBClEK,UACd,UAAU,kBACV,gBAAgB,YAChB,KAAK,QAAQ,yBAAyB,MAAM,IAAI,OAAO,EAAE;;;;;;UC4D1C,2BACf,UAAU,mBAAmB;;EAG7B,gBAAgB;;EAEhB,QAAQ;;EAER,SAAS,MACP;IAAgB;IAA8B;;;EAGhD,gBAAgB,mBAAmB;;;;;;;;;wBAUf,oBACpB,UAAU,mBAAmB,aAE7B,KAAK,oBAAoB,IACzB,SAAS,2BAA2B,KACnC,QAAQ,eAAe;;;;;;;;;;qBC/Fb,gBAAgB;;;;;;;;wBAuCb,aAAa,SAAS,oBAAoB;;;UCxCzC;;EAEf,OAAO;;;;;;EAMP,gBAAgB;;EAEhB,SAAS;;;;;;;;;;;wBAYW,cACpB,OAAO,iBACP,KAAK,uBACJ,QAAQ"}
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { A as generateConfigCommandHelp, B as createWorkdirStore, C as extractTemplateVars, D as installSkills, E as readSkills, F as resolveConfig, G as formatZodError, H as resolvePort, I as toUpperSnake, K as defineCommand, L as userConfigPath, M as configKeyToEnvVar, N as getMissingRequiredFields, O as createHelpCommand, P as localConfigPath, R as userStoreFolder, S as isSkillInvocation, T as renderSkillTemplate, U as resolveReactorDefaults, V as defaultPort, W as createLogger, _ as IDENTITY_WRAPS, a as getProjectMapping, b as DEFAULT_SKILL_INSTRUCTION, c as defineTrigger, d as createReplSession, f as parseReplInput, g as createRoutine, h as createRoutineServiceAdapter, i as defineRegistry, j as resolveWorkdir, k as createConfigCommand, l as defineCli, m as createCompositeServiceManager, n as isDocType, o as createTypes, p as tokenizeArgs, q as readPackageInfo, r as deterministicId, s as createDocumentChangeTrigger, t as buildDefaultReactor, u as initLifecycle, v as composeWraps, w as registerDefaultHelpers, x as createSkillCommands, y as createProcessManager, z as createMemoryWorkdirStore } from "./src-DD8PWpD5.mjs";
|
|
2
|
+
import { a as scanProjects, c as checkCommand, d as isPortFree, f as getSchemaFields, i as PROJECT_INDICATORS, l as checkPort, n as defineService, p as slugToTitle, r as resolveServiceName, t as createServiceManager, u as checkWorkdir } from "./services-9E-r0nWl.mjs";
|
|
3
|
+
import { a as getGhostSuggestion, i as getCompletions, n as applyCompletion, o as formatStreamChunk, r as getCompletionSuffix, s as renderStream, t as renderMarkdown } from "./markdown-D-sP2zw_.mjs";
|
|
4
|
+
import { a as captureRoutePrefix, i as buildSwitchboardRoutes, r as buildSwitchboardRouteSpecs, s as isWsEndpointType, t as buildServiceRoutes } from "./proxy-routes-DP3ztsnS.mjs";
|
|
5
|
+
import { n as createServiceCommands, r as formatStatus, t as createEventBus } from "./events-BnwGFTjv.mjs";
|
|
6
|
+
import { t as createProxyServer } from "./proxy-BFR8GScT.mjs";
|
|
7
|
+
import { t as startSwitchboard } from "./switchboard-CyvOavqL.mjs";
|
|
8
|
+
export { DEFAULT_SKILL_INSTRUCTION, IDENTITY_WRAPS, PROJECT_INDICATORS, applyCompletion, buildDefaultReactor, buildServiceRoutes, buildSwitchboardRouteSpecs, buildSwitchboardRoutes, captureRoutePrefix, checkCommand, checkPort, checkWorkdir, composeWraps, configKeyToEnvVar, createCompositeServiceManager, createConfigCommand, createDocumentChangeTrigger, createEventBus, createHelpCommand, createLogger, createMemoryWorkdirStore, createProcessManager, createProxyServer, createReplSession, createRoutine, createRoutineServiceAdapter, createServiceCommands, createServiceManager, createSkillCommands, createTypes, createWorkdirStore, defaultPort, defineCli, defineCommand, defineRegistry, defineService, defineTrigger, deterministicId, extractTemplateVars, formatStatus, formatStreamChunk, formatZodError, generateConfigCommandHelp, getCompletionSuffix, getCompletions, getGhostSuggestion, getMissingRequiredFields, getProjectMapping, getSchemaFields, initLifecycle, installSkills, isDocType, isPortFree, isSkillInvocation, isWsEndpointType, localConfigPath, parseReplInput, readPackageInfo, readSkills, registerDefaultHelpers, renderMarkdown, renderSkillTemplate, renderStream, resolveConfig, resolvePort, resolveReactorDefaults, resolveServiceName, resolveWorkdir, scanProjects, slugToTitle, startSwitchboard, toUpperSnake, tokenizeArgs, userConfigPath, userStoreFolder };
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { signActionV2 } from "@powerhousedao/shared/document-model";
|
|
2
|
+
//#region src/integrations/powerhouse/local-signer.ts
|
|
3
|
+
/**
|
|
4
|
+
* Attribution for an unauthenticated clint reactor. The zero address says
|
|
5
|
+
* "nobody in particular" rather than impersonating a wallet; pass
|
|
6
|
+
* {@link LocalSignerOptions.user} to attribute writes to a real identity.
|
|
7
|
+
*/
|
|
8
|
+
const ANONYMOUS_CLINT_USER = {
|
|
9
|
+
address: "0x0000000000000000000000000000000000000000",
|
|
10
|
+
networkId: "eip155",
|
|
11
|
+
chainId: 1
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* The clint-embedded reactor's signer — replicated from reactor-monitor's
|
|
15
|
+
* LocalSigner (unpublished package; NOTE(port): new documents are v2-required
|
|
16
|
+
* by default on the modern stack, and clint's old embedded reactor submitted
|
|
17
|
+
* unsigned actions — UNSIGNED_REQUIRED on every write): a fresh in-memory P-256 key, no Renown.
|
|
18
|
+
*
|
|
19
|
+
* This is the smallest signer the stack actually works with, and the reason
|
|
20
|
+
* it is a real key rather than a no-op stub is worth stating: new documents
|
|
21
|
+
* are created `v2-required` by default, and `v2-required` refuses an unsigned
|
|
22
|
+
* write (`UNSIGNED_REQUIRED`) regardless of `authEnforcement`. A
|
|
23
|
+
* signs-nothing signer therefore cannot create a document at all. Signing
|
|
24
|
+
* with a local key keeps the default policy intact while staying free of key
|
|
25
|
+
* storage, wallets and credential services.
|
|
26
|
+
*
|
|
27
|
+
* What it deliberately does not do:
|
|
28
|
+
* - persist the key: it is regenerated per boot, so signatures from an
|
|
29
|
+
* earlier session verify against the tuple they carry, not against this
|
|
30
|
+
* key;
|
|
31
|
+
* - prove anything about the signing identity. There is no credential
|
|
32
|
+
* binding this key to `user`, so `featureFlags.authEnforcement` must stay
|
|
33
|
+
* off (under it a signed write with no trust policy is refused);
|
|
34
|
+
* - verify: `verify()` resolves, which is what the reactor's own signature
|
|
35
|
+
* verification path expects of a host signer (it verifies tuples itself,
|
|
36
|
+
* against the key in the tuple).
|
|
37
|
+
*/
|
|
38
|
+
var LocalSigner = class LocalSigner {
|
|
39
|
+
user;
|
|
40
|
+
app;
|
|
41
|
+
publicKey;
|
|
42
|
+
privateKey;
|
|
43
|
+
constructor(keyPair, did, user, appName) {
|
|
44
|
+
this.publicKey = keyPair.publicKey;
|
|
45
|
+
this.privateKey = keyPair.privateKey;
|
|
46
|
+
this.user = user;
|
|
47
|
+
this.app = {
|
|
48
|
+
name: appName,
|
|
49
|
+
key: did
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
/** The `did:key` this signer's tuples name as the signing key. */
|
|
53
|
+
get did() {
|
|
54
|
+
return this.app.key;
|
|
55
|
+
}
|
|
56
|
+
static async create(options = {}) {
|
|
57
|
+
const keyPair = await crypto.subtle.generateKey({
|
|
58
|
+
name: "ECDSA",
|
|
59
|
+
namedCurve: "P-256"
|
|
60
|
+
}, true, ["sign", "verify"]);
|
|
61
|
+
return new LocalSigner(keyPair, await didKeyFor(keyPair.publicKey), options.user ?? ANONYMOUS_CLINT_USER, options.appName ?? "clint");
|
|
62
|
+
}
|
|
63
|
+
async sign(data) {
|
|
64
|
+
const signature = await crypto.subtle.sign({
|
|
65
|
+
name: "ECDSA",
|
|
66
|
+
hash: "SHA-256"
|
|
67
|
+
}, this.privateKey, data.buffer);
|
|
68
|
+
return new Uint8Array(signature);
|
|
69
|
+
}
|
|
70
|
+
verify() {
|
|
71
|
+
return Promise.resolve();
|
|
72
|
+
}
|
|
73
|
+
signAction(action, target) {
|
|
74
|
+
return signActionV2({
|
|
75
|
+
action,
|
|
76
|
+
target,
|
|
77
|
+
signer: {
|
|
78
|
+
user: this.user,
|
|
79
|
+
app: this.app
|
|
80
|
+
},
|
|
81
|
+
sign: (data) => this.sign(data)
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
/** Convenience over {@link LocalSigner.create}. */
|
|
86
|
+
function createLocalSigner(options) {
|
|
87
|
+
return LocalSigner.create(options);
|
|
88
|
+
}
|
|
89
|
+
const BASE58 = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";
|
|
90
|
+
const P256_MULTICODEC = [128, 36];
|
|
91
|
+
/**
|
|
92
|
+
* `did:key:z<base58btc(multicodec || compressed point)>` for a P-256 key —
|
|
93
|
+
* the form `packages/reactor`'s `importDidKey` decodes. Encoding lives here
|
|
94
|
+
* because `@powerhousedao/shared/document-model` exports `base58Decode` but
|
|
95
|
+
* not `base58Encode`.
|
|
96
|
+
*/
|
|
97
|
+
async function didKeyFor(publicKey) {
|
|
98
|
+
const raw = new Uint8Array(await crypto.subtle.exportKey("raw", publicKey));
|
|
99
|
+
const compressed = /* @__PURE__ */ new Uint8Array(35);
|
|
100
|
+
compressed[0] = P256_MULTICODEC[0];
|
|
101
|
+
compressed[1] = P256_MULTICODEC[1];
|
|
102
|
+
compressed[2] = (raw[64] & 1) === 1 ? 3 : 2;
|
|
103
|
+
compressed.set(raw.subarray(1, 33), 3);
|
|
104
|
+
return `did:key:z${base58Encode(compressed)}`;
|
|
105
|
+
}
|
|
106
|
+
function base58Encode(bytes) {
|
|
107
|
+
const digits = [0];
|
|
108
|
+
for (const byte of bytes) {
|
|
109
|
+
let carry = byte;
|
|
110
|
+
for (let i = 0; i < digits.length; i++) {
|
|
111
|
+
carry += digits[i] << 8;
|
|
112
|
+
digits[i] = carry % 58;
|
|
113
|
+
carry = Math.floor(carry / 58);
|
|
114
|
+
}
|
|
115
|
+
while (carry > 0) {
|
|
116
|
+
digits.push(carry % 58);
|
|
117
|
+
carry = Math.floor(carry / 58);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
let out = "";
|
|
121
|
+
for (let k = 0; k < bytes.length && bytes[k] === 0; k++) out += "1";
|
|
122
|
+
for (let i = digits.length - 1; i >= 0; i--) out += BASE58[digits[i]];
|
|
123
|
+
return out;
|
|
124
|
+
}
|
|
125
|
+
//#endregion
|
|
126
|
+
export { createLocalSigner };
|
|
127
|
+
|
|
128
|
+
//# sourceMappingURL=local-signer-EFzJV3bn.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"local-signer-EFzJV3bn.mjs","names":[],"sources":["../src/integrations/powerhouse/local-signer.ts"],"sourcesContent":["import {\n signActionV2,\n type Action,\n type ActionSigningTarget,\n type AppActionSigner,\n type ISigner,\n type Signature,\n type UserActionSigner,\n} from \"@powerhousedao/shared/document-model\";\n\n/**\n * Attribution for an unauthenticated clint reactor. The zero address says\n * \"nobody in particular\" rather than impersonating a wallet; pass\n * {@link LocalSignerOptions.user} to attribute writes to a real identity.\n */\nexport const ANONYMOUS_CLINT_USER: UserActionSigner = {\n address: \"0x0000000000000000000000000000000000000000\",\n networkId: \"eip155\",\n chainId: 1,\n};\n\nexport const CLINT_APP_NAME = \"clint\";\n\nexport type LocalSignerOptions = {\n /** Who writes are attributed to. Defaults to {@link ANONYMOUS_CLINT_USER}. */\n user?: UserActionSigner;\n /** The `app.name` half of the signer identity. */\n appName?: string;\n};\n\n/**\n * The clint-embedded reactor's signer — replicated from reactor-monitor's\n * LocalSigner (unpublished package; NOTE(port): new documents are v2-required\n * by default on the modern stack, and clint's old embedded reactor submitted\n * unsigned actions — UNSIGNED_REQUIRED on every write): a fresh in-memory P-256 key, no Renown.\n *\n * This is the smallest signer the stack actually works with, and the reason\n * it is a real key rather than a no-op stub is worth stating: new documents\n * are created `v2-required` by default, and `v2-required` refuses an unsigned\n * write (`UNSIGNED_REQUIRED`) regardless of `authEnforcement`. A\n * signs-nothing signer therefore cannot create a document at all. Signing\n * with a local key keeps the default policy intact while staying free of key\n * storage, wallets and credential services.\n *\n * What it deliberately does not do:\n * - persist the key: it is regenerated per boot, so signatures from an\n * earlier session verify against the tuple they carry, not against this\n * key;\n * - prove anything about the signing identity. There is no credential\n * binding this key to `user`, so `featureFlags.authEnforcement` must stay\n * off (under it a signed write with no trust policy is refused);\n * - verify: `verify()` resolves, which is what the reactor's own signature\n * verification path expects of a host signer (it verifies tuples itself,\n * against the key in the tuple).\n */\nexport class LocalSigner implements ISigner {\n readonly user: UserActionSigner;\n readonly app: AppActionSigner;\n readonly publicKey: CryptoKey;\n private readonly privateKey: CryptoKey;\n\n private constructor(\n keyPair: CryptoKeyPair,\n did: string,\n user: UserActionSigner,\n appName: string,\n ) {\n this.publicKey = keyPair.publicKey;\n this.privateKey = keyPair.privateKey;\n this.user = user;\n this.app = { name: appName, key: did };\n }\n\n /** The `did:key` this signer's tuples name as the signing key. */\n get did(): string {\n return this.app.key;\n }\n\n static async create(options: LocalSignerOptions = {}): Promise<LocalSigner> {\n const keyPair = await crypto.subtle.generateKey(\n { name: \"ECDSA\", namedCurve: \"P-256\" },\n true,\n [\"sign\", \"verify\"],\n );\n return new LocalSigner(\n keyPair,\n await didKeyFor(keyPair.publicKey),\n options.user ?? ANONYMOUS_CLINT_USER,\n options.appName ?? CLINT_APP_NAME,\n );\n }\n\n async sign(data: Uint8Array): Promise<Uint8Array> {\n const signature = await crypto.subtle.sign(\n { name: \"ECDSA\", hash: \"SHA-256\" },\n this.privateKey,\n data.buffer as ArrayBuffer,\n );\n return new Uint8Array(signature);\n }\n\n verify(): Promise<void> {\n return Promise.resolve();\n }\n\n signAction(action: Action, target: ActionSigningTarget): Promise<Signature> {\n return signActionV2({\n action,\n target,\n signer: { user: this.user, app: this.app },\n sign: (data) => this.sign(data),\n });\n }\n}\n\n/** Convenience over {@link LocalSigner.create}. */\nexport function createLocalSigner(\n options?: LocalSignerOptions,\n): Promise<ISigner> {\n return LocalSigner.create(options);\n}\n\nconst BASE58 = \"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz\";\nconst P256_MULTICODEC = [0x80, 0x24] as const;\n\n/**\n * `did:key:z<base58btc(multicodec || compressed point)>` for a P-256 key —\n * the form `packages/reactor`'s `importDidKey` decodes. Encoding lives here\n * because `@powerhousedao/shared/document-model` exports `base58Decode` but\n * not `base58Encode`.\n */\nasync function didKeyFor(publicKey: CryptoKey): Promise<string> {\n const raw = new Uint8Array(await crypto.subtle.exportKey(\"raw\", publicKey));\n const compressed = new Uint8Array(35);\n compressed[0] = P256_MULTICODEC[0];\n compressed[1] = P256_MULTICODEC[1];\n // Compressed SEC1: the prefix records the parity of y, then the 32-byte x.\n compressed[2] = (raw[64]! & 1) === 1 ? 0x03 : 0x02;\n compressed.set(raw.subarray(1, 33), 3);\n return `did:key:z${base58Encode(compressed)}`;\n}\n\nfunction base58Encode(bytes: Uint8Array): string {\n const digits: number[] = [0];\n for (const byte of bytes) {\n let carry = byte;\n for (let i = 0; i < digits.length; i++) {\n carry += digits[i]! << 8;\n digits[i] = carry % 58;\n carry = Math.floor(carry / 58);\n }\n while (carry > 0) {\n digits.push(carry % 58);\n carry = Math.floor(carry / 58);\n }\n }\n let out = \"\";\n for (let k = 0; k < bytes.length && bytes[k] === 0; k++) {\n out += \"1\";\n }\n for (let i = digits.length - 1; i >= 0; i--) {\n out += BASE58[digits[i]!];\n }\n return out;\n}\n"],"mappings":";;;;;;;AAeA,MAAa,uBAAyC;CACpD,SAAS;CACT,WAAW;CACX,SAAS;AACX;;;;;;;;;;;;;;;;;;;;;;;;;;AAoCA,IA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,IAAO;CAC9C,WAAW,IAAI,IAAI,SAAS,GAAG,EAAE,GAAG,CAAC;CACrC,OAAO,YAAY,aAAa,UAAU;AAC5C;AAEA,SAAS,aAAa,OAA2B;CAC/C,MAAM,SAAmB,CAAC,CAAC;CAC3B,KAAK,MAAM,QAAQ,OAAO;EACxB,IAAI,QAAQ;EACZ,KAAK,IAAI,IAAI,GAAG,IAAI,OAAO,QAAQ,KAAK;GACtC,SAAS,OAAO,MAAO;GACvB,OAAO,KAAK,QAAQ;GACpB,QAAQ,KAAK,MAAM,QAAQ,EAAE;EAC/B;EACA,OAAO,QAAQ,GAAG;GAChB,OAAO,KAAK,QAAQ,EAAE;GACtB,QAAQ,KAAK,MAAM,QAAQ,EAAE;EAC/B;CACF;CACA,IAAI,MAAM;CACV,KAAK,IAAI,IAAI,GAAG,IAAI,MAAM,UAAU,MAAM,OAAO,GAAG,KAClD,OAAO;CAET,KAAK,IAAI,IAAI,OAAO,SAAS,GAAG,KAAK,GAAG,KACtC,OAAO,OAAO,OAAO;CAEvB,OAAO;AACT"}
|
|
@@ -0,0 +1,275 @@
|
|
|
1
|
+
import { f as getSchemaFields } from "./services-9E-r0nWl.mjs";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
import { Marked } from "marked";
|
|
4
|
+
import { markedTerminal } from "marked-terminal";
|
|
5
|
+
import { supportsLanguage } from "cli-highlight";
|
|
6
|
+
//#region src/core/stream.ts
|
|
7
|
+
const DIM = "\x1B[2m";
|
|
8
|
+
const RESET = "\x1B[0m";
|
|
9
|
+
const RED = "\x1B[31m";
|
|
10
|
+
const GREEN_DIM = "\x1B[32;2m";
|
|
11
|
+
/**
|
|
12
|
+
* Format a single StreamChunk into a display string.
|
|
13
|
+
*
|
|
14
|
+
* This is the framework-level formatter. The Mastra integration maps
|
|
15
|
+
* Mastra's fullStream chunks to StreamChunk first, then this renders them.
|
|
16
|
+
*
|
|
17
|
+
* Tool activity is styled with dim green (calls/results) and red (errors)
|
|
18
|
+
* so it's visually distinct from the agent's text output.
|
|
19
|
+
*/
|
|
20
|
+
function formatStreamChunk(chunk) {
|
|
21
|
+
switch (chunk.type) {
|
|
22
|
+
case "text-delta": return chunk.text;
|
|
23
|
+
case "tool-call": return `\n${DIM}${GREEN_DIM}▶ ${chunk.toolName}${RESET}${DIM}(${truncateArgs(chunk.args)})${RESET}\n`;
|
|
24
|
+
case "tool-result":
|
|
25
|
+
if (chunk.isError) return `${RED}✗ ${chunk.toolName} error: ${formatResult(chunk.result)}${RESET}\n`;
|
|
26
|
+
const body = hasTextField(chunk.result) ? chunk.result.text : typeof chunk.result === "string" ? chunk.result : null;
|
|
27
|
+
if (body && body.length > 0) return `${DIM}${GREEN_DIM}✓ ${chunk.toolName}${RESET}\n${body}\n`;
|
|
28
|
+
return `${DIM}${GREEN_DIM}✓ ${chunk.toolName}${RESET}${DIM} → ${truncateResult(chunk.result)}${RESET}\n`;
|
|
29
|
+
case "tool-output": return chunk.text;
|
|
30
|
+
case "error": return `${RED}Error: ${chunk.error}${RESET}\n`;
|
|
31
|
+
case "step-finish":
|
|
32
|
+
case "finish": return "";
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Consume a stream of StreamChunks and yield { chunk, formatted } pairs.
|
|
37
|
+
*
|
|
38
|
+
* Inserts an extra newline before the first text-delta after tool activity,
|
|
39
|
+
* so the agent's prose is visually separated from tool call/result lines.
|
|
40
|
+
*/
|
|
41
|
+
async function* renderStream(stream) {
|
|
42
|
+
let lastChunkWasText = false;
|
|
43
|
+
for await (const chunk of stream) {
|
|
44
|
+
let prefix = "";
|
|
45
|
+
if (chunk.type === "text-delta") {
|
|
46
|
+
if (!lastChunkWasText) {
|
|
47
|
+
prefix = "\n";
|
|
48
|
+
lastChunkWasText = true;
|
|
49
|
+
}
|
|
50
|
+
} else lastChunkWasText = false;
|
|
51
|
+
yield {
|
|
52
|
+
chunk,
|
|
53
|
+
formatted: prefix + formatStreamChunk(chunk)
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
function truncateArgs(args) {
|
|
58
|
+
const json = JSON.stringify(args);
|
|
59
|
+
return json.length > 120 ? json.slice(0, 120) + "…" : json;
|
|
60
|
+
}
|
|
61
|
+
function truncateResult(result) {
|
|
62
|
+
const str = formatResult(result);
|
|
63
|
+
return str.length > 200 ? str.slice(0, 200) + "…" : str;
|
|
64
|
+
}
|
|
65
|
+
function formatResult(result) {
|
|
66
|
+
if (result === void 0 || result === null) return "ok";
|
|
67
|
+
if (typeof result === "string") return result;
|
|
68
|
+
return JSON.stringify(result);
|
|
69
|
+
}
|
|
70
|
+
function hasTextField(result) {
|
|
71
|
+
return typeof result === "object" && result !== null && "text" in result && typeof result.text === "string";
|
|
72
|
+
}
|
|
73
|
+
//#endregion
|
|
74
|
+
//#region src/interactive/completions.ts
|
|
75
|
+
/**
|
|
76
|
+
* Tokenize input respecting quotes, and report whether the cursor is inside
|
|
77
|
+
* an open quote (meaning we should not offer completions).
|
|
78
|
+
*/
|
|
79
|
+
function tokenizeInput(input) {
|
|
80
|
+
const tokens = [];
|
|
81
|
+
let current = "";
|
|
82
|
+
let inQuote = false;
|
|
83
|
+
let quoteChar = "";
|
|
84
|
+
for (const ch of input) if (inQuote) {
|
|
85
|
+
if (ch === quoteChar) inQuote = false;
|
|
86
|
+
else current += ch;
|
|
87
|
+
} else if (ch === "\"" || ch === "'") {
|
|
88
|
+
inQuote = true;
|
|
89
|
+
quoteChar = ch;
|
|
90
|
+
} else if (ch === " " || ch === " ") {
|
|
91
|
+
if (current) {
|
|
92
|
+
tokens.push(current);
|
|
93
|
+
current = "";
|
|
94
|
+
}
|
|
95
|
+
} else current += ch;
|
|
96
|
+
if (current) tokens.push(current);
|
|
97
|
+
const trailingSpace = !inQuote && input.length > 0 && (input[input.length - 1] === " " || input[input.length - 1] === " ");
|
|
98
|
+
return {
|
|
99
|
+
tokens,
|
|
100
|
+
inQuote,
|
|
101
|
+
trailingSpace
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Collect flag names already present in the tokens.
|
|
106
|
+
*/
|
|
107
|
+
function usedFlags(tokens) {
|
|
108
|
+
const used = /* @__PURE__ */ new Set();
|
|
109
|
+
for (const t of tokens) if (t.startsWith("--")) used.add(t);
|
|
110
|
+
return used;
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Get auto-completion suggestions for partial REPL input.
|
|
114
|
+
*
|
|
115
|
+
* Supports:
|
|
116
|
+
* - Command name completion: `/gr` → ['/greet']
|
|
117
|
+
* - Flag name completion: `/add --` → ['--title', '--priority', '--due']
|
|
118
|
+
* - Flag name after trailing space: `/add ` → ['--title', '--priority', '--due']
|
|
119
|
+
* - Enum value completion: `/list --filter d` → ['done']
|
|
120
|
+
* - No completions inside quoted strings
|
|
121
|
+
*/
|
|
122
|
+
function getCompletions(input, commands) {
|
|
123
|
+
const trimmed = input.trimStart();
|
|
124
|
+
if (!trimmed.startsWith("/")) return [];
|
|
125
|
+
const { tokens, inQuote, trailingSpace } = tokenizeInput(trimmed);
|
|
126
|
+
if (tokens.length === 0) return [];
|
|
127
|
+
if (inQuote) return [];
|
|
128
|
+
if (tokens.length === 1 && !trailingSpace) {
|
|
129
|
+
const prefix = tokens[0].slice(1).toLowerCase();
|
|
130
|
+
const builtins = ["exit", "quit"];
|
|
131
|
+
return [...commands.map((c) => c.id), ...builtins].filter((name) => name.toLowerCase().startsWith(prefix)).map((name) => `/${name}`);
|
|
132
|
+
}
|
|
133
|
+
const cmdName = tokens[0].slice(1).toLowerCase();
|
|
134
|
+
const cmd = commands.find((c) => c.id === cmdName);
|
|
135
|
+
if (!cmd) return [];
|
|
136
|
+
const fields = getSchemaFields(cmd.inputSchema);
|
|
137
|
+
const used = usedFlags(tokens);
|
|
138
|
+
if (trailingSpace) {
|
|
139
|
+
const lastToken = tokens[tokens.length - 1];
|
|
140
|
+
if (lastToken.startsWith("--")) {
|
|
141
|
+
const fieldName = lastToken.slice(2);
|
|
142
|
+
const field = fields.find((f) => f.key === fieldName);
|
|
143
|
+
if (field && field.baseType !== "boolean") return getFieldValueCompletions(cmd, fieldName, "");
|
|
144
|
+
}
|
|
145
|
+
return fields.filter((f) => !used.has(`--${f.key}`)).map((f) => `--${f.key}`);
|
|
146
|
+
}
|
|
147
|
+
const lastToken = tokens[tokens.length - 1];
|
|
148
|
+
const prevToken = tokens.length >= 2 ? tokens[tokens.length - 2] : "";
|
|
149
|
+
if (prevToken.startsWith("--")) {
|
|
150
|
+
const fieldName = prevToken.slice(2);
|
|
151
|
+
const field = fields.find((f) => f.key === fieldName);
|
|
152
|
+
if (field && field.baseType !== "boolean") return getFieldValueCompletions(cmd, fieldName, lastToken);
|
|
153
|
+
}
|
|
154
|
+
if (lastToken.startsWith("-")) {
|
|
155
|
+
const prefix = lastToken.startsWith("--") ? lastToken.slice(2).toLowerCase() : "";
|
|
156
|
+
return fields.filter((f) => f.key.toLowerCase().startsWith(prefix) && !used.has(`--${f.key}`)).map((f) => `--${f.key}`);
|
|
157
|
+
}
|
|
158
|
+
return [];
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Get value completions for an enum field.
|
|
162
|
+
*/
|
|
163
|
+
function getFieldValueCompletions(cmd, fieldName, partial) {
|
|
164
|
+
const enumValues = getEnumValues(cmd.inputSchema, fieldName);
|
|
165
|
+
if (!enumValues) return [];
|
|
166
|
+
const prefix = partial.toLowerCase();
|
|
167
|
+
return enumValues.filter((v) => v.toLowerCase().startsWith(prefix));
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* Get the suffix to append after a flag completion.
|
|
171
|
+
* Returns ` "` for non-boolean, non-enum fields (opening a value quote),
|
|
172
|
+
* empty string otherwise.
|
|
173
|
+
*/
|
|
174
|
+
function getCompletionSuffix(completion, input, commands) {
|
|
175
|
+
if (!completion.startsWith("--")) return "";
|
|
176
|
+
const { tokens } = tokenizeInput(input.trimStart());
|
|
177
|
+
const cmdName = tokens[0]?.slice(1).toLowerCase();
|
|
178
|
+
const cmd = commands.find((c) => c.id === cmdName);
|
|
179
|
+
if (!cmd) return "";
|
|
180
|
+
const fieldName = completion.slice(2);
|
|
181
|
+
const field = getSchemaFields(cmd.inputSchema).find((f) => f.key === fieldName);
|
|
182
|
+
if (!field || field.baseType === "boolean") return "";
|
|
183
|
+
if (getEnumValues(cmd.inputSchema, fieldName)) return " ";
|
|
184
|
+
return " \"";
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* Get the ghost suggestion for the current input — the full input string
|
|
188
|
+
* with the first completion applied, suitable for inline preview.
|
|
189
|
+
*
|
|
190
|
+
* Returns null if no suggestion is available.
|
|
191
|
+
*/
|
|
192
|
+
function getGhostSuggestion(input, commands) {
|
|
193
|
+
const { inQuote } = tokenizeInput(input.trimStart());
|
|
194
|
+
if (inQuote) return input + "\"";
|
|
195
|
+
const completions = getCompletions(input, commands);
|
|
196
|
+
if (completions.length === 0) return null;
|
|
197
|
+
return applyCompletion(input, completions[0]) + getCompletionSuffix(completions[0], input, commands);
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* Apply a completion candidate to the current input by replacing the last token.
|
|
201
|
+
* If the input ends with a trailing space, the completion is appended.
|
|
202
|
+
*
|
|
203
|
+
* For command completions (`/gr` + `/greet` → `/greet`), replaces the only token.
|
|
204
|
+
* For flag completions (`/greet --na` + `--name` → `/greet --name`), replaces the last token.
|
|
205
|
+
* For value completions (`/list --filter d` + `done` → `/list --filter done`), replaces the last token.
|
|
206
|
+
* For trailing space (`/add ` + `--title` → `/add --title`), appends.
|
|
207
|
+
*/
|
|
208
|
+
function applyCompletion(input, completion) {
|
|
209
|
+
if (input.length > 0 && (input[input.length - 1] === " " || input[input.length - 1] === " ")) return input + completion;
|
|
210
|
+
const lastSpaceIdx = input.lastIndexOf(" ");
|
|
211
|
+
if (lastSpaceIdx === -1) return completion;
|
|
212
|
+
return input.slice(0, lastSpaceIdx + 1) + completion;
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
* Extract enum values from a Zod schema field, if it's an enum type.
|
|
216
|
+
* Unwraps Default/Optional/Nullable wrappers to find the underlying ZodEnum.
|
|
217
|
+
*/
|
|
218
|
+
function getEnumValues(schema, fieldName) {
|
|
219
|
+
if (!(schema instanceof z.ZodObject)) return null;
|
|
220
|
+
let field = schema.shape[fieldName];
|
|
221
|
+
if (!field) return null;
|
|
222
|
+
const wrapperTypes = /* @__PURE__ */ new Set([
|
|
223
|
+
"default",
|
|
224
|
+
"optional",
|
|
225
|
+
"nullable"
|
|
226
|
+
]);
|
|
227
|
+
let current = field;
|
|
228
|
+
while (wrapperTypes.has(current.type) && current.def.innerType) {
|
|
229
|
+
current = current.def.innerType;
|
|
230
|
+
field = current;
|
|
231
|
+
}
|
|
232
|
+
if (field instanceof z.ZodEnum) return field.options;
|
|
233
|
+
return null;
|
|
234
|
+
}
|
|
235
|
+
//#endregion
|
|
236
|
+
//#region src/interactive/markdown.ts
|
|
237
|
+
const marked = new Marked();
|
|
238
|
+
const terminalExt = markedTerminal();
|
|
239
|
+
const originalCode = terminalExt.renderer.code;
|
|
240
|
+
terminalExt.renderer.code = function(...args) {
|
|
241
|
+
const [first, second, third] = args;
|
|
242
|
+
if (first && typeof first === "object") {
|
|
243
|
+
const token = first;
|
|
244
|
+
if (token.lang && !supportsLanguage(token.lang)) return originalCode.call(this, {
|
|
245
|
+
...token,
|
|
246
|
+
lang: ""
|
|
247
|
+
});
|
|
248
|
+
return originalCode.call(this, first);
|
|
249
|
+
}
|
|
250
|
+
if (typeof second === "string" && !supportsLanguage(second)) return originalCode.call(this, first, "", third);
|
|
251
|
+
return originalCode.call(this, ...args);
|
|
252
|
+
};
|
|
253
|
+
marked.use(terminalExt);
|
|
254
|
+
marked.use({ walkTokens(token) {
|
|
255
|
+
if (token.type === "list" || token.type === "list_item") token.loose = false;
|
|
256
|
+
} });
|
|
257
|
+
/**
|
|
258
|
+
* Render a markdown string for terminal display.
|
|
259
|
+
* Returns ANSI-formatted text suitable for terminal output.
|
|
260
|
+
*
|
|
261
|
+
* For plain text (no markdown), the output is the same as the input
|
|
262
|
+
* (with a trailing newline trimmed).
|
|
263
|
+
*/
|
|
264
|
+
function renderMarkdown(text) {
|
|
265
|
+
if (!text) return "";
|
|
266
|
+
const rendered = marked.parse(text);
|
|
267
|
+
/* istanbul ignore next -- marked.parse() always returns string with sync config */
|
|
268
|
+
if (typeof rendered !== "string") return text;
|
|
269
|
+
const stripAnsi = (s) => s.replace(/\x1b\[[0-9;]*m/g, "");
|
|
270
|
+
return rendered.split("\n").filter((line) => line.length === 0 || stripAnsi(line).trim().length > 0).join("\n").trimEnd();
|
|
271
|
+
}
|
|
272
|
+
//#endregion
|
|
273
|
+
export { getGhostSuggestion as a, getCompletions as i, applyCompletion as n, formatStreamChunk as o, getCompletionSuffix as r, renderStream as s, renderMarkdown as t };
|
|
274
|
+
|
|
275
|
+
//# sourceMappingURL=markdown-D-sP2zw_.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"markdown-D-sP2zw_.mjs","names":[],"sources":["../src/core/stream.ts","../src/interactive/completions.ts","../src/interactive/markdown.ts"],"sourcesContent":["import type { StreamChunk } from \"./types.js\";\n\n// ANSI escape codes for semantic coloring of tool activity\nconst DIM = \"\\x1b[2m\";\nconst RESET = \"\\x1b[0m\";\nconst RED = \"\\x1b[31m\";\nconst GREEN_DIM = \"\\x1b[32;2m\";\n\n/**\n * Format a single StreamChunk into a display string.\n *\n * This is the framework-level formatter. The Mastra integration maps\n * Mastra's fullStream chunks to StreamChunk first, then this renders them.\n *\n * Tool activity is styled with dim green (calls/results) and red (errors)\n * so it's visually distinct from the agent's text output.\n */\nexport function formatStreamChunk(chunk: StreamChunk): string {\n switch (chunk.type) {\n case \"text-delta\":\n return chunk.text;\n\n case \"tool-call\":\n return `\\n${DIM}${GREEN_DIM}▶ ${chunk.toolName}${RESET}${DIM}(${truncateArgs(chunk.args)})${RESET}\\n`;\n\n case \"tool-result\":\n if (chunk.isError) {\n return `${RED}✗ ${chunk.toolName} error: ${formatResult(chunk.result)}${RESET}\\n`;\n }\n // Extract text body: from { text: string } field or raw string result\n // eslint-disable-next-line no-case-declarations\n const body = hasTextField(chunk.result)\n ? (chunk.result as { text: string }).text\n : typeof chunk.result === \"string\"\n ? chunk.result\n : null;\n if (body && body.length > 0) {\n return `${DIM}${GREEN_DIM}✓ ${chunk.toolName}${RESET}\\n${body}\\n`;\n }\n // Short/null/object results: inline summary\n return `${DIM}${GREEN_DIM}✓ ${chunk.toolName}${RESET}${DIM} → ${truncateResult(chunk.result)}${RESET}\\n`;\n\n case \"tool-output\":\n return chunk.text;\n\n case \"error\":\n return `${RED}Error: ${chunk.error}${RESET}\\n`;\n\n case \"step-finish\":\n case \"finish\":\n // Lifecycle chunks carry token usage for cost accounting; no display\n // text by default. Renderers that care (eg. observability/eval) read\n // the chunk directly instead of relying on `formatted`.\n return \"\";\n }\n}\n\n/** A rendered stream element: the raw chunk paired with its formatted text. */\nexport interface RenderedChunk {\n chunk: StreamChunk;\n formatted: string;\n}\n\n/**\n * Consume a stream of StreamChunks and yield { chunk, formatted } pairs.\n *\n * Inserts an extra newline before the first text-delta after tool activity,\n * so the agent's prose is visually separated from tool call/result lines.\n */\nexport async function* renderStream(\n stream: AsyncGenerator<StreamChunk>,\n): AsyncGenerator<RenderedChunk, void, unknown> {\n let lastChunkWasText = false;\n\n for await (const chunk of stream) {\n let prefix = \"\";\n if (chunk.type === \"text-delta\") {\n if (!lastChunkWasText) {\n prefix = \"\\n\";\n lastChunkWasText = true;\n }\n } else {\n lastChunkWasText = false;\n }\n yield { chunk, formatted: prefix + formatStreamChunk(chunk) };\n }\n}\n\nfunction truncateArgs(args: unknown): string {\n const json = JSON.stringify(args);\n return json.length > 120 ? json.slice(0, 120) + \"…\" : json;\n}\n\nfunction truncateResult(result: unknown): string {\n const str = formatResult(result);\n return str.length > 200 ? str.slice(0, 200) + \"…\" : str;\n}\n\nfunction formatResult(result: unknown): string {\n if (result === undefined || result === null) return \"ok\";\n if (typeof result === \"string\") return result;\n return JSON.stringify(result);\n}\n\nfunction hasTextField(result: unknown): boolean {\n return (\n typeof result === \"object\" &&\n result !== null &&\n \"text\" in result &&\n typeof (result as Record<string, unknown>).text === \"string\"\n );\n}\n","import { z } from \"zod\";\nimport type { Command } from \"../core/types.js\";\nimport { getSchemaFields } from \"../core/schema.js\";\nimport type { FieldInfo } from \"../core/schema.js\";\n\n/**\n * Tokenize input respecting quotes, and report whether the cursor is inside\n * an open quote (meaning we should not offer completions).\n */\nfunction tokenizeInput(input: string): {\n tokens: string[];\n inQuote: boolean;\n trailingSpace: boolean;\n} {\n const tokens: string[] = [];\n let current = \"\";\n let inQuote = false;\n let quoteChar = \"\";\n\n for (const ch of input) {\n if (inQuote) {\n if (ch === quoteChar) {\n inQuote = false;\n } else {\n current += ch;\n }\n } else if (ch === '\"' || ch === \"'\") {\n inQuote = true;\n quoteChar = ch;\n } else if (ch === \" \" || ch === \"\\t\") {\n if (current) {\n tokens.push(current);\n current = \"\";\n }\n } else {\n current += ch;\n }\n }\n if (current) tokens.push(current);\n\n const trailingSpace =\n !inQuote &&\n input.length > 0 &&\n (input[input.length - 1] === \" \" || input[input.length - 1] === \"\\t\");\n return { tokens, inQuote, trailingSpace };\n}\n\n/**\n * Collect flag names already present in the tokens.\n */\nfunction usedFlags(tokens: string[]): Set<string> {\n const used = new Set<string>();\n for (const t of tokens) {\n if (t.startsWith(\"--\")) used.add(t);\n }\n return used;\n}\n\n/**\n * Get auto-completion suggestions for partial REPL input.\n *\n * Supports:\n * - Command name completion: `/gr` → ['/greet']\n * - Flag name completion: `/add --` → ['--title', '--priority', '--due']\n * - Flag name after trailing space: `/add ` → ['--title', '--priority', '--due']\n * - Enum value completion: `/list --filter d` → ['done']\n * - No completions inside quoted strings\n */\nexport function getCompletions(input: string, commands: Command[]): string[] {\n const trimmed = input.trimStart();\n if (!trimmed.startsWith(\"/\")) return [];\n\n const { tokens, inQuote, trailingSpace } = tokenizeInput(trimmed);\n if (tokens.length === 0) return [];\n\n // Don't complete inside quoted strings\n if (inQuote) return [];\n\n // Completing the command name: `/gr` → ['/greet']\n if (tokens.length === 1 && !trailingSpace) {\n const prefix = tokens[0]!.slice(1).toLowerCase();\n const builtins = [\"exit\", \"quit\"];\n const allNames = [...commands.map((c) => c.id), ...builtins];\n return allNames\n .filter((name) => name.toLowerCase().startsWith(prefix))\n .map((name) => `/${name}`);\n }\n\n // Find the command\n const cmdName = tokens[0]!.slice(1).toLowerCase();\n const cmd = commands.find((c) => c.id === cmdName);\n if (!cmd) return [];\n\n const fields = getSchemaFields(cmd.inputSchema);\n const used = usedFlags(tokens);\n\n // Trailing space after input — suggest next possible flags or values\n if (trailingSpace) {\n const lastToken = tokens[tokens.length - 1]!;\n // If the last token is a non-boolean flag, suggest its values\n if (lastToken.startsWith(\"--\")) {\n const fieldName = lastToken.slice(2);\n const field = fields.find((f) => f.key === fieldName);\n if (field && field.baseType !== \"boolean\") {\n return getFieldValueCompletions(cmd, fieldName, \"\");\n }\n }\n // Suggest unused flags\n return fields\n .filter((f) => !used.has(`--${f.key}`))\n .map((f) => `--${f.key}`);\n }\n\n const lastToken = tokens[tokens.length - 1]!;\n const prevToken = tokens.length >= 2 ? tokens[tokens.length - 2]! : \"\";\n\n // If previous token is a non-boolean flag, complete the value\n if (prevToken.startsWith(\"--\")) {\n const fieldName = prevToken.slice(2);\n const field = fields.find((f) => f.key === fieldName);\n if (field && field.baseType !== \"boolean\") {\n return getFieldValueCompletions(cmd, fieldName, lastToken);\n }\n }\n\n // If the current token starts with - or --, complete the flag name\n if (lastToken.startsWith(\"-\")) {\n const prefix = lastToken.startsWith(\"--\")\n ? lastToken.slice(2).toLowerCase()\n : \"\";\n return fields\n .filter(\n (f) =>\n f.key.toLowerCase().startsWith(prefix) && !used.has(`--${f.key}`),\n )\n .map((f) => `--${f.key}`);\n }\n\n return [];\n}\n\n/**\n * Get value completions for an enum field.\n */\nfunction getFieldValueCompletions(\n cmd: Command,\n fieldName: string,\n partial: string,\n): string[] {\n const enumValues = getEnumValues(cmd.inputSchema, fieldName);\n if (!enumValues) return [];\n\n const prefix = partial.toLowerCase();\n return enumValues.filter((v) => v.toLowerCase().startsWith(prefix));\n}\n\n/**\n * Get the suffix to append after a flag completion.\n * Returns ` \"` for non-boolean, non-enum fields (opening a value quote),\n * empty string otherwise.\n */\nexport function getCompletionSuffix(\n completion: string,\n input: string,\n commands: Command[],\n): string {\n if (!completion.startsWith(\"--\")) return \"\";\n\n const trimmed = input.trimStart();\n const { tokens } = tokenizeInput(trimmed);\n const cmdName = tokens[0]?.slice(1).toLowerCase();\n const cmd = commands.find((c) => c.id === cmdName);\n if (!cmd) return \"\";\n\n const fieldName = completion.slice(2);\n const fields = getSchemaFields(cmd.inputSchema);\n const field = fields.find((f) => f.key === fieldName);\n if (!field || field.baseType === \"boolean\") return \"\";\n\n // Enum fields don't need quotes\n const enumValues = getEnumValues(cmd.inputSchema, fieldName);\n if (enumValues) return \" \";\n\n return ' \"';\n}\n\n/**\n * Get the ghost suggestion for the current input — the full input string\n * with the first completion applied, suitable for inline preview.\n *\n * Returns null if no suggestion is available.\n */\nexport function getGhostSuggestion(\n input: string,\n commands: Command[],\n): string | null {\n // Inside an open quote — suggest closing it\n const trimmed = input.trimStart();\n const { inQuote } = tokenizeInput(trimmed);\n if (inQuote) return input + '\"';\n\n const completions = getCompletions(input, commands);\n if (completions.length === 0) return null;\n\n const applied = applyCompletion(input, completions[0]!);\n const suffix = getCompletionSuffix(completions[0]!, input, commands);\n\n return applied + suffix;\n}\n\n/**\n * Apply a completion candidate to the current input by replacing the last token.\n * If the input ends with a trailing space, the completion is appended.\n *\n * For command completions (`/gr` + `/greet` → `/greet`), replaces the only token.\n * For flag completions (`/greet --na` + `--name` → `/greet --name`), replaces the last token.\n * For value completions (`/list --filter d` + `done` → `/list --filter done`), replaces the last token.\n * For trailing space (`/add ` + `--title` → `/add --title`), appends.\n */\nexport function applyCompletion(input: string, completion: string): string {\n const trailingSpace =\n input.length > 0 &&\n (input[input.length - 1] === \" \" || input[input.length - 1] === \"\\t\");\n if (trailingSpace) return input + completion;\n const lastSpaceIdx = input.lastIndexOf(\" \");\n if (lastSpaceIdx === -1) return completion;\n return input.slice(0, lastSpaceIdx + 1) + completion;\n}\n\n/**\n * Extract enum values from a Zod schema field, if it's an enum type.\n * Unwraps Default/Optional/Nullable wrappers to find the underlying ZodEnum.\n */\nfunction getEnumValues(schema: z.ZodType, fieldName: string): string[] | null {\n if (!(schema instanceof z.ZodObject)) return null;\n\n let field = (schema.shape as Record<string, z.ZodType>)[fieldName];\n if (!field) return null;\n\n // Unwrap Default/Optional/Nullable wrappers using public Zod v4 API\n const wrapperTypes = new Set([\"default\", \"optional\", \"nullable\"]);\n let current = field as { type: string; def: { innerType?: unknown } };\n while (wrapperTypes.has(current.type) && current.def.innerType) {\n current = current.def.innerType as typeof current;\n field = current as unknown as z.ZodType;\n }\n\n // Check if it's a ZodEnum\n if (field instanceof z.ZodEnum) {\n return field.options as string[];\n }\n\n return null;\n}\n","import { Marked } from \"marked\";\nimport { markedTerminal } from \"marked-terminal\";\nimport { supportsLanguage } from \"cli-highlight\";\n\n// Create a dedicated Marked instance with terminal rendering.\n// This avoids mutating the global marked instance.\nconst marked = new Marked();\nconst terminalExt = markedTerminal() as {\n renderer: Record<string, (...args: unknown[]) => string>;\n useNewRenderer: boolean;\n};\n// marked-terminal bundles highlight.js v10 (via cli-highlight), which does not\n// register `graphql` (and a handful of other langs). When the agent emits a\n// ```graphql fence, the bundled hljs logs \"Could not find the language ...\" to\n// stderr before falling back to plain styling. Strip the lang for any\n// unsupported language so we hit the auto-detect path instead of the noisy\n// explicit-language path.\nconst originalCode = terminalExt.renderer.code;\nterminalExt.renderer.code = function (\n this: unknown,\n ...args: unknown[]\n): string {\n const [first, second, third] = args;\n if (first && typeof first === \"object\") {\n const token = first as { lang?: string };\n if (token.lang && !supportsLanguage(token.lang)) {\n return originalCode.call(this, { ...token, lang: \"\" });\n }\n return originalCode.call(this, first);\n }\n if (typeof second === \"string\" && !supportsLanguage(second)) {\n return originalCode.call(this, first, \"\", third);\n }\n return originalCode.call(this, ...args);\n};\nmarked.use(terminalExt as any);\n// Force all lists to render as \"tight\" (no extra newlines between items).\n// Without this, a single blank line between top-level items makes marked\n// set loose:true on the entire list, causing marked-terminal to add\n// double newlines between ALL items including tight nested ones.\nmarked.use({\n walkTokens(token: { type: string; loose?: boolean }) {\n if (token.type === \"list\" || token.type === \"list_item\") {\n token.loose = false;\n }\n },\n});\n\n/**\n * Render a markdown string for terminal display.\n * Returns ANSI-formatted text suitable for terminal output.\n *\n * For plain text (no markdown), the output is the same as the input\n * (with a trailing newline trimmed).\n */\nexport function renderMarkdown(text: string): string {\n if (!text) return \"\";\n const rendered = marked.parse(text);\n /* istanbul ignore next -- marked.parse() always returns string with sync config */\n if (typeof rendered !== \"string\") {\n return text;\n }\n // marked-terminal inserts whitespace-only lines (with ANSI resets)\n // between list items as separators. Remove these but keep truly empty\n // lines which serve as paragraph breaks.\n const stripAnsi = (s: string) => s.replace(/\\x1b\\[[0-9;]*m/g, \"\");\n return rendered\n .split(\"\\n\")\n .filter((line) => line.length === 0 || stripAnsi(line).trim().length > 0)\n .join(\"\\n\")\n .trimEnd();\n}\n"],"mappings":";;;;;;AAGA,MAAM,MAAM;AACZ,MAAM,QAAQ;AACd,MAAM,MAAM;AACZ,MAAM,YAAY;;;;;;;;;;AAWlB,SAAgB,kBAAkB,OAA4B;CAC5D,QAAQ,MAAM,MAAd;EACE,KAAK,cACH,OAAO,MAAM;EAEf,KAAK,aACH,OAAO,KAAK,MAAM,UAAU,IAAI,MAAM,WAAW,QAAQ,IAAI,GAAG,aAAa,MAAM,IAAI,EAAE,GAAG,MAAM;EAEpG,KAAK;GACH,IAAI,MAAM,SACR,OAAO,GAAG,IAAI,IAAI,MAAM,SAAS,UAAU,aAAa,MAAM,MAAM,IAAI,MAAM;GAIhF,M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