@turmind/halo 1.1.4 → 1.1.6

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.js CHANGED
@@ -8,7 +8,7 @@ var __export = (target, all) => {
8
8
  __defProp(target, name, { get: all[name], enumerable: true });
9
9
  };
10
10
 
11
- // packages/cli/src/server-supervisor.ts
11
+ // src/server-supervisor.ts
12
12
  var server_supervisor_exports = {};
13
13
  __export(server_supervisor_exports, {
14
14
  MAX_RESTARTS: () => MAX_RESTARTS,
@@ -114,7 +114,7 @@ async function superviseServer() {
114
114
  }
115
115
  var SUPERVISE_ENV, MAX_RESTARTS, RESTART_WINDOW_MS, RESTART_DELAY_MS, INTENTIONAL_SIGNALS;
116
116
  var init_server_supervisor = __esm({
117
- "packages/cli/src/server-supervisor.ts"() {
117
+ "src/server-supervisor.ts"() {
118
118
  "use strict";
119
119
  SUPERVISE_ENV = "HALO_SUPERVISE";
120
120
  MAX_RESTARTS = 5;
@@ -124,7 +124,7 @@ var init_server_supervisor = __esm({
124
124
  }
125
125
  });
126
126
 
127
- // packages/server/dist/prompts/md-loader.js
127
+ // ../server/dist/prompts/md-loader.js
128
128
  import fs2 from "node:fs/promises";
129
129
  import fsSync from "node:fs";
130
130
  import path2 from "node:path";
@@ -266,13 +266,13 @@ function resolveMdFilePath(agentId, fileType, scope, workspaceRoot) {
266
266
  }
267
267
  var HALO_HOME;
268
268
  var init_md_loader = __esm({
269
- "packages/server/dist/prompts/md-loader.js"() {
269
+ "../server/dist/prompts/md-loader.js"() {
270
270
  "use strict";
271
271
  HALO_HOME = path2.join(homedir2(), ".halo", "global");
272
272
  }
273
273
  });
274
274
 
275
- // packages/server/dist/settings-schema.js
275
+ // ../server/dist/settings-schema.js
276
276
  import fs3 from "node:fs";
277
277
  import path3 from "node:path";
278
278
  import { homedir as homedir3 } from "node:os";
@@ -525,7 +525,7 @@ function loadSettingsSchema(workspaceRoot) {
525
525
  }
526
526
  var GLOBAL_MODELS_DIR, GLOBAL_SKILLS_DIR, GLOBAL_AGENTS_DIR, VALID_TYPES;
527
527
  var init_settings_schema = __esm({
528
- "packages/server/dist/settings-schema.js"() {
528
+ "../server/dist/settings-schema.js"() {
529
529
  "use strict";
530
530
  GLOBAL_MODELS_DIR = path3.join(homedir3(), ".halo", "global", "models");
531
531
  GLOBAL_SKILLS_DIR = path3.join(homedir3(), ".halo", "global", "skills");
@@ -534,7 +534,7 @@ var init_settings_schema = __esm({
534
534
  }
535
535
  });
536
536
 
537
- // packages/server/dist/config.js
537
+ // ../server/dist/config.js
538
538
  var config_exports = {};
539
539
  __export(config_exports, {
540
540
  HALO_GLOBAL_DIR: () => HALO_GLOBAL_DIR,
@@ -840,7 +840,7 @@ function getModelsRegistry() {
840
840
  }
841
841
  var HALO_HOME2, HALO_GLOBAL_DIR, HALO_SECRETS_DIR, _modelsRegistryCache, SYSTEM_CONFIG_PATH, _systemConfigCache, SETTINGS_PATH, _settingsCache, _schemaDefaultsCache, ENV_PATTERN, _wsSettingsCache, config, HIDDEN_DIRS_DEFAULT, HIDDEN_FILES_DEFAULT;
842
842
  var init_config = __esm({
843
- "packages/server/dist/config.js"() {
843
+ "../server/dist/config.js"() {
844
844
  "use strict";
845
845
  init_settings_schema();
846
846
  HALO_HOME2 = path4.join(homedir4(), ".halo");
@@ -1058,7 +1058,7 @@ var init_config = __esm({
1058
1058
  }
1059
1059
  });
1060
1060
 
1061
- // packages/server/dist/agents/conversation-repair.js
1061
+ // ../server/dist/agents/conversation-repair.js
1062
1062
  function getToolUseId(block) {
1063
1063
  const b = block;
1064
1064
  if (b.type === "tool_use" && typeof b.id === "string")
@@ -1176,12 +1176,12 @@ function repairConversationMessages(raw, label = "[Repair]") {
1176
1176
  return messages2;
1177
1177
  }
1178
1178
  var init_conversation_repair = __esm({
1179
- "packages/server/dist/agents/conversation-repair.js"() {
1179
+ "../server/dist/agents/conversation-repair.js"() {
1180
1180
  "use strict";
1181
1181
  }
1182
1182
  });
1183
1183
 
1184
- // packages/server/dist/agents/compact.js
1184
+ // ../server/dist/agents/compact.js
1185
1185
  function splitForCompact(messages2) {
1186
1186
  const keepCount = config.compact.keep_messages;
1187
1187
  let cut = Math.max(0, messages2.length - keepCount);
@@ -1228,13 +1228,13 @@ ${summaryText}` }]
1228
1228
  return { compacted: true, messages: [summaryMsg, ...recentMsgs] };
1229
1229
  }
1230
1230
  var init_compact = __esm({
1231
- "packages/server/dist/agents/compact.js"() {
1231
+ "../server/dist/agents/compact.js"() {
1232
1232
  "use strict";
1233
1233
  init_config();
1234
1234
  }
1235
1235
  });
1236
1236
 
1237
- // packages/server/dist/agents/micro-compact.js
1237
+ // ../server/dist/agents/micro-compact.js
1238
1238
  function microCompactMessages(messages2, keepRecent = DEFAULT_KEEP_RECENT) {
1239
1239
  if (!messages2 || messages2.length === 0) {
1240
1240
  return { compacted: false, cleared: 0, messages: messages2 };
@@ -1282,7 +1282,7 @@ function microCompactMessages(messages2, keepRecent = DEFAULT_KEEP_RECENT) {
1282
1282
  }
1283
1283
  var MICRO_COMPACT_PLACEHOLDER, COMPACTABLE_TOOLS, DEFAULT_KEEP_RECENT;
1284
1284
  var init_micro_compact = __esm({
1285
- "packages/server/dist/agents/micro-compact.js"() {
1285
+ "../server/dist/agents/micro-compact.js"() {
1286
1286
  "use strict";
1287
1287
  MICRO_COMPACT_PLACEHOLDER = "[Old tool result content cleared]";
1288
1288
  COMPACTABLE_TOOLS = /* @__PURE__ */ new Set([
@@ -1299,10 +1299,10 @@ var init_micro_compact = __esm({
1299
1299
  }
1300
1300
  });
1301
1301
 
1302
- // packages/server/dist/agents/agent-loop.js
1302
+ // ../server/dist/agents/agent-loop.js
1303
1303
  var TOOL_ERROR_MARKER, TOOL_WARN_MARKER, MODEL_TIMEOUT_ERROR, AgentLoop;
1304
1304
  var init_agent_loop = __esm({
1305
- "packages/server/dist/agents/agent-loop.js"() {
1305
+ "../server/dist/agents/agent-loop.js"() {
1306
1306
  "use strict";
1307
1307
  init_config();
1308
1308
  TOOL_ERROR_MARKER = "__TOOL_ERROR__";
@@ -1464,7 +1464,7 @@ Error: ${err instanceof Error ? err.message : String(err)}`;
1464
1464
  }
1465
1465
  });
1466
1466
 
1467
- // packages/server/dist/prompts/md-vars.js
1467
+ // ../server/dist/prompts/md-vars.js
1468
1468
  var md_vars_exports = {};
1469
1469
  __export(md_vars_exports, {
1470
1470
  buildRenderContext: () => buildRenderContext,
@@ -1627,7 +1627,7 @@ async function buildRenderContext(opts) {
1627
1627
  }
1628
1628
  var PATTERN, ENV_PATTERN2, ARG_PATTERN, PARAM_PATH;
1629
1629
  var init_md_vars = __esm({
1630
- "packages/server/dist/prompts/md-vars.js"() {
1630
+ "../server/dist/prompts/md-vars.js"() {
1631
1631
  "use strict";
1632
1632
  PATTERN = /\{\{\s*([\w-][\w.-]*)\s*\}\}/g;
1633
1633
  ENV_PATTERN2 = /<<([A-Z_][A-Z0-9_]*)>>/g;
@@ -1636,7 +1636,7 @@ var init_md_vars = __esm({
1636
1636
  }
1637
1637
  });
1638
1638
 
1639
- // packages/server/dist/agents/agent-loader.js
1639
+ // ../server/dist/agents/agent-loader.js
1640
1640
  import fs6 from "node:fs/promises";
1641
1641
  import fsSync2 from "node:fs";
1642
1642
  import path6 from "node:path";
@@ -1919,7 +1919,7 @@ function isTeamMember(team, targetId) {
1919
1919
  }
1920
1920
  var GLOBAL_AGENTS_DIR2, GLOBAL_SKILLS_DIR2, SKILL_ID_RE, ACCESS_RANK;
1921
1921
  var init_agent_loader = __esm({
1922
- "packages/server/dist/agents/agent-loader.js"() {
1922
+ "../server/dist/agents/agent-loader.js"() {
1923
1923
  "use strict";
1924
1924
  init_agent_loop();
1925
1925
  GLOBAL_AGENTS_DIR2 = path6.join(homedir6(), ".halo", "global", "agents");
@@ -1934,7 +1934,7 @@ var init_agent_loader = __esm({
1934
1934
  }
1935
1935
  });
1936
1936
 
1937
- // packages/server/dist/ws/broadcast.js
1937
+ // ../server/dist/ws/broadcast.js
1938
1938
  import path7 from "node:path";
1939
1939
  function setBroadcastWss(wss2) {
1940
1940
  _wss = wss2;
@@ -1980,14 +1980,14 @@ function broadcastToWorkspace(workspacePath, event) {
1980
1980
  }
1981
1981
  var _wss, _workspaceOfClient;
1982
1982
  var init_broadcast = __esm({
1983
- "packages/server/dist/ws/broadcast.js"() {
1983
+ "../server/dist/ws/broadcast.js"() {
1984
1984
  "use strict";
1985
1985
  _wss = null;
1986
1986
  _workspaceOfClient = null;
1987
1987
  }
1988
1988
  });
1989
1989
 
1990
- // packages/server/dist/db/schema.js
1990
+ // ../server/dist/db/schema.js
1991
1991
  var schema_exports = {};
1992
1992
  __export(schema_exports, {
1993
1993
  agentSessions: () => agentSessions,
@@ -1996,7 +1996,7 @@ __export(schema_exports, {
1996
1996
  import { sqliteTable, text, integer } from "drizzle-orm/sqlite-core";
1997
1997
  var agentSessions, disabledItems;
1998
1998
  var init_schema = __esm({
1999
- "packages/server/dist/db/schema.js"() {
1999
+ "../server/dist/db/schema.js"() {
2000
2000
  "use strict";
2001
2001
  agentSessions = sqliteTable("agent_sessions", {
2002
2002
  id: text("id").primaryKey(),
@@ -2033,7 +2033,7 @@ var init_schema = __esm({
2033
2033
  }
2034
2034
  });
2035
2035
 
2036
- // packages/server/dist/init.js
2036
+ // ../server/dist/init.js
2037
2037
  var init_exports = {};
2038
2038
  __export(init_exports, {
2039
2039
  TEMPLATES_DIR: () => TEMPLATES_DIR,
@@ -2399,7 +2399,7 @@ function ensureWorkspaceHalo(workspaceRoot) {
2399
2399
  }
2400
2400
  var __dirname, TEMPLATES_DIR, DOCS_SRC_CANDIDATES, TEMPLATE_VERSION, VERSION_FILE, SKIP_NAMES, BUILTIN_AGENT_IDS, BUILTIN_SKILL_IDS, BUNDLED_DOCS, INSTALLED_OPTIONAL_SKILLS_FILE;
2401
2401
  var init_init = __esm({
2402
- "packages/server/dist/init.js"() {
2402
+ "../server/dist/init.js"() {
2403
2403
  "use strict";
2404
2404
  __dirname = path8.dirname(fileURLToPath(import.meta.url));
2405
2405
  TEMPLATES_DIR = path8.resolve(__dirname, "..", "templates");
@@ -2472,7 +2472,7 @@ var init_init = __esm({
2472
2472
  }
2473
2473
  });
2474
2474
 
2475
- // packages/server/dist/db/index.js
2475
+ // ../server/dist/db/index.js
2476
2476
  import Database from "better-sqlite3";
2477
2477
  import { drizzle } from "drizzle-orm/better-sqlite3";
2478
2478
  import { eq, and } from "drizzle-orm";
@@ -2561,7 +2561,7 @@ function toggleDisabled(db, itemType, itemId, scope) {
2561
2561
  }
2562
2562
  var SCHEMA_SQL_PATH, dbCache;
2563
2563
  var init_db = __esm({
2564
- "packages/server/dist/db/index.js"() {
2564
+ "../server/dist/db/index.js"() {
2565
2565
  "use strict";
2566
2566
  init_schema();
2567
2567
  init_init();
@@ -2570,7 +2570,7 @@ var init_db = __esm({
2570
2570
  }
2571
2571
  });
2572
2572
 
2573
- // packages/server/dist/agents/session-tools.js
2573
+ // ../server/dist/agents/session-tools.js
2574
2574
  async function callerTeamFor(sm, sessionId) {
2575
2575
  const callerId = sm.sessions.get(sessionId)?.agentId;
2576
2576
  if (!callerId)
@@ -2833,7 +2833,7 @@ ${skillInfo}` : ""
2833
2833
  ];
2834
2834
  }
2835
2835
  var init_session_tools = __esm({
2836
- "packages/server/dist/agents/session-tools.js"() {
2836
+ "../server/dist/agents/session-tools.js"() {
2837
2837
  "use strict";
2838
2838
  init_config();
2839
2839
  init_agent_loader();
@@ -2841,7 +2841,7 @@ var init_session_tools = __esm({
2841
2841
  }
2842
2842
  });
2843
2843
 
2844
- // packages/server/dist/sessions/session-archive.js
2844
+ // ../server/dist/sessions/session-archive.js
2845
2845
  import fsSync3 from "node:fs";
2846
2846
  import fs9 from "node:fs/promises";
2847
2847
  import path10 from "node:path";
@@ -2904,13 +2904,13 @@ async function deleteArchiveSegments(dir, seg) {
2904
2904
  }
2905
2905
  var ARCHIVE_SIZE_THRESHOLD;
2906
2906
  var init_session_archive = __esm({
2907
- "packages/server/dist/sessions/session-archive.js"() {
2907
+ "../server/dist/sessions/session-archive.js"() {
2908
2908
  "use strict";
2909
2909
  ARCHIVE_SIZE_THRESHOLD = 3 * 1024 * 1024;
2910
2910
  }
2911
2911
  });
2912
2912
 
2913
- // packages/server/dist/sessions/session-store.js
2913
+ // ../server/dist/sessions/session-store.js
2914
2914
  import fsSync4 from "node:fs";
2915
2915
  import fs10 from "node:fs/promises";
2916
2916
  import path11 from "node:path";
@@ -2953,6 +2953,9 @@ function fileSegment(sessionId) {
2953
2953
  const parts = sessionId.split(">");
2954
2954
  return parts[parts.length - 1];
2955
2955
  }
2956
+ function stripTurnStamp(s) {
2957
+ return s.replace(/^\[\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z\] ?/, "");
2958
+ }
2956
2959
  function resolveSessionPath(dir, sessionId, ext) {
2957
2960
  return path11.join(dir, `${fileSegment(sessionId)}${ext}`);
2958
2961
  }
@@ -3151,13 +3154,13 @@ function findAndUpdateSessionTitle(sessionId, title, projectPath) {
3151
3154
  return false;
3152
3155
  }
3153
3156
  var init_session_store = __esm({
3154
- "packages/server/dist/sessions/session-store.js"() {
3157
+ "../server/dist/sessions/session-store.js"() {
3155
3158
  "use strict";
3156
3159
  init_session_archive();
3157
3160
  }
3158
3161
  });
3159
3162
 
3160
- // packages/server/dist/agents/goal-mode.js
3163
+ // ../server/dist/agents/goal-mode.js
3161
3164
  import fs11 from "node:fs";
3162
3165
  import path12 from "node:path";
3163
3166
  import { createHash } from "node:crypto";
@@ -3629,7 +3632,7 @@ function sweepActiveGoals(host) {
3629
3632
  }
3630
3633
  var GOAL_AGENT_ID, DEFAULT_GOAL_CAPS, NO_PROGRESS_LIMIT, DELEGATED_DECISION_CAP, WORKER_RECENT_MAX_MESSAGES, WORKER_RECENT_MSG_CHARS, WORKER_RECENT_TOTAL_CHARS, NEED_INPUT_MARKER;
3631
3634
  var init_goal_mode = __esm({
3632
- "packages/server/dist/agents/goal-mode.js"() {
3635
+ "../server/dist/agents/goal-mode.js"() {
3633
3636
  "use strict";
3634
3637
  init_schema();
3635
3638
  init_session_store();
@@ -3650,7 +3653,7 @@ var init_goal_mode = __esm({
3650
3653
  }
3651
3654
  });
3652
3655
 
3653
- // packages/server/dist/agents/workspace-runtime-lock.js
3656
+ // ../server/dist/agents/workspace-runtime-lock.js
3654
3657
  import fs12 from "node:fs";
3655
3658
  import path13 from "node:path";
3656
3659
  function isPidAlive(pid) {
@@ -3698,13 +3701,13 @@ function claimWorkspaceRuntime(workspaceRoot) {
3698
3701
  }
3699
3702
  var RUNTIME_LOCK_FILE;
3700
3703
  var init_workspace_runtime_lock = __esm({
3701
- "packages/server/dist/agents/workspace-runtime-lock.js"() {
3704
+ "../server/dist/agents/workspace-runtime-lock.js"() {
3702
3705
  "use strict";
3703
3706
  RUNTIME_LOCK_FILE = "runtime.lock";
3704
3707
  }
3705
3708
  });
3706
3709
 
3707
- // packages/server/dist/db/evo-db.js
3710
+ // ../server/dist/db/evo-db.js
3708
3711
  import Database2 from "better-sqlite3";
3709
3712
  import { drizzle as drizzle2 } from "drizzle-orm/better-sqlite3";
3710
3713
  import { sqliteTable as sqliteTable2, text as text2, integer as integer2 } from "drizzle-orm/sqlite-core";
@@ -3728,7 +3731,7 @@ function getEvoDb() {
3728
3731
  }
3729
3732
  var evolutionRuns, evolutionApplies, CREATE_SQL, _evoDb;
3730
3733
  var init_evo_db = __esm({
3731
- "packages/server/dist/db/evo-db.js"() {
3734
+ "../server/dist/db/evo-db.js"() {
3732
3735
  "use strict";
3733
3736
  evolutionRuns = sqliteTable2("evolution_runs", {
3734
3737
  id: text2("id").primaryKey(),
@@ -3810,7 +3813,7 @@ CREATE INDEX IF NOT EXISTS idx_evo_applies_archived ON evolution_applies(archive
3810
3813
  }
3811
3814
  });
3812
3815
 
3813
- // packages/server/dist/paths.js
3816
+ // ../server/dist/paths.js
3814
3817
  import path15 from "node:path";
3815
3818
  import { homedir as homedir8 } from "node:os";
3816
3819
  function haloHome() {
@@ -3856,12 +3859,12 @@ function evoApplyLogFile(applyId) {
3856
3859
  return path15.join(evoLogsDir(), `apply-${applyId}.log`);
3857
3860
  }
3858
3861
  var init_paths = __esm({
3859
- "packages/server/dist/paths.js"() {
3862
+ "../server/dist/paths.js"() {
3860
3863
  "use strict";
3861
3864
  }
3862
3865
  });
3863
3866
 
3864
- // packages/server/dist/evolution/enqueue.js
3867
+ // ../server/dist/evolution/enqueue.js
3865
3868
  import fs14 from "node:fs";
3866
3869
  import path16 from "node:path";
3867
3870
  import { homedir as homedir9 } from "node:os";
@@ -4146,20 +4149,20 @@ function enqueueEvoRun(input) {
4146
4149
  return { ok: true, runId, runDir };
4147
4150
  }
4148
4151
  var init_enqueue = __esm({
4149
- "packages/server/dist/evolution/enqueue.js"() {
4152
+ "../server/dist/evolution/enqueue.js"() {
4150
4153
  "use strict";
4151
4154
  init_evo_db();
4152
4155
  init_paths();
4153
4156
  }
4154
4157
  });
4155
4158
 
4156
- // packages/core/dist/workspace/workspace.js
4159
+ // ../core/dist/workspace/workspace.js
4157
4160
  import { readFile, writeFile, mkdir } from "node:fs/promises";
4158
4161
  import { realpathSync } from "node:fs";
4159
4162
  import { resolve, isAbsolute, sep } from "node:path";
4160
4163
  var WorkspaceError, Workspace;
4161
4164
  var init_workspace = __esm({
4162
- "packages/core/dist/workspace/workspace.js"() {
4165
+ "../core/dist/workspace/workspace.js"() {
4163
4166
  "use strict";
4164
4167
  WorkspaceError = class extends Error {
4165
4168
  constructor(message) {
@@ -4204,13 +4207,13 @@ var init_workspace = __esm({
4204
4207
  }
4205
4208
  });
4206
4209
 
4207
- // packages/core/dist/workspace/git-manager.js
4210
+ // ../core/dist/workspace/git-manager.js
4208
4211
  import path17 from "node:path";
4209
4212
  import { promises as fs15 } from "node:fs";
4210
4213
  import simpleGit from "simple-git";
4211
4214
  var GitManagerError, GitManager;
4212
4215
  var init_git_manager = __esm({
4213
- "packages/core/dist/workspace/git-manager.js"() {
4216
+ "../core/dist/workspace/git-manager.js"() {
4214
4217
  "use strict";
4215
4218
  GitManagerError = class extends Error {
4216
4219
  constructor(message) {
@@ -4567,7 +4570,7 @@ var init_git_manager = __esm({
4567
4570
  }
4568
4571
  });
4569
4572
 
4570
- // packages/core/dist/media/mime.js
4573
+ // ../core/dist/media/mime.js
4571
4574
  function normalizeExt(ext) {
4572
4575
  const lower = ext.toLowerCase();
4573
4576
  return lower.startsWith(".") ? lower : `.${lower}`;
@@ -4580,7 +4583,7 @@ function extFromImageMime(mime) {
4580
4583
  }
4581
4584
  var PHOTO_MIME_BY_EXT, SERVE_ONLY_MIME_BY_EXT, IMAGE_MIME_BY_EXT, EXT_BY_PHOTO_MIME, IMAGE_EXTS;
4582
4585
  var init_mime = __esm({
4583
- "packages/core/dist/media/mime.js"() {
4586
+ "../core/dist/media/mime.js"() {
4584
4587
  "use strict";
4585
4588
  PHOTO_MIME_BY_EXT = {
4586
4589
  ".png": "image/png",
@@ -4604,9 +4607,9 @@ var init_mime = __esm({
4604
4607
  }
4605
4608
  });
4606
4609
 
4607
- // packages/core/dist/index.js
4610
+ // ../core/dist/index.js
4608
4611
  var init_dist = __esm({
4609
- "packages/core/dist/index.js"() {
4612
+ "../core/dist/index.js"() {
4610
4613
  "use strict";
4611
4614
  init_workspace();
4612
4615
  init_git_manager();
@@ -4614,7 +4617,7 @@ var init_dist = __esm({
4614
4617
  }
4615
4618
  });
4616
4619
 
4617
- // packages/server/dist/channels/shared/media-store.js
4620
+ // ../server/dist/channels/shared/media-store.js
4618
4621
  import fs16 from "node:fs/promises";
4619
4622
  import path18 from "node:path";
4620
4623
  import { randomBytes } from "node:crypto";
@@ -4675,7 +4678,7 @@ async function saveInboundMedia(params) {
4675
4678
  }
4676
4679
  var VISION_IMAGE_MIME_TYPES, EXT_BY_AV_MIME;
4677
4680
  var init_media_store = __esm({
4678
- "packages/server/dist/channels/shared/media-store.js"() {
4681
+ "../server/dist/channels/shared/media-store.js"() {
4679
4682
  "use strict";
4680
4683
  init_dist();
4681
4684
  VISION_IMAGE_MIME_TYPES = ["image/jpeg", "image/png", "image/gif", "image/webp"];
@@ -4692,7 +4695,7 @@ var init_media_store = __esm({
4692
4695
  }
4693
4696
  });
4694
4697
 
4695
- // packages/server/dist/sessions/ui-log-builder.js
4698
+ // ../server/dist/sessions/ui-log-builder.js
4696
4699
  import { randomUUID } from "node:crypto";
4697
4700
  function createEmptyUIState() {
4698
4701
  return {
@@ -5096,19 +5099,19 @@ function applyEvent(state, event) {
5096
5099
  }
5097
5100
  var msgCounter;
5098
5101
  var init_ui_log_builder = __esm({
5099
- "packages/server/dist/sessions/ui-log-builder.js"() {
5102
+ "../server/dist/sessions/ui-log-builder.js"() {
5100
5103
  "use strict";
5101
5104
  msgCounter = 0;
5102
5105
  }
5103
5106
  });
5104
5107
 
5105
- // packages/server/dist/agents/session-ui-store.js
5108
+ // ../server/dist/agents/session-ui-store.js
5106
5109
  import fsSync5 from "node:fs";
5107
5110
  import path19 from "node:path";
5108
5111
  import { eq as eq3 } from "drizzle-orm";
5109
5112
  var UI_STATE_IDLE_TTL_MS, UI_STATE_SWEEP_PERIOD_MS, SessionUIStore;
5110
5113
  var init_session_ui_store = __esm({
5111
- "packages/server/dist/agents/session-ui-store.js"() {
5114
+ "../server/dist/agents/session-ui-store.js"() {
5112
5115
  "use strict";
5113
5116
  init_broadcast();
5114
5117
  init_schema();
@@ -5622,11 +5625,11 @@ var init_session_ui_store = __esm({
5622
5625
  }
5623
5626
  });
5624
5627
 
5625
- // packages/server/dist/agents/session-query-store.js
5628
+ // ../server/dist/agents/session-query-store.js
5626
5629
  import { eq as eq4, and as and3, isNull as isNull2, desc, lt, gte, inArray } from "drizzle-orm";
5627
5630
  var SessionQueryStore;
5628
5631
  var init_session_query_store = __esm({
5629
- "packages/server/dist/agents/session-query-store.js"() {
5632
+ "../server/dist/agents/session-query-store.js"() {
5630
5633
  "use strict";
5631
5634
  init_schema();
5632
5635
  init_session_store();
@@ -5845,7 +5848,7 @@ var init_session_query_store = __esm({
5845
5848
  }
5846
5849
  });
5847
5850
 
5848
- // packages/server/dist/agents/bedrock-agent.js
5851
+ // ../server/dist/agents/bedrock-agent.js
5849
5852
  import { BedrockRuntimeClient, InvokeModelCommand } from "@aws-sdk/client-bedrock-runtime";
5850
5853
  function effortToBudget(effort, maxTokens) {
5851
5854
  const table = {
@@ -5867,7 +5870,7 @@ function extractRegionFromEndpoint(endpoint) {
5867
5870
  }
5868
5871
  var BedrockAgent;
5869
5872
  var init_bedrock_agent = __esm({
5870
- "packages/server/dist/agents/bedrock-agent.js"() {
5873
+ "../server/dist/agents/bedrock-agent.js"() {
5871
5874
  "use strict";
5872
5875
  init_config();
5873
5876
  init_agent_loop();
@@ -5996,7 +5999,7 @@ var init_bedrock_agent = __esm({
5996
5999
  }
5997
6000
  });
5998
6001
 
5999
- // packages/server/dist/agents/deepseek-agent.js
6002
+ // ../server/dist/agents/deepseek-agent.js
6000
6003
  function safeParse(json) {
6001
6004
  try {
6002
6005
  return JSON.parse(json || "{}");
@@ -6006,7 +6009,7 @@ function safeParse(json) {
6006
6009
  }
6007
6010
  var DeepSeekAgent;
6008
6011
  var init_deepseek_agent = __esm({
6009
- "packages/server/dist/agents/deepseek-agent.js"() {
6012
+ "../server/dist/agents/deepseek-agent.js"() {
6010
6013
  "use strict";
6011
6014
  init_config();
6012
6015
  init_agent_loop();
@@ -6186,7 +6189,7 @@ var init_deepseek_agent = __esm({
6186
6189
  }
6187
6190
  });
6188
6191
 
6189
- // packages/server/dist/agents/kimi-agent.js
6192
+ // ../server/dist/agents/kimi-agent.js
6190
6193
  function safeParse2(json) {
6191
6194
  try {
6192
6195
  return JSON.parse(json || "{}");
@@ -6196,7 +6199,7 @@ function safeParse2(json) {
6196
6199
  }
6197
6200
  var KimiAgent;
6198
6201
  var init_kimi_agent = __esm({
6199
- "packages/server/dist/agents/kimi-agent.js"() {
6202
+ "../server/dist/agents/kimi-agent.js"() {
6200
6203
  "use strict";
6201
6204
  init_config();
6202
6205
  init_agent_loop();
@@ -6392,7 +6395,7 @@ var init_kimi_agent = __esm({
6392
6395
  }
6393
6396
  });
6394
6397
 
6395
- // packages/server/dist/agents/minimax-agent.js
6398
+ // ../server/dist/agents/minimax-agent.js
6396
6399
  function effortToBudget2(effort, maxTokens) {
6397
6400
  const table = {
6398
6401
  low: 2048,
@@ -6409,7 +6412,7 @@ function effortToBudget2(effort, maxTokens) {
6409
6412
  }
6410
6413
  var MiniMaxAgent;
6411
6414
  var init_minimax_agent = __esm({
6412
- "packages/server/dist/agents/minimax-agent.js"() {
6415
+ "../server/dist/agents/minimax-agent.js"() {
6413
6416
  "use strict";
6414
6417
  init_config();
6415
6418
  init_agent_loop();
@@ -6531,7 +6534,7 @@ var init_minimax_agent = __esm({
6531
6534
  }
6532
6535
  });
6533
6536
 
6534
- // packages/server/dist/agents/qwen-agent.js
6537
+ // ../server/dist/agents/qwen-agent.js
6535
6538
  function effortToBudget3(effort, maxTokens) {
6536
6539
  const table = {
6537
6540
  low: 2048,
@@ -6548,7 +6551,7 @@ function effortToBudget3(effort, maxTokens) {
6548
6551
  }
6549
6552
  var QwenAgent;
6550
6553
  var init_qwen_agent = __esm({
6551
- "packages/server/dist/agents/qwen-agent.js"() {
6554
+ "../server/dist/agents/qwen-agent.js"() {
6552
6555
  "use strict";
6553
6556
  init_config();
6554
6557
  init_agent_loop();
@@ -6666,7 +6669,7 @@ var init_qwen_agent = __esm({
6666
6669
  }
6667
6670
  });
6668
6671
 
6669
- // packages/server/dist/agents/hunyuan-agent.js
6672
+ // ../server/dist/agents/hunyuan-agent.js
6670
6673
  function safeParse3(json) {
6671
6674
  try {
6672
6675
  return JSON.parse(json || "{}");
@@ -6676,7 +6679,7 @@ function safeParse3(json) {
6676
6679
  }
6677
6680
  var HunyuanAgent;
6678
6681
  var init_hunyuan_agent = __esm({
6679
- "packages/server/dist/agents/hunyuan-agent.js"() {
6682
+ "../server/dist/agents/hunyuan-agent.js"() {
6680
6683
  "use strict";
6681
6684
  init_config();
6682
6685
  init_agent_loop();
@@ -6847,7 +6850,7 @@ var init_hunyuan_agent = __esm({
6847
6850
  }
6848
6851
  });
6849
6852
 
6850
- // packages/server/dist/agents/doubao-agent.js
6853
+ // ../server/dist/agents/doubao-agent.js
6851
6854
  function safeParse4(json) {
6852
6855
  try {
6853
6856
  return JSON.parse(json || "{}");
@@ -6857,7 +6860,7 @@ function safeParse4(json) {
6857
6860
  }
6858
6861
  var DoubaoAgent;
6859
6862
  var init_doubao_agent = __esm({
6860
- "packages/server/dist/agents/doubao-agent.js"() {
6863
+ "../server/dist/agents/doubao-agent.js"() {
6861
6864
  "use strict";
6862
6865
  init_config();
6863
6866
  init_agent_loop();
@@ -7028,7 +7031,7 @@ var init_doubao_agent = __esm({
7028
7031
  }
7029
7032
  });
7030
7033
 
7031
- // packages/server/dist/agents/openai-agent.js
7034
+ // ../server/dist/agents/openai-agent.js
7032
7035
  function safeParse5(json) {
7033
7036
  try {
7034
7037
  return JSON.parse(json || "{}");
@@ -7038,7 +7041,7 @@ function safeParse5(json) {
7038
7041
  }
7039
7042
  var OpenAIAgent;
7040
7043
  var init_openai_agent = __esm({
7041
- "packages/server/dist/agents/openai-agent.js"() {
7044
+ "../server/dist/agents/openai-agent.js"() {
7042
7045
  "use strict";
7043
7046
  init_config();
7044
7047
  init_agent_loop();
@@ -7210,7 +7213,7 @@ var init_openai_agent = __esm({
7210
7213
  }
7211
7214
  });
7212
7215
 
7213
- // packages/server/dist/agents/mantle-agent.js
7216
+ // ../server/dist/agents/mantle-agent.js
7214
7217
  import { SignatureV4 } from "@smithy/signature-v4";
7215
7218
  import { Sha256 } from "@aws-crypto/sha256-js";
7216
7219
  import { defaultProvider } from "@aws-sdk/credential-provider-node";
@@ -7227,7 +7230,7 @@ function safeParse6(json) {
7227
7230
  }
7228
7231
  var MantleAgent;
7229
7232
  var init_mantle_agent = __esm({
7230
- "packages/server/dist/agents/mantle-agent.js"() {
7233
+ "../server/dist/agents/mantle-agent.js"() {
7231
7234
  "use strict";
7232
7235
  init_config();
7233
7236
  init_agent_loop();
@@ -7446,10 +7449,10 @@ var init_mantle_agent = __esm({
7446
7449
  }
7447
7450
  });
7448
7451
 
7449
- // packages/server/dist/agents/anthropic-agent.js
7452
+ // ../server/dist/agents/anthropic-agent.js
7450
7453
  var AnthropicAgent;
7451
7454
  var init_anthropic_agent = __esm({
7452
- "packages/server/dist/agents/anthropic-agent.js"() {
7455
+ "../server/dist/agents/anthropic-agent.js"() {
7453
7456
  "use strict";
7454
7457
  init_config();
7455
7458
  init_agent_loop();
@@ -7572,7 +7575,7 @@ var init_anthropic_agent = __esm({
7572
7575
  }
7573
7576
  });
7574
7577
 
7575
- // packages/server/dist/agents/model-runtime.js
7578
+ // ../server/dist/agents/model-runtime.js
7576
7579
  function createModelRuntime(providerId, cfg) {
7577
7580
  switch (providerId) {
7578
7581
  case "aws-bedrock-claude-invoke":
@@ -7707,7 +7710,7 @@ function createModelRuntime(providerId, cfg) {
7707
7710
  }
7708
7711
  }
7709
7712
  var init_model_runtime = __esm({
7710
- "packages/server/dist/agents/model-runtime.js"() {
7713
+ "../server/dist/agents/model-runtime.js"() {
7711
7714
  "use strict";
7712
7715
  init_bedrock_agent();
7713
7716
  init_deepseek_agent();
@@ -7722,7 +7725,7 @@ var init_model_runtime = __esm({
7722
7725
  }
7723
7726
  });
7724
7727
 
7725
- // packages/server/dist/tools/sandbox.js
7728
+ // ../server/dist/tools/sandbox.js
7726
7729
  import { exec, execFile, spawn as spawn2 } from "node:child_process";
7727
7730
  import { promisify } from "node:util";
7728
7731
  import path20 from "node:path";
@@ -8197,7 +8200,7 @@ async function sandboxReaddir(dirPath, opts) {
8197
8200
  }
8198
8201
  var execAsync, execFileAsync, HOME, HALO_HOME3, GLOBAL_DIR, KILL_GRACE_MS, _bwrapAvailable, DEFAULT_HIDDEN_DIRS, DEFAULT_HIDDEN_FILES, WORKSPACE_HIDDEN_DIRS, WORKSPACE_HIDDEN_FILES, _hiddenDirs, _hiddenFiles, _writableDirs;
8199
8202
  var init_sandbox = __esm({
8200
- "packages/server/dist/tools/sandbox.js"() {
8203
+ "../server/dist/tools/sandbox.js"() {
8201
8204
  "use strict";
8202
8205
  execAsync = promisify(exec);
8203
8206
  execFileAsync = promisify(execFile);
@@ -8246,7 +8249,7 @@ var init_sandbox = __esm({
8246
8249
  }
8247
8250
  });
8248
8251
 
8249
- // packages/server/dist/tools/workspace-tools.js
8252
+ // ../server/dist/tools/workspace-tools.js
8250
8253
  import fs17 from "node:fs/promises";
8251
8254
  import path21 from "node:path";
8252
8255
  import crypto from "node:crypto";
@@ -8963,7 +8966,7 @@ function imageDimensions(buf, mediaType) {
8963
8966
  }
8964
8967
  var SKIP_DIRS, GLOB_MAX_RESULTS, HOME2, PARAMS_PATTERN, ENV_PATTERN3;
8965
8968
  var init_workspace_tools = __esm({
8966
- "packages/server/dist/tools/workspace-tools.js"() {
8969
+ "../server/dist/tools/workspace-tools.js"() {
8967
8970
  "use strict";
8968
8971
  init_config();
8969
8972
  init_sandbox();
@@ -8979,7 +8982,7 @@ var init_workspace_tools = __esm({
8979
8982
  }
8980
8983
  });
8981
8984
 
8982
- // packages/server/dist/tools/draft-tool.js
8985
+ // ../server/dist/tools/draft-tool.js
8983
8986
  function createDraftTool() {
8984
8987
  let drafts = 0;
8985
8988
  const tool = {
@@ -9014,7 +9017,7 @@ Error: draft requires non-empty \`content\` \u2014 put your full draft answer th
9014
9017
  }
9015
9018
  var MAX_DRAFTS, REVIEW_CHECKLIST;
9016
9019
  var init_draft_tool = __esm({
9017
- "packages/server/dist/tools/draft-tool.js"() {
9020
+ "../server/dist/tools/draft-tool.js"() {
9018
9021
  "use strict";
9019
9022
  init_agent_loop();
9020
9023
  MAX_DRAFTS = 3;
@@ -9028,7 +9031,7 @@ If the draft clears all three, write the final answer now. If not, fix it (gathe
9028
9031
  }
9029
9032
  });
9030
9033
 
9031
- // packages/server/dist/prompts/system-prompts.js
9034
+ // ../server/dist/prompts/system-prompts.js
9032
9035
  import fs18 from "node:fs/promises";
9033
9036
  import path22 from "node:path";
9034
9037
  import { homedir as homedir12 } from "node:os";
@@ -9114,17 +9117,17 @@ async function loadSystemPrompts(workspaceRoot) {
9114
9117
  }
9115
9118
  var GLOBAL_PROMPTS_DIR;
9116
9119
  var init_system_prompts = __esm({
9117
- "packages/server/dist/prompts/system-prompts.js"() {
9120
+ "../server/dist/prompts/system-prompts.js"() {
9118
9121
  "use strict";
9119
9122
  GLOBAL_PROMPTS_DIR = path22.join(homedir12(), ".halo", "global", "prompts");
9120
9123
  }
9121
9124
  });
9122
9125
 
9123
- // packages/server/dist/agents/session-agent-builder.js
9126
+ // ../server/dist/agents/session-agent-builder.js
9124
9127
  import path23 from "node:path";
9125
9128
  var SessionAgentBuilder;
9126
9129
  var init_session_agent_builder = __esm({
9127
- "packages/server/dist/agents/session-agent-builder.js"() {
9130
+ "../server/dist/agents/session-agent-builder.js"() {
9128
9131
  "use strict";
9129
9132
  init_model_runtime();
9130
9133
  init_workspace_tools();
@@ -9526,10 +9529,10 @@ do delegate, say so in one line and keep going.`;
9526
9529
  }
9527
9530
  });
9528
9531
 
9529
- // packages/server/dist/commands/registry.js
9532
+ // ../server/dist/commands/registry.js
9530
9533
  var CommandRegistry;
9531
9534
  var init_registry = __esm({
9532
- "packages/server/dist/commands/registry.js"() {
9535
+ "../server/dist/commands/registry.js"() {
9533
9536
  "use strict";
9534
9537
  CommandRegistry = class {
9535
9538
  descriptors = /* @__PURE__ */ new Map();
@@ -9543,13 +9546,13 @@ var init_registry = __esm({
9543
9546
  }
9544
9547
  });
9545
9548
 
9546
- // packages/server/dist/commands/index.js
9549
+ // ../server/dist/commands/index.js
9547
9550
  function builtinCommandNames() {
9548
9551
  return commandRegistry.listDescriptors().filter((d) => d.source === "builtin").map((d) => d.name);
9549
9552
  }
9550
9553
  var commandRegistry;
9551
9554
  var init_commands = __esm({
9552
- "packages/server/dist/commands/index.js"() {
9555
+ "../server/dist/commands/index.js"() {
9553
9556
  "use strict";
9554
9557
  init_registry();
9555
9558
  commandRegistry = new CommandRegistry();
@@ -9599,7 +9602,7 @@ var init_commands = __esm({
9599
9602
  }
9600
9603
  });
9601
9604
 
9602
- // packages/server/dist/channels/shared/i18n.js
9605
+ // ../server/dist/channels/shared/i18n.js
9603
9606
  function getLang(account) {
9604
9607
  const v = account.language;
9605
9608
  return v === "en" || v === "zh" ? v : "en";
@@ -9618,7 +9621,7 @@ function t(key, lang, params) {
9618
9621
  }
9619
9622
  var messages;
9620
9623
  var init_i18n = __esm({
9621
- "packages/server/dist/channels/shared/i18n.js"() {
9624
+ "../server/dist/channels/shared/i18n.js"() {
9622
9625
  "use strict";
9623
9626
  messages = {
9624
9627
  // ── /help ──
@@ -9787,7 +9790,7 @@ var init_i18n = __esm({
9787
9790
  }
9788
9791
  });
9789
9792
 
9790
- // packages/server/dist/commands/skill-command.js
9793
+ // ../server/dist/commands/skill-command.js
9791
9794
  import fs19 from "node:fs/promises";
9792
9795
  import path24 from "node:path";
9793
9796
  async function scanDir(dir) {
@@ -9929,7 +9932,7 @@ ${body}`;
9929
9932
  }
9930
9933
  var cachedEntries;
9931
9934
  var init_skill_command = __esm({
9932
- "packages/server/dist/commands/skill-command.js"() {
9935
+ "../server/dist/commands/skill-command.js"() {
9933
9936
  "use strict";
9934
9937
  init_commands();
9935
9938
  init_agent_loader();
@@ -9940,7 +9943,7 @@ var init_skill_command = __esm({
9940
9943
  }
9941
9944
  });
9942
9945
 
9943
- // packages/server/dist/agents/session-skill-commands.js
9946
+ // ../server/dist/agents/session-skill-commands.js
9944
9947
  import { eq as eq5 } from "drizzle-orm";
9945
9948
  function commandVisibilityGate(d) {
9946
9949
  if (!d.verbs || d.verbs.length === 0)
@@ -9957,7 +9960,7 @@ function commandVisibilityGate(d) {
9957
9960
  }
9958
9961
  var VIS_RANK, SessionSkillCommands;
9959
9962
  var init_session_skill_commands = __esm({
9960
- "packages/server/dist/agents/session-skill-commands.js"() {
9963
+ "../server/dist/agents/session-skill-commands.js"() {
9961
9964
  "use strict";
9962
9965
  init_db();
9963
9966
  init_schema();
@@ -10024,12 +10027,12 @@ var init_session_skill_commands = __esm({
10024
10027
  }
10025
10028
  });
10026
10029
 
10027
- // packages/server/dist/agents/session-state-store.js
10030
+ // ../server/dist/agents/session-state-store.js
10028
10031
  import fsSync6 from "node:fs";
10029
10032
  import path25 from "node:path";
10030
10033
  var SessionStateStore;
10031
10034
  var init_session_state_store = __esm({
10032
- "packages/server/dist/agents/session-state-store.js"() {
10035
+ "../server/dist/agents/session-state-store.js"() {
10033
10036
  "use strict";
10034
10037
  init_session_store();
10035
10038
  SessionStateStore = class {
@@ -10092,7 +10095,7 @@ var init_session_state_store = __esm({
10092
10095
  }
10093
10096
  });
10094
10097
 
10095
- // packages/server/dist/agents/session-manager.js
10098
+ // ../server/dist/agents/session-manager.js
10096
10099
  import fsSync7 from "node:fs";
10097
10100
  import path26 from "node:path";
10098
10101
  import { eq as eq6, and as and4, isNull as isNull3, isNotNull as isNotNull2 } from "drizzle-orm";
@@ -10173,7 +10176,7 @@ function generateSessionId() {
10173
10176
  }
10174
10177
  var SessionManager;
10175
10178
  var init_session_manager = __esm({
10176
- "packages/server/dist/agents/session-manager.js"() {
10179
+ "../server/dist/agents/session-manager.js"() {
10177
10180
  "use strict";
10178
10181
  init_md_loader();
10179
10182
  init_config();
@@ -10790,7 +10793,7 @@ var init_session_manager = __esm({
10790
10793
  session.output += event.text ?? "";
10791
10794
  if (event.final)
10792
10795
  session.finalOutput += event.text ?? "";
10793
- this.emitEvent(session.id, { type: "stream", text: event.text, agentName, agentId, taskId });
10796
+ this.emitEvent(session.id, { type: "stream", text: event.text, final: event.final, agentName, agentId, taskId });
10794
10797
  break;
10795
10798
  }
10796
10799
  case "thinking": {
@@ -10850,6 +10853,14 @@ var init_session_manager = __esm({
10850
10853
  session.output = "";
10851
10854
  session.finalOutput = "";
10852
10855
  session.turnError = null;
10856
+ const stamp = `[${(/* @__PURE__ */ new Date()).toISOString()}]`;
10857
+ const stamped = (text5) => text5 ? `${stamp} ${text5}` : stamp;
10858
+ if (typeof message === "string") {
10859
+ message = stamped(message);
10860
+ } else {
10861
+ const i = message.findIndex((b) => b.type === "text");
10862
+ message = i === -1 ? [{ type: "text", text: stamp }, ...message] : message.map((b, j) => j === i && b.type === "text" ? { type: "text", text: stamped(b.text) } : b);
10863
+ }
10853
10864
  for (let attempt = 0; attempt < maxRetries; attempt++) {
10854
10865
  session.abortController = new AbortController();
10855
10866
  const signal = session.abortController.signal;
@@ -11946,7 +11957,7 @@ ${result.summary}`, agentName: "user", report: true, taskId });
11946
11957
  for (let i = 0; i < raw.length; i++) {
11947
11958
  if (!isRawTurnStart(raw[i]))
11948
11959
  continue;
11949
- if (stripImageMarkers(rawMessageText(raw[i])) === target) {
11960
+ if (stripImageMarkers(stripTurnStamp(rawMessageText(raw[i]))) === target) {
11950
11961
  seen++;
11951
11962
  if (seen === rank) {
11952
11963
  start = i;
@@ -12164,11 +12175,11 @@ ${q.text}` : q.text);
12164
12175
  }
12165
12176
  });
12166
12177
 
12167
- // packages/server/dist/agents/session-manager-registry.js
12178
+ // ../server/dist/agents/session-manager-registry.js
12168
12179
  import fs20 from "node:fs";
12169
12180
  var SessionManagerRegistry;
12170
12181
  var init_session_manager_registry = __esm({
12171
- "packages/server/dist/agents/session-manager-registry.js"() {
12182
+ "../server/dist/agents/session-manager-registry.js"() {
12172
12183
  "use strict";
12173
12184
  init_session_manager();
12174
12185
  init_init();
@@ -12223,7 +12234,7 @@ var init_session_manager_registry = __esm({
12223
12234
  }
12224
12235
  });
12225
12236
 
12226
- // packages/server/dist/logger.js
12237
+ // ../server/dist/logger.js
12227
12238
  import fs21 from "node:fs";
12228
12239
  import path27 from "node:path";
12229
12240
  import { homedir as homedir13 } from "node:os";
@@ -12323,7 +12334,7 @@ function initLogger() {
12323
12334
  }
12324
12335
  var LOG_FILENAME, logDir, logFile, currentSize, LEVEL_ORDER;
12325
12336
  var init_logger = __esm({
12326
- "packages/server/dist/logger.js"() {
12337
+ "../server/dist/logger.js"() {
12327
12338
  "use strict";
12328
12339
  init_config();
12329
12340
  LOG_FILENAME = "server.log";
@@ -12334,7 +12345,7 @@ var init_logger = __esm({
12334
12345
  }
12335
12346
  });
12336
12347
 
12337
- // packages/server/dist/channels/shared/commands.js
12348
+ // ../server/dist/channels/shared/commands.js
12338
12349
  import fs22 from "node:fs";
12339
12350
  import path28 from "node:path";
12340
12351
  import os from "node:os";
@@ -13060,7 +13071,7 @@ function execWsSwitch(ctx, arg) {
13060
13071
  }
13061
13072
  var ALIASES_FILE, aliasCache, CHANNEL_LIST_LIMIT, DISPATCH_COMMANDS, NOT_ROUTED, SUBCOMMAND_ROUTES, RANK;
13062
13073
  var init_commands2 = __esm({
13063
- "packages/server/dist/channels/shared/commands.js"() {
13074
+ "../server/dist/channels/shared/commands.js"() {
13064
13075
  "use strict";
13065
13076
  init_agent_loader();
13066
13077
  init_init();
@@ -13136,7 +13147,7 @@ var init_commands2 = __esm({
13136
13147
  }
13137
13148
  });
13138
13149
 
13139
- // packages/cli/src/harness.ts
13150
+ // src/harness.ts
13140
13151
  var harness_exports = {};
13141
13152
  __export(harness_exports, {
13142
13153
  createHarness: () => createHarness,
@@ -13377,7 +13388,7 @@ async function createHarness(opts) {
13377
13388
  }
13378
13389
  var SESSION_PREFIX, USER_ID;
13379
13390
  var init_harness = __esm({
13380
- "packages/cli/src/harness.ts"() {
13391
+ "src/harness.ts"() {
13381
13392
  "use strict";
13382
13393
  init_session_manager();
13383
13394
  init_session_manager_registry();
@@ -13394,7 +13405,7 @@ var init_harness = __esm({
13394
13405
  }
13395
13406
  });
13396
13407
 
13397
- // packages/server/dist/middleware/password-hash.js
13408
+ // ../server/dist/middleware/password-hash.js
13398
13409
  var password_hash_exports = {};
13399
13410
  __export(password_hash_exports, {
13400
13411
  generateJwtSecret: () => generateJwtSecret,
@@ -13444,7 +13455,7 @@ function generateJwtSecret() {
13444
13455
  }
13445
13456
  var scryptAsync, COST, KEY_LEN;
13446
13457
  var init_password_hash = __esm({
13447
- "packages/server/dist/middleware/password-hash.js"() {
13458
+ "../server/dist/middleware/password-hash.js"() {
13448
13459
  "use strict";
13449
13460
  scryptAsync = promisify2(crypto2.scrypt);
13450
13461
  COST = { N: 16384, r: 8, p: 1 };
@@ -13452,7 +13463,7 @@ var init_password_hash = __esm({
13452
13463
  }
13453
13464
  });
13454
13465
 
13455
- // packages/server/dist/setup-config.js
13466
+ // ../server/dist/setup-config.js
13456
13467
  var setup_config_exports = {};
13457
13468
  __export(setup_config_exports, {
13458
13469
  configLeafSet: () => configLeafSet,
@@ -13493,13 +13504,13 @@ function configLeafSet(dotPath) {
13493
13504
  }
13494
13505
  var CONFIG_PATH;
13495
13506
  var init_setup_config = __esm({
13496
- "packages/server/dist/setup-config.js"() {
13507
+ "../server/dist/setup-config.js"() {
13497
13508
  "use strict";
13498
13509
  CONFIG_PATH = path30.join(homedir14(), ".halo", "secrets", "config.yaml");
13499
13510
  }
13500
13511
  });
13501
13512
 
13502
- // packages/server/dist/setup-settings.js
13513
+ // ../server/dist/setup-settings.js
13503
13514
  var setup_settings_exports = {};
13504
13515
  __export(setup_settings_exports, {
13505
13516
  maskSecret: () => maskSecret,
@@ -13578,13 +13589,13 @@ function maskSecret(value) {
13578
13589
  }
13579
13590
  var SETTINGS_PATH2;
13580
13591
  var init_setup_settings = __esm({
13581
- "packages/server/dist/setup-settings.js"() {
13592
+ "../server/dist/setup-settings.js"() {
13582
13593
  "use strict";
13583
13594
  SETTINGS_PATH2 = path31.join(homedir15(), ".halo", "secrets", "settings.yaml");
13584
13595
  }
13585
13596
  });
13586
13597
 
13587
- // packages/server/dist/setup-providers.js
13598
+ // ../server/dist/setup-providers.js
13588
13599
  var setup_providers_exports = {};
13589
13600
  __export(setup_providers_exports, {
13590
13601
  AWS_CREDENTIAL_CHAIN_PROVIDER: () => AWS_CREDENTIAL_CHAIN_PROVIDER,
@@ -13790,7 +13801,7 @@ function listRequiredSkillsWithSecrets() {
13790
13801
  }
13791
13802
  var AWS_CREDENTIAL_CHAIN_PROVIDER, REBIND_BUILTIN_AGENT_IDS, GLOBAL_AGENTS_DIR3;
13792
13803
  var init_setup_providers = __esm({
13793
- "packages/server/dist/setup-providers.js"() {
13804
+ "../server/dist/setup-providers.js"() {
13794
13805
  "use strict";
13795
13806
  init_init();
13796
13807
  init_setup_settings();
@@ -13800,7 +13811,7 @@ var init_setup_providers = __esm({
13800
13811
  }
13801
13812
  });
13802
13813
 
13803
- // packages/cli/src/setup-bind-provider.ts
13814
+ // src/setup-bind-provider.ts
13804
13815
  var setup_bind_provider_exports = {};
13805
13816
  __export(setup_bind_provider_exports, {
13806
13817
  AWS_CHAIN_PROVIDER: () => AWS_CHAIN_PROVIDER,
@@ -13840,14 +13851,14 @@ function buildBindProviderPlan(configured, currentProvider, currentProviderHasKe
13840
13851
  }
13841
13852
  var AWS_CHAIN_PROVIDER, KEEP_CURRENT;
13842
13853
  var init_setup_bind_provider = __esm({
13843
- "packages/cli/src/setup-bind-provider.ts"() {
13854
+ "src/setup-bind-provider.ts"() {
13844
13855
  "use strict";
13845
13856
  AWS_CHAIN_PROVIDER = "aws-bedrock-claude-invoke";
13846
13857
  KEEP_CURRENT = "__keep__";
13847
13858
  }
13848
13859
  });
13849
13860
 
13850
- // packages/cli/src/setup-prompts.ts
13861
+ // src/setup-prompts.ts
13851
13862
  var setup_prompts_exports = {};
13852
13863
  __export(setup_prompts_exports, {
13853
13864
  promptMultiSelect: () => promptMultiSelect,
@@ -14133,12 +14144,12 @@ function promptMultiSelectRich(question, options) {
14133
14144
  });
14134
14145
  }
14135
14146
  var init_setup_prompts = __esm({
14136
- "packages/cli/src/setup-prompts.ts"() {
14147
+ "src/setup-prompts.ts"() {
14137
14148
  "use strict";
14138
14149
  }
14139
14150
  });
14140
14151
 
14141
- // packages/cli/src/upgrade-verify.ts
14152
+ // src/upgrade-verify.ts
14142
14153
  var upgrade_verify_exports = {};
14143
14154
  __export(upgrade_verify_exports, {
14144
14155
  ALLOW_SCRIPTS: () => ALLOW_SCRIPTS,
@@ -14163,7 +14174,7 @@ function verifyNativeModules(pkgRoot) {
14163
14174
  }
14164
14175
  var NATIVE_MODULE_SMOKES, ALLOW_SCRIPTS;
14165
14176
  var init_upgrade_verify = __esm({
14166
- "packages/cli/src/upgrade-verify.ts"() {
14177
+ "src/upgrade-verify.ts"() {
14167
14178
  "use strict";
14168
14179
  NATIVE_MODULE_SMOKES = [
14169
14180
  { name: "better-sqlite3", smoke: "new (require(process.argv[1]))(':memory:')" },
@@ -14173,7 +14184,7 @@ var init_upgrade_verify = __esm({
14173
14184
  }
14174
14185
  });
14175
14186
 
14176
- // packages/cli/src/render-md.ts
14187
+ // src/render-md.ts
14177
14188
  import { marked } from "marked";
14178
14189
  import { markedTerminal } from "marked-terminal";
14179
14190
  function renderMarkdown(text5) {
@@ -14181,14 +14192,14 @@ function renderMarkdown(text5) {
14181
14192
  return rendered.replace(/\n{3,}/g, "\n\n").trimEnd();
14182
14193
  }
14183
14194
  var init_render_md = __esm({
14184
- "packages/cli/src/render-md.ts"() {
14195
+ "src/render-md.ts"() {
14185
14196
  "use strict";
14186
14197
  marked.use(markedTerminal({ reflowText: true, width: Math.min(process.stdout.columns || 80, 120) }));
14187
14198
  marked.use({ breaks: true });
14188
14199
  }
14189
14200
  });
14190
14201
 
14191
- // packages/cli/src/resolve-refs.ts
14202
+ // src/resolve-refs.ts
14192
14203
  import fs28 from "node:fs";
14193
14204
  import path34 from "node:path";
14194
14205
  function resolveRefs(input, workspace) {
@@ -14267,7 +14278,7 @@ ${content}
14267
14278
  }
14268
14279
  var MAX_FILE_BYTES, MAX_IMAGE_BYTES, REF_PATTERN;
14269
14280
  var init_resolve_refs = __esm({
14270
- "packages/cli/src/resolve-refs.ts"() {
14281
+ "src/resolve-refs.ts"() {
14271
14282
  "use strict";
14272
14283
  init_dist();
14273
14284
  MAX_FILE_BYTES = 100 * 1024;
@@ -14276,7 +14287,7 @@ var init_resolve_refs = __esm({
14276
14287
  }
14277
14288
  });
14278
14289
 
14279
- // packages/cli/src/format-usage.ts
14290
+ // src/format-usage.ts
14280
14291
  function fmtK(n) {
14281
14292
  return `${(n / 1e3).toFixed(1)}K`;
14282
14293
  }
@@ -14320,7 +14331,7 @@ function formatUsageLine(event) {
14320
14331
  }
14321
14332
  var ANSI;
14322
14333
  var init_format_usage = __esm({
14323
- "packages/cli/src/format-usage.ts"() {
14334
+ "src/format-usage.ts"() {
14324
14335
  "use strict";
14325
14336
  ANSI = {
14326
14337
  reset: "\x1B[0m",
@@ -14334,7 +14345,7 @@ var init_format_usage = __esm({
14334
14345
  }
14335
14346
  });
14336
14347
 
14337
- // packages/cli/src/tui/components/banner.tsx
14348
+ // src/tui/components/banner.tsx
14338
14349
  import { Box, Text } from "ink";
14339
14350
  import { jsx } from "react/jsx-runtime";
14340
14351
  function Banner() {
@@ -14342,7 +14353,7 @@ function Banner() {
14342
14353
  }
14343
14354
  var LINES, COLORS;
14344
14355
  var init_banner = __esm({
14345
- "packages/cli/src/tui/components/banner.tsx"() {
14356
+ "src/tui/components/banner.tsx"() {
14346
14357
  "use strict";
14347
14358
  LINES = [
14348
14359
  " \u2588\u2588\u2557 \u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2588\u2557 ",
@@ -14356,7 +14367,7 @@ var init_banner = __esm({
14356
14367
  }
14357
14368
  });
14358
14369
 
14359
- // packages/cli/src/tui/components/messages.tsx
14370
+ // src/tui/components/messages.tsx
14360
14371
  import { Box as Box2, Static, Text as Text2 } from "ink";
14361
14372
  import { jsx as jsx2, jsxs } from "react/jsx-runtime";
14362
14373
  function Messages({ blocks }) {
@@ -14414,7 +14425,7 @@ function Block({ block }) {
14414
14425
  }
14415
14426
  var BANNER_ID;
14416
14427
  var init_messages = __esm({
14417
- "packages/cli/src/tui/components/messages.tsx"() {
14428
+ "src/tui/components/messages.tsx"() {
14418
14429
  "use strict";
14419
14430
  init_format_usage();
14420
14431
  init_banner();
@@ -14422,7 +14433,7 @@ var init_messages = __esm({
14422
14433
  }
14423
14434
  });
14424
14435
 
14425
- // packages/cli/src/tui/terminal-text.ts
14436
+ // src/tui/terminal-text.ts
14426
14437
  function sanitizeToolOutput(s) {
14427
14438
  return s.replace(ESCAPE_SEQ_RE, "").replace(/\r\n?/g, "\n").replace(/\t/g, " ").replace(C0_RE, "");
14428
14439
  }
@@ -14452,14 +14463,14 @@ function tailByRows(text5, cols, maxRows) {
14452
14463
  }
14453
14464
  var ESCAPE_SEQ_RE, C0_RE;
14454
14465
  var init_terminal_text = __esm({
14455
- "packages/cli/src/tui/terminal-text.ts"() {
14466
+ "src/tui/terminal-text.ts"() {
14456
14467
  "use strict";
14457
14468
  ESCAPE_SEQ_RE = /\x1b\][^\x07\n]*\x07|\x1b\[[0-9;?]*[ -/]*[@-~]|\x1b[@-Z\\-_]/g;
14458
14469
  C0_RE = /[\x00-\x09\x0b-\x1f\x7f]/g;
14459
14470
  }
14460
14471
  });
14461
14472
 
14462
- // packages/cli/src/tui/components/streaming.tsx
14473
+ // src/tui/components/streaming.tsx
14463
14474
  import { useEffect, useState } from "react";
14464
14475
  import { Box as Box3, Text as Text3, useStdout } from "ink";
14465
14476
  import Spinner from "ink-spinner";
@@ -14512,13 +14523,13 @@ function Streaming({ spinnerLabel, liveText, liveThinking, activeSubs, turnStart
14512
14523
  ] });
14513
14524
  }
14514
14525
  var init_streaming = __esm({
14515
- "packages/cli/src/tui/components/streaming.tsx"() {
14526
+ "src/tui/components/streaming.tsx"() {
14516
14527
  "use strict";
14517
14528
  init_terminal_text();
14518
14529
  }
14519
14530
  });
14520
14531
 
14521
- // packages/cli/src/tui/history.ts
14532
+ // src/tui/history.ts
14522
14533
  import fs29 from "node:fs";
14523
14534
  import path35 from "node:path";
14524
14535
  import os2 from "node:os";
@@ -14544,14 +14555,14 @@ function appendHistory(entry) {
14544
14555
  }
14545
14556
  var HISTORY_FILE, MAX_ENTRIES;
14546
14557
  var init_history = __esm({
14547
- "packages/cli/src/tui/history.ts"() {
14558
+ "src/tui/history.ts"() {
14548
14559
  "use strict";
14549
14560
  HISTORY_FILE = path35.join(os2.homedir(), ".halo", "global", "tui-history.json");
14550
14561
  MAX_ENTRIES = 100;
14551
14562
  }
14552
14563
  });
14553
14564
 
14554
- // packages/cli/src/tui/components/status-bar.tsx
14565
+ // src/tui/components/status-bar.tsx
14555
14566
  import { Box as Box4, Text as Text4 } from "ink";
14556
14567
  import { Fragment, jsx as jsx4, jsxs as jsxs3 } from "react/jsx-runtime";
14557
14568
  function shortModel(modelId) {
@@ -14587,12 +14598,12 @@ function StatusBar({ agentName, modelId, contextPercent, workspace, sessionId, v
14587
14598
  ] });
14588
14599
  }
14589
14600
  var init_status_bar = __esm({
14590
- "packages/cli/src/tui/components/status-bar.tsx"() {
14601
+ "src/tui/components/status-bar.tsx"() {
14591
14602
  "use strict";
14592
14603
  }
14593
14604
  });
14594
14605
 
14595
- // packages/cli/src/tui/components/slash-suggest.tsx
14606
+ // src/tui/components/slash-suggest.tsx
14596
14607
  import { Box as Box5, Text as Text5 } from "ink";
14597
14608
  import { jsx as jsx5, jsxs as jsxs4 } from "react/jsx-runtime";
14598
14609
  function SlashSuggest({ items, selectedIdx, maxWidth = 80 }) {
@@ -14619,12 +14630,12 @@ function SlashSuggest({ items, selectedIdx, maxWidth = 80 }) {
14619
14630
  ] });
14620
14631
  }
14621
14632
  var init_slash_suggest = __esm({
14622
- "packages/cli/src/tui/components/slash-suggest.tsx"() {
14633
+ "src/tui/components/slash-suggest.tsx"() {
14623
14634
  "use strict";
14624
14635
  }
14625
14636
  });
14626
14637
 
14627
- // packages/cli/src/tui/components/path-suggest.tsx
14638
+ // src/tui/components/path-suggest.tsx
14628
14639
  import { Box as Box6, Text as Text6 } from "ink";
14629
14640
  import { jsx as jsx6, jsxs as jsxs5 } from "react/jsx-runtime";
14630
14641
  function PathSuggest({ items, selectedIdx, cwdLabel }) {
@@ -14651,12 +14662,12 @@ function PathSuggest({ items, selectedIdx, cwdLabel }) {
14651
14662
  ] });
14652
14663
  }
14653
14664
  var init_path_suggest = __esm({
14654
- "packages/cli/src/tui/components/path-suggest.tsx"() {
14665
+ "src/tui/components/path-suggest.tsx"() {
14655
14666
  "use strict";
14656
14667
  }
14657
14668
  });
14658
14669
 
14659
- // packages/cli/src/tui/path-suggest-engine.ts
14670
+ // src/tui/path-suggest-engine.ts
14660
14671
  import fs30 from "node:fs";
14661
14672
  import path36 from "node:path";
14662
14673
  function detectActiveRef(value) {
@@ -14742,13 +14753,13 @@ function applyPathPick(value, ref, pick) {
14742
14753
  return `${before}@${kind} ${path66}`;
14743
14754
  }
14744
14755
  var init_path_suggest_engine = __esm({
14745
- "packages/cli/src/tui/path-suggest-engine.ts"() {
14756
+ "src/tui/path-suggest-engine.ts"() {
14746
14757
  "use strict";
14747
14758
  init_dist();
14748
14759
  }
14749
14760
  });
14750
14761
 
14751
- // packages/cli/src/tui/line-editor.ts
14762
+ // src/tui/line-editor.ts
14752
14763
  function toGraphemes(s) {
14753
14764
  if (s === "") return [];
14754
14765
  return [...segmenter.segment(s)].map((seg) => seg.segment);
@@ -14802,13 +14813,13 @@ function deleteToEnd(e) {
14802
14813
  }
14803
14814
  var segmenter;
14804
14815
  var init_line_editor = __esm({
14805
- "packages/cli/src/tui/line-editor.ts"() {
14816
+ "src/tui/line-editor.ts"() {
14806
14817
  "use strict";
14807
14818
  segmenter = new Intl.Segmenter();
14808
14819
  }
14809
14820
  });
14810
14821
 
14811
- // packages/cli/src/tui/components/text-input.tsx
14822
+ // src/tui/components/text-input.tsx
14812
14823
  import { Text as Text7 } from "ink";
14813
14824
  import { jsx as jsx7, jsxs as jsxs6 } from "react/jsx-runtime";
14814
14825
  function TextInputView({ value, cursor, placeholder }) {
@@ -14833,13 +14844,13 @@ function TextInputView({ value, cursor, placeholder }) {
14833
14844
  ] });
14834
14845
  }
14835
14846
  var init_text_input = __esm({
14836
- "packages/cli/src/tui/components/text-input.tsx"() {
14847
+ "src/tui/components/text-input.tsx"() {
14837
14848
  "use strict";
14838
14849
  init_line_editor();
14839
14850
  }
14840
14851
  });
14841
14852
 
14842
- // packages/cli/src/tui/components/input-box.tsx
14853
+ // src/tui/components/input-box.tsx
14843
14854
  import { useState as useState2, useEffect as useEffect2, useMemo, useRef } from "react";
14844
14855
  import { Box as Box7, Text as Text8, useInput, usePaste } from "ink";
14845
14856
  import { jsx as jsx8, jsxs as jsxs7 } from "react/jsx-runtime";
@@ -15090,7 +15101,7 @@ function InputBox({ enabled, placeholder, history, onSubmit, hint, commands = []
15090
15101
  ] });
15091
15102
  }
15092
15103
  var init_input_box = __esm({
15093
- "packages/cli/src/tui/components/input-box.tsx"() {
15104
+ "src/tui/components/input-box.tsx"() {
15094
15105
  "use strict";
15095
15106
  init_slash_suggest();
15096
15107
  init_path_suggest();
@@ -15100,7 +15111,7 @@ var init_input_box = __esm({
15100
15111
  }
15101
15112
  });
15102
15113
 
15103
- // packages/cli/src/tui/components/log-navigator.tsx
15114
+ // src/tui/components/log-navigator.tsx
15104
15115
  import { useState as useState3, useMemo as useMemo2, useEffect as useEffect3 } from "react";
15105
15116
  import { Box as Box8, Text as Text9, useInput as useInput2 } from "ink";
15106
15117
  import { jsx as jsx9, jsxs as jsxs8 } from "react/jsx-runtime";
@@ -15179,12 +15190,12 @@ function LogNavigator({ tree, onPick, onCancel }) {
15179
15190
  ] });
15180
15191
  }
15181
15192
  var init_log_navigator = __esm({
15182
- "packages/cli/src/tui/components/log-navigator.tsx"() {
15193
+ "src/tui/components/log-navigator.tsx"() {
15183
15194
  "use strict";
15184
15195
  }
15185
15196
  });
15186
15197
 
15187
- // packages/cli/src/tui/components/log-viewer.tsx
15198
+ // src/tui/components/log-viewer.tsx
15188
15199
  import { useState as useState4, useMemo as useMemo3, useEffect as useEffect4, useRef as useRef2 } from "react";
15189
15200
  import { Box as Box9, Text as Text10, useInput as useInput3, useStdout as useStdout2 } from "ink";
15190
15201
  import { jsx as jsx10, jsxs as jsxs9 } from "react/jsx-runtime";
@@ -15257,12 +15268,12 @@ function LogViewer({ title, lines, live, onClose }) {
15257
15268
  ] });
15258
15269
  }
15259
15270
  var init_log_viewer = __esm({
15260
- "packages/cli/src/tui/components/log-viewer.tsx"() {
15271
+ "src/tui/components/log-viewer.tsx"() {
15261
15272
  "use strict";
15262
15273
  }
15263
15274
  });
15264
15275
 
15265
- // packages/cli/src/tui/app.tsx
15276
+ // src/tui/app.tsx
15266
15277
  import { useEffect as useEffect5, useMemo as useMemo4, useReducer, useState as useState5, useRef as useRef3 } from "react";
15267
15278
  import { Box as Box10, useApp, useInput as useInput4 } from "ink";
15268
15279
  import { jsx as jsx11, jsxs as jsxs10 } from "react/jsx-runtime";
@@ -15972,7 +15983,7 @@ ${lines.join("\n")}` });
15972
15983
  }
15973
15984
  var MAX_CONTEXT_TOKENS_FALLBACK, blockSeq, ANSI2;
15974
15985
  var init_app = __esm({
15975
- "packages/cli/src/tui/app.tsx"() {
15986
+ "src/tui/app.tsx"() {
15976
15987
  "use strict";
15977
15988
  init_render_md();
15978
15989
  init_resolve_refs();
@@ -16000,7 +16011,7 @@ var init_app = __esm({
16000
16011
  }
16001
16012
  });
16002
16013
 
16003
- // packages/cli/src/tui.tsx
16014
+ // src/tui.tsx
16004
16015
  var tui_exports = {};
16005
16016
  __export(tui_exports, {
16006
16017
  runTui: () => runTui
@@ -16015,13 +16026,13 @@ async function runTui(harness, opts = {}) {
16015
16026
  await instance.waitUntilExit();
16016
16027
  }
16017
16028
  var init_tui = __esm({
16018
- "packages/cli/src/tui.tsx"() {
16029
+ "src/tui.tsx"() {
16019
16030
  "use strict";
16020
16031
  init_app();
16021
16032
  }
16022
16033
  });
16023
16034
 
16024
- // packages/cli/src/cli.ts
16035
+ // src/cli.ts
16025
16036
  var cli_exports = {};
16026
16037
  __export(cli_exports, {
16027
16038
  runCli: () => runCli
@@ -16051,12 +16062,12 @@ async function runCli(harness, message, opts) {
16051
16062
  }
16052
16063
  const resolvedMessage = ref.text;
16053
16064
  const resolvedImages = ref.images.length > 0 ? ref.images : void 0;
16054
- const chunks = [];
16065
+ let turnFinal = "";
16066
+ let turnAll = "";
16055
16067
  const toolCalls = [];
16056
16068
  let errorText = "";
16057
16069
  let usage = null;
16058
16070
  let lastToolName = "";
16059
- let hadOutput = false;
16060
16071
  let hadMeta = false;
16061
16072
  const agentNames = /* @__PURE__ */ new Map();
16062
16073
  let spinnerTimer = null;
@@ -16111,16 +16122,20 @@ async function runCli(harness, message, opts) {
16111
16122
  process.stderr.write("\n");
16112
16123
  hadMeta = false;
16113
16124
  }
16114
- if (event.taskId) {
16115
- if (opts.verbose) process.stderr.write(`${tag}\x1B[2m${event.text}\x1B[0m
16125
+ if (opts.verbose) process.stderr.write(`${tag}\x1B[2m${event.text}\x1B[0m
16116
16126
  `);
16117
- } else {
16118
- if (opts.format === "text") process.stdout.write(renderMarkdown(event.text) + "\n");
16119
- chunks.push(event.text);
16120
- hadOutput = true;
16127
+ if (!event.taskId) {
16128
+ turnAll += event.text;
16129
+ if (event.final) turnFinal += event.text;
16121
16130
  }
16122
16131
  }
16123
16132
  break;
16133
+ case "queued_message":
16134
+ if (!event.taskId) {
16135
+ turnFinal = "";
16136
+ turnAll = "";
16137
+ }
16138
+ break;
16124
16139
  case "thinking":
16125
16140
  if (opts.verbose && event.text) {
16126
16141
  stopSpinner();
@@ -16158,10 +16173,6 @@ async function runCli(harness, message, opts) {
16158
16173
  usage = event;
16159
16174
  if (opts.verbose) {
16160
16175
  stopSpinner();
16161
- if (hadOutput) {
16162
- process.stdout.write("\n");
16163
- hadOutput = false;
16164
- }
16165
16176
  process.stderr.write(`
16166
16177
  ${tag}${formatUsageLine(event)}
16167
16178
  `);
@@ -16181,13 +16192,15 @@ ${tag}${formatUsageLine(event)}
16181
16192
  }
16182
16193
  }
16183
16194
  stopSpinner();
16195
+ const answer = turnFinal || turnAll;
16184
16196
  if (opts.format === "text") {
16185
- if (chunks.length > 0 && !chunks[chunks.length - 1].endsWith("\n")) {
16186
- process.stdout.write("\n");
16197
+ if (answer) {
16198
+ const out = process.stdout.isTTY ? renderMarkdown(answer) : answer;
16199
+ process.stdout.write(out.endsWith("\n") ? out : out + "\n");
16187
16200
  }
16188
16201
  } else {
16189
16202
  const result = {
16190
- text: chunks.join(""),
16203
+ text: answer,
16191
16204
  sessionId: harness.sessionId,
16192
16205
  toolCalls,
16193
16206
  usage: usage ? {
@@ -16203,7 +16216,7 @@ ${tag}${formatUsageLine(event)}
16203
16216
  return errorText ? 1 : 0;
16204
16217
  }
16205
16218
  var init_cli = __esm({
16206
- "packages/cli/src/cli.ts"() {
16219
+ "src/cli.ts"() {
16207
16220
  "use strict";
16208
16221
  init_render_md();
16209
16222
  init_resolve_refs();
@@ -16211,7 +16224,7 @@ var init_cli = __esm({
16211
16224
  }
16212
16225
  });
16213
16226
 
16214
- // packages/server/dist/channels/shared/media.js
16227
+ // ../server/dist/channels/shared/media.js
16215
16228
  import path37 from "node:path";
16216
16229
  import os3 from "node:os";
16217
16230
  function tempDir() {
@@ -16252,7 +16265,7 @@ function classifyMedia(filePath) {
16252
16265
  }
16253
16266
  var MEDIA_MARKER_RE, VIDEO_EXTS, VOICE_EXTS;
16254
16267
  var init_media = __esm({
16255
- "packages/server/dist/channels/shared/media.js"() {
16268
+ "../server/dist/channels/shared/media.js"() {
16256
16269
  "use strict";
16257
16270
  init_dist();
16258
16271
  MEDIA_MARKER_RE = /^MEDIA:\s*(\S.*?)\s*$/gm;
@@ -16261,7 +16274,7 @@ var init_media = __esm({
16261
16274
  }
16262
16275
  });
16263
16276
 
16264
- // packages/server/dist/routes/workspace-path.js
16277
+ // ../server/dist/routes/workspace-path.js
16265
16278
  import fs31 from "node:fs/promises";
16266
16279
  import { existsSync as existsSync2, realpathSync as realpathSync3 } from "node:fs";
16267
16280
  import path38 from "node:path";
@@ -16305,12 +16318,12 @@ function isSafeIdSegment(id) {
16305
16318
  return /^[\w.:>\u4e00-\u9fff-]+$/.test(id);
16306
16319
  }
16307
16320
  var init_workspace_path = __esm({
16308
- "packages/server/dist/routes/workspace-path.js"() {
16321
+ "../server/dist/routes/workspace-path.js"() {
16309
16322
  "use strict";
16310
16323
  }
16311
16324
  });
16312
16325
 
16313
- // packages/server/dist/routes/files.js
16326
+ // ../server/dist/routes/files.js
16314
16327
  import { Hono } from "hono";
16315
16328
  import fs32 from "node:fs/promises";
16316
16329
  import { createReadStream } from "node:fs";
@@ -16850,7 +16863,7 @@ function createFileRoutes() {
16850
16863
  return app2;
16851
16864
  }
16852
16865
  var init_files = __esm({
16853
- "packages/server/dist/routes/files.js"() {
16866
+ "../server/dist/routes/files.js"() {
16854
16867
  "use strict";
16855
16868
  init_dist();
16856
16869
  init_media();
@@ -16858,7 +16871,7 @@ var init_files = __esm({
16858
16871
  }
16859
16872
  });
16860
16873
 
16861
- // packages/server/dist/routes/data-preview.js
16874
+ // ../server/dist/routes/data-preview.js
16862
16875
  import { Hono as Hono2 } from "hono";
16863
16876
  import fs33 from "node:fs/promises";
16864
16877
  import { createReadStream as createReadStream2 } from "node:fs";
@@ -17083,7 +17096,7 @@ function createDataPreviewRoutes() {
17083
17096
  }
17084
17097
  var DEFAULT_LIMIT, MAX_LIMIT, MAX_ROW_CHARS, QUOTE, CR, LF, COMMA, SEMI, TAB, CsvScanner;
17085
17098
  var init_data_preview = __esm({
17086
- "packages/server/dist/routes/data-preview.js"() {
17099
+ "../server/dist/routes/data-preview.js"() {
17087
17100
  "use strict";
17088
17101
  init_workspace_path();
17089
17102
  DEFAULT_LIMIT = 100;
@@ -17184,7 +17197,7 @@ var init_data_preview = __esm({
17184
17197
  }
17185
17198
  });
17186
17199
 
17187
- // packages/server/dist/git-credentials.js
17200
+ // ../server/dist/git-credentials.js
17188
17201
  import fs34 from "node:fs";
17189
17202
  import path41 from "node:path";
17190
17203
  import { homedir as homedir18 } from "node:os";
@@ -17259,13 +17272,13 @@ function deleteGitCredential(host) {
17259
17272
  }
17260
17273
  var GIT_CREDENTIALS_PATH;
17261
17274
  var init_git_credentials = __esm({
17262
- "packages/server/dist/git-credentials.js"() {
17275
+ "../server/dist/git-credentials.js"() {
17263
17276
  "use strict";
17264
17277
  GIT_CREDENTIALS_PATH = path41.join(homedir18(), ".git-credentials");
17265
17278
  }
17266
17279
  });
17267
17280
 
17268
- // packages/server/dist/git-ssh.js
17281
+ // ../server/dist/git-ssh.js
17269
17282
  import fs35 from "node:fs";
17270
17283
  import os4 from "node:os";
17271
17284
  import path42 from "node:path";
@@ -17442,7 +17455,7 @@ function getRemoteProtocol(projectRoot) {
17442
17455
  }
17443
17456
  var SSH_DIR, NON_KEY_NAMES, ownedAgentPid, ASKPASS_SCRIPT;
17444
17457
  var init_git_ssh = __esm({
17445
- "packages/server/dist/git-ssh.js"() {
17458
+ "../server/dist/git-ssh.js"() {
17446
17459
  "use strict";
17447
17460
  SSH_DIR = path42.join(os4.homedir(), ".ssh");
17448
17461
  NON_KEY_NAMES = /* @__PURE__ */ new Set(["known_hosts", "known_hosts2", "authorized_keys", "config"]);
@@ -17455,7 +17468,7 @@ printf '%s\\n' "$HALO_SSH_PASSPHRASE"
17455
17468
  }
17456
17469
  });
17457
17470
 
17458
- // packages/server/dist/routes/git.js
17471
+ // ../server/dist/routes/git.js
17459
17472
  import { Hono as Hono3 } from "hono";
17460
17473
  import os5 from "node:os";
17461
17474
  import path43 from "node:path";
@@ -17821,7 +17834,7 @@ function createGitRoutes() {
17821
17834
  return app2;
17822
17835
  }
17823
17836
  var init_git = __esm({
17824
- "packages/server/dist/routes/git.js"() {
17837
+ "../server/dist/routes/git.js"() {
17825
17838
  "use strict";
17826
17839
  init_dist();
17827
17840
  init_workspace_path();
@@ -17831,7 +17844,7 @@ var init_git = __esm({
17831
17844
  }
17832
17845
  });
17833
17846
 
17834
- // packages/server/dist/routes/mtime-cache.js
17847
+ // ../server/dist/routes/mtime-cache.js
17835
17848
  function createMtimeCache() {
17836
17849
  const entries = /* @__PURE__ */ new Map();
17837
17850
  return {
@@ -17846,12 +17859,12 @@ function createMtimeCache() {
17846
17859
  };
17847
17860
  }
17848
17861
  var init_mtime_cache = __esm({
17849
- "packages/server/dist/routes/mtime-cache.js"() {
17862
+ "../server/dist/routes/mtime-cache.js"() {
17850
17863
  "use strict";
17851
17864
  }
17852
17865
  });
17853
17866
 
17854
- // packages/server/dist/routes/agent-configs.js
17867
+ // ../server/dist/routes/agent-configs.js
17855
17868
  import { Hono as Hono4 } from "hono";
17856
17869
  import fs36 from "node:fs/promises";
17857
17870
  import path44 from "node:path";
@@ -18366,7 +18379,7 @@ ${body.description ?? ""}
18366
18379
  }
18367
18380
  var _cachedTools, GLOBAL_AGENTS_DIR4, FALLBACK_SCAFFOLD_PROVIDER, _yamlCache;
18368
18381
  var init_agent_configs = __esm({
18369
- "packages/server/dist/routes/agent-configs.js"() {
18382
+ "../server/dist/routes/agent-configs.js"() {
18370
18383
  "use strict";
18371
18384
  init_workspace_tools();
18372
18385
  init_draft_tool();
@@ -18382,7 +18395,7 @@ var init_agent_configs = __esm({
18382
18395
  }
18383
18396
  });
18384
18397
 
18385
- // packages/server/dist/routes/skills.js
18398
+ // ../server/dist/routes/skills.js
18386
18399
  import { Hono as Hono5 } from "hono";
18387
18400
  import fs37 from "node:fs/promises";
18388
18401
  import path45 from "node:path";
@@ -18577,7 +18590,7 @@ function createSkillRoutes() {
18577
18590
  }
18578
18591
  var GLOBAL_SETTINGS_PATH, _skillMdCache;
18579
18592
  var init_skills = __esm({
18580
- "packages/server/dist/routes/skills.js"() {
18593
+ "../server/dist/routes/skills.js"() {
18581
18594
  "use strict";
18582
18595
  init_agent_loader();
18583
18596
  init_db();
@@ -18588,7 +18601,7 @@ var init_skills = __esm({
18588
18601
  }
18589
18602
  });
18590
18603
 
18591
- // packages/server/dist/routes/settings.js
18604
+ // ../server/dist/routes/settings.js
18592
18605
  import { Hono as Hono6 } from "hono";
18593
18606
  import fs38 from "node:fs/promises";
18594
18607
  import path46 from "node:path";
@@ -18857,7 +18870,7 @@ function createSettingsRoutes() {
18857
18870
  }
18858
18871
  var GLOBAL_SETTINGS_PATH2, _changeListeners;
18859
18872
  var init_settings = __esm({
18860
- "packages/server/dist/routes/settings.js"() {
18873
+ "../server/dist/routes/settings.js"() {
18861
18874
  "use strict";
18862
18875
  init_settings_schema();
18863
18876
  init_workspace_path();
@@ -18866,7 +18879,7 @@ var init_settings = __esm({
18866
18879
  }
18867
18880
  });
18868
18881
 
18869
- // packages/server/dist/evolution/archive.js
18882
+ // ../server/dist/evolution/archive.js
18870
18883
  import fs39 from "node:fs";
18871
18884
  import path47 from "node:path";
18872
18885
  import { pipeline } from "node:stream/promises";
@@ -19033,7 +19046,7 @@ function stopArchiveDaemon() {
19033
19046
  }
19034
19047
  var TERMINAL_RUN_STATUSES, TERMINAL_APPLY_STATUSES, DAY_MS, ARCHIVE_AFTER_MS, PURGE_AFTER_MS, _archiveTimer, _startupTimer;
19035
19048
  var init_archive = __esm({
19036
- "packages/server/dist/evolution/archive.js"() {
19049
+ "../server/dist/evolution/archive.js"() {
19037
19050
  "use strict";
19038
19051
  init_evo_db();
19039
19052
  init_paths();
@@ -19047,7 +19060,7 @@ var init_archive = __esm({
19047
19060
  }
19048
19061
  });
19049
19062
 
19050
- // packages/server/dist/db/raw-sqlite.js
19063
+ // ../server/dist/db/raw-sqlite.js
19051
19064
  function rawSqlite(db) {
19052
19065
  const withClient = db;
19053
19066
  const client = withClient.$client ?? withClient.session?.client;
@@ -19056,12 +19069,12 @@ function rawSqlite(db) {
19056
19069
  return client;
19057
19070
  }
19058
19071
  var init_raw_sqlite = __esm({
19059
- "packages/server/dist/db/raw-sqlite.js"() {
19072
+ "../server/dist/db/raw-sqlite.js"() {
19060
19073
  "use strict";
19061
19074
  }
19062
19075
  });
19063
19076
 
19064
- // packages/server/dist/routes/evolution.js
19077
+ // ../server/dist/routes/evolution.js
19065
19078
  import { Hono as Hono7 } from "hono";
19066
19079
  import { eq as eq8, desc as desc2, lt as lt3, and as and6, or, sql } from "drizzle-orm";
19067
19080
  import fs40 from "node:fs/promises";
@@ -19319,7 +19332,7 @@ function extractText(content) {
19319
19332
  }
19320
19333
  var UNDELETABLE_RUN_STATUSES;
19321
19334
  var init_evolution = __esm({
19322
- "packages/server/dist/routes/evolution.js"() {
19335
+ "../server/dist/routes/evolution.js"() {
19323
19336
  "use strict";
19324
19337
  init_evo_db();
19325
19338
  init_archive();
@@ -19330,7 +19343,7 @@ var init_evolution = __esm({
19330
19343
  }
19331
19344
  });
19332
19345
 
19333
- // packages/server/dist/routes/sessions.js
19346
+ // ../server/dist/routes/sessions.js
19334
19347
  import { Hono as Hono8 } from "hono";
19335
19348
  import { eq as eq9 } from "drizzle-orm";
19336
19349
  function rawId() {
@@ -19376,7 +19389,7 @@ function convertRawMessages(raw, agentName) {
19376
19389
  const texts = [];
19377
19390
  for (const block of blocks) {
19378
19391
  if (block.text && !block.toolResult && block.type !== "tool_result") {
19379
- const text5 = block.text.replace(/^\[Session [^\]]+\]\s*\n*/i, "").replace(/^\[(?:Message|Report) from [^\]]+\]\s*\n*/i, "").trim();
19392
+ const text5 = stripTurnStamp(block.text).replace(/^\[Session [^\]]+\]\s*\n*/i, "").replace(/^\[(?:Message|Report) from [^\]]+\]\s*\n*/i, "").trim();
19380
19393
  if (text5)
19381
19394
  texts.push(text5);
19382
19395
  }
@@ -19587,7 +19600,7 @@ function createSessionRoutes(smRegistry) {
19587
19600
  }
19588
19601
  var msgCounter2;
19589
19602
  var init_sessions = __esm({
19590
- "packages/server/dist/routes/sessions.js"() {
19603
+ "../server/dist/routes/sessions.js"() {
19591
19604
  "use strict";
19592
19605
  init_db();
19593
19606
  init_schema();
@@ -19598,7 +19611,7 @@ var init_sessions = __esm({
19598
19611
  }
19599
19612
  });
19600
19613
 
19601
- // packages/server/dist/routes/session-archive.js
19614
+ // ../server/dist/routes/session-archive.js
19602
19615
  import { Hono as Hono9 } from "hono";
19603
19616
  function createSessionArchiveRoutes(smRegistry) {
19604
19617
  const app2 = new Hono9();
@@ -19631,7 +19644,7 @@ function createSessionArchiveRoutes(smRegistry) {
19631
19644
  return app2;
19632
19645
  }
19633
19646
  var init_session_archive2 = __esm({
19634
- "packages/server/dist/routes/session-archive.js"() {
19647
+ "../server/dist/routes/session-archive.js"() {
19635
19648
  "use strict";
19636
19649
  init_db();
19637
19650
  init_session_store();
@@ -19640,7 +19653,7 @@ var init_session_archive2 = __esm({
19640
19653
  }
19641
19654
  });
19642
19655
 
19643
- // packages/server/dist/db/channel-db.js
19656
+ // ../server/dist/db/channel-db.js
19644
19657
  import Database4 from "better-sqlite3";
19645
19658
  import { drizzle as drizzle3 } from "drizzle-orm/better-sqlite3";
19646
19659
  import { sqliteTable as sqliteTable3, text as text3, integer as integer3 } from "drizzle-orm/sqlite-core";
@@ -19665,7 +19678,7 @@ function getChannelDb() {
19665
19678
  }
19666
19679
  var channelAccounts, CREATE_SQL2, _channelDb;
19667
19680
  var init_channel_db = __esm({
19668
- "packages/server/dist/db/channel-db.js"() {
19681
+ "../server/dist/db/channel-db.js"() {
19669
19682
  "use strict";
19670
19683
  channelAccounts = sqliteTable3("channel_accounts", {
19671
19684
  accountId: text3("account_id").primaryKey(),
@@ -19698,7 +19711,7 @@ CREATE INDEX IF NOT EXISTS idx_channel_accounts_type ON channel_accounts(channel
19698
19711
  }
19699
19712
  });
19700
19713
 
19701
- // packages/server/dist/channels/shared/accounts.js
19714
+ // ../server/dist/channels/shared/accounts.js
19702
19715
  import fs42 from "node:fs";
19703
19716
  import path50 from "node:path";
19704
19717
  import { eq as eq10, and as and7 } from "drizzle-orm";
@@ -19806,7 +19819,7 @@ function deleteAccount(db, accountId) {
19806
19819
  }
19807
19820
  var ACCOUNT_ACCESS_LEVELS, CHAT_ACCESS_LEVELS, _lastActiveChatCache;
19808
19821
  var init_accounts = __esm({
19809
- "packages/server/dist/channels/shared/accounts.js"() {
19822
+ "../server/dist/channels/shared/accounts.js"() {
19810
19823
  "use strict";
19811
19824
  init_channel_db();
19812
19825
  init_init();
@@ -19816,7 +19829,7 @@ var init_accounts = __esm({
19816
19829
  }
19817
19830
  });
19818
19831
 
19819
- // packages/server/dist/channels/web/accounts.js
19832
+ // ../server/dist/channels/web/accounts.js
19820
19833
  function toWeb(a) {
19821
19834
  const c = a.config;
19822
19835
  return {
@@ -19879,14 +19892,14 @@ function deleteAccount2(db, accountId) {
19879
19892
  }
19880
19893
  var CH;
19881
19894
  var init_accounts2 = __esm({
19882
- "packages/server/dist/channels/web/accounts.js"() {
19895
+ "../server/dist/channels/web/accounts.js"() {
19883
19896
  "use strict";
19884
19897
  init_accounts();
19885
19898
  CH = "web";
19886
19899
  }
19887
19900
  });
19888
19901
 
19889
- // packages/server/dist/middleware/brute-force.js
19902
+ // ../server/dist/middleware/brute-force.js
19890
19903
  import { getConnInfo } from "@hono/node-server/conninfo";
19891
19904
  function bucket(name) {
19892
19905
  let b = buckets.get(name);
@@ -19937,7 +19950,7 @@ function clearFailures(bucketName, ip) {
19937
19950
  }
19938
19951
  var MAX_ATTEMPTS, LOCKOUT_MS, buckets;
19939
19952
  var init_brute_force = __esm({
19940
- "packages/server/dist/middleware/brute-force.js"() {
19953
+ "../server/dist/middleware/brute-force.js"() {
19941
19954
  "use strict";
19942
19955
  init_config();
19943
19956
  MAX_ATTEMPTS = 5;
@@ -19946,7 +19959,7 @@ var init_brute_force = __esm({
19946
19959
  }
19947
19960
  });
19948
19961
 
19949
- // packages/server/dist/middleware/web-token.js
19962
+ // ../server/dist/middleware/web-token.js
19950
19963
  function resolveTokenAuth(c, db) {
19951
19964
  const ip = getClientIp(c);
19952
19965
  if (isLockedOut(TOKEN_BUCKET, ip))
@@ -19968,7 +19981,7 @@ function tokenAuthJsonError(c, reason) {
19968
19981
  }
19969
19982
  var TOKEN_BUCKET, TOKEN_AUTH_STATUS, JSON_ERROR;
19970
19983
  var init_web_token = __esm({
19971
- "packages/server/dist/middleware/web-token.js"() {
19984
+ "../server/dist/middleware/web-token.js"() {
19972
19985
  "use strict";
19973
19986
  init_accounts2();
19974
19987
  init_brute_force();
@@ -19986,7 +19999,7 @@ var init_web_token = __esm({
19986
19999
  }
19987
20000
  });
19988
20001
 
19989
- // packages/server/dist/sessions/session-types.js
20002
+ // ../server/dist/sessions/session-types.js
19990
20003
  function messageToolCalls(msg) {
19991
20004
  if (msg.contentBlocks) {
19992
20005
  return msg.contentBlocks.filter((b) => b.type === "tool_call").map((b) => b.toolCall);
@@ -20011,12 +20024,12 @@ function inferMessageType(msg) {
20011
20024
  return "notification";
20012
20025
  }
20013
20026
  var init_session_types = __esm({
20014
- "packages/server/dist/sessions/session-types.js"() {
20027
+ "../server/dist/sessions/session-types.js"() {
20015
20028
  "use strict";
20016
20029
  }
20017
20030
  });
20018
20031
 
20019
- // packages/server/dist/routes/halo-city.js
20032
+ // ../server/dist/routes/halo-city.js
20020
20033
  import { Hono as Hono10 } from "hono";
20021
20034
  import fs43 from "node:fs";
20022
20035
  import path51 from "node:path";
@@ -20403,7 +20416,7 @@ function createShowRoutes(registry2) {
20403
20416
  }
20404
20417
  var SESSIONS_PER_WS, _skillCache, _metaCache, _roReaders, SESSION_LOG_MAX_MSGS, _birthCache;
20405
20418
  var init_halo_city = __esm({
20406
- "packages/server/dist/routes/halo-city.js"() {
20419
+ "../server/dist/routes/halo-city.js"() {
20407
20420
  "use strict";
20408
20421
  init_channel_db();
20409
20422
  init_web_token();
@@ -20420,7 +20433,7 @@ var init_halo_city = __esm({
20420
20433
  }
20421
20434
  });
20422
20435
 
20423
- // packages/server/dist/routes/metrics.js
20436
+ // ../server/dist/routes/metrics.js
20424
20437
  import { Hono as Hono11 } from "hono";
20425
20438
  function family(name, type, help, samples) {
20426
20439
  const lines = [`# HELP ${name} ${help}`, `# TYPE ${name} ${type}`];
@@ -20499,7 +20512,7 @@ function createMetricsRoutes(registry2) {
20499
20512
  }
20500
20513
  var TEXT_ERROR, SESSIONS_PER_WS2;
20501
20514
  var init_metrics = __esm({
20502
- "packages/server/dist/routes/metrics.js"() {
20515
+ "../server/dist/routes/metrics.js"() {
20503
20516
  "use strict";
20504
20517
  init_channel_db();
20505
20518
  init_web_token();
@@ -20513,7 +20526,7 @@ var init_metrics = __esm({
20513
20526
  }
20514
20527
  });
20515
20528
 
20516
- // packages/server/dist/routes/commands.js
20529
+ // ../server/dist/routes/commands.js
20517
20530
  import { Hono as Hono12 } from "hono";
20518
20531
  function createCommandRoutes(registry2, smRegistry) {
20519
20532
  const app2 = new Hono12();
@@ -20538,12 +20551,12 @@ function createCommandRoutes(registry2, smRegistry) {
20538
20551
  return app2;
20539
20552
  }
20540
20553
  var init_commands3 = __esm({
20541
- "packages/server/dist/routes/commands.js"() {
20554
+ "../server/dist/routes/commands.js"() {
20542
20555
  "use strict";
20543
20556
  }
20544
20557
  });
20545
20558
 
20546
- // packages/server/dist/routes/agentcore.js
20559
+ // ../server/dist/routes/agentcore.js
20547
20560
  import { Hono as Hono13 } from "hono";
20548
20561
  import path52 from "node:path";
20549
20562
  import fs44 from "node:fs";
@@ -20892,7 +20905,7 @@ ${fullText}`, images.length > 0 ? images : void 0);
20892
20905
  }
20893
20906
  var SESSION_HEADER, MAX_IMAGES_PER_MESSAGE, MAX_IMAGE_BASE64_LENGTH, MAX_PENDING_UPLOADS, MAX_CHUNKS_PER_UPLOAD, activeOverrides;
20894
20907
  var init_agentcore = __esm({
20895
- "packages/server/dist/routes/agentcore.js"() {
20908
+ "../server/dist/routes/agentcore.js"() {
20896
20909
  "use strict";
20897
20910
  init_commands2();
20898
20911
  init_ui_log_builder();
@@ -20907,7 +20920,7 @@ var init_agentcore = __esm({
20907
20920
  }
20908
20921
  });
20909
20922
 
20910
- // packages/server/dist/ws/file-watcher.js
20923
+ // ../server/dist/ws/file-watcher.js
20911
20924
  import fs45 from "node:fs";
20912
20925
  import path53 from "node:path";
20913
20926
  function enqueueNativeOp(op) {
@@ -20929,7 +20942,7 @@ function isUnwatchablePath(absPath) {
20929
20942
  }
20930
20943
  var IGNORED_SEGMENTS, IS_WIN32, IGNORED_SEGMENT_SET, NATIVE_IGNORE, nativeOpChain, WorkspaceWatcher;
20931
20944
  var init_file_watcher = __esm({
20932
- "packages/server/dist/ws/file-watcher.js"() {
20945
+ "../server/dist/ws/file-watcher.js"() {
20933
20946
  "use strict";
20934
20947
  IGNORED_SEGMENTS = [
20935
20948
  // VCS
@@ -21151,12 +21164,12 @@ var init_file_watcher = __esm({
21151
21164
  }
21152
21165
  });
21153
21166
 
21154
- // packages/server/dist/ws/git-dir-watcher.js
21167
+ // ../server/dist/ws/git-dir-watcher.js
21155
21168
  import fs46 from "node:fs";
21156
21169
  import path54 from "node:path";
21157
21170
  var GitDirWatcher;
21158
21171
  var init_git_dir_watcher = __esm({
21159
- "packages/server/dist/ws/git-dir-watcher.js"() {
21172
+ "../server/dist/ws/git-dir-watcher.js"() {
21160
21173
  "use strict";
21161
21174
  GitDirWatcher = class {
21162
21175
  watcher = null;
@@ -21275,7 +21288,7 @@ var init_git_dir_watcher = __esm({
21275
21288
  }
21276
21289
  });
21277
21290
 
21278
- // packages/server/dist/ws/event-processor.js
21291
+ // ../server/dist/ws/event-processor.js
21279
21292
  function sendJson(ws, data) {
21280
21293
  if (ws.readyState === ws.OPEN) {
21281
21294
  try {
@@ -21374,13 +21387,13 @@ function bufferDetachedNotification(event, pendingEvents) {
21374
21387
  }
21375
21388
  }
21376
21389
  var init_event_processor = __esm({
21377
- "packages/server/dist/ws/event-processor.js"() {
21390
+ "../server/dist/ws/event-processor.js"() {
21378
21391
  "use strict";
21379
21392
  init_ui_log_builder();
21380
21393
  }
21381
21394
  });
21382
21395
 
21383
- // packages/server/dist/ws/terminal-manager.js
21396
+ // ../server/dist/ws/terminal-manager.js
21384
21397
  import { homedir as homedir22 } from "node:os";
21385
21398
  import { basename } from "node:path";
21386
21399
  import { createRequire } from "node:module";
@@ -21411,7 +21424,7 @@ function attachListenersOnce(t2) {
21411
21424
  }
21412
21425
  var requireFromHere, ptyModule, TERMINAL_GRACE_MS, terminals, TerminalManager;
21413
21426
  var init_terminal_manager = __esm({
21414
- "packages/server/dist/ws/terminal-manager.js"() {
21427
+ "../server/dist/ws/terminal-manager.js"() {
21415
21428
  "use strict";
21416
21429
  init_config();
21417
21430
  init_event_processor();
@@ -21558,7 +21571,7 @@ var init_terminal_manager = __esm({
21558
21571
  }
21559
21572
  });
21560
21573
 
21561
- // packages/server/dist/ws/handler.js
21574
+ // ../server/dist/ws/handler.js
21562
21575
  import path55 from "node:path";
21563
21576
  function setupWebSocketHandler(deps) {
21564
21577
  const { wss: wss2, registry: registry2 } = deps;
@@ -22186,7 +22199,7 @@ ${msg.message}` : markers.join("\n");
22186
22199
  }
22187
22200
  var CLIENT_SILENCE_LIMIT_MS, detachedSessions;
22188
22201
  var init_handler = __esm({
22189
- "packages/server/dist/ws/handler.js"() {
22202
+ "../server/dist/ws/handler.js"() {
22190
22203
  "use strict";
22191
22204
  init_ui_log_builder();
22192
22205
  init_config();
@@ -22205,7 +22218,7 @@ var init_handler = __esm({
22205
22218
  }
22206
22219
  });
22207
22220
 
22208
- // packages/server/dist/db/cron-db.js
22221
+ // ../server/dist/db/cron-db.js
22209
22222
  import Database6 from "better-sqlite3";
22210
22223
  import { drizzle as drizzle4 } from "drizzle-orm/better-sqlite3";
22211
22224
  import { sqliteTable as sqliteTable4, text as text4, integer as integer4 } from "drizzle-orm/sqlite-core";
@@ -22240,7 +22253,7 @@ function getCronDb() {
22240
22253
  }
22241
22254
  var cronJobs, cronRuns, CREATE_SQL3, _cronDb;
22242
22255
  var init_cron_db = __esm({
22243
- "packages/server/dist/db/cron-db.js"() {
22256
+ "../server/dist/db/cron-db.js"() {
22244
22257
  "use strict";
22245
22258
  cronJobs = sqliteTable4("cron_jobs", {
22246
22259
  id: text4("id").primaryKey(),
@@ -22350,7 +22363,7 @@ CREATE INDEX IF NOT EXISTS idx_cron_runs_status ON cron_runs(status);
22350
22363
  }
22351
22364
  });
22352
22365
 
22353
- // packages/server/dist/cron/dispatcher.js
22366
+ // ../server/dist/cron/dispatcher.js
22354
22367
  function registerCronDispatcher(d) {
22355
22368
  _registry.set(d.channelType, d);
22356
22369
  }
@@ -22397,14 +22410,14 @@ async function dispatchToTargets(rawText, targets, workspacePath) {
22397
22410
  }
22398
22411
  var _registry;
22399
22412
  var init_dispatcher = __esm({
22400
- "packages/server/dist/cron/dispatcher.js"() {
22413
+ "../server/dist/cron/dispatcher.js"() {
22401
22414
  "use strict";
22402
22415
  init_media();
22403
22416
  _registry = /* @__PURE__ */ new Map();
22404
22417
  }
22405
22418
  });
22406
22419
 
22407
- // packages/server/dist/child-env.js
22420
+ // ../server/dist/child-env.js
22408
22421
  function cleanChildEnv() {
22409
22422
  const env = { ...process.env };
22410
22423
  delete env.HALO_PASSWORD;
@@ -22412,12 +22425,12 @@ function cleanChildEnv() {
22412
22425
  return env;
22413
22426
  }
22414
22427
  var init_child_env = __esm({
22415
- "packages/server/dist/child-env.js"() {
22428
+ "../server/dist/child-env.js"() {
22416
22429
  "use strict";
22417
22430
  }
22418
22431
  });
22419
22432
 
22420
- // packages/server/dist/cron/runner.js
22433
+ // ../server/dist/cron/runner.js
22421
22434
  import { spawn as spawn3, execFileSync } from "node:child_process";
22422
22435
  import fs48 from "node:fs";
22423
22436
  import path57 from "node:path";
@@ -22942,7 +22955,7 @@ function pruneOldLogs() {
22942
22955
  }
22943
22956
  var DAY_MS2, CLI_TIMEOUT_SEC, KILL_GRACE_SEC, RUNS_PER_JOB_KEEP, LOG_RETENTION_DAYS, _active, _inflight, _fingerprint, _daemonTimers, _lastCronDataVersion;
22944
22957
  var init_runner = __esm({
22945
- "packages/server/dist/cron/runner.js"() {
22958
+ "../server/dist/cron/runner.js"() {
22946
22959
  "use strict";
22947
22960
  init_cron_db();
22948
22961
  init_raw_sqlite();
@@ -22962,7 +22975,7 @@ var init_runner = __esm({
22962
22975
  }
22963
22976
  });
22964
22977
 
22965
- // packages/server/dist/routes/cron.js
22978
+ // ../server/dist/routes/cron.js
22966
22979
  import { Hono as Hono14 } from "hono";
22967
22980
  import { eq as eq12, desc as desc3, lt as lt5, and as and8 } from "drizzle-orm";
22968
22981
  import fs49 from "node:fs/promises";
@@ -23234,7 +23247,7 @@ function computeNextRun(j) {
23234
23247
  }
23235
23248
  var TIMEOUT_SEC_MIN, TIMEOUT_SEC_MAX;
23236
23249
  var init_cron = __esm({
23237
- "packages/server/dist/routes/cron.js"() {
23250
+ "../server/dist/routes/cron.js"() {
23238
23251
  "use strict";
23239
23252
  init_cron_db();
23240
23253
  init_runner();
@@ -23245,7 +23258,7 @@ var init_cron = __esm({
23245
23258
  }
23246
23259
  });
23247
23260
 
23248
- // packages/server/dist/evolution/ticker.js
23261
+ // ../server/dist/evolution/ticker.js
23249
23262
  import { eq as eq13, and as and9, or as or2, asc, isNull as isNull5, sql as sql2 } from "drizzle-orm";
23250
23263
  function setEvoSpawner(fn) {
23251
23264
  _spawner = fn;
@@ -23471,7 +23484,7 @@ function claimApply(id) {
23471
23484
  }
23472
23485
  var _lastRunStatus, _lastApplyStatus, _spawner, TICK_INTERVAL_MS, _interval, _startupTimer2;
23473
23486
  var init_ticker = __esm({
23474
- "packages/server/dist/evolution/ticker.js"() {
23487
+ "../server/dist/evolution/ticker.js"() {
23475
23488
  "use strict";
23476
23489
  init_config();
23477
23490
  init_evo_db();
@@ -23487,13 +23500,13 @@ var init_ticker = __esm({
23487
23500
  }
23488
23501
  });
23489
23502
 
23490
- // packages/server/dist/evolution/spawn.js
23503
+ // ../server/dist/evolution/spawn.js
23491
23504
  import path58 from "node:path";
23492
23505
  import { spawn as spawn4 } from "node:child_process";
23493
23506
  import { fileURLToPath as fileURLToPath2 } from "node:url";
23494
23507
  var __dirname2, WRAPPER_PATH, realEvoSpawner;
23495
23508
  var init_spawn = __esm({
23496
- "packages/server/dist/evolution/spawn.js"() {
23509
+ "../server/dist/evolution/spawn.js"() {
23497
23510
  "use strict";
23498
23511
  init_child_env();
23499
23512
  __dirname2 = path58.dirname(fileURLToPath2(import.meta.url));
@@ -23515,7 +23528,7 @@ var init_spawn = __esm({
23515
23528
  }
23516
23529
  });
23517
23530
 
23518
- // packages/server/dist/channels/registry.js
23531
+ // ../server/dist/channels/registry.js
23519
23532
  function bootChannels(app2, descriptors, deps) {
23520
23533
  for (const d of descriptors) {
23521
23534
  if (d.registerCronDispatcher)
@@ -23540,13 +23553,13 @@ async function shutdownChannels() {
23540
23553
  }
23541
23554
  var _running;
23542
23555
  var init_registry2 = __esm({
23543
- "packages/server/dist/channels/registry.js"() {
23556
+ "../server/dist/channels/registry.js"() {
23544
23557
  "use strict";
23545
23558
  _running = [];
23546
23559
  }
23547
23560
  });
23548
23561
 
23549
- // packages/server/dist/channels/telegram/accounts.js
23562
+ // ../server/dist/channels/telegram/accounts.js
23550
23563
  function toTelegram(a) {
23551
23564
  const c = a.config;
23552
23565
  return {
@@ -23620,18 +23633,40 @@ function deleteAccount3(db, accountId) {
23620
23633
  }
23621
23634
  var CH2;
23622
23635
  var init_accounts3 = __esm({
23623
- "packages/server/dist/channels/telegram/accounts.js"() {
23636
+ "../server/dist/channels/telegram/accounts.js"() {
23624
23637
  "use strict";
23625
23638
  init_accounts();
23626
23639
  CH2 = "telegram";
23627
23640
  }
23628
23641
  });
23629
23642
 
23630
- // packages/server/dist/channels/telegram/event-adapter.js
23643
+ // ../server/dist/channels/shared/chunk.js
23644
+ function splitText(text5, limit) {
23645
+ const out = [];
23646
+ let rest = text5;
23647
+ while (rest.length > limit) {
23648
+ const window = rest.slice(0, limit);
23649
+ const lastPara = window.lastIndexOf("\n\n");
23650
+ const cut = lastPara > limit / 2 ? lastPara + 2 : limit;
23651
+ out.push(rest.slice(0, cut));
23652
+ rest = rest.slice(cut).trimStart();
23653
+ }
23654
+ if (rest)
23655
+ out.push(rest);
23656
+ return out;
23657
+ }
23658
+ var init_chunk = __esm({
23659
+ "../server/dist/channels/shared/chunk.js"() {
23660
+ "use strict";
23661
+ }
23662
+ });
23663
+
23664
+ // ../server/dist/channels/telegram/event-adapter.js
23631
23665
  var HARD_CHARS, TelegramResponder;
23632
23666
  var init_event_adapter = __esm({
23633
- "packages/server/dist/channels/telegram/event-adapter.js"() {
23667
+ "../server/dist/channels/telegram/event-adapter.js"() {
23634
23668
  "use strict";
23669
+ init_chunk();
23635
23670
  init_media();
23636
23671
  HARD_CHARS = 4e3;
23637
23672
  TelegramResponder = class {
@@ -23648,7 +23683,7 @@ var init_event_adapter = __esm({
23648
23683
  return;
23649
23684
  switch (event.type) {
23650
23685
  case "stream":
23651
- if (event.text)
23686
+ if (event.final && event.text)
23652
23687
  this.append(event.text);
23653
23688
  break;
23654
23689
  case "error":
@@ -23676,34 +23711,20 @@ var init_event_adapter = __esm({
23676
23711
  }
23677
23712
  append(text5) {
23678
23713
  this.buffer += text5;
23679
- while (this.buffer.length >= HARD_CHARS) {
23680
- const cut = this.findSplitPoint(this.buffer, HARD_CHARS);
23681
- const chunk = this.buffer.slice(0, cut);
23682
- this.buffer = this.buffer.slice(cut).trimStart();
23714
+ if (this.buffer.length <= HARD_CHARS)
23715
+ return;
23716
+ const chunks = splitText(this.buffer, HARD_CHARS);
23717
+ this.buffer = chunks.pop() ?? "";
23718
+ for (const chunk of chunks)
23683
23719
  void this.dispatchChunk(chunk);
23684
- }
23685
23720
  }
23686
23721
  flushAll() {
23687
23722
  if (!this.buffer)
23688
23723
  return;
23689
- while (this.buffer.length > HARD_CHARS) {
23690
- const cut = this.findSplitPoint(this.buffer, HARD_CHARS);
23691
- const chunk = this.buffer.slice(0, cut);
23692
- this.buffer = this.buffer.slice(cut).trimStart();
23724
+ const chunks = splitText(this.buffer, HARD_CHARS);
23725
+ this.buffer = "";
23726
+ for (const chunk of chunks)
23693
23727
  void this.dispatchChunk(chunk);
23694
- }
23695
- if (this.buffer) {
23696
- const text5 = this.buffer;
23697
- this.buffer = "";
23698
- void this.dispatchChunk(text5);
23699
- }
23700
- }
23701
- findSplitPoint(text5, limit) {
23702
- const window = text5.slice(0, limit);
23703
- const lastPara = window.lastIndexOf("\n\n");
23704
- if (lastPara > limit / 2)
23705
- return lastPara + 2;
23706
- return limit;
23707
23728
  }
23708
23729
  async dispatchChunk(chunk) {
23709
23730
  const { text: text5, mediaPaths } = extractMediaMessage(chunk);
@@ -23726,7 +23747,7 @@ var init_event_adapter = __esm({
23726
23747
  }
23727
23748
  });
23728
23749
 
23729
- // packages/server/dist/channels/shared/busy-hint.js
23750
+ // ../server/dist/channels/shared/busy-hint.js
23730
23751
  function busyHint(sm, sessionId, lang) {
23731
23752
  if (sm.isSessionCompacting(sessionId))
23732
23753
  return t("handler.compacting", lang);
@@ -23735,13 +23756,13 @@ function busyHint(sm, sessionId, lang) {
23735
23756
  return null;
23736
23757
  }
23737
23758
  var init_busy_hint = __esm({
23738
- "packages/server/dist/channels/shared/busy-hint.js"() {
23759
+ "../server/dist/channels/shared/busy-hint.js"() {
23739
23760
  "use strict";
23740
23761
  init_i18n();
23741
23762
  }
23742
23763
  });
23743
23764
 
23744
- // packages/server/dist/channels/shared/inbound.js
23765
+ // ../server/dist/channels/shared/inbound.js
23745
23766
  function sessionAccess(accountAccessLevel) {
23746
23767
  return accountAccessLevel === "full" ? null : accountAccessLevel === "workspace" ? "workspace" : "readonly";
23747
23768
  }
@@ -23799,7 +23820,7 @@ async function dispatchChannelCommand(ctx, command, arg, opts) {
23799
23820
  }
23800
23821
  var InboundBridge;
23801
23822
  var init_inbound = __esm({
23802
- "packages/server/dist/channels/shared/inbound.js"() {
23823
+ "../server/dist/channels/shared/inbound.js"() {
23803
23824
  "use strict";
23804
23825
  init_goal_mode();
23805
23826
  init_accounts();
@@ -23869,17 +23890,17 @@ var init_inbound = __esm({
23869
23890
  }
23870
23891
  });
23871
23892
 
23872
- // packages/server/dist/channels/shared/session-prefix.js
23893
+ // ../server/dist/channels/shared/session-prefix.js
23873
23894
  function sessionPrefix(channel, userId) {
23874
23895
  return `${channel}_${userId}_`;
23875
23896
  }
23876
23897
  var init_session_prefix = __esm({
23877
- "packages/server/dist/channels/shared/session-prefix.js"() {
23898
+ "../server/dist/channels/shared/session-prefix.js"() {
23878
23899
  "use strict";
23879
23900
  }
23880
23901
  });
23881
23902
 
23882
- // packages/server/dist/channels/telegram/handler.js
23903
+ // ../server/dist/channels/telegram/handler.js
23883
23904
  import { Bot, InputFile } from "grammy";
23884
23905
  function inferMediaKind(filePath) {
23885
23906
  const cls = classifyMedia(filePath);
@@ -24266,7 +24287,7 @@ async function handleUserMessage(args) {
24266
24287
  }
24267
24288
  var MAX_TG_DOWNLOAD_BYTES;
24268
24289
  var init_handler2 = __esm({
24269
- "packages/server/dist/channels/telegram/handler.js"() {
24290
+ "../server/dist/channels/telegram/handler.js"() {
24270
24291
  "use strict";
24271
24292
  init_accounts3();
24272
24293
  init_event_adapter();
@@ -24281,7 +24302,7 @@ var init_handler2 = __esm({
24281
24302
  }
24282
24303
  });
24283
24304
 
24284
- // packages/server/dist/routes/telegram.js
24305
+ // ../server/dist/routes/telegram.js
24285
24306
  import { Hono as Hono15 } from "hono";
24286
24307
  import { Bot as Bot2 } from "grammy";
24287
24308
  import fs50 from "node:fs";
@@ -24400,14 +24421,14 @@ function createTelegramRoutes(deps) {
24400
24421
  return app2;
24401
24422
  }
24402
24423
  var init_telegram = __esm({
24403
- "packages/server/dist/routes/telegram.js"() {
24424
+ "../server/dist/routes/telegram.js"() {
24404
24425
  "use strict";
24405
24426
  init_accounts3();
24406
24427
  init_accounts();
24407
24428
  }
24408
24429
  });
24409
24430
 
24410
- // packages/server/dist/channels/telegram/cron-dispatcher.js
24431
+ // ../server/dist/channels/telegram/cron-dispatcher.js
24411
24432
  import { Bot as Bot3 } from "grammy";
24412
24433
  async function dispatch(accountId, text5, explicitChatId) {
24413
24434
  const acct = getAccount3(getChannelDb(), accountId);
@@ -24456,7 +24477,7 @@ function registerTelegramCronDispatcher() {
24456
24477
  registerCronDispatcher({ channelType: "telegram", dispatch, listTargets });
24457
24478
  }
24458
24479
  var init_cron_dispatcher = __esm({
24459
- "packages/server/dist/channels/telegram/cron-dispatcher.js"() {
24480
+ "../server/dist/channels/telegram/cron-dispatcher.js"() {
24460
24481
  "use strict";
24461
24482
  init_channel_db();
24462
24483
  init_accounts3();
@@ -24464,10 +24485,10 @@ var init_cron_dispatcher = __esm({
24464
24485
  }
24465
24486
  });
24466
24487
 
24467
- // packages/server/dist/channels/telegram/descriptor.js
24488
+ // ../server/dist/channels/telegram/descriptor.js
24468
24489
  var telegramDescriptor;
24469
24490
  var init_descriptor = __esm({
24470
- "packages/server/dist/channels/telegram/descriptor.js"() {
24491
+ "../server/dist/channels/telegram/descriptor.js"() {
24471
24492
  "use strict";
24472
24493
  init_handler2();
24473
24494
  init_telegram();
@@ -24482,7 +24503,7 @@ var init_descriptor = __esm({
24482
24503
  }
24483
24504
  });
24484
24505
 
24485
- // packages/server/dist/channels/wechat/api.js
24506
+ // ../server/dist/channels/wechat/api.js
24486
24507
  import crypto3 from "node:crypto";
24487
24508
  function buildClientVersion(version) {
24488
24509
  const [ma, mi, pa] = version.split(".").map((p) => parseInt(p, 10));
@@ -24627,7 +24648,7 @@ async function sendMessage(params) {
24627
24648
  try {
24628
24649
  const parsed = JSON.parse(raw);
24629
24650
  if (parsed.ret !== void 0 && parsed.ret !== 0 || parsed.errcode !== void 0 && parsed.errcode !== 0) {
24630
- const hint = parsed.ret === -2 ? " (target user has never messaged this bot \u2014 they must send any message first)" : "";
24651
+ const hint = parsed.ret === -2 ? " (gateway rejected the message \u2014 payload too large (>16KB observed) or the target user has no recent inbound message with this bot)" : "";
24631
24652
  throw new Error(`[wechat:sendmessage] gateway error ret=${parsed.ret} errcode=${parsed.errcode} ${parsed.errmsg ?? ""}${hint}`);
24632
24653
  }
24633
24654
  } catch (err) {
@@ -24671,7 +24692,7 @@ async function notifyStop(params) {
24671
24692
  }
24672
24693
  var QR_BASE_URL, DEFAULT_BOT_TYPE, CHANNEL_VERSION, ILINK_APP_ID, ILINK_APP_CLIENT_VERSION, DEFAULT_LONG_POLL_TIMEOUT_MS, DEFAULT_API_TIMEOUT_MS;
24673
24694
  var init_api = __esm({
24674
- "packages/server/dist/channels/wechat/api.js"() {
24695
+ "../server/dist/channels/wechat/api.js"() {
24675
24696
  "use strict";
24676
24697
  QR_BASE_URL = "https://ilinkai.weixin.qq.com";
24677
24698
  DEFAULT_BOT_TYPE = "3";
@@ -24683,10 +24704,10 @@ var init_api = __esm({
24683
24704
  }
24684
24705
  });
24685
24706
 
24686
- // packages/server/dist/channels/wechat/types.js
24707
+ // ../server/dist/channels/wechat/types.js
24687
24708
  var MessageItemType, MessageType, MessageState, UploadMediaType;
24688
24709
  var init_types = __esm({
24689
- "packages/server/dist/channels/wechat/types.js"() {
24710
+ "../server/dist/channels/wechat/types.js"() {
24690
24711
  "use strict";
24691
24712
  MessageItemType = {
24692
24713
  NONE: 0,
@@ -24715,7 +24736,7 @@ var init_types = __esm({
24715
24736
  }
24716
24737
  });
24717
24738
 
24718
- // packages/server/dist/channels/wechat/accounts.js
24739
+ // ../server/dist/channels/wechat/accounts.js
24719
24740
  function toWechat(a) {
24720
24741
  const c = a.config;
24721
24742
  return {
@@ -24797,24 +24818,27 @@ function saveSyncBuf(db, accountId, syncBuf) {
24797
24818
  }
24798
24819
  var CH3;
24799
24820
  var init_accounts4 = __esm({
24800
- "packages/server/dist/channels/wechat/accounts.js"() {
24821
+ "../server/dist/channels/wechat/accounts.js"() {
24801
24822
  "use strict";
24802
24823
  init_accounts();
24803
24824
  CH3 = "wechat";
24804
24825
  }
24805
24826
  });
24806
24827
 
24807
- // packages/server/dist/channels/wechat/event-adapter.js
24808
- var HARD_CHARS2, WechatResponder;
24828
+ // ../server/dist/channels/wechat/event-adapter.js
24829
+ var WECHAT_TEXT_LIMIT, WechatResponder;
24809
24830
  var init_event_adapter2 = __esm({
24810
- "packages/server/dist/channels/wechat/event-adapter.js"() {
24831
+ "../server/dist/channels/wechat/event-adapter.js"() {
24811
24832
  "use strict";
24833
+ init_chunk();
24812
24834
  init_media();
24813
- HARD_CHARS2 = 3500;
24835
+ WECHAT_TEXT_LIMIT = 3500;
24814
24836
  WechatResponder = class {
24815
24837
  buffer = "";
24816
24838
  deps;
24817
24839
  closed = false;
24840
+ /** Tail of the per-responder send chain — see `enqueueChunk`. */
24841
+ sendTail = Promise.resolve();
24818
24842
  constructor(deps) {
24819
24843
  this.deps = deps;
24820
24844
  }
@@ -24825,19 +24849,19 @@ var init_event_adapter2 = __esm({
24825
24849
  return;
24826
24850
  switch (event.type) {
24827
24851
  case "stream":
24828
- if (event.text)
24852
+ if (event.final && event.text)
24829
24853
  this.append(event.text);
24830
24854
  break;
24831
24855
  case "error":
24832
24856
  if (event.error) {
24833
24857
  this.flushAll();
24834
- void this.dispatchChunk(`\u274C ${event.error}`);
24858
+ this.enqueueChunk(`\u274C ${event.error}`);
24835
24859
  }
24836
24860
  break;
24837
24861
  case "system":
24838
24862
  if (event.text) {
24839
24863
  this.flushAll();
24840
- void this.dispatchChunk(`\u2139\uFE0F ${event.text}`);
24864
+ this.enqueueChunk(`\u2139\uFE0F ${event.text}`);
24841
24865
  }
24842
24866
  break;
24843
24867
  case "complete":
@@ -24845,46 +24869,43 @@ var init_event_adapter2 = __esm({
24845
24869
  break;
24846
24870
  }
24847
24871
  }
24872
+ /** Returns the drain promise so the bridge keeps the reply route alive
24873
+ * until the last queued chunk has actually been sent. */
24848
24874
  close() {
24849
24875
  if (this.closed)
24850
- return;
24876
+ return this.sendTail;
24851
24877
  this.flushAll();
24852
24878
  this.closed = true;
24879
+ return this.sendTail;
24853
24880
  }
24854
24881
  append(text5) {
24855
24882
  this.buffer += text5;
24856
- while (this.buffer.length >= HARD_CHARS2) {
24857
- const cut = this.findSplitPoint(this.buffer, HARD_CHARS2);
24858
- const chunk = this.buffer.slice(0, cut);
24859
- this.buffer = this.buffer.slice(cut).trimStart();
24860
- void this.dispatchChunk(chunk);
24861
- }
24883
+ if (this.buffer.length <= WECHAT_TEXT_LIMIT)
24884
+ return;
24885
+ const chunks = splitText(this.buffer, WECHAT_TEXT_LIMIT);
24886
+ this.buffer = chunks.pop() ?? "";
24887
+ for (const chunk of chunks)
24888
+ this.enqueueChunk(chunk);
24862
24889
  }
24863
24890
  flushAll() {
24864
24891
  if (!this.buffer)
24865
24892
  return;
24866
- while (this.buffer.length > HARD_CHARS2) {
24867
- const cut = this.findSplitPoint(this.buffer, HARD_CHARS2);
24868
- const chunk = this.buffer.slice(0, cut);
24869
- this.buffer = this.buffer.slice(cut).trimStart();
24870
- void this.dispatchChunk(chunk);
24871
- }
24872
- if (this.buffer) {
24873
- const text5 = this.buffer;
24874
- this.buffer = "";
24875
- void this.dispatchChunk(text5);
24876
- }
24893
+ const chunks = splitText(this.buffer, WECHAT_TEXT_LIMIT);
24894
+ this.buffer = "";
24895
+ for (const chunk of chunks)
24896
+ this.enqueueChunk(chunk);
24877
24897
  }
24878
24898
  /**
24879
- * Pick an index ≤ `limit` to split `text` at. Prefer the last paragraph
24880
- * break (`\n\n`) within the limit; fall back to a hard cut at `limit`.
24899
+ * Serialize sends per responder — same rationale as the Slack adapter
24900
+ * (audit A-L3): a flush emits several chunks in one synchronous loop, and
24901
+ * firing their HTTP sends concurrently gave arrival order no guarantee.
24902
+ * Each chunk waits for the previous send to settle; the `catch` keeps a
24903
+ * rejected link from poisoning the chain (dispatchChunk already logs
24904
+ * per-send failures).
24881
24905
  */
24882
- findSplitPoint(text5, limit) {
24883
- const window = text5.slice(0, limit);
24884
- const lastPara = window.lastIndexOf("\n\n");
24885
- if (lastPara > limit / 2)
24886
- return lastPara + 2;
24887
- return limit;
24906
+ enqueueChunk(chunk) {
24907
+ this.sendTail = this.sendTail.then(() => this.dispatchChunk(chunk)).catch(() => {
24908
+ });
24888
24909
  }
24889
24910
  /**
24890
24911
  * Extract MEDIA: lines, dispatching them as media sends. Remaining text
@@ -24911,7 +24932,7 @@ var init_event_adapter2 = __esm({
24911
24932
  }
24912
24933
  });
24913
24934
 
24914
- // packages/server/dist/channels/wechat/cdn.js
24935
+ // ../server/dist/channels/wechat/cdn.js
24915
24936
  import { createDecipheriv, createCipheriv, randomBytes as randomBytes2, createHash as createHash2 } from "node:crypto";
24916
24937
  function decryptAesEcb(ciphertext, key) {
24917
24938
  const decipher = createDecipheriv("aes-128-ecb", key, null);
@@ -25010,14 +25031,14 @@ async function uploadCiphertext(params) {
25010
25031
  }
25011
25032
  var CDN_BASE_URL, UPLOAD_MAX_RETRIES;
25012
25033
  var init_cdn = __esm({
25013
- "packages/server/dist/channels/wechat/cdn.js"() {
25034
+ "../server/dist/channels/wechat/cdn.js"() {
25014
25035
  "use strict";
25015
25036
  CDN_BASE_URL = "https://novac2c.cdn.weixin.qq.com/c2c";
25016
25037
  UPLOAD_MAX_RETRIES = 3;
25017
25038
  }
25018
25039
  });
25019
25040
 
25020
- // packages/server/dist/channels/wechat/send-media.js
25041
+ // ../server/dist/channels/wechat/send-media.js
25021
25042
  import fs51 from "node:fs/promises";
25022
25043
  import path59 from "node:path";
25023
25044
  function inferKind(filePath) {
@@ -25111,7 +25132,7 @@ function buildMessageItem(args) {
25111
25132
  };
25112
25133
  }
25113
25134
  var init_send_media = __esm({
25114
- "packages/server/dist/channels/wechat/send-media.js"() {
25135
+ "../server/dist/channels/wechat/send-media.js"() {
25115
25136
  "use strict";
25116
25137
  init_api();
25117
25138
  init_cdn();
@@ -25120,7 +25141,7 @@ var init_send_media = __esm({
25120
25141
  }
25121
25142
  });
25122
25143
 
25123
- // packages/server/dist/channels/wechat/login.js
25144
+ // ../server/dist/channels/wechat/login.js
25124
25145
  import { randomUUID as randomUUID2 } from "node:crypto";
25125
25146
  function isFresh(l) {
25126
25147
  return Date.now() - l.startedAt < ACTIVE_TTL_MS;
@@ -25222,7 +25243,7 @@ async function waitLogin(params) {
25222
25243
  }
25223
25244
  var ACTIVE_TTL_MS, MAX_QR_REFRESH, activeLogins;
25224
25245
  var init_login = __esm({
25225
- "packages/server/dist/channels/wechat/login.js"() {
25246
+ "../server/dist/channels/wechat/login.js"() {
25226
25247
  "use strict";
25227
25248
  init_api();
25228
25249
  ACTIVE_TTL_MS = 5 * 6e4;
@@ -25231,7 +25252,7 @@ var init_login = __esm({
25231
25252
  }
25232
25253
  });
25233
25254
 
25234
- // packages/server/dist/channels/wechat/handler.js
25255
+ // ../server/dist/channels/wechat/handler.js
25235
25256
  import fs52 from "node:fs";
25236
25257
  import path60 from "node:path";
25237
25258
  import QRCode from "qrcode";
@@ -25687,7 +25708,7 @@ function sleep2(ms, signal) {
25687
25708
  }
25688
25709
  var MAX_CONSECUTIVE_FAILURES, BACKOFF_DELAY_MS, RETRY_DELAY_MS;
25689
25710
  var init_handler3 = __esm({
25690
- "packages/server/dist/channels/wechat/handler.js"() {
25711
+ "../server/dist/channels/wechat/handler.js"() {
25691
25712
  "use strict";
25692
25713
  init_api();
25693
25714
  init_types();
@@ -25709,7 +25730,7 @@ var init_handler3 = __esm({
25709
25730
  }
25710
25731
  });
25711
25732
 
25712
- // packages/server/dist/routes/wechat.js
25733
+ // ../server/dist/routes/wechat.js
25713
25734
  import { Hono as Hono16 } from "hono";
25714
25735
  import path61 from "node:path";
25715
25736
  import fs53 from "node:fs";
@@ -25824,7 +25845,7 @@ function stripSecrets(acc) {
25824
25845
  return rest;
25825
25846
  }
25826
25847
  var init_wechat = __esm({
25827
- "packages/server/dist/routes/wechat.js"() {
25848
+ "../server/dist/routes/wechat.js"() {
25828
25849
  "use strict";
25829
25850
  init_login();
25830
25851
  init_accounts4();
@@ -25832,7 +25853,7 @@ var init_wechat = __esm({
25832
25853
  }
25833
25854
  });
25834
25855
 
25835
- // packages/server/dist/channels/wechat/cron-dispatcher.js
25856
+ // ../server/dist/channels/wechat/cron-dispatcher.js
25836
25857
  function readLastActiveChatId(accountId) {
25837
25858
  const acct = getAccount(getChannelDb(), accountId);
25838
25859
  if (!acct)
@@ -25852,7 +25873,14 @@ async function dispatch2(accountId, text5, explicitChatId, media) {
25852
25873
  }
25853
25874
  const out = [];
25854
25875
  if (text5) {
25855
- await sendToUser({ account: acct, toUserId: chatId, text: text5 });
25876
+ const chunks = splitText(text5, WECHAT_TEXT_LIMIT);
25877
+ for (const [i, chunk] of chunks.entries()) {
25878
+ try {
25879
+ await sendToUser({ account: acct, toUserId: chatId, text: chunk });
25880
+ } catch (err) {
25881
+ throw new Error(`chunk ${i + 1}/${chunks.length}: ${err instanceof Error ? err.message : String(err)}`);
25882
+ }
25883
+ }
25856
25884
  out.push({ channelType: "wechat", accountId, chatId, ok: true });
25857
25885
  }
25858
25886
  for (const filePath of media?.paths ?? []) {
@@ -25899,22 +25927,24 @@ function registerWechatCronDispatcher() {
25899
25927
  registerCronDispatcher({ channelType: "wechat", supportsMedia: true, dispatch: dispatch2, listTargets: listTargets2 });
25900
25928
  }
25901
25929
  var init_cron_dispatcher2 = __esm({
25902
- "packages/server/dist/channels/wechat/cron-dispatcher.js"() {
25930
+ "../server/dist/channels/wechat/cron-dispatcher.js"() {
25903
25931
  "use strict";
25904
25932
  init_channel_db();
25905
25933
  init_accounts();
25906
25934
  init_accounts4();
25907
25935
  init_handler3();
25908
25936
  init_send_media();
25937
+ init_event_adapter2();
25938
+ init_chunk();
25909
25939
  init_media();
25910
25940
  init_dispatcher();
25911
25941
  }
25912
25942
  });
25913
25943
 
25914
- // packages/server/dist/channels/wechat/descriptor.js
25944
+ // ../server/dist/channels/wechat/descriptor.js
25915
25945
  var wechatDescriptor;
25916
25946
  var init_descriptor2 = __esm({
25917
- "packages/server/dist/channels/wechat/descriptor.js"() {
25947
+ "../server/dist/channels/wechat/descriptor.js"() {
25918
25948
  "use strict";
25919
25949
  init_handler3();
25920
25950
  init_wechat();
@@ -25929,7 +25959,7 @@ var init_descriptor2 = __esm({
25929
25959
  }
25930
25960
  });
25931
25961
 
25932
- // packages/server/dist/channels/web/handler.js
25962
+ // ../server/dist/channels/web/handler.js
25933
25963
  function buildWebSessionPrefix(accountId) {
25934
25964
  return sessionPrefix("web", accountId);
25935
25965
  }
@@ -26312,7 +26342,7 @@ function createMediaBuffer() {
26312
26342
  };
26313
26343
  }
26314
26344
  var init_handler4 = __esm({
26315
- "packages/server/dist/channels/web/handler.js"() {
26345
+ "../server/dist/channels/web/handler.js"() {
26316
26346
  "use strict";
26317
26347
  init_ui_log_builder();
26318
26348
  init_accounts2();
@@ -26327,7 +26357,7 @@ var init_handler4 = __esm({
26327
26357
  }
26328
26358
  });
26329
26359
 
26330
- // packages/server/dist/routes/web.js
26360
+ // ../server/dist/routes/web.js
26331
26361
  import { Hono as Hono17 } from "hono";
26332
26362
  import { streamSSE } from "hono/streaming";
26333
26363
  import crypto4 from "node:crypto";
@@ -26524,7 +26554,7 @@ function createWebRoutes(deps) {
26524
26554
  return app2;
26525
26555
  }
26526
26556
  var init_web = __esm({
26527
- "packages/server/dist/routes/web.js"() {
26557
+ "../server/dist/routes/web.js"() {
26528
26558
  "use strict";
26529
26559
  init_dist();
26530
26560
  init_accounts2();
@@ -26533,10 +26563,10 @@ var init_web = __esm({
26533
26563
  }
26534
26564
  });
26535
26565
 
26536
- // packages/server/dist/channels/web/descriptor.js
26566
+ // ../server/dist/channels/web/descriptor.js
26537
26567
  var webDescriptor;
26538
26568
  var init_descriptor3 = __esm({
26539
- "packages/server/dist/channels/web/descriptor.js"() {
26569
+ "../server/dist/channels/web/descriptor.js"() {
26540
26570
  "use strict";
26541
26571
  init_handler4();
26542
26572
  init_web();
@@ -26552,7 +26582,7 @@ var init_descriptor3 = __esm({
26552
26582
  }
26553
26583
  });
26554
26584
 
26555
- // packages/server/dist/channels/slack/accounts.js
26585
+ // ../server/dist/channels/slack/accounts.js
26556
26586
  function toSlack(a) {
26557
26587
  const c = a.config;
26558
26588
  return {
@@ -26628,14 +26658,14 @@ function deleteAccount5(db, accountId) {
26628
26658
  }
26629
26659
  var CH4;
26630
26660
  var init_accounts5 = __esm({
26631
- "packages/server/dist/channels/slack/accounts.js"() {
26661
+ "../server/dist/channels/slack/accounts.js"() {
26632
26662
  "use strict";
26633
26663
  init_accounts();
26634
26664
  CH4 = "slack";
26635
26665
  }
26636
26666
  });
26637
26667
 
26638
- // packages/server/dist/channels/shared/markdown.js
26668
+ // ../server/dist/channels/shared/markdown.js
26639
26669
  function formatForSlack(input) {
26640
26670
  if (!input)
26641
26671
  return "";
@@ -26714,19 +26744,20 @@ function stripCommonMark(line) {
26714
26744
  return line;
26715
26745
  }
26716
26746
  var init_markdown = __esm({
26717
- "packages/server/dist/channels/shared/markdown.js"() {
26747
+ "../server/dist/channels/shared/markdown.js"() {
26718
26748
  "use strict";
26719
26749
  }
26720
26750
  });
26721
26751
 
26722
- // packages/server/dist/channels/slack/event-adapter.js
26723
- var HARD_CHARS3, SlackResponder;
26752
+ // ../server/dist/channels/slack/event-adapter.js
26753
+ var HARD_CHARS2, SlackResponder;
26724
26754
  var init_event_adapter3 = __esm({
26725
- "packages/server/dist/channels/slack/event-adapter.js"() {
26755
+ "../server/dist/channels/slack/event-adapter.js"() {
26726
26756
  "use strict";
26757
+ init_chunk();
26727
26758
  init_markdown();
26728
26759
  init_media();
26729
- HARD_CHARS3 = 35e3;
26760
+ HARD_CHARS2 = 35e3;
26730
26761
  SlackResponder = class {
26731
26762
  buffer = "";
26732
26763
  deps;
@@ -26743,7 +26774,7 @@ var init_event_adapter3 = __esm({
26743
26774
  return;
26744
26775
  switch (event.type) {
26745
26776
  case "stream":
26746
- if (event.text)
26777
+ if (event.final && event.text)
26747
26778
  this.buffer += event.text;
26748
26779
  break;
26749
26780
  case "system":
@@ -26775,24 +26806,10 @@ var init_event_adapter3 = __esm({
26775
26806
  flushBuffer() {
26776
26807
  if (!this.buffer)
26777
26808
  return;
26778
- while (this.buffer.length > HARD_CHARS3) {
26779
- const cut = this.findSplitPoint(this.buffer, HARD_CHARS3);
26780
- const chunk = this.buffer.slice(0, cut);
26781
- this.buffer = this.buffer.slice(cut).trimStart();
26809
+ const chunks = splitText(this.buffer, HARD_CHARS2);
26810
+ this.buffer = "";
26811
+ for (const chunk of chunks)
26782
26812
  this.enqueueChunk(chunk);
26783
- }
26784
- if (this.buffer) {
26785
- const text5 = this.buffer;
26786
- this.buffer = "";
26787
- this.enqueueChunk(text5);
26788
- }
26789
- }
26790
- findSplitPoint(text5, limit) {
26791
- const window = text5.slice(0, limit);
26792
- const lastPara = window.lastIndexOf("\n\n");
26793
- if (lastPara > limit / 2)
26794
- return lastPara + 2;
26795
- return limit;
26796
26813
  }
26797
26814
  /**
26798
26815
  * Serialize sends per responder. `flushBuffer` can produce several chunks
@@ -26828,7 +26845,7 @@ var init_event_adapter3 = __esm({
26828
26845
  }
26829
26846
  });
26830
26847
 
26831
- // packages/server/dist/channels/slack/api.js
26848
+ // ../server/dist/channels/slack/api.js
26832
26849
  async function slackPost(endpoint, token, body) {
26833
26850
  const isForm = body instanceof FormData;
26834
26851
  const res = await fetch(`${SLACK_API}/${endpoint}`, {
@@ -27016,13 +27033,13 @@ async function downloadFile(botToken, urlPrivate) {
27016
27033
  }
27017
27034
  var SLACK_API;
27018
27035
  var init_api2 = __esm({
27019
- "packages/server/dist/channels/slack/api.js"() {
27036
+ "../server/dist/channels/slack/api.js"() {
27020
27037
  "use strict";
27021
27038
  SLACK_API = "https://slack.com/api";
27022
27039
  }
27023
27040
  });
27024
27041
 
27025
- // packages/server/dist/channels/slack/handler.js
27042
+ // ../server/dist/channels/slack/handler.js
27026
27043
  import path62 from "node:path";
27027
27044
  import { WebSocket } from "ws";
27028
27045
  function slashToBang(text5, commandNames) {
@@ -27382,7 +27399,7 @@ function buildCmdCtx(args) {
27382
27399
  }
27383
27400
  var SLACK_EXTRA_COMMANDS, SEEN_EVENT_IDS, SEEN_EVENT_IDS_MAX;
27384
27401
  var init_handler5 = __esm({
27385
- "packages/server/dist/channels/slack/handler.js"() {
27402
+ "../server/dist/channels/slack/handler.js"() {
27386
27403
  "use strict";
27387
27404
  init_accounts5();
27388
27405
  init_event_adapter3();
@@ -27402,7 +27419,7 @@ var init_handler5 = __esm({
27402
27419
  }
27403
27420
  });
27404
27421
 
27405
- // packages/server/dist/routes/slack.js
27422
+ // ../server/dist/routes/slack.js
27406
27423
  import { Hono as Hono18 } from "hono";
27407
27424
  import fs55 from "node:fs";
27408
27425
  function createSlackRoutes(deps) {
@@ -27536,7 +27553,7 @@ function createSlackRoutes(deps) {
27536
27553
  return app2;
27537
27554
  }
27538
27555
  var init_slack = __esm({
27539
- "packages/server/dist/routes/slack.js"() {
27556
+ "../server/dist/routes/slack.js"() {
27540
27557
  "use strict";
27541
27558
  init_accounts5();
27542
27559
  init_accounts();
@@ -27544,7 +27561,7 @@ var init_slack = __esm({
27544
27561
  }
27545
27562
  });
27546
27563
 
27547
- // packages/server/dist/channels/slack/cron-dispatcher.js
27564
+ // ../server/dist/channels/slack/cron-dispatcher.js
27548
27565
  function parseChatId(raw) {
27549
27566
  const idx = raw.indexOf(":");
27550
27567
  if (idx < 0)
@@ -27608,7 +27625,7 @@ function registerSlackCronDispatcher() {
27608
27625
  registerCronDispatcher({ channelType: "slack", supportsMedia: true, dispatch: dispatch3, listTargets: listTargets3 });
27609
27626
  }
27610
27627
  var init_cron_dispatcher3 = __esm({
27611
- "packages/server/dist/channels/slack/cron-dispatcher.js"() {
27628
+ "../server/dist/channels/slack/cron-dispatcher.js"() {
27612
27629
  "use strict";
27613
27630
  init_channel_db();
27614
27631
  init_accounts5();
@@ -27618,10 +27635,10 @@ var init_cron_dispatcher3 = __esm({
27618
27635
  }
27619
27636
  });
27620
27637
 
27621
- // packages/server/dist/channels/slack/descriptor.js
27638
+ // ../server/dist/channels/slack/descriptor.js
27622
27639
  var slackDescriptor;
27623
27640
  var init_descriptor4 = __esm({
27624
- "packages/server/dist/channels/slack/descriptor.js"() {
27641
+ "../server/dist/channels/slack/descriptor.js"() {
27625
27642
  "use strict";
27626
27643
  init_handler5();
27627
27644
  init_slack();
@@ -27636,7 +27653,7 @@ var init_descriptor4 = __esm({
27636
27653
  }
27637
27654
  });
27638
27655
 
27639
- // packages/server/dist/channels/feishu/accounts.js
27656
+ // ../server/dist/channels/feishu/accounts.js
27640
27657
  function toFeishu(a) {
27641
27658
  const c = a.config;
27642
27659
  return {
@@ -27714,21 +27731,22 @@ function deleteAccount6(db, accountId) {
27714
27731
  }
27715
27732
  var CH5;
27716
27733
  var init_accounts6 = __esm({
27717
- "packages/server/dist/channels/feishu/accounts.js"() {
27734
+ "../server/dist/channels/feishu/accounts.js"() {
27718
27735
  "use strict";
27719
27736
  init_accounts();
27720
27737
  CH5 = "feishu";
27721
27738
  }
27722
27739
  });
27723
27740
 
27724
- // packages/server/dist/channels/feishu/event-adapter.js
27725
- var HARD_CHARS4, FeishuResponder;
27741
+ // ../server/dist/channels/feishu/event-adapter.js
27742
+ var HARD_CHARS3, FeishuResponder;
27726
27743
  var init_event_adapter4 = __esm({
27727
- "packages/server/dist/channels/feishu/event-adapter.js"() {
27744
+ "../server/dist/channels/feishu/event-adapter.js"() {
27728
27745
  "use strict";
27746
+ init_chunk();
27729
27747
  init_markdown();
27730
27748
  init_media();
27731
- HARD_CHARS4 = 4500;
27749
+ HARD_CHARS3 = 4500;
27732
27750
  FeishuResponder = class {
27733
27751
  buffer = "";
27734
27752
  deps;
@@ -27745,7 +27763,7 @@ var init_event_adapter4 = __esm({
27745
27763
  return;
27746
27764
  switch (event.type) {
27747
27765
  case "stream":
27748
- if (event.text)
27766
+ if (event.final && event.text)
27749
27767
  this.buffer += event.text;
27750
27768
  break;
27751
27769
  case "system":
@@ -27777,24 +27795,10 @@ var init_event_adapter4 = __esm({
27777
27795
  flushBuffer() {
27778
27796
  if (!this.buffer)
27779
27797
  return;
27780
- while (this.buffer.length > HARD_CHARS4) {
27781
- const cut = this.findSplitPoint(this.buffer, HARD_CHARS4);
27782
- const chunk = this.buffer.slice(0, cut);
27783
- this.buffer = this.buffer.slice(cut).trimStart();
27798
+ const chunks = splitText(this.buffer, HARD_CHARS3);
27799
+ this.buffer = "";
27800
+ for (const chunk of chunks)
27784
27801
  this.enqueueChunk(chunk);
27785
- }
27786
- if (this.buffer) {
27787
- const text5 = this.buffer;
27788
- this.buffer = "";
27789
- this.enqueueChunk(text5);
27790
- }
27791
- }
27792
- findSplitPoint(text5, limit) {
27793
- const window = text5.slice(0, limit);
27794
- const lastPara = window.lastIndexOf("\n\n");
27795
- if (lastPara > limit / 2)
27796
- return lastPara + 2;
27797
- return limit;
27798
27802
  }
27799
27803
  /**
27800
27804
  * Serialize sends per responder — same rationale as the Slack adapter
@@ -27830,7 +27834,7 @@ var init_event_adapter4 = __esm({
27830
27834
  }
27831
27835
  });
27832
27836
 
27833
- // packages/server/dist/channels/feishu/api.js
27837
+ // ../server/dist/channels/feishu/api.js
27834
27838
  async function getTenantAccessToken(args) {
27835
27839
  const cached = tokenCache.get(args.appId);
27836
27840
  if (cached && cached.expiresAt - Date.now() > 6e4)
@@ -28094,14 +28098,14 @@ async function searchFeishuTargets(args) {
28094
28098
  }
28095
28099
  var FEISHU_BASE, tokenCache;
28096
28100
  var init_api3 = __esm({
28097
- "packages/server/dist/channels/feishu/api.js"() {
28101
+ "../server/dist/channels/feishu/api.js"() {
28098
28102
  "use strict";
28099
28103
  FEISHU_BASE = "https://open.feishu.cn";
28100
28104
  tokenCache = /* @__PURE__ */ new Map();
28101
28105
  }
28102
28106
  });
28103
28107
 
28104
- // packages/server/dist/channels/feishu/handler.js
28108
+ // ../server/dist/channels/feishu/handler.js
28105
28109
  import path63 from "node:path";
28106
28110
  import * as Lark from "@larksuiteoapi/node-sdk";
28107
28111
  function buildSessionPrefixForThread2(chatId, rootId) {
@@ -28511,7 +28515,7 @@ function buildCmdCtx2(args) {
28511
28515
  };
28512
28516
  }
28513
28517
  var init_handler6 = __esm({
28514
- "packages/server/dist/channels/feishu/handler.js"() {
28518
+ "../server/dist/channels/feishu/handler.js"() {
28515
28519
  "use strict";
28516
28520
  init_accounts6();
28517
28521
  init_event_adapter4();
@@ -28526,7 +28530,7 @@ var init_handler6 = __esm({
28526
28530
  }
28527
28531
  });
28528
28532
 
28529
- // packages/server/dist/routes/feishu.js
28533
+ // ../server/dist/routes/feishu.js
28530
28534
  import { Hono as Hono19 } from "hono";
28531
28535
  import fs56 from "node:fs";
28532
28536
  function createFeishuRoutes(deps) {
@@ -28663,7 +28667,7 @@ function createFeishuRoutes(deps) {
28663
28667
  return app2;
28664
28668
  }
28665
28669
  var init_feishu = __esm({
28666
- "packages/server/dist/routes/feishu.js"() {
28670
+ "../server/dist/routes/feishu.js"() {
28667
28671
  "use strict";
28668
28672
  init_accounts6();
28669
28673
  init_accounts();
@@ -28671,7 +28675,7 @@ var init_feishu = __esm({
28671
28675
  }
28672
28676
  });
28673
28677
 
28674
- // packages/server/dist/channels/feishu/cron-dispatcher.js
28678
+ // ../server/dist/channels/feishu/cron-dispatcher.js
28675
28679
  function parseChatId2(raw) {
28676
28680
  const idx = raw.indexOf(":");
28677
28681
  return { chatId: idx < 0 ? raw : raw.slice(0, idx) };
@@ -28721,7 +28725,7 @@ function registerFeishuCronDispatcher() {
28721
28725
  registerCronDispatcher({ channelType: "feishu", dispatch: dispatch4, listTargets: listTargets4 });
28722
28726
  }
28723
28727
  var init_cron_dispatcher4 = __esm({
28724
- "packages/server/dist/channels/feishu/cron-dispatcher.js"() {
28728
+ "../server/dist/channels/feishu/cron-dispatcher.js"() {
28725
28729
  "use strict";
28726
28730
  init_channel_db();
28727
28731
  init_accounts6();
@@ -28730,10 +28734,10 @@ var init_cron_dispatcher4 = __esm({
28730
28734
  }
28731
28735
  });
28732
28736
 
28733
- // packages/server/dist/channels/feishu/descriptor.js
28737
+ // ../server/dist/channels/feishu/descriptor.js
28734
28738
  var feishuDescriptor;
28735
28739
  var init_descriptor5 = __esm({
28736
- "packages/server/dist/channels/feishu/descriptor.js"() {
28740
+ "../server/dist/channels/feishu/descriptor.js"() {
28737
28741
  "use strict";
28738
28742
  init_handler6();
28739
28743
  init_feishu();
@@ -28748,10 +28752,10 @@ var init_descriptor5 = __esm({
28748
28752
  }
28749
28753
  });
28750
28754
 
28751
- // packages/server/dist/channels/descriptors.js
28755
+ // ../server/dist/channels/descriptors.js
28752
28756
  var defaultChannelDescriptors;
28753
28757
  var init_descriptors = __esm({
28754
- "packages/server/dist/channels/descriptors.js"() {
28758
+ "../server/dist/channels/descriptors.js"() {
28755
28759
  "use strict";
28756
28760
  init_descriptor();
28757
28761
  init_descriptor2();
@@ -28768,7 +28772,7 @@ var init_descriptors = __esm({
28768
28772
  }
28769
28773
  });
28770
28774
 
28771
- // packages/server/dist/middleware/auth.js
28775
+ // ../server/dist/middleware/auth.js
28772
28776
  import { Hono as Hono20 } from "hono";
28773
28777
  import { getCookie, setCookie } from "hono/cookie";
28774
28778
  import crypto5 from "node:crypto";
@@ -28961,7 +28965,7 @@ function authMiddleware() {
28961
28965
  }
28962
28966
  var TOKEN_MAX_AGE, REFRESH_AFTER, COOKIE_NAME, ADMIN_LOGIN_BUCKET, isLockedOut2, recordFailure2, clearFailures2, PUBLIC_PATHS;
28963
28967
  var init_auth = __esm({
28964
- "packages/server/dist/middleware/auth.js"() {
28968
+ "../server/dist/middleware/auth.js"() {
28965
28969
  "use strict";
28966
28970
  init_config();
28967
28971
  init_password_hash();
@@ -28978,7 +28982,7 @@ var init_auth = __esm({
28978
28982
  }
28979
28983
  });
28980
28984
 
28981
- // packages/server/dist/index.js
28985
+ // ../server/dist/index.js
28982
28986
  var dist_exports = {};
28983
28987
  import { Hono as Hono21 } from "hono";
28984
28988
  import { cors } from "hono/cors";
@@ -29106,7 +29110,7 @@ async function gracefulShutdown(signal) {
29106
29110
  }
29107
29111
  var __dirname3, PORT, HALO_VERSION, PROJECT_ROOT, HALO_HOME4, GIT_SHA, AGENTCORE, app, allowlist, authRoutes, fileRoutes, dataPreviewRoutes, gitRoutes, agentConfigRoutes, skillRoutes, settingsRoutes, evolutionRoutes, cronRoutes, channelDb, registry, sessionRoutes, sessionArchiveRoutes, showRoutes, metricsRoutes, commandRoutes, FRONTEND_DIR, server, wss;
29108
29112
  var init_dist2 = __esm({
29109
- async "packages/server/dist/index.js"() {
29113
+ async "../server/dist/index.js"() {
29110
29114
  "use strict";
29111
29115
  init_files();
29112
29116
  init_data_preview();
@@ -29144,7 +29148,7 @@ var init_dist2 = __esm({
29144
29148
  init_git_ssh();
29145
29149
  __dirname3 = path64.dirname(fileURLToPath3(import.meta.url));
29146
29150
  PORT = config.server.port;
29147
- HALO_VERSION = "1.1.4";
29151
+ HALO_VERSION = "1.1.6";
29148
29152
  PROJECT_ROOT = findProjectRoot();
29149
29153
  HALO_HOME4 = path64.join(homedir24(), ".halo");
29150
29154
  GIT_SHA = readGitSha();
@@ -29321,7 +29325,7 @@ var init_dist2 = __esm({
29321
29325
  }
29322
29326
  });
29323
29327
 
29324
- // packages/acp-adapter/dist/halo-client.js
29328
+ // ../acp-adapter/dist/halo-client.js
29325
29329
  async function safeText(res) {
29326
29330
  try {
29327
29331
  return (await res.text()).slice(0, 500);
@@ -29364,7 +29368,7 @@ async function* parseSseStream(body) {
29364
29368
  }
29365
29369
  var HaloClient;
29366
29370
  var init_halo_client = __esm({
29367
- "packages/acp-adapter/dist/halo-client.js"() {
29371
+ "../acp-adapter/dist/halo-client.js"() {
29368
29372
  "use strict";
29369
29373
  HaloClient = class {
29370
29374
  opts;
@@ -29443,7 +29447,7 @@ var init_halo_client = __esm({
29443
29447
  }
29444
29448
  });
29445
29449
 
29446
- // packages/acp-adapter/dist/adapter.js
29450
+ // ../acp-adapter/dist/adapter.js
29447
29451
  function newError(message, code = -32603) {
29448
29452
  const e = new Error(message);
29449
29453
  e.code = code;
@@ -29451,7 +29455,7 @@ function newError(message, code = -32603) {
29451
29455
  }
29452
29456
  var AcpAdapter;
29453
29457
  var init_adapter = __esm({
29454
- "packages/acp-adapter/dist/adapter.js"() {
29458
+ "../acp-adapter/dist/adapter.js"() {
29455
29459
  "use strict";
29456
29460
  init_halo_client();
29457
29461
  AcpAdapter = class {
@@ -29740,10 +29744,10 @@ var init_adapter = __esm({
29740
29744
  }
29741
29745
  });
29742
29746
 
29743
- // packages/acp-adapter/dist/jsonrpc.js
29747
+ // ../acp-adapter/dist/jsonrpc.js
29744
29748
  var ERROR_PARSE, ERROR_METHOD_NOT_FOUND, ERROR_INTERNAL, JsonRpcConnection;
29745
29749
  var init_jsonrpc = __esm({
29746
- "packages/acp-adapter/dist/jsonrpc.js"() {
29750
+ "../acp-adapter/dist/jsonrpc.js"() {
29747
29751
  "use strict";
29748
29752
  ERROR_PARSE = -32700;
29749
29753
  ERROR_METHOD_NOT_FOUND = -32601;
@@ -29876,7 +29880,7 @@ var init_jsonrpc = __esm({
29876
29880
  }
29877
29881
  });
29878
29882
 
29879
- // packages/acp-adapter/dist/index.js
29883
+ // ../acp-adapter/dist/index.js
29880
29884
  var dist_exports2 = {};
29881
29885
  __export(dist_exports2, {
29882
29886
  main: () => main
@@ -29992,7 +29996,7 @@ function main(argv = process.argv.slice(2)) {
29992
29996
  }
29993
29997
  var HELP;
29994
29998
  var init_dist3 = __esm({
29995
- "packages/acp-adapter/dist/index.js"() {
29999
+ "../acp-adapter/dist/index.js"() {
29996
30000
  "use strict";
29997
30001
  init_adapter();
29998
30002
  init_jsonrpc();
@@ -30031,7 +30035,7 @@ Stdio:
30031
30035
  }
30032
30036
  });
30033
30037
 
30034
- // packages/cli/src/silence-warnings.ts
30038
+ // src/silence-warnings.ts
30035
30039
  var emit = process.emitWarning.bind(process);
30036
30040
  process.emitWarning = (warning, ...args) => {
30037
30041
  const opt = args[0];
@@ -30040,13 +30044,13 @@ process.emitWarning = (warning, ...args) => {
30040
30044
  return emit(warning, ...args);
30041
30045
  };
30042
30046
 
30043
- // packages/cli/src/index.ts
30047
+ // src/index.ts
30044
30048
  init_server_supervisor();
30045
30049
  import path65 from "node:path";
30046
30050
  import fs58 from "node:fs";
30047
30051
  import { homedir as homedir25 } from "node:os";
30048
30052
  import { parseArgs as parseArgs2 } from "node:util";
30049
- var VERSION = "1.1.4";
30053
+ var VERSION = "1.1.6";
30050
30054
  var HELP_TOP = `Usage: halo <command> [options]
30051
30055
 
30052
30056
  Commands: