praxis-agent 0.34.0 → 0.36.0
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/README.md +9 -1
- package/dist/application/background-agent-manager.d.ts +16 -6
- package/dist/application/background-agent-manager.js +139 -97
- package/dist/application/context-engine.d.ts +56 -0
- package/dist/application/context-engine.js +129 -0
- package/dist/application/session-service.d.ts +8 -5
- package/dist/application/session-service.js +1824 -1728
- package/dist/application/subagent-service.js +385 -193
- package/dist/application/top-level-agent-manager.d.ts +1 -0
- package/dist/application/top-level-agent-manager.js +1025 -403
- package/dist/application/transcript-projection.d.ts +33 -0
- package/dist/application/transcript-projection.js +110 -0
- package/dist/application/turn-lifecycle.d.ts +40 -0
- package/dist/application/turn-lifecycle.js +36 -0
- package/dist/application/turn-memory-coordinator.d.ts +43 -0
- package/dist/application/turn-memory-coordinator.js +98 -0
- package/dist/cli/agents-dashboard.js +10 -5
- package/dist/cli/interactive.js +279 -209
- package/dist/cli/protocol.js +5 -2
- package/dist/cli/tui/claude-style.d.ts +5 -48
- package/dist/cli/tui/claude-style.js +167 -197
- package/dist/cli/tui/task-panel.js +10 -1
- package/dist/cli/tui/theme.d.ts +46 -3
- package/dist/cli/tui/theme.js +414 -56
- package/dist/cli/tui/tool-permission.js +9 -5
- package/dist/cli/tui/transcript-presentation.d.ts +89 -0
- package/dist/cli/tui/transcript-presentation.js +169 -0
- package/dist/cli/tui/transcript-viewport.d.ts +5 -34
- package/dist/cli/tui/transcript-viewport.js +639 -158
- package/dist/cli/tui/tui-interaction-router.d.ts +78 -0
- package/dist/cli/tui/tui-interaction-router.js +127 -0
- package/dist/cli/tui/tui-view-model.d.ts +6 -2
- package/dist/cli/tui/tui-view-model.js +23 -6
- package/dist/cli-runtime.d.ts +2 -2
- package/dist/compatibility/claude/context.d.ts +2 -2
- package/dist/compatibility/claude/context.js +2 -14
- package/dist/compatibility/claude/data-plane-adapter.d.ts +9 -0
- package/dist/compatibility/claude/data-plane-adapter.js +44 -0
- package/dist/compatibility/claude/paths.js +2 -2
- package/dist/compatibility/claude/shared-resources.d.ts +7 -38
- package/dist/compatibility/claude/transcript-codec.d.ts +21 -0
- package/dist/compatibility/claude/transcript-codec.js +512 -0
- package/dist/core/agent-orchestration.d.ts +31 -0
- package/dist/core/agent-orchestration.js +235 -0
- package/dist/core/context.d.ts +25 -7
- package/dist/core/context.js +46 -0
- package/dist/core/prompt-composer.d.ts +8 -16
- package/dist/core/prompt-composer.js +65 -25
- package/dist/core/resources.d.ts +39 -0
- package/dist/core/resources.js +2 -0
- package/dist/core/runtime.d.ts +6 -1
- package/dist/core/runtime.js +15 -1
- package/dist/core/session.d.ts +2 -0
- package/dist/core/session.js +5 -0
- package/dist/core/transcript-codec.d.ts +70 -0
- package/dist/core/transcript-codec.js +60 -0
- package/dist/core/transcript-event.d.ts +33 -0
- package/dist/core/transcript-event.js +198 -0
- package/dist/persistence/claude-job-store.d.ts +58 -0
- package/dist/persistence/claude-job-store.js +483 -1
- package/dist/persistence/data-plane-adapter.d.ts +32 -0
- package/dist/persistence/data-plane-adapter.js +2 -0
- package/dist/persistence/data-plane.d.ts +4 -20
- package/dist/persistence/data-plane.js +10 -47
- package/dist/persistence/native-data-plane-adapter.d.ts +9 -0
- package/dist/persistence/native-data-plane-adapter.js +39 -0
- package/dist/persistence/native-resources.d.ts +4 -4
- package/dist/persistence/native-transcript-codec.d.ts +13 -0
- package/dist/persistence/native-transcript-codec.js +102 -0
- package/dist/persistence/native-transcript-reader.d.ts +53 -0
- package/dist/persistence/native-transcript-reader.js +283 -0
- package/dist/persistence/subagent-lifecycle-store.d.ts +41 -8
- package/dist/persistence/subagent-lifecycle-store.js +373 -146
- package/dist/platform/exclusive-file-lease.d.ts +3 -0
- package/dist/platform/exclusive-file-lease.js +3 -0
- package/dist/tools/claude-user-message.d.ts +0 -1
- package/dist/tools/claude-user-message.js +0 -1
- package/package.json +6 -2
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import { AgentRunCancelledError, } from '../core/runtime.js';
|
|
2
|
+
import { contextRecoveryMadeProgress, isPromptTooLongError, } from '../core/context-budget.js';
|
|
3
|
+
function assertSignal(signal) {
|
|
4
|
+
if (signal?.aborted)
|
|
5
|
+
throw new AgentRunCancelledError();
|
|
6
|
+
}
|
|
7
|
+
function validateEnvelope(envelope) {
|
|
8
|
+
if (!Array.isArray(envelope.messages) || !Array.isArray(envelope.tools)) {
|
|
9
|
+
throw new TypeError('Context envelope must contain messages and tools arrays');
|
|
10
|
+
}
|
|
11
|
+
if (envelope.outputTokens !== undefined &&
|
|
12
|
+
(!Number.isSafeInteger(envelope.outputTokens) || envelope.outputTokens < 0)) {
|
|
13
|
+
throw new TypeError('Context envelope outputTokens must be nonnegative');
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
/** Owns context measurement, bounded recovery, and the proposal/commit seam. */
|
|
17
|
+
export class ContextEngine {
|
|
18
|
+
recoveryUsed = false;
|
|
19
|
+
budget;
|
|
20
|
+
memory;
|
|
21
|
+
autoCompact;
|
|
22
|
+
constructor(options = {}) {
|
|
23
|
+
this.budget = options.budget;
|
|
24
|
+
this.memory = options.memory ?? {};
|
|
25
|
+
this.autoCompact = options.autoCompact ?? true;
|
|
26
|
+
}
|
|
27
|
+
async prepare(port, signal) {
|
|
28
|
+
const current = port.current();
|
|
29
|
+
validateEnvelope(current);
|
|
30
|
+
if (!this.budget || !this.autoCompact)
|
|
31
|
+
return current;
|
|
32
|
+
const before = this.reportRequired(current);
|
|
33
|
+
if (!before.shouldCompact)
|
|
34
|
+
return current;
|
|
35
|
+
assertSignal(signal);
|
|
36
|
+
const irreducible = port.irreducible();
|
|
37
|
+
validateEnvelope(irreducible);
|
|
38
|
+
const irreducibleReport = this.reportRequired(irreducible);
|
|
39
|
+
this.budget.assertFits(irreducibleReport);
|
|
40
|
+
await this.memory.beforeCompact?.();
|
|
41
|
+
assertSignal(signal);
|
|
42
|
+
const proposal = await port.propose({
|
|
43
|
+
trigger: 'auto',
|
|
44
|
+
before,
|
|
45
|
+
irreducible: irreducibleReport,
|
|
46
|
+
...(signal ? { signal } : {}),
|
|
47
|
+
});
|
|
48
|
+
assertSignal(signal);
|
|
49
|
+
validateEnvelope(proposal.envelope);
|
|
50
|
+
this.budget.assertFits(this.reportRequired(proposal.envelope));
|
|
51
|
+
await proposal.commit();
|
|
52
|
+
await this.memory.afterCompact?.();
|
|
53
|
+
return proposal.envelope;
|
|
54
|
+
}
|
|
55
|
+
async recover(error, port, signal) {
|
|
56
|
+
if (!isPromptTooLongError(error))
|
|
57
|
+
return { kind: 'not-applicable' };
|
|
58
|
+
if (this.recoveryUsed)
|
|
59
|
+
return { kind: 'exhausted', error };
|
|
60
|
+
// Recovery is a single turn-scoped opportunity, regardless of whether the
|
|
61
|
+
// proposal eventually proves usable. This prevents provider retry loops.
|
|
62
|
+
this.recoveryUsed = true;
|
|
63
|
+
assertSignal(signal);
|
|
64
|
+
if (!this.budget || !this.autoCompact) {
|
|
65
|
+
return { kind: 'exhausted', error };
|
|
66
|
+
}
|
|
67
|
+
try {
|
|
68
|
+
const current = port.current();
|
|
69
|
+
validateEnvelope(current);
|
|
70
|
+
const before = this.reportRequired(current, { promptTooLong: true });
|
|
71
|
+
const irreducible = port.irreducible();
|
|
72
|
+
validateEnvelope(irreducible);
|
|
73
|
+
const irreducibleReport = this.reportRequired(irreducible);
|
|
74
|
+
this.budget.assertFits(irreducibleReport);
|
|
75
|
+
await this.memory.beforeCompact?.();
|
|
76
|
+
assertSignal(signal);
|
|
77
|
+
const proposal = await port.propose({
|
|
78
|
+
trigger: 'reactive',
|
|
79
|
+
before,
|
|
80
|
+
irreducible: irreducibleReport,
|
|
81
|
+
...(signal ? { signal } : {}),
|
|
82
|
+
});
|
|
83
|
+
assertSignal(signal);
|
|
84
|
+
validateEnvelope(proposal.envelope);
|
|
85
|
+
const after = this.reportRequired(proposal.envelope);
|
|
86
|
+
this.budget.assertFits(after);
|
|
87
|
+
if (!contextRecoveryMadeProgress({
|
|
88
|
+
beforeOccupancyTokens: before.occupancyTokens,
|
|
89
|
+
afterOccupancyTokens: after.occupancyTokens,
|
|
90
|
+
})) {
|
|
91
|
+
return { kind: 'exhausted', error };
|
|
92
|
+
}
|
|
93
|
+
await proposal.commit();
|
|
94
|
+
await this.memory.afterCompact?.();
|
|
95
|
+
return { kind: 'retry', envelope: proposal.envelope };
|
|
96
|
+
}
|
|
97
|
+
catch (cause) {
|
|
98
|
+
if (signal?.aborted || cause instanceof AgentRunCancelledError)
|
|
99
|
+
throw cause;
|
|
100
|
+
return { kind: 'exhausted', error };
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
observeUsage(usage, messages, tools) {
|
|
104
|
+
this.budget?.observeUsage(usage, messages, tools);
|
|
105
|
+
}
|
|
106
|
+
report(envelope, options = {}) {
|
|
107
|
+
validateEnvelope(envelope);
|
|
108
|
+
if (!this.budget) {
|
|
109
|
+
return undefined;
|
|
110
|
+
}
|
|
111
|
+
return this.budget.evaluate(envelope.messages, envelope.tools, {
|
|
112
|
+
...(envelope.outputTokens === undefined
|
|
113
|
+
? {}
|
|
114
|
+
: { outputTokens: envelope.outputTokens }),
|
|
115
|
+
...options,
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
reportRequired(envelope, options = {}) {
|
|
119
|
+
if (!this.budget)
|
|
120
|
+
throw new Error('Context budget is unavailable');
|
|
121
|
+
return this.budget.evaluate(envelope.messages, envelope.tools, {
|
|
122
|
+
...(envelope.outputTokens === undefined
|
|
123
|
+
? {}
|
|
124
|
+
: { outputTokens: envelope.outputTokens }),
|
|
125
|
+
...options,
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
//# sourceMappingURL=context-engine.js.map
|
|
@@ -2,7 +2,7 @@ import { type AgentColorName, type AgentColorSelection } from '../compatibility/
|
|
|
2
2
|
import type { ClaudeConditionalRuleResolver } from '../compatibility/claude/context.js';
|
|
3
3
|
import { type DataPlane } from '../persistence/data-plane.js';
|
|
4
4
|
import { type ClaudeFileResource, type ClaudeFileResourceConfig } from '../compatibility/claude/file-resources.js';
|
|
5
|
-
import {
|
|
5
|
+
import type { TranscriptDisplayItem } from './transcript-projection.js';
|
|
6
6
|
import { type ClaudeTranscriptEntry } from '../compatibility/claude/schema.js';
|
|
7
7
|
import { type ClaudeSessionMetadata } from '../compatibility/claude/session-metadata.js';
|
|
8
8
|
import { type ClaudeInterruptionClassification } from '../compatibility/claude/interruption.js';
|
|
@@ -15,6 +15,7 @@ import { type ContextAssembler } from '../core/context.js';
|
|
|
15
15
|
import type { ClaudeExtensionCatalog } from '../extensions/claude-extensions.js';
|
|
16
16
|
import type { ClaudeHookRunner } from '../hooks/claude-hooks.js';
|
|
17
17
|
import { type TranscriptParseIssue } from '../persistence/claude-transcript-store.js';
|
|
18
|
+
import type { TranscriptCodecDiagnostic } from '../core/transcript-codec.js';
|
|
18
19
|
import type { ClaudeCostStateStore } from '../persistence/claude-cost-state-store.js';
|
|
19
20
|
import { type AgentPermissionMode } from './subagent-service.js';
|
|
20
21
|
import { type ScheduledPrompt } from './scheduled-prompt-manager.js';
|
|
@@ -138,14 +139,14 @@ export interface SessionSummary {
|
|
|
138
139
|
lastPrompt: string | null;
|
|
139
140
|
updatedAt: string;
|
|
140
141
|
status: SessionStatus;
|
|
141
|
-
issue: TranscriptParseIssue | null;
|
|
142
|
+
issue: (TranscriptParseIssue | TranscriptCodecDiagnostic) | null;
|
|
142
143
|
prNumber?: number;
|
|
143
144
|
prUrl?: string;
|
|
144
145
|
prRepository?: string;
|
|
145
146
|
}
|
|
146
147
|
export type SessionStatus = 'ready' | 'read-only' | 'corrupt';
|
|
147
148
|
export interface SessionInspection extends SessionSummary {
|
|
148
|
-
claudeVersion
|
|
149
|
+
claudeVersion?: string;
|
|
149
150
|
writeMode: 'read-only' | 'read-write';
|
|
150
151
|
entryCount: number;
|
|
151
152
|
byteLength: number;
|
|
@@ -273,7 +274,7 @@ export declare class ClaudeSessionService {
|
|
|
273
274
|
readEffectiveAgentColor(sessionId: string): Promise<AgentColorName | undefined>;
|
|
274
275
|
export(sessionId: string): Promise<Buffer>;
|
|
275
276
|
registerResumePath(requestedPath: string): Promise<SessionSummary>;
|
|
276
|
-
transcript(sessionId: string, resumeSessionAt?: string): Promise<
|
|
277
|
+
transcript(sessionId: string, resumeSessionAt?: string): Promise<TranscriptDisplayItem[]>;
|
|
277
278
|
interruption(sessionId: string): Promise<ClaudeInterruptionClassification>;
|
|
278
279
|
metadata(sessionId: string): Promise<ClaudeSessionMetadata>;
|
|
279
280
|
rename(sessionId: string, name: string): Promise<void>;
|
|
@@ -345,12 +346,14 @@ export declare class ClaudeSessionService {
|
|
|
345
346
|
private assertSessionPersistence;
|
|
346
347
|
private assertWritable;
|
|
347
348
|
private sessionStatus;
|
|
349
|
+
private nativeSessionStatus;
|
|
350
|
+
private claudeSessionSummary;
|
|
348
351
|
private provider;
|
|
352
|
+
private assertNativeWriteTargetIsLegacy;
|
|
349
353
|
model(): string | undefined;
|
|
350
354
|
private providerForAgent;
|
|
351
355
|
private resolveAgent;
|
|
352
356
|
private mainAgentSystemPrompt;
|
|
353
|
-
private assembledSystemMessages;
|
|
354
357
|
private contextBudget;
|
|
355
358
|
private sessionMemoryEnabled;
|
|
356
359
|
private sessionMemoryController;
|