@orion-agents/orion-code 0.4.7 → 0.4.9
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/CHANGELOG.md +17 -1
- package/README.md +8 -9
- package/README.zh-CN.md +8 -8
- package/dist/acp/session-updates.js +1 -0
- package/dist/cli.js +42 -3
- package/dist/commands/session-command-handlers.js +8 -3
- package/dist/commands/system-commands.js +3 -3
- package/dist/commands/types.d.ts +3 -0
- package/dist/framework/loop-progress.js +3 -1
- package/dist/framework/query.d.ts +6 -8
- package/dist/framework/query.js +39 -76
- package/dist/framework/tool-serializer.d.ts +12 -0
- package/dist/framework/tool-serializer.js +35 -0
- package/dist/framework/tool.d.ts +2 -0
- package/dist/framework/verification-command.d.ts +21 -0
- package/dist/framework/verification-command.js +53 -4
- package/dist/harness/context-harness.d.ts +3 -9
- package/dist/harness/context-harness.js +43 -163
- package/dist/harness/ledger.js +2 -1
- package/dist/harness/state.d.ts +3 -0
- package/dist/harness/state.js +37 -4
- package/dist/harness/task-checklist.d.ts +1 -1
- package/dist/harness/task-checklist.js +1 -1
- package/dist/harness/types.d.ts +1 -0
- package/dist/harness/verification.js +5 -4
- package/dist/print-ui/delivery.d.ts +15 -0
- package/dist/print-ui/delivery.js +131 -0
- package/dist/print-ui/event-stream.d.ts +6 -1
- package/dist/print-ui/event-stream.js +56 -10
- package/dist/print-ui/launch.d.ts +5 -0
- package/dist/print-ui/launch.js +66 -9
- package/dist/runtime/agent-loop.d.ts +3 -1
- package/dist/runtime/agent-loop.js +26 -41
- package/dist/runtime/agent-runtime-controller.d.ts +4 -1
- package/dist/runtime/agent-runtime-controller.js +36 -22
- package/dist/runtime/agent-runtime-runner.d.ts +4 -0
- package/dist/runtime/agent-runtime-runner.js +9 -0
- package/dist/runtime/builtin-tool-provider.js +6 -5
- package/dist/runtime/composer/layout.d.ts +1 -1
- package/dist/runtime/composer/layout.js +5 -5
- package/dist/runtime/core-tools/descriptors.d.ts +1 -1
- package/dist/runtime/core-tools/descriptors.js +39 -1
- package/dist/runtime/first-party-core-provider.js +1 -0
- package/dist/runtime/first-party-tool-services.js +10 -0
- package/dist/runtime/goal-lifecycle-v2.js +5 -0
- package/dist/runtime/goal-runtime-coordinator.js +6 -2
- package/dist/runtime/goals/evidence.js +2 -0
- package/dist/runtime/legacy-thread-materializer.d.ts +7 -0
- package/dist/runtime/legacy-thread-materializer.js +32 -6
- package/dist/runtime/orion-runtime-v1.d.ts +2 -1
- package/dist/runtime/orion-runtime-v1.js +34 -6
- package/dist/runtime/product-bootstrap.d.ts +2 -0
- package/dist/runtime/product-bootstrap.js +1 -0
- package/dist/runtime/product-orion-runtime.d.ts +2 -1
- package/dist/runtime/product-orion-runtime.js +7 -2
- package/dist/runtime/rich-text/layout.d.ts +3 -1
- package/dist/runtime/rich-text/layout.js +37 -22
- package/dist/runtime/shell-process-sessions.d.ts +41 -0
- package/dist/runtime/shell-process-sessions.js +258 -0
- package/dist/runtime/step-snapshot.js +61 -11
- package/dist/runtime/subagents/presets.d.ts +1 -1
- package/dist/runtime/subagents/presets.js +1 -0
- package/dist/runtime/task-context-recovery.js +14 -3
- package/dist/runtime/task-context-service.d.ts +2 -6
- package/dist/runtime/task-context-service.js +3 -12
- package/dist/runtime/thread-event-store.d.ts +3 -0
- package/dist/runtime/thread-event-store.js +35 -22
- package/dist/runtime/thread-session-index.d.ts +15 -3
- package/dist/runtime/thread-session-index.js +152 -45
- package/dist/runtime/thread-session-view.js +1 -1
- package/dist/runtime/thread-ui-adapter.d.ts +1 -1
- package/dist/runtime/thread-ui-adapter.js +23 -5
- package/dist/runtime/tool-gateway.d.ts +1 -0
- package/dist/runtime/tool-gateway.js +1 -0
- package/dist/runtime/tool-transcript-entry.d.ts +8 -1
- package/dist/runtime/tool-transcript-entry.js +35 -7
- package/dist/runtime/ui-events.d.ts +10 -0
- package/dist/runtime/verification-feedback.d.ts +4 -0
- package/dist/runtime/verification-feedback.js +61 -0
- package/dist/services/global-config.d.ts +1 -1
- package/dist/services/global-config.js +2 -0
- package/dist/services/llm.d.ts +3 -0
- package/dist/services/llm.js +48 -4
- package/dist/terminal-ui/raw-editor.js +2 -1
- package/dist/tools/bash_security.d.ts +1 -24
- package/dist/tools/bash_security.js +7 -124
- package/dist/tools/core/exec-command.js +51 -42
- package/dist/tools/core/index.d.ts +2 -1
- package/dist/tools/core/index.js +4 -1
- package/dist/tools/core/process-session.d.ts +2 -0
- package/dist/tools/core/process-session.js +54 -0
- package/dist/tools/todo.js +9 -13
- package/dist/tui-core/frame.d.ts +2 -0
- package/dist/tui-core/frame.js +19 -0
- package/dist/tui-core/input-parser.d.ts +4 -1
- package/dist/tui-core/input-parser.js +22 -0
- package/dist/tui-ui/chrome-view-model.d.ts +0 -2
- package/dist/tui-ui/chrome-view-model.js +54 -56
- package/dist/tui-ui/launch.js +133 -202
- package/dist/tui-ui/layout.d.ts +16 -41
- package/dist/tui-ui/layout.js +408 -295
- package/dist/tui-ui/render-scheduler.d.ts +2 -5
- package/dist/tui-ui/render-scheduler.js +10 -10
- package/dist/tui-ui/response-clipboard.d.ts +17 -0
- package/dist/tui-ui/response-clipboard.js +201 -0
- package/dist/tui-ui/runner.d.ts +65 -80
- package/dist/tui-ui/runner.js +545 -738
- package/dist/tui-ui/session-picker-preview.d.ts +8 -0
- package/dist/tui-ui/session-picker-preview.js +119 -0
- package/dist/tui-ui/session-picker.d.ts +20 -0
- package/dist/tui-ui/session-picker.js +42 -0
- package/dist/tui-ui/state.d.ts +34 -81
- package/dist/tui-ui/state.js +155 -288
- package/dist/tui-ui/terminal-image.d.ts +3 -7
- package/dist/tui-ui/terminal-image.js +18 -47
- package/dist/tui-ui/terminal-viewport.d.ts +55 -0
- package/dist/tui-ui/terminal-viewport.js +221 -0
- package/dist/tui-ui/transcript-layout.d.ts +5 -0
- package/dist/tui-ui/transcript-layout.js +43 -28
- package/dist/tui-ui/transcript-pager.d.ts +39 -0
- package/dist/tui-ui/transcript-pager.js +278 -0
- package/dist/tui-ui/transcript-tool-output.d.ts +16 -0
- package/dist/tui-ui/transcript-tool-output.js +102 -0
- package/dist/utils/bounded-file.d.ts +4 -0
- package/dist/utils/bounded-file.js +30 -0
- package/dist/utils/command-process.d.ts +4 -0
- package/dist/utils/command-process.js +23 -0
- package/dist/utils/shell-command.d.ts +29 -0
- package/dist/utils/shell-command.js +185 -0
- package/docs/cli-guide.md +50 -6
- package/npm-shrinkwrap.json +115 -15
- package/package.json +4 -1
- package/dist/tui-ui/inline-surface.d.ts +0 -191
- package/dist/tui-ui/inline-surface.js +0 -644
- package/dist/tui-ui/input-ownership.d.ts +0 -46
- package/dist/tui-ui/input-ownership.js +0 -74
- package/dist/tui-ui/transcript-inspector-layout.d.ts +0 -9
- package/dist/tui-ui/transcript-inspector-layout.js +0 -107
- package/dist/tui-ui/transcript-inspector-surface.d.ts +0 -18
- package/dist/tui-ui/transcript-inspector-surface.js +0 -91
- package/dist/tui-ui/transcript-inspector.d.ts +0 -36
- package/dist/tui-ui/transcript-inspector.js +0 -129
|
@@ -5,6 +5,7 @@ exports.planLegacyThreadMaterializationV1 = planLegacyThreadMaterializationV1;
|
|
|
5
5
|
exports.materializeLegacyThreadV1 = materializeLegacyThreadV1;
|
|
6
6
|
exports.resolveSessionStorageV1 = resolveSessionStorageV1;
|
|
7
7
|
exports.openSessionCheckpointStorageV1 = openSessionCheckpointStorageV1;
|
|
8
|
+
exports.peekSessionCheckpointStorageV1 = peekSessionCheckpointStorageV1;
|
|
8
9
|
exports.openSessionStorageV1 = openSessionStorageV1;
|
|
9
10
|
exports.loadThreadCutoverIndexV1 = loadThreadCutoverIndexV1;
|
|
10
11
|
exports.deleteSessionThreadRecordsV1 = deleteSessionThreadRecordsV1;
|
|
@@ -12,6 +13,7 @@ const fs_1 = require("fs");
|
|
|
12
13
|
const path_1 = require("path");
|
|
13
14
|
const atomic_write_1 = require("../services/atomic-write");
|
|
14
15
|
const file_lock_1 = require("../services/file-lock");
|
|
16
|
+
const bounded_file_1 = require("../utils/bounded-file");
|
|
15
17
|
const paths_1 = require("../product/paths");
|
|
16
18
|
const canonical_1 = require("./protocol/canonical");
|
|
17
19
|
const legacy_session_importer_1 = require("./legacy-session-importer");
|
|
@@ -124,10 +126,26 @@ function openSessionCheckpointStorageV1(projectPathInput, sessionId) {
|
|
|
124
126
|
const entry = index.sessions[sessionId];
|
|
125
127
|
if (!entry)
|
|
126
128
|
return undefined;
|
|
129
|
+
return openBoundSessionCheckpoint(projectPath, sessionId, entry, index.generation);
|
|
130
|
+
}
|
|
131
|
+
/** Classify the storage binding even when its cached checkpoint is unavailable. */
|
|
132
|
+
function peekSessionCheckpointStorageV1(projectPathInput, sessionId, maxBytes) {
|
|
133
|
+
const projectPath = (0, path_1.resolve)(projectPathInput);
|
|
134
|
+
const index = readThreadCutoverIndex((0, paths_1.getProjectThreadsV2IndexPath)(projectPath), maxBytes);
|
|
135
|
+
if (!Object.prototype.hasOwnProperty.call(index.sessions, sessionId))
|
|
136
|
+
return { kind: 'legacy' };
|
|
137
|
+
return {
|
|
138
|
+
kind: 'thread',
|
|
139
|
+
checkpoint: openBoundSessionCheckpoint(projectPath, sessionId, index.sessions[sessionId], index.generation, maxBytes),
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
function openBoundSessionCheckpoint(projectPath, sessionId, entry, generation, maxBytes) {
|
|
127
143
|
const store = new thread_event_store_1.ThreadEventStore((0, paths_1.getProjectThreadsV2Dir)(projectPath), entry.threadId, {
|
|
128
144
|
maxReplayEvents: Math.max(10000, entry.cursor),
|
|
129
145
|
});
|
|
130
|
-
const head =
|
|
146
|
+
const head = maxBytes === undefined
|
|
147
|
+
? store.capturePersistedCheckpointHead()
|
|
148
|
+
: store.peekPersistedCheckpointHead(maxBytes);
|
|
131
149
|
if (!head ||
|
|
132
150
|
head.cursor < entry.cursor ||
|
|
133
151
|
!head.verifiedPrefixes.some(prefix => prefix.cursor === entry.cursor &&
|
|
@@ -145,7 +163,7 @@ function openSessionCheckpointStorageV1(projectPathInput, sessionId) {
|
|
|
145
163
|
threadId: entry.threadId,
|
|
146
164
|
cursor: head.cursor,
|
|
147
165
|
projectionDigest: head.projectionDigest,
|
|
148
|
-
generation
|
|
166
|
+
generation,
|
|
149
167
|
}),
|
|
150
168
|
store,
|
|
151
169
|
head,
|
|
@@ -620,14 +638,22 @@ function assertSourceUnchanged(projectPath, sessionId, expectedImportDigest) {
|
|
|
620
638
|
throw sourceChanged('Legacy source changed after v2 facts were materialized');
|
|
621
639
|
}
|
|
622
640
|
}
|
|
623
|
-
function readThreadCutoverIndex(path) {
|
|
624
|
-
if (!(0, fs_1.existsSync)(path))
|
|
641
|
+
function readThreadCutoverIndex(path, maxBytes) {
|
|
642
|
+
if (maxBytes === undefined && !(0, fs_1.existsSync)(path))
|
|
625
643
|
return emptyIndex();
|
|
626
644
|
let index;
|
|
627
645
|
try {
|
|
628
|
-
|
|
646
|
+
const contentText = maxBytes === undefined
|
|
647
|
+
? (0, fs_1.readFileSync)(path, 'utf8')
|
|
648
|
+
: (0, bounded_file_1.readBoundedRegularFileSync)(path, maxBytes)?.toString('utf8');
|
|
649
|
+
if (contentText === undefined)
|
|
650
|
+
throw new Error('Thread cutover index exceeds preview limits');
|
|
651
|
+
index = JSON.parse(contentText);
|
|
629
652
|
}
|
|
630
|
-
catch {
|
|
653
|
+
catch (error) {
|
|
654
|
+
if (maxBytes !== undefined && error.code === 'ENOENT') {
|
|
655
|
+
return emptyIndex();
|
|
656
|
+
}
|
|
631
657
|
throw indexCorrupt(`Thread cutover index is unreadable: ${path}`);
|
|
632
658
|
}
|
|
633
659
|
const { digest: _digest, ...content } = index;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ToolContext } from '../framework/tool';
|
|
2
2
|
import type { StopDecision } from '../framework/stop-decision';
|
|
3
|
-
import type { LLMService, Message, StreamCallbacks } from '../services/llm';
|
|
3
|
+
import type { LLMService, Message, StreamCallbacks, StructuredOutputSchema } from '../services/llm';
|
|
4
4
|
import { AgentLoopV1 } from './agent-loop';
|
|
5
5
|
import { type BuiltinToolCatalogV1 } from './builtin-tool-provider';
|
|
6
6
|
import type { CapabilityToolCandidateV1 } from './capabilities';
|
|
@@ -78,6 +78,7 @@ export interface OrionSubagentCompositionV1 extends RuntimeServicePort {
|
|
|
78
78
|
}
|
|
79
79
|
export interface OrionRuntimeLoopOptionsV1 {
|
|
80
80
|
readonly streamCallbacks?: StreamCallbacks;
|
|
81
|
+
readonly outputSchema?: StructuredOutputSchema;
|
|
81
82
|
readonly loopBudget?: ConstructorParameters<typeof AgentLoopV1>[0]['loopBudget'];
|
|
82
83
|
/** Resolve each turn from trusted product input, not a model-authored continuation prompt. */
|
|
83
84
|
readonly resolveLoopBudget?: (context: ThreadTurnExecutionContextV1, goal: GoalRuntimeCoordinatorV2) => ConstructorParameters<typeof AgentLoopV1>[0]['loopBudget'];
|
|
@@ -4,6 +4,7 @@ exports.OrionRuntimeV1 = exports.OrionRuntimeV1Error = void 0;
|
|
|
4
4
|
exports.createOrionRuntimeV1 = createOrionRuntimeV1;
|
|
5
5
|
const fs_1 = require("fs");
|
|
6
6
|
const path_1 = require("path");
|
|
7
|
+
const state_1 = require("../harness/state");
|
|
7
8
|
const paths_1 = require("../product/paths");
|
|
8
9
|
const task_checklist_1 = require("../harness/task-checklist");
|
|
9
10
|
const file_lock_1 = require("../services/file-lock");
|
|
@@ -535,18 +536,22 @@ class OrionRuntimeV1 {
|
|
|
535
536
|
const loopOptions = this.options.loop;
|
|
536
537
|
const agentLoop = new agent_loop_1.AgentLoopV1({
|
|
537
538
|
llm: this.options.modelExecutor,
|
|
539
|
+
outputSchema: loopOptions?.outputSchema,
|
|
538
540
|
taskContext,
|
|
539
541
|
steps: stepFactory,
|
|
540
542
|
gateway,
|
|
541
543
|
previousCommitDigest: () => latestTurnCommitProjection(eventStore)?.digest,
|
|
542
544
|
enableTaskTodos: this.options.enableTaskTodos,
|
|
543
545
|
resolveGoalTask: () => goal.state,
|
|
544
|
-
loadBaseMessages:
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
546
|
+
loadBaseMessages: async (context) => {
|
|
547
|
+
const history = await loadRuntimeBaseMessages(compactPersistence, this.options.loadBaseMessages?.(eventStore, context, prompts, {
|
|
548
|
+
taskContext,
|
|
549
|
+
goal,
|
|
550
|
+
skills,
|
|
551
|
+
mcp,
|
|
552
|
+
}));
|
|
553
|
+
return restoreLegacyHarnessHistory(history, eventStore);
|
|
554
|
+
},
|
|
550
555
|
toolContext: () => this.options.toolContext,
|
|
551
556
|
streamCallbacks: this.options.loop?.streamCallbacks,
|
|
552
557
|
get loopBudget() {
|
|
@@ -1050,6 +1055,29 @@ function parseModelVisibleHistory(history) {
|
|
|
1050
1055
|
}
|
|
1051
1056
|
return history.map(message => ({ ...message }));
|
|
1052
1057
|
}
|
|
1058
|
+
function restoreLegacyHarnessHistory(history, store) {
|
|
1059
|
+
if (!history.some(message => message.role === 'user' &&
|
|
1060
|
+
((0, state_1.isLegacyCompletionFeedback)(message) ||
|
|
1061
|
+
(0, state_1.withoutLegacyGoalGate)(message.content) !== undefined)))
|
|
1062
|
+
return history;
|
|
1063
|
+
const projection = store.loadProjection();
|
|
1064
|
+
const recordedInputs = new Set(Object.values(projection.items)
|
|
1065
|
+
.filter(item => item.role === 'user')
|
|
1066
|
+
.map(item => item.content));
|
|
1067
|
+
if (!recordedInputs.size)
|
|
1068
|
+
return history;
|
|
1069
|
+
const goalInputs = new Set(Object.values(projection.turns)
|
|
1070
|
+
.filter(turn => turn.mode === 'goal')
|
|
1071
|
+
.map(turn => turn.input));
|
|
1072
|
+
return history.flatMap(message => {
|
|
1073
|
+
if ((0, state_1.isLegacyCompletionFeedback)(message) && !recordedInputs.has(message.content))
|
|
1074
|
+
return [];
|
|
1075
|
+
const repaired = message.role === 'user' && goalInputs.has(message.content)
|
|
1076
|
+
? (0, state_1.withoutLegacyGoalGate)(message.content)
|
|
1077
|
+
: undefined;
|
|
1078
|
+
return [repaired ? { ...message, content: repaired } : message];
|
|
1079
|
+
});
|
|
1080
|
+
}
|
|
1053
1081
|
function isMessage(value) {
|
|
1054
1082
|
if (!value || typeof value !== 'object')
|
|
1055
1083
|
return false;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type UIRenderer } from '../services/config';
|
|
2
|
+
import { type StructuredOutputSchema } from '../services/llm';
|
|
2
3
|
import { type SettingsInvalidationV1 } from '../services/settings-coordinator';
|
|
3
4
|
import { type SessionMeta } from '../services/session-storage';
|
|
4
5
|
import { type FirstPartyMcpServerConfigV1 } from './mcp';
|
|
@@ -24,6 +25,7 @@ export declare function createWorkspaceRuntimeKernelV1(options: CreateWorkspaceR
|
|
|
24
25
|
export interface ProductUiRuntimeBootstrapOptions {
|
|
25
26
|
readonly cwd: string;
|
|
26
27
|
readonly uiRenderer?: UIRenderer;
|
|
28
|
+
readonly outputSchema?: StructuredOutputSchema;
|
|
27
29
|
readonly sessionSource?: SessionMeta['source'];
|
|
28
30
|
readonly sessionMcpServers?: Readonly<Record<string, FirstPartyMcpServerConfigV1>>;
|
|
29
31
|
/** Renderer-specific shutdown label used in durable diagnostics. */
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Store } from '../framework/store';
|
|
2
2
|
import type { OrionCodeCLIConfig } from '../services/config';
|
|
3
3
|
import type { CompactCoordinator } from '../services/compact/coordinator';
|
|
4
|
-
import { LLMService } from '../services/llm';
|
|
4
|
+
import { LLMService, type StructuredOutputSchema } from '../services/llm';
|
|
5
5
|
import type { ProviderRequestGate } from '../services/provider-resilience/request-gate';
|
|
6
6
|
import { type BuiltinToolCatalogV1 } from './builtin-tool-provider';
|
|
7
7
|
import type { McpConnectorV1, McpServerDescriptorInputV1 } from './mcp';
|
|
@@ -17,6 +17,7 @@ export interface ProductOrionRuntimeOptionsV1 {
|
|
|
17
17
|
readonly config: OrionCodeCLIConfig;
|
|
18
18
|
readonly store: Store;
|
|
19
19
|
readonly llm: LLMService;
|
|
20
|
+
readonly outputSchema?: StructuredOutputSchema;
|
|
20
21
|
/** Runtime-owned coordinator used by automatic and explicit maintenance compaction. */
|
|
21
22
|
readonly compactCoordinator?: CompactCoordinator;
|
|
22
23
|
readonly toolCatalog: BuiltinToolCatalogV1;
|
|
@@ -142,6 +142,7 @@ function createProductOrionRuntimeV1(options, sessionId, activation) {
|
|
|
142
142
|
return assembled.messages;
|
|
143
143
|
},
|
|
144
144
|
loop: {
|
|
145
|
+
outputSchema: options.outputSchema,
|
|
145
146
|
resolveLoopBudget: (context, goal) => (0, loop_budget_1.resolveRuntimeLoopBudget)(context.mode === 'goal' ? (goal.state?.objective ?? '') : context.input, options.config),
|
|
146
147
|
...(options.compactCoordinator ? { compactCoordinator: options.compactCoordinator } : {}),
|
|
147
148
|
onContextUsage: usage => options.store.setContextUsage(usage),
|
|
@@ -933,8 +934,12 @@ function createPlanStopDecision(commit, promptReceiptDigest) {
|
|
|
933
934
|
progressDelta: structuredClone(completion.progressDelta),
|
|
934
935
|
}
|
|
935
936
|
: {}),
|
|
936
|
-
...(completion?.
|
|
937
|
-
? {
|
|
937
|
+
...(completion?.criterionResults
|
|
938
|
+
? {
|
|
939
|
+
evidenceRefs: [
|
|
940
|
+
...new Set(completion.criterionResults.flatMap(result => result.evidenceRefs)),
|
|
941
|
+
],
|
|
942
|
+
}
|
|
938
943
|
: {}),
|
|
939
944
|
resumable: false,
|
|
940
945
|
});
|
|
@@ -6,7 +6,9 @@ export interface RichTextLayoutOptions {
|
|
|
6
6
|
theme: RichTextThemeResolver;
|
|
7
7
|
/** Left indentation for the content (continuation alignment). */
|
|
8
8
|
indent?: number;
|
|
9
|
+
/** Preserve logical lines for native soft wrapping in terminal scrollback. */
|
|
10
|
+
nativeWrap?: boolean;
|
|
9
11
|
}
|
|
10
|
-
/**
|
|
12
|
+
/** Fit visual rows to the width unless the terminal owns wrapping. */
|
|
11
13
|
export declare function layoutRichText(doc: RichTextDocument, options: RichTextLayoutOptions): StyledRow[];
|
|
12
14
|
//# sourceMappingURL=layout.d.ts.map
|
|
@@ -8,13 +8,13 @@ exports.layoutRichText = layoutRichText;
|
|
|
8
8
|
const string_width_1 = __importDefault(require("string-width"));
|
|
9
9
|
const grapheme_1 = require("../composer/grapheme");
|
|
10
10
|
const style_1 = require("../../tui-core/style");
|
|
11
|
-
/**
|
|
11
|
+
/** Fit visual rows to the width unless the terminal owns wrapping. */
|
|
12
12
|
function layoutRichText(doc, options) {
|
|
13
13
|
const width = normalizeWidth(options.width);
|
|
14
14
|
const indent = normalizeIndent(options.indent ?? 0, width);
|
|
15
15
|
const rows = [];
|
|
16
16
|
for (const block of doc.blocks) {
|
|
17
|
-
const blockRows = layoutBlock(block, width, options.theme, indent);
|
|
17
|
+
const blockRows = layoutBlock(block, width, options.theme, indent, options.nativeWrap ?? false);
|
|
18
18
|
if (blockRows.length === 0)
|
|
19
19
|
continue;
|
|
20
20
|
if (rows.length > 0)
|
|
@@ -24,20 +24,20 @@ function layoutRichText(doc, options) {
|
|
|
24
24
|
}
|
|
25
25
|
return rows;
|
|
26
26
|
}
|
|
27
|
-
function layoutBlock(block, width, theme, indent) {
|
|
27
|
+
function layoutBlock(block, width, theme, indent, nativeWrap) {
|
|
28
28
|
switch (block.type) {
|
|
29
29
|
case 'paragraph':
|
|
30
|
-
return layoutInline(block.spans, width, theme, theme('assistantText'), indent);
|
|
30
|
+
return layoutInline(block.spans, width, theme, theme('assistantText'), indent, nativeWrap);
|
|
31
31
|
case 'heading':
|
|
32
|
-
return layoutInline(block.spans, width, theme, theme('heading'), indent);
|
|
32
|
+
return layoutInline(block.spans, width, theme, theme('heading'), indent, nativeWrap);
|
|
33
33
|
case 'list':
|
|
34
|
-
return layoutList(block, width, theme, indent);
|
|
34
|
+
return layoutList(block, width, theme, indent, nativeWrap);
|
|
35
35
|
case 'quote':
|
|
36
|
-
return layoutQuote(block, width, theme, indent);
|
|
36
|
+
return layoutQuote(block, width, theme, indent, nativeWrap);
|
|
37
37
|
case 'code':
|
|
38
|
-
return layoutCode(block.lines, width, theme, indent, block.language);
|
|
38
|
+
return layoutCode(block.lines, width, theme, indent, nativeWrap, block.language);
|
|
39
39
|
case 'diff':
|
|
40
|
-
return layoutDiff(block.lines, width, theme, indent);
|
|
40
|
+
return layoutDiff(block.lines, width, theme, indent, nativeWrap);
|
|
41
41
|
case 'table':
|
|
42
42
|
return layoutTable(block, width, theme, indent);
|
|
43
43
|
case 'rule': {
|
|
@@ -51,15 +51,15 @@ function layoutBlock(block, width, theme, indent) {
|
|
|
51
51
|
}
|
|
52
52
|
}
|
|
53
53
|
}
|
|
54
|
-
function layoutInline(spans, width, theme, baseStyle, indent) {
|
|
54
|
+
function layoutInline(spans, width, theme, baseStyle, indent, nativeWrap = false) {
|
|
55
55
|
const prefix = indent > 0 ? [{ text: ' '.repeat(indent), style: baseStyle }] : [];
|
|
56
56
|
const styled = spans.map(span => ({
|
|
57
57
|
text: span.text,
|
|
58
58
|
style: resolveSpanStyle(span, baseStyle, theme),
|
|
59
59
|
}));
|
|
60
|
-
return layoutPrefixedSpans(styled, width, prefix, prefix, 'word');
|
|
60
|
+
return layoutPrefixedSpans(styled, width, prefix, prefix, 'word', nativeWrap);
|
|
61
61
|
}
|
|
62
|
-
function layoutList(block, width, theme, indent) {
|
|
62
|
+
function layoutList(block, width, theme, indent, nativeWrap) {
|
|
63
63
|
const rows = [];
|
|
64
64
|
block.items.forEach((item, itemIndex) => {
|
|
65
65
|
const marker = block.ordered ? `${itemIndex + 1}. ` : '- ';
|
|
@@ -79,19 +79,19 @@ function layoutList(block, width, theme, indent) {
|
|
|
79
79
|
text: span.text,
|
|
80
80
|
style: resolveSpanStyle(span, base, theme),
|
|
81
81
|
}));
|
|
82
|
-
rows.push(...layoutPrefixedSpans(styled, width, firstPrefix, continuationPrefix, 'word'));
|
|
82
|
+
rows.push(...layoutPrefixedSpans(styled, width, firstPrefix, continuationPrefix, 'word', nativeWrap));
|
|
83
83
|
return;
|
|
84
84
|
}
|
|
85
85
|
if (blockIndex === 0) {
|
|
86
86
|
rows.push(clampRow(firstPrefix, width));
|
|
87
87
|
}
|
|
88
88
|
const childIndent = normalizeIndent(markerIndent + (0, string_width_1.default)(marker), width);
|
|
89
|
-
rows.push(...layoutBlock(subBlock, width, theme, childIndent));
|
|
89
|
+
rows.push(...layoutBlock(subBlock, width, theme, childIndent, nativeWrap));
|
|
90
90
|
});
|
|
91
91
|
});
|
|
92
92
|
return rows;
|
|
93
93
|
}
|
|
94
|
-
function layoutQuote(block, width, theme, indent) {
|
|
94
|
+
function layoutQuote(block, width, theme, indent, nativeWrap) {
|
|
95
95
|
const prefix = [
|
|
96
96
|
{
|
|
97
97
|
text: `${' '.repeat(normalizeIndent(indent, width))}> `,
|
|
@@ -102,16 +102,17 @@ function layoutQuote(block, width, theme, indent) {
|
|
|
102
102
|
const childWidth = Math.max(1, width - prefixWidth);
|
|
103
103
|
const rows = [];
|
|
104
104
|
for (const child of block.blocks) {
|
|
105
|
-
const childRows = layoutBlock(child, childWidth, theme, 0);
|
|
105
|
+
const childRows = layoutBlock(child, childWidth, theme, 0, nativeWrap);
|
|
106
106
|
if (childRows.length === 0)
|
|
107
107
|
rows.push(clampRow(prefix, width));
|
|
108
108
|
for (const childRow of childRows) {
|
|
109
|
-
|
|
109
|
+
const row = [...prefix, ...childRow];
|
|
110
|
+
rows.push(nativeWrap ? row : clampRow(row, width));
|
|
110
111
|
}
|
|
111
112
|
}
|
|
112
113
|
return rows;
|
|
113
114
|
}
|
|
114
|
-
function layoutCode(lines, width, theme, indent, language) {
|
|
115
|
+
function layoutCode(lines, width, theme, indent, nativeWrap, language) {
|
|
115
116
|
const safeIndent = normalizeIndent(indent, width);
|
|
116
117
|
const available = Math.max(1, width - safeIndent);
|
|
117
118
|
const style = theme('code');
|
|
@@ -121,9 +122,17 @@ function layoutCode(lines, width, theme, indent, language) {
|
|
|
121
122
|
const labelStyle = mergeStyles(style, theme('muted'));
|
|
122
123
|
const labelPrefix = safeIndent > 0 ? [{ text: ' '.repeat(safeIndent), style: labelStyle }] : [];
|
|
123
124
|
const label = truncateToWidth(language, available);
|
|
124
|
-
|
|
125
|
+
const labelRow = [{ text: label, style: labelStyle }];
|
|
126
|
+
rows.push([
|
|
127
|
+
...labelPrefix,
|
|
128
|
+
...(nativeWrap ? labelRow : padRow(labelRow, available, labelStyle)),
|
|
129
|
+
]);
|
|
125
130
|
}
|
|
126
131
|
for (const line of lines.length > 0 ? lines : ['']) {
|
|
132
|
+
if (nativeWrap) {
|
|
133
|
+
rows.push([...prefix, { text: line, style }]);
|
|
134
|
+
continue;
|
|
135
|
+
}
|
|
127
136
|
const gutter = available >= 6 && (0, string_width_1.default)(line) > available ? 2 : 0;
|
|
128
137
|
const wrapped = wrapStyledSpans([{ text: line, style }], available - gutter, 'code');
|
|
129
138
|
wrapped.forEach((row, index) => {
|
|
@@ -135,7 +144,7 @@ function layoutCode(lines, width, theme, indent, language) {
|
|
|
135
144
|
}
|
|
136
145
|
return rows;
|
|
137
146
|
}
|
|
138
|
-
function layoutDiff(lines, width, theme, indent) {
|
|
147
|
+
function layoutDiff(lines, width, theme, indent, nativeWrap) {
|
|
139
148
|
const rows = [];
|
|
140
149
|
const safeIndent = normalizeIndent(indent, width);
|
|
141
150
|
for (const line of lines) {
|
|
@@ -143,7 +152,7 @@ function layoutDiff(lines, width, theme, indent) {
|
|
|
143
152
|
const style = diffLineStyle(line.kind, theme);
|
|
144
153
|
const firstPrefix = [{ text: `${' '.repeat(safeIndent)}${prefix}`, style }];
|
|
145
154
|
const continuationPrefix = [{ text: `${' '.repeat(safeIndent)}↳`, style }];
|
|
146
|
-
rows.push(...layoutPrefixedSpans([{ text: line.content, style }], width, firstPrefix, continuationPrefix, 'hard'));
|
|
155
|
+
rows.push(...layoutPrefixedSpans([{ text: line.content, style }], width, firstPrefix, continuationPrefix, 'hard', nativeWrap));
|
|
147
156
|
}
|
|
148
157
|
return rows;
|
|
149
158
|
}
|
|
@@ -245,7 +254,13 @@ function layoutTableAsKeyValue(block, width, theme, indent) {
|
|
|
245
254
|
}
|
|
246
255
|
return rows;
|
|
247
256
|
}
|
|
248
|
-
function layoutPrefixedSpans(spans, width, firstPrefix, continuationPrefix, mode) {
|
|
257
|
+
function layoutPrefixedSpans(spans, width, firstPrefix, continuationPrefix, mode, nativeWrap = false) {
|
|
258
|
+
if (nativeWrap) {
|
|
259
|
+
return splitStyledUnitsIntoLines(spans).map((line, index) => [
|
|
260
|
+
...(index === 0 ? firstPrefix : continuationPrefix),
|
|
261
|
+
...unitsToRow(line),
|
|
262
|
+
]);
|
|
263
|
+
}
|
|
249
264
|
const prefixWidth = Math.max(rowWidth(firstPrefix), rowWidth(continuationPrefix));
|
|
250
265
|
if (prefixWidth >= width) {
|
|
251
266
|
const prefixRow = clampRow(firstPrefix, width);
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { ToolResult } from '../framework/tool';
|
|
2
|
+
export declare const DEFAULT_PROCESS_YIELD_MS = 500;
|
|
3
|
+
export declare const MAX_PROCESS_YIELD_MS = 5000;
|
|
4
|
+
export declare const MAX_PROCESS_INPUT_BYTES = 65536;
|
|
5
|
+
type ProcessAction = 'poll' | 'write' | 'cancel';
|
|
6
|
+
type ProcessBackend = 'none' | 'seatbelt' | 'bubblewrap';
|
|
7
|
+
interface ProcessLaunch {
|
|
8
|
+
file: string;
|
|
9
|
+
args: string[];
|
|
10
|
+
cwd: string;
|
|
11
|
+
projectRoot: string;
|
|
12
|
+
backend: ProcessBackend;
|
|
13
|
+
timeoutMs: number;
|
|
14
|
+
maxOutputBytes: number;
|
|
15
|
+
yieldMs: number;
|
|
16
|
+
signal?: AbortSignal;
|
|
17
|
+
}
|
|
18
|
+
interface ProcessRequest {
|
|
19
|
+
processId: string;
|
|
20
|
+
projectRoot: string;
|
|
21
|
+
action: ProcessAction;
|
|
22
|
+
input?: string;
|
|
23
|
+
yieldMs: number;
|
|
24
|
+
signal?: AbortSignal;
|
|
25
|
+
}
|
|
26
|
+
/** Retained commands belong to one running Thread/Turn and are never restored from storage. */
|
|
27
|
+
export declare class TurnShellProcesses {
|
|
28
|
+
private readonly turnSignal?;
|
|
29
|
+
private readonly sessions;
|
|
30
|
+
private closing?;
|
|
31
|
+
private readonly abort;
|
|
32
|
+
constructor(turnSignal?: AbortSignal | undefined);
|
|
33
|
+
start(options: ProcessLaunch): Promise<ToolResult>;
|
|
34
|
+
backendFor(processId: string, projectRoot: string): ProcessBackend | undefined;
|
|
35
|
+
operate(request: ProcessRequest): Promise<ToolResult>;
|
|
36
|
+
close(): Promise<void>;
|
|
37
|
+
private get;
|
|
38
|
+
private read;
|
|
39
|
+
}
|
|
40
|
+
export {};
|
|
41
|
+
//# sourceMappingURL=shell-process-sessions.d.ts.map
|