@oar-sh/oar 0.9.7 → 0.9.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. package/CHANGELOG.md +113 -0
  2. package/README.md +46 -18
  3. package/bin/oar.js +320 -18
  4. package/package.json +1 -1
  5. package/server/claude-worker/claude-sdk-adapter.mjs +0 -11
  6. package/server/claude-worker/claude-session-process.mjs +196 -28
  7. package/server/claude-worker/sdk-message-normalizer.mjs +28 -0
  8. package/server/public/app/activity-replay-state.mjs +68 -5
  9. package/server/public/app/api-client.js +6 -2
  10. package/server/public/app/bootstrap.js +124 -57
  11. package/server/public/app/context-usage-view.mjs +127 -8
  12. package/server/public/app/conversation-view.js +62 -7
  13. package/server/public/app/pwa-install.js +5 -0
  14. package/server/public/app/scrollbar-hover.mjs +78 -0
  15. package/server/public/app/settings-modal.js +4 -1
  16. package/server/public/app/socket-handlers.js +2 -1
  17. package/server/public/app/store.js +26 -0
  18. package/server/public/app/transcript-separators.mjs +48 -11
  19. package/server/public/app-icon-192.png +0 -0
  20. package/server/public/app-icon-512.png +0 -0
  21. package/server/public/app-icon-light-192.png +0 -0
  22. package/server/public/app-icon-light-512.png +0 -0
  23. package/server/public/app-icon-light-maskable-512.png +0 -0
  24. package/server/public/app-icon-light.svg +4 -0
  25. package/server/public/app-icon-maskable-512.png +0 -0
  26. package/server/public/app-icon.svg +3 -3
  27. package/server/public/favicon.ico +0 -0
  28. package/server/public/index.html +183 -13
  29. package/server/public/manifest.webmanifest +9 -3
  30. package/server/public/sw.js +6 -1
  31. package/server/routes/messages-routes.mjs +3 -1
  32. package/server/routes/sessions-routes.mjs +15 -2
  33. package/server/server-runtime.mjs +10 -8
  34. package/server/services/claude-context-usage.mjs +51 -3
  35. package/server/services/oar-cli-helpers.mjs +67 -1
  36. package/server/services/pwa-manifest-theme.mjs +30 -0
  37. package/server/services/session-worker-registry-service.mjs +18 -1
  38. package/server/services/update-install-service.mjs +9 -3
@@ -82,6 +82,19 @@ function normalizeSteeringCancellableIds(raw) {
82
82
  return ids;
83
83
  }
84
84
 
85
+ // The Claude worker's running CLI: the compaction window it was spawned with
86
+ // (a token count, null = Auto) and whether background work holds it, which
87
+ // blocks the respawn that applies a changed window. Null when no CLI runs or
88
+ // the worker does not report it.
89
+ function normalizeSteeringAutoCompactWindow(raw) {
90
+ if (!raw || typeof raw !== 'object') return null;
91
+ const active = Number(raw.active);
92
+ return {
93
+ active: Number.isFinite(active) && active > 0 ? Math.round(active) : null,
94
+ backgroundWork: raw.backgroundWork === true,
95
+ };
96
+ }
97
+
85
98
  // The worker's composer-facing steering snapshot, published on its heartbeat.
86
99
  // Callers follow the registry convention of spreading the existing entry into
87
100
  // upserts, so an update without `steering` keeps the last known snapshot.
@@ -98,7 +111,7 @@ export function normalizeWorkerSteeringSnapshot(raw) {
98
111
  if (!raw || typeof raw !== 'object') return null;
99
112
  const holdReason = String(raw.holdReason || '').trim().toLowerCase();
100
113
  const messageId = String(raw.messageId || '').trim().slice(0, STEERING_MESSAGE_ID_MAX_LENGTH);
101
- return {
114
+ const snapshot = {
102
115
  turnActive: raw.turnActive === true,
103
116
  canSteer: raw.canSteer === true,
104
117
  holdReason: STEERING_HOLD_REASONS.has(holdReason) ? holdReason : null,
@@ -106,6 +119,10 @@ export function normalizeWorkerSteeringSnapshot(raw) {
106
119
  supported: raw.supported === true,
107
120
  cancellableIds: normalizeSteeringCancellableIds(raw.cancellableIds),
108
121
  };
122
+ // Only a snapshot that reports a running CLI carries the key.
123
+ const autoCompactWindow = normalizeSteeringAutoCompactWindow(raw.autoCompactWindow);
124
+ if (autoCompactWindow) snapshot.autoCompactWindow = autoCompactWindow;
125
+ return snapshot;
109
126
  }
110
127
 
111
128
  function sanitizeState(raw = null) {
@@ -1,6 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  import { spawn as defaultSpawn } from 'child_process';
4
+ import fs from 'fs';
4
5
 
5
6
  import {
6
7
  CLI_SPAWN_DISABLED_ERROR,
@@ -10,6 +11,7 @@ import {
10
11
  stripTerminalEscapes,
11
12
  tailOf,
12
13
  } from './cli-process-runner.mjs';
14
+ import { NPM_ALLOW_SCRIPTS_ARG, resolveNpmInvocation } from './oar-cli-helpers.mjs';
13
15
  import { compareSemverIsh, parseSemverIsh } from '../../shared/update-semver.mjs';
14
16
 
15
17
  // Applies an OAR self-update: `npm i -g @oar-sh/oar@<version>` with the log
@@ -99,6 +101,9 @@ export function readUpdateOutcome(readSetting) {
99
101
  export function createUpdateInstallService({
100
102
  runningVersion,
101
103
  installMethod = 'npm-global',
104
+ packageRoot = '',
105
+ execPath = process.execPath,
106
+ existsImpl = fs.existsSync,
102
107
  spawnImpl = defaultSpawn,
103
108
  env = process.env,
104
109
  platform = process.platform,
@@ -204,12 +209,13 @@ export function createUpdateInstallService({
204
209
 
205
210
  // npm itself is a shim on Windows; spawn npm.cmd through a shell there
206
211
  // (args are fixed strings + a validated semver, so no injection surface).
207
- const command = platform === 'win32' ? 'npm.cmd' : 'npm';
208
- const args = ['install', '-g', `${UPDATE_PACKAGE_NAME}@${target}`];
212
+ const npm = resolveNpmInvocation({ execPath, packageRoot, platform, env, existsImpl });
213
+ const command = npm.command;
214
+ const args = ['install', '-g', ...npm.prefixArgs, NPM_ALLOW_SCRIPTS_ARG, `${UPDATE_PACKAGE_NAME}@${target}`];
209
215
  const result = await runToCompletion(
210
216
  () => spawnImpl(command, args, {
211
217
  stdio: ['ignore', 'pipe', 'pipe'],
212
- env: { ...env },
218
+ env: npm.env,
213
219
  ...(platform === 'win32' ? { windowsHide: true, shell: true } : { detached: true }),
214
220
  }),
215
221
  {