@cursor/sdk 1.0.7 → 1.0.8
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 +3 -360
- package/dist/cjs/642.index.js +1 -0
- package/dist/cjs/agent.d.ts +8 -4
- package/dist/cjs/agent.d.ts.map +1 -1
- package/dist/cjs/analytics.d.ts +5 -0
- package/dist/cjs/analytics.d.ts.map +1 -1
- package/dist/cjs/cloud-agent.d.ts.map +1 -1
- package/dist/cjs/cloud-api-client.d.ts +3 -3
- package/dist/cjs/cloud-api-client.d.ts.map +1 -1
- package/dist/cjs/cloud-executor.d.ts.map +1 -1
- package/dist/cjs/executor-types.d.ts +1 -1
- package/dist/cjs/executor-types.d.ts.map +1 -1
- package/dist/cjs/index.js +5 -5
- package/dist/cjs/index.js.LICENSE.txt +11 -0
- package/dist/cjs/local-executor.d.ts +4 -1
- package/dist/cjs/local-executor.d.ts.map +1 -1
- package/dist/cjs/local-model-validation.d.ts +6 -0
- package/dist/cjs/local-model-validation.d.ts.map +1 -0
- package/dist/cjs/options.d.ts +4 -2
- package/dist/cjs/options.d.ts.map +1 -1
- package/dist/cjs/platform.d.ts +4 -1
- package/dist/cjs/platform.d.ts.map +1 -1
- package/dist/cjs/sdk-statsig.d.ts +10 -0
- package/dist/cjs/sdk-statsig.d.ts.map +1 -0
- package/dist/cjs/stubs.d.ts +3 -2
- package/dist/cjs/stubs.d.ts.map +1 -1
- package/dist/cjs/subagent-conversion.d.ts +13 -2
- package/dist/cjs/subagent-conversion.d.ts.map +1 -1
- package/dist/esm/642.index.js +1 -0
- package/dist/esm/agent.d.ts +8 -4
- package/dist/esm/agent.d.ts.map +1 -1
- package/dist/esm/analytics.d.ts +5 -0
- package/dist/esm/analytics.d.ts.map +1 -1
- package/dist/esm/cloud-agent.d.ts.map +1 -1
- package/dist/esm/cloud-api-client.d.ts +3 -3
- package/dist/esm/cloud-api-client.d.ts.map +1 -1
- package/dist/esm/cloud-executor.d.ts.map +1 -1
- package/dist/esm/executor-types.d.ts +1 -1
- package/dist/esm/executor-types.d.ts.map +1 -1
- package/dist/esm/index.js +3 -3
- package/dist/esm/index.js.LICENSE.txt +11 -0
- package/dist/esm/local-executor.d.ts +4 -1
- package/dist/esm/local-executor.d.ts.map +1 -1
- package/dist/esm/local-model-validation.d.ts +6 -0
- package/dist/esm/local-model-validation.d.ts.map +1 -0
- package/dist/esm/options.d.ts +4 -2
- package/dist/esm/options.d.ts.map +1 -1
- package/dist/esm/platform.d.ts +4 -1
- package/dist/esm/platform.d.ts.map +1 -1
- package/dist/esm/sdk-statsig.d.ts +10 -0
- package/dist/esm/sdk-statsig.d.ts.map +1 -0
- package/dist/esm/stubs.d.ts +3 -2
- package/dist/esm/stubs.d.ts.map +1 -1
- package/dist/esm/subagent-conversion.d.ts +13 -2
- package/dist/esm/subagent-conversion.d.ts.map +1 -1
- package/package.json +8 -8
- package/dist/cjs/829.index.js +0 -1
- package/dist/esm/829.index.js +0 -1
|
@@ -5,6 +5,17 @@
|
|
|
5
5
|
* Licensed under the MIT License.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
+
/*!
|
|
9
|
+
* re2js
|
|
10
|
+
* RE2JS is the JavaScript port of RE2, a regular expression engine that provides linear time matching
|
|
11
|
+
*
|
|
12
|
+
* @version v1.2.2
|
|
13
|
+
* @author Alexey Vasiliev
|
|
14
|
+
* @homepage https://github.com/le0pard/re2js#readme
|
|
15
|
+
* @repository github:le0pard/re2js
|
|
16
|
+
* @license MIT
|
|
17
|
+
*/
|
|
18
|
+
|
|
8
19
|
/*!
|
|
9
20
|
* strip-bom-string <https://github.com/jonschlinkert/strip-bom-string>
|
|
10
21
|
*
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import { type RuntimeCustomSubagentDefinition } from "@anysphere/cursor-sdk-local-runtime";
|
|
1
2
|
import type { RunExecutor } from "./executor-types.js";
|
|
2
|
-
import type { McpServerConfig, SettingSource } from "./options.js";
|
|
3
|
+
import type { McpServerConfig, SandboxOptions, SettingSource } from "./options.js";
|
|
3
4
|
export interface LocalExecutorHandle {
|
|
4
5
|
run: RunExecutor;
|
|
5
6
|
reload(): Promise<void>;
|
|
@@ -9,7 +10,9 @@ export interface CreateLocalExecutorOptions {
|
|
|
9
10
|
readonly workingDirectory?: string;
|
|
10
11
|
readonly apiKey?: string;
|
|
11
12
|
readonly settingSources?: readonly SettingSource[];
|
|
13
|
+
readonly sandboxOptions?: SandboxOptions;
|
|
12
14
|
readonly mcpServers?: Record<string, McpServerConfig>;
|
|
15
|
+
readonly customSubagents?: readonly RuntimeCustomSubagentDefinition[];
|
|
13
16
|
}
|
|
14
17
|
export declare function createLocalExecutor(optionsOrWorkingDirectory?: CreateLocalExecutorOptions | string, apiKey?: string): Promise<LocalExecutorHandle>;
|
|
15
18
|
//# sourceMappingURL=local-executor.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"local-executor.d.ts","sourceRoot":"","sources":["../../src/agent/local-executor.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"local-executor.d.ts","sourceRoot":"","sources":["../../src/agent/local-executor.ts"],"names":[],"mappings":"AAwBA,OAAO,EAQL,KAAK,+BAA+B,EAKrC,MAAM,qCAAqC,CAAC;AAsE7C,OAAO,KAAK,EACV,WAAW,EAIZ,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK,EACV,eAAe,EACf,cAAc,EACd,aAAa,EACd,MAAM,cAAc,CAAC;AAItB,MAAM,WAAW,mBAAmB;IAClC,GAAG,EAAE,WAAW,CAAC;IACjB,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACxB,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CAC1B;AAED,MAAM,WAAW,0BAA0B;IACzC,QAAQ,CAAC,gBAAgB,CAAC,EAAE,MAAM,CAAC;IACnC,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,cAAc,CAAC,EAAE,SAAS,aAAa,EAAE,CAAC;IACnD,QAAQ,CAAC,cAAc,CAAC,EAAE,cAAc,CAAC;IACzC,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC;IACtD,QAAQ,CAAC,eAAe,CAAC,EAAE,SAAS,+BAA+B,EAAE,CAAC;CACvE;AA0GD,wBAAsB,mBAAmB,CACvC,yBAAyB,CAAC,EAAE,0BAA0B,GAAG,MAAM,EAC/D,MAAM,CAAC,EAAE,MAAM,GACd,OAAO,CAAC,mBAAmB,CAAC,CAka9B"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { ModelListItem, ModelSelection } from "./options.js";
|
|
2
|
+
export interface LocalModelValidationOptions {
|
|
3
|
+
listModels?: () => Promise<ModelListItem[]>;
|
|
4
|
+
}
|
|
5
|
+
export declare function resolveLocalModelSelection(selection: ModelSelection, options?: LocalModelValidationOptions): Promise<ModelSelection>;
|
|
6
|
+
//# sourceMappingURL=local-model-validation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"local-model-validation.d.ts","sourceRoot":"","sources":["../../src/agent/local-model-validation.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAElE,MAAM,WAAW,2BAA2B;IAC1C,UAAU,CAAC,EAAE,MAAM,OAAO,CAAC,aAAa,EAAE,CAAC,CAAC;CAC7C;AAED,wBAAsB,0BAA0B,CAC9C,SAAS,EAAE,cAAc,EACzB,OAAO,GAAE,2BAAgC,GACxC,OAAO,CAAC,cAAc,CAAC,CAQzB"}
|
package/dist/esm/options.d.ts
CHANGED
|
@@ -32,6 +32,9 @@ export type McpServerConfig = {
|
|
|
32
32
|
};
|
|
33
33
|
};
|
|
34
34
|
export type SettingSource = "project" | "user" | "team" | "mdm" | "plugins" | "all";
|
|
35
|
+
export interface SandboxOptions {
|
|
36
|
+
enabled: boolean;
|
|
37
|
+
}
|
|
35
38
|
export interface ModelParameterValue {
|
|
36
39
|
id: string;
|
|
37
40
|
value: string;
|
|
@@ -84,7 +87,6 @@ export interface AgentOptions {
|
|
|
84
87
|
name?: string;
|
|
85
88
|
local?: {
|
|
86
89
|
cwd?: string | string[];
|
|
87
|
-
envVars?: Record<string, string>;
|
|
88
90
|
/**
|
|
89
91
|
* Ambient Cursor settings layers to load from the local filesystem.
|
|
90
92
|
* Local agents only. On cloud, `project` / `team` / `plugins` are
|
|
@@ -92,6 +94,7 @@ export interface AgentOptions {
|
|
|
92
94
|
* this field is gated to the local shape.
|
|
93
95
|
*/
|
|
94
96
|
settingSources?: SettingSource[];
|
|
97
|
+
sandboxOptions?: SandboxOptions;
|
|
95
98
|
};
|
|
96
99
|
cloud?: {
|
|
97
100
|
env?: {
|
|
@@ -116,7 +119,6 @@ export interface AgentOptions {
|
|
|
116
119
|
mcpServers?: Record<string, McpServerConfig>;
|
|
117
120
|
agents?: Record<string, AgentDefinition>;
|
|
118
121
|
agentId?: string;
|
|
119
|
-
resume?: string;
|
|
120
122
|
platform?: CursorAgentPlatformOptions;
|
|
121
123
|
}
|
|
122
124
|
//# sourceMappingURL=options.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"options.d.ts","sourceRoot":"","sources":["../../src/agent/options.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,+CAA+C,CAAC;AAEhG,MAAM,WAAW,iBAAiB;IAChC,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,MAAM,QAAQ,GAChB;IACE,GAAG,EAAE,MAAM,CAAC;IACZ,SAAS,CAAC,EAAE,iBAAiB,CAAC;CAC/B,GACD;IACE,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,iBAAiB,CAAC;CAC/B,CAAC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AK,CAAC,EAAE,KAAK,CAAC;YACZ,GAAG,EAAE,MAAM,CAAC;YACZ,WAAW,CAAC,EAAE,MAAM,CAAC;YACrB,KAAK,CAAC,EAAE,MAAM,CAAC;SAChB,CAAC,CAAC;QACH,mBAAmB,CAAC,EAAE,OAAO,CAAC;QAC9B,YAAY,CAAC,EAAE,OAAO,CAAC;QACvB,mBAAmB,CAAC,EAAE,OAAO,CAAC;KAC/B,CAAC;IACF,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC;IAC7C,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC;IACzC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,0BAA0B,CAAC;CACvC"}
|
package/dist/esm/platform.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { AgentCheckpointStore, AgentRunStore, CursorAgentPlatformOptions, RunEventNotifier, RunEventStore } from "@anysphere/cursor-sdk-local-runtime/run-store";
|
|
2
2
|
import type { AgentMessage, AgentOperationOptions, CursorRequestOptions, GetAgentMessagesOptions, GetAgentOptions, GetRunOptions, ListAgentsOptions, ListRunsOptions, ListResult as PublicListResult, SDKAgent, SDKAgentInfo, SDKModel, SDKRepository, SDKUser } from "./agent.js";
|
|
3
3
|
import { type SDKMessage } from "./messages.js";
|
|
4
|
-
import type { AgentOptions } from "./options.js";
|
|
4
|
+
import type { AgentOptions, ModelSelection } from "./options.js";
|
|
5
5
|
import { type Run } from "./run.js";
|
|
6
6
|
export declare class CursorAgentPlatform {
|
|
7
7
|
readonly store: AgentRunStore;
|
|
@@ -9,7 +9,10 @@ export declare class CursorAgentPlatform {
|
|
|
9
9
|
readonly eventStore: RunEventStore | undefined;
|
|
10
10
|
readonly eventNotifier: RunEventNotifier | undefined;
|
|
11
11
|
private readonly workspaceRef;
|
|
12
|
+
private readonly localModelListCache;
|
|
12
13
|
constructor(store: AgentRunStore, checkpointStore: AgentCheckpointStore, eventStore: RunEventStore | undefined, eventNotifier: RunEventNotifier | undefined, workspaceRef: string);
|
|
14
|
+
resolveLocalModelSelection(selection: ModelSelection, apiKey: string | undefined): Promise<ModelSelection>;
|
|
15
|
+
private listModelsForLocalValidation;
|
|
13
16
|
createAgent(options: AgentOptions): Promise<SDKAgent>;
|
|
14
17
|
resumeAgent(agentId: string, options: Partial<AgentOptions>): Promise<SDKAgent>;
|
|
15
18
|
listAgents(options?: ListAgentsOptions): Promise<PublicListResult<SDKAgentInfo>>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"platform.d.ts","sourceRoot":"","sources":["../../src/agent/platform.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,oBAAoB,EAEpB,aAAa,EACb,0BAA0B,EAC1B,gBAAgB,EAChB,aAAa,EAId,MAAM,+CAA+C,CAAC;AAIvD,OAAO,KAAK,EACV,YAAY,EACZ,qBAAqB,EACrB,oBAAoB,EACpB,uBAAuB,EACvB,eAAe,EACf,aAAa,EACb,iBAAiB,EACjB,eAAe,EACf,UAAU,IAAI,gBAAgB,EAC9B,QAAQ,EACR,YAAY,EACZ,QAAQ,EACR,aAAa,EACb,OAAO,EAER,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"platform.d.ts","sourceRoot":"","sources":["../../src/agent/platform.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,oBAAoB,EAEpB,aAAa,EACb,0BAA0B,EAC1B,gBAAgB,EAChB,aAAa,EAId,MAAM,+CAA+C,CAAC;AAIvD,OAAO,KAAK,EACV,YAAY,EACZ,qBAAqB,EACrB,oBAAoB,EACpB,uBAAuB,EACvB,eAAe,EACf,aAAa,EACb,iBAAiB,EACjB,eAAe,EACf,UAAU,IAAI,gBAAgB,EAC9B,QAAQ,EACR,YAAY,EACZ,QAAQ,EACR,aAAa,EACb,OAAO,EAER,MAAM,YAAY,CAAC;AAWpB,OAAO,EAGL,KAAK,UAAU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EAAE,CAAC,CAKzB;AAaD,wBAAsB,eAAe,CACnC,OAAO,EAAE,MAAM,EACf,OAAO,CAAC,EAAE,eAAe,GACxB,OAAO,CAAC,YAAY,CAAC,CASvB;AAED,wBAAsB,mBAAmB,CACvC,OAAO,EAAE,MAAM,EACf,OAAO,CAAC,EAAE,qBAAqB,GAC9B,OAAO,CAAC,IAAI,CAAC,CASf;AAED,wBAAsB,qBAAqB,CACzC,OAAO,EAAE,MAAM,EACf,OAAO,CAAC,EAAE,qBAAqB,GAC9B,OAAO,CAAC,IAAI,CAAC,CASf;AAED,wBAAsB,kBAAkB,CACtC,OAAO,EAAE,MAAM,EACf,OAAO,CAAC,EAAE,qBAAqB,GAC9B,OAAO,CAAC,IAAI,CAAC,CASf;AAED,wBAAsB,YAAY,CAChC,OAAO,CAAC,EAAE,oBAAoB,GAC7B,OAAO,CAAC,OAAO,CAAC,CAGlB;AAED,wBAAsB,iBAAiB,CACrC,OAAO,CAAC,EAAE,oBAAoB,GAC7B,OAAO,CAAC,QAAQ,EAAE,CAAC,CAGrB;AAED,wBAAsB,uBAAuB,CAC3C,OAAO,CAAC,EAAE,oBAAoB,GAC7B,OAAO,CAAC,aAAa,EAAE,CAAC,CAG1B"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export interface SdkStatsigClient {
|
|
2
|
+
checkFeatureGate(gateName: string): boolean;
|
|
3
|
+
getDynamicConfigValue<T>(params: {
|
|
4
|
+
configName: string;
|
|
5
|
+
paramName: string;
|
|
6
|
+
defaultValue: T;
|
|
7
|
+
}): T;
|
|
8
|
+
}
|
|
9
|
+
export declare function bootstrapSdkStatsig(apiKey: string): Promise<SdkStatsigClient>;
|
|
10
|
+
//# sourceMappingURL=sdk-statsig.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sdk-statsig.d.ts","sourceRoot":"","sources":["../../src/agent/sdk-statsig.ts"],"names":[],"mappings":"AAWA,MAAM,WAAW,gBAAgB;IAC/B,gBAAgB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC;IAC5C,qBAAqB,CAAC,CAAC,EAAE,MAAM,EAAE;QAC/B,UAAU,EAAE,MAAM,CAAC;QACnB,SAAS,EAAE,MAAM,CAAC;QAClB,YAAY,EAAE,CAAC,CAAC;KACjB,GAAG,CAAC,CAAC;CACP;AA0ID,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAsB7E"}
|
package/dist/esm/stubs.d.ts
CHANGED
|
@@ -23,6 +23,7 @@ export declare class UnimplementedRun implements Run {
|
|
|
23
23
|
}
|
|
24
24
|
export declare class UnimplementedAgent implements SDKAgent {
|
|
25
25
|
readonly agentId = "unimplemented-agent";
|
|
26
|
+
readonly model: undefined;
|
|
26
27
|
send(_message: string | SDKUserMessage, _options?: SendOptions): Promise<Run>;
|
|
27
28
|
close(): void;
|
|
28
29
|
reload(): Promise<void>;
|
|
@@ -35,11 +36,11 @@ export declare class Agent {
|
|
|
35
36
|
/**
|
|
36
37
|
* Create an agent instance.
|
|
37
38
|
*/
|
|
38
|
-
static create(options: AgentOptions): SDKAgent
|
|
39
|
+
static create(options: AgentOptions): Promise<SDKAgent>;
|
|
39
40
|
/**
|
|
40
41
|
* Resume an existing agent by ID.
|
|
41
42
|
*/
|
|
42
|
-
static resume(agentId: string, options?: Partial<AgentOptions>): SDKAgent
|
|
43
|
+
static resume(agentId: string, options?: Partial<AgentOptions>): Promise<SDKAgent>;
|
|
43
44
|
/**
|
|
44
45
|
* Convenience API to create an agent, run one prompt, and close.
|
|
45
46
|
*/
|
package/dist/esm/stubs.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stubs.d.ts","sourceRoot":"","sources":["../../src/agent/stubs.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACV,YAAY,EACZ,qBAAqB,EACrB,oBAAoB,EACpB,uBAAuB,EACvB,eAAe,EACf,aAA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OAAO,CAAC,EAAE,aAAa,GAAG,OAAO,CAAC,GAAG,CAAC;IAIzE;;;OAGG;WACU,GAAG,CACd,OAAO,EAAE,MAAM,EACf,OAAO,CAAC,EAAE,eAAe,GACxB,OAAO,CAAC,YAAY,CAAC;IAIxB;;OAEG;WACU,OAAO,CAClB,OAAO,EAAE,MAAM,EACf,OAAO,CAAC,EAAE,qBAAqB,GAC9B,OAAO,CAAC,IAAI,CAAC;IAIhB;;OAEG;WACU,SAAS,CACpB,OAAO,EAAE,MAAM,EACf,OAAO,CAAC,EAAE,qBAAqB,GAC9B,OAAO,CAAC,IAAI,CAAC;IAIhB;;OAEG;WACU,MAAM,CACjB,OAAO,EAAE,MAAM,EACf,OAAO,CAAC,EAAE,qBAAqB,GAC9B,OAAO,CAAC,IAAI,CAAC;IAIhB,MAAM,CAAC,QAAQ,CAAC,QAAQ;sBAEX,MAAM,YACL,uBAAuB,GAChC,OAAO,CAAC,YAAY,EAAE,CAAC;MAG1B;CACH;AAED;;;;GAIG;AACH,qBAAa,MAAM;IACjB,OAAO;IAEP;;OAEG;WACU,EAAE,CAAC,OAAO,CAAC,EAAE,oBAAoB,GAAG,OAAO,CAAC,OAAO,CAAC;IAIjE;;OAEG;IACH,MAAM,CAAC,QAAQ,CAAC,MAAM;uBACL,oBAAoB,GAAG,OAAO,CAAC,QAAQ,EAAE,CAAC;MAGzD;IAEF;;OAEG;IACH,MAAM,CAAC,QAAQ,CAAC,YAAY;uBACX,oBAAoB,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC;MAG9D;CACH"}
|
|
@@ -1,9 +1,20 @@
|
|
|
1
1
|
import type { V1CustomSubagent } from "./cloud-api-client.js";
|
|
2
2
|
import type { AgentDefinition } from "./options.js";
|
|
3
|
+
export interface SDKCustomSubagentDefinition {
|
|
4
|
+
name: string;
|
|
5
|
+
description: string;
|
|
6
|
+
prompt: string;
|
|
7
|
+
model: string;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Convert SDK `AgentOptions.agents` to a plain, serializable custom subagent
|
|
11
|
+
* shape. Inline `McpServerConfig` entries on a subagent are rejected; SDK
|
|
12
|
+
* custom subagents inherit the parent agent's MCP config.
|
|
13
|
+
*/
|
|
14
|
+
export declare function convertAgentDefinitionsToCustomSubagents(agents: Record<string, AgentDefinition> | undefined): SDKCustomSubagentDefinition[] | undefined;
|
|
3
15
|
/**
|
|
4
16
|
* Convert SDK `AgentOptions.agents` to the `V1CustomSubagent[]` shape the
|
|
5
|
-
* cloud API expects.
|
|
6
|
-
* rejected; v1 cloud subagents inherit the parent agent's MCP config.
|
|
17
|
+
* cloud API expects.
|
|
7
18
|
*/
|
|
8
19
|
export declare function convertAgentDefinitionsToV1CustomSubagents(agents: Record<string, AgentDefinition> | undefined): V1CustomSubagent[] | undefined;
|
|
9
20
|
//# sourceMappingURL=subagent-conversion.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"subagent-conversion.d.ts","sourceRoot":"","sources":["../../src/agent/subagent-conversion.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAE9D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAEpD;;;;GAIG;AACH,wBAAgB,0CAA0C,CACxD,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,GAAG,SAAS,GAClD,gBAAgB,EAAE,GAAG,SAAS,
|
|
1
|
+
{"version":3,"file":"subagent-conversion.d.ts","sourceRoot":"","sources":["../../src/agent/subagent-conversion.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAE9D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAEpD,MAAM,WAAW,2BAA2B;IAC1C,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;CACf;AAED;;;;GAIG;AACH,wBAAgB,wCAAwC,CACtD,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,GAAG,SAAS,GAClD,2BAA2B,EAAE,GAAG,SAAS,CAqC3C;AAED;;;GAGG;AACH,wBAAgB,0CAA0C,CACxD,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,GAAG,SAAS,GAClD,gBAAgB,EAAE,GAAG,SAAS,CAEhC"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cursor/sdk",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "1.0.8",
|
|
4
|
+
"description": "TypeScript SDK for Cursor agents.",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.md",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -57,7 +57,6 @@
|
|
|
57
57
|
"check": "biome check && tsc --noEmit",
|
|
58
58
|
"fix": "biome check --write --unsafe",
|
|
59
59
|
"test": "vitest run",
|
|
60
|
-
"sdk-playground": "node --conditions bun --import tsx scripts/sdk-playground.ts",
|
|
61
60
|
"test:watch": "vitest",
|
|
62
61
|
"test:ui": "vitest --ui",
|
|
63
62
|
"prettier:changed": "git diff -z --name-only --diff-filter=ACMRTUXB --relative HEAD -- . | xargs -0 npx prettier --ignore-unknown --write",
|
|
@@ -69,6 +68,7 @@
|
|
|
69
68
|
"@bufbuild/protobuf": "1.10.0",
|
|
70
69
|
"@connectrpc/connect": "^1.6.1",
|
|
71
70
|
"@connectrpc/connect-node": "^1.6.1",
|
|
71
|
+
"@statsig/js-client": "3.31.0",
|
|
72
72
|
"sqlite3": "^5.1.7",
|
|
73
73
|
"zod": "^3.25.0"
|
|
74
74
|
},
|
|
@@ -103,10 +103,10 @@
|
|
|
103
103
|
"zod": "^3.25.0"
|
|
104
104
|
},
|
|
105
105
|
"optionalDependencies": {
|
|
106
|
-
"@cursor/sdk-darwin-arm64": "1.0.
|
|
107
|
-
"@cursor/sdk-darwin-x64": "1.0.
|
|
108
|
-
"@cursor/sdk-linux-arm64": "1.0.
|
|
109
|
-
"@cursor/sdk-linux-x64": "1.0.
|
|
110
|
-
"@cursor/sdk-win32-x64": "1.0.
|
|
106
|
+
"@cursor/sdk-darwin-arm64": "1.0.8",
|
|
107
|
+
"@cursor/sdk-darwin-x64": "1.0.8",
|
|
108
|
+
"@cursor/sdk-linux-arm64": "1.0.8",
|
|
109
|
+
"@cursor/sdk-linux-x64": "1.0.8",
|
|
110
|
+
"@cursor/sdk-win32-x64": "1.0.8"
|
|
111
111
|
}
|
|
112
112
|
}
|
package/dist/cjs/829.index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";exports.id=829,exports.ids=[829],exports.modules={"./src/agent/cloud-agent.ts"(t,e,n){n.r(e),n.d(e,{archiveCloudAgent:()=>U,createCloudAgent:()=>R,deleteCloudAgent:()=>D,getCloudAgent:()=>k,getCloudMe:()=>q,getCloudRun:()=>x,listCloudAgents:()=>$,listCloudModels:()=>P,listCloudRepositories:()=>K,listCloudRuns:()=>j,resumeCloudAgent:()=>C,unarchiveCloudAgent:()=>T});var i=n("../cursor-sdk-local-runtime/dist/run-store/index.js"),s=n("./src/agent/analytics.ts"),r=n("./src/agent/errors.ts"),o=n("./src/agent/executor-common.ts"),a=n("./src/agent/utils/logger.ts"),u=function(t,e,n,i){return new(n||(n=Promise))((function(s,r){function o(t){try{u(i.next(t))}catch(t){r(t)}}function a(t){try{u(i.throw(t))}catch(t){r(t)}}function u(t){var e;t.done?s(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(o,a)}u((i=i.apply(t,e||[])).next())}))};function d(t){var e;return Object.assign(Object.assign(Object.assign({status:null!==(e=t.status)&&void 0!==e?e:"FINISHED"},void 0!==t.result?{result:t.result}:{}),void 0!==t.durationMs?{durationMs:t.durationMs}:{}),t.git?{git:{branches:t.git.branches.map((t=>Object.assign(Object.assign({repoUrl:t.repoUrl},void 0!==t.branch?{branch:t.branch}:{}),void 0!==t.prUrl?{prUrl:t.prUrl}:{})))}}:{})}class c{constructor(t,e){var n;this.baseUrl=null!==(n=null!=e?e:process.env.CURSOR_BACKEND_URL)&&void 0!==n?n:"https://api.cursor.com",this.apiKey=t,this.isLocalhost=/:\/\/(localhost|127\.0\.0\.1)/.test(this.baseUrl)}headers(t){return u(this,void 0,void 0,(function*(){yield(0,o.ly)(this.apiKey);const e={Authorization:`Bearer ${this.apiKey}`,"x-ghost-mode":(0,o.U)(this.apiKey),"x-cursor-client-version":(0,o.tF)()};return(null==t?void 0:t.hasBody)&&(e["Content-Type"]="application/json"),this.isLocalhost&&(e["x-background-composer-local-use-non-vm"]="true"),(null==t?void 0:t.streaming)&&(e["x-cursor-streaming"]="true"),e}))}request(t){return u(this,arguments,void 0,(function*({method:t,path:e,body:n,query:i}){const s=i?Object.entries(i).filter((([,t])=>void 0!==t)).map((([t,e])=>`${encodeURIComponent(t)}=${encodeURIComponent(String(e))}`)).join("&"):"",r=`${this.baseUrl}${e}${s?`?${s}`:""}`,o=void 0!==n,u=yield this.headers({hasBody:o});a.v.log(`[cloud-api] ${t} ${r}`);const d=yield fetch(r,Object.assign({method:t,headers:u},o?{body:JSON.stringify(n)}:{}));if(!d.ok){const n=yield d.text().catch((()=>""));a.v.log(`[cloud-api] ${t} ${e} status=${d.status} ${n}`),this.throwApiError(d.status,n)}const c=yield d.text();return c?JSON.parse(c):{}}))}throwApiError(t,e){let n,i,s="unknown",o=e||`Request failed with status ${t}`;try{const t=JSON.parse(e);(null==t?void 0:t.error)&&(s=t.error.code,o=t.error.message,n=t.error.helpUrl,i=t.error.provider)}catch(t){}if("integration_not_connected"===s){if(void 0!==n&&void 0!==i)throw new r.VW(`[${s}] ${o}`,{helpUrl:n,provider:i,isRetryable:!1});throw new r.j1(`[${s}] ${o}`,{isRetryable:!1})}switch(t){case 401:throw new r.v3(o,{isRetryable:!1});case 429:throw new r.OE(o,{isRetryable:!0});case 400:case 404:case 409:throw new r.j1(`[${s}] ${o}`,{isRetryable:!1});default:if(t>=500)throw new r.Dr(o,{isRetryable:!0});throw new r.c$(`[${s}] ${o}`,{isRetryable:!1})}}createAgent(t){return u(this,void 0,void 0,(function*(){return this.request({method:"POST",path:"/v1/agents",body:t})}))}getAgent(t){return u(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`/v1/agents/${l(t)}`})}))}listAgents(t){return u(this,void 0,void 0,(function*(){return this.request({method:"GET",path:"/v1/agents",query:t})}))}archiveAgent(t){return u(this,void 0,void 0,(function*(){return this.request({method:"POST",path:`/v1/agents/${l(t)}/archive`})}))}unarchiveAgent(t){return u(this,void 0,void 0,(function*(){return this.request({method:"POST",path:`/v1/agents/${l(t)}/unarchive`})}))}deleteAgent(t){return u(this,void 0,void 0,(function*(){return this.request({method:"DELETE",path:`/v1/agents/${l(t)}`})}))}createRun(t,e){return u(this,void 0,void 0,(function*(){return this.request({method:"POST",path:`/v1/agents/${l(t)}/runs`,body:e})}))}listRuns(t,e){return u(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`/v1/agents/${l(t)}/runs`,query:e})}))}getRun(t){return u(this,arguments,void 0,(function*({agentId:t,runId:e}){return this.request({method:"GET",path:`/v1/agents/${l(t)}/runs/${l(e)}`})}))}cancelRun(t){return u(this,arguments,void 0,(function*({agentId:t,runId:e}){return this.request({method:"POST",path:`/v1/agents/${l(t)}/runs/${l(e)}/cancel`})}))}streamRun(t){return u(this,arguments,void 0,(function*({agentId:t,runId:e,lastEventId:n,signal:i}){const s=`${this.baseUrl}/v1/agents/${l(t)}/runs/${l(e)}/stream`,r=yield this.headers({streaming:!0});r.Accept="text/event-stream",n&&(r["Last-Event-ID"]=n),a.v.log(`[cloud-api] GET ${s}`);const o=yield fetch(s,{method:"GET",headers:r,signal:i});if(!o.ok||!o.body){const t=yield o.text().catch((()=>""));a.v.log(`[cloud-api] stream status=${o.status} ${t}`),this.throwApiError(o.status,t)}return o}))}listArtifacts(t){return u(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`/v1/agents/${l(t)}/artifacts`})}))}getArtifactDownloadUrl(t){return u(this,arguments,void 0,(function*({agentId:t,path:e}){return this.request({method:"GET",path:`/v1/agents/${l(t)}/artifacts/download`,query:{path:e}})}))}getMe(){return u(this,void 0,void 0,(function*(){return this.request({method:"GET",path:"/v1/me"})}))}listModels(){return u(this,void 0,void 0,(function*(){return this.request({method:"GET",path:"/v1/models"})}))}listRepositories(){return u(this,void 0,void 0,(function*(){return this.request({method:"GET",path:"/v1/repositories"})}))}}function l(t){return encodeURIComponent(t)}function h(t){if(void 0===t)return;const e=[];for(const[n,i]of Object.entries(t))if("command"in i){if(void 0!==i.cwd)throw new r.j1(`Cloud MCP server "${n}" cannot include cwd.`);e.push(Object.assign({name:n},i))}else e.push(Object.assign({name:n},i));return e.length>0?e:void 0}var v=n("./src/agent/run-interaction-accumulator.ts"),f=n("./src/agent/tool-call-utils.ts"),g=n("./src/agent/types/delta-types.ts"),p=function(t,e,n,i){return new(n||(n=Promise))((function(s,r){function o(t){try{u(i.next(t))}catch(t){r(t)}}function a(t){try{u(i.throw(t))}catch(t){r(t)}}function u(t){var e;t.done?s(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(o,a)}u((i=i.apply(t,e||[])).next())}))},m=function(t){return this instanceof m?(this.v=t,this):new m(t)};function y(t){const e=null!=t?t:process.env.CURSOR_API_KEY;if(!e)throw new Error("API key is required for cloud operations. Set CURSOR_API_KEY or pass apiKey.");return e}function w(t){switch(t){case"CREATING":case"RUNNING":return"running";case"FINISHED":return"finished";case"CANCELLED":return"cancelled";default:return"error"}}function b(t){return"running"===t||"completed"===t||"error"===t}const S=new Set(["assistant","thinking","tool_call"]);class _{constructor(){this.queue=[],this.waiters=[],this.closed=!1}push(t){if(this.closed)return;const e=this.waiters.shift();e?e({value:t,done:!1}):this.queue.push(t)}close(){var t;if(!this.closed)for(this.closed=!0;this.waiters.length>0;)null===(t=this.waiters.shift())||void 0===t||t({value:void 0,done:!0})}stream(){return function(t,e,n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var i,s=n.apply(t,e||[]),r=[];return i=Object.create(("function"==typeof AsyncIterator?AsyncIterator:Object).prototype),o("next"),o("throw"),o("return",(function(t){return function(e){return Promise.resolve(e).then(t,d)}})),i[Symbol.asyncIterator]=function(){return this},i;function o(t,e){s[t]&&(i[t]=function(e){return new Promise((function(n,i){r.push([t,e,n,i])>1||a(t,e)}))},e&&(i[t]=e(i[t])))}function a(t,e){try{(n=s[t](e)).value instanceof m?Promise.resolve(n.value.v).then(u,d):c(r[0][2],n)}catch(t){c(r[0][3],t)}var n}function u(t){a("next",t)}function d(t){a("throw",t)}function c(t,e){t(e),r.shift(),r.length&&a(r[0][0],r[0][1])}}(this,arguments,(function*(){for(;;){const t=this.queue.shift();if(t){yield yield m(t);continue}if(this.closed)return yield m(void 0);const e=yield m(new Promise((t=>{this.waiters.push(t)})));if(e.done)return yield m(void 0);yield yield m(e.value)}}))}}const I=new Set(["unauthorized","forbidden","not_found"]);function A(t,e){return p(this,void 0,void 0,(function*(){t<=0||(null==e?void 0:e.aborted)||(yield new Promise((n=>{const i=setTimeout((()=>{null==e||e.removeEventListener("abort",s),n()}),t),s=()=>{clearTimeout(i),n()};null==e||e.addEventListener("abort",s,{once:!0})})))}))}class E{constructor(t,e,n){this.client=t,this.buffer=new _,this.listeners=new Set,this.streamStarted=!1,this.emittedLegacyFrameIds=new Set,this.id=e.id,this.agentId=e.agentId,this._status=w(e.status),this.createdAt=Date.parse(e.createdAt);const i=d(e);this._result=i.result,this._durationMs=i.durationMs,this._git=i.git,this.sendOptions=n}get status(){return this._status}get result(){return this._result}get durationMs(){return this._durationMs}get git(){return this._git}supports(t){return"stream"===t||"wait"===t||"cancel"===t||"conversation"===t}unsupportedReason(t){if(!this.supports(t))return`Unknown run operation "${t}"`}stream(){return this.ensureStreamStarted(),this.buffer.stream()}conversation(){return p(this,void 0,void 0,(function*(){var t,e;this.ensureStreamStarted();try{yield this.streamPromise}catch(t){}return null!==(e=null===(t=this.accumulator)||void 0===t?void 0:t.conversation())&&void 0!==e?e:[]}))}wait(){return p(this,void 0,void 0,(function*(){if("running"!==this._status)return this.buildResult();this.ensureStreamStarted();try{yield this.streamPromise}catch(t){"running"===this._status&&this.setStatus("error")}return this.buildResult()}))}cancel(){return p(this,void 0,void 0,(function*(){var t;"cancelled"!==this._status&&(yield this.client.cancelRun({agentId:this.agentId,runId:this.id}),null===(t=this.abortController)||void 0===t||t.abort(),this.setStatus("cancelled"))}))}onDidChangeStatus(t){return this.listeners.add(t),()=>this.listeners.delete(t)}ensureStreamStarted(){var t,e;if(this.streamStarted)return;this.streamStarted=!0,this.abortController=new AbortController;const n=new v.e4({onDelta:null===(t=this.sendOptions)||void 0===t?void 0:t.onDelta,onStep:null===(e=this.sendOptions)||void 0===e?void 0:e.onStep});this.accumulator=n,this.streamPromise=this.runStreamLoop(n,this.abortController.signal),this.streamPromise.catch((()=>{}))}runStreamLoop(t,e){return p(this,void 0,void 0,(function*(){let n=0;const i=Date.now()+72e5;try{do{const r=yield this.runOneStreamAttempt(t,e);if(e.aborted)break;if("received-result"===r)break;if(yield this.refetchAndSync(),e.aborted||"running"!==this._status)break;if(Date.now()>=i)break;if(n>=6){yield this.pollRunUntilTerminal(e,i);break}const o=Math.min((s=n,Math.min(3e4,1e3*Math.pow(2,s))),Math.max(0,i-Date.now()));n++,yield A(o,e)}while("running"===this._status&&!e.aborted);"running"===this._status&&Date.now()>=i&&this.setStatus("error"),"finished"===this._status&&(yield t.flushPendingStep())}finally{this.buffer.close()}var s}))}runOneStreamAttempt(t,e){return p(this,void 0,void 0,(function*(){const n=this.lastEventId;let i=!1;try{const n=yield this.client.streamRun(Object.assign({agentId:this.agentId,runId:this.id,signal:e},void 0!==this.lastEventId?{lastEventId:this.lastEventId}:{}));yield function(t,e,n,i,s){return p(this,void 0,void 0,(function*(){var r,o,a,u,c,l,h,v;const p=t.body.getReader(),m=new TextDecoder;let y="";try{for(;;){if(null==s?void 0:s.aborted)return;const{value:t,done:_}=yield p.read();if(_)break;y+=m.decode(t,{stream:!0});let I=y.indexOf("\n\n");for(;-1!==I;){const t=y.slice(0,I);y=y.slice(I+2),I=y.indexOf("\n\n");const s=t.split("\n");let m,_;const A=[];for(const t of s)t.startsWith("id: ")?_=t.slice(4).trim():t.startsWith("event: ")?m=t.slice(7).trim():t.startsWith("data: ")&&A.push(t.slice(6));if(void 0!==_&&_.length>0&&(void 0===m||!S.has(m))&&(null===(r=i.onEventId)||void 0===r||r.call(i,_)),"done"===m)return void(yield p.cancel());if(0===A.length)continue;const E=A.join("\n");let O;try{O=JSON.parse(E)}catch(t){throw new Error(`Malformed SSE event: ${E}`)}if(m&&(!S.has(m)||void 0===_||!1!==(null===(o=i.shouldEmitLegacyFrame)||void 0===o?void 0:o.call(i,_))))switch(m){case"assistant":{const t=(0,f.u)(O)?O:{};i.onMessage({type:"assistant",agent_id:e,run_id:n,message:{role:"assistant",content:[{type:"text",text:null!==(a=t.text)&&void 0!==a?a:""}]}});break}case"thinking":{const t=(0,f.u)(O)?O:{};i.onMessage({type:"thinking",agent_id:e,run_id:n,text:null!==(u=t.text)&&void 0!==u?u:""});break}case"tool_call":{const t=(0,f.u)(O)?O:{},s=(0,f.u)(t.data)?t.data:t,r=b(s.status)?s.status:"running",o="string"==typeof s.callId?s.callId:"",a="string"==typeof s.name?s.name:"unknown";i.onMessage(Object.assign(Object.assign(Object.assign({type:"tool_call",agent_id:e,run_id:n,call_id:o,name:a,status:r},"args"in s?{args:s.args}:{}),"result"in s?{result:s.result}:{}),(0,f.D)(s.truncated)?{truncated:s.truncated}:{}));break}case"interaction_update":{if(void 0===i.onInteractionUpdate)break;const t=g.Zs.safeParse(O);if(!t.success)break;yield i.onInteractionUpdate(t.data);break}case"status":{const t=((0,f.u)(O)?O:{}).status;t&&(null===(c=i.onStatusChange)||void 0===c||c.call(i,w(t)),i.onMessage({type:"status",agent_id:e,run_id:n,status:t}));break}case"result":if((0,f.u)(O)){const t=O,e=Object.assign(Object.assign({},t),"string"==typeof t.text&&void 0===t.result?{result:t.text}:{});null===(l=i.onResult)||void 0===l||l.call(i,d(e))}return void(yield p.cancel());case"heartbeat":break;case"error":{const t=(0,f.u)(O)?O:{},e=null!==(h=t.code)&&void 0!==h?h:"UNKNOWN",n=null!==(v=t.message)&&void 0!==v?v:"Unknown error";throw new Error(`[${e}] ${n}`)}}}}}catch(t){if((null==s?void 0:s.aborted)||"object"==typeof t&&null!==t&&"name"in t&&"AbortError"===t.name)return;throw t}finally{try{yield p.cancel()}catch(t){}}}))}(n,this.agentId,this.id,{onMessage:t=>this.buffer.push(t),onResult:t=>{var e;this._result=t.result,this._durationMs=t.durationMs,this._git=t.git,this.setStatus(w(null!==(e=t.status)&&void 0!==e?e:"FINISHED")),i=!0},onStatusChange:t=>{"running"===t&&this.setStatus(t)},onInteractionUpdate:e=>t.apply(e),onEventId:t=>{this.lastEventId=t,this.emittedLegacyFrameIds.clear()},shouldEmitLegacyFrame:t=>!this.emittedLegacyFrameIds.has(t)&&(this.emittedLegacyFrameIds.add(t),!0)},e)}catch(t){if(function(t){return t instanceof Error&&t.message.startsWith("[invalid_last_event_id]")}(t))this.lastEventId===n&&(this.lastEventId=void 0);else if(function(t){if(t instanceof r.v3||t instanceof r.j1)return!0;if(t instanceof Error){const e=/^\[([a-z_]+)\]/.exec(t.message);if(null!==e&&I.has(e[1]))return!0}return!1}(t))throw"running"===this._status&&this.setStatus("error"),t}return i?"received-result":"stream-dropped"}))}pollRunUntilTerminal(t,e){return p(this,void 0,void 0,(function*(){for(;"running"===this._status&&!t.aborted;){const n=e-Date.now();if(n<=0)return void this.setStatus("error");if(yield A(Math.min(15e3,n),t),t.aborted)return;yield this.refetchAndSync()}}))}setStatus(t){if(this._status!==t){this._status=t;for(const e of this.listeners)e(t)}}refetchAndSync(){return p(this,void 0,void 0,(function*(){let t;try{t=yield this.client.getRun({agentId:this.agentId,runId:this.id})}catch(t){if(t instanceof r.v3||t instanceof r.j1)throw"running"===this._status&&this.setStatus("error"),t;return}const e=d(t);void 0!==e.result&&(this._result=e.result),void 0!==e.durationMs&&(this._durationMs=e.durationMs),void 0!==e.git&&(this._git=e.git),"running"===this._status&&this.setStatus(w(t.status))}))}buildResult(){const t="running"===this._status?"error":this._status;return Object.assign(Object.assign(Object.assign({id:this.id,status:t},void 0!==this._result?{result:this._result}:{}),void 0!==this._durationMs?{durationMs:this._durationMs}:{}),void 0!==this._git?{git:this._git}:{})}}class O{constructor(t,e,n,i){this.client=e,this.options=n,this.agentId=t,this.serverCreated=i}send(t,e){return p(this,void 0,void 0,(function*(){var n,i,o,a,u,d,c,l,v,f,g,p,m,y,w,b;const S=function(t){var e;return"string"==typeof t?{text:t}:{text:t.text,images:null===(e=t.images)||void 0===e?void 0:e.map((t=>"url"in t?{url:t.url,dimension:t.dimension}:{data:t.data,mimeType:t.mimeType,dimension:t.dimension}))}}(t);if(void 0!==(null==e?void 0:e.model))throw new Error("Cloud send model overrides are not supported in v1");const _=!this.serverCreated,I=void 0!==(null==e?void 0:e.onStep)||void 0!==(null==e?void 0:e.onDelta)?Object.assign(Object.assign({},void 0!==e.onStep?{onStep:e.onStep}:{}),void 0!==e.onDelta?{onDelta:e.onDelta}:{}):void 0;let A;if(_){const t=function(t){if(void 0===t)return;const e=Object.entries(t);if(0===e.length)return;const n=[];for(const[t,i]of e){if(void 0!==i.mcpServers)for(const e of i.mcpServers)if("string"!=typeof e)throw new r.j1(`Custom subagent "${t}" has an inline McpServerConfig in mcpServers; cloud custom subagents only support string references in v1.`);const e=void 0===i.model||"inherit"===i.model?"inherit":i.model.id;n.push({name:t,description:i.description,prompt:i.prompt,model:e})}return n}(this.options.agents),e=yield this.client.createAgent(Object.assign(Object.assign(Object.assign(Object.assign({agentId:this.agentId,prompt:S,model:this.options.model},void 0!==this.options.name?{name:this.options.name}:{}),{mcpServers:h(this.options.mcpServers)}),void 0!==t?{customSubagents:t}:{}),{env:null===(n=this.options.cloud)||void 0===n?void 0:n.env,repos:null===(i=this.options.cloud)||void 0===i?void 0:i.repos,workOnCurrentBranch:null===(o=this.options.cloud)||void 0===o?void 0:o.workOnCurrentBranch,autoCreatePR:null===(a=this.options.cloud)||void 0===a?void 0:a.autoCreatePR,skipReviewerRequest:null===(u=this.options.cloud)||void 0===u?void 0:u.skipReviewerRequest}));if(e.agent.id!==this.agentId)throw new Error(`Server returned mismatched agent id "${e.agent.id}"; expected "${this.agentId}". This indicates a backend bug.`);this.serverCreated=!0,A=new E(this.client,e.run,I)}else{const t=yield this.client.createRun(this.agentId,{prompt:S});A=new E(this.client,t.run,I)}const O=null!==(l=null===(c=null===(d=this.options.cloud)||void 0===d?void 0:d.env)||void 0===c?void 0:c.type)&&void 0!==l?l:"cloud";(0,s.Zn)(this.options.apiKey,{agent_id:this.agentId,run_id:A.id,runtime:O,model:null!==(f=null===(v=this.options.model)||void 0===v?void 0:v.id)&&void 0!==f?f:"default",prompt_length:S.text.length,has_images:(null!==(p=null===(g=S.images)||void 0===g?void 0:g.length)&&void 0!==p?p:0)>0,is_resume:!_||void 0!==this.options.resume,mcp_server_count:Object.keys(null!==(m=this.options.mcpServers)&&void 0!==m?m:{}).length,cloud_repo_count:null===(w=null===(y=this.options.cloud)||void 0===y?void 0:y.repos)||void 0===w?void 0:w.length,cloud_auto_create_pr:null===(b=this.options.cloud)||void 0===b?void 0:b.autoCreatePR});const R=this.options.apiKey,C=this.agentId,$=A.id;return A.wait().then((t=>{(0,s.G5)(R,{agent_id:C,run_id:$,runtime:O,end_reason:"finished"===t.status?"success":"cancelled"===t.status?"abort":"error"})})),A.ensureStreamStarted(),A}))}close(){(0,s.rd)()}reload(){return p(this,void 0,void 0,(function*(){}))}[Symbol.asyncDispose](){return p(this,void 0,void 0,(function*(){yield(0,s.rd)()}))}listArtifacts(){return p(this,void 0,void 0,(function*(){return this.serverCreated?(yield this.client.listArtifacts(this.agentId)).items.map((t=>({path:t.path,sizeBytes:t.sizeBytes,updatedAt:t.updatedAt}))):[]}))}downloadArtifact(t){return p(this,void 0,void 0,(function*(){if(!this.serverCreated)throw new Error("Agent has not been created yet; call send() first.");const{url:e}=yield this.client.getArtifactDownloadUrl({agentId:this.agentId,path:t}),n=yield fetch(e);if(!n.ok)throw new Error(`Failed to download artifact: ${n.status}`);return Buffer.from(yield n.arrayBuffer())}))}}function R(t){var e;const n=y(t.apiKey),s=new c(n),r=null!==(e=t.agentId)&&void 0!==e?e:(0,i.M2)();return new O(r,s,t,!1)}function C(t,e){const n=y(e.apiKey),i=new c(n);return new O(t,i,Object.assign({},e),!0)}function $(t){return p(this,void 0,void 0,(function*(){const e=y(t.apiKey),n=new c(e),i=yield n.listAgents({limit:t.limit,cursor:t.cursor,prUrl:t.prUrl,includeArchived:t.includeArchived});return{items:i.items.map(M),nextCursor:i.nextCursor}}))}function j(t,e){return p(this,void 0,void 0,(function*(){const n=y(e.apiKey),i=new c(n),s=yield i.listRuns(t,{limit:e.limit,cursor:e.cursor});return{items:s.items.map((t=>new E(i,t))),nextCursor:s.nextCursor}}))}function x(t,e){return p(this,void 0,void 0,(function*(){const n=y(e.apiKey),i=new c(n),s=yield i.getRun({agentId:e.agentId,runId:t});return new E(i,s)}))}function M(t){var e,n,i;return{agentId:t.id,name:null!==(e=t.name)&&void 0!==e?e:"",summary:null!==(n=t.name)&&void 0!==n?n:"",lastModified:new Date(t.updatedAt).getTime(),createdAt:new Date(t.createdAt).getTime(),archived:"ARCHIVED"===t.status,runtime:"cloud",env:t.env,repos:null===(i=t.repos)||void 0===i?void 0:i.map((t=>t.url))}}function k(t,e){return p(this,void 0,void 0,(function*(){const n=y(e.apiKey),i=new c(n);return M(yield i.getAgent(t))}))}function U(t,e){return p(this,void 0,void 0,(function*(){const n=y(e.apiKey),i=new c(n);yield i.archiveAgent(t)}))}function T(t,e){return p(this,void 0,void 0,(function*(){const n=y(e.apiKey),i=new c(n);yield i.unarchiveAgent(t)}))}function D(t,e){return p(this,void 0,void 0,(function*(){const n=y(e.apiKey),i=new c(n);yield i.deleteAgent(t)}))}function q(t){return p(this,void 0,void 0,(function*(){const e=y(t.apiKey);return new c(e).getMe()}))}function P(t){return p(this,void 0,void 0,(function*(){const e=y(t.apiKey),n=new c(e);return(yield n.listModels()).items}))}function K(t){return p(this,void 0,void 0,(function*(){const e=y(t.apiKey),n=new c(e);return(yield n.listRepositories()).items}))}}};
|
package/dist/esm/829.index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export const __webpack_esm_id__=829;export const __webpack_esm_ids__=[829];export const __webpack_esm_modules__={"./src/agent/cloud-agent.ts"(t,e,n){n.d(e,{archiveCloudAgent:()=>U,createCloudAgent:()=>R,deleteCloudAgent:()=>D,getCloudAgent:()=>M,getCloudMe:()=>q,getCloudRun:()=>x,listCloudAgents:()=>$,listCloudModels:()=>P,listCloudRepositories:()=>K,listCloudRuns:()=>j,resumeCloudAgent:()=>C,unarchiveCloudAgent:()=>T}),n.r(e);var i=n("../cursor-sdk-local-runtime/dist/run-store/index.js"),s=n("./src/agent/analytics.ts"),r=n("./src/agent/errors.ts"),o=n("./src/agent/executor-common.ts"),a=n("./src/agent/utils/logger.ts"),u=function(t,e,n,i){return new(n||(n=Promise))((function(s,r){function o(t){try{u(i.next(t))}catch(t){r(t)}}function a(t){try{u(i.throw(t))}catch(t){r(t)}}function u(t){var e;t.done?s(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(o,a)}u((i=i.apply(t,e||[])).next())}))};function d(t){var e;return Object.assign(Object.assign(Object.assign({status:null!==(e=t.status)&&void 0!==e?e:"FINISHED"},void 0!==t.result?{result:t.result}:{}),void 0!==t.durationMs?{durationMs:t.durationMs}:{}),t.git?{git:{branches:t.git.branches.map((t=>Object.assign(Object.assign({repoUrl:t.repoUrl},void 0!==t.branch?{branch:t.branch}:{}),void 0!==t.prUrl?{prUrl:t.prUrl}:{})))}}:{})}class c{constructor(t,e){var n;this.baseUrl=null!==(n=null!=e?e:process.env.CURSOR_BACKEND_URL)&&void 0!==n?n:"https://api.cursor.com",this.apiKey=t,this.isLocalhost=/:\/\/(localhost|127\.0\.0\.1)/.test(this.baseUrl)}headers(t){return u(this,void 0,void 0,(function*(){yield(0,o.ly)(this.apiKey);const e={Authorization:`Bearer ${this.apiKey}`,"x-ghost-mode":(0,o.U)(this.apiKey),"x-cursor-client-version":(0,o.tF)()};return(null==t?void 0:t.hasBody)&&(e["Content-Type"]="application/json"),this.isLocalhost&&(e["x-background-composer-local-use-non-vm"]="true"),(null==t?void 0:t.streaming)&&(e["x-cursor-streaming"]="true"),e}))}request(t){return u(this,arguments,void 0,(function*({method:t,path:e,body:n,query:i}){const s=i?Object.entries(i).filter((([,t])=>void 0!==t)).map((([t,e])=>`${encodeURIComponent(t)}=${encodeURIComponent(String(e))}`)).join("&"):"",r=`${this.baseUrl}${e}${s?`?${s}`:""}`,o=void 0!==n,u=yield this.headers({hasBody:o});a.v.log(`[cloud-api] ${t} ${r}`);const d=yield fetch(r,Object.assign({method:t,headers:u},o?{body:JSON.stringify(n)}:{}));if(!d.ok){const n=yield d.text().catch((()=>""));a.v.log(`[cloud-api] ${t} ${e} status=${d.status} ${n}`),this.throwApiError(d.status,n)}const c=yield d.text();return c?JSON.parse(c):{}}))}throwApiError(t,e){let n,i,s="unknown",o=e||`Request failed with status ${t}`;try{const t=JSON.parse(e);(null==t?void 0:t.error)&&(s=t.error.code,o=t.error.message,n=t.error.helpUrl,i=t.error.provider)}catch(t){}if("integration_not_connected"===s){if(void 0!==n&&void 0!==i)throw new r.VW(`[${s}] ${o}`,{helpUrl:n,provider:i,isRetryable:!1});throw new r.j1(`[${s}] ${o}`,{isRetryable:!1})}switch(t){case 401:throw new r.v3(o,{isRetryable:!1});case 429:throw new r.OE(o,{isRetryable:!0});case 400:case 404:case 409:throw new r.j1(`[${s}] ${o}`,{isRetryable:!1});default:if(t>=500)throw new r.Dr(o,{isRetryable:!0});throw new r.c$(`[${s}] ${o}`,{isRetryable:!1})}}createAgent(t){return u(this,void 0,void 0,(function*(){return this.request({method:"POST",path:"/v1/agents",body:t})}))}getAgent(t){return u(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`/v1/agents/${l(t)}`})}))}listAgents(t){return u(this,void 0,void 0,(function*(){return this.request({method:"GET",path:"/v1/agents",query:t})}))}archiveAgent(t){return u(this,void 0,void 0,(function*(){return this.request({method:"POST",path:`/v1/agents/${l(t)}/archive`})}))}unarchiveAgent(t){return u(this,void 0,void 0,(function*(){return this.request({method:"POST",path:`/v1/agents/${l(t)}/unarchive`})}))}deleteAgent(t){return u(this,void 0,void 0,(function*(){return this.request({method:"DELETE",path:`/v1/agents/${l(t)}`})}))}createRun(t,e){return u(this,void 0,void 0,(function*(){return this.request({method:"POST",path:`/v1/agents/${l(t)}/runs`,body:e})}))}listRuns(t,e){return u(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`/v1/agents/${l(t)}/runs`,query:e})}))}getRun(t){return u(this,arguments,void 0,(function*({agentId:t,runId:e}){return this.request({method:"GET",path:`/v1/agents/${l(t)}/runs/${l(e)}`})}))}cancelRun(t){return u(this,arguments,void 0,(function*({agentId:t,runId:e}){return this.request({method:"POST",path:`/v1/agents/${l(t)}/runs/${l(e)}/cancel`})}))}streamRun(t){return u(this,arguments,void 0,(function*({agentId:t,runId:e,lastEventId:n,signal:i}){const s=`${this.baseUrl}/v1/agents/${l(t)}/runs/${l(e)}/stream`,r=yield this.headers({streaming:!0});r.Accept="text/event-stream",n&&(r["Last-Event-ID"]=n),a.v.log(`[cloud-api] GET ${s}`);const o=yield fetch(s,{method:"GET",headers:r,signal:i});if(!o.ok||!o.body){const t=yield o.text().catch((()=>""));a.v.log(`[cloud-api] stream status=${o.status} ${t}`),this.throwApiError(o.status,t)}return o}))}listArtifacts(t){return u(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`/v1/agents/${l(t)}/artifacts`})}))}getArtifactDownloadUrl(t){return u(this,arguments,void 0,(function*({agentId:t,path:e}){return this.request({method:"GET",path:`/v1/agents/${l(t)}/artifacts/download`,query:{path:e}})}))}getMe(){return u(this,void 0,void 0,(function*(){return this.request({method:"GET",path:"/v1/me"})}))}listModels(){return u(this,void 0,void 0,(function*(){return this.request({method:"GET",path:"/v1/models"})}))}listRepositories(){return u(this,void 0,void 0,(function*(){return this.request({method:"GET",path:"/v1/repositories"})}))}}function l(t){return encodeURIComponent(t)}function h(t){if(void 0===t)return;const e=[];for(const[n,i]of Object.entries(t))if("command"in i){if(void 0!==i.cwd)throw new r.j1(`Cloud MCP server "${n}" cannot include cwd.`);e.push(Object.assign({name:n},i))}else e.push(Object.assign({name:n},i));return e.length>0?e:void 0}var v=n("./src/agent/run-interaction-accumulator.ts"),f=n("./src/agent/tool-call-utils.ts"),g=n("./src/agent/types/delta-types.ts"),p=function(t,e,n,i){return new(n||(n=Promise))((function(s,r){function o(t){try{u(i.next(t))}catch(t){r(t)}}function a(t){try{u(i.throw(t))}catch(t){r(t)}}function u(t){var e;t.done?s(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(o,a)}u((i=i.apply(t,e||[])).next())}))},m=function(t){return this instanceof m?(this.v=t,this):new m(t)};function y(t){const e=null!=t?t:process.env.CURSOR_API_KEY;if(!e)throw new Error("API key is required for cloud operations. Set CURSOR_API_KEY or pass apiKey.");return e}function w(t){switch(t){case"CREATING":case"RUNNING":return"running";case"FINISHED":return"finished";case"CANCELLED":return"cancelled";default:return"error"}}function b(t){return"running"===t||"completed"===t||"error"===t}const _=new Set(["assistant","thinking","tool_call"]);class S{constructor(){this.queue=[],this.waiters=[],this.closed=!1}push(t){if(this.closed)return;const e=this.waiters.shift();e?e({value:t,done:!1}):this.queue.push(t)}close(){var t;if(!this.closed)for(this.closed=!0;this.waiters.length>0;)null===(t=this.waiters.shift())||void 0===t||t({value:void 0,done:!0})}stream(){return function(t,e,n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var i,s=n.apply(t,e||[]),r=[];return i=Object.create(("function"==typeof AsyncIterator?AsyncIterator:Object).prototype),o("next"),o("throw"),o("return",(function(t){return function(e){return Promise.resolve(e).then(t,d)}})),i[Symbol.asyncIterator]=function(){return this},i;function o(t,e){s[t]&&(i[t]=function(e){return new Promise((function(n,i){r.push([t,e,n,i])>1||a(t,e)}))},e&&(i[t]=e(i[t])))}function a(t,e){try{(n=s[t](e)).value instanceof m?Promise.resolve(n.value.v).then(u,d):c(r[0][2],n)}catch(t){c(r[0][3],t)}var n}function u(t){a("next",t)}function d(t){a("throw",t)}function c(t,e){t(e),r.shift(),r.length&&a(r[0][0],r[0][1])}}(this,arguments,(function*(){for(;;){const t=this.queue.shift();if(t){yield yield m(t);continue}if(this.closed)return yield m(void 0);const e=yield m(new Promise((t=>{this.waiters.push(t)})));if(e.done)return yield m(void 0);yield yield m(e.value)}}))}}const I=new Set(["unauthorized","forbidden","not_found"]);function A(t,e){return p(this,void 0,void 0,(function*(){t<=0||(null==e?void 0:e.aborted)||(yield new Promise((n=>{const i=setTimeout((()=>{null==e||e.removeEventListener("abort",s),n()}),t),s=()=>{clearTimeout(i),n()};null==e||e.addEventListener("abort",s,{once:!0})})))}))}class E{constructor(t,e,n){this.client=t,this.buffer=new S,this.listeners=new Set,this.streamStarted=!1,this.emittedLegacyFrameIds=new Set,this.id=e.id,this.agentId=e.agentId,this._status=w(e.status),this.createdAt=Date.parse(e.createdAt);const i=d(e);this._result=i.result,this._durationMs=i.durationMs,this._git=i.git,this.sendOptions=n}get status(){return this._status}get result(){return this._result}get durationMs(){return this._durationMs}get git(){return this._git}supports(t){return"stream"===t||"wait"===t||"cancel"===t||"conversation"===t}unsupportedReason(t){if(!this.supports(t))return`Unknown run operation "${t}"`}stream(){return this.ensureStreamStarted(),this.buffer.stream()}conversation(){return p(this,void 0,void 0,(function*(){var t,e;this.ensureStreamStarted();try{yield this.streamPromise}catch(t){}return null!==(e=null===(t=this.accumulator)||void 0===t?void 0:t.conversation())&&void 0!==e?e:[]}))}wait(){return p(this,void 0,void 0,(function*(){if("running"!==this._status)return this.buildResult();this.ensureStreamStarted();try{yield this.streamPromise}catch(t){"running"===this._status&&this.setStatus("error")}return this.buildResult()}))}cancel(){return p(this,void 0,void 0,(function*(){var t;"cancelled"!==this._status&&(yield this.client.cancelRun({agentId:this.agentId,runId:this.id}),null===(t=this.abortController)||void 0===t||t.abort(),this.setStatus("cancelled"))}))}onDidChangeStatus(t){return this.listeners.add(t),()=>this.listeners.delete(t)}ensureStreamStarted(){var t,e;if(this.streamStarted)return;this.streamStarted=!0,this.abortController=new AbortController;const n=new v.e4({onDelta:null===(t=this.sendOptions)||void 0===t?void 0:t.onDelta,onStep:null===(e=this.sendOptions)||void 0===e?void 0:e.onStep});this.accumulator=n,this.streamPromise=this.runStreamLoop(n,this.abortController.signal),this.streamPromise.catch((()=>{}))}runStreamLoop(t,e){return p(this,void 0,void 0,(function*(){let n=0;const i=Date.now()+72e5;try{do{const r=yield this.runOneStreamAttempt(t,e);if(e.aborted)break;if("received-result"===r)break;if(yield this.refetchAndSync(),e.aborted||"running"!==this._status)break;if(Date.now()>=i)break;if(n>=6){yield this.pollRunUntilTerminal(e,i);break}const o=Math.min((s=n,Math.min(3e4,1e3*Math.pow(2,s))),Math.max(0,i-Date.now()));n++,yield A(o,e)}while("running"===this._status&&!e.aborted);"running"===this._status&&Date.now()>=i&&this.setStatus("error"),"finished"===this._status&&(yield t.flushPendingStep())}finally{this.buffer.close()}var s}))}runOneStreamAttempt(t,e){return p(this,void 0,void 0,(function*(){const n=this.lastEventId;let i=!1;try{const n=yield this.client.streamRun(Object.assign({agentId:this.agentId,runId:this.id,signal:e},void 0!==this.lastEventId?{lastEventId:this.lastEventId}:{}));yield function(t,e,n,i,s){return p(this,void 0,void 0,(function*(){var r,o,a,u,c,l,h,v;const p=t.body.getReader(),m=new TextDecoder;let y="";try{for(;;){if(null==s?void 0:s.aborted)return;const{value:t,done:S}=yield p.read();if(S)break;y+=m.decode(t,{stream:!0});let I=y.indexOf("\n\n");for(;-1!==I;){const t=y.slice(0,I);y=y.slice(I+2),I=y.indexOf("\n\n");const s=t.split("\n");let m,S;const A=[];for(const t of s)t.startsWith("id: ")?S=t.slice(4).trim():t.startsWith("event: ")?m=t.slice(7).trim():t.startsWith("data: ")&&A.push(t.slice(6));if(void 0!==S&&S.length>0&&(void 0===m||!_.has(m))&&(null===(r=i.onEventId)||void 0===r||r.call(i,S)),"done"===m)return void(yield p.cancel());if(0===A.length)continue;const E=A.join("\n");let O;try{O=JSON.parse(E)}catch(t){throw new Error(`Malformed SSE event: ${E}`)}if(m&&(!_.has(m)||void 0===S||!1!==(null===(o=i.shouldEmitLegacyFrame)||void 0===o?void 0:o.call(i,S))))switch(m){case"assistant":{const t=(0,f.u)(O)?O:{};i.onMessage({type:"assistant",agent_id:e,run_id:n,message:{role:"assistant",content:[{type:"text",text:null!==(a=t.text)&&void 0!==a?a:""}]}});break}case"thinking":{const t=(0,f.u)(O)?O:{};i.onMessage({type:"thinking",agent_id:e,run_id:n,text:null!==(u=t.text)&&void 0!==u?u:""});break}case"tool_call":{const t=(0,f.u)(O)?O:{},s=(0,f.u)(t.data)?t.data:t,r=b(s.status)?s.status:"running",o="string"==typeof s.callId?s.callId:"",a="string"==typeof s.name?s.name:"unknown";i.onMessage(Object.assign(Object.assign(Object.assign({type:"tool_call",agent_id:e,run_id:n,call_id:o,name:a,status:r},"args"in s?{args:s.args}:{}),"result"in s?{result:s.result}:{}),(0,f.D)(s.truncated)?{truncated:s.truncated}:{}));break}case"interaction_update":{if(void 0===i.onInteractionUpdate)break;const t=g.Zs.safeParse(O);if(!t.success)break;yield i.onInteractionUpdate(t.data);break}case"status":{const t=((0,f.u)(O)?O:{}).status;t&&(null===(c=i.onStatusChange)||void 0===c||c.call(i,w(t)),i.onMessage({type:"status",agent_id:e,run_id:n,status:t}));break}case"result":if((0,f.u)(O)){const t=O,e=Object.assign(Object.assign({},t),"string"==typeof t.text&&void 0===t.result?{result:t.text}:{});null===(l=i.onResult)||void 0===l||l.call(i,d(e))}return void(yield p.cancel());case"heartbeat":break;case"error":{const t=(0,f.u)(O)?O:{},e=null!==(h=t.code)&&void 0!==h?h:"UNKNOWN",n=null!==(v=t.message)&&void 0!==v?v:"Unknown error";throw new Error(`[${e}] ${n}`)}}}}}catch(t){if((null==s?void 0:s.aborted)||"object"==typeof t&&null!==t&&"name"in t&&"AbortError"===t.name)return;throw t}finally{try{yield p.cancel()}catch(t){}}}))}(n,this.agentId,this.id,{onMessage:t=>this.buffer.push(t),onResult:t=>{var e;this._result=t.result,this._durationMs=t.durationMs,this._git=t.git,this.setStatus(w(null!==(e=t.status)&&void 0!==e?e:"FINISHED")),i=!0},onStatusChange:t=>{"running"===t&&this.setStatus(t)},onInteractionUpdate:e=>t.apply(e),onEventId:t=>{this.lastEventId=t,this.emittedLegacyFrameIds.clear()},shouldEmitLegacyFrame:t=>!this.emittedLegacyFrameIds.has(t)&&(this.emittedLegacyFrameIds.add(t),!0)},e)}catch(t){if(function(t){return t instanceof Error&&t.message.startsWith("[invalid_last_event_id]")}(t))this.lastEventId===n&&(this.lastEventId=void 0);else if(function(t){if(t instanceof r.v3||t instanceof r.j1)return!0;if(t instanceof Error){const e=/^\[([a-z_]+)\]/.exec(t.message);if(null!==e&&I.has(e[1]))return!0}return!1}(t))throw"running"===this._status&&this.setStatus("error"),t}return i?"received-result":"stream-dropped"}))}pollRunUntilTerminal(t,e){return p(this,void 0,void 0,(function*(){for(;"running"===this._status&&!t.aborted;){const n=e-Date.now();if(n<=0)return void this.setStatus("error");if(yield A(Math.min(15e3,n),t),t.aborted)return;yield this.refetchAndSync()}}))}setStatus(t){if(this._status!==t){this._status=t;for(const e of this.listeners)e(t)}}refetchAndSync(){return p(this,void 0,void 0,(function*(){let t;try{t=yield this.client.getRun({agentId:this.agentId,runId:this.id})}catch(t){if(t instanceof r.v3||t instanceof r.j1)throw"running"===this._status&&this.setStatus("error"),t;return}const e=d(t);void 0!==e.result&&(this._result=e.result),void 0!==e.durationMs&&(this._durationMs=e.durationMs),void 0!==e.git&&(this._git=e.git),"running"===this._status&&this.setStatus(w(t.status))}))}buildResult(){const t="running"===this._status?"error":this._status;return Object.assign(Object.assign(Object.assign({id:this.id,status:t},void 0!==this._result?{result:this._result}:{}),void 0!==this._durationMs?{durationMs:this._durationMs}:{}),void 0!==this._git?{git:this._git}:{})}}class O{constructor(t,e,n,i){this.client=e,this.options=n,this.agentId=t,this.serverCreated=i}send(t,e){return p(this,void 0,void 0,(function*(){var n,i,o,a,u,d,c,l,v,f,g,p,m,y,w,b;const _=function(t){var e;return"string"==typeof t?{text:t}:{text:t.text,images:null===(e=t.images)||void 0===e?void 0:e.map((t=>"url"in t?{url:t.url,dimension:t.dimension}:{data:t.data,mimeType:t.mimeType,dimension:t.dimension}))}}(t);if(void 0!==(null==e?void 0:e.model))throw new Error("Cloud send model overrides are not supported in v1");const S=!this.serverCreated,I=void 0!==(null==e?void 0:e.onStep)||void 0!==(null==e?void 0:e.onDelta)?Object.assign(Object.assign({},void 0!==e.onStep?{onStep:e.onStep}:{}),void 0!==e.onDelta?{onDelta:e.onDelta}:{}):void 0;let A;if(S){const t=function(t){if(void 0===t)return;const e=Object.entries(t);if(0===e.length)return;const n=[];for(const[t,i]of e){if(void 0!==i.mcpServers)for(const e of i.mcpServers)if("string"!=typeof e)throw new r.j1(`Custom subagent "${t}" has an inline McpServerConfig in mcpServers; cloud custom subagents only support string references in v1.`);const e=void 0===i.model||"inherit"===i.model?"inherit":i.model.id;n.push({name:t,description:i.description,prompt:i.prompt,model:e})}return n}(this.options.agents),e=yield this.client.createAgent(Object.assign(Object.assign(Object.assign(Object.assign({agentId:this.agentId,prompt:_,model:this.options.model},void 0!==this.options.name?{name:this.options.name}:{}),{mcpServers:h(this.options.mcpServers)}),void 0!==t?{customSubagents:t}:{}),{env:null===(n=this.options.cloud)||void 0===n?void 0:n.env,repos:null===(i=this.options.cloud)||void 0===i?void 0:i.repos,workOnCurrentBranch:null===(o=this.options.cloud)||void 0===o?void 0:o.workOnCurrentBranch,autoCreatePR:null===(a=this.options.cloud)||void 0===a?void 0:a.autoCreatePR,skipReviewerRequest:null===(u=this.options.cloud)||void 0===u?void 0:u.skipReviewerRequest}));if(e.agent.id!==this.agentId)throw new Error(`Server returned mismatched agent id "${e.agent.id}"; expected "${this.agentId}". This indicates a backend bug.`);this.serverCreated=!0,A=new E(this.client,e.run,I)}else{const t=yield this.client.createRun(this.agentId,{prompt:_});A=new E(this.client,t.run,I)}const O=null!==(l=null===(c=null===(d=this.options.cloud)||void 0===d?void 0:d.env)||void 0===c?void 0:c.type)&&void 0!==l?l:"cloud";(0,s.Zn)(this.options.apiKey,{agent_id:this.agentId,run_id:A.id,runtime:O,model:null!==(f=null===(v=this.options.model)||void 0===v?void 0:v.id)&&void 0!==f?f:"default",prompt_length:_.text.length,has_images:(null!==(p=null===(g=_.images)||void 0===g?void 0:g.length)&&void 0!==p?p:0)>0,is_resume:!S||void 0!==this.options.resume,mcp_server_count:Object.keys(null!==(m=this.options.mcpServers)&&void 0!==m?m:{}).length,cloud_repo_count:null===(w=null===(y=this.options.cloud)||void 0===y?void 0:y.repos)||void 0===w?void 0:w.length,cloud_auto_create_pr:null===(b=this.options.cloud)||void 0===b?void 0:b.autoCreatePR});const R=this.options.apiKey,C=this.agentId,$=A.id;return A.wait().then((t=>{(0,s.G5)(R,{agent_id:C,run_id:$,runtime:O,end_reason:"finished"===t.status?"success":"cancelled"===t.status?"abort":"error"})})),A.ensureStreamStarted(),A}))}close(){(0,s.rd)()}reload(){return p(this,void 0,void 0,(function*(){}))}[Symbol.asyncDispose](){return p(this,void 0,void 0,(function*(){yield(0,s.rd)()}))}listArtifacts(){return p(this,void 0,void 0,(function*(){return this.serverCreated?(yield this.client.listArtifacts(this.agentId)).items.map((t=>({path:t.path,sizeBytes:t.sizeBytes,updatedAt:t.updatedAt}))):[]}))}downloadArtifact(t){return p(this,void 0,void 0,(function*(){if(!this.serverCreated)throw new Error("Agent has not been created yet; call send() first.");const{url:e}=yield this.client.getArtifactDownloadUrl({agentId:this.agentId,path:t}),n=yield fetch(e);if(!n.ok)throw new Error(`Failed to download artifact: ${n.status}`);return Buffer.from(yield n.arrayBuffer())}))}}function R(t){var e;const n=y(t.apiKey),s=new c(n),r=null!==(e=t.agentId)&&void 0!==e?e:(0,i.M2)();return new O(r,s,t,!1)}function C(t,e){const n=y(e.apiKey),i=new c(n);return new O(t,i,Object.assign({},e),!0)}function $(t){return p(this,void 0,void 0,(function*(){const e=y(t.apiKey),n=new c(e),i=yield n.listAgents({limit:t.limit,cursor:t.cursor,prUrl:t.prUrl,includeArchived:t.includeArchived});return{items:i.items.map(k),nextCursor:i.nextCursor}}))}function j(t,e){return p(this,void 0,void 0,(function*(){const n=y(e.apiKey),i=new c(n),s=yield i.listRuns(t,{limit:e.limit,cursor:e.cursor});return{items:s.items.map((t=>new E(i,t))),nextCursor:s.nextCursor}}))}function x(t,e){return p(this,void 0,void 0,(function*(){const n=y(e.apiKey),i=new c(n),s=yield i.getRun({agentId:e.agentId,runId:t});return new E(i,s)}))}function k(t){var e,n,i;return{agentId:t.id,name:null!==(e=t.name)&&void 0!==e?e:"",summary:null!==(n=t.name)&&void 0!==n?n:"",lastModified:new Date(t.updatedAt).getTime(),createdAt:new Date(t.createdAt).getTime(),archived:"ARCHIVED"===t.status,runtime:"cloud",env:t.env,repos:null===(i=t.repos)||void 0===i?void 0:i.map((t=>t.url))}}function M(t,e){return p(this,void 0,void 0,(function*(){const n=y(e.apiKey),i=new c(n);return k(yield i.getAgent(t))}))}function U(t,e){return p(this,void 0,void 0,(function*(){const n=y(e.apiKey),i=new c(n);yield i.archiveAgent(t)}))}function T(t,e){return p(this,void 0,void 0,(function*(){const n=y(e.apiKey),i=new c(n);yield i.unarchiveAgent(t)}))}function D(t,e){return p(this,void 0,void 0,(function*(){const n=y(e.apiKey),i=new c(n);yield i.deleteAgent(t)}))}function q(t){return p(this,void 0,void 0,(function*(){const e=y(t.apiKey);return new c(e).getMe()}))}function P(t){return p(this,void 0,void 0,(function*(){const e=y(t.apiKey),n=new c(e);return(yield n.listModels()).items}))}function K(t){return p(this,void 0,void 0,(function*(){const e=y(t.apiKey),n=new c(e);return(yield n.listRepositories()).items}))}}};
|