@qoder-ai/qoder-agent-sdk 1.0.21 → 1.0.23
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 +12 -8
- package/dist/core/process-transport.d.ts +2 -0
- package/dist/core/runtime-launch-options.d.ts +2 -0
- package/dist/index.d.ts +3 -2
- package/dist/index.js +28 -28
- package/dist/protocol/control.d.ts +44 -79
- package/dist/protocol/index.d.ts +1 -1
- package/dist/protocol/index.js +1 -1
- package/dist/protocol/messages.d.ts +19 -0
- package/dist/runtime-manifest.json +6 -6
- package/dist/types/messages.d.ts +3 -1
- package/dist/types/model-policy-provider.d.ts +10 -0
- package/dist/types/options.d.ts +19 -0
- package/dist/types/session.d.ts +5 -0
- package/dist/types/tools.d.ts +15 -1
- package/package.json +2 -2
- package/scripts/postinstall.cjs +144 -24
|
@@ -231,6 +231,16 @@ export type SDKControlGetModelPolicyResponse = {
|
|
|
231
231
|
* the supplied API key instead of the default upstream.
|
|
232
232
|
*/
|
|
233
233
|
custom_model?: CustomModel;
|
|
234
|
+
/**
|
|
235
|
+
* Optional routing scene label the CLI forwards as the inference request
|
|
236
|
+
* body `task_id`.
|
|
237
|
+
*/
|
|
238
|
+
task_id?: string;
|
|
239
|
+
/**
|
|
240
|
+
* Optional business sub-task label the CLI forwards as `business.sub_task`
|
|
241
|
+
* on the inference request (billing/analytics).
|
|
242
|
+
*/
|
|
243
|
+
sub_task?: string;
|
|
234
244
|
};
|
|
235
245
|
export type SDKControlSetMaxThinkingTokensRequest = {
|
|
236
246
|
type: 'set_max_thinking_tokens';
|
|
@@ -514,93 +524,48 @@ export type SDKControlInitializeResponse = {
|
|
|
514
524
|
capabilities?: string[];
|
|
515
525
|
};
|
|
516
526
|
export type SDKControlGetContextUsageResponse = {
|
|
527
|
+
model: string;
|
|
528
|
+
contextWindow: {
|
|
529
|
+
/** Context occupancy as a percentage from 0 to 100. */
|
|
530
|
+
usedPercentage: number;
|
|
531
|
+
};
|
|
532
|
+
/** Local estimates in the same order and category model as `/context`. */
|
|
517
533
|
categories: Array<{
|
|
518
|
-
|
|
519
|
-
tokens: number;
|
|
520
|
-
color: string;
|
|
521
|
-
isDeferred?: boolean;
|
|
522
|
-
}>;
|
|
523
|
-
totalTokens: number;
|
|
524
|
-
maxTokens: number;
|
|
525
|
-
rawMaxTokens: number;
|
|
526
|
-
percentage: number;
|
|
527
|
-
gridRows: Array<Array<{
|
|
528
|
-
color: string;
|
|
529
|
-
isFilled: boolean;
|
|
530
|
-
categoryName: string;
|
|
531
|
-
tokens: number;
|
|
534
|
+
type: 'system_prompt' | 'system_tools' | 'skills' | 'messages' | 'other' | 'free_space' | 'auto_compact';
|
|
532
535
|
percentage: number;
|
|
533
|
-
squareFullness: number;
|
|
534
|
-
}>>;
|
|
535
|
-
model: string;
|
|
536
|
-
memoryFiles: Array<{
|
|
537
|
-
path: string;
|
|
538
|
-
type: string;
|
|
539
|
-
tokens: number;
|
|
540
|
-
}>;
|
|
541
|
-
mcpTools: Array<{
|
|
542
|
-
name: string;
|
|
543
|
-
serverName: string;
|
|
544
|
-
tokens: number;
|
|
545
|
-
isLoaded?: boolean;
|
|
546
536
|
}>;
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
isLoaded: boolean;
|
|
551
|
-
}>;
|
|
552
|
-
systemTools?: Array<{
|
|
553
|
-
name: string;
|
|
554
|
-
tokens: number;
|
|
555
|
-
}>;
|
|
556
|
-
systemPromptSections?: Array<{
|
|
557
|
-
name: string;
|
|
558
|
-
tokens: number;
|
|
559
|
-
}>;
|
|
560
|
-
agents: Array<{
|
|
561
|
-
agentType: string;
|
|
562
|
-
source: string;
|
|
563
|
-
tokens: number;
|
|
564
|
-
}>;
|
|
565
|
-
slashCommands?: {
|
|
566
|
-
totalCommands: number;
|
|
567
|
-
includedCommands: number;
|
|
568
|
-
tokens: number;
|
|
537
|
+
autoCompact: {
|
|
538
|
+
enabled: boolean;
|
|
539
|
+
thresholdPercentage: number;
|
|
569
540
|
};
|
|
570
|
-
skills
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
541
|
+
skills: {
|
|
542
|
+
count: number;
|
|
543
|
+
/** Aggregate skill frontmatter as a percentage of the full context. */
|
|
544
|
+
percentageOfContext: number;
|
|
545
|
+
items: Array<{
|
|
575
546
|
name: string;
|
|
576
|
-
source:
|
|
577
|
-
|
|
547
|
+
source: 'project' | 'user' | 'built-in' | 'plugin';
|
|
548
|
+
/** This skill's frontmatter as a percentage of the full context. */
|
|
549
|
+
percentageOfContext: number;
|
|
578
550
|
}>;
|
|
579
551
|
};
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
}>;
|
|
552
|
+
duplicateFileReads: Array<{
|
|
553
|
+
path: string;
|
|
554
|
+
count: number;
|
|
555
|
+
}>;
|
|
556
|
+
session: {
|
|
557
|
+
messageCount: number;
|
|
558
|
+
promptCount: number;
|
|
559
|
+
toolCalls: {
|
|
560
|
+
total: number;
|
|
561
|
+
succeeded: number;
|
|
562
|
+
failed: number;
|
|
563
|
+
};
|
|
564
|
+
linesChanged: {
|
|
565
|
+
added: number;
|
|
566
|
+
removed: number;
|
|
567
|
+
};
|
|
597
568
|
};
|
|
598
|
-
apiUsage: {
|
|
599
|
-
input_tokens: number;
|
|
600
|
-
output_tokens: number;
|
|
601
|
-
cache_creation_input_tokens: number;
|
|
602
|
-
cache_read_input_tokens: number;
|
|
603
|
-
} | null;
|
|
604
569
|
};
|
|
605
570
|
export type SDKControlReloadPluginsResponse = {
|
|
606
571
|
commands: SlashCommand[];
|
package/dist/protocol/index.d.ts
CHANGED
|
@@ -19,7 +19,7 @@ export type { AICodeTrackingLaunchOptions, QoderAgentLaunchOptions, QoderCliFlag
|
|
|
19
19
|
export { buildQoderCliFlagSettings, buildQoderCliFlagSettingsArgs, } from './launch.js';
|
|
20
20
|
export type { PermissionMode, PermissionBehavior, PermissionDecisionClassification, PermissionUpdateDestination, PermissionRuleValue, PermissionUpdate, PermissionResult, } from './permissions.js';
|
|
21
21
|
export type { McpStdioServerConfig, McpSSEServerConfig, McpHttpServerConfig, McpSdkServerConfig, McpServerConfigForProcessTransport, McpServerStatus, McpServerStatusConfig, McpSetServersResult, OAuthToken, } from './mcp.js';
|
|
22
|
-
export type { SDKAssistantMessage, SDKUserMessage, SDKUserMessageReplay, SDKResultSuccess, SDKResultError, SDKResultMessage, SDKFileAttachment, SDKSystemMessage, SDKPartialAssistantMessage, SDKCompactBoundaryMessage, SDKStatusMessage, SDKAPIRetryMessage, SDKHookStartedMessage, SDKHookProgressMessage, SDKHookResponseMessage, SDKTaskNotificationMessage, SDKTaskStartedMessage, SDKTaskProgressMessage, SDKTaskUpdatedMessage, SDKBackgroundTasksChangedMessage, SDKSessionStateChangedMessage, SDKSessionTitleChangedMessage, SDKFilesPersistedEvent, SDKElicitationCompleteMessage, SDKPromptSuggestionMessage, SDKCloudAgentEventMessage, SDKPermissionDenial, SDKPermissionDeniedMessage, SDKPermissionDeniedReasonType, SDKMessage, } from './messages.js';
|
|
22
|
+
export type { SDKAssistantMessage, SDKToolNonExecutionKind, SDKToolResultMeta, SDKUserMessage, SDKUserMessageReplay, SDKResultSuccess, SDKResultError, SDKResultMessage, SDKFileAttachment, SDKSystemMessage, SDKPartialAssistantMessage, SDKCompactBoundaryMessage, SDKStatusMessage, SDKAPIRetryMessage, SDKHookStartedMessage, SDKHookProgressMessage, SDKHookResponseMessage, SDKTaskNotificationMessage, SDKTaskStartedMessage, SDKTaskProgressMessage, SDKTaskUpdatedMessage, SDKBackgroundTasksChangedMessage, SDKSessionStateChangedMessage, SDKSessionTitleChangedMessage, SDKFilesPersistedEvent, SDKElicitationCompleteMessage, SDKPromptSuggestionMessage, SDKCloudAgentEventMessage, SDKPermissionDenial, SDKPermissionDeniedMessage, SDKPermissionDeniedReasonType, SDKMessage, } from './messages.js';
|
|
23
23
|
export type { BaseHookInput, PreToolUseHookInput, PostToolUseHookInput, PostToolUseFailureHookInput, UserPromptSubmitHookInput, SessionStartHookInput, SessionEndHookInput, StopHookInput, StopFailureHookInput, SubagentStartHookInput, SubagentStopHookInput, PreCompactHookInput, PostCompactHookInput, PermissionRequestHookInput, PermissionDeniedHookInput, SetupHookInput, TeammateIdleHookInput, TaskCreatedHookInput, TaskCompletedHookInput, ElicitationHookInput, ElicitationResultHookInput, ConfigChangeHookInput, WorktreeCreateHookInput, WorktreeRemoveHookInput, InstructionsLoadedHookInput, CwdChangedHookInput, FileChangedHookInput, HookInput, PreToolUseHookSpecificOutput, PostToolUseHookSpecificOutput, PostToolUseFailureHookSpecificOutput, UserPromptSubmitHookSpecificOutput, SessionStartHookSpecificOutput, SetupHookSpecificOutput, SubagentStartHookSpecificOutput, PermissionRequestHookSpecificOutput, ElicitationHookSpecificOutput, ElicitationResultHookSpecificOutput, CwdChangedHookSpecificOutput, FileChangedHookSpecificOutput, WorktreeCreateHookSpecificOutput, SyncHookJSONOutput, AsyncHookJSONOutput, HookJSONOutput, HookEvent, } from './hooks.js';
|
|
24
24
|
export type { AgentMcpServerSpec, AgentDefinition, AgentInfo, AgentMemoryScope, } from './agents.js';
|
|
25
25
|
export { QoderModelPurpose } from './control.js';
|
package/dist/protocol/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var r="1.2.0";function i(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function n(e={}){let t={...e.settings??{}},o=e.aiCodeTracking?.installGitCommitHook;if(o!==void 0){let s=t.aiCodeTracking;t.aiCodeTracking={...i(s)?s:{},installGitCommitHook:o}}return t}function
|
|
1
|
+
var r="1.2.0";function i(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function n(e={}){let t={...e.settings??{}},o=e.aiCodeTracking?.installGitCommitHook;if(o!==void 0){let s=t.aiCodeTracking;t.aiCodeTracking={...i(s)?s:{},installGitCommitHook:o}}return t}function p(e={}){let t=n(e);return Object.keys(t).length===0?[]:["--settings",JSON.stringify(t)]}var l={Main:"main",Plan:"plan",Task:"task",Compact:"compact",Title:"title",Suggestion:"suggestion",Generate:"generate",HookPrompt:"hook_prompt",Subagent:"subagent",WebFetch:"web_fetch",ImageGen:"image_gen",Compression:"compression",Utility:"utility"};export{l as QoderModelPurpose,r as WIRE_PROTOCOL_VERSION,n as buildQoderCliFlagSettings,p as buildQoderCliFlagSettingsArgs};
|
|
@@ -17,6 +17,13 @@ export type SDKAssistantMessage = {
|
|
|
17
17
|
type: 'assistant';
|
|
18
18
|
message: BetaMessage;
|
|
19
19
|
parent_tool_use_id: string | null;
|
|
20
|
+
/**
|
|
21
|
+
* Present when qodercli synthesized this Assistant message from an API
|
|
22
|
+
* failure rather than a model response. Embedded hosts can use the marker to
|
|
23
|
+
* avoid rendering duplicate error text when the terminal Result already
|
|
24
|
+
* provides a structured error surface.
|
|
25
|
+
*/
|
|
26
|
+
isApiErrorMessage?: true;
|
|
20
27
|
/** Qoder model request ID, present only when explicitly enabled in the CLI. */
|
|
21
28
|
request_id?: string;
|
|
22
29
|
error?: SDKAssistantMessageError;
|
|
@@ -28,6 +35,16 @@ export type SDKAssistantMessage = {
|
|
|
28
35
|
uuid: UUID;
|
|
29
36
|
session_id: string;
|
|
30
37
|
};
|
|
38
|
+
export type SDKToolNonExecutionKind = 'user-rejected' | 'permission-rule' | 'automode-blocked' | 'automode-unavailable' | 'automode-parsing-error' | 'interrupted' | 'cancelled';
|
|
39
|
+
/**
|
|
40
|
+
* Display-only metadata for a tool result whose tool did not run to
|
|
41
|
+
* completion. This wrapper-level field is never part of the model message.
|
|
42
|
+
*/
|
|
43
|
+
export type SDKToolResultMeta = {
|
|
44
|
+
id: string;
|
|
45
|
+
non_execution_kind: SDKToolNonExecutionKind;
|
|
46
|
+
user_feedback?: string;
|
|
47
|
+
};
|
|
31
48
|
export type SDKUserMessage = {
|
|
32
49
|
type: 'user';
|
|
33
50
|
message: MessageParam;
|
|
@@ -35,6 +52,7 @@ export type SDKUserMessage = {
|
|
|
35
52
|
file_attachments?: SDKFileAttachment[];
|
|
36
53
|
isSynthetic?: boolean;
|
|
37
54
|
tool_use_result?: unknown;
|
|
55
|
+
tool_result_meta?: SDKToolResultMeta[];
|
|
38
56
|
/**
|
|
39
57
|
* Delivery priority. `next` is the default; `now` interrupts the active
|
|
40
58
|
* turn, while `later` waits for the session to become idle.
|
|
@@ -57,6 +75,7 @@ export type SDKUserMessageReplay = {
|
|
|
57
75
|
file_attachments?: SDKFileAttachment[];
|
|
58
76
|
isSynthetic?: boolean;
|
|
59
77
|
tool_use_result?: unknown;
|
|
78
|
+
tool_result_meta?: SDKToolResultMeta[];
|
|
60
79
|
/**
|
|
61
80
|
* Delivery priority. `next` is the default; `now` interrupts the active
|
|
62
81
|
* turn, while `later` waits for the session to become idle.
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 1,
|
|
3
3
|
"brand": "global",
|
|
4
|
-
"sdkVersion": "1.0.
|
|
5
|
-
"qoderCliVersion": "1.1.
|
|
4
|
+
"sdkVersion": "1.0.23",
|
|
5
|
+
"qoderCliVersion": "1.1.23",
|
|
6
6
|
"defaultTransport": "worker",
|
|
7
7
|
"workerRuntime": {
|
|
8
8
|
"packaged": false,
|
|
9
9
|
"delivery": "install",
|
|
10
10
|
"source": "qodercli-worker-runtime",
|
|
11
|
-
"
|
|
12
|
-
"
|
|
13
|
-
"sdkVersion": "1.0.
|
|
14
|
-
"qoderCliVersion": "1.1.
|
|
11
|
+
"urlTemplate": "https://download.qoder.com/qodercli/releases/1.1.23/qodercli-worker-runtime-{target}.tgz",
|
|
12
|
+
"artifactNameTemplate": "qodercli-worker-runtime-{target}.tgz",
|
|
13
|
+
"sdkVersion": "1.0.23",
|
|
14
|
+
"qoderCliVersion": "1.1.23"
|
|
15
15
|
}
|
|
16
16
|
}
|
package/dist/types/messages.d.ts
CHANGED
|
@@ -9,13 +9,15 @@ import type { SDKMessage as ProtocolSDKMessage, SDKStatusMessage as ProtocolSDKS
|
|
|
9
9
|
import type { MessageParam, UUID } from './common.js';
|
|
10
10
|
import type { PermissionMode } from './permissions.js';
|
|
11
11
|
import type { SessionKey } from '../session/session-store.js';
|
|
12
|
-
export type { SDKAssistantMessage, SDKResultSuccess, SDKResultError, SDKResultMessage, SDKPartialAssistantMessage, SDKCompactBoundaryMessage, SDKAPIRetryMessage, SDKHookStartedMessage, SDKHookProgressMessage, SDKHookResponseMessage, SDKTaskNotificationMessage, SDKTaskStartedMessage, SDKTaskProgressMessage, SDKTaskUpdatedMessage, SDKBackgroundTasksChangedMessage, SDKSessionStateChangedMessage, SDKSessionTitleChangedMessage, SDKFilesPersistedEvent, SDKElicitationCompleteMessage, SDKPromptSuggestionMessage, SDKCloudAgentEventMessage, SDKPermissionDenial, } from '../protocol/index.js';
|
|
12
|
+
export type { SDKAssistantMessage, SDKResultSuccess, SDKResultError, SDKResultMessage, SDKPartialAssistantMessage, SDKCompactBoundaryMessage, SDKAPIRetryMessage, SDKHookStartedMessage, SDKHookProgressMessage, SDKHookResponseMessage, SDKTaskNotificationMessage, SDKTaskStartedMessage, SDKTaskProgressMessage, SDKTaskUpdatedMessage, SDKBackgroundTasksChangedMessage, SDKSessionStateChangedMessage, SDKSessionTitleChangedMessage, SDKFilesPersistedEvent, SDKElicitationCompleteMessage, SDKPromptSuggestionMessage, SDKCloudAgentEventMessage, SDKPermissionDenial, SDKToolNonExecutionKind, SDKToolResultMeta, } from '../protocol/index.js';
|
|
13
13
|
export type SDKUserMessage = {
|
|
14
14
|
type: 'user';
|
|
15
15
|
message: MessageParam;
|
|
16
16
|
parent_tool_use_id: string | null;
|
|
17
17
|
isSynthetic?: boolean;
|
|
18
18
|
tool_use_result?: unknown;
|
|
19
|
+
/** CLI-stamped display metadata for tool results that did not execute. */
|
|
20
|
+
tool_result_meta?: import('../protocol/index.js').SDKToolResultMeta[];
|
|
19
21
|
/**
|
|
20
22
|
* Delivery priority. `next` is the default; `now` interrupts the active
|
|
21
23
|
* turn, while `later` waits for the session to become idle.
|
|
@@ -48,6 +48,16 @@ export interface ModelPolicyResult {
|
|
|
48
48
|
});
|
|
49
49
|
/** Optional per-request model policy parameters (contextWindow, reasoningEffort). */
|
|
50
50
|
parameters?: Record<string, unknown>;
|
|
51
|
+
/**
|
|
52
|
+
* Optional routing scene label sent as the inference request body `task_id`.
|
|
53
|
+
* The server selects models by it; internal CLI tasks keep their own values.
|
|
54
|
+
*/
|
|
55
|
+
taskId?: string;
|
|
56
|
+
/**
|
|
57
|
+
* Optional business sub-task label sent as `business.sub_task` on the
|
|
58
|
+
* inference request, used for billing/analytics. Not involved in routing.
|
|
59
|
+
*/
|
|
60
|
+
subTask?: string;
|
|
51
61
|
}
|
|
52
62
|
/**
|
|
53
63
|
* Host-registered callback for pull-mode model selection.
|
package/dist/types/options.d.ts
CHANGED
|
@@ -141,6 +141,25 @@ export type Options = {
|
|
|
141
141
|
enableFileCheckpointing?: boolean;
|
|
142
142
|
toolConfig?: ToolConfig;
|
|
143
143
|
forkSession?: boolean;
|
|
144
|
+
/**
|
|
145
|
+
* When resuming, load the conversation chain only through this entry UUID.
|
|
146
|
+
* Use with `resume`; when combined with `forkSession`, the new session starts
|
|
147
|
+
* from this historical point while retaining its file checkpoint history.
|
|
148
|
+
* The UUID may identify any persisted chain entry, not only an assistant
|
|
149
|
+
* message. Use the last entry belonging to the turn that must be kept.
|
|
150
|
+
*/
|
|
151
|
+
resumeSessionAt?: string;
|
|
152
|
+
/**
|
|
153
|
+
* With `resumeSessionAt`, declares the prompt UUID of the turn intended to be
|
|
154
|
+
* discarded. The CLI refuses the truncation if the discarded range contains
|
|
155
|
+
* unrelated work such as a queued prompt or task notification.
|
|
156
|
+
*
|
|
157
|
+
* A refusal is returned as an execution error whose message starts with
|
|
158
|
+
* `Resume rejected by --resume-drops-turn:`. Treat it as a deterministic
|
|
159
|
+
* stale-view conflict: resume without truncation to recover the new evidence
|
|
160
|
+
* instead of retrying the same request.
|
|
161
|
+
*/
|
|
162
|
+
resumeDropsTurn?: string;
|
|
144
163
|
hooks?: Partial<Record<HookEvent, HookCallbackMatcher[]>>;
|
|
145
164
|
onElicitation?: OnElicitation;
|
|
146
165
|
/**
|
package/dist/types/session.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { SDKToolResultMeta } from '../protocol/messages.js';
|
|
1
2
|
export type SDKSessionInfo = {
|
|
2
3
|
/** Unique session identifier (UUID). */
|
|
3
4
|
sessionId: string;
|
|
@@ -31,6 +32,10 @@ export type SessionMessage = {
|
|
|
31
32
|
* messages, depth-one subagents, and transcripts without this metadata.
|
|
32
33
|
*/
|
|
33
34
|
parent_agent_id: string | null;
|
|
35
|
+
/** Present when qodercli persisted an Assistant synthesized from an API failure. */
|
|
36
|
+
isApiErrorMessage?: true;
|
|
37
|
+
/** CLI-stamped display metadata for tool results that did not execute. */
|
|
38
|
+
tool_result_meta?: SDKToolResultMeta[];
|
|
34
39
|
/**
|
|
35
40
|
* ISO 8601 timestamp of when this transcript entry was written to the
|
|
36
41
|
* jsonl file. Mirrors the on-disk `timestamp` field. Optional because
|
package/dist/types/tools.d.ts
CHANGED
|
@@ -62,6 +62,20 @@ export type BashInput = {
|
|
|
62
62
|
description?: string;
|
|
63
63
|
run_in_background?: boolean;
|
|
64
64
|
};
|
|
65
|
+
export type BashToolBackgroundLaunchResult = {
|
|
66
|
+
kind: 'backgrounded';
|
|
67
|
+
pid: number;
|
|
68
|
+
taskId: string;
|
|
69
|
+
outputFile?: string;
|
|
70
|
+
command: string;
|
|
71
|
+
stdout?: string;
|
|
72
|
+
initialOutput: string;
|
|
73
|
+
backgroundReason?: 'user' | 'model' | 'timeout' | 'auto';
|
|
74
|
+
telemetryExecutionId?: string;
|
|
75
|
+
totalLines?: number;
|
|
76
|
+
totalBytes?: number;
|
|
77
|
+
};
|
|
78
|
+
export declare function isBashToolBackgroundLaunchResult(value: unknown): value is BashToolBackgroundLaunchResult;
|
|
65
79
|
export type BashOutput = {
|
|
66
80
|
stdout: string;
|
|
67
81
|
stderr: string;
|
|
@@ -372,4 +386,4 @@ export type McpOutput = {
|
|
|
372
386
|
isError?: boolean;
|
|
373
387
|
};
|
|
374
388
|
export type ToolInputSchemas = AgentInput | BashInput | FileReadInput | FileEditInput | FileWriteInput | GlobInput | GrepInput | WebFetchInput | WebSearchInput | AskUserQuestionInput | NotebookEditInput | TaskStopInput | TaskCreateInput | TaskGetInput | TaskUpdateInput | TaskListInput | ExitPlanModeInput | ConfigInput | EnterWorktreeInput | ExitWorktreeInput | TodoWriteInput | ListMcpResourcesInput | ReadMcpResourceInput | McpInput;
|
|
375
|
-
export type ToolOutputSchemas = AgentOutput | BashOutput | FileReadOutput | FileEditOutput | FileWriteOutput | GlobOutput | GrepOutput | WebFetchOutput | WebSearchOutput | AskUserQuestionOutput | NotebookEditOutput | TaskStopOutput | TaskCreateOutput | TaskGetOutput | TaskUpdateOutput | TaskListOutput | ExitPlanModeOutput | ConfigOutput | EnterWorktreeOutput | ExitWorktreeOutput | TodoWriteOutput | ListMcpResourcesOutput | McpOutput;
|
|
389
|
+
export type ToolOutputSchemas = AgentOutput | BashToolBackgroundLaunchResult | BashOutput | FileReadOutput | FileEditOutput | FileWriteOutput | GlobOutput | GrepOutput | WebFetchOutput | WebSearchOutput | AskUserQuestionOutput | NotebookEditOutput | TaskStopOutput | TaskCreateOutput | TaskGetOutput | TaskUpdateOutput | TaskListOutput | ExitPlanModeOutput | ConfigOutput | EnterWorktreeOutput | ExitWorktreeOutput | TodoWriteOutput | ListMcpResourcesOutput | McpOutput;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@qoder-ai/qoder-agent-sdk",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.23",
|
|
4
4
|
"description": "TypeScript SDK for building Qoder-powered coding agents.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
"peerDependencies": {
|
|
51
51
|
"zod": "^3.25.0 || ^4.0.0"
|
|
52
52
|
},
|
|
53
|
-
"qoderCliVersion": "1.1.
|
|
53
|
+
"qoderCliVersion": "1.1.23",
|
|
54
54
|
"qoderSdkBrand": "global",
|
|
55
55
|
"license": "SEE LICENSE IN LICENSE"
|
|
56
56
|
}
|
package/scripts/postinstall.cjs
CHANGED
|
@@ -30,7 +30,6 @@ const CN_DEV_DOWNLOAD_BASE_URL = 'https://static.qoder.com.cn/qoder-cli-cn/dev/r
|
|
|
30
30
|
const PACKAGE_JSON = require('../package.json');
|
|
31
31
|
const LOG_PREFIX = `[${PACKAGE_JSON.name ?? '@qoder-ai/qoder-agent-sdk'}]`;
|
|
32
32
|
const WORKER_RUNTIME_ENTRY_NAMES = ['qoder-worker-runtime.obf.mjs', 'qoder-worker-runtime.mjs'];
|
|
33
|
-
const REQUIRED_WORKER_RUNTIME_ASSETS = [path.join('vendor', 'ripgrep', 'x64-win32', 'rg.exe')];
|
|
34
33
|
|
|
35
34
|
function isTruthy(value) {
|
|
36
35
|
return value === '1' || value === 'true';
|
|
@@ -209,8 +208,36 @@ function getDownloadUrl() {
|
|
|
209
208
|
return `${baseUrl}/${getArtifactName()}`;
|
|
210
209
|
}
|
|
211
210
|
|
|
212
|
-
function
|
|
213
|
-
|
|
211
|
+
function getWorkerRuntimeTarget(target = getPlatformTarget()) {
|
|
212
|
+
const [platform, arch] = target.split('-');
|
|
213
|
+
if (platform === 'darwin') return `darwin-${arch}`;
|
|
214
|
+
if (platform === 'linux') return `linux-${arch}`;
|
|
215
|
+
if (platform === 'windows') return `win32-${arch}`;
|
|
216
|
+
throw new Error(
|
|
217
|
+
`Worker runtime platform artifacts do not support ${target}. Supported: darwin-arm64, darwin-x64, linux-arm64, linux-x64, windows-arm64, windows-x64`,
|
|
218
|
+
);
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
function getWorkerRuntimeArtifactName(site = getCliSite(), target = getPlatformTarget()) {
|
|
222
|
+
const workerTarget = getWorkerRuntimeTarget(target);
|
|
223
|
+
return `${getCliArtifactPrefix(site)}-worker-runtime-${workerTarget}.tgz`;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
function getWorkerRuntimeArtifactNameTemplate(site = getCliSite()) {
|
|
227
|
+
return `${getCliArtifactPrefix(site)}-worker-runtime-{target}.tgz`;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
function getWorkerRuntimeRequiredAssets(target = getPlatformTarget()) {
|
|
231
|
+
const workerTarget = getWorkerRuntimeTarget(target);
|
|
232
|
+
const [platform, arch] = workerTarget.split('-');
|
|
233
|
+
return [
|
|
234
|
+
path.join(
|
|
235
|
+
'vendor',
|
|
236
|
+
'ripgrep',
|
|
237
|
+
`${arch}-${platform}`,
|
|
238
|
+
platform === 'win32' ? 'rg.exe' : 'rg',
|
|
239
|
+
),
|
|
240
|
+
];
|
|
214
241
|
}
|
|
215
242
|
|
|
216
243
|
function hasWorkerRuntimeDownloadSiteOverride() {
|
|
@@ -231,6 +258,14 @@ function getManifestWorkerRuntimeDownloadUrl(manifest = readRuntimeManifest()) {
|
|
|
231
258
|
return url ?? null;
|
|
232
259
|
}
|
|
233
260
|
|
|
261
|
+
function getManifestWorkerRuntimeDownloadUrlTemplate(manifest = readRuntimeManifest()) {
|
|
262
|
+
const workerRuntime = getManifestWorkerRuntime(manifest);
|
|
263
|
+
if (!workerRuntime || workerRuntime.packaged === true) return null;
|
|
264
|
+
return typeof workerRuntime.urlTemplate === 'string' && workerRuntime.urlTemplate.length > 0
|
|
265
|
+
? workerRuntime.urlTemplate
|
|
266
|
+
: null;
|
|
267
|
+
}
|
|
268
|
+
|
|
234
269
|
function getManifestWorkerRuntimeSha256(manifest = readRuntimeManifest()) {
|
|
235
270
|
const workerRuntime = getManifestWorkerRuntime(manifest);
|
|
236
271
|
if (!workerRuntime || workerRuntime.packaged === true) return null;
|
|
@@ -246,30 +281,39 @@ function getManifestWorkerRuntimeSha256(manifest = readRuntimeManifest()) {
|
|
|
246
281
|
return checksum ? checksum.trim().toLowerCase() : null;
|
|
247
282
|
}
|
|
248
283
|
|
|
284
|
+
function getWorkerRuntimeDownloadUrlTemplate() {
|
|
285
|
+
const version = getCliVersion();
|
|
286
|
+
const baseUrl = normalizeDownloadBaseUrl(getWorkerRuntimeDownloadBaseUrl(version), version);
|
|
287
|
+
return `${baseUrl}/${getWorkerRuntimeArtifactNameTemplate()}`;
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
function getWorkerRuntimeDefaultDownloadUrl() {
|
|
291
|
+
return getWorkerRuntimeDownloadUrlTemplate().replace(
|
|
292
|
+
'{target}',
|
|
293
|
+
getWorkerRuntimeTarget(),
|
|
294
|
+
);
|
|
295
|
+
}
|
|
296
|
+
|
|
249
297
|
function getWorkerRuntimeDownloadUrl() {
|
|
250
298
|
if (process.env.QODER_WORKER_RUNTIME_URL) {
|
|
251
299
|
return process.env.QODER_WORKER_RUNTIME_URL;
|
|
252
300
|
}
|
|
253
301
|
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
302
|
+
if (!hasWorkerRuntimeDownloadSiteOverride()) {
|
|
303
|
+
const template = getManifestWorkerRuntimeDownloadUrlTemplate();
|
|
304
|
+
if (template) {
|
|
305
|
+
return template.replace('{target}', getWorkerRuntimeTarget());
|
|
306
|
+
}
|
|
307
|
+
const manifestUrl = getManifestWorkerRuntimeDownloadUrl();
|
|
308
|
+
if (manifestUrl) return manifestUrl;
|
|
259
309
|
}
|
|
260
310
|
|
|
261
|
-
|
|
262
|
-
const baseUrl = normalizeDownloadBaseUrl(getWorkerRuntimeDownloadBaseUrl(version), version);
|
|
263
|
-
return `${baseUrl}/${getWorkerRuntimeArtifactName()}`;
|
|
311
|
+
return getWorkerRuntimeDefaultDownloadUrl();
|
|
264
312
|
}
|
|
265
313
|
|
|
266
314
|
function getWorkerRuntimeExpectedSha256(url = getWorkerRuntimeDownloadUrl()) {
|
|
267
315
|
const manifestUrl = getManifestWorkerRuntimeDownloadUrl();
|
|
268
|
-
|
|
269
|
-
return getManifestWorkerRuntimeSha256();
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
return null;
|
|
316
|
+
return manifestUrl === url ? getManifestWorkerRuntimeSha256() : null;
|
|
273
317
|
}
|
|
274
318
|
|
|
275
319
|
function getBundledDir() {
|
|
@@ -375,6 +419,15 @@ function isPackagedWorkerRuntimeCompatibleWithSite(site = getCliSite()) {
|
|
|
375
419
|
runtimeInfo.build && typeof runtimeInfo.build === 'object' ? runtimeInfo.build : {};
|
|
376
420
|
const actualProductName = buildInfo.productName;
|
|
377
421
|
const actualSite = buildInfo.site;
|
|
422
|
+
const expectedVersion = getCliVersion();
|
|
423
|
+
|
|
424
|
+
if (runtimeInfo.version !== expectedVersion) {
|
|
425
|
+
return false;
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
if (runtimeInfo.profile !== 'platform' || runtimeInfo.target !== getWorkerRuntimeTarget()) {
|
|
429
|
+
return false;
|
|
430
|
+
}
|
|
378
431
|
|
|
379
432
|
if (
|
|
380
433
|
typeof actualProductName === 'string' &&
|
|
@@ -462,8 +515,10 @@ async function downloadFile(url, destPath) {
|
|
|
462
515
|
console.log(`${LOG_PREFIX} Downloading: ${url}`);
|
|
463
516
|
const response = await requestUrl(url);
|
|
464
517
|
if (response.statusCode !== 200) {
|
|
518
|
+
const error = new Error(`Download failed: HTTP ${response.statusCode}`);
|
|
519
|
+
error.statusCode = response.statusCode;
|
|
465
520
|
response.resume();
|
|
466
|
-
throw
|
|
521
|
+
throw error;
|
|
467
522
|
}
|
|
468
523
|
|
|
469
524
|
await new Promise((resolve, reject) => {
|
|
@@ -506,6 +561,7 @@ async function downloadWithRetry(url, destPath, maxRetries = 2) {
|
|
|
506
561
|
lastError = error;
|
|
507
562
|
console.error(`${LOG_PREFIX} Download failed: ${error.message}`);
|
|
508
563
|
fs.rmSync(destPath, { force: true });
|
|
564
|
+
if (error.statusCode === 404) break;
|
|
509
565
|
}
|
|
510
566
|
}
|
|
511
567
|
throw lastError;
|
|
@@ -709,7 +765,7 @@ function assertWorkerRuntimeComplete(runtimeDir, sourceDescription) {
|
|
|
709
765
|
throw new Error(`Worker runtime entry missing in ${sourceDescription}: ${runtimePath}`);
|
|
710
766
|
}
|
|
711
767
|
|
|
712
|
-
const missingAssets =
|
|
768
|
+
const missingAssets = getWorkerRuntimeRequiredAssets().filter(
|
|
713
769
|
(assetPath) => !fs.existsSync(path.join(runtimeDir, assetPath)),
|
|
714
770
|
);
|
|
715
771
|
if (missingAssets.length > 0) {
|
|
@@ -725,7 +781,49 @@ function assertWorkerRuntimeComplete(runtimeDir, sourceDescription) {
|
|
|
725
781
|
return runtimePath;
|
|
726
782
|
}
|
|
727
783
|
|
|
728
|
-
function
|
|
784
|
+
function assertWorkerRuntimeIdentity(runtimeDir) {
|
|
785
|
+
const runtimeInfoPath = path.join(runtimeDir, 'runtime-info.json');
|
|
786
|
+
if (!fs.existsSync(runtimeInfoPath)) {
|
|
787
|
+
throw new Error(`Downloaded Worker runtime is missing identity metadata: ${runtimeInfoPath}`);
|
|
788
|
+
}
|
|
789
|
+
|
|
790
|
+
let runtimeInfo;
|
|
791
|
+
try {
|
|
792
|
+
runtimeInfo = JSON.parse(fs.readFileSync(runtimeInfoPath, 'utf8'));
|
|
793
|
+
} catch (error) {
|
|
794
|
+
throw new Error(`Downloaded Worker runtime has invalid identity metadata: ${error.message}`);
|
|
795
|
+
}
|
|
796
|
+
|
|
797
|
+
const expectedTarget = getWorkerRuntimeTarget();
|
|
798
|
+
const expectedSite = getCliSite();
|
|
799
|
+
const expectedProductName = getCliArtifactPrefix(expectedSite);
|
|
800
|
+
const expectedVersion = getCliVersion();
|
|
801
|
+
const mismatches = [];
|
|
802
|
+
|
|
803
|
+
if (runtimeInfo.profile !== 'platform') {
|
|
804
|
+
mismatches.push(`profile=${String(runtimeInfo.profile)} (expected platform)`);
|
|
805
|
+
}
|
|
806
|
+
if (runtimeInfo.target !== expectedTarget) {
|
|
807
|
+
mismatches.push(`target=${String(runtimeInfo.target)} (expected ${expectedTarget})`);
|
|
808
|
+
}
|
|
809
|
+
if (runtimeInfo.version !== expectedVersion) {
|
|
810
|
+
mismatches.push(`version=${String(runtimeInfo.version)} (expected ${expectedVersion})`);
|
|
811
|
+
}
|
|
812
|
+
if (runtimeInfo.build?.site !== expectedSite) {
|
|
813
|
+
mismatches.push(`site=${String(runtimeInfo.build?.site)} (expected ${expectedSite})`);
|
|
814
|
+
}
|
|
815
|
+
if (runtimeInfo.build?.productName !== expectedProductName) {
|
|
816
|
+
mismatches.push(
|
|
817
|
+
`productName=${String(runtimeInfo.build?.productName)} (expected ${expectedProductName})`,
|
|
818
|
+
);
|
|
819
|
+
}
|
|
820
|
+
|
|
821
|
+
if (mismatches.length > 0) {
|
|
822
|
+
throw new Error(`Downloaded Worker runtime identity mismatch: ${mismatches.join(', ')}`);
|
|
823
|
+
}
|
|
824
|
+
}
|
|
825
|
+
|
|
826
|
+
function installExtractedWorkerRuntime(extractDir, workerDir, options = {}) {
|
|
729
827
|
const contentRoot = findWorkerRuntimeRoot(extractDir);
|
|
730
828
|
if (!contentRoot) {
|
|
731
829
|
throw new Error(
|
|
@@ -733,6 +831,9 @@ function installExtractedWorkerRuntime(extractDir, workerDir) {
|
|
|
733
831
|
);
|
|
734
832
|
}
|
|
735
833
|
assertWorkerRuntimeComplete(contentRoot, contentRoot);
|
|
834
|
+
if (options.validateIdentity === true) {
|
|
835
|
+
assertWorkerRuntimeIdentity(contentRoot);
|
|
836
|
+
}
|
|
736
837
|
|
|
737
838
|
fs.rmSync(workerDir, { recursive: true, force: true });
|
|
738
839
|
copyDirContents(contentRoot, workerDir);
|
|
@@ -744,24 +845,36 @@ function installExtractedWorkerRuntime(extractDir, workerDir) {
|
|
|
744
845
|
return runtimePath;
|
|
745
846
|
}
|
|
746
847
|
|
|
747
|
-
async function
|
|
748
|
-
const url = getWorkerRuntimeDownloadUrl();
|
|
749
|
-
const expectedSha256 = getWorkerRuntimeExpectedSha256(url);
|
|
848
|
+
async function downloadAndInstallWorkerRuntime(workerDir, options = {}) {
|
|
849
|
+
const url = options.urlOverride ?? getWorkerRuntimeDownloadUrl();
|
|
850
|
+
const expectedSha256 = options.urlOverride ? null : getWorkerRuntimeExpectedSha256(url);
|
|
750
851
|
const tempDir = fs.mkdtempSync(path.join(os.tmpdir(), 'qoder-worker-runtime-'));
|
|
751
852
|
const archivePath = path.join(tempDir, path.basename(new URL(url).pathname));
|
|
752
853
|
const extractDir = path.join(tempDir, 'extract');
|
|
753
854
|
|
|
754
855
|
try {
|
|
856
|
+
fs.mkdirSync(extractDir, { recursive: true });
|
|
755
857
|
await downloadWithRetry(url, archivePath);
|
|
756
858
|
await verifyChecksum(url, archivePath, expectedSha256);
|
|
757
|
-
fs.mkdirSync(extractDir, { recursive: true });
|
|
758
859
|
await extractArchive(archivePath, extractDir);
|
|
759
|
-
return
|
|
860
|
+
return {
|
|
861
|
+
runtimePath: installExtractedWorkerRuntime(extractDir, workerDir, {
|
|
862
|
+
validateIdentity: true,
|
|
863
|
+
}),
|
|
864
|
+
url,
|
|
865
|
+
};
|
|
760
866
|
} finally {
|
|
761
867
|
fs.rmSync(tempDir, { recursive: true, force: true });
|
|
762
868
|
}
|
|
763
869
|
}
|
|
764
870
|
|
|
871
|
+
async function installWorkerRuntimeFromDownload() {
|
|
872
|
+
const installed = await downloadAndInstallWorkerRuntime(
|
|
873
|
+
getPackagedWorkerRuntimeDir(),
|
|
874
|
+
);
|
|
875
|
+
return installed.runtimePath;
|
|
876
|
+
}
|
|
877
|
+
|
|
765
878
|
async function main() {
|
|
766
879
|
if (isTruthy(process.env.QODER_SKIP_DOWNLOAD)) {
|
|
767
880
|
console.log(`${LOG_PREFIX} QODER_SKIP_DOWNLOAD is set, skipping runtime downloads.`);
|
|
@@ -849,6 +962,8 @@ if (require.main === module) {
|
|
|
849
962
|
}
|
|
850
963
|
|
|
851
964
|
module.exports = {
|
|
965
|
+
assertWorkerRuntimeIdentity,
|
|
966
|
+
downloadAndInstallWorkerRuntime,
|
|
852
967
|
downloadWithRetry,
|
|
853
968
|
extractArchive,
|
|
854
969
|
getTarExtractInvocation,
|
|
@@ -870,8 +985,13 @@ module.exports = {
|
|
|
870
985
|
getDefaultRuntimeTransport,
|
|
871
986
|
getWorkerRuntimeExpectedSha256,
|
|
872
987
|
getWorkerRuntimeArtifactName,
|
|
988
|
+
getWorkerRuntimeArtifactNameTemplate,
|
|
873
989
|
getWorkerRuntimeDownloadBaseUrl,
|
|
874
990
|
getWorkerRuntimeDownloadUrl,
|
|
991
|
+
getWorkerRuntimeDownloadUrlTemplate,
|
|
992
|
+
getWorkerRuntimeRequiredAssets,
|
|
993
|
+
getWorkerRuntimeTarget,
|
|
994
|
+
getManifestWorkerRuntimeDownloadUrlTemplate,
|
|
875
995
|
hasPackagedWorkerRuntime,
|
|
876
996
|
installExtractedContents,
|
|
877
997
|
installExtractedWorkerRuntime,
|