@ecmaos-apps/ai 0.2.1 → 0.2.3

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.
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAGA,OAAO,KAAK,EAAE,kBAAkB,EAAS,MAAM,eAAe,CAAA;AA2K9D,iBAAe,IAAI,CAAC,kBAAkB,EAAE,kBAAkB,kBAwFzD;AAED,eAAe,IAAI,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAGA,OAAO,KAAK,EAAE,kBAAkB,EAAS,MAAM,eAAe,CAAA;AA2K9D,iBAAe,IAAI,CAAC,kBAAkB,EAAE,kBAAkB,kBA2HzD;AAED,eAAe,IAAI,CAAA"}
package/dist/index.js CHANGED
@@ -6859,15 +6859,15 @@ function parser(args) {
6859
6859
  return { options, params };
6860
6860
  }
6861
6861
  async function loadSession(session, { shell }) {
6862
- const sessionExists = await shell.context.fs.promises.exists(`${shell.envObject.HOME}/.config/ai/sessions/${session}`);
6863
- if (!sessionExists) await shell.context.fs.promises.mkdir(`${shell.envObject.HOME}/.config/ai/sessions/${session}`, { recursive: true });
6864
- const sessionFileExists = await shell.context.fs.promises.exists(`${shell.envObject.HOME}/.config/ai/sessions/${session}/session.json`);
6865
- if (!sessionFileExists) await shell.context.fs.promises.writeFile(`${shell.envObject.HOME}/.config/ai/sessions/${session}/session.json`, JSON.stringify(DefaultSessionData));
6866
- const sessionData = await shell.context.fs.promises.readFile(`${shell.envObject.HOME}/.config/ai/sessions/${session}/session.json`, "utf-8");
6862
+ const sessionExists = await shell.context.fs.promises.exists(`${shell.envObject.HOME}/.cache/ai/sessions/${session}`);
6863
+ if (!sessionExists) await shell.context.fs.promises.mkdir(`${shell.envObject.HOME}/.cache/ai/sessions/${session}`, { recursive: true });
6864
+ const sessionFileExists = await shell.context.fs.promises.exists(`${shell.envObject.HOME}/.cache/ai/sessions/${session}/session.json`);
6865
+ if (!sessionFileExists) await shell.context.fs.promises.writeFile(`${shell.envObject.HOME}/.cache/ai/sessions/${session}/session.json`, JSON.stringify(DefaultSessionData));
6866
+ const sessionData = await shell.context.fs.promises.readFile(`${shell.envObject.HOME}/.cache/ai/sessions/${session}/session.json`, "utf-8");
6867
6867
  return JSON.parse(sessionData);
6868
6868
  }
6869
6869
  async function saveSession(session, data, { shell }) {
6870
- await shell.context.fs.promises.writeFile(`${shell.envObject.HOME}/.config/ai/sessions/${session}/session.json`, JSON.stringify(data));
6870
+ await shell.context.fs.promises.writeFile(`${shell.envObject.HOME}/.cache/ai/sessions/${session}/session.json`, JSON.stringify(data));
6871
6871
  }
6872
6872
  async function compressMessages(messages, openai, model) {
6873
6873
  const summaryPrompt = `Please provide a concise summary of the following conversation history, preserving key information, decisions, and context that would be important for continuing the conversation:
@@ -6937,7 +6937,7 @@ async function readStdin(stdin, timeoutMs = 100) {
6937
6937
  return chunks.join("").trim();
6938
6938
  }
6939
6939
  async function main(processEntryParams) {
6940
- const { args, shell, stdin, stdout, stderr } = processEntryParams;
6940
+ const { args, shell, stdin, stdout, stderr, terminal } = processEntryParams;
6941
6941
  const { options, params } = parser(args);
6942
6942
  const stdoutWriter = stdout?.getWriter();
6943
6943
  const stderrWriter = stderr?.getWriter();
@@ -7006,6 +7006,41 @@ async function main(processEntryParams) {
7006
7006
  await print(`Error: ${error instanceof Error ? error.message : String(error)}
7007
7007
  `, "stderr");
7008
7008
  return 1;
7009
+ } finally {
7010
+ try {
7011
+ if (stdoutWriter) {
7012
+ if (stdout && terminal && stdout !== terminal.stdout) {
7013
+ try {
7014
+ await stdoutWriter.close();
7015
+ } catch {
7016
+ try {
7017
+ stdoutWriter.releaseLock();
7018
+ } catch {
7019
+ }
7020
+ }
7021
+ } else {
7022
+ stdoutWriter.releaseLock();
7023
+ }
7024
+ }
7025
+ } catch {
7026
+ }
7027
+ try {
7028
+ if (stderrWriter) {
7029
+ if (stderr && terminal && stderr !== terminal.stderr) {
7030
+ try {
7031
+ await stderrWriter.close();
7032
+ } catch {
7033
+ try {
7034
+ stderrWriter.releaseLock();
7035
+ } catch {
7036
+ }
7037
+ }
7038
+ } else {
7039
+ stderrWriter.releaseLock();
7040
+ }
7041
+ }
7042
+ } catch {
7043
+ }
7009
7044
  }
7010
7045
  }
7011
7046
  var index_default = main;