0agent 1.0.97 → 1.1.1

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.
Files changed (2) hide show
  1. package/dist/daemon.mjs +103 -24
  2. package/package.json +1 -1
package/dist/daemon.mjs CHANGED
@@ -5917,6 +5917,72 @@ var init_ContextCollapse = __esm({
5917
5917
  }
5918
5918
  });
5919
5919
 
5920
+ // packages/daemon/src/utils/GitContext.ts
5921
+ import { execSync as execSync6 } from "node:child_process";
5922
+ function getGitContext(cwd) {
5923
+ const state = getGitState(cwd);
5924
+ if (!state.isGitRepo) return null;
5925
+ const lines = [
5926
+ `Git: branch \`${state.branch}\`${state.hasUncommitted ? " (uncommitted changes)" : ""}`
5927
+ ];
5928
+ if (state.recentCommits.length > 0) {
5929
+ lines.push(`Recent commits:`);
5930
+ for (const c of state.recentCommits) {
5931
+ lines.push(` ${c}`);
5932
+ }
5933
+ }
5934
+ if (state.hasUncommitted && state.status) {
5935
+ const statusLines = state.status.split("\n").slice(0, 8);
5936
+ lines.push(`Working tree:`);
5937
+ for (const s of statusLines) {
5938
+ lines.push(` ${s}`);
5939
+ }
5940
+ if (state.status.split("\n").length > 8) {
5941
+ lines.push(` ... and ${state.status.split("\n").length - 8} more files`);
5942
+ }
5943
+ }
5944
+ return lines.join("\n");
5945
+ }
5946
+ function getGitState(cwd) {
5947
+ try {
5948
+ execSync6("git rev-parse --git-dir", { cwd, stdio: "pipe", timeout: 3e3 });
5949
+ } catch {
5950
+ return { branch: "", recentCommits: [], status: "", hasUncommitted: false, isGitRepo: false };
5951
+ }
5952
+ let branch = "unknown";
5953
+ try {
5954
+ branch = execSync6("git branch --show-current", { cwd, encoding: "utf8", timeout: 3e3 }).trim() || "HEAD (detached)";
5955
+ } catch {
5956
+ }
5957
+ let recentCommits = [];
5958
+ try {
5959
+ const log = execSync6("git log --oneline -5 --no-decorate", { cwd, encoding: "utf8", timeout: 3e3 }).trim();
5960
+ recentCommits = log ? log.split("\n") : [];
5961
+ } catch {
5962
+ }
5963
+ let status = "";
5964
+ let hasUncommitted = false;
5965
+ try {
5966
+ status = execSync6("git status --short", { cwd, encoding: "utf8", timeout: 3e3 }).trim();
5967
+ hasUncommitted = status.length > 0;
5968
+ } catch {
5969
+ }
5970
+ return { branch, recentCommits, status, hasUncommitted, isGitRepo: true };
5971
+ }
5972
+ function getTimeContext() {
5973
+ const hour = (/* @__PURE__ */ new Date()).getHours();
5974
+ if (hour < 6) return "late night";
5975
+ if (hour < 12) return "morning";
5976
+ if (hour < 17) return "afternoon";
5977
+ if (hour < 21) return "evening";
5978
+ return "night";
5979
+ }
5980
+ var init_GitContext = __esm({
5981
+ "packages/daemon/src/utils/GitContext.ts"() {
5982
+ "use strict";
5983
+ }
5984
+ });
5985
+
5920
5986
  // packages/daemon/src/services/StreamingToolExecutor.ts
5921
5987
  function isPreExecSafe(tc) {
5922
5988
  if (PRE_EXEC_SAFE.has(tc.name)) return true;
@@ -6008,6 +6074,7 @@ var init_AgentExecutor = __esm({
6008
6074
  init_IterationBudget();
6009
6075
  init_PromptInjectionScanner();
6010
6076
  init_ContextCollapse();
6077
+ init_GitContext();
6011
6078
  init_StreamingToolExecutor();
6012
6079
  SELF_MOD_PATTERN = /\b(yourself|the agent|this agent|this cli|0agent|your code|your source|agent cli|improve.*agent|update.*agent|add.*to.*agent|fix.*agent|self.?improv)\b/i;
6013
6080
  AgentExecutor = class {
@@ -6370,8 +6437,16 @@ content = element.text if element else page.get_all_text()` : `content = page.ge
6370
6437
  `SELF-IMPROVEMENT: When asked to add a capability, fix something about yourself, or adapt \u2014`,
6371
6438
  `modify YOUR OWN source at ${agentRoot}/packages/daemon/src/. Read, edit, rebuild.`,
6372
6439
  ``,
6373
- `PERSONALITY: Defined in ~/.0agent/soul.md (read it on first run for full personality guide).`,
6374
- `Be warm, helpful, genuinely curious. Save user info to memory_write.`,
6440
+ `\u2550\u2550\u2550 COWORKER PERSONALITY \u2550\u2550\u2550`,
6441
+ `You are a senior colleague, not a chatbot. Act like it:`,
6442
+ ` \u2022 Have OPINIONS. If you see a better approach, say so. "That works, but I'd do X because Y."`,
6443
+ ` \u2022 Push back when something is wrong. "I wouldn't commit that \u2014 here's why."`,
6444
+ ` \u2022 Be direct and concise. No "I'd be happy to help!" \u2014 just help.`,
6445
+ ` \u2022 Match the user's energy. Terse question \u2192 terse answer. Deep discussion \u2192 engage deeply.`,
6446
+ ` \u2022 Reference past work. "Last time you had this issue, we fixed it by..."`,
6447
+ ` \u2022 Notice things. If you see a bug, failing test, or concern \u2014 mention it unprompted.`,
6448
+ ` \u2022 When the user says "continue" or "keep going" \u2014 check conversation history and resume.`,
6449
+ ` Time: ${getTimeContext()}. Personality details: ~/.0agent/soul.md`,
6375
6450
  ``,
6376
6451
  `Use tools to accomplish tasks \u2014 don't describe what to do, do it.`,
6377
6452
  `Prefer file_op edit (find-and-replace) over rewriting entire files.`,
@@ -6558,6 +6633,8 @@ content = element.text if element else page.get_all_text()` : `content = page.ge
6558
6633
  } catch {
6559
6634
  }
6560
6635
  }
6636
+ const gitCtx = getGitContext(this.cwd);
6637
+ if (gitCtx) lines.push(``, gitCtx);
6561
6638
  if (extra) lines.push(``, `Context:`, extra);
6562
6639
  return lines.join("\n");
6563
6640
  }
@@ -6814,7 +6891,7 @@ var init_ExecutionVerifier = __esm({
6814
6891
  import { readFileSync as readFileSync8, writeFileSync as writeFileSync6, existsSync as existsSync11 } from "node:fs";
6815
6892
  import { resolve as resolve10, dirname as dirname3 } from "node:path";
6816
6893
  import { fileURLToPath } from "node:url";
6817
- import { execSync as execSync7, spawn as spawn6 } from "node:child_process";
6894
+ import { execSync as execSync8, spawn as spawn6 } from "node:child_process";
6818
6895
  function isRuntimeBug(error) {
6819
6896
  if (TASK_FAILURE_PATTERNS.some((p) => p.test(error))) return false;
6820
6897
  return RUNTIME_BUG_PATTERNS.some((p) => p.test(error));
@@ -6944,7 +7021,7 @@ var init_RuntimeSelfHeal = __esm({
6944
7021
  const bundleScript = resolve10(this.projectRoot, "scripts", "bundle.mjs");
6945
7022
  if (existsSync11(bundleScript)) {
6946
7023
  try {
6947
- execSync7(`node "${bundleScript}"`, {
7024
+ execSync8(`node "${bundleScript}"`, {
6948
7025
  cwd: this.projectRoot,
6949
7026
  timeout: 6e4,
6950
7027
  stdio: "ignore"
@@ -7152,7 +7229,7 @@ var ProactiveSurface_exports = {};
7152
7229
  __export(ProactiveSurface_exports, {
7153
7230
  ProactiveSurface: () => ProactiveSurface
7154
7231
  });
7155
- import { execSync as execSync10 } from "node:child_process";
7232
+ import { execSync as execSync11 } from "node:child_process";
7156
7233
  import { existsSync as existsSync21, readFileSync as readFileSync17, statSync as statSync3, readdirSync as readdirSync5 } from "node:fs";
7157
7234
  import { resolve as resolve17, join as join7 } from "node:path";
7158
7235
  function readdirSafe(dir) {
@@ -7221,7 +7298,7 @@ var init_ProactiveSurface = __esm({
7221
7298
  try {
7222
7299
  const currentHead = this.getGitHead();
7223
7300
  if (!currentHead || currentHead === this.lastKnownHead) return null;
7224
- const log = execSync10(
7301
+ const log = execSync11(
7225
7302
  `git log ${this.lastKnownHead}..${currentHead} --oneline --stat`,
7226
7303
  { cwd: this.cwd, timeout: 3e3, encoding: "utf8" }
7227
7304
  ).trim();
@@ -7297,7 +7374,7 @@ var init_ProactiveSurface = __esm({
7297
7374
  }
7298
7375
  getGitHead() {
7299
7376
  try {
7300
- return execSync10("git rev-parse HEAD", { cwd: this.cwd, timeout: 1e3, encoding: "utf8" }).trim();
7377
+ return execSync11("git rev-parse HEAD", { cwd: this.cwd, timeout: 1e3, encoding: "utf8" }).trim();
7301
7378
  } catch {
7302
7379
  return "";
7303
7380
  }
@@ -7704,7 +7781,7 @@ var AnthropicSkillFetcher = class {
7704
7781
  };
7705
7782
 
7706
7783
  // packages/daemon/src/utils/ProjectScanner.ts
7707
- import { execSync as execSync6 } from "node:child_process";
7784
+ import { execSync as execSync7 } from "node:child_process";
7708
7785
  import { readFileSync as readFileSync6, existsSync as existsSync8 } from "node:fs";
7709
7786
  import { join as join2 } from "node:path";
7710
7787
  import { createServer } from "node:net";
@@ -7786,7 +7863,7 @@ var ProjectScanner = class {
7786
7863
  }
7787
7864
  getRecentCommits() {
7788
7865
  try {
7789
- const out = execSync6("git log --oneline -5 2>/dev/null", {
7866
+ const out = execSync7("git log --oneline -5 2>/dev/null", {
7790
7867
  cwd: this.cwd,
7791
7868
  timeout: 3e3,
7792
7869
  encoding: "utf8"
@@ -7798,7 +7875,7 @@ var ProjectScanner = class {
7798
7875
  }
7799
7876
  getDirtyFiles() {
7800
7877
  try {
7801
- const out = execSync6("git status --short 2>/dev/null", {
7878
+ const out = execSync7("git status --short 2>/dev/null", {
7802
7879
  cwd: this.cwd,
7803
7880
  timeout: 3e3,
7804
7881
  encoding: "utf8"
@@ -8469,7 +8546,9 @@ var SessionManager = class {
8469
8546
  const projectCtx = this.projectContext ? ProjectScanner.buildContextPrompt(this.projectContext) : void 0;
8470
8547
  let conversationHistory;
8471
8548
  if (this.conversationStore && userEntityId) {
8472
- const history = this.conversationStore.buildContextMessages(userEntityId, 8);
8549
+ const isContinue = /^(continue|keep going|go on|resume|what were we|where were we|carry on)/i.test(enrichedReq.task.trim());
8550
+ const historyDepth = isContinue ? 16 : 8;
8551
+ const history = this.conversationStore.buildContextMessages(userEntityId, historyDepth);
8473
8552
  if (history.length > 0) {
8474
8553
  const historyStr = history.map((m) => `${m.role === "user" ? "User" : "Agent"}: ${m.content.slice(0, 400)}`).join("\n");
8475
8554
  conversationHistory = `CONVERSATION HISTORY (use this for context on follow-up requests):
@@ -10669,7 +10748,7 @@ git checkout <commit> graph/ # restore graph files
10669
10748
  };
10670
10749
 
10671
10750
  // packages/daemon/src/services/CodespaceManager.ts
10672
- import { execSync as execSync8, spawn as spawn7 } from "node:child_process";
10751
+ import { execSync as execSync9, spawn as spawn7 } from "node:child_process";
10673
10752
  var BROWSER_PORT_REMOTE = 3e3;
10674
10753
  var BROWSER_PORT_LOCAL = 3001;
10675
10754
  var DISPLAY_NAME = "0agent-browser";
@@ -10711,7 +10790,7 @@ var CodespaceManager = class {
10711
10790
  console.log(`[Codespace] Creating browser codespace from ${this.memoryRepo}...`);
10712
10791
  console.log("[Codespace] First time: ~2-3 minutes. Subsequent starts: ~30 seconds.");
10713
10792
  try {
10714
- const result = execSync8(
10793
+ const result = execSync9(
10715
10794
  `gh codespace create --repo "${this.memoryRepo}" --machine basicLinux32gb --display-name "${DISPLAY_NAME}" --json name`,
10716
10795
  { encoding: "utf8", timeout: 3e5 }
10717
10796
  );
@@ -10725,7 +10804,7 @@ var CodespaceManager = class {
10725
10804
  /** Find the 0agent-browser codespace by display name. */
10726
10805
  findExisting() {
10727
10806
  try {
10728
- const out = execSync8("gh codespace list --json name,state,displayName,repository", {
10807
+ const out = execSync9("gh codespace list --json name,state,displayName,repository", {
10729
10808
  encoding: "utf8",
10730
10809
  timeout: 1e4
10731
10810
  });
@@ -10741,7 +10820,7 @@ var CodespaceManager = class {
10741
10820
  const info = this.findExisting();
10742
10821
  if (info?.state === "Shutdown") {
10743
10822
  console.log("[Codespace] Starting stopped codespace (~30s)...");
10744
- execSync8(`gh codespace start --codespace "${name}"`, { timeout: 12e4 });
10823
+ execSync9(`gh codespace start --codespace "${name}"`, { timeout: 12e4 });
10745
10824
  await this.waitForState(name, "Available", 60);
10746
10825
  console.log("[Codespace] Codespace is running");
10747
10826
  } else if (info?.state === "Starting") {
@@ -10753,7 +10832,7 @@ var CodespaceManager = class {
10753
10832
  /** Start the browser server inside the codespace (idempotent). */
10754
10833
  async startBrowserServer(name) {
10755
10834
  try {
10756
- execSync8(
10835
+ execSync9(
10757
10836
  `gh codespace exec --codespace "${name}" -- bash -c "pgrep -f 'node server.js' > /dev/null 2>&1 || (cd /workspaces && nohup node server.js > /tmp/browser-server.log 2>&1 &)"`,
10758
10837
  { timeout: 3e4 }
10759
10838
  );
@@ -10808,7 +10887,7 @@ var CodespaceManager = class {
10808
10887
  this.closeTunnel();
10809
10888
  const info = this.findExisting();
10810
10889
  if (info?.state === "Available") {
10811
- execSync8(`gh codespace stop --codespace "${info.name}"`, { timeout: 3e4 });
10890
+ execSync9(`gh codespace stop --codespace "${info.name}"`, { timeout: 3e4 });
10812
10891
  console.log("[Codespace] Stopped (state preserved, restarts in 30s when needed)");
10813
10892
  }
10814
10893
  }
@@ -10817,7 +10896,7 @@ var CodespaceManager = class {
10817
10896
  this.closeTunnel();
10818
10897
  const info = this.findExisting();
10819
10898
  if (info) {
10820
- execSync8(`gh codespace delete --codespace "${info.name}" --force`, { timeout: 3e4 });
10899
+ execSync9(`gh codespace delete --codespace "${info.name}" --force`, { timeout: 3e4 });
10821
10900
  console.log("[Codespace] Deleted");
10822
10901
  }
10823
10902
  }
@@ -10843,7 +10922,7 @@ var CodespaceManager = class {
10843
10922
  /** Check if gh CLI is installed and authenticated. */
10844
10923
  static isAvailable() {
10845
10924
  try {
10846
- execSync8("gh auth status", { stdio: "ignore", timeout: 5e3 });
10925
+ execSync9("gh auth status", { stdio: "ignore", timeout: 5e3 });
10847
10926
  return true;
10848
10927
  } catch {
10849
10928
  return false;
@@ -11450,13 +11529,13 @@ Sessions: ${h.active_sessions} active`
11450
11529
  const buf = await res.arrayBuffer();
11451
11530
  const { writeFileSync: writeFileSync14 } = await import("node:fs");
11452
11531
  writeFileSync14(tmpPath, Buffer.from(buf));
11453
- const { execSync: execSync11 } = await import("node:child_process");
11532
+ const { execSync: execSync12 } = await import("node:child_process");
11454
11533
  try {
11455
- execSync11(`ffmpeg -y -i "${tmpPath}" -ar 16000 -ac 1 "${wavPath}" 2>/dev/null`, { timeout: 3e4 });
11534
+ execSync12(`ffmpeg -y -i "${tmpPath}" -ar 16000 -ac 1 "${wavPath}" 2>/dev/null`, { timeout: 3e4 });
11456
11535
  } catch {
11457
11536
  }
11458
11537
  const inputFile = existsSync18(wavPath) ? wavPath : tmpPath;
11459
- const whisperOut = execSync11(
11538
+ const whisperOut = execSync12(
11460
11539
  `whisper "${inputFile}" --model ${this.whisperModel} --output_format txt --output_dir "${tmpDir}" --fp16 False 2>/dev/null`,
11461
11540
  { timeout: 12e4, encoding: "utf8" }
11462
11541
  );
@@ -11906,7 +11985,7 @@ var WhatsAppAdapter = class {
11906
11985
  import * as readline from "node:readline";
11907
11986
 
11908
11987
  // packages/daemon/src/surfaces/WhisperSTT.ts
11909
- import { execSync as execSync9, spawnSync as spawnSync5 } from "node:child_process";
11988
+ import { execSync as execSync10, spawnSync as spawnSync5 } from "node:child_process";
11910
11989
  import { existsSync as existsSync19, mkdirSync as mkdirSync9, readFileSync as readFileSync16 } from "node:fs";
11911
11990
  import { tmpdir as tmpdir4 } from "node:os";
11912
11991
  import { join as join5, basename as basename2 } from "node:path";
@@ -11934,7 +12013,7 @@ var WhisperSTT = class _WhisperSTT {
11934
12013
  try {
11935
12014
  const langFlag = this.language ? `--language ${this.language}` : "";
11936
12015
  const cmd = this.binary === "faster-whisper" ? `faster-whisper "${audioPath}" --model ${this.model} ${langFlag} --output_format txt --output_dir "${outDir}"` : `whisper "${audioPath}" --model ${this.model} ${langFlag} --output_format txt --output_dir "${outDir}" --fp16 False`;
11937
- execSync9(cmd, { timeout: 18e4, stdio: "pipe" });
12016
+ execSync10(cmd, { timeout: 18e4, stdio: "pipe" });
11938
12017
  const baseName = basename2(audioPath).replace(/\.[^.]+$/, "");
11939
12018
  const txtPath = join5(outDir, `${baseName}.txt`);
11940
12019
  if (existsSync19(txtPath)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "0agent",
3
- "version": "1.0.97",
3
+ "version": "1.1.1",
4
4
  "description": "A persistent, learning AI agent that runs on your machine. An agent that learns.",
5
5
  "private": false,
6
6
  "license": "Apache-2.0",