maka-agent 0.2.0-dev.34.20260915 → 0.2.0-dev.35.20260915
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/native/runtime-host-windows-task-launcher/prebuilds/win32-x64/maka-runtime-host-task-launcher.exe +0 -0
- package/node_modules/@maka/runtime/dist/ai-sdk-turn.js +2 -18
- package/node_modules/@maka/runtime/dist/openai-codex-history-compactor.js +1 -2
- package/node_modules/@maka/runtime/dist/provider-error-classification.js +29 -38
- package/node_modules/@maka/runtime-host/dist/client/connect-or-spawn.js +4 -1
- package/node_modules/@maka/runtime-host/dist/client/wait-for-ready.js +1 -1
- package/node_modules/@maka/runtime-host/dist/control/endpoint.js +7 -6
- package/node_modules/@maka/runtime-host/dist/server/execution-composition.js +2 -2
- package/node_modules/@maka/runtime-host/dist/server/workhub-message-attachments.js +1 -0
- package/node_modules/@maka/storage/dist/agent-run-store-contract.js +942 -0
- package/node_modules/@maka/storage/dist/agent-run-store.js +3 -923
- package/node_modules/@maka/storage/dist/artifact-store.js +63 -7
- package/node_modules/@maka/storage/dist/execution-persistence-provider.js +54 -0
- package/node_modules/@maka/storage/dist/execution-stores.js +181 -58
- package/node_modules/@maka/storage/dist/goal-authority.js +39 -8
- package/node_modules/@maka/storage/dist/graph-control-values.js +126 -0
- package/node_modules/@maka/storage/dist/interaction-store-contract.js +231 -0
- package/node_modules/@maka/storage/dist/interaction-store.js +62 -217
- package/node_modules/@maka/storage/dist/local-execution-persistence.js +80 -0
- package/node_modules/@maka/storage/dist/root-authority.js +4 -0
- package/node_modules/@maka/storage/dist/runtime-event-store-contract.js +19 -0
- package/node_modules/@maka/storage/dist/runtime-partial-values.js +114 -0
- package/node_modules/@maka/storage/dist/session-store-contract.js +61 -0
- package/node_modules/@maka/storage/dist/session-store-values.js +342 -0
- package/node_modules/@maka/storage/dist/session-store.js +7 -351
- package/node_modules/@maka/storage/dist/sqlite-runtime-store.js +4 -185
- package/node_modules/@maka/storage/dist/sqlite-session-metadata-store.js +9 -129
- package/node_modules/@maka/storage/dist/storage-writer-composition.js +2 -3
- package/node_modules/@maka/storage/dist/tool-commit-validation.js +111 -0
- package/node_modules/@maka/storage/package.json +1 -0
- package/package.json +1 -1
|
Binary file
|
|
@@ -20,6 +20,7 @@ import { DEFAULT_TOOL_MODE, isToolMode } from '@maka/core/tool-mode';
|
|
|
20
20
|
import { resolveEffectiveOrchestration, } from '@maka/core/orchestration';
|
|
21
21
|
import { stripUndefinedDeep } from '@maka/core/tool-args-identity';
|
|
22
22
|
import { YIELD_AGENT_GRAPH_TOOL_NAME, } from './stream-graph-supervisor-tools.js';
|
|
23
|
+
import { providerRetryReason } from './provider-error-classification.js';
|
|
23
24
|
import Ajv from 'ajv';
|
|
24
25
|
import Ajv2019 from 'ajv/dist/2019.js';
|
|
25
26
|
import Ajv2020 from 'ajv/dist/2020.js';
|
|
@@ -355,20 +356,6 @@ function providerRetryDelayMs(failedAttempt, retryAfterMs) {
|
|
|
355
356
|
const base = Math.min(PROVIDER_RETRY_BASE_DELAY_MS * 2 ** Math.max(0, failedAttempt - 1), PROVIDER_RETRY_MAX_DELAY_MS);
|
|
356
357
|
return Math.ceil(base + Math.random() * PROVIDER_RETRY_JITTER_FACTOR * base);
|
|
357
358
|
}
|
|
358
|
-
function providerRetryReason(kind) {
|
|
359
|
-
switch (kind) {
|
|
360
|
-
case 'stream_truncated':
|
|
361
|
-
case 'network':
|
|
362
|
-
case 'provider_unavailable':
|
|
363
|
-
case 'rate_limit':
|
|
364
|
-
case 'timeout':
|
|
365
|
-
return kind;
|
|
366
|
-
case 'provider_capacity':
|
|
367
|
-
return 'provider_capacity';
|
|
368
|
-
default:
|
|
369
|
-
return 'unknown';
|
|
370
|
-
}
|
|
371
|
-
}
|
|
372
359
|
/**
|
|
373
360
|
* The mutable state of ONE `send()`.
|
|
374
361
|
*
|
|
@@ -1669,9 +1656,6 @@ export class AiSdkTurn {
|
|
|
1669
1656
|
else if (providerAttempt >= MAX_PROVIDER_ATTEMPTS_PER_STEP) {
|
|
1670
1657
|
retry = { decision: 'exhausted', attempts: providerAttempt };
|
|
1671
1658
|
}
|
|
1672
|
-
else if (failure.kind === 'context_overflow') {
|
|
1673
|
-
retry = { decision: 'declined', because: 'policy' };
|
|
1674
|
-
}
|
|
1675
1659
|
else if (!failure.retryable) {
|
|
1676
1660
|
retry = { decision: 'declined', because: 'policy' };
|
|
1677
1661
|
}
|
|
@@ -1686,7 +1670,7 @@ export class AiSdkTurn {
|
|
|
1686
1670
|
const delayMs = providerRetryDelayMs(providerAttempt, failure.retryAfterMs);
|
|
1687
1671
|
const nextAttempt = providerAttempt + 1;
|
|
1688
1672
|
const maxAttempts = MAX_PROVIDER_ATTEMPTS_PER_STEP;
|
|
1689
|
-
const reason = providerRetryReason(failure.kind);
|
|
1673
|
+
const reason = providerRetryReason(failure.kind) ?? 'unknown';
|
|
1690
1674
|
queue.push({
|
|
1691
1675
|
type: 'provider_retry',
|
|
1692
1676
|
id: this.deps.newId(),
|
|
@@ -125,8 +125,7 @@ export function shouldFallbackFromOpenAiCodexHistoryCompaction(error, abortSigna
|
|
|
125
125
|
return true;
|
|
126
126
|
if (error.reason !== 'provider_error')
|
|
127
127
|
return false;
|
|
128
|
-
|
|
129
|
-
return diagnostic.errorClass === 'request_rejected' && !diagnostic.retryable;
|
|
128
|
+
return providerFailureDiagnostic(error).errorClass === 'request_rejected';
|
|
130
129
|
}
|
|
131
130
|
function hasAbortCause(error) {
|
|
132
131
|
const seen = new Set();
|
|
@@ -64,6 +64,7 @@ const PROVIDER_BILLING_PROVIDER_CODES = new Set([
|
|
|
64
64
|
'insufficient_quota', // OpenAI & OpenAI-compatible: error.code
|
|
65
65
|
'insufficient_balance', // DeepSeek: error.code
|
|
66
66
|
'quota_exceeded', // OpenAI-compatible variants: error.code
|
|
67
|
+
'freeusagelimiterror', // OpenCode Zen free tier exhausted (HTTP 429): error.type
|
|
67
68
|
]);
|
|
68
69
|
/**
|
|
69
70
|
* Free-text usage/billing wording that overrides a credential-shaped HTTP
|
|
@@ -83,12 +84,29 @@ const USAGE_LIMIT_TEXT_PATTERNS = [
|
|
|
83
84
|
];
|
|
84
85
|
const PROVIDER_FAILURE_FIELD_MAX_BYTES = 256;
|
|
85
86
|
const MAX_SAFE_TIMER_DELAY_MS = 2_147_483_647;
|
|
86
|
-
|
|
87
|
-
const
|
|
88
|
-
'
|
|
89
|
-
OPENAI_RESPONSES_WEBSOCKET_TRANSPORT_ERROR,
|
|
87
|
+
/** Codes the incremental Responses transport raises before any HTTP response. */
|
|
88
|
+
const OPENAI_RESPONSES_TRANSPORT_CODES = new Set([
|
|
89
|
+
'OPENAI_RESPONSES_WEBSOCKET_TRANSPORT_ERROR',
|
|
90
90
|
'OPENAI_RESPONSES_CONTINUATION_UNAVAILABLE',
|
|
91
91
|
]);
|
|
92
|
+
/** Retryability follows the kind alone; never re-derive it from a status or header. */
|
|
93
|
+
const MODEL_FAILURE_RETRY = {
|
|
94
|
+
abort: null,
|
|
95
|
+
auth: null,
|
|
96
|
+
context_overflow: null,
|
|
97
|
+
network: 'network',
|
|
98
|
+
provider_billing: null,
|
|
99
|
+
provider_capacity: 'provider_capacity',
|
|
100
|
+
provider_unavailable: 'provider_unavailable',
|
|
101
|
+
rate_limit: 'rate_limit',
|
|
102
|
+
request_rejected: null,
|
|
103
|
+
stream_truncated: 'stream_truncated',
|
|
104
|
+
timeout: 'timeout',
|
|
105
|
+
unknown: null,
|
|
106
|
+
};
|
|
107
|
+
export function providerRetryReason(kind) {
|
|
108
|
+
return MODEL_FAILURE_RETRY[kind];
|
|
109
|
+
}
|
|
92
110
|
function providerErrorTarget(error) {
|
|
93
111
|
return RetryError.isInstance(error) && error.lastError !== undefined && error.lastError !== error
|
|
94
112
|
? error.lastError
|
|
@@ -150,49 +168,22 @@ function parseRetryAfterMs(headers) {
|
|
|
150
168
|
const seconds = Number(rawRetryAfter);
|
|
151
169
|
delayMs = Number.isFinite(seconds) ? seconds * 1_000 : Date.parse(rawRetryAfter) - Date.now();
|
|
152
170
|
}
|
|
153
|
-
if (!Number.isFinite(delayMs) || delayMs <= 0 || delayMs > MAX_SAFE_TIMER_DELAY_MS)
|
|
154
|
-
return
|
|
171
|
+
if (!Number.isFinite(delayMs) || delayMs <= 0 || delayMs > MAX_SAFE_TIMER_DELAY_MS) {
|
|
172
|
+
return undefined;
|
|
173
|
+
}
|
|
155
174
|
return Math.ceil(delayMs);
|
|
156
175
|
}
|
|
157
176
|
function retryMetadataFromFacts(facts, errorClass = classifyProviderFacts(facts)) {
|
|
158
177
|
if (facts.aborted)
|
|
159
178
|
return { retryable: false };
|
|
160
|
-
const { evidence } = facts;
|
|
161
|
-
if (RUNTIME_RETRYABLE_ERROR_CODES.has(evidence.code))
|
|
162
|
-
return { retryable: true };
|
|
163
179
|
// The Codex transport already spent its complete 2/10/30-second budget.
|
|
164
180
|
// Do not let the outer model loop restart that same transport budget.
|
|
165
181
|
if (isTrustedCodexEdgeRejection(facts))
|
|
166
182
|
return { retryable: false };
|
|
167
|
-
|
|
168
|
-
const retryAfterMs = parseRetryAfterMs(facts.responseHeaders ?? {});
|
|
169
|
-
if (errorClass === 'provider_capacity') {
|
|
170
|
-
// Capacity is transient even when the provider sends a malformed delay;
|
|
171
|
-
// fall back to the adapter's bounded local backoff in that case.
|
|
172
|
-
return {
|
|
173
|
-
retryable: true,
|
|
174
|
-
...(retryAfterMs !== undefined && retryAfterMs !== null ? { retryAfterMs } : {}),
|
|
175
|
-
};
|
|
176
|
-
}
|
|
177
|
-
if (errorClass === 'rate_limit' || status === 429) {
|
|
178
|
-
if (retryAfterMs === undefined || retryAfterMs === null)
|
|
179
|
-
return { retryable: false };
|
|
180
|
-
return { retryable: true, retryAfterMs };
|
|
181
|
-
}
|
|
182
|
-
const retryable = errorClass === 'stream_truncated' ||
|
|
183
|
-
errorClass === 'network' ||
|
|
184
|
-
errorClass === 'provider_unavailable' ||
|
|
185
|
-
status === 408 ||
|
|
186
|
-
status === 409 ||
|
|
187
|
-
(status >= 500 && status <= 599);
|
|
188
|
-
if (!retryable)
|
|
189
|
-
return { retryable: false };
|
|
190
|
-
if (retryAfterMs === null)
|
|
183
|
+
if (MODEL_FAILURE_RETRY[errorClass] === null)
|
|
191
184
|
return { retryable: false };
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
...(retryAfterMs !== undefined ? { retryAfterMs } : {}),
|
|
195
|
-
};
|
|
185
|
+
const retryAfterMs = parseRetryAfterMs(facts.responseHeaders ?? {});
|
|
186
|
+
return { retryable: true, ...(retryAfterMs === undefined ? {} : { retryAfterMs }) };
|
|
196
187
|
}
|
|
197
188
|
/** Collects `code`/`type` strings from a payload and from its `error` wrapper. */
|
|
198
189
|
function collectStructuredCodes(payload, out) {
|
|
@@ -606,7 +597,7 @@ function classifyProviderFacts(facts) {
|
|
|
606
597
|
const { evidence } = facts;
|
|
607
598
|
const { text, statusCode, code, structuredCodes } = evidence;
|
|
608
599
|
const normalizedCode = code.toLowerCase();
|
|
609
|
-
if (code
|
|
600
|
+
if (OPENAI_RESPONSES_TRANSPORT_CODES.has(code))
|
|
610
601
|
return 'network';
|
|
611
602
|
if (code === 'MODEL_STREAM_TIMEOUT')
|
|
612
603
|
return 'timeout';
|
|
@@ -27,7 +27,10 @@ import { isPermanentCandidateStartupFailure, } from '../candidate-startup-failur
|
|
|
27
27
|
import { clearCandidateStartupDiagnostic, selectCandidateStartupDiagnostic, } from '../control/startup-diagnostic.js';
|
|
28
28
|
import { decodeRuntimeHostManagedLaunchClaim, readRuntimeHostManagedDeploymentConfig, runtimeHostManagedLaunchRejection, RuntimeHostManagedDeploymentError, } from '../operator/managed-deployment.js';
|
|
29
29
|
import { abortable, waitForRuntimeHostReady } from './wait-for-ready.js';
|
|
30
|
-
|
|
30
|
+
// Candidate readiness includes the Windows named-pipe ACL helper, whose
|
|
31
|
+
// fail-closed ceiling is 60s. Leave enough room for election and connection
|
|
32
|
+
// bookkeeping after that helper returns.
|
|
33
|
+
const DEFAULT_ELECTION_DEADLINE_MS = 75_000;
|
|
31
34
|
const DEFAULT_BACKOFF_MIN_MS = 20;
|
|
32
35
|
const DEFAULT_BACKOFF_MAX_MS = 250;
|
|
33
36
|
const MIN_CANDIDATE_INTERVAL_MS = 250;
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
* specific language governing permissions and limitations
|
|
17
17
|
* under the License.
|
|
18
18
|
*/
|
|
19
|
-
export async function waitForRuntimeHostReady(connection, timeoutMs =
|
|
19
|
+
export async function waitForRuntimeHostReady(connection, timeoutMs = 75_000, signal) {
|
|
20
20
|
if (!Number.isSafeInteger(timeoutMs) || timeoutMs <= 0 || timeoutMs > 120_000) {
|
|
21
21
|
throw new RangeError('timeoutMs must be an integer between 1 and 120000');
|
|
22
22
|
}
|
|
@@ -32,12 +32,13 @@ const WINDOWS_PIPE_PATH_ENV = 'MAKA_RUNTIME_HOST_PIPE_PATH';
|
|
|
32
32
|
// per-connection check, so the call has to succeed and a timeout has to
|
|
33
33
|
// refuse the endpoint. That makes the budget a question of how long we are
|
|
34
34
|
// willing to wait, not how long the work should take. Windows PowerShell 5.1
|
|
35
|
-
// cold start plus .NET type loading is seconds on a loaded CI runner, and
|
|
36
|
-
// 10s
|
|
37
|
-
//
|
|
38
|
-
// waits on this, so raising it
|
|
39
|
-
//
|
|
40
|
-
|
|
35
|
+
// cold start plus .NET type loading is seconds on a loaded CI runner, and both
|
|
36
|
+
// 10s (#3225) and 30s (npm Nightly run 34917337079) budgets have killed healthy
|
|
37
|
+
// hosted runners. Keep a full minute so ordinary runner variance does not
|
|
38
|
+
// refuse a secure endpoint. Endpoint readiness waits on this, so raising it
|
|
39
|
+
// means checking that the waiters still outlast it:
|
|
40
|
+
// scripts/windows-runtime-host-local-ipc-trust.ps1 and client/connect-or-spawn.ts.
|
|
41
|
+
const WINDOWS_PIPE_ACL_TIMEOUT_MS = 60_000;
|
|
41
42
|
const WINDOWS_PIPE_ACL_DIAGNOSTIC_LIMIT = 1_000;
|
|
42
43
|
const WINDOWS_PIPE_ACL_STDERR_MAX_BYTES = 4 * 1024;
|
|
43
44
|
const WINDOWS_PIPE_ACL_SCRIPT = String.raw `
|
|
@@ -67,7 +67,6 @@ import { PluginSessionQueryService } from '@maka/runtime/plugin-session-query-se
|
|
|
67
67
|
import { PluginShellEnvService } from '@maka/runtime/plugin-shell-env-service';
|
|
68
68
|
import { PluginSkillService } from '@maka/runtime/plugin-skill-service';
|
|
69
69
|
import { isHostedExecutionTerminal } from './hosted-execution-authority.js';
|
|
70
|
-
import { createAgentGraphControlStore } from '@maka/storage/agent-graph-control-store';
|
|
71
70
|
import { createArtifactAttachmentResourceReader } from '@maka/storage/artifact-stores';
|
|
72
71
|
import { createReadImageSnapshotStore } from '@maka/storage/read-image-snapshot-store';
|
|
73
72
|
import { isSessionNotFoundError } from '@maka/storage/execution-stores';
|
|
@@ -175,6 +174,7 @@ export function runtimeHostFilesystemWorkerRuntime(versions) {
|
|
|
175
174
|
}
|
|
176
175
|
export async function createExecutionRuntimeHostComposition(context, options = {}, dependencies = {}) {
|
|
177
176
|
const storage = await openStorageWriterComposition(context.owner.lease, {
|
|
177
|
+
executionProvider: dependencies.executionPersistenceProvider,
|
|
178
178
|
contextOffloadLimits: CONTEXT_OFFLOAD_LIMITS,
|
|
179
179
|
afterRuntimePolicyOpened: async (stores) => {
|
|
180
180
|
if (options.bootstrapRuntimePolicy !== false) {
|
|
@@ -499,7 +499,7 @@ export async function createExecutionRuntimeHostComposition(context, options = {
|
|
|
499
499
|
hostTools: childHostTools,
|
|
500
500
|
worktreePatchWriteBackAvailable: true,
|
|
501
501
|
});
|
|
502
|
-
const openedGraphControlStore =
|
|
502
|
+
const openedGraphControlStore = stores.graphControlStore;
|
|
503
503
|
graphControlStore = openedGraphControlStore;
|
|
504
504
|
let resolveAvailableToolNames;
|
|
505
505
|
let resolveNewSessionToolNames;
|
|
@@ -33,6 +33,7 @@ export async function copyWorkHubAttachmentsToTarget(store, artifacts, targetSes
|
|
|
33
33
|
targetSessionId,
|
|
34
34
|
turnIds: [],
|
|
35
35
|
includeArtifactIds: ids,
|
|
36
|
+
existingTarget: 'reuse_verified',
|
|
36
37
|
});
|
|
37
38
|
return attachments.map((attachment, index) => {
|
|
38
39
|
const relativePath = copied.artifactIds.get(ids[index]);
|