sparkecoder 0.1.5 → 0.1.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { R as ResolvedConfig } from './index-Btr542-G.js';
2
- export { A as Agent, a as AgentOptions, b as AgentRunOptions, c as AgentStreamResult, S as SparkcoderConfig, T as ToolApprovalConfig } from './index-Btr542-G.js';
1
+ import { R as ResolvedConfig } from './index-BeKylVnB.js';
2
+ export { A as Agent, a as AgentOptions, b as AgentRunOptions, c as AgentStreamResult, S as SparkcoderConfig, T as ToolApprovalConfig } from './index-BeKylVnB.js';
3
3
  export { ServerOptions, createApp, startServer, stopServer } from './server/index.js';
4
4
  export { checkpointQueries, closeDatabase, fileBackupQueries, getDb, initDatabase, messageQueries, sessionQueries, skillQueries, todoQueries, toolExecutionQueries } from './db/index.js';
5
5
  import { F as FileBackup, C as Checkpoint } from './schema-CkrIadxa.js';
@@ -96,6 +96,7 @@ interface TerminalMeta {
96
96
  createdAt: string;
97
97
  sessionId: string;
98
98
  background: boolean;
99
+ name?: string;
99
100
  }
100
101
  interface TerminalResult {
101
102
  id: string;
@@ -134,6 +135,7 @@ declare function runSync(command: string, workingDirectory: string, options: {
134
135
  declare function runBackground(command: string, workingDirectory: string, options: {
135
136
  sessionId: string;
136
137
  terminalId?: string;
138
+ name?: string;
137
139
  }): Promise<TerminalResult>;
138
140
  /**
139
141
  * Get logs from a terminal
package/dist/index.js CHANGED
@@ -1131,7 +1131,8 @@ async function runBackground(command, workingDirectory, options) {
1131
1131
  cwd: workingDirectory,
1132
1132
  createdAt: (/* @__PURE__ */ new Date()).toISOString(),
1133
1133
  sessionId: options.sessionId,
1134
- background: true
1134
+ background: true,
1135
+ name: options.name
1135
1136
  }, workingDirectory);
1136
1137
  const logFile = join2(logDir, "output.log");
1137
1138
  const wrappedCommand = `(${command}) 2>&1 | tee -a ${shellEscape(logFile)}`;
@@ -3969,7 +3970,10 @@ terminals2.post(
3969
3970
  return c.json({ error: "tmux is not installed. Background terminals require tmux." }, 400);
3970
3971
  }
3971
3972
  const workingDirectory = body.cwd || session.workingDirectory;
3972
- const result = await runBackground(body.command, workingDirectory, { sessionId });
3973
+ const result = await runBackground(body.command, workingDirectory, {
3974
+ sessionId,
3975
+ name: body.name
3976
+ });
3973
3977
  return c.json({
3974
3978
  id: result.id,
3975
3979
  name: body.name || null,
@@ -3993,7 +3997,7 @@ terminals2.get("/:sessionId/terminals", async (c) => {
3993
3997
  const running = await isRunning(meta.id);
3994
3998
  return {
3995
3999
  id: meta.id,
3996
- name: null,
4000
+ name: meta.name || null,
3997
4001
  command: meta.command,
3998
4002
  cwd: meta.cwd,
3999
4003
  status: running ? "running" : "stopped",
@@ -4077,10 +4081,17 @@ terminals2.post(
4077
4081
  "/:sessionId/terminals/:terminalId/write",
4078
4082
  zValidator4("json", writeSchema),
4079
4083
  async (c) => {
4080
- return c.json({
4081
- error: "stdin writing not supported in tmux mode. Use tmux send-keys directly if needed.",
4082
- hint: 'tmux send-keys -t spark_{terminalId} "your input"'
4083
- }, 501);
4084
+ const terminalId = c.req.param("terminalId");
4085
+ const body = c.req.valid("json");
4086
+ const isRunning2 = await isRunning(terminalId);
4087
+ if (!isRunning2) {
4088
+ return c.json({ error: "Terminal is not running" }, 400);
4089
+ }
4090
+ const success = await sendInput(terminalId, body.input, { pressEnter: false });
4091
+ if (!success) {
4092
+ return c.json({ error: "Failed to write to terminal" }, 500);
4093
+ }
4094
+ return c.json({ success: true, written: body.input.length });
4084
4095
  }
4085
4096
  );
4086
4097
  terminals2.post("/:sessionId/terminals/kill-all", async (c) => {
@@ -4089,12 +4100,12 @@ terminals2.post("/:sessionId/terminals/kill-all", async (c) => {
4089
4100
  if (!session) {
4090
4101
  return c.json({ error: "Session not found" }, 404);
4091
4102
  }
4092
- const terminalIds = await listSessions();
4103
+ const sessionTerminals = await listSessionTerminals(sessionId, session.workingDirectory);
4093
4104
  let killed = 0;
4094
- for (const id of terminalIds) {
4095
- const meta = await getMeta(id, session.workingDirectory);
4096
- if (meta && meta.sessionId === sessionId) {
4097
- const success = await killTerminal(id);
4105
+ for (const terminal of sessionTerminals) {
4106
+ const isRunning2 = await isRunning(terminal.id);
4107
+ if (isRunning2) {
4108
+ const success = await killTerminal(terminal.id);
4098
4109
  if (success) killed++;
4099
4110
  }
4100
4111
  }