@robota-sdk/agent-sdk 3.0.0-beta.43 → 3.0.0-beta.44

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.
@@ -36,55 +36,40 @@ __export(index_exports, {
36
36
  BundlePluginInstaller: () => BundlePluginInstaller,
37
37
  BundlePluginLoader: () => BundlePluginLoader,
38
38
  CommandRegistry: () => CommandRegistry,
39
- DEFAULT_TOOL_DESCRIPTIONS: () => DEFAULT_TOOL_DESCRIPTIONS,
40
- FileSessionLogger: () => import_agent_sessions6.FileSessionLogger,
41
39
  InteractiveSession: () => InteractiveSession,
42
40
  MarketplaceClient: () => MarketplaceClient,
41
+ PluginCommandSource: () => PluginCommandSource,
43
42
  PluginSettingsStore: () => PluginSettingsStore,
44
43
  PromptExecutor: () => PromptExecutor,
45
- Session: () => import_agent_sessions5.Session,
46
- SessionStore: () => import_agent_sessions7.SessionStore,
47
- SilentSessionLogger: () => import_agent_sessions6.SilentSessionLogger,
48
44
  SkillCommandSource: () => SkillCommandSource,
49
- SystemCommandExecutor: () => SystemCommandExecutor,
50
- TRUST_TO_MODE: () => import_agent_core.TRUST_TO_MODE,
45
+ TRUST_TO_MODE: () => import_agent_core3.TRUST_TO_MODE,
51
46
  assembleSubagentPrompt: () => assembleSubagentPrompt,
52
- bashTool: () => import_agent_tools3.bashTool,
53
- buildSystemPrompt: () => buildSystemPrompt,
47
+ buildSkillPrompt: () => buildSkillPrompt,
48
+ chatEntryToMessage: () => import_agent_core4.chatEntryToMessage,
54
49
  createAgentTool: () => createAgentTool,
55
- createDefaultTools: () => createDefaultTools,
56
- createProvider: () => createProvider,
57
- createSession: () => createSession,
50
+ createQuery: () => createQuery,
58
51
  createSubagentLogger: () => createSubagentLogger,
59
52
  createSubagentSession: () => createSubagentSession,
60
- createSystemCommands: () => createSystemCommands,
61
- detectProject: () => detectProject,
62
- editTool: () => import_agent_tools6.editTool,
63
- evaluatePermission: () => import_agent_core4.evaluatePermission,
53
+ evaluatePermission: () => import_agent_core5.evaluatePermission,
64
54
  getBuiltInAgent: () => getBuiltInAgent,
65
55
  getForkWorkerSuffix: () => getForkWorkerSuffix,
56
+ getMessagesForAPI: () => import_agent_core4.getMessagesForAPI,
66
57
  getSubagentSuffix: () => getSubagentSuffix,
67
- globTool: () => import_agent_tools7.globTool,
68
- grepTool: () => import_agent_tools8.grepTool,
69
- loadConfig: () => loadConfig,
70
- loadContext: () => loadContext,
58
+ isChatEntry: () => import_agent_core4.isChatEntry,
59
+ messageToHistoryEntry: () => import_agent_core4.messageToHistoryEntry,
71
60
  parseFrontmatter: () => parseFrontmatter2,
61
+ preprocessShellCommands: () => preprocessShellCommands,
72
62
  projectPaths: () => projectPaths,
73
63
  promptForApproval: () => promptForApproval,
74
- query: () => query,
75
- readTool: () => import_agent_tools4.readTool,
76
64
  resolveSubagentLogDir: () => resolveSubagentLogDir,
77
65
  retrieveAgentToolDeps: () => retrieveAgentToolDeps,
78
- runHooks: () => import_agent_core5.runHooks,
66
+ runHooks: () => import_agent_core6.runHooks,
79
67
  storeAgentToolDeps: () => storeAgentToolDeps,
80
- userPaths: () => userPaths,
81
- writeTool: () => import_agent_tools5.writeTool
68
+ substituteVariables: () => substituteVariables,
69
+ userPaths: () => userPaths
82
70
  });
83
71
  module.exports = __toCommonJS(index_exports);
84
72
 
85
- // src/types.ts
86
- var import_agent_core = require("@robota-sdk/agent-core");
87
-
88
73
  // src/hooks/prompt-executor.ts
89
74
  function extractJson(raw) {
90
75
  const codeBlockMatch = /```(?:json)?\s*\n?([\s\S]*?)\n?\s*```/.exec(raw);
@@ -314,18 +299,6 @@ function createDefaultTools() {
314
299
  ];
315
300
  }
316
301
 
317
- // src/assembly/create-provider.ts
318
- var import_agent_provider_anthropic = require("@robota-sdk/agent-provider-anthropic");
319
- function createProvider(config) {
320
- const apiKey = config.provider.apiKey ?? process.env["ANTHROPIC_API_KEY"];
321
- if (!apiKey) {
322
- throw new Error(
323
- "ANTHROPIC_API_KEY is not set. Set the environment variable or configure provider.apiKey in ~/.robota/settings.json"
324
- );
325
- }
326
- return new import_agent_provider_anthropic.AnthropicProvider({ apiKey });
327
- }
328
-
329
302
  // src/tools/agent-tool.ts
330
303
  var import_zod = require("zod");
331
304
  var import_agent_tools2 = require("@robota-sdk/agent-tools");
@@ -455,7 +428,7 @@ function createSubagentSession(options) {
455
428
  agentsMd: parentContext.agentsMd,
456
429
  isForkWorker: options.isForkWorker ?? false
457
430
  });
458
- const provider = createProvider(parentConfig);
431
+ const provider = options.provider;
459
432
  return new import_agent_sessions.Session({
460
433
  tools,
461
434
  provider,
@@ -516,6 +489,7 @@ function createAgentTool(deps) {
516
489
  parentConfig: deps.config,
517
490
  parentContext: deps.context,
518
491
  parentTools: deps.tools,
492
+ provider: deps.provider,
519
493
  terminal: deps.terminal,
520
494
  permissionMode: deps.permissionMode,
521
495
  permissionHandler: deps.permissionHandler,
@@ -662,7 +636,12 @@ var AgentDefinitionLoader = class {
662
636
 
663
637
  // src/assembly/create-session.ts
664
638
  function createSession(options) {
665
- const provider = options.provider ?? createProvider(options.config);
639
+ if (!options.provider) {
640
+ throw new Error(
641
+ "provider is required. SDK is provider-neutral \u2014 consumer must create and pass a provider instance."
642
+ );
643
+ }
644
+ const provider = options.provider;
666
645
  const defaultTools = createDefaultTools();
667
646
  const tools = [...defaultTools, ...options.additionalTools ?? []];
668
647
  const agentLoader = new AgentDefinitionLoader(process.cwd());
@@ -690,6 +669,7 @@ function createSession(options) {
690
669
  context: options.context,
691
670
  tools,
692
671
  terminal: options.terminal,
672
+ provider,
693
673
  permissionMode: options.permissionMode,
694
674
  permissionHandler: options.permissionHandler,
695
675
  hooks: options.config.hooks,
@@ -759,10 +739,28 @@ function resolveSubagentLogDir(parentSessionId, baseLogsDir) {
759
739
  return (0, import_node_path2.join)(baseLogsDir, parentSessionId, "subagents");
760
740
  }
761
741
 
762
- // src/index.ts
763
- var import_agent_sessions5 = require("@robota-sdk/agent-sessions");
764
- var import_agent_sessions6 = require("@robota-sdk/agent-sessions");
765
- var import_agent_sessions7 = require("@robota-sdk/agent-sessions");
742
+ // src/interactive/interactive-session.ts
743
+ var import_agent_sessions4 = require("@robota-sdk/agent-sessions");
744
+
745
+ // src/paths.ts
746
+ var import_node_path3 = require("path");
747
+ var import_node_os2 = require("os");
748
+ function projectPaths(cwd) {
749
+ const base = (0, import_node_path3.join)(cwd, ".robota");
750
+ return {
751
+ settings: (0, import_node_path3.join)(base, "settings.json"),
752
+ settingsLocal: (0, import_node_path3.join)(base, "settings.local.json"),
753
+ logs: (0, import_node_path3.join)(base, "logs"),
754
+ sessions: (0, import_node_path3.join)(base, "sessions")
755
+ };
756
+ }
757
+ function userPaths() {
758
+ const base = (0, import_node_path3.join)((0, import_node_os2.homedir)(), ".robota");
759
+ return {
760
+ settings: (0, import_node_path3.join)(base, "settings.json"),
761
+ sessions: (0, import_node_path3.join)(base, "sessions")
762
+ };
763
+ }
766
764
 
767
765
  // src/config/config-loader.ts
768
766
  var import_fs = require("fs");
@@ -1096,89 +1094,207 @@ async function detectProject(cwd) {
1096
1094
  };
1097
1095
  }
1098
1096
 
1099
- // src/permissions/permission-prompt.ts
1100
- var import_chalk = __toESM(require("chalk"), 1);
1101
- var PERMISSION_OPTIONS = ["Allow", "Deny"];
1102
- var ALLOW_INDEX = 0;
1103
- function formatArgs(toolArgs) {
1104
- const entries = Object.entries(toolArgs);
1105
- if (entries.length === 0) {
1106
- return "(no arguments)";
1107
- }
1108
- return entries.map(([k, v]) => `${k}: ${typeof v === "string" ? v : JSON.stringify(v)}`).join(", ");
1109
- }
1110
- async function promptForApproval(terminal, toolName, toolArgs) {
1111
- terminal.writeLine("");
1112
- terminal.writeLine(import_chalk.default.yellow(`[Permission Required] Tool: ${toolName}`));
1113
- terminal.writeLine(import_chalk.default.dim(` ${formatArgs(toolArgs)}`));
1114
- terminal.writeLine("");
1115
- const selected = await terminal.select(PERMISSION_OPTIONS, ALLOW_INDEX);
1116
- return selected === ALLOW_INDEX;
1117
- }
1097
+ // src/interactive/interactive-session.ts
1098
+ var import_agent_core = require("@robota-sdk/agent-core");
1099
+ var import_node_crypto = require("crypto");
1118
1100
 
1119
- // src/query.ts
1120
- async function query(prompt, options) {
1121
- const cwd = options?.cwd ?? process.cwd();
1122
- const [config, context, projectInfo] = await Promise.all([
1123
- loadConfig(cwd),
1124
- loadContext(cwd),
1125
- detectProject(cwd)
1126
- ]);
1127
- const noopTerminal = {
1128
- write: () => {
1101
+ // src/commands/system-command.ts
1102
+ var VALID_MODES = ["plan", "default", "acceptEdits", "bypassPermissions"];
1103
+ function createSystemCommands() {
1104
+ return [
1105
+ {
1106
+ name: "help",
1107
+ description: "Show available commands",
1108
+ execute: (_session, _args) => ({
1109
+ message: [
1110
+ "Available commands:",
1111
+ " help \u2014 Show this help",
1112
+ " clear \u2014 Clear conversation",
1113
+ " compact [instr] \u2014 Compact context (optional focus instructions)",
1114
+ " mode [m] \u2014 Show/change permission mode",
1115
+ " model <id> \u2014 Change AI model",
1116
+ " language <code> \u2014 Set response language (ko, en, ja, zh)",
1117
+ " cost \u2014 Show session info",
1118
+ " context \u2014 Context window info",
1119
+ " permissions \u2014 Permission rules",
1120
+ " reset \u2014 Delete settings and exit"
1121
+ ].join("\n"),
1122
+ success: true
1123
+ })
1124
+ },
1125
+ {
1126
+ name: "clear",
1127
+ description: "Clear conversation history",
1128
+ execute: (session, _args) => {
1129
+ const underlying = session.getSession();
1130
+ underlying.clearHistory();
1131
+ return { message: "Conversation cleared.", success: true };
1132
+ }
1133
+ },
1134
+ {
1135
+ name: "compact",
1136
+ description: "Compress context window",
1137
+ execute: async (session, args) => {
1138
+ const underlying = session.getSession();
1139
+ const instructions = args.trim() || void 0;
1140
+ const before = underlying.getContextState().usedPercentage;
1141
+ await underlying.compact(instructions);
1142
+ const after = underlying.getContextState().usedPercentage;
1143
+ return {
1144
+ message: `Context compacted: ${Math.round(before)}% -> ${Math.round(after)}%`,
1145
+ success: true,
1146
+ data: { before, after }
1147
+ };
1148
+ }
1149
+ },
1150
+ {
1151
+ name: "mode",
1152
+ description: "Show/change permission mode",
1153
+ execute: (session, args) => {
1154
+ const underlying = session.getSession();
1155
+ const arg = args.trim().split(/\s+/)[0];
1156
+ if (!arg) {
1157
+ return {
1158
+ message: `Current mode: ${underlying.getPermissionMode()}`,
1159
+ success: true,
1160
+ data: { mode: underlying.getPermissionMode() }
1161
+ };
1162
+ }
1163
+ if (VALID_MODES.includes(arg)) {
1164
+ underlying.setPermissionMode(arg);
1165
+ return {
1166
+ message: `Permission mode set to: ${arg}`,
1167
+ success: true,
1168
+ data: { mode: arg }
1169
+ };
1170
+ }
1171
+ return {
1172
+ message: `Invalid mode. Valid: ${VALID_MODES.join(" | ")}`,
1173
+ success: false
1174
+ };
1175
+ }
1176
+ },
1177
+ {
1178
+ name: "model",
1179
+ description: "Change AI model",
1180
+ execute: (_session, args) => {
1181
+ const modelId = args.trim().split(/\s+/)[0];
1182
+ if (!modelId) {
1183
+ return { message: "Usage: model <model-id>", success: false };
1184
+ }
1185
+ return {
1186
+ message: `Model change requested: ${modelId}`,
1187
+ success: true,
1188
+ data: { modelId }
1189
+ };
1190
+ }
1129
1191
  },
1130
- writeLine: () => {
1192
+ {
1193
+ name: "language",
1194
+ description: "Set response language",
1195
+ execute: (_session, args) => {
1196
+ const lang = args.trim().split(/\s+/)[0];
1197
+ if (!lang) {
1198
+ return { message: "Usage: language <code> (e.g., ko, en, ja, zh)", success: false };
1199
+ }
1200
+ return {
1201
+ message: `Language set to "${lang}".`,
1202
+ success: true,
1203
+ data: { language: lang }
1204
+ };
1205
+ }
1131
1206
  },
1132
- writeMarkdown: () => {
1207
+ {
1208
+ name: "cost",
1209
+ description: "Show session info",
1210
+ execute: (session, _args) => {
1211
+ const underlying = session.getSession();
1212
+ const sessionId = underlying.getSessionId();
1213
+ const messageCount = underlying.getMessageCount();
1214
+ return {
1215
+ message: `Session: ${sessionId}
1216
+ Messages: ${messageCount}`,
1217
+ success: true,
1218
+ data: { sessionId, messageCount }
1219
+ };
1220
+ }
1133
1221
  },
1134
- writeError: () => {
1222
+ {
1223
+ name: "context",
1224
+ description: "Context window info",
1225
+ execute: (session, _args) => {
1226
+ const ctx = session.getContextState();
1227
+ return {
1228
+ message: `Context: ${ctx.usedTokens.toLocaleString()} / ${ctx.maxTokens.toLocaleString()} tokens (${Math.round(ctx.usedPercentage)}%)`,
1229
+ success: true,
1230
+ data: {
1231
+ usedTokens: ctx.usedTokens,
1232
+ maxTokens: ctx.maxTokens,
1233
+ percentage: ctx.usedPercentage
1234
+ }
1235
+ };
1236
+ }
1135
1237
  },
1136
- prompt: () => Promise.resolve(""),
1137
- select: () => Promise.resolve(0),
1138
- spinner: () => ({ stop: () => {
1139
- }, update: () => {
1140
- } })
1141
- };
1142
- const session = createSession({
1143
- config,
1144
- context,
1145
- terminal: noopTerminal,
1146
- projectInfo,
1147
- permissionMode: options?.permissionMode ?? "bypassPermissions",
1148
- maxTurns: options?.maxTurns,
1149
- provider: options?.provider,
1150
- permissionHandler: options?.permissionHandler,
1151
- onTextDelta: options?.onTextDelta,
1152
- onCompact: options?.onCompact,
1153
- compactInstructions: context.compactInstructions,
1154
- promptForApproval
1155
- });
1156
- return session.run(prompt);
1157
- }
1158
-
1159
- // src/index.ts
1160
- var import_agent_core4 = require("@robota-sdk/agent-core");
1161
- var import_agent_core5 = require("@robota-sdk/agent-core");
1162
-
1163
- // src/paths.ts
1164
- var import_node_path3 = require("path");
1165
- var import_node_os2 = require("os");
1166
- function projectPaths(cwd) {
1167
- const base = (0, import_node_path3.join)(cwd, ".robota");
1168
- return {
1169
- settings: (0, import_node_path3.join)(base, "settings.json"),
1170
- settingsLocal: (0, import_node_path3.join)(base, "settings.local.json"),
1171
- logs: (0, import_node_path3.join)(base, "logs"),
1172
- sessions: (0, import_node_path3.join)(base, "sessions")
1173
- };
1174
- }
1175
- function userPaths() {
1176
- const base = (0, import_node_path3.join)((0, import_node_os2.homedir)(), ".robota");
1177
- return {
1178
- settings: (0, import_node_path3.join)(base, "settings.json"),
1179
- sessions: (0, import_node_path3.join)(base, "sessions")
1180
- };
1238
+ {
1239
+ name: "permissions",
1240
+ description: "Show permission rules",
1241
+ execute: (session, _args) => {
1242
+ const underlying = session.getSession();
1243
+ const mode = underlying.getPermissionMode();
1244
+ const sessionAllowed = underlying.getSessionAllowedTools();
1245
+ const lines = [`Permission mode: ${mode}`];
1246
+ if (sessionAllowed.length > 0) {
1247
+ lines.push(`Session-approved tools: ${sessionAllowed.join(", ")}`);
1248
+ } else {
1249
+ lines.push("No session-approved tools.");
1250
+ }
1251
+ return {
1252
+ message: lines.join("\n"),
1253
+ success: true,
1254
+ data: { mode, sessionAllowed }
1255
+ };
1256
+ }
1257
+ },
1258
+ {
1259
+ name: "reset",
1260
+ description: "Delete settings",
1261
+ execute: (_session, _args) => {
1262
+ return {
1263
+ message: "Reset requested.",
1264
+ success: true,
1265
+ data: { resetRequested: true }
1266
+ };
1267
+ }
1268
+ }
1269
+ ];
1181
1270
  }
1271
+ var SystemCommandExecutor = class {
1272
+ commands;
1273
+ constructor(commands) {
1274
+ this.commands = /* @__PURE__ */ new Map();
1275
+ for (const cmd of commands ?? createSystemCommands()) {
1276
+ this.commands.set(cmd.name, cmd);
1277
+ }
1278
+ }
1279
+ /** Register an additional command. */
1280
+ register(command) {
1281
+ this.commands.set(command.name, command);
1282
+ }
1283
+ /** Execute a command by name. Returns null if command not found. */
1284
+ async execute(name, session, args) {
1285
+ const cmd = this.commands.get(name);
1286
+ if (!cmd) return null;
1287
+ return await cmd.execute(session, args);
1288
+ }
1289
+ /** List all registered commands. */
1290
+ listCommands() {
1291
+ return [...this.commands.values()];
1292
+ }
1293
+ /** Check if a command exists. */
1294
+ hasCommand(name) {
1295
+ return this.commands.has(name);
1296
+ }
1297
+ };
1182
1298
 
1183
1299
  // src/plugins/plugin-settings-store.ts
1184
1300
  var import_node_fs3 = require("fs");
@@ -1975,478 +2091,163 @@ var MarketplaceClient = class {
1975
2091
  }
1976
2092
  };
1977
2093
 
1978
- // src/commands/command-registry.ts
1979
- var CommandRegistry = class {
1980
- sources = [];
1981
- addSource(source) {
1982
- this.sources.push(source);
2094
+ // src/plugins/plugin-hooks-merger.ts
2095
+ var import_node_path8 = require("path");
2096
+ function buildPluginEnv(plugin) {
2097
+ const dataDir = (0, import_node_path8.join)((0, import_node_path8.dirname)((0, import_node_path8.dirname)(plugin.pluginDir)), "data", plugin.manifest.name);
2098
+ return {
2099
+ CLAUDE_PLUGIN_ROOT: plugin.pluginDir,
2100
+ CLAUDE_PLUGIN_PATH: plugin.pluginDir,
2101
+ CLAUDE_PLUGIN_DATA: dataDir
2102
+ };
2103
+ }
2104
+ function resolvePluginRoot(group, pluginDir) {
2105
+ if (Array.isArray(group.hooks)) {
2106
+ return {
2107
+ ...group,
2108
+ hooks: group.hooks.map((h) => {
2109
+ if (typeof h.command === "string") {
2110
+ return {
2111
+ ...h,
2112
+ command: h.command.replace(/\$\{CLAUDE_PLUGIN_ROOT\}/g, pluginDir)
2113
+ };
2114
+ }
2115
+ return h;
2116
+ })
2117
+ };
1983
2118
  }
1984
- /** Get all commands, optionally filtered by prefix */
1985
- getCommands(filter) {
1986
- const all = [];
1987
- for (const source of this.sources) {
1988
- all.push(...source.getCommands());
2119
+ return group;
2120
+ }
2121
+ function mergePluginHooks(plugins) {
2122
+ const merged = {};
2123
+ for (const plugin of plugins) {
2124
+ const hooksObj = plugin.hooks;
2125
+ if (!hooksObj) continue;
2126
+ const pluginEnv = buildPluginEnv(plugin);
2127
+ const innerHooks = hooksObj.hooks ?? hooksObj;
2128
+ for (const [event, groups] of Object.entries(innerHooks)) {
2129
+ if (!Array.isArray(groups)) continue;
2130
+ if (!merged[event]) merged[event] = [];
2131
+ const resolved = groups.map((group) => {
2132
+ const r = resolvePluginRoot(group, plugin.pluginDir);
2133
+ r.env = pluginEnv;
2134
+ return r;
2135
+ });
2136
+ merged[event].push(...resolved);
1989
2137
  }
1990
- if (!filter) return all;
1991
- const lower = filter.toLowerCase();
1992
- return all.filter((cmd) => cmd.name.toLowerCase().startsWith(lower));
1993
2138
  }
1994
- /** Resolve a short name to its fully qualified plugin:name form */
1995
- resolveQualifiedName(shortName) {
1996
- const matches = this.getCommands().filter(
1997
- (c) => c.source === "plugin" && c.name.includes(":") && c.name.endsWith(`:${shortName}`)
1998
- );
1999
- if (matches.length !== 1) return null;
2000
- return matches[0].name;
2139
+ return merged;
2140
+ }
2141
+ function mergeHooksIntoConfig(configHooks, pluginHooks) {
2142
+ const pluginKeys = Object.keys(pluginHooks);
2143
+ if (pluginKeys.length === 0) return configHooks;
2144
+ const merged = {};
2145
+ for (const [event, groups] of Object.entries(pluginHooks)) {
2146
+ merged[event] = [...groups];
2001
2147
  }
2002
- /** Get subcommands for a specific command */
2003
- getSubcommands(commandName) {
2004
- const lower = commandName.toLowerCase();
2005
- for (const source of this.sources) {
2006
- for (const cmd of source.getCommands()) {
2007
- if (cmd.name.toLowerCase() === lower && cmd.subcommands) {
2008
- return cmd.subcommands;
2009
- }
2010
- }
2148
+ if (configHooks) {
2149
+ for (const [event, groups] of Object.entries(configHooks)) {
2150
+ if (!Array.isArray(groups)) continue;
2151
+ if (!merged[event]) merged[event] = [];
2152
+ merged[event].push(...groups);
2011
2153
  }
2012
- return [];
2013
- }
2014
- };
2015
-
2016
- // src/commands/builtin-source.ts
2017
- var import_agent_core2 = require("@robota-sdk/agent-core");
2018
- function buildModelSubcommands() {
2019
- const seen = /* @__PURE__ */ new Set();
2020
- const commands = [];
2021
- for (const model of Object.values(import_agent_core2.CLAUDE_MODELS)) {
2022
- if (seen.has(model.name)) continue;
2023
- seen.add(model.name);
2024
- commands.push({
2025
- name: model.id,
2026
- description: `${model.name} (${(0, import_agent_core2.formatTokenCount)(model.contextWindow).toUpperCase()})`,
2027
- source: "builtin"
2028
- });
2029
2154
  }
2030
- return commands;
2031
- }
2032
- function createBuiltinCommands() {
2033
- return [
2034
- { name: "help", description: "Show available commands", source: "builtin" },
2035
- { name: "clear", description: "Clear conversation history", source: "builtin" },
2036
- {
2037
- name: "mode",
2038
- description: "Permission mode",
2039
- source: "builtin",
2040
- subcommands: [
2041
- { name: "plan", description: "Plan only, no execution", source: "builtin" },
2042
- { name: "default", description: "Ask before risky actions", source: "builtin" },
2043
- { name: "acceptEdits", description: "Auto-approve file edits", source: "builtin" },
2044
- { name: "bypassPermissions", description: "Skip all permission checks", source: "builtin" }
2045
- ]
2046
- },
2047
- {
2048
- name: "model",
2049
- description: "Select AI model",
2050
- source: "builtin",
2051
- subcommands: buildModelSubcommands()
2052
- },
2053
- {
2054
- name: "language",
2055
- description: "Set response language",
2056
- source: "builtin",
2057
- subcommands: [
2058
- { name: "ko", description: "Korean", source: "builtin" },
2059
- { name: "en", description: "English", source: "builtin" },
2060
- { name: "ja", description: "Japanese", source: "builtin" },
2061
- { name: "zh", description: "Chinese", source: "builtin" }
2062
- ]
2063
- },
2064
- { name: "compact", description: "Compress context window", source: "builtin" },
2065
- { name: "cost", description: "Show session info", source: "builtin" },
2066
- { name: "context", description: "Context window info", source: "builtin" },
2067
- { name: "permissions", description: "Permission rules", source: "builtin" },
2068
- { name: "plugin", description: "Manage plugins", source: "builtin" },
2069
- { name: "reload-plugins", description: "Reload all plugin resources", source: "builtin" },
2070
- { name: "reset", description: "Delete settings and exit", source: "builtin" },
2071
- { name: "exit", description: "Exit CLI", source: "builtin" }
2072
- ];
2155
+ return merged;
2073
2156
  }
2074
- var BuiltinCommandSource = class {
2075
- name = "builtin";
2076
- commands;
2077
- constructor() {
2078
- this.commands = createBuiltinCommands();
2079
- }
2080
- getCommands() {
2081
- return this.commands;
2082
- }
2083
- };
2084
2157
 
2085
- // src/commands/skill-source.ts
2086
- var import_node_fs7 = require("fs");
2087
- var import_node_path8 = require("path");
2158
+ // src/interactive/interactive-session.ts
2088
2159
  var import_node_os3 = require("os");
2089
- var BOOLEAN_KEYS = /* @__PURE__ */ new Set(["disable-model-invocation", "user-invocable"]);
2090
- var LIST_KEYS2 = /* @__PURE__ */ new Set(["allowed-tools"]);
2091
- function kebabToCamel(key) {
2092
- return key.replace(/-([a-z])/g, (_match, letter) => letter.toUpperCase());
2093
- }
2094
- function parseFrontmatter2(content) {
2095
- const lines = content.split("\n");
2096
- if (lines[0]?.trim() !== "---") return null;
2097
- const result = {};
2098
- for (let i = 1; i < lines.length; i++) {
2099
- const line = lines[i];
2100
- if (line.trim() === "---") break;
2101
- const match = line.match(/^([a-z][a-z0-9-]*):\s*(.+)/);
2102
- if (!match) continue;
2103
- const key = match[1];
2104
- const rawValue = match[2].trim();
2105
- const camelKey = kebabToCamel(key);
2106
- if (BOOLEAN_KEYS.has(key)) {
2107
- result[camelKey] = rawValue === "true";
2108
- } else if (LIST_KEYS2.has(key)) {
2109
- result[camelKey] = rawValue.split(",").map((s) => s.trim());
2160
+ var import_node_path9 = require("path");
2161
+ var TOOL_ARG_DISPLAY_MAX = 80;
2162
+ var TAIL_KEEP = 30;
2163
+ var MAX_COMPLETED_TOOLS = 50;
2164
+ var STREAMING_FLUSH_INTERVAL_MS = 16;
2165
+ var InteractiveSession = class {
2166
+ session = null;
2167
+ commandExecutor;
2168
+ listeners = /* @__PURE__ */ new Map();
2169
+ initialized = false;
2170
+ initPromise = null;
2171
+ // Streaming state
2172
+ streamingText = "";
2173
+ flushTimer = null;
2174
+ // Tool state
2175
+ activeTools = [];
2176
+ // Execution state
2177
+ executing = false;
2178
+ pendingPrompt = null;
2179
+ pendingDisplayInput;
2180
+ pendingRawInput;
2181
+ // Full history timeline (chat messages + events)
2182
+ history = [];
2183
+ constructor(options) {
2184
+ this.commandExecutor = new SystemCommandExecutor(createSystemCommands());
2185
+ if ("session" in options && options.session) {
2186
+ this.session = options.session;
2187
+ this.initialized = true;
2110
2188
  } else {
2111
- result[camelKey] = rawValue;
2189
+ const stdOpts = options;
2190
+ this.initPromise = this.initializeAsync(stdOpts);
2191
+ }
2192
+ }
2193
+ async initializeAsync(options) {
2194
+ const cwd = options.cwd;
2195
+ const [config, context, projectInfo] = await Promise.all([
2196
+ loadConfig(cwd),
2197
+ loadContext(cwd),
2198
+ detectProject(cwd)
2199
+ ]);
2200
+ const pluginsDir = (0, import_node_path9.join)((0, import_node_os3.homedir)(), ".robota", "plugins");
2201
+ const pluginLoader = new BundlePluginLoader(pluginsDir);
2202
+ let mergedConfig = config;
2203
+ try {
2204
+ const plugins = pluginLoader.loadPluginsSync();
2205
+ if (plugins.length > 0) {
2206
+ const pluginHooks = mergePluginHooks(plugins);
2207
+ mergedConfig = {
2208
+ ...config,
2209
+ hooks: mergeHooksIntoConfig(
2210
+ config.hooks,
2211
+ pluginHooks
2212
+ )
2213
+ };
2214
+ }
2215
+ } catch {
2112
2216
  }
2217
+ const paths = projectPaths(cwd);
2218
+ this.session = createSession({
2219
+ config: mergedConfig,
2220
+ context,
2221
+ projectInfo,
2222
+ permissionMode: options.permissionMode,
2223
+ maxTurns: options.maxTurns,
2224
+ terminal: NOOP_TERMINAL,
2225
+ sessionLogger: new import_agent_sessions4.FileSessionLogger(paths.logs),
2226
+ permissionHandler: options.permissionHandler,
2227
+ provider: options.provider,
2228
+ onTextDelta: (delta) => this.handleTextDelta(delta),
2229
+ onToolExecution: (event) => this.handleToolExecution(event)
2230
+ });
2231
+ this.initialized = true;
2113
2232
  }
2114
- return Object.keys(result).length > 0 ? result : null;
2115
- }
2116
- function buildCommand(frontmatter, content, fallbackName) {
2117
- const cmd = {
2118
- name: frontmatter?.name ?? fallbackName,
2119
- description: frontmatter?.description ?? `Skill: ${fallbackName}`,
2120
- source: "skill",
2121
- skillContent: content
2122
- };
2123
- if (frontmatter?.argumentHint !== void 0) cmd.argumentHint = frontmatter.argumentHint;
2124
- if (frontmatter?.disableModelInvocation !== void 0)
2125
- cmd.disableModelInvocation = frontmatter.disableModelInvocation;
2126
- if (frontmatter?.userInvocable !== void 0) cmd.userInvocable = frontmatter.userInvocable;
2127
- if (frontmatter?.allowedTools !== void 0) cmd.allowedTools = frontmatter.allowedTools;
2128
- if (frontmatter?.model !== void 0) cmd.model = frontmatter.model;
2129
- if (frontmatter?.effort !== void 0) cmd.effort = frontmatter.effort;
2130
- if (frontmatter?.context !== void 0) cmd.context = frontmatter.context;
2131
- if (frontmatter?.agent !== void 0) cmd.agent = frontmatter.agent;
2132
- return cmd;
2133
- }
2134
- function scanSkillsDir(skillsDir) {
2135
- if (!(0, import_node_fs7.existsSync)(skillsDir)) return [];
2136
- const commands = [];
2137
- const entries = (0, import_node_fs7.readdirSync)(skillsDir, { withFileTypes: true });
2138
- for (const entry of entries) {
2139
- if (!entry.isDirectory()) continue;
2140
- const skillFile = (0, import_node_path8.join)(skillsDir, entry.name, "SKILL.md");
2141
- if (!(0, import_node_fs7.existsSync)(skillFile)) continue;
2142
- const content = (0, import_node_fs7.readFileSync)(skillFile, "utf-8");
2143
- const frontmatter = parseFrontmatter2(content);
2144
- commands.push(buildCommand(frontmatter, content, entry.name));
2145
- }
2146
- return commands;
2147
- }
2148
- function scanCommandsDir(commandsDir) {
2149
- if (!(0, import_node_fs7.existsSync)(commandsDir)) return [];
2150
- const commands = [];
2151
- const entries = (0, import_node_fs7.readdirSync)(commandsDir, { withFileTypes: true });
2152
- for (const entry of entries) {
2153
- if (!entry.isFile() || !entry.name.endsWith(".md")) continue;
2154
- const filePath = (0, import_node_path8.join)(commandsDir, entry.name);
2155
- const content = (0, import_node_fs7.readFileSync)(filePath, "utf-8");
2156
- const frontmatter = parseFrontmatter2(content);
2157
- const fallbackName = (0, import_node_path8.basename)(entry.name, ".md");
2158
- commands.push(buildCommand(frontmatter, content, fallbackName));
2233
+ async ensureInitialized() {
2234
+ if (this.initialized) return;
2235
+ if (this.initPromise) await this.initPromise;
2159
2236
  }
2160
- return commands;
2161
- }
2162
- var SkillCommandSource = class {
2163
- name = "skill";
2164
- cwd;
2165
- home;
2166
- cachedCommands = null;
2167
- constructor(cwd, home) {
2168
- this.cwd = cwd;
2169
- this.home = home ?? (0, import_node_os3.homedir)();
2237
+ getSessionOrThrow() {
2238
+ if (!this.session)
2239
+ throw new Error("InteractiveSession not initialized. Call submit() or await initialization.");
2240
+ return this.session;
2170
2241
  }
2171
- getCommands() {
2172
- if (this.cachedCommands) return this.cachedCommands;
2173
- const sources = [
2174
- scanSkillsDir((0, import_node_path8.join)(this.cwd, ".claude", "skills")),
2175
- scanCommandsDir((0, import_node_path8.join)(this.cwd, ".claude", "commands")),
2176
- scanSkillsDir((0, import_node_path8.join)(this.home, ".robota", "skills")),
2177
- scanSkillsDir((0, import_node_path8.join)(this.cwd, ".agents", "skills"))
2178
- ];
2179
- const seen = /* @__PURE__ */ new Set();
2180
- const merged = [];
2181
- for (const commands of sources) {
2182
- for (const cmd of commands) {
2183
- if (!seen.has(cmd.name)) {
2184
- seen.add(cmd.name);
2185
- merged.push(cmd);
2186
- }
2187
- }
2242
+ // ── Event system ──────────────────────────────────────────────
2243
+ on(event, handler) {
2244
+ if (!this.listeners.has(event)) {
2245
+ this.listeners.set(event, /* @__PURE__ */ new Set());
2188
2246
  }
2189
- this.cachedCommands = merged;
2190
- return this.cachedCommands;
2247
+ this.listeners.get(event).add(handler);
2191
2248
  }
2192
- getModelInvocableSkills() {
2193
- return this.getCommands().filter((cmd) => cmd.disableModelInvocation !== true);
2194
- }
2195
- getUserInvocableSkills() {
2196
- return this.getCommands().filter((cmd) => cmd.userInvocable !== false);
2197
- }
2198
- };
2199
-
2200
- // src/commands/system-command.ts
2201
- var VALID_MODES = ["plan", "default", "acceptEdits", "bypassPermissions"];
2202
- function createSystemCommands() {
2203
- return [
2204
- {
2205
- name: "help",
2206
- description: "Show available commands",
2207
- execute: (_session, _args) => ({
2208
- message: [
2209
- "Available commands:",
2210
- " help \u2014 Show this help",
2211
- " clear \u2014 Clear conversation",
2212
- " compact [instr] \u2014 Compact context (optional focus instructions)",
2213
- " mode [m] \u2014 Show/change permission mode",
2214
- " model <id> \u2014 Change AI model",
2215
- " language <code> \u2014 Set response language (ko, en, ja, zh)",
2216
- " cost \u2014 Show session info",
2217
- " context \u2014 Context window info",
2218
- " permissions \u2014 Permission rules",
2219
- " reset \u2014 Delete settings and exit"
2220
- ].join("\n"),
2221
- success: true
2222
- })
2223
- },
2224
- {
2225
- name: "clear",
2226
- description: "Clear conversation history",
2227
- execute: (session, _args) => {
2228
- const underlying = session.getSession();
2229
- underlying.clearHistory();
2230
- return { message: "Conversation cleared.", success: true };
2231
- }
2232
- },
2233
- {
2234
- name: "compact",
2235
- description: "Compress context window",
2236
- execute: async (session, args) => {
2237
- const underlying = session.getSession();
2238
- const instructions = args.trim() || void 0;
2239
- const before = underlying.getContextState().usedPercentage;
2240
- await underlying.compact(instructions);
2241
- const after = underlying.getContextState().usedPercentage;
2242
- return {
2243
- message: `Context compacted: ${Math.round(before)}% -> ${Math.round(after)}%`,
2244
- success: true,
2245
- data: { before, after }
2246
- };
2247
- }
2248
- },
2249
- {
2250
- name: "mode",
2251
- description: "Show/change permission mode",
2252
- execute: (session, args) => {
2253
- const underlying = session.getSession();
2254
- const arg = args.trim().split(/\s+/)[0];
2255
- if (!arg) {
2256
- return {
2257
- message: `Current mode: ${underlying.getPermissionMode()}`,
2258
- success: true,
2259
- data: { mode: underlying.getPermissionMode() }
2260
- };
2261
- }
2262
- if (VALID_MODES.includes(arg)) {
2263
- underlying.setPermissionMode(arg);
2264
- return {
2265
- message: `Permission mode set to: ${arg}`,
2266
- success: true,
2267
- data: { mode: arg }
2268
- };
2269
- }
2270
- return {
2271
- message: `Invalid mode. Valid: ${VALID_MODES.join(" | ")}`,
2272
- success: false
2273
- };
2274
- }
2275
- },
2276
- {
2277
- name: "model",
2278
- description: "Change AI model",
2279
- execute: (_session, args) => {
2280
- const modelId = args.trim().split(/\s+/)[0];
2281
- if (!modelId) {
2282
- return { message: "Usage: model <model-id>", success: false };
2283
- }
2284
- return {
2285
- message: `Model change requested: ${modelId}`,
2286
- success: true,
2287
- data: { modelId }
2288
- };
2289
- }
2290
- },
2291
- {
2292
- name: "language",
2293
- description: "Set response language",
2294
- execute: (_session, args) => {
2295
- const lang = args.trim().split(/\s+/)[0];
2296
- if (!lang) {
2297
- return { message: "Usage: language <code> (e.g., ko, en, ja, zh)", success: false };
2298
- }
2299
- return {
2300
- message: `Language set to "${lang}".`,
2301
- success: true,
2302
- data: { language: lang }
2303
- };
2304
- }
2305
- },
2306
- {
2307
- name: "cost",
2308
- description: "Show session info",
2309
- execute: (session, _args) => {
2310
- const underlying = session.getSession();
2311
- const sessionId = underlying.getSessionId();
2312
- const messageCount = underlying.getMessageCount();
2313
- return {
2314
- message: `Session: ${sessionId}
2315
- Messages: ${messageCount}`,
2316
- success: true,
2317
- data: { sessionId, messageCount }
2318
- };
2319
- }
2320
- },
2321
- {
2322
- name: "context",
2323
- description: "Context window info",
2324
- execute: (session, _args) => {
2325
- const ctx = session.getContextState();
2326
- return {
2327
- message: `Context: ${ctx.usedTokens.toLocaleString()} / ${ctx.maxTokens.toLocaleString()} tokens (${Math.round(ctx.usedPercentage)}%)`,
2328
- success: true,
2329
- data: {
2330
- usedTokens: ctx.usedTokens,
2331
- maxTokens: ctx.maxTokens,
2332
- percentage: ctx.usedPercentage
2333
- }
2334
- };
2335
- }
2336
- },
2337
- {
2338
- name: "permissions",
2339
- description: "Show permission rules",
2340
- execute: (session, _args) => {
2341
- const underlying = session.getSession();
2342
- const mode = underlying.getPermissionMode();
2343
- const sessionAllowed = underlying.getSessionAllowedTools();
2344
- const lines = [`Permission mode: ${mode}`];
2345
- if (sessionAllowed.length > 0) {
2346
- lines.push(`Session-approved tools: ${sessionAllowed.join(", ")}`);
2347
- } else {
2348
- lines.push("No session-approved tools.");
2349
- }
2350
- return {
2351
- message: lines.join("\n"),
2352
- success: true,
2353
- data: { mode, sessionAllowed }
2354
- };
2355
- }
2356
- },
2357
- {
2358
- name: "reset",
2359
- description: "Delete settings",
2360
- execute: (_session, _args) => {
2361
- return {
2362
- message: "Reset requested.",
2363
- success: true,
2364
- data: { resetRequested: true }
2365
- };
2366
- }
2367
- }
2368
- ];
2369
- }
2370
- var SystemCommandExecutor = class {
2371
- commands;
2372
- constructor(commands) {
2373
- this.commands = /* @__PURE__ */ new Map();
2374
- for (const cmd of commands ?? createSystemCommands()) {
2375
- this.commands.set(cmd.name, cmd);
2376
- }
2377
- }
2378
- /** Register an additional command. */
2379
- register(command) {
2380
- this.commands.set(command.name, command);
2381
- }
2382
- /** Execute a command by name. Returns null if command not found. */
2383
- async execute(name, session, args) {
2384
- const cmd = this.commands.get(name);
2385
- if (!cmd) return null;
2386
- return await cmd.execute(session, args);
2387
- }
2388
- /** List all registered commands. */
2389
- listCommands() {
2390
- return [...this.commands.values()];
2391
- }
2392
- /** Check if a command exists. */
2393
- hasCommand(name) {
2394
- return this.commands.has(name);
2395
- }
2396
- };
2397
-
2398
- // src/interactive/interactive-session.ts
2399
- var import_agent_sessions4 = require("@robota-sdk/agent-sessions");
2400
- var import_agent_core3 = require("@robota-sdk/agent-core");
2401
- var TOOL_ARG_DISPLAY_MAX = 80;
2402
- var TAIL_KEEP = 30;
2403
- var MAX_COMPLETED_TOOLS = 50;
2404
- var STREAMING_FLUSH_INTERVAL_MS = 16;
2405
- var InteractiveSession = class {
2406
- session;
2407
- listeners = /* @__PURE__ */ new Map();
2408
- // Streaming state
2409
- streamingText = "";
2410
- flushTimer = null;
2411
- // Tool state
2412
- activeTools = [];
2413
- // Execution state
2414
- executing = false;
2415
- pendingPrompt = null;
2416
- pendingDisplayInput;
2417
- pendingRawInput;
2418
- // Display messages (what clients render — not the raw session history)
2419
- messages = [];
2420
- constructor(options) {
2421
- if (options.session) {
2422
- this.session = options.session;
2423
- } else {
2424
- const cwd = options.cwd ?? process.cwd();
2425
- const paths = projectPaths(cwd);
2426
- this.session = createSession({
2427
- config: options.config,
2428
- context: options.context,
2429
- projectInfo: options.projectInfo,
2430
- sessionStore: options.sessionStore,
2431
- permissionMode: options.permissionMode,
2432
- maxTurns: options.maxTurns,
2433
- terminal: NOOP_TERMINAL,
2434
- sessionLogger: new import_agent_sessions4.FileSessionLogger(paths.logs),
2435
- permissionHandler: options.permissionHandler,
2436
- onTextDelta: (delta) => this.handleTextDelta(delta),
2437
- onToolExecution: (event) => this.handleToolExecution(event)
2438
- });
2439
- }
2440
- }
2441
- // ── Event system ──────────────────────────────────────────────
2442
- on(event, handler) {
2443
- if (!this.listeners.has(event)) {
2444
- this.listeners.set(event, /* @__PURE__ */ new Set());
2445
- }
2446
- this.listeners.get(event).add(handler);
2447
- }
2448
- off(event, handler) {
2449
- this.listeners.get(event)?.delete(handler);
2249
+ off(event, handler) {
2250
+ this.listeners.get(event)?.delete(handler);
2450
2251
  }
2451
2252
  emit(event, ...args) {
2452
2253
  const handlers = this.listeners.get(event);
@@ -2457,10 +2258,9 @@ var InteractiveSession = class {
2457
2258
  }
2458
2259
  }
2459
2260
  // ── Public API ────────────────────────────────────────────────
2460
- /** Submit a prompt. Queues if already executing (max 1 queued).
2461
- * displayInput overrides what appears as the user message (e.g., "/audit" instead of full skill prompt).
2462
- * rawInput is passed to Session.run() for hook matching (e.g., "/rulebased-harness:audit"). */
2261
+ /** Submit a prompt. Queues if already executing (max 1 queued). */
2463
2262
  async submit(input, displayInput, rawInput) {
2263
+ await this.ensureInitialized();
2464
2264
  if (this.executing) {
2465
2265
  this.pendingPrompt = input;
2466
2266
  this.pendingDisplayInput = displayInput;
@@ -2469,14 +2269,23 @@ var InteractiveSession = class {
2469
2269
  }
2470
2270
  await this.executePrompt(input, displayInput, rawInput);
2471
2271
  }
2272
+ /** Execute a system command by name. Returns null if not found. */
2273
+ async executeCommand(name, args) {
2274
+ await this.ensureInitialized();
2275
+ return this.commandExecutor.execute(name, this, args);
2276
+ }
2472
2277
  /** Abort current execution and clear queue. */
2473
2278
  abort() {
2474
2279
  this.pendingPrompt = null;
2475
- this.session.abort();
2280
+ this.pendingDisplayInput = void 0;
2281
+ this.pendingRawInput = void 0;
2282
+ this.session?.abort();
2476
2283
  }
2477
2284
  /** Cancel queued prompt without aborting current execution. */
2478
2285
  cancelQueue() {
2479
2286
  this.pendingPrompt = null;
2287
+ this.pendingDisplayInput = void 0;
2288
+ this.pendingRawInput = void 0;
2480
2289
  }
2481
2290
  isExecuting() {
2482
2291
  return this.executing;
@@ -2484,8 +2293,13 @@ var InteractiveSession = class {
2484
2293
  getPendingPrompt() {
2485
2294
  return this.pendingPrompt;
2486
2295
  }
2296
+ /** Get full history timeline (chat + events) for TUI rendering */
2297
+ getFullHistory() {
2298
+ return this.history;
2299
+ }
2300
+ /** Get chat messages only (backward compatible) */
2487
2301
  getMessages() {
2488
- return this.messages;
2302
+ return this.history.filter((e) => e.category === "chat").map((e) => e.data);
2489
2303
  }
2490
2304
  getStreamingText() {
2491
2305
  return this.streamingText;
@@ -2494,39 +2308,44 @@ var InteractiveSession = class {
2494
2308
  return this.activeTools;
2495
2309
  }
2496
2310
  getContextState() {
2497
- return this.session.getContextState();
2311
+ return this.getSessionOrThrow().getContextState();
2498
2312
  }
2313
+ /** Access underlying Session. For advanced use / testing only. */
2499
2314
  getSession() {
2500
- return this.session;
2315
+ return this.getSessionOrThrow();
2501
2316
  }
2502
2317
  // ── Execution ─────────────────────────────────────────────────
2503
2318
  async executePrompt(input, displayInput, rawInput) {
2504
2319
  this.executing = true;
2505
2320
  this.clearStreaming();
2506
2321
  this.emit("thinking", true);
2507
- this.messages.push((0, import_agent_core3.createUserMessage)(displayInput ?? input));
2508
- const historyBefore = this.session.getHistory().length;
2322
+ this.history.push((0, import_agent_core.messageToHistoryEntry)((0, import_agent_core.createUserMessage)(displayInput ?? input)));
2323
+ const historyBefore = this.getSessionOrThrow().getHistory().length;
2509
2324
  try {
2510
- const response = await this.session.run(input, rawInput);
2325
+ const response = await this.getSessionOrThrow().run(input, rawInput);
2511
2326
  this.flushStreaming();
2327
+ this.pushToolSummaryMessage();
2512
2328
  this.clearStreaming();
2513
2329
  const result = this.buildResult(response || "(empty response)", historyBefore);
2514
- this.messages.push((0, import_agent_core3.createAssistantMessage)(result.response));
2330
+ this.history.push((0, import_agent_core.messageToHistoryEntry)((0, import_agent_core.createAssistantMessage)(result.response)));
2515
2331
  this.emit("complete", result);
2516
2332
  this.emit("context_update", this.getContextState());
2517
2333
  } catch (err) {
2518
2334
  this.flushStreaming();
2519
- this.clearStreaming();
2520
2335
  if (isAbortError(err)) {
2521
2336
  const result = this.buildInterruptedResult(historyBefore);
2337
+ this.pushToolSummaryMessage();
2338
+ this.clearStreaming();
2522
2339
  if (result.response) {
2523
- this.messages.push((0, import_agent_core3.createAssistantMessage)(result.response));
2340
+ this.history.push((0, import_agent_core.messageToHistoryEntry)((0, import_agent_core.createAssistantMessage)(result.response)));
2524
2341
  }
2525
- this.messages.push((0, import_agent_core3.createSystemMessage)("Interrupted by user."));
2342
+ this.history.push((0, import_agent_core.messageToHistoryEntry)((0, import_agent_core.createSystemMessage)("Interrupted by user.")));
2526
2343
  this.emit("interrupted", result);
2527
2344
  } else {
2345
+ this.pushToolSummaryMessage();
2346
+ this.clearStreaming();
2528
2347
  const errMsg = err instanceof Error ? err.message : String(err);
2529
- this.messages.push((0, import_agent_core3.createSystemMessage)(`Error: ${errMsg}`));
2348
+ this.history.push((0, import_agent_core.messageToHistoryEntry)((0, import_agent_core.createSystemMessage)(`Error: ${errMsg}`)));
2530
2349
  this.emit("error", err instanceof Error ? err : new Error(errMsg));
2531
2350
  }
2532
2351
  } finally {
@@ -2556,22 +2375,14 @@ var InteractiveSession = class {
2556
2375
  handleToolExecution(event) {
2557
2376
  if (event.type === "start") {
2558
2377
  const firstArg = extractFirstArg(event.toolArgs);
2559
- const state = {
2560
- toolName: event.toolName,
2561
- firstArg,
2562
- isRunning: true
2563
- };
2378
+ const state = { toolName: event.toolName, firstArg, isRunning: true };
2564
2379
  this.activeTools.push(state);
2565
2380
  this.emit("tool_start", state);
2566
2381
  } else {
2567
2382
  const result = event.denied ? "denied" : event.success === false ? "error" : "success";
2568
2383
  const idx = this.activeTools.findIndex((t) => t.toolName === event.toolName && t.isRunning);
2569
2384
  if (idx !== -1) {
2570
- const finished = {
2571
- ...this.activeTools[idx],
2572
- isRunning: false,
2573
- result
2574
- };
2385
+ const finished = { ...this.activeTools[idx], isRunning: false, result };
2575
2386
  this.activeTools[idx] = finished;
2576
2387
  this.trimCompletedTools();
2577
2388
  this.emit("tool_end", finished);
@@ -2579,6 +2390,31 @@ var InteractiveSession = class {
2579
2390
  }
2580
2391
  }
2581
2392
  // ── Helpers ───────────────────────────────────────────────────
2393
+ /** Push tool execution summary into messages (before Robota response).
2394
+ * Moves tool info from activeTools (real-time display) to messages (permanent display).
2395
+ * After this, activeTools will be cleared by clearStreaming(). */
2396
+ pushToolSummaryMessage() {
2397
+ if (this.activeTools.length === 0) return;
2398
+ const summary = this.activeTools.map((t) => {
2399
+ const status = t.isRunning ? "\u27F3" : t.result === "success" ? "\u2713" : t.result === "error" ? "\u2717" : "\u2298";
2400
+ return `${status} ${t.toolName}${t.firstArg ? `(${t.firstArg})` : ""}`;
2401
+ }).join("\n");
2402
+ this.history.push({
2403
+ id: (0, import_node_crypto.randomUUID)(),
2404
+ timestamp: /* @__PURE__ */ new Date(),
2405
+ category: "event",
2406
+ type: "tool-summary",
2407
+ data: {
2408
+ tools: this.activeTools.map((t) => ({
2409
+ toolName: t.toolName,
2410
+ firstArg: t.firstArg,
2411
+ isRunning: t.isRunning,
2412
+ result: t.result
2413
+ })),
2414
+ summary
2415
+ }
2416
+ });
2417
+ }
2582
2418
  clearStreaming() {
2583
2419
  this.streamingText = "";
2584
2420
  this.activeTools = [];
@@ -2597,30 +2433,28 @@ var InteractiveSession = class {
2597
2433
  const toolSummaries = this.extractToolSummaries(historyBefore);
2598
2434
  return {
2599
2435
  response,
2600
- messages: this.messages,
2436
+ history: this.history,
2601
2437
  toolSummaries,
2602
2438
  contextState: this.getContextState()
2603
2439
  };
2604
2440
  }
2605
2441
  buildInterruptedResult(historyBefore) {
2606
- const history = this.session.getHistory();
2442
+ const history = this.getSessionOrThrow().getHistory();
2607
2443
  const toolSummaries = this.extractToolSummaries(historyBefore);
2608
2444
  const parts = [];
2609
2445
  for (let i = historyBefore; i < history.length; i++) {
2610
2446
  const msg = history[i];
2611
- if (msg?.role === "assistant" && msg.content) {
2612
- parts.push(msg.content);
2613
- }
2447
+ if (msg?.role === "assistant" && msg.content) parts.push(msg.content);
2614
2448
  }
2615
2449
  return {
2616
2450
  response: parts.join("\n\n"),
2617
- messages: this.messages,
2451
+ history: this.history,
2618
2452
  toolSummaries,
2619
2453
  contextState: this.getContextState()
2620
2454
  };
2621
2455
  }
2622
2456
  extractToolSummaries(historyBefore) {
2623
- const history = this.session.getHistory();
2457
+ const history = this.getSessionOrThrow().getHistory();
2624
2458
  const summaries = [];
2625
2459
  for (let i = historyBefore; i < history.length; i++) {
2626
2460
  const msg = history[i];
@@ -2672,13 +2506,395 @@ var NOOP_TERMINAL = {
2672
2506
  } })
2673
2507
  };
2674
2508
 
2509
+ // src/query.ts
2510
+ function createQuery(options) {
2511
+ const session = new InteractiveSession({
2512
+ cwd: options.cwd ?? process.cwd(),
2513
+ provider: options.provider,
2514
+ permissionMode: options.permissionMode ?? "bypassPermissions",
2515
+ maxTurns: options.maxTurns,
2516
+ permissionHandler: options.permissionHandler
2517
+ });
2518
+ if (options.onTextDelta) {
2519
+ session.on("text_delta", options.onTextDelta);
2520
+ }
2521
+ return async (prompt) => {
2522
+ return new Promise((resolve2, reject) => {
2523
+ const onComplete = (result) => {
2524
+ cleanup();
2525
+ resolve2(result.response);
2526
+ };
2527
+ const onInterrupted = (result) => {
2528
+ cleanup();
2529
+ resolve2(result.response);
2530
+ };
2531
+ const onError = (error) => {
2532
+ cleanup();
2533
+ reject(error);
2534
+ };
2535
+ const cleanup = () => {
2536
+ session.off("complete", onComplete);
2537
+ session.off("interrupted", onInterrupted);
2538
+ session.off("error", onError);
2539
+ };
2540
+ session.on("complete", onComplete);
2541
+ session.on("interrupted", onInterrupted);
2542
+ session.on("error", onError);
2543
+ session.submit(prompt).catch((err) => {
2544
+ cleanup();
2545
+ reject(err instanceof Error ? err : new Error(String(err)));
2546
+ });
2547
+ });
2548
+ };
2549
+ }
2550
+
2551
+ // src/commands/command-registry.ts
2552
+ var CommandRegistry = class {
2553
+ sources = [];
2554
+ addSource(source) {
2555
+ this.sources.push(source);
2556
+ }
2557
+ /** Get all commands, optionally filtered by prefix */
2558
+ getCommands(filter) {
2559
+ const all = [];
2560
+ for (const source of this.sources) {
2561
+ all.push(...source.getCommands());
2562
+ }
2563
+ if (!filter) return all;
2564
+ const lower = filter.toLowerCase();
2565
+ return all.filter((cmd) => cmd.name.toLowerCase().startsWith(lower));
2566
+ }
2567
+ /** Resolve a short name to its fully qualified plugin:name form */
2568
+ resolveQualifiedName(shortName) {
2569
+ const matches = this.getCommands().filter(
2570
+ (c) => c.source === "plugin" && c.name.includes(":") && c.name.endsWith(`:${shortName}`)
2571
+ );
2572
+ if (matches.length !== 1) return null;
2573
+ return matches[0].name;
2574
+ }
2575
+ /** Get subcommands for a specific command */
2576
+ getSubcommands(commandName) {
2577
+ const lower = commandName.toLowerCase();
2578
+ for (const source of this.sources) {
2579
+ for (const cmd of source.getCommands()) {
2580
+ if (cmd.name.toLowerCase() === lower && cmd.subcommands) {
2581
+ return cmd.subcommands;
2582
+ }
2583
+ }
2584
+ }
2585
+ return [];
2586
+ }
2587
+ };
2588
+
2589
+ // src/commands/builtin-source.ts
2590
+ var import_agent_core2 = require("@robota-sdk/agent-core");
2591
+ function buildModelSubcommands() {
2592
+ const seen = /* @__PURE__ */ new Set();
2593
+ const commands = [];
2594
+ for (const model of Object.values(import_agent_core2.CLAUDE_MODELS)) {
2595
+ if (seen.has(model.name)) continue;
2596
+ seen.add(model.name);
2597
+ commands.push({
2598
+ name: model.id,
2599
+ description: `${model.name} (${(0, import_agent_core2.formatTokenCount)(model.contextWindow).toUpperCase()})`,
2600
+ source: "builtin"
2601
+ });
2602
+ }
2603
+ return commands;
2604
+ }
2605
+ function createBuiltinCommands() {
2606
+ return [
2607
+ { name: "help", description: "Show available commands", source: "builtin" },
2608
+ { name: "clear", description: "Clear conversation history", source: "builtin" },
2609
+ {
2610
+ name: "mode",
2611
+ description: "Permission mode",
2612
+ source: "builtin",
2613
+ subcommands: [
2614
+ { name: "plan", description: "Plan only, no execution", source: "builtin" },
2615
+ { name: "default", description: "Ask before risky actions", source: "builtin" },
2616
+ { name: "acceptEdits", description: "Auto-approve file edits", source: "builtin" },
2617
+ { name: "bypassPermissions", description: "Skip all permission checks", source: "builtin" }
2618
+ ]
2619
+ },
2620
+ {
2621
+ name: "model",
2622
+ description: "Select AI model",
2623
+ source: "builtin",
2624
+ subcommands: buildModelSubcommands()
2625
+ },
2626
+ {
2627
+ name: "language",
2628
+ description: "Set response language",
2629
+ source: "builtin",
2630
+ subcommands: [
2631
+ { name: "ko", description: "Korean", source: "builtin" },
2632
+ { name: "en", description: "English", source: "builtin" },
2633
+ { name: "ja", description: "Japanese", source: "builtin" },
2634
+ { name: "zh", description: "Chinese", source: "builtin" }
2635
+ ]
2636
+ },
2637
+ { name: "compact", description: "Compress context window", source: "builtin" },
2638
+ { name: "cost", description: "Show session info", source: "builtin" },
2639
+ { name: "context", description: "Context window info", source: "builtin" },
2640
+ { name: "permissions", description: "Permission rules", source: "builtin" },
2641
+ { name: "plugin", description: "Manage plugins", source: "builtin" },
2642
+ { name: "reload-plugins", description: "Reload all plugin resources", source: "builtin" },
2643
+ { name: "reset", description: "Delete settings and exit", source: "builtin" },
2644
+ { name: "exit", description: "Exit CLI", source: "builtin" }
2645
+ ];
2646
+ }
2647
+ var BuiltinCommandSource = class {
2648
+ name = "builtin";
2649
+ commands;
2650
+ constructor() {
2651
+ this.commands = createBuiltinCommands();
2652
+ }
2653
+ getCommands() {
2654
+ return this.commands;
2655
+ }
2656
+ };
2657
+
2658
+ // src/commands/skill-source.ts
2659
+ var import_node_fs7 = require("fs");
2660
+ var import_node_path10 = require("path");
2661
+ var import_node_os4 = require("os");
2662
+ var BOOLEAN_KEYS = /* @__PURE__ */ new Set(["disable-model-invocation", "user-invocable"]);
2663
+ var LIST_KEYS2 = /* @__PURE__ */ new Set(["allowed-tools"]);
2664
+ function kebabToCamel(key) {
2665
+ return key.replace(/-([a-z])/g, (_match, letter) => letter.toUpperCase());
2666
+ }
2667
+ function parseFrontmatter2(content) {
2668
+ const lines = content.split("\n");
2669
+ if (lines[0]?.trim() !== "---") return null;
2670
+ const result = {};
2671
+ for (let i = 1; i < lines.length; i++) {
2672
+ const line = lines[i];
2673
+ if (line.trim() === "---") break;
2674
+ const match = line.match(/^([a-z][a-z0-9-]*):\s*(.+)/);
2675
+ if (!match) continue;
2676
+ const key = match[1];
2677
+ const rawValue = match[2].trim();
2678
+ const camelKey = kebabToCamel(key);
2679
+ if (BOOLEAN_KEYS.has(key)) {
2680
+ result[camelKey] = rawValue === "true";
2681
+ } else if (LIST_KEYS2.has(key)) {
2682
+ result[camelKey] = rawValue.split(",").map((s) => s.trim());
2683
+ } else {
2684
+ result[camelKey] = rawValue;
2685
+ }
2686
+ }
2687
+ return Object.keys(result).length > 0 ? result : null;
2688
+ }
2689
+ function buildCommand(frontmatter, content, fallbackName) {
2690
+ const cmd = {
2691
+ name: frontmatter?.name ?? fallbackName,
2692
+ description: frontmatter?.description ?? `Skill: ${fallbackName}`,
2693
+ source: "skill",
2694
+ skillContent: content
2695
+ };
2696
+ if (frontmatter?.argumentHint !== void 0) cmd.argumentHint = frontmatter.argumentHint;
2697
+ if (frontmatter?.disableModelInvocation !== void 0)
2698
+ cmd.disableModelInvocation = frontmatter.disableModelInvocation;
2699
+ if (frontmatter?.userInvocable !== void 0) cmd.userInvocable = frontmatter.userInvocable;
2700
+ if (frontmatter?.allowedTools !== void 0) cmd.allowedTools = frontmatter.allowedTools;
2701
+ if (frontmatter?.model !== void 0) cmd.model = frontmatter.model;
2702
+ if (frontmatter?.effort !== void 0) cmd.effort = frontmatter.effort;
2703
+ if (frontmatter?.context !== void 0) cmd.context = frontmatter.context;
2704
+ if (frontmatter?.agent !== void 0) cmd.agent = frontmatter.agent;
2705
+ return cmd;
2706
+ }
2707
+ function scanSkillsDir(skillsDir) {
2708
+ if (!(0, import_node_fs7.existsSync)(skillsDir)) return [];
2709
+ const commands = [];
2710
+ const entries = (0, import_node_fs7.readdirSync)(skillsDir, { withFileTypes: true });
2711
+ for (const entry of entries) {
2712
+ if (!entry.isDirectory()) continue;
2713
+ const skillFile = (0, import_node_path10.join)(skillsDir, entry.name, "SKILL.md");
2714
+ if (!(0, import_node_fs7.existsSync)(skillFile)) continue;
2715
+ const content = (0, import_node_fs7.readFileSync)(skillFile, "utf-8");
2716
+ const frontmatter = parseFrontmatter2(content);
2717
+ commands.push(buildCommand(frontmatter, content, entry.name));
2718
+ }
2719
+ return commands;
2720
+ }
2721
+ function scanCommandsDir(commandsDir) {
2722
+ if (!(0, import_node_fs7.existsSync)(commandsDir)) return [];
2723
+ const commands = [];
2724
+ const entries = (0, import_node_fs7.readdirSync)(commandsDir, { withFileTypes: true });
2725
+ for (const entry of entries) {
2726
+ if (!entry.isFile() || !entry.name.endsWith(".md")) continue;
2727
+ const filePath = (0, import_node_path10.join)(commandsDir, entry.name);
2728
+ const content = (0, import_node_fs7.readFileSync)(filePath, "utf-8");
2729
+ const frontmatter = parseFrontmatter2(content);
2730
+ const fallbackName = (0, import_node_path10.basename)(entry.name, ".md");
2731
+ commands.push(buildCommand(frontmatter, content, fallbackName));
2732
+ }
2733
+ return commands;
2734
+ }
2735
+ var SkillCommandSource = class {
2736
+ name = "skill";
2737
+ cwd;
2738
+ home;
2739
+ cachedCommands = null;
2740
+ constructor(cwd, home) {
2741
+ this.cwd = cwd;
2742
+ this.home = home ?? (0, import_node_os4.homedir)();
2743
+ }
2744
+ getCommands() {
2745
+ if (this.cachedCommands) return this.cachedCommands;
2746
+ const sources = [
2747
+ scanSkillsDir((0, import_node_path10.join)(this.cwd, ".claude", "skills")),
2748
+ scanCommandsDir((0, import_node_path10.join)(this.cwd, ".claude", "commands")),
2749
+ scanSkillsDir((0, import_node_path10.join)(this.home, ".robota", "skills")),
2750
+ scanSkillsDir((0, import_node_path10.join)(this.cwd, ".agents", "skills"))
2751
+ ];
2752
+ const seen = /* @__PURE__ */ new Set();
2753
+ const merged = [];
2754
+ for (const commands of sources) {
2755
+ for (const cmd of commands) {
2756
+ if (!seen.has(cmd.name)) {
2757
+ seen.add(cmd.name);
2758
+ merged.push(cmd);
2759
+ }
2760
+ }
2761
+ }
2762
+ this.cachedCommands = merged;
2763
+ return this.cachedCommands;
2764
+ }
2765
+ getModelInvocableSkills() {
2766
+ return this.getCommands().filter((cmd) => cmd.disableModelInvocation !== true);
2767
+ }
2768
+ getUserInvocableSkills() {
2769
+ return this.getCommands().filter((cmd) => cmd.userInvocable !== false);
2770
+ }
2771
+ };
2772
+
2773
+ // src/commands/plugin-source.ts
2774
+ var PluginCommandSource = class {
2775
+ name = "plugin";
2776
+ plugins;
2777
+ constructor(plugins) {
2778
+ this.plugins = plugins;
2779
+ }
2780
+ getCommands() {
2781
+ const commands = [];
2782
+ for (const plugin of this.plugins) {
2783
+ for (const skill of plugin.skills) {
2784
+ const baseName = skill.name.includes("@") ? skill.name.split("@")[0] : skill.name;
2785
+ commands.push({
2786
+ name: baseName,
2787
+ description: `(${plugin.manifest.name}) ${skill.description}`,
2788
+ source: "plugin",
2789
+ skillContent: skill.skillContent,
2790
+ pluginDir: plugin.pluginDir
2791
+ });
2792
+ }
2793
+ for (const cmd of plugin.commands) {
2794
+ commands.push({
2795
+ name: cmd.name,
2796
+ description: cmd.description,
2797
+ source: "plugin",
2798
+ skillContent: cmd.skillContent,
2799
+ pluginDir: plugin.pluginDir
2800
+ });
2801
+ }
2802
+ }
2803
+ return commands;
2804
+ }
2805
+ };
2806
+
2807
+ // src/utils/skill-prompt.ts
2808
+ var import_node_child_process3 = require("child_process");
2809
+ function substituteVariables(content, args, context) {
2810
+ const argParts = args ? args.split(/\s+/) : [];
2811
+ let result = content;
2812
+ result = result.replace(/\$ARGUMENTS\[(\d+)]/g, (_match, index) => {
2813
+ return argParts[Number(index)] ?? "";
2814
+ });
2815
+ result = result.replace(/\$ARGUMENTS/g, args);
2816
+ result = result.replace(/\$(\d)(?!\d|\w|\[)/g, (_match, digit) => {
2817
+ return argParts[Number(digit)] ?? "";
2818
+ });
2819
+ result = result.replace(/\$\{CLAUDE_SESSION_ID}/g, context?.sessionId ?? "");
2820
+ result = result.replace(/\$\{CLAUDE_SKILL_DIR}/g, context?.skillDir ?? "");
2821
+ return result;
2822
+ }
2823
+ async function preprocessShellCommands(content) {
2824
+ const shellPattern = /!`([^`]+)`/g;
2825
+ if (!shellPattern.test(content)) {
2826
+ return content;
2827
+ }
2828
+ shellPattern.lastIndex = 0;
2829
+ let result = content;
2830
+ let match;
2831
+ const matches = [];
2832
+ while ((match = shellPattern.exec(content)) !== null) {
2833
+ matches.push({ full: match[0], command: match[1] });
2834
+ }
2835
+ for (const { full, command } of matches) {
2836
+ let output = "";
2837
+ try {
2838
+ output = (0, import_node_child_process3.execSync)(command, {
2839
+ timeout: 5e3,
2840
+ encoding: "utf-8",
2841
+ stdio: ["pipe", "pipe", "pipe"]
2842
+ }).trimEnd();
2843
+ } catch {
2844
+ output = "";
2845
+ }
2846
+ result = result.replace(full, output);
2847
+ }
2848
+ return result;
2849
+ }
2850
+ async function buildSkillPrompt(input, registry, context) {
2851
+ const parts = input.slice(1).split(/\s+/);
2852
+ const cmd = parts[0]?.toLowerCase() ?? "";
2853
+ const skillCmd = registry.getCommands().find((c) => c.name === cmd && (c.source === "skill" || c.source === "plugin"));
2854
+ if (!skillCmd) return null;
2855
+ const args = parts.slice(1).join(" ").trim();
2856
+ const userInstruction = args || skillCmd.description;
2857
+ if (skillCmd.skillContent) {
2858
+ let processed = await preprocessShellCommands(skillCmd.skillContent);
2859
+ processed = substituteVariables(processed, args, context);
2860
+ return `<skill name="${cmd}">
2861
+ ${processed}
2862
+ </skill>
2863
+
2864
+ Execute the "${cmd}" skill: ${userInstruction}`;
2865
+ }
2866
+ return `Use the "${cmd}" skill: ${userInstruction}`;
2867
+ }
2868
+
2869
+ // src/types.ts
2870
+ var import_agent_core3 = require("@robota-sdk/agent-core");
2871
+
2872
+ // src/index.ts
2873
+ var import_agent_core4 = require("@robota-sdk/agent-core");
2874
+ var import_agent_core5 = require("@robota-sdk/agent-core");
2875
+
2876
+ // src/permissions/permission-prompt.ts
2877
+ var import_chalk = __toESM(require("chalk"), 1);
2878
+ var PERMISSION_OPTIONS = ["Allow", "Deny"];
2879
+ var ALLOW_INDEX = 0;
2880
+ function formatArgs(toolArgs) {
2881
+ const entries = Object.entries(toolArgs);
2882
+ if (entries.length === 0) {
2883
+ return "(no arguments)";
2884
+ }
2885
+ return entries.map(([k, v]) => `${k}: ${typeof v === "string" ? v : JSON.stringify(v)}`).join(", ");
2886
+ }
2887
+ async function promptForApproval(terminal, toolName, toolArgs) {
2888
+ terminal.writeLine("");
2889
+ terminal.writeLine(import_chalk.default.yellow(`[Permission Required] Tool: ${toolName}`));
2890
+ terminal.writeLine(import_chalk.default.dim(` ${formatArgs(toolArgs)}`));
2891
+ terminal.writeLine("");
2892
+ const selected = await terminal.select(PERMISSION_OPTIONS, ALLOW_INDEX);
2893
+ return selected === ALLOW_INDEX;
2894
+ }
2895
+
2675
2896
  // src/index.ts
2676
- var import_agent_tools3 = require("@robota-sdk/agent-tools");
2677
- var import_agent_tools4 = require("@robota-sdk/agent-tools");
2678
- var import_agent_tools5 = require("@robota-sdk/agent-tools");
2679
- var import_agent_tools6 = require("@robota-sdk/agent-tools");
2680
- var import_agent_tools7 = require("@robota-sdk/agent-tools");
2681
- var import_agent_tools8 = require("@robota-sdk/agent-tools");
2897
+ var import_agent_core6 = require("@robota-sdk/agent-core");
2682
2898
  // Annotate the CommonJS export names for ESM import in node:
2683
2899
  0 && (module.exports = {
2684
2900
  AgentExecutor,
@@ -2687,47 +2903,35 @@ var import_agent_tools8 = require("@robota-sdk/agent-tools");
2687
2903
  BundlePluginInstaller,
2688
2904
  BundlePluginLoader,
2689
2905
  CommandRegistry,
2690
- DEFAULT_TOOL_DESCRIPTIONS,
2691
- FileSessionLogger,
2692
2906
  InteractiveSession,
2693
2907
  MarketplaceClient,
2908
+ PluginCommandSource,
2694
2909
  PluginSettingsStore,
2695
2910
  PromptExecutor,
2696
- Session,
2697
- SessionStore,
2698
- SilentSessionLogger,
2699
2911
  SkillCommandSource,
2700
- SystemCommandExecutor,
2701
2912
  TRUST_TO_MODE,
2702
2913
  assembleSubagentPrompt,
2703
- bashTool,
2704
- buildSystemPrompt,
2914
+ buildSkillPrompt,
2915
+ chatEntryToMessage,
2705
2916
  createAgentTool,
2706
- createDefaultTools,
2707
- createProvider,
2708
- createSession,
2917
+ createQuery,
2709
2918
  createSubagentLogger,
2710
2919
  createSubagentSession,
2711
- createSystemCommands,
2712
- detectProject,
2713
- editTool,
2714
2920
  evaluatePermission,
2715
2921
  getBuiltInAgent,
2716
2922
  getForkWorkerSuffix,
2923
+ getMessagesForAPI,
2717
2924
  getSubagentSuffix,
2718
- globTool,
2719
- grepTool,
2720
- loadConfig,
2721
- loadContext,
2925
+ isChatEntry,
2926
+ messageToHistoryEntry,
2722
2927
  parseFrontmatter,
2928
+ preprocessShellCommands,
2723
2929
  projectPaths,
2724
2930
  promptForApproval,
2725
- query,
2726
- readTool,
2727
2931
  resolveSubagentLogDir,
2728
2932
  retrieveAgentToolDeps,
2729
2933
  runHooks,
2730
2934
  storeAgentToolDeps,
2731
- userPaths,
2732
- writeTool
2935
+ substituteVariables,
2936
+ userPaths
2733
2937
  });