@myagentroam/agent 0.9.108 → 0.9.110
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/dist/cli/main.js +7 -1
- package/dist/model/catalog-file.d.ts +4 -0
- package/dist/model/configuration.d.ts +2 -0
- package/dist/model/configuration.js +3 -0
- package/dist/model/contracts.d.ts +2 -0
- package/dist/model/openai-responses.js +25 -3
- package/dist/sdk/agent.js +72 -2
- package/package.json +1 -1
package/dist/cli/main.js
CHANGED
|
@@ -19,7 +19,7 @@ Usage:
|
|
|
19
19
|
maragent run <prompt> [--reasoning-effort EFFORT] [--format text|json|stream-json] [--codex-auth-file PATH]
|
|
20
20
|
maragent resume [sessionId] [--reasoning-effort EFFORT] [--codex-auth-file PATH]
|
|
21
21
|
maragent sessions list|delete <sessionId>
|
|
22
|
-
maragent models list|add|edit|remove|test [id] [--default-reasoning-effort EFFORT] [--code-mode|--no-code-mode] [--high-density-compaction|--no-high-density-compaction] [--responses-encoding standard|lite] [--codex-auth-file PATH]
|
|
22
|
+
maragent models list|add|edit|remove|test [id] [--default-reasoning-effort EFFORT] [--code-mode|--no-code-mode] [--high-density-compaction|--no-high-density-compaction] [--responses-encoding standard|lite] [--fast-mode|--no-fast-mode] [--codex-auth-file PATH]
|
|
23
23
|
`;
|
|
24
24
|
function takeOption(arguments_, name) {
|
|
25
25
|
const index = arguments_.indexOf(name);
|
|
@@ -132,6 +132,10 @@ async function modelsCommand(home, arguments_, codexAuthFile) {
|
|
|
132
132
|
const credential = option('--credential', existing?.credentialSource === 'CODEX_AUTH_FILE' ? 'codex-auth-file' : 'api-key') ?? 'api-key';
|
|
133
133
|
if (credential !== 'api-key' && credential !== 'codex-auth-file')
|
|
134
134
|
throw new MarAgentError('MAR_AGENT_CLI_ARGUMENT_INVALID', '--credential is invalid.');
|
|
135
|
+
const hasFastModeOption = arguments_.includes('--fast-mode') || arguments_.includes('--no-fast-mode');
|
|
136
|
+
const fastMode = booleanFlag(arguments_, '--fast-mode', '--no-fast-mode', credential === 'codex-auth-file' ? (existing?.fastMode ?? false) : false);
|
|
137
|
+
if (hasFastModeOption && (protocol !== 'OPENAI_RESPONSES' || credential !== 'codex-auth-file'))
|
|
138
|
+
throw new MarAgentError('MAR_AGENT_CLI_ARGUMENT_INVALID', '--fast-mode requires Codex.');
|
|
135
139
|
const readsApiKey = takeFlag(arguments_, '--api-key-stdin');
|
|
136
140
|
if (credential === 'codex-auth-file' && readsApiKey)
|
|
137
141
|
throw new MarAgentError('MAR_AGENT_CLI_ARGUMENT_INVALID', '--api-key-stdin cannot be combined with an external credential.');
|
|
@@ -182,6 +186,7 @@ async function modelsCommand(home, arguments_, codexAuthFile) {
|
|
|
182
186
|
titleGeneration: existing?.titleGeneration ?? false,
|
|
183
187
|
codeMode: booleanFlag(arguments_, '--code-mode', '--no-code-mode', existing?.codeMode ?? false),
|
|
184
188
|
highDensityCompaction: booleanFlag(arguments_, '--high-density-compaction', '--no-high-density-compaction', existing?.highDensityCompaction ?? false),
|
|
189
|
+
...(credential === 'codex-auth-file' && fastMode ? { fastMode: true } : {}),
|
|
185
190
|
hostedWebSearch: booleanFlag(arguments_, '--web-search', '--no-web-search', existing?.hostedWebSearch ?? false),
|
|
186
191
|
...(responsesTransport === undefined ? {} : { responsesTransport }),
|
|
187
192
|
...(responsesEncoding === undefined ? {} : { responsesEncoding }),
|
|
@@ -378,6 +383,7 @@ function runtimeModels(models, codexAuthFile) {
|
|
|
378
383
|
{
|
|
379
384
|
...configuration,
|
|
380
385
|
responsesEncoding: configuration.responsesEncoding ?? 'STANDARD',
|
|
386
|
+
codexCredential: true,
|
|
381
387
|
credentialProvider: provider
|
|
382
388
|
}
|
|
383
389
|
];
|
|
@@ -11,6 +11,7 @@ export declare function readModelCatalog(home: string): Promise<CliModelCatalog>
|
|
|
11
11
|
export declare function writeModelCatalog(home: string, catalog: CliModelCatalog): Promise<void>;
|
|
12
12
|
export declare function serializeModel(model: CliModelConfiguration): {
|
|
13
13
|
apiKey: string;
|
|
14
|
+
codexCredential?: boolean;
|
|
14
15
|
responsesTransport?: import("./configuration.js").ResponsesTransport;
|
|
15
16
|
responsesPreviousResponseId?: boolean;
|
|
16
17
|
id: string;
|
|
@@ -27,6 +28,7 @@ export declare function serializeModel(model: CliModelConfiguration): {
|
|
|
27
28
|
titleGeneration: boolean;
|
|
28
29
|
codeMode: boolean;
|
|
29
30
|
highDensityCompaction: boolean;
|
|
31
|
+
fastMode?: boolean | undefined;
|
|
30
32
|
hostedWebSearch: boolean;
|
|
31
33
|
responsesEncoding?: "STANDARD" | "LITE" | undefined;
|
|
32
34
|
enabled: boolean;
|
|
@@ -34,6 +36,7 @@ export declare function serializeModel(model: CliModelConfiguration): {
|
|
|
34
36
|
credential: {
|
|
35
37
|
type: "CODEX_AUTH_FILE";
|
|
36
38
|
};
|
|
39
|
+
codexCredential?: boolean;
|
|
37
40
|
responsesTransport?: import("./configuration.js").ResponsesTransport;
|
|
38
41
|
responsesPreviousResponseId?: boolean;
|
|
39
42
|
id: string;
|
|
@@ -50,6 +53,7 @@ export declare function serializeModel(model: CliModelConfiguration): {
|
|
|
50
53
|
titleGeneration: boolean;
|
|
51
54
|
codeMode: boolean;
|
|
52
55
|
highDensityCompaction: boolean;
|
|
56
|
+
fastMode?: boolean | undefined;
|
|
53
57
|
hostedWebSearch: boolean;
|
|
54
58
|
responsesEncoding?: "STANDARD" | "LITE" | undefined;
|
|
55
59
|
enabled: boolean;
|
|
@@ -70,6 +70,7 @@ declare const rawModelSchema: z.ZodObject<{
|
|
|
70
70
|
titleGeneration: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
71
71
|
codeMode: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
72
72
|
highDensityCompaction: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
73
|
+
fastMode: z.ZodOptional<z.ZodBoolean>;
|
|
73
74
|
hostedWebSearch: z.ZodBoolean;
|
|
74
75
|
responsesTransport: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
75
76
|
transport: z.ZodLiteral<"HTTP">;
|
|
@@ -90,6 +91,7 @@ declare const rawModelSchema: z.ZodObject<{
|
|
|
90
91
|
export interface MarAgentModelConfiguration extends Omit<z.infer<typeof rawModelSchema>, 'apiKey' | 'responsesPreviousResponseId' | 'responsesTransport'> {
|
|
91
92
|
apiKey?: SecretValue;
|
|
92
93
|
credentialProvider?: ModelCredentialProvider;
|
|
94
|
+
codexCredential?: boolean;
|
|
93
95
|
responsesTransport?: ResponsesTransport;
|
|
94
96
|
responsesPreviousResponseId?: boolean;
|
|
95
97
|
}
|
|
@@ -50,6 +50,7 @@ const rawModelSchema = z
|
|
|
50
50
|
titleGeneration: z.boolean().optional().default(false),
|
|
51
51
|
codeMode: z.boolean().optional().default(false),
|
|
52
52
|
highDensityCompaction: z.boolean().optional().default(false),
|
|
53
|
+
fastMode: z.boolean().optional(),
|
|
53
54
|
hostedWebSearch: z.boolean(),
|
|
54
55
|
responsesTransport: rawResponsesTransportSchema.optional(),
|
|
55
56
|
responsesEncoding: z.enum(['STANDARD', 'LITE']).optional(),
|
|
@@ -89,6 +90,8 @@ const rawModelSchema = z
|
|
|
89
90
|
context.addIssue({ code: 'custom', message: 'Responses transport requires Responses.' });
|
|
90
91
|
if (value.protocol !== 'OPENAI_RESPONSES' && value.responsesEncoding !== undefined)
|
|
91
92
|
context.addIssue({ code: 'custom', message: 'Responses encoding requires Responses.' });
|
|
93
|
+
if (value.protocol !== 'OPENAI_RESPONSES' && value.fastMode === true)
|
|
94
|
+
context.addIssue({ code: 'custom', message: 'Fast mode requires Responses.' });
|
|
92
95
|
});
|
|
93
96
|
export function resolveModelDefaultReasoningEffort(model) {
|
|
94
97
|
const configured = marAgentReasoningEffortSchema.safeParse(model.defaultReasoningEffort);
|
|
@@ -65,6 +65,8 @@ export interface ModelRequest {
|
|
|
65
65
|
/** Preserve the visible tool catalog while controlling whether the model may call it. */
|
|
66
66
|
toolChoice?: 'auto' | 'none';
|
|
67
67
|
reasoningEffort?: MarAgentReasoningEffort;
|
|
68
|
+
/** Stable request-level effort while native configuration updates select the current effort. */
|
|
69
|
+
requestReasoningEffort?: MarAgentReasoningEffort;
|
|
68
70
|
promptCacheKey?: string;
|
|
69
71
|
images?: readonly {
|
|
70
72
|
mimeType: string;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { isDeepStrictEqual } from 'node:util';
|
|
2
2
|
import { createHash, randomUUID } from 'node:crypto';
|
|
3
3
|
import { describeMarAgentError, MarAgentError } from '../error.js';
|
|
4
|
-
import { resolveModelDefaultReasoningEffort } from './configuration.js';
|
|
4
|
+
import { marAgentReasoningEffortSchema, resolveModelDefaultReasoningEffort } from './configuration.js';
|
|
5
5
|
import WebSocket from 'ws';
|
|
6
6
|
import { isRetryableUpstreamOverloadCode, number, parseSse, record, text } from './sse.js';
|
|
7
7
|
import { connectSocks5Target, fetchModelResponse, isRetryableModelHttpStatus, isRetryableModelTransportError, modelRetryMaxAttempts, isRetryableModelRequestError, modelRetryDelay, waitForModelRetry } from './http.js';
|
|
@@ -872,6 +872,7 @@ function responsesRequestBody(configuration, request, messages, prefixIdentity =
|
|
|
872
872
|
}
|
|
873
873
|
return {
|
|
874
874
|
model: configuration.modelId,
|
|
875
|
+
...(configuration.fastMode === true ? { service_tier: 'priority' } : {}),
|
|
875
876
|
...(lite
|
|
876
877
|
? {
|
|
877
878
|
tool_choice: toolChoice,
|
|
@@ -886,7 +887,9 @@ function responsesRequestBody(configuration, request, messages, prefixIdentity =
|
|
|
886
887
|
include: ['reasoning.encrypted_content'],
|
|
887
888
|
...(request.promptCacheKey ? { prompt_cache_key: request.promptCacheKey } : {}),
|
|
888
889
|
reasoning: {
|
|
889
|
-
effort: request.
|
|
890
|
+
effort: request.requestReasoningEffort?.trim() ||
|
|
891
|
+
request.reasoningEffort?.trim() ||
|
|
892
|
+
resolveModelDefaultReasoningEffort(configuration),
|
|
890
893
|
summary: 'auto',
|
|
891
894
|
...(lite ? { context: 'all_turns' } : {})
|
|
892
895
|
}
|
|
@@ -922,6 +925,7 @@ function incrementalResponsesInput(state, current) {
|
|
|
922
925
|
function responsesContinuationPropertiesMatch(previous, current) {
|
|
923
926
|
const properties = [
|
|
924
927
|
'model',
|
|
928
|
+
'service_tier',
|
|
925
929
|
'instructions',
|
|
926
930
|
'tools',
|
|
927
931
|
'tool_choice',
|
|
@@ -1614,7 +1618,20 @@ export function openAiInput(messages, images, modelId, requireEncryptedReasoning
|
|
|
1614
1618
|
for (const message of compatibleMessages)
|
|
1615
1619
|
if (message.role === 'tool_call' && message.inputMode === 'freeform' && message.callId)
|
|
1616
1620
|
customCallIds.add(message.callId);
|
|
1617
|
-
|
|
1621
|
+
const orderedMessages = [];
|
|
1622
|
+
for (const message of compatibleMessages) {
|
|
1623
|
+
if (message.role === 'provider' && message.item?.type === 'configuration_update') {
|
|
1624
|
+
const userIndex = orderedMessages.findLastIndex((candidate) => candidate.role === 'user');
|
|
1625
|
+
if (userIndex >= 0) {
|
|
1626
|
+
orderedMessages.splice(userIndex, 0, message);
|
|
1627
|
+
continue;
|
|
1628
|
+
}
|
|
1629
|
+
}
|
|
1630
|
+
orderedMessages.push(message);
|
|
1631
|
+
}
|
|
1632
|
+
// SDK records the update after the user input; the wire item must precede
|
|
1633
|
+
// that user message so the new effort applies to the response.
|
|
1634
|
+
return orderedMessages
|
|
1618
1635
|
.filter((message) => !(message.role === 'tool_call' && message.callId && providerCallIds.has(message.callId)) &&
|
|
1619
1636
|
!(message.role === 'assistant' && providerMessageTexts.has(message.content)))
|
|
1620
1637
|
.map((message) => openAiInputItem(message, message === lastUser ? images : undefined, customCallIds));
|
|
@@ -1624,6 +1641,11 @@ function openAiInputItem(message, images, customCallIds = new Set()) {
|
|
|
1624
1641
|
if (message.role === 'provider') {
|
|
1625
1642
|
if (message.provider !== 'OPENAI_RESPONSES' || !message.item)
|
|
1626
1643
|
throw new MarAgentError('MAR_AGENT_MODEL_PROTOCOL_ERROR', 'Provider context item is invalid.');
|
|
1644
|
+
if (message.item.type === 'configuration_update') {
|
|
1645
|
+
const effort = marAgentReasoningEffortSchema.safeParse(record(message.item.reasoning).effort);
|
|
1646
|
+
if (effort.success)
|
|
1647
|
+
return { type: 'configuration_update', reasoning: { effort: effort.data } };
|
|
1648
|
+
}
|
|
1627
1649
|
const item = responseItem(message.item);
|
|
1628
1650
|
if (!item)
|
|
1629
1651
|
throw new MarAgentError('MAR_AGENT_MODEL_PROTOCOL_ERROR', 'Provider context item type is unsupported.');
|
package/dist/sdk/agent.js
CHANGED
|
@@ -3,7 +3,7 @@ import { isDeepStrictEqual } from 'node:util';
|
|
|
3
3
|
import { describeMarAgentError, MarAgentError } from '../error.js';
|
|
4
4
|
import { negotiateHost } from '../host/contracts.js';
|
|
5
5
|
import { AnthropicMessagesAdapter, isAnthropicRecoverableStreamError } from '../model/anthropic-messages.js';
|
|
6
|
-
import { resolveModelDefaultReasoningEffort } from '../model/configuration.js';
|
|
6
|
+
import { marAgentReasoningEffortSchema, resolveModelDefaultReasoningEffort } from '../model/configuration.js';
|
|
7
7
|
import { modelRetryMaxAttempts, isRetryableModelRequestError, waitForModelRetry } from '../model/http.js';
|
|
8
8
|
import { OpenAiResponsesAdapter, isOpenAiResponsesRecoverableStreamError } from '../model/openai-responses.js';
|
|
9
9
|
import { AsyncQueue } from '../runtime/async-queue.js';
|
|
@@ -400,6 +400,39 @@ export async function createMarAgent(options) {
|
|
|
400
400
|
let lastServerUsage = latestModelUsage(contextRecords, selectedModel.id);
|
|
401
401
|
const compactUserTokenLimit = Math.min(20_000, Math.floor(selectedModel.contextWindowTokens / 8));
|
|
402
402
|
const reasoningEffort = input.reasoningEffort ?? selectedModel.defaultReasoningEffort;
|
|
403
|
+
const useEffortUpdates = selectedModel.protocol === 'OPENAI_RESPONSES' &&
|
|
404
|
+
selectedModel.responsesEncoding !== 'LITE' &&
|
|
405
|
+
selectedModel.codexCredential === true;
|
|
406
|
+
const previousReasoningEffort = useEffortUpdates
|
|
407
|
+
? reasoningEffortBaseline(contextRecords, selectedModel.id)
|
|
408
|
+
: undefined;
|
|
409
|
+
let requestReasoningEffort = useEffortUpdates
|
|
410
|
+
? (previousReasoningEffort ?? reasoningEffort)
|
|
411
|
+
: undefined;
|
|
412
|
+
let effectiveReasoningEffort = useEffortUpdates
|
|
413
|
+
? previousReasoningEffort === undefined
|
|
414
|
+
? requestReasoningEffort
|
|
415
|
+
: (lastConfigurationEffort(messages, selectedModel.id) ?? requestReasoningEffort)
|
|
416
|
+
: undefined;
|
|
417
|
+
if (mode !== 'compact' &&
|
|
418
|
+
useEffortUpdates &&
|
|
419
|
+
effectiveReasoningEffort !== reasoningEffort) {
|
|
420
|
+
const update = {
|
|
421
|
+
role: 'provider',
|
|
422
|
+
content: '',
|
|
423
|
+
provider: 'OPENAI_RESPONSES',
|
|
424
|
+
providerModelId: selectedModel.id,
|
|
425
|
+
item: { type: 'configuration_update', reasoning: { effort: reasoningEffort } }
|
|
426
|
+
};
|
|
427
|
+
messages.push(update);
|
|
428
|
+
await store.append(sessionId, {
|
|
429
|
+
type: 'model.context',
|
|
430
|
+
payload: update,
|
|
431
|
+
executionId,
|
|
432
|
+
turnId
|
|
433
|
+
});
|
|
434
|
+
effectiveReasoningEffort = reasoningEffort;
|
|
435
|
+
}
|
|
403
436
|
if (mode !== 'compact' && subagents)
|
|
404
437
|
await subagents.beginParentExecution({
|
|
405
438
|
executionId,
|
|
@@ -646,7 +679,7 @@ export async function createMarAgent(options) {
|
|
|
646
679
|
tools: executionTools,
|
|
647
680
|
toolChoice: 'none',
|
|
648
681
|
promptCacheKey: sessionId,
|
|
649
|
-
reasoningEffort,
|
|
682
|
+
reasoningEffort: requestReasoningEffort ?? reasoningEffort,
|
|
650
683
|
onAttemptDiagnostic: recordModelAttempt('COMPACTION')
|
|
651
684
|
})) {
|
|
652
685
|
if (event.type === 'text.completed' &&
|
|
@@ -713,6 +746,8 @@ export async function createMarAgent(options) {
|
|
|
713
746
|
await persistContextualWorldState(store, sessionId, contextualWorldState);
|
|
714
747
|
lastServerContextTokens = undefined;
|
|
715
748
|
lastServerUsage = undefined;
|
|
749
|
+
requestReasoningEffort = reasoningEffort;
|
|
750
|
+
effectiveReasoningEffort = reasoningEffort;
|
|
716
751
|
await emit({ type: 'context.compacted', compactionId });
|
|
717
752
|
return true;
|
|
718
753
|
};
|
|
@@ -796,6 +831,7 @@ export async function createMarAgent(options) {
|
|
|
796
831
|
: { allowTools: false }),
|
|
797
832
|
promptCacheKey: sessionId,
|
|
798
833
|
reasoningEffort,
|
|
834
|
+
...(requestReasoningEffort === undefined ? {} : { requestReasoningEffort }),
|
|
799
835
|
...(modelInputImages?.length ? { images: modelInputImages } : {}),
|
|
800
836
|
onAttemptDiagnostic: recordModelAttempt(mode === 'compact' ? 'COMPACTION' : 'EXECUTION')
|
|
801
837
|
})) {
|
|
@@ -1496,6 +1532,8 @@ function resolveAgentModels(configurations, requestedDefaultModelId) {
|
|
|
1496
1532
|
(model.protocol !== 'OPENAI_RESPONSES' ||
|
|
1497
1533
|
!['STANDARD', 'LITE'].includes(model.responsesEncoding)))
|
|
1498
1534
|
throw new MarAgentError('MAR_AGENT_MODEL_CONFIG_INVALID', 'Responses encoding is invalid.');
|
|
1535
|
+
if (model.fastMode === true && model.protocol !== 'OPENAI_RESPONSES')
|
|
1536
|
+
throw new MarAgentError('MAR_AGENT_MODEL_CONFIG_INVALID', 'Fast mode requires Responses.');
|
|
1499
1537
|
if (model.credentialProvider !== undefined)
|
|
1500
1538
|
credentialProviders.add(model.credentialProvider);
|
|
1501
1539
|
}
|
|
@@ -1754,6 +1792,38 @@ function latestModelUsage(records, selectedModelId) {
|
|
|
1754
1792
|
}
|
|
1755
1793
|
return usage;
|
|
1756
1794
|
}
|
|
1795
|
+
function reasoningEffortBaseline(records, modelId) {
|
|
1796
|
+
let baseline;
|
|
1797
|
+
for (let index = records.length - 1; index >= 0; index--) {
|
|
1798
|
+
const record = records[index];
|
|
1799
|
+
if (compactSummaryFromCheckpoint(record) !== undefined)
|
|
1800
|
+
break;
|
|
1801
|
+
if (record.type !== 'execution.header')
|
|
1802
|
+
continue;
|
|
1803
|
+
const payload = record.payload;
|
|
1804
|
+
if (payload.modelId !== modelId)
|
|
1805
|
+
break;
|
|
1806
|
+
const effort = marAgentReasoningEffortSchema.safeParse(payload.reasoningEffort);
|
|
1807
|
+
if (effort.success)
|
|
1808
|
+
baseline = effort.data;
|
|
1809
|
+
}
|
|
1810
|
+
return baseline;
|
|
1811
|
+
}
|
|
1812
|
+
function lastConfigurationEffort(messages, modelId) {
|
|
1813
|
+
for (let index = messages.length - 1; index >= 0; index--) {
|
|
1814
|
+
const message = messages[index];
|
|
1815
|
+
if (message.role !== 'provider' ||
|
|
1816
|
+
message.provider !== 'OPENAI_RESPONSES' ||
|
|
1817
|
+
message.providerModelId !== modelId ||
|
|
1818
|
+
message.item?.type !== 'configuration_update')
|
|
1819
|
+
continue;
|
|
1820
|
+
const reasoning = message.item.reasoning;
|
|
1821
|
+
const effort = marAgentReasoningEffortSchema.safeParse(reasoning?.effort);
|
|
1822
|
+
if (effort.success)
|
|
1823
|
+
return effort.data;
|
|
1824
|
+
}
|
|
1825
|
+
return undefined;
|
|
1826
|
+
}
|
|
1757
1827
|
function shouldUseNativeCompaction(input) {
|
|
1758
1828
|
if (input.estimatedRequestTokens <= input.contextWindowTokens)
|
|
1759
1829
|
return true;
|