@openchamber/web 1.22.1 → 1.22.2
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/bin/cli.js +4 -1
- package/bin/cli.test.js +92 -0
- package/bin/lib/cli-startup.js +49 -0
- package/bin/lib/commands-startup.js +41 -6
- package/dist/assets/{CodeMirrorCommentWidgets-BO_2OW4E.js → CodeMirrorCommentWidgets-BI-TY1UG.js} +1 -1
- package/dist/assets/{DiffView-CNnDxRmO.js → DiffView-cOmByCaX.js} +3 -3
- package/dist/assets/{DirtyBranchSwitchDialog-jADfXQnR.js → DirtyBranchSwitchDialog-BwSnDlNy.js} +1 -1
- package/dist/assets/FilesView-DRRy_6oZ.js +17 -0
- package/dist/assets/{GitView-Cv2xH-S6.js → GitView-B7YCg1YM.js} +4 -4
- package/dist/assets/{JsonTreeView-DUiIpERC.js → JsonTreeView-CjzNsiIU.js} +1 -1
- package/dist/assets/{LinearIssuesView-CoZ7pQN5.js → LinearIssuesView-BYlE0YrW.js} +1 -1
- package/dist/assets/{MarkdownImageGallery-DffjmciG.js → MarkdownImageGallery-DlTF-wua.js} +1 -1
- package/dist/assets/MarkdownRendererImpl-CqgeZRlP.js +12 -0
- package/dist/assets/{OnboardingScreen-CTZe6HZn.js → OnboardingScreen-BsJU7oav.js} +1 -1
- package/dist/assets/{PatchDiff-BymkP9JA.js → PatchDiff-CDNu968J.js} +1 -1
- package/dist/assets/{PierreDiffViewer-BvwtCxW4.js → PierreDiffViewer-BoBsAanf.js} +1 -1
- package/dist/assets/{PlanView-C1qvAm7m.js → PlanView-Cxr8LQT1.js} +4 -4
- package/dist/assets/SettingsView-bsKpCZbB.js +28 -0
- package/dist/assets/{SettingsWindow-COzgfFxM.js → SettingsWindow-B0rHQdw4.js} +1 -1
- package/dist/assets/{ToolOutputDialog-Dlhh_-oe.js → ToolOutputDialog-6zP8hwzX.js} +6 -6
- package/dist/assets/{ToolPartDiffPreview-b9joNtXH.js → ToolPartDiffPreview-Bvwh4Y31.js} +2 -2
- package/dist/assets/{VirtualizedFileDiff-vqW3KKo5.js → VirtualizedFileDiff-aaIfrRxl.js} +1 -1
- package/dist/assets/{WalkthroughView-D-HFgdmM.js → WalkthroughView-baZ0ssy9.js} +2 -2
- package/dist/assets/{computeVirtualFileMetrics-DUnyszhW.js → computeVirtualFileMetrics-DfgllYQc.js} +2 -2
- package/dist/assets/{contextPanelEmbeddedChat-CV-DwAiX.js → contextPanelEmbeddedChat-prHos-tt.js} +1 -1
- package/dist/assets/{de-Cv_4FoXm.js → de-hknQLFxa.js} +2 -2
- package/dist/assets/{es-BIWNEbnS.js → es-C_bD3kvW.js} +2 -2
- package/dist/assets/{fr-SD3OfMHJ.js → fr-BVF-C2Nu.js} +2 -2
- package/dist/assets/index-B0aX0JeI.js +39 -0
- package/dist/assets/{index-DLiD86ge.js → index-DUwZ2cWA.js} +1 -1
- package/dist/assets/index-Dl3xbAB_.css +1 -0
- package/dist/assets/{isDiffPlainText-TNageFjy.js → isDiffPlainText-COIS9Df5.js} +1 -1
- package/dist/assets/{isFilePlainText-JPmZOYSp.js → isFilePlainText-D7LEG-KY.js} +1 -1
- package/dist/assets/{ja-D7I9HofF.js → ja-B2G5hD59.js} +2 -2
- package/dist/assets/{ko-BsVJM_PQ.js → ko-D6OrOdZ3.js} +2 -2
- package/dist/assets/main-BBuBZzoi.js +930 -0
- package/dist/assets/{main-DCB4JgVe.js → main-CwIEELQq.js} +2 -2
- package/dist/assets/{markdownCore-BoQVG5-a.js → markdownCore-BE_Hhps5.js} +2 -2
- package/dist/assets/{miniChat-BtV7N5OF.js → miniChat-CeXAoWiF.js} +2 -2
- package/dist/assets/{mobile-DZV_sfX7.js → mobile-ilq39yLQ.js} +2 -2
- package/dist/assets/{patchFileDiff-Chmiz6hq.js → patchFileDiff-DLky6SYr.js} +5 -5
- package/dist/assets/{pl-XR9Bs8Be.js → pl-CVroZXt1.js} +2 -2
- package/dist/assets/{pt-BR-Due4be8g.js → pt-BR-eH3onaIW.js} +2 -2
- package/dist/assets/{renderElectronMiniChatApp-8tXADjfl.js → renderElectronMiniChatApp-BsywqmJT.js} +2 -2
- package/dist/assets/{renderMobileApp-Cji7Hma5.js → renderMobileApp-CDun1795.js} +7 -7
- package/dist/assets/runtimeEndpointReset-DebJIo5U.js +17 -0
- package/dist/assets/{scheduledTasksApi-9e-UX6im.js → scheduledTasksApi-B0tChXQC.js} +1 -1
- package/dist/assets/{shikiHighlight-CRpCl7UT.js → shikiHighlight-DJSXdcG4.js} +1 -1
- package/dist/assets/tr-BvtU2tXS.js +7 -0
- package/dist/assets/{uk-COYh2BaN.js → uk-nu36iqFz.js} +2 -2
- package/dist/assets/{useAppFontEffects-CCgvcQ6u.js → useAppFontEffects-Bb1Zihd2.js} +134 -131
- package/dist/assets/useInlineCommentController-B8dQWRpH.js +2 -0
- package/dist/assets/{useRootScrollLock-KzOUytpn.js → useRootScrollLock-DrJ8gE-x.js} +1 -1
- package/dist/assets/{vendor-codemirror-language-data-BxpoC5Fp.js → vendor-codemirror-language-data-CNjvbb69.js} +2 -2
- package/dist/assets/vendor-zod-CK21ihK-.js +39 -0
- package/dist/assets/{web-components-B6QgbmTo.js → web-components-C06MmTcR.js} +1 -1
- package/dist/assets/{zh-CN-Cjk6lzhc.js → zh-CN-BClBzZ64.js} +2 -2
- package/dist/assets/{zh-TW-Dk0dOg03.js → zh-TW-CXtSqJHF.js} +2 -2
- package/dist/index.html +5 -5
- package/dist/mini-chat.html +4 -4
- package/dist/mobile.html +4 -4
- package/package.json +3 -3
- package/server/index.js +7 -1
- package/server/lib/changelog/update-notes.js +82 -0
- package/server/lib/changelog/update-notes.test.js +59 -0
- package/server/lib/fs/DOCUMENTATION.md +2 -0
- package/server/lib/fs/routes.js +32 -21
- package/server/lib/fs/routes.test.js +77 -0
- package/server/lib/git/service.js +10 -0
- package/server/lib/git/service.test.js +18 -0
- package/server/lib/message-queue/DOCUMENTATION.md +17 -7
- package/server/lib/message-queue/runtime.js +59 -7
- package/server/lib/message-queue/runtime.test.js +59 -3
- package/server/lib/opencode/DOCUMENTATION.md +8 -4
- package/server/lib/opencode/config-paths.test.js +116 -0
- package/server/lib/opencode/feature-routes-runtime.js +2 -0
- package/server/lib/opencode/input-history-scope.js +14 -0
- package/server/lib/opencode/plugins.js +2 -2
- package/server/lib/opencode/providers.js +44 -2
- package/server/lib/opencode/providers.test.js +131 -4
- package/server/lib/opencode/routes.js +4 -4
- package/server/lib/opencode/server-startup-runtime.js +1 -1
- package/server/lib/opencode/settings-helpers.js +28 -0
- package/server/lib/opencode/settings-helpers.test.js +177 -0
- package/server/lib/opencode/shared.js +4 -1
- package/server/lib/opencode/skill-routes.js +2 -1
- package/server/lib/opencode/snippets.js +1 -2
- package/server/lib/package-manager.js +3 -28
- package/server/lib/quota/utils/auth.js +1 -1
- package/server/lib/relay/host-client.test.js +9 -1
- package/server/lib/session-goal/DOCUMENTATION.md +20 -7
- package/server/lib/session-goal/runtime.js +76 -11
- package/server/lib/session-goal/runtime.test.js +426 -0
- package/server/lib/skills-catalog/DOCUMENTATION.md +1 -1
- package/server/lib/skills-catalog/install.js +3 -2
- package/server/lib/terminal/DOCUMENTATION.md +11 -7
- package/server/lib/terminal/runtime.js +150 -19
- package/server/lib/terminal/runtime.test.js +553 -26
- package/server/lib/terminal/shells.js +17 -0
- package/server/lib/terminal/shells.test.js +32 -1
- package/server/lib/walkthrough/routes.test.js +26 -5
- package/dist/assets/FilesView-8wdiG2mj.js +0 -17
- package/dist/assets/MarkdownRendererImpl-DxqdYDAx.js +0 -12
- package/dist/assets/SettingsView-xGONHFGS.js +0 -28
- package/dist/assets/index-CHUT_bDS.css +0 -1
- package/dist/assets/index-DDInLQDd.js +0 -40
- package/dist/assets/main-De8Z5w49.js +0 -928
- package/dist/assets/runtimeEndpointReset-gWt3Lb5D.js +0 -16
- package/dist/assets/tr-DBJcAv4y.js +0 -7
- package/dist/assets/useInlineCommentController-BkfXnjNZ.js +0 -2
- package/dist/assets/vendor-zod-DVWEh-IS.js +0 -39
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import express from 'express';
|
|
2
2
|
import { createProjectIdFromPath } from '../projects/project-id.js';
|
|
3
3
|
import fs from 'fs';
|
|
4
|
-
import os from 'os';
|
|
5
4
|
import path from 'path';
|
|
6
5
|
import {
|
|
7
6
|
buildDeferredRestartResponse,
|
|
8
7
|
} from './config-mutation-response.js';
|
|
9
8
|
import { getClaudeCliAuthStatus } from './claude-cli-auth.js';
|
|
9
|
+
import { OPENCODE_CONFIG_DIR } from './shared.js';
|
|
10
10
|
|
|
11
11
|
export const registerOpenCodeRoutes = (app, dependencies) => {
|
|
12
12
|
const {
|
|
@@ -807,7 +807,7 @@ ${desktopReturn ? `<a class="return" href="openchamber://focus/mcp-auth">Return
|
|
|
807
807
|
});
|
|
808
808
|
|
|
809
809
|
// Behavior / Global AGENTS.md endpoints
|
|
810
|
-
const AGENTS_MD_PATH = path.join(
|
|
810
|
+
const AGENTS_MD_PATH = path.join(OPENCODE_CONFIG_DIR, 'AGENTS.md');
|
|
811
811
|
const MAX_BEHAVIOR_PROMPT_SIZE = 1024 * 1024; // 1 MB
|
|
812
812
|
|
|
813
813
|
app.get('/api/behavior/agents-md', async (_req, res) => {
|
|
@@ -815,10 +815,10 @@ ${desktopReturn ? `<a class="return" href="openchamber://focus/mcp-auth">Return
|
|
|
815
815
|
try {
|
|
816
816
|
await fs.promises.access(AGENTS_MD_PATH);
|
|
817
817
|
} catch {
|
|
818
|
-
return res.json({ content: '', exists: false });
|
|
818
|
+
return res.json({ content: '', exists: false, path: AGENTS_MD_PATH });
|
|
819
819
|
}
|
|
820
820
|
const content = await fs.promises.readFile(AGENTS_MD_PATH, 'utf8');
|
|
821
|
-
return res.json({ content, exists: true });
|
|
821
|
+
return res.json({ content, exists: true, path: AGENTS_MD_PATH });
|
|
822
822
|
} catch (error) {
|
|
823
823
|
console.error('Failed to read AGENTS.md:', error);
|
|
824
824
|
return res.status(500).json({ error: 'Failed to read AGENTS.md' });
|
|
@@ -138,7 +138,7 @@ export const createServerStartupRuntime = (dependencies) => {
|
|
|
138
138
|
// Cover every signal a shell or dev harness may use to stop/restart us, so
|
|
139
139
|
// the managed OpenCode child is always torn down gracefully instead of
|
|
140
140
|
// orphaned: SIGINT/SIGQUIT (Ctrl+C/Ctrl+\), SIGTERM (kill/default), SIGHUP
|
|
141
|
-
// (terminal close), SIGUSR2 (nodemon restart
|
|
141
|
+
// (terminal close), SIGUSR2 (nodemon restart outside Windows).
|
|
142
142
|
process.on('SIGTERM', handleSignal);
|
|
143
143
|
process.on('SIGINT', handleSignal);
|
|
144
144
|
process.on('SIGQUIT', handleSignal);
|
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
import { isAgentMemoryFeatureAvailable } from '../agent-memory/feature-flag.js';
|
|
2
|
+
import {
|
|
3
|
+
DEFAULT_INPUT_HISTORY_LIMIT,
|
|
4
|
+
DEFAULT_INPUT_HISTORY_SCOPE,
|
|
5
|
+
isInputHistoryLimit,
|
|
6
|
+
isInputHistoryScope,
|
|
7
|
+
} from './input-history-scope.js';
|
|
2
8
|
|
|
3
9
|
export const createSettingsHelpers = (dependencies) => {
|
|
4
10
|
const {
|
|
@@ -140,6 +146,12 @@ export const createSettingsHelpers = (dependencies) => {
|
|
|
140
146
|
if (typeof candidate.themeVariant === 'string' && (candidate.themeVariant === 'light' || candidate.themeVariant === 'dark')) {
|
|
141
147
|
result.themeVariant = candidate.themeVariant;
|
|
142
148
|
}
|
|
149
|
+
if (typeof candidate.inputHistoryScope === 'string' && isInputHistoryScope(candidate.inputHistoryScope)) {
|
|
150
|
+
result.inputHistoryScope = candidate.inputHistoryScope;
|
|
151
|
+
}
|
|
152
|
+
if (isInputHistoryLimit(candidate.inputHistoryLimit)) {
|
|
153
|
+
result.inputHistoryLimit = candidate.inputHistoryLimit;
|
|
154
|
+
}
|
|
143
155
|
if (typeof candidate.useSystemTheme === 'boolean') {
|
|
144
156
|
result.useSystemTheme = candidate.useSystemTheme;
|
|
145
157
|
}
|
|
@@ -519,6 +531,12 @@ export const createSettingsHelpers = (dependencies) => {
|
|
|
519
531
|
if (typeof candidate.inputSpellcheckEnabled === 'boolean') {
|
|
520
532
|
result.inputSpellcheckEnabled = candidate.inputSpellcheckEnabled;
|
|
521
533
|
}
|
|
534
|
+
if (candidate.enterToSend === true || candidate.enterToSend === false) {
|
|
535
|
+
result.enterToSend = candidate.enterToSend;
|
|
536
|
+
}
|
|
537
|
+
if (candidate.enterToSendConfigured === true || candidate.enterToSendConfigured === false) {
|
|
538
|
+
result.enterToSendConfigured = candidate.enterToSendConfigured;
|
|
539
|
+
}
|
|
522
540
|
if (typeof candidate.showOpenCodeUpdateNotifications === 'boolean') {
|
|
523
541
|
result.showOpenCodeUpdateNotifications = candidate.showOpenCodeUpdateNotifications;
|
|
524
542
|
}
|
|
@@ -687,6 +705,12 @@ export const createSettingsHelpers = (dependencies) => {
|
|
|
687
705
|
result.gitChangesViewMode = mode;
|
|
688
706
|
}
|
|
689
707
|
}
|
|
708
|
+
if (typeof candidate.toolJsonViewMode === 'string') {
|
|
709
|
+
const mode = candidate.toolJsonViewMode.trim();
|
|
710
|
+
if (mode === 'summary' || mode === 'formatted' || mode === 'raw') {
|
|
711
|
+
result.toolJsonViewMode = mode;
|
|
712
|
+
}
|
|
713
|
+
}
|
|
690
714
|
if (typeof candidate.directoryShowHidden === 'boolean') {
|
|
691
715
|
result.directoryShowHidden = candidate.directoryShowHidden;
|
|
692
716
|
}
|
|
@@ -927,6 +951,8 @@ export const createSettingsHelpers = (dependencies) => {
|
|
|
927
951
|
const pwaAppName = normalizePwaAppName(settings?.pwaAppName, '');
|
|
928
952
|
const pwaOrientation = normalizePwaOrientation(settings?.pwaOrientation, 'system');
|
|
929
953
|
const mobileKeyboardMode = normalizeMobileKeyboardMode(settings?.mobileKeyboardMode, 'native');
|
|
954
|
+
const inputHistoryScope = sanitized.inputHistoryScope ?? DEFAULT_INPUT_HISTORY_SCOPE;
|
|
955
|
+
const inputHistoryLimit = sanitized.inputHistoryLimit ?? DEFAULT_INPUT_HISTORY_LIMIT;
|
|
930
956
|
|
|
931
957
|
return {
|
|
932
958
|
...sanitized,
|
|
@@ -937,6 +963,8 @@ export const createSettingsHelpers = (dependencies) => {
|
|
|
937
963
|
...(pwaAppName ? { pwaAppName } : {}),
|
|
938
964
|
pwaOrientation,
|
|
939
965
|
mobileKeyboardMode,
|
|
966
|
+
inputHistoryScope,
|
|
967
|
+
inputHistoryLimit,
|
|
940
968
|
securityScopedBookmarks: bookmarks,
|
|
941
969
|
pinnedDirectories: normalizeStringArray(settings.pinnedDirectories),
|
|
942
970
|
typographySizes: sanitizeTypographySizesPartial(settings.typographySizes),
|
|
@@ -1,8 +1,19 @@
|
|
|
1
|
+
import { execFileSync } from 'node:child_process';
|
|
2
|
+
import { mkdirSync, mkdtempSync, readdirSync, rmSync } from 'node:fs';
|
|
3
|
+
import { tmpdir } from 'node:os';
|
|
4
|
+
import { dirname, join } from 'node:path';
|
|
5
|
+
import { fileURLToPath, pathToFileURL } from 'node:url';
|
|
1
6
|
import { describe, expect, it } from 'vitest';
|
|
2
7
|
|
|
8
|
+
import {
|
|
9
|
+
DEFAULT_INPUT_HISTORY_LIMIT,
|
|
10
|
+
} from './input-history-scope.js';
|
|
3
11
|
import { createSettingsHelpers } from './settings-helpers.js';
|
|
4
12
|
import { createSettingsNormalizationRuntime } from './settings-normalization-runtime.js';
|
|
5
13
|
|
|
14
|
+
const testFilePath = fileURLToPath(import.meta.url);
|
|
15
|
+
const packagesWebDir = join(dirname(testFilePath), '..', '..', '..');
|
|
16
|
+
|
|
6
17
|
const createTestHelpers = () => createSettingsHelpers({
|
|
7
18
|
normalizePathForPersistence: (value) => value,
|
|
8
19
|
normalizeDirectoryPath: (value) => value,
|
|
@@ -58,6 +69,66 @@ const createTestHelpersWithRealSanitizers = () => {
|
|
|
58
69
|
};
|
|
59
70
|
|
|
60
71
|
describe('settings helpers', () => {
|
|
72
|
+
it('imports from the packed @openchamber/web tarball without escaping the published package', async () => {
|
|
73
|
+
const tempRoot = mkdtempSync(join(tmpdir(), 'settings-helpers-pack-'));
|
|
74
|
+
const packDir = join(tempRoot, 'pack');
|
|
75
|
+
const extractDir = join(tempRoot, 'extract');
|
|
76
|
+
|
|
77
|
+
try {
|
|
78
|
+
mkdirSync(packDir);
|
|
79
|
+
mkdirSync(extractDir);
|
|
80
|
+
execFileSync('npm', ['pack', '--silent', '--pack-destination', packDir], {
|
|
81
|
+
cwd: packagesWebDir,
|
|
82
|
+
stdio: 'pipe',
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
const tarballName = readdirSync(packDir).find((entry) => entry.endsWith('.tgz'));
|
|
86
|
+
expect(tarballName).toBeTruthy();
|
|
87
|
+
|
|
88
|
+
execFileSync('tar', ['-xzf', join(packDir, tarballName), '-C', extractDir], {
|
|
89
|
+
stdio: 'pipe',
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
const extractedModule = await import(
|
|
93
|
+
pathToFileURL(join(extractDir, 'package', 'server', 'lib', 'opencode', 'settings-helpers.js')).href
|
|
94
|
+
);
|
|
95
|
+
|
|
96
|
+
const helpers = extractedModule.createSettingsHelpers({
|
|
97
|
+
normalizePathForPersistence: (value) => value,
|
|
98
|
+
normalizeDirectoryPath: (value) => value,
|
|
99
|
+
normalizeTunnelBootstrapTtlMs: (value) => value,
|
|
100
|
+
normalizeTunnelSessionTtlMs: (value) => value,
|
|
101
|
+
normalizeTunnelProvider: (value) => value,
|
|
102
|
+
normalizeTunnelMode: (value) => value,
|
|
103
|
+
normalizeOptionalPath: (value) => value,
|
|
104
|
+
normalizeManagedRemoteTunnelHostname: (value) => value,
|
|
105
|
+
normalizeManagedRemoteTunnelPresets: () => undefined,
|
|
106
|
+
normalizeManagedRemoteTunnelPresetTokens: () => undefined,
|
|
107
|
+
sanitizeTypographySizesPartial: () => undefined,
|
|
108
|
+
normalizeStringArray: (input) => input,
|
|
109
|
+
sanitizeModelRefs: () => undefined,
|
|
110
|
+
sanitizeSkillCatalogs: () => undefined,
|
|
111
|
+
sanitizeProjects: () => undefined,
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
expect(helpers.sanitizeSettingsUpdate({ inputHistoryScope: 'global' })).toEqual({
|
|
115
|
+
inputHistoryScope: 'global',
|
|
116
|
+
});
|
|
117
|
+
expect(helpers.sanitizeSettingsUpdate({ inputHistoryScope: 'session' })).toEqual({
|
|
118
|
+
inputHistoryScope: 'session',
|
|
119
|
+
});
|
|
120
|
+
expect(helpers.sanitizeSettingsUpdate({ inputHistoryLimit: 40 })).toEqual({
|
|
121
|
+
inputHistoryLimit: 40,
|
|
122
|
+
});
|
|
123
|
+
expect(helpers.formatSettingsResponse({})).toMatchObject({
|
|
124
|
+
inputHistoryScope: 'session',
|
|
125
|
+
inputHistoryLimit: DEFAULT_INPUT_HISTORY_LIMIT,
|
|
126
|
+
});
|
|
127
|
+
} finally {
|
|
128
|
+
rmSync(tempRoot, { recursive: true, force: true });
|
|
129
|
+
}
|
|
130
|
+
});
|
|
131
|
+
|
|
61
132
|
it('accepts only booleans for draft starter visibility', () => {
|
|
62
133
|
const helpers = createTestHelpers();
|
|
63
134
|
|
|
@@ -66,6 +137,14 @@ describe('settings helpers', () => {
|
|
|
66
137
|
expect(helpers.sanitizeSettingsUpdate({ draftStartersVisible: 'false' })).toEqual({});
|
|
67
138
|
});
|
|
68
139
|
|
|
140
|
+
it('sanitizes both Enter settings independently', () => {
|
|
141
|
+
const helpers = createTestHelpers();
|
|
142
|
+
|
|
143
|
+
expect(helpers.sanitizeSettingsUpdate({ enterToSend: true })).toEqual({ enterToSend: true });
|
|
144
|
+
expect(helpers.sanitizeSettingsUpdate({ enterToSendConfigured: false })).toEqual({ enterToSendConfigured: false });
|
|
145
|
+
expect(helpers.sanitizeSettingsUpdate({ enterToSend: 'true', enterToSendConfigured: 1 })).toEqual({});
|
|
146
|
+
});
|
|
147
|
+
|
|
69
148
|
it('sanitizes shared sidebar display preferences', () => {
|
|
70
149
|
const helpers = createTestHelpers();
|
|
71
150
|
|
|
@@ -88,6 +167,15 @@ describe('settings helpers', () => {
|
|
|
88
167
|
})).toEqual({});
|
|
89
168
|
});
|
|
90
169
|
|
|
170
|
+
it('persists valid tool JSON view modes', () => {
|
|
171
|
+
const helpers = createTestHelpers();
|
|
172
|
+
|
|
173
|
+
expect(helpers.sanitizeSettingsUpdate({ toolJsonViewMode: 'summary' })).toEqual({ toolJsonViewMode: 'summary' });
|
|
174
|
+
expect(helpers.sanitizeSettingsUpdate({ toolJsonViewMode: 'formatted' })).toEqual({ toolJsonViewMode: 'formatted' });
|
|
175
|
+
expect(helpers.sanitizeSettingsUpdate({ toolJsonViewMode: 'raw' })).toEqual({ toolJsonViewMode: 'raw' });
|
|
176
|
+
expect(helpers.sanitizeSettingsUpdate({ toolJsonViewMode: 'unknown' })).toEqual({});
|
|
177
|
+
});
|
|
178
|
+
|
|
91
179
|
it('accepts only booleans for wide chat layout', () => {
|
|
92
180
|
const helpers = createTestHelpers();
|
|
93
181
|
|
|
@@ -134,6 +222,74 @@ describe('settings helpers', () => {
|
|
|
134
222
|
expect(helpers.sanitizeSettingsUpdate({ messageStreamTransport: 'websocket' })).toEqual({});
|
|
135
223
|
});
|
|
136
224
|
|
|
225
|
+
it('accepts inputHistoryScope as a persisted shared setting', () => {
|
|
226
|
+
const helpers = createTestHelpers();
|
|
227
|
+
|
|
228
|
+
expect(helpers.sanitizeSettingsUpdate({ inputHistoryScope: 'global' })).toEqual({
|
|
229
|
+
inputHistoryScope: 'global',
|
|
230
|
+
});
|
|
231
|
+
expect(helpers.sanitizeSettingsUpdate({ inputHistoryScope: 'session' })).toEqual({
|
|
232
|
+
inputHistoryScope: 'session',
|
|
233
|
+
});
|
|
234
|
+
});
|
|
235
|
+
|
|
236
|
+
it('accepts valid inputHistoryLimit values as a persisted shared setting', () => {
|
|
237
|
+
const helpers = createTestHelpers();
|
|
238
|
+
|
|
239
|
+
expect(helpers.sanitizeSettingsUpdate({ inputHistoryLimit: 1 })).toEqual({
|
|
240
|
+
inputHistoryLimit: 1,
|
|
241
|
+
});
|
|
242
|
+
expect(helpers.sanitizeSettingsUpdate({ inputHistoryLimit: 40 })).toEqual({
|
|
243
|
+
inputHistoryLimit: 40,
|
|
244
|
+
});
|
|
245
|
+
expect(helpers.sanitizeSettingsUpdate({ inputHistoryLimit: 100 })).toEqual({
|
|
246
|
+
inputHistoryLimit: 100,
|
|
247
|
+
});
|
|
248
|
+
});
|
|
249
|
+
|
|
250
|
+
it('rejects invalid inputHistoryLimit values', () => {
|
|
251
|
+
const helpers = createTestHelpers();
|
|
252
|
+
|
|
253
|
+
expect(helpers.sanitizeSettingsUpdate({ inputHistoryLimit: 0 })).toEqual({});
|
|
254
|
+
expect(helpers.sanitizeSettingsUpdate({ inputHistoryLimit: 101 })).toEqual({});
|
|
255
|
+
expect(helpers.sanitizeSettingsUpdate({ inputHistoryLimit: 1.5 })).toEqual({});
|
|
256
|
+
expect(helpers.sanitizeSettingsUpdate({ inputHistoryLimit: '40' })).toEqual({});
|
|
257
|
+
expect(helpers.sanitizeSettingsUpdate({ inputHistoryLimit: Number.NaN })).toEqual({});
|
|
258
|
+
expect(helpers.sanitizeSettingsUpdate({ inputHistoryLimit: Number.POSITIVE_INFINITY })).toEqual({});
|
|
259
|
+
expect(helpers.sanitizeSettingsUpdate({ inputHistoryLimit: Number.NEGATIVE_INFINITY })).toEqual({});
|
|
260
|
+
});
|
|
261
|
+
|
|
262
|
+
it('rejects invalid inputHistoryScope values', () => {
|
|
263
|
+
const helpers = createTestHelpers();
|
|
264
|
+
|
|
265
|
+
expect(helpers.sanitizeSettingsUpdate({ inputHistoryScope: 'workspace' })).toEqual({});
|
|
266
|
+
});
|
|
267
|
+
|
|
268
|
+
it('defaults inputHistoryScope to session in formatted settings responses', () => {
|
|
269
|
+
const helpers = createTestHelpers();
|
|
270
|
+
|
|
271
|
+
expect(helpers.formatSettingsResponse({ inputHistoryScope: 'global' })).toMatchObject({
|
|
272
|
+
inputHistoryScope: 'global',
|
|
273
|
+
});
|
|
274
|
+
expect(helpers.formatSettingsResponse({})).toMatchObject({
|
|
275
|
+
inputHistoryScope: 'session',
|
|
276
|
+
});
|
|
277
|
+
});
|
|
278
|
+
|
|
279
|
+
it('defaults missing inputHistoryLimit to 40 in formatted settings responses and preserves valid values', () => {
|
|
280
|
+
const helpers = createTestHelpers();
|
|
281
|
+
|
|
282
|
+
expect(helpers.formatSettingsResponse({})).toMatchObject({
|
|
283
|
+
inputHistoryLimit: DEFAULT_INPUT_HISTORY_LIMIT,
|
|
284
|
+
});
|
|
285
|
+
expect(helpers.formatSettingsResponse({ inputHistoryLimit: 1 })).toMatchObject({
|
|
286
|
+
inputHistoryLimit: 1,
|
|
287
|
+
});
|
|
288
|
+
expect(helpers.formatSettingsResponse({ inputHistoryLimit: 100 })).toMatchObject({
|
|
289
|
+
inputHistoryLimit: 100,
|
|
290
|
+
});
|
|
291
|
+
});
|
|
292
|
+
|
|
137
293
|
it('sanitizes the persisted terminal shell', () => {
|
|
138
294
|
const helpers = createTestHelpers();
|
|
139
295
|
|
|
@@ -316,6 +472,27 @@ describe('settings helpers', () => {
|
|
|
316
472
|
});
|
|
317
473
|
});
|
|
318
474
|
|
|
475
|
+
it('accepts and rejects invalid Enter-to-send preference values', () => {
|
|
476
|
+
const helpers = createTestHelpers();
|
|
477
|
+
|
|
478
|
+
expect(helpers.sanitizeSettingsUpdate({ enterToSend: true, enterToSendConfigured: true })).toEqual({
|
|
479
|
+
enterToSend: true,
|
|
480
|
+
enterToSendConfigured: true,
|
|
481
|
+
});
|
|
482
|
+
expect(helpers.sanitizeSettingsUpdate({ enterToSend: false, enterToSendConfigured: true })).toEqual({
|
|
483
|
+
enterToSend: false,
|
|
484
|
+
enterToSendConfigured: true,
|
|
485
|
+
});
|
|
486
|
+
expect(helpers.sanitizeSettingsUpdate({ enterToSend: false, enterToSendConfigured: false })).toEqual({
|
|
487
|
+
enterToSend: false,
|
|
488
|
+
enterToSendConfigured: false,
|
|
489
|
+
});
|
|
490
|
+
expect(helpers.sanitizeSettingsUpdate({ enterToSend: 'true' })).toEqual({});
|
|
491
|
+
expect(helpers.sanitizeSettingsUpdate({ enterToSend: 1 })).toEqual({});
|
|
492
|
+
expect(helpers.sanitizeSettingsUpdate({ enterToSendConfigured: 'true' })).toEqual({});
|
|
493
|
+
expect(helpers.sanitizeSettingsUpdate({ enterToSendConfigured: 1 })).toEqual({});
|
|
494
|
+
});
|
|
495
|
+
|
|
319
496
|
it('accepts dismissed OpenCode update toast version as a persisted shared setting', () => {
|
|
320
497
|
const helpers = createTestHelpers();
|
|
321
498
|
|
|
@@ -6,7 +6,10 @@ import { parse as parseJsonc, printParseErrorCode } from 'jsonc-parser';
|
|
|
6
6
|
|
|
7
7
|
// ============== PATH CONSTANTS ==============
|
|
8
8
|
|
|
9
|
-
const OPENCODE_CONFIG_DIR = path.join(
|
|
9
|
+
const OPENCODE_CONFIG_DIR = path.join(
|
|
10
|
+
process.env.XDG_CONFIG_HOME?.trim() || path.join(os.homedir(), '.config'),
|
|
11
|
+
'opencode',
|
|
12
|
+
);
|
|
10
13
|
const AGENT_DIR = path.join(OPENCODE_CONFIG_DIR, 'agents');
|
|
11
14
|
const COMMAND_DIR = path.join(OPENCODE_CONFIG_DIR, 'commands');
|
|
12
15
|
const SKILL_DIR = path.join(OPENCODE_CONFIG_DIR, 'skills');
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { createOpencodeClient } from '@opencode-ai/sdk/v2';
|
|
2
2
|
import { buildDeferredRestartResponse } from './config-mutation-response.js';
|
|
3
|
+
import { OPENCODE_CONFIG_DIR } from './shared.js';
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
6
|
* Matches how OpenCode reads its own boolean env flags: any value other than
|
|
@@ -110,7 +111,7 @@ export const registerSkillRoutes = (app, dependencies) => {
|
|
|
110
111
|
}
|
|
111
112
|
|
|
112
113
|
const userRoots = [
|
|
113
|
-
|
|
114
|
+
OPENCODE_CONFIG_DIR,
|
|
114
115
|
path.join(home, '.opencode'),
|
|
115
116
|
path.join(home, '.claude', 'skills'),
|
|
116
117
|
path.join(home, '.agents', 'skills'),
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import fs from 'fs';
|
|
2
2
|
import path from 'path';
|
|
3
|
-
import os from 'os';
|
|
4
3
|
import yaml from 'yaml';
|
|
4
|
+
import { OPENCODE_CONFIG_DIR } from './shared.js';
|
|
5
5
|
|
|
6
|
-
const OPENCODE_CONFIG_DIR = path.join(os.homedir(), '.config', 'opencode');
|
|
7
6
|
const GLOBAL_SNIPPET_DIR = path.join(OPENCODE_CONFIG_DIR, 'snippet');
|
|
8
7
|
const GLOBAL_SNIPPET_DIR_ALT = path.join(OPENCODE_CONFIG_DIR, 'snippets');
|
|
9
8
|
const SNIPPET_EXTENSION = '.md';
|
|
@@ -4,6 +4,7 @@ import fs from 'fs';
|
|
|
4
4
|
import os from 'os';
|
|
5
5
|
import path from 'path';
|
|
6
6
|
import { fileURLToPath } from 'url';
|
|
7
|
+
import { fetchUpdateNotes } from './changelog/update-notes.js';
|
|
7
8
|
|
|
8
9
|
const __filename = fileURLToPath(import.meta.url);
|
|
9
10
|
const __dirname = path.dirname(__filename);
|
|
@@ -11,7 +12,6 @@ const __dirname = path.dirname(__filename);
|
|
|
11
12
|
const PACKAGE_NAME = '@openchamber/web';
|
|
12
13
|
const PACKAGE_PATH_SEGMENTS = PACKAGE_NAME.split('/');
|
|
13
14
|
const NPM_REGISTRY_URL = `https://registry.npmjs.org/${PACKAGE_NAME}`;
|
|
14
|
-
const CHANGELOG_URL = 'https://raw.githubusercontent.com/openchamber/openchamber/main/CHANGELOG.md';
|
|
15
15
|
const GITHUB_RELEASES_URL = 'https://github.com/openchamber/openchamber/releases';
|
|
16
16
|
const GITHUB_RELEASES_API_URL = 'https://api.github.com/repos/openchamber/openchamber/releases';
|
|
17
17
|
let cachedDetectedPm = null;
|
|
@@ -737,34 +737,9 @@ function compareVersions(left, right) {
|
|
|
737
737
|
return 0;
|
|
738
738
|
}
|
|
739
739
|
|
|
740
|
-
/**
|
|
741
|
-
* Fetch changelog notes between versions
|
|
742
|
-
*/
|
|
740
|
+
/** Release notes between the installed and the offered version, or undefined. */
|
|
743
741
|
async function fetchChangelogNotes(fromVersion, toVersion) {
|
|
744
|
-
|
|
745
|
-
const response = await fetch(CHANGELOG_URL, {
|
|
746
|
-
signal: AbortSignal.timeout(10000),
|
|
747
|
-
});
|
|
748
|
-
|
|
749
|
-
if (!response.ok) return undefined;
|
|
750
|
-
|
|
751
|
-
const changelog = await response.text();
|
|
752
|
-
const sections = changelog.split(/^## /m).slice(1);
|
|
753
|
-
|
|
754
|
-
const relevantSections = sections.filter((section) => {
|
|
755
|
-
const match = section.match(/^\[(\d+\.\d+\.\d+)\]/);
|
|
756
|
-
if (!match) return false;
|
|
757
|
-
return compareVersions(match[1], fromVersion) > 0 && compareVersions(match[1], toVersion) <= 0;
|
|
758
|
-
});
|
|
759
|
-
|
|
760
|
-
if (relevantSections.length === 0) return undefined;
|
|
761
|
-
|
|
762
|
-
return relevantSections
|
|
763
|
-
.map((s) => '## ' + s.trim())
|
|
764
|
-
.join('\n\n');
|
|
765
|
-
} catch {
|
|
766
|
-
return undefined;
|
|
767
|
-
}
|
|
742
|
+
return (await fetchUpdateNotes(fromVersion, toVersion, compareVersions)) ?? undefined;
|
|
768
743
|
}
|
|
769
744
|
|
|
770
745
|
export async function checkForUpdates(options = {}) {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import fs from 'fs';
|
|
2
2
|
import path from 'path';
|
|
3
3
|
import os from 'os';
|
|
4
|
+
import { OPENCODE_CONFIG_DIR } from '../../opencode/shared.js';
|
|
4
5
|
|
|
5
|
-
const OPENCODE_CONFIG_DIR = path.join(os.homedir(), '.config', 'opencode');
|
|
6
6
|
const OPENCODE_DATA_DIR = path.join(os.homedir(), '.local', 'share', 'opencode');
|
|
7
7
|
|
|
8
8
|
export const ANTIGRAVITY_ACCOUNTS_PATHS = [
|
|
@@ -98,6 +98,9 @@ const startFakeRelay = () => {
|
|
|
98
98
|
wsUrl: `ws://127.0.0.1:${port}`,
|
|
99
99
|
state,
|
|
100
100
|
stop: () => new Promise((r) => {
|
|
101
|
+
// A socket a failed test left open would hold server.close() until
|
|
102
|
+
// the hook timeout; drop them so a failure is reported once.
|
|
103
|
+
for (const client of wss.clients) client.terminate();
|
|
101
104
|
wss.close();
|
|
102
105
|
server.close(() => r());
|
|
103
106
|
}),
|
|
@@ -162,7 +165,6 @@ const runScriptedClient = async ({ relayUrl, serverId, hostEncPubJwk }) => {
|
|
|
162
165
|
url.searchParams.set('role', 'client');
|
|
163
166
|
url.searchParams.set('serverId', serverId);
|
|
164
167
|
url.searchParams.set('connectionId', connectionId);
|
|
165
|
-
const ws = new WebSocket(url.toString());
|
|
166
168
|
|
|
167
169
|
const hostPub = await globalThis.crypto.subtle.importKey(
|
|
168
170
|
'jwk',
|
|
@@ -182,6 +184,12 @@ const runScriptedClient = async ({ relayUrl, serverId, hostEncPubJwk }) => {
|
|
|
182
184
|
resolveDone = resolve;
|
|
183
185
|
});
|
|
184
186
|
|
|
187
|
+
// Dialed only now, with the key material ready and the listeners attached
|
|
188
|
+
// in the same tick. Dialing before the WebCrypto awaits above let a loopback
|
|
189
|
+
// socket open while the key generation was still queued on the threadpool,
|
|
190
|
+
// and an `open` event with no listener means no hello, no ready, and a
|
|
191
|
+
// client that waits forever. Loaded CI runners hit exactly that.
|
|
192
|
+
const ws = new WebSocket(url.toString());
|
|
185
193
|
ws.on('open', async () => {
|
|
186
194
|
ws.send(JSON.stringify({
|
|
187
195
|
t: 'hello',
|
|
@@ -108,13 +108,26 @@ before touching the filesystem). Rationale: metadata rides every
|
|
|
108
108
|
stop), with a tick-side safety net. Messages sent while paused leave
|
|
109
109
|
the goal alone; Resume re-arms the loop, and resuming over an aborted
|
|
110
110
|
tail skips the audit and goes straight to a continuation nudge;
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
111
|
+
- terminal checks, cheapest first: assistant turn error → `blocked`;
|
|
112
|
+
`tokensUsed >= tokenBudget` → `budgetLimited`;
|
|
113
|
+
`turnsUsed >= MAX_AUTO_TURNS` (20) → `blocked`;
|
|
114
|
+
- error classification is independent of `finish`: `MessageAbortedError`
|
|
115
|
+
keeps the pause/resume behavior; only a `finish: "length"` with no
|
|
116
|
+
error, or `MessageOutputLengthError`, is an in-progress truncation that
|
|
117
|
+
skips the audit and continues. Any other non-null error wins over a
|
|
118
|
+
length finish and blocks with its non-empty `error.name`, or
|
|
119
|
+
`assistant turn failed` when unnamed;
|
|
120
|
+
- length recovery is bounded separately from the token budget and
|
|
121
|
+
auto-continuation cap: the first truncation permits one continuation, but
|
|
122
|
+
a second consecutive completed, non-summary assistant turn that is also
|
|
123
|
+
truncated settles the goal as `blocked` (`repeated output truncation`).
|
|
124
|
+
The consecutive state is derived from the loaded message history, not
|
|
125
|
+
persisted, using `info.time.created` chronology rather than message IDs.
|
|
126
|
+
Summary messages are not agent turns; an ordinary completed assistant
|
|
127
|
+
turn naturally breaks the consecutive condition. Explicit Resume grants
|
|
128
|
+
one new recovery attempt over the same transcript; the continuation
|
|
129
|
+
consumes that permission, so another truncation blocks again. Resume
|
|
130
|
+
does not bypass assistant errors or the token budget;
|
|
118
131
|
- otherwise, small-model audit of the objective + the last assistant turn
|
|
119
132
|
only — no conversation history and no continuation prompts
|
|
120
133
|
(`restrictToPreferredProvider`, session's own provider/model preferred):
|
|
@@ -244,6 +244,57 @@ const messageTokenTotal = (info) => {
|
|
|
244
244
|
return input + cachedRead + output;
|
|
245
245
|
};
|
|
246
246
|
|
|
247
|
+
const getErrorName = (error) => error?.name?.trim?.() ?? '';
|
|
248
|
+
|
|
249
|
+
const isLengthTruncated = (info, errorName = getErrorName(info?.error)) => {
|
|
250
|
+
const error = info?.error;
|
|
251
|
+
const hasError = error !== null && error !== undefined;
|
|
252
|
+
return errorName === 'MessageOutputLengthError' || (!hasError && info?.finish === 'length');
|
|
253
|
+
};
|
|
254
|
+
|
|
255
|
+
// Summary messages are assistant-shaped, but they are compaction turns rather
|
|
256
|
+
// than agent turns. They must not break or satisfy the consecutive truncation
|
|
257
|
+
// check; only completed, non-summary assistant turns participate. Chronology
|
|
258
|
+
// comes from `time.created`, never from message IDs; array position is only a
|
|
259
|
+
// tie-breaker for equal timestamps.
|
|
260
|
+
const hasRepeatedLengthTail = (messages, latestAssistant, goalCreatedAt) => {
|
|
261
|
+
const latestInfo = latestAssistant?.info;
|
|
262
|
+
if (latestInfo?.summary === true) return false;
|
|
263
|
+
const latestIndex = messages.indexOf(latestAssistant);
|
|
264
|
+
const latestCreated = latestInfo?.time?.created;
|
|
265
|
+
if (
|
|
266
|
+
latestIndex < 0
|
|
267
|
+
|| !(latestInfo?.time?.completed > 0)
|
|
268
|
+
|| !(Number.isFinite(latestCreated) && latestCreated > 0)
|
|
269
|
+
|| !isLengthTruncated(latestInfo)
|
|
270
|
+
) return false;
|
|
271
|
+
|
|
272
|
+
let previous = null;
|
|
273
|
+
for (let i = 0; i < messages.length; i += 1) {
|
|
274
|
+
const info = messages[i]?.info;
|
|
275
|
+
if (info?.role !== 'assistant' || info.summary === true || !(info.time?.completed > 0)) continue;
|
|
276
|
+
const created = info.time?.created;
|
|
277
|
+
// An unknown timestamp cannot safely participate in chronology. Ignore it
|
|
278
|
+
// rather than letting an unrelated older message hide known chronology.
|
|
279
|
+
if (!(Number.isFinite(created) && created > 0)) continue;
|
|
280
|
+
if (i === latestIndex) continue;
|
|
281
|
+
if (created > latestCreated || (created === latestCreated && i > latestIndex)) continue;
|
|
282
|
+
if (
|
|
283
|
+
!previous
|
|
284
|
+
|| created > previous.created
|
|
285
|
+
|| (created === previous.created && i > previous.index)
|
|
286
|
+
) {
|
|
287
|
+
previous = { info, created, index: i };
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
return Boolean(
|
|
292
|
+
previous
|
|
293
|
+
&& previous.created > goalCreatedAt
|
|
294
|
+
&& isLengthTruncated(previous.info),
|
|
295
|
+
);
|
|
296
|
+
};
|
|
297
|
+
|
|
247
298
|
export const createSessionGoalRuntime = ({
|
|
248
299
|
buildOpenCodeUrl,
|
|
249
300
|
getOpenCodeAuthHeaders,
|
|
@@ -609,7 +660,11 @@ export const createSessionGoalRuntime = ({
|
|
|
609
660
|
// resumed over an aborted tail: that is an explicit "keep going", so it
|
|
610
661
|
// falls through to the continuation below (skipping the audit — an
|
|
611
662
|
// aborted reply is not evidence of anything).
|
|
612
|
-
const
|
|
663
|
+
const error = lastAssistantInfo.error;
|
|
664
|
+
const errorName = getErrorName(error);
|
|
665
|
+
const hasError = error !== null && error !== undefined;
|
|
666
|
+
const abortedTail = errorName === 'MessageAbortedError';
|
|
667
|
+
const lengthTail = isLengthTruncated(lastAssistantInfo, errorName);
|
|
613
668
|
if (abortedTail && goal.statusReason !== 'resumed') {
|
|
614
669
|
await writeGoal(sessionId, directory, goal.id, () => ({
|
|
615
670
|
status: 'paused',
|
|
@@ -623,13 +678,12 @@ export const createSessionGoalRuntime = ({
|
|
|
623
678
|
return;
|
|
624
679
|
}
|
|
625
680
|
|
|
626
|
-
//
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
: 'assistant turn failed';
|
|
681
|
+
// Non-length turn error → blocked (prevents runaway auto-continuation into
|
|
682
|
+
// failures). Recognized length cutoffs are in-progress continuations, not
|
|
683
|
+
// hard failures.
|
|
684
|
+
if (!abortedTail && !lengthTail && hasError) {
|
|
631
685
|
await settleGoal({
|
|
632
|
-
sessionId, directory, goal, status: 'blocked', statusReason:
|
|
686
|
+
sessionId, directory, goal, status: 'blocked', statusReason: errorName || 'assistant turn failed', tokensUsed, tokensBaseline, tokensCommitted, lastAccountedMessageID,
|
|
633
687
|
});
|
|
634
688
|
return;
|
|
635
689
|
}
|
|
@@ -650,17 +704,28 @@ export const createSessionGoalRuntime = ({
|
|
|
650
704
|
return;
|
|
651
705
|
}
|
|
652
706
|
|
|
707
|
+
// A second consecutive completed, non-summary length-truncated turn is a
|
|
708
|
+
// bounded recovery failure. Derive this from the loaded transcript rather
|
|
709
|
+
// than persisting another goal counter.
|
|
710
|
+
if (lengthTail && goal.statusReason !== 'resumed' && hasRepeatedLengthTail(messages, lastAssistant, goal.createdAt)) {
|
|
711
|
+
await settleGoal({
|
|
712
|
+
sessionId, directory, goal, status: 'blocked', statusReason: 'repeated output truncation', tokensUsed, tokensBaseline, tokensCommitted, lastAccountedMessageID,
|
|
713
|
+
});
|
|
714
|
+
return;
|
|
715
|
+
}
|
|
716
|
+
|
|
653
717
|
// --- Small-model audit: the sole termination authority besides the hard
|
|
654
718
|
// stops above (turn error, budget, continuation cap). The working agent
|
|
655
719
|
// has no channel to settle its own goal.
|
|
656
720
|
//
|
|
657
|
-
// Exception: when the latest message is a compaction summary
|
|
658
|
-
// by
|
|
659
|
-
// "in progress, not finished".
|
|
721
|
+
// Exception: when the latest message is a compaction summary or was cut off
|
|
722
|
+
// by the output token limit (length stop), the agent by definition ran into
|
|
723
|
+
// the context/output limit mid-work — that IS "in progress, not finished".
|
|
724
|
+
// No audit call; continue unconditionally.
|
|
660
725
|
let audit = null;
|
|
661
726
|
let blockedStreak = 0;
|
|
662
727
|
let auditFailStreak = goal.auditFailStreak;
|
|
663
|
-
if (lastAssistantInfo.summary === true || abortedTail) {
|
|
728
|
+
if (lastAssistantInfo.summary === true || abortedTail || lengthTail) {
|
|
664
729
|
blockedStreak = goal.blockedStreak;
|
|
665
730
|
} else {
|
|
666
731
|
audit = await runAudit({ goal: { ...goal, objective: effectiveObjective }, assistantText, directory, lastAssistantInfo: executionInfo ?? lastAssistantInfo });
|