maka-agent 0.2.0-dev.43.20260919 → 0.2.0-dev.45.20260921
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/LICENSE +12 -6
- package/dist/mcp-capability-provider.js +7 -0
- package/dist/runtime-host-service-manager.js +1 -6
- package/dist/runtime-host-tui-command.js +1 -1
- package/dist/runtime-host-update-command.js +39 -27
- package/native/runtime-host-windows-task-launcher/prebuilds/win32-x64/maka-runtime-host-task-launcher.exe +0 -0
- package/node_modules/@maka/core/dist/artifacts.js +1 -0
- package/node_modules/@maka/core/dist/chat-model-choice.js +3 -0
- package/node_modules/@maka/core/dist/llm-connections.js +3 -21
- package/node_modules/@maka/core/dist/model-catalog.js +8 -20
- package/node_modules/@maka/core/dist/model-metadata.generated.js +304 -304
- package/node_modules/@maka/core/dist/model-metadata.js +1 -2
- package/node_modules/@maka/core/dist/model-thinking.js +16 -1
- package/node_modules/@maka/core/dist/models-dev-projection.js +0 -1
- package/node_modules/@maka/core/dist/provider-auth.js +1 -7
- package/node_modules/@maka/core/dist/provider-registry.js +20 -58
- package/node_modules/@maka/core/dist/recall.js +5 -1
- package/node_modules/@maka/core/dist/runtime-policy/connection-catalog-codec.js +7 -0
- package/node_modules/@maka/core/dist/runtime-policy/model-catalog-entry-codec.js +14 -1
- package/node_modules/@maka/core/dist/session-start-mode.js +2 -5
- package/node_modules/@maka/core/dist/session.js +0 -1
- package/node_modules/@maka/core/dist/settings.js +19 -3
- package/node_modules/@maka/core/dist/tool-quiet-preview.js +2 -16
- package/node_modules/@maka/core/dist/transcript-search.js +46 -0
- package/node_modules/@maka/core/package.json +1 -4
- package/node_modules/@maka/mcp/dist/index.js +22 -0
- package/node_modules/@maka/mcp/dist/oauth.js +4 -2
- package/node_modules/@maka/mcp/dist/tool-progress.js +45 -0
- package/node_modules/@maka/runtime/dist/model-factory.js +0 -16
- package/node_modules/@maka/runtime/dist/model-fetcher.js +1 -4
- package/node_modules/@maka/runtime/dist/model-runtime.js +0 -8
- package/node_modules/@maka/runtime/dist/opencode-session-header.js +2 -3
- package/node_modules/@maka/runtime/dist/recall-tools.js +4 -0
- package/node_modules/@maka/runtime/dist/session-manager.js +5 -57
- package/node_modules/@maka/runtime/dist/subagent-tools.js +69 -11
- package/node_modules/@maka/runtime/dist/test-connection.js +4 -114
- package/node_modules/@maka/runtime/package.json +0 -1
- package/node_modules/@maka/runtime-host/dist/client/client-capability-channel.js +44 -9
- package/node_modules/@maka/runtime-host/dist/client/host-handoff-copy.js +25 -18
- package/node_modules/@maka/runtime-host/dist/client/host-handoff.js +3 -1
- package/node_modules/@maka/runtime-host/dist/client/index.js +1 -1
- package/node_modules/@maka/runtime-host/dist/client/session-subscription.js +33 -3
- package/node_modules/@maka/runtime-host/dist/protocol/connection-effects.js +0 -108
- package/node_modules/@maka/runtime-host/dist/protocol/index.js +12 -1
- package/node_modules/@maka/runtime-host/dist/protocol/message.js +10 -0
- package/node_modules/@maka/runtime-host/dist/protocol/operations.js +4 -6
- package/node_modules/@maka/runtime-host/dist/protocol/recall.js +270 -0
- package/node_modules/@maka/runtime-host/dist/protocol/session-catalog.js +1 -1
- package/node_modules/@maka/runtime-host/dist/protocol/session-continuity.js +1 -7
- package/node_modules/@maka/runtime-host/dist/protocol/turn.js +0 -33
- package/node_modules/@maka/runtime-host/dist/protocol/usage-screen.js +12 -4
- package/node_modules/@maka/runtime-host/dist/server/access-credential-store.js +6 -0
- package/node_modules/@maka/runtime-host/dist/server/bootstrap-runtime-policy.js +31 -104
- package/node_modules/@maka/runtime-host/dist/server/connection-effect-coordinator.js +1 -57
- package/node_modules/@maka/runtime-host/dist/server/execution-composition.js +11 -35
- package/node_modules/@maka/runtime-host/dist/server/interactive-run-composer.js +3 -20
- package/node_modules/@maka/runtime-host/dist/server/interactive-turn-coordinator.js +1 -16
- package/node_modules/@maka/runtime-host/dist/server/message-coordinator.js +46 -28
- package/node_modules/@maka/runtime-host/dist/server/recall-coordinator.js +117 -0
- package/node_modules/@maka/runtime-host/dist/server/root-turn-coordinator.js +5 -16
- package/node_modules/@maka/runtime-host/dist/server/session-catalog-coordinator.js +21 -12
- package/node_modules/@maka/runtime-host/dist/server/session-revision-coordinator.js +0 -4
- package/node_modules/@maka/runtime-host/dist/server/session-turn-access-request-coordinator.js +7 -17
- package/node_modules/@maka/storage/dist/artifact-metadata-codec.js +4 -3
- package/node_modules/@maka/storage/dist/artifact-store.js +1 -11
- package/node_modules/@maka/storage/dist/process-lifetime-file-update-lock.js +0 -41
- package/node_modules/@maka/storage/dist/runtime-policy/connection-catalog-document.js +0 -62
- package/node_modules/@maka/storage/dist/runtime-policy/coordinator.js +0 -31
- package/node_modules/@maka/storage/dist/runtime-policy-stores.js +0 -3
- package/node_modules/@maka/storage/dist/sqlite-usage-schema.js +29 -5
- package/node_modules/@maka/storage/dist/sqlite-workflow-schema.js +2 -0
- package/node_modules/@maka/storage/dist/storage-writer-composition.js +0 -3
- package/node_modules/@maka/storage/dist/telemetry-file-schema.js +5 -3
- package/node_modules/@maka/storage/dist/usage-screen.js +5 -6
- package/node_modules/@maka/storage/dist/usage-stores.js +14 -4
- package/node_modules/@maka/storage/package.json +0 -2
- package/package.json +1 -1
- package/node_modules/@maka/core/dist/connection-usage.js +0 -27
- package/node_modules/@maka/core/dist/deep-research-client-progress.js +0 -132
- package/node_modules/@maka/core/dist/deep-research-run.js +0 -625
- package/node_modules/@maka/core/dist/deep-research.js +0 -208
- package/node_modules/@maka/core/dist/thread-search.js +0 -498
- package/node_modules/@maka/runtime/dist/commandcode-cli-language-model.js +0 -837
- package/node_modules/@maka/runtime/dist/connection-usage.js +0 -232
- package/node_modules/@maka/runtime/dist/deep-research-tools.js +0 -732
- package/node_modules/@maka/runtime-host/dist/protocol/deep-research.js +0 -233
- package/node_modules/@maka/runtime-host/dist/server/deep-research-coordinator.js +0 -116
- package/node_modules/@maka/storage/dist/deep-research-authority.js +0 -129
- package/node_modules/@maka/storage/dist/deep-research-store.js +0 -343
|
@@ -195,9 +195,6 @@ export class RuntimePolicyCoordinator {
|
|
|
195
195
|
setDefaultTarget(input) {
|
|
196
196
|
return this.inLane(async (root) => this.projectCatalogMutation(root, await this.catalog.setDefaultTarget(root, input)));
|
|
197
197
|
}
|
|
198
|
-
migrateSystemSeed(input) {
|
|
199
|
-
return this.inLane((root) => this.catalog.migrateSystemSeed(root, input));
|
|
200
|
-
}
|
|
201
198
|
setCredential(rawInput) {
|
|
202
199
|
return this.setCredentialWithAuthority(rawInput, 'client');
|
|
203
200
|
}
|
|
@@ -1114,29 +1111,6 @@ export class RuntimePolicyCoordinator {
|
|
|
1114
1111
|
});
|
|
1115
1112
|
}));
|
|
1116
1113
|
}
|
|
1117
|
-
beginConnectionUsage(connectionId) {
|
|
1118
|
-
return this.inLane(async (root) => {
|
|
1119
|
-
const prepared = await this.prepareConnectionOperation(root, connectionId, 'read_usage');
|
|
1120
|
-
if (prepared.kind !== 'ready')
|
|
1121
|
-
return prepared;
|
|
1122
|
-
const ticket = this.issueTicket('connection_usage', connectionUsageSemanticBasis(prepared));
|
|
1123
|
-
return deepFreeze({
|
|
1124
|
-
kind: 'ready',
|
|
1125
|
-
ticket: ticket,
|
|
1126
|
-
connection: structuredClone(prepared.connection),
|
|
1127
|
-
secretMaterial: prepared.secretMaterial,
|
|
1128
|
-
networkProxy: structuredClone(prepared.networkProxy),
|
|
1129
|
-
});
|
|
1130
|
-
});
|
|
1131
|
-
}
|
|
1132
|
-
/**
|
|
1133
|
-
* Read-only counterpart of `completeConnectionTest`: nothing was written, so
|
|
1134
|
-
* there is no catalog state to revalidate — the ticket is simply spent.
|
|
1135
|
-
*/
|
|
1136
|
-
async completeConnectionUsage(ticket) {
|
|
1137
|
-
const claimed = this.claimTicket(ticket, 'connection_usage');
|
|
1138
|
-
await this.completeClaimedTicket(claimed, async () => undefined);
|
|
1139
|
-
}
|
|
1140
1114
|
async prepareConnectionOperation(root, connectionId, action) {
|
|
1141
1115
|
const catalog = await this.catalog.read(root);
|
|
1142
1116
|
const connection = findConnection(catalog, { connectionId });
|
|
@@ -1597,9 +1571,6 @@ function connectionTestSemanticBasis(prepared) {
|
|
|
1597
1571
|
model: connectionTestModelBasis(prepared.connection),
|
|
1598
1572
|
};
|
|
1599
1573
|
}
|
|
1600
|
-
function connectionUsageSemanticBasis(prepared) {
|
|
1601
|
-
return { kind: 'connection_usage', ...commonSemanticConnectionBasis(prepared) };
|
|
1602
|
-
}
|
|
1603
1574
|
function isCanonicalConnectionTestModel(connection, modelId) {
|
|
1604
1575
|
const basis = connectionTestModelBasis(connection);
|
|
1605
1576
|
// Either source admits: testing a discovered model before enabling it is the
|
|
@@ -1712,8 +1683,6 @@ function ticketLabel(kind) {
|
|
|
1712
1683
|
return 'model fetch';
|
|
1713
1684
|
case 'connection_test':
|
|
1714
1685
|
return 'connection test';
|
|
1715
|
-
case 'connection_usage':
|
|
1716
|
-
return 'connection usage';
|
|
1717
1686
|
}
|
|
1718
1687
|
}
|
|
1719
1688
|
function networkProxyCredentialLocator() {
|
|
@@ -97,7 +97,6 @@ function createWriterFacade(coordinator) {
|
|
|
97
97
|
update: (input) => coordinator.updateConnection(input),
|
|
98
98
|
remove: (input) => coordinator.removeConnection(input),
|
|
99
99
|
setDefaultTarget: (input) => coordinator.setDefaultTarget(input),
|
|
100
|
-
migrateSystemSeed: (input) => coordinator.migrateSystemSeed(input),
|
|
101
100
|
},
|
|
102
101
|
credentialVault: {
|
|
103
102
|
getSnapshot: () => coordinator.getVaultSnapshot(),
|
|
@@ -127,8 +126,6 @@ function createWriterFacade(coordinator) {
|
|
|
127
126
|
completeConnectionOnboarding: (ticket, input) => coordinator.completeConnectionOnboarding(ticket, input),
|
|
128
127
|
beginConnectionTest: (connectionId, modelId) => coordinator.beginConnectionTest(connectionId, modelId),
|
|
129
128
|
completeConnectionTest: (ticket, result) => coordinator.completeConnectionTest(ticket, result),
|
|
130
|
-
beginConnectionUsage: (connectionId) => coordinator.beginConnectionUsage(connectionId),
|
|
131
|
-
completeConnectionUsage: (ticket) => coordinator.completeConnectionUsage(ticket),
|
|
132
129
|
},
|
|
133
130
|
};
|
|
134
131
|
freezeFacade(stores);
|
|
@@ -203,6 +203,7 @@ export function migrateSqliteUsageDatabase(db) {
|
|
|
203
203
|
|
|
204
204
|
CREATE INDEX IF NOT EXISTS usage_llm_calls_session_ts
|
|
205
205
|
ON usage_llm_calls(session_id, ts DESC, id);
|
|
206
|
+
DROP INDEX IF EXISTS usage_llm_calls_session_id;
|
|
206
207
|
`);
|
|
207
208
|
// A ledger old enough to predate Session attribution has no column to carry
|
|
208
209
|
// through, and the conversion below reads one.
|
|
@@ -224,6 +225,8 @@ export function migrateSqliteUsageDatabase(db) {
|
|
|
224
225
|
INSERT OR IGNORE INTO usage_screen_revision VALUES (1, lower(hex(randomblob(16))), 0);
|
|
225
226
|
CREATE INDEX IF NOT EXISTS usage_llm_calls_screen ON usage_llm_calls(ts DESC, storage_key DESC);
|
|
226
227
|
CREATE INDEX IF NOT EXISTS usage_tool_invocations_screen ON usage_tool_invocations(ts DESC, storage_key DESC);
|
|
228
|
+
CREATE INDEX IF NOT EXISTS usage_tool_invocations_session_id
|
|
229
|
+
ON usage_tool_invocations(json_extract(record_json, '$.sessionId'));
|
|
227
230
|
CREATE INDEX IF NOT EXISTS usage_model_call_attempts_screen ON usage_model_call_attempts(completed_at DESC, attempt_id DESC);
|
|
228
231
|
`);
|
|
229
232
|
// These are invalidation metadata, never an accounting or repair authority.
|
|
@@ -246,11 +249,26 @@ export function migrateSqliteUsageDatabase(db) {
|
|
|
246
249
|
for (const event of ['INSERT', 'UPDATE', 'DELETE']) {
|
|
247
250
|
let when = '';
|
|
248
251
|
if (table === 'session_metadata') {
|
|
249
|
-
//
|
|
252
|
+
// Metadata only participates in Usage through activity titles. Avoid
|
|
253
|
+
// fencing an open screen for Sessions that have no retained activity.
|
|
254
|
+
const hasUsage = (row) => `(
|
|
255
|
+
EXISTS (SELECT 1 FROM usage_llm_calls WHERE session_id = ${row}.session_id LIMIT 1)
|
|
256
|
+
OR EXISTS (
|
|
257
|
+
SELECT 1 FROM usage_tool_invocations
|
|
258
|
+
WHERE json_extract(record_json, '$.sessionId') = ${row}.session_id LIMIT 1
|
|
259
|
+
)
|
|
260
|
+
OR EXISTS (
|
|
261
|
+
SELECT 1 FROM usage_model_call_attempts
|
|
262
|
+
WHERE session_id = ${row}.session_id LIMIT 1
|
|
263
|
+
)
|
|
264
|
+
)`;
|
|
250
265
|
when =
|
|
251
|
-
event === '
|
|
252
|
-
?
|
|
253
|
-
: ''
|
|
266
|
+
event === 'INSERT'
|
|
267
|
+
? `WHEN ${hasUsage('NEW')}`
|
|
268
|
+
: event === 'DELETE'
|
|
269
|
+
? `WHEN ${hasUsage('OLD')}`
|
|
270
|
+
: `WHEN (OLD.name IS NOT NEW.name OR OLD.session_id IS NOT NEW.session_id)
|
|
271
|
+
AND (${hasUsage('OLD')} OR ${hasUsage('NEW')})`;
|
|
254
272
|
}
|
|
255
273
|
else if (table === 'core_agent_run_events') {
|
|
256
274
|
const old = "OLD.event_type = 'model_call_attempt_recorded'";
|
|
@@ -265,7 +283,13 @@ export function migrateSqliteUsageDatabase(db) {
|
|
|
265
283
|
? 'WHEN OLD.latest_model_call_sequence IS NOT NULL'
|
|
266
284
|
: 'WHEN OLD.latest_model_call_sequence IS NOT NEW.latest_model_call_sequence OR OLD.session_id IS NOT NEW.session_id OR OLD.run_id IS NOT NEW.run_id';
|
|
267
285
|
}
|
|
268
|
-
|
|
286
|
+
const trigger = `${table}_screen_${event.toLowerCase()}`;
|
|
287
|
+
// Schema v8 originally installed unconditional metadata INSERT/DELETE
|
|
288
|
+
// triggers. Recreate those named triggers so existing databases receive
|
|
289
|
+
// the narrowed predicate as well as fresh databases.
|
|
290
|
+
if (table === 'session_metadata')
|
|
291
|
+
db.exec(`DROP TRIGGER IF EXISTS ${trigger}`);
|
|
292
|
+
db.exec(`CREATE TRIGGER IF NOT EXISTS ${trigger}
|
|
269
293
|
AFTER ${event} ON ${table} ${when} BEGIN
|
|
270
294
|
UPDATE usage_screen_revision SET revision = revision + 1 WHERE singleton = 1;
|
|
271
295
|
END`);
|
|
@@ -57,6 +57,8 @@ export function migrateSqliteWorkflowDatabase(db) {
|
|
|
57
57
|
UNIQUE (session_id, store_version)
|
|
58
58
|
);
|
|
59
59
|
|
|
60
|
+
-- Retained for existing State Roots: schema validation compares the complete DDL.
|
|
61
|
+
-- The research writer is retired, but its stored events must survive upgrades.
|
|
60
62
|
CREATE TABLE IF NOT EXISTS workflow_deep_research_events (
|
|
61
63
|
session_id TEXT NOT NULL,
|
|
62
64
|
sequence INTEGER NOT NULL CHECK (sequence >= 0),
|
|
@@ -19,7 +19,6 @@
|
|
|
19
19
|
import { openInteractiveArtifactStoreForWrite } from './artifact-stores.js';
|
|
20
20
|
import { openInteractiveContextOffloadStoreForWrite } from './context-offload-store.js';
|
|
21
21
|
import { openInteractiveDailyReviewAuthorityForWrite } from './daily-review-authority.js';
|
|
22
|
-
import { openInteractiveDeepResearchStoreForWrite } from './deep-research-authority.js';
|
|
23
22
|
import { openInteractiveExecutionStoresForWrite } from './execution-stores.js';
|
|
24
23
|
import { openInteractiveLongTermMemoryStoreForWrite } from './long-term-memory-store.js';
|
|
25
24
|
import { openInteractiveMemoryBundleStoreForWrite } from './memory-bundle-store.js';
|
|
@@ -87,7 +86,6 @@ async function createComposition(lease, options) {
|
|
|
87
86
|
}
|
|
88
87
|
const scheduledTasks = await openWriter(() => openInteractiveScheduledTaskStoreForWrite(lease), closeWriter);
|
|
89
88
|
const plan = await openWriter(() => openInteractivePlanStoreForWrite(lease), closeWriter);
|
|
90
|
-
const deepResearch = await openWriter(() => openInteractiveDeepResearchStoreForWrite(lease), closeWriter);
|
|
91
89
|
const dailyReview = await openWriter(() => openInteractiveDailyReviewAuthorityForWrite(lease), closeWriter);
|
|
92
90
|
const goal = execution.goalStore;
|
|
93
91
|
const memoryBundle = await openWriter(() => openInteractiveMemoryBundleStoreForWrite(lease));
|
|
@@ -117,7 +115,6 @@ async function createComposition(lease, options) {
|
|
|
117
115
|
runtimePolicy,
|
|
118
116
|
scheduledTasks,
|
|
119
117
|
plan,
|
|
120
|
-
deepResearch,
|
|
121
118
|
dailyReview,
|
|
122
119
|
goal,
|
|
123
120
|
memoryBundle,
|
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
* under the License.
|
|
18
18
|
*/
|
|
19
19
|
import { MODEL_CALL_KINDS, } from '@maka/core/usage-stats/types';
|
|
20
|
+
import { isUsageTimestamp } from '@maka/core/settings';
|
|
20
21
|
import { isContextBudgetDiagnostic, isPromptSegmentEstimate } from '@maka/core/usage-record-schema';
|
|
21
22
|
function exactKeys(shape) {
|
|
22
23
|
return new Set(Object.keys(shape));
|
|
@@ -110,8 +111,8 @@ export function decodePersistedLlmCallRecord(input) {
|
|
|
110
111
|
'latencyMs',
|
|
111
112
|
'costUsd',
|
|
112
113
|
'startedAt',
|
|
113
|
-
|
|
114
|
-
|
|
114
|
+
]) ||
|
|
115
|
+
!isUsageTimestamp(input.ts)) {
|
|
115
116
|
throw invalid('invalid required LLM number');
|
|
116
117
|
}
|
|
117
118
|
if (input.cachedInputTokens !== input.cacheHitInputTokens) {
|
|
@@ -172,7 +173,8 @@ export function decodePersistedToolInvocationRecord(input) {
|
|
|
172
173
|
if (!strings(input, ['id', 'toolName', 'date'])) {
|
|
173
174
|
throw invalid('invalid required tool string');
|
|
174
175
|
}
|
|
175
|
-
if (!nonNegativeNumbers(input, ['durationMs', 'bytesIn', 'bytesOut', 'startedAt'
|
|
176
|
+
if (!nonNegativeNumbers(input, ['durationMs', 'bytesIn', 'bytesOut', 'startedAt']) ||
|
|
177
|
+
!isUsageTimestamp(input.ts)) {
|
|
176
178
|
throw invalid('invalid required tool number');
|
|
177
179
|
}
|
|
178
180
|
if (!['success', 'error', 'aborted'].includes(input.status)) {
|
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
* under the License.
|
|
18
18
|
*/
|
|
19
19
|
import { createHash, randomUUID } from 'node:crypto';
|
|
20
|
+
import { isUsageScreenSearch, isUsageTimestamp, } from '@maka/core/settings';
|
|
20
21
|
import { acquireOperationalStateDatabase } from './operational-state-store.js';
|
|
21
22
|
import { CACHE_READ_TOKENS } from './model-call-usage-sql.js';
|
|
22
23
|
import { TelemetryQueryValidationError } from './telemetry-repo.js';
|
|
@@ -201,12 +202,10 @@ export function createUsageScreenReader(root) {
|
|
|
201
202
|
};
|
|
202
203
|
}
|
|
203
204
|
function validateQuery(query) {
|
|
204
|
-
if (!
|
|
205
|
-
!
|
|
206
|
-
query.range.from < 0 ||
|
|
205
|
+
if (!isUsageTimestamp(query.range.from) ||
|
|
206
|
+
!isUsageTimestamp(query.range.to) ||
|
|
207
207
|
query.range.to < query.range.from ||
|
|
208
|
-
|
|
209
|
-
query.search.length > 1024 ||
|
|
208
|
+
!isUsageScreenSearch(query.search) ||
|
|
210
209
|
!['all', 'success', 'error', 'aborted'].includes(query.status)) {
|
|
211
210
|
throw new TelemetryQueryValidationError('Invalid Usage screen query');
|
|
212
211
|
}
|
|
@@ -246,7 +245,7 @@ function activity(db, query, cursor) {
|
|
|
246
245
|
if (!Array.isArray(value) ||
|
|
247
246
|
value.length !== 4 ||
|
|
248
247
|
value[0] !== hash(query) ||
|
|
249
|
-
!
|
|
248
|
+
!isUsageTimestamp(value[1]) ||
|
|
250
249
|
value[1] < query.range.from ||
|
|
251
250
|
value[1] > query.range.to ||
|
|
252
251
|
!['canonical', 'legacy', 'tool'].includes(value[2]) ||
|
|
@@ -110,11 +110,15 @@ export function authenticateInteractiveUsageStoresWriter(stores) {
|
|
|
110
110
|
export async function openInteractiveUsageStoresForRead(lease) {
|
|
111
111
|
const repos = await runWithStorageRootLease(lease, 'interactive', 'read', (root) => openRepos(root, false));
|
|
112
112
|
let closed = false;
|
|
113
|
+
let barrier = Promise.resolve();
|
|
113
114
|
let closePromise;
|
|
114
115
|
const run = (operation) => {
|
|
115
116
|
if (closed)
|
|
116
117
|
return Promise.reject(new InteractiveUsageStoresClosedError());
|
|
117
|
-
|
|
118
|
+
const admitted = runWithStorageRootLease(lease, 'interactive', 'read', async () => operation());
|
|
119
|
+
const settled = admitted.then(() => undefined, () => undefined);
|
|
120
|
+
barrier = Promise.all([barrier, settled]).then(() => undefined);
|
|
121
|
+
return admitted;
|
|
118
122
|
};
|
|
119
123
|
const stores = {
|
|
120
124
|
readUsageScreen: (input) => run(() => repos.screen.read(input)),
|
|
@@ -128,8 +132,11 @@ export async function openInteractiveUsageStoresForRead(lease) {
|
|
|
128
132
|
if (closePromise)
|
|
129
133
|
return closePromise;
|
|
130
134
|
closed = true;
|
|
131
|
-
|
|
132
|
-
closePromise =
|
|
135
|
+
const accepted = barrier;
|
|
136
|
+
closePromise = accepted.then(async () => {
|
|
137
|
+
repos.screen.close();
|
|
138
|
+
await closeRepos(repos.telemetry, repos.modelCalls, repos.pricing);
|
|
139
|
+
});
|
|
133
140
|
return closePromise;
|
|
134
141
|
},
|
|
135
142
|
};
|
|
@@ -230,7 +237,10 @@ function createWriterFacade(lease, telemetry, modelCalls, pricing, screen) {
|
|
|
230
237
|
});
|
|
231
238
|
const read = (operation) => {
|
|
232
239
|
assertOpen();
|
|
233
|
-
|
|
240
|
+
const admitted = Promise.resolve().then(() => run(operation));
|
|
241
|
+
const settled = admitted.then(() => undefined, () => undefined);
|
|
242
|
+
barrier = Promise.all([barrier, settled]).then(() => undefined);
|
|
243
|
+
return admitted;
|
|
234
244
|
};
|
|
235
245
|
const beginDrain = () => {
|
|
236
246
|
if (drainPromise)
|
|
@@ -13,8 +13,6 @@
|
|
|
13
13
|
"./tool-result-archive-evidence": "./dist/tool-result-archive-evidence.js",
|
|
14
14
|
"./credential-store": "./dist/credential-store.js",
|
|
15
15
|
"./daily-review-authority": "./dist/daily-review-authority.js",
|
|
16
|
-
"./deep-research-authority": "./dist/deep-research-authority.js",
|
|
17
|
-
"./deep-research-store": "./dist/deep-research-store.js",
|
|
18
16
|
"./encrypted-file-managed-secret-store": "./dist/encrypted-file-managed-secret-store.js",
|
|
19
17
|
"./execution-stores": "./dist/execution-stores.js",
|
|
20
18
|
"./execution-persistence-provider": "./dist/execution-persistence-provider.js",
|
package/package.json
CHANGED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Licensed to the Apache Software Foundation (ASF) under one
|
|
3
|
-
* or more contributor license agreements. See the NOTICE file
|
|
4
|
-
* distributed with this work for additional information
|
|
5
|
-
* regarding copyright ownership. The ASF licenses this file
|
|
6
|
-
* to you under the Apache License, Version 2.0 (the
|
|
7
|
-
* "License"); you may not use this file except in compliance
|
|
8
|
-
* with the License. You may obtain a copy of the License at
|
|
9
|
-
*
|
|
10
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
-
*
|
|
12
|
-
* Unless required by applicable law or agreed to in writing,
|
|
13
|
-
* software distributed under the License is distributed on an
|
|
14
|
-
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
15
|
-
* KIND, either express or implied. See the License for the
|
|
16
|
-
* specific language governing permissions and limitations
|
|
17
|
-
* under the License.
|
|
18
|
-
*/
|
|
19
|
-
/**
|
|
20
|
-
* The providers Maka can read account usage from. The single source of truth
|
|
21
|
-
* for both the settings section's visibility and the runtime dispatch, so a
|
|
22
|
-
* provider that gains a mapper is offered the card in the same change.
|
|
23
|
-
*/
|
|
24
|
-
const USAGE_PROVIDERS = new Set(['commandcode-go']);
|
|
25
|
-
export function providerReportsUsage(providerType) {
|
|
26
|
-
return USAGE_PROVIDERS.has(providerType);
|
|
27
|
-
}
|
|
@@ -1,132 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Licensed to the Apache Software Foundation (ASF) under one
|
|
3
|
-
* or more contributor license agreements. See the NOTICE file
|
|
4
|
-
* distributed with this work for additional information
|
|
5
|
-
* regarding copyright ownership. The ASF licenses this file
|
|
6
|
-
* to you under the Apache License, Version 2.0 (the
|
|
7
|
-
* "License"); you may not use this file except in compliance
|
|
8
|
-
* with the License. You may obtain a copy of the License at
|
|
9
|
-
*
|
|
10
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
-
*
|
|
12
|
-
* Unless required by applicable law or agreed to in writing,
|
|
13
|
-
* software distributed under the License is distributed on an
|
|
14
|
-
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
15
|
-
* KIND, either express or implied. See the License for the
|
|
16
|
-
* specific language governing permissions and limitations
|
|
17
|
-
* under the License.
|
|
18
|
-
*/
|
|
19
|
-
import { buildDeepResearchImplementationPrompt } from './deep-research.js';
|
|
20
|
-
import { DEEP_RESEARCH_CLIENT_IMPLEMENTATION_PROMPT_MAX_BYTES, DEEP_RESEARCH_CLIENT_OBJECTIVE_MAX_BYTES, DEEP_RESEARCH_CLIENT_PROGRESS_MAX_BYTES, DEEP_RESEARCH_CLIENT_RECENT_ITEMS_MAX, DEEP_RESEARCH_CLIENT_TEXT_MAX_BYTES, } from './deep-research-run.js';
|
|
21
|
-
/** Build the single bounded product projection used by local and hosted clients. */
|
|
22
|
-
export function projectDeepResearchClientProgress(run) {
|
|
23
|
-
const blockers = [
|
|
24
|
-
...run.checklist.flatMap((item) => item.blockedReason ? [labeledBlocker(item.title, item.blockedReason)] : []),
|
|
25
|
-
...run.steps.flatMap((step) => step.blockedReason ? [labeledBlocker(step.objective, step.blockedReason)] : []),
|
|
26
|
-
];
|
|
27
|
-
const base = {
|
|
28
|
-
sessionId: run.sessionId,
|
|
29
|
-
objective: truncateUtf8(run.objective, DEEP_RESEARCH_CLIENT_OBJECTIVE_MAX_BYTES),
|
|
30
|
-
scopeLevel: run.scopeLevel,
|
|
31
|
-
status: run.status,
|
|
32
|
-
stage: run.stage,
|
|
33
|
-
round: run.round,
|
|
34
|
-
createdAt: run.createdAt,
|
|
35
|
-
updatedAt: run.updatedAt,
|
|
36
|
-
artifactsCount: run.artifacts.length,
|
|
37
|
-
stepsCount: run.steps.length,
|
|
38
|
-
checklist: run.checklist.map((item) => ({
|
|
39
|
-
itemId: item.itemId,
|
|
40
|
-
title: truncateUtf8(item.title, DEEP_RESEARCH_CLIENT_TEXT_MAX_BYTES),
|
|
41
|
-
status: item.status,
|
|
42
|
-
...(item.blockedReason
|
|
43
|
-
? { blockedReason: truncateUtf8(item.blockedReason, DEEP_RESEARCH_CLIENT_TEXT_MAX_BYTES) }
|
|
44
|
-
: {}),
|
|
45
|
-
})),
|
|
46
|
-
reportSections: run.reportSections.map(({ key, status }) => ({ key, status })),
|
|
47
|
-
recentInspectedRefs: run.steps
|
|
48
|
-
.flatMap((step) => step.inspectedRefs)
|
|
49
|
-
.slice(-DEEP_RESEARCH_CLIENT_RECENT_ITEMS_MAX)
|
|
50
|
-
.map((ref) => ({
|
|
51
|
-
kind: ref.kind,
|
|
52
|
-
locator: truncateUtf8(ref.locator, DEEP_RESEARCH_CLIENT_TEXT_MAX_BYTES),
|
|
53
|
-
...(ref.label
|
|
54
|
-
? { label: truncateUtf8(ref.label, DEEP_RESEARCH_CLIENT_TEXT_MAX_BYTES) }
|
|
55
|
-
: {}),
|
|
56
|
-
})),
|
|
57
|
-
workerRunIds: [...new Set(run.steps.flatMap((step) => step.workerRunIds))].slice(-DEEP_RESEARCH_CLIENT_RECENT_ITEMS_MAX),
|
|
58
|
-
blockers: [
|
|
59
|
-
...new Set(blockers.map((value) => truncateUtf8(value, DEEP_RESEARCH_CLIENT_TEXT_MAX_BYTES))),
|
|
60
|
-
].slice(-DEEP_RESEARCH_CLIENT_RECENT_ITEMS_MAX),
|
|
61
|
-
...(run.reportArtifactId ? { reportArtifactId: run.reportArtifactId } : {}),
|
|
62
|
-
};
|
|
63
|
-
if (encodedBytes(base) > DEEP_RESEARCH_CLIENT_PROGRESS_MAX_BYTES) {
|
|
64
|
-
throw new Error('Deep Research client progress cannot fit its required fields');
|
|
65
|
-
}
|
|
66
|
-
if (run.status !== 'completed')
|
|
67
|
-
return base;
|
|
68
|
-
return fitImplementationPrompt(base, buildDeepResearchImplementationPrompt(run));
|
|
69
|
-
}
|
|
70
|
-
function labeledBlocker(label, reason) {
|
|
71
|
-
const separator = ': ';
|
|
72
|
-
const reasonBudget = Math.floor(DEEP_RESEARCH_CLIENT_TEXT_MAX_BYTES * 0.75);
|
|
73
|
-
const boundedReason = truncateUtf8(reason, reasonBudget);
|
|
74
|
-
const titleBudget = DEEP_RESEARCH_CLIENT_TEXT_MAX_BYTES - utf8Bytes(separator) - utf8Bytes(boundedReason);
|
|
75
|
-
return `${truncateUtf8(label, titleBudget)}${separator}${boundedReason}`;
|
|
76
|
-
}
|
|
77
|
-
function fitImplementationPrompt(base, prompt) {
|
|
78
|
-
const bounded = truncateUtf8(prompt, DEEP_RESEARCH_CLIENT_IMPLEMENTATION_PROMPT_MAX_BYTES);
|
|
79
|
-
const full = { ...base, implementationPrompt: bounded };
|
|
80
|
-
if (encodedBytes(full) <= DEEP_RESEARCH_CLIENT_PROGRESS_MAX_BYTES)
|
|
81
|
-
return full;
|
|
82
|
-
const characters = Array.from(bounded);
|
|
83
|
-
let low = 1;
|
|
84
|
-
let high = characters.length;
|
|
85
|
-
let best = base;
|
|
86
|
-
while (low <= high) {
|
|
87
|
-
const midpoint = Math.floor((low + high) / 2);
|
|
88
|
-
const candidate = {
|
|
89
|
-
...base,
|
|
90
|
-
implementationPrompt: truncateCharacters(bounded, midpoint),
|
|
91
|
-
};
|
|
92
|
-
if (encodedBytes(candidate) <= DEEP_RESEARCH_CLIENT_PROGRESS_MAX_BYTES) {
|
|
93
|
-
best = candidate;
|
|
94
|
-
low = midpoint + 1;
|
|
95
|
-
}
|
|
96
|
-
else {
|
|
97
|
-
high = midpoint - 1;
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
return best;
|
|
101
|
-
}
|
|
102
|
-
function truncateCharacters(value, maxCharacters) {
|
|
103
|
-
const characters = Array.from(value);
|
|
104
|
-
if (characters.length <= maxCharacters)
|
|
105
|
-
return value;
|
|
106
|
-
if (maxCharacters === 1)
|
|
107
|
-
return characters[0] ?? '…';
|
|
108
|
-
return `${characters.slice(0, maxCharacters - 1).join('')}…`;
|
|
109
|
-
}
|
|
110
|
-
function encodedBytes(value) {
|
|
111
|
-
return new TextEncoder().encode(JSON.stringify(value)).byteLength;
|
|
112
|
-
}
|
|
113
|
-
function utf8Bytes(value) {
|
|
114
|
-
return new TextEncoder().encode(value).byteLength;
|
|
115
|
-
}
|
|
116
|
-
function truncateUtf8(value, maxBytes) {
|
|
117
|
-
const encoder = new TextEncoder();
|
|
118
|
-
if (encoder.encode(value).byteLength <= maxBytes)
|
|
119
|
-
return value;
|
|
120
|
-
const marker = '…';
|
|
121
|
-
const markerBytes = encoder.encode(marker).byteLength;
|
|
122
|
-
let bytes = 0;
|
|
123
|
-
let output = '';
|
|
124
|
-
for (const character of value) {
|
|
125
|
-
const characterBytes = encoder.encode(character).byteLength;
|
|
126
|
-
if (bytes + characterBytes + markerBytes > maxBytes)
|
|
127
|
-
break;
|
|
128
|
-
output += character;
|
|
129
|
-
bytes += characterBytes;
|
|
130
|
-
}
|
|
131
|
-
return `${output}${marker}`;
|
|
132
|
-
}
|