@ai-sdk/harness-deepagents 1.0.69 → 1.0.71
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/CHANGELOG.md +14 -0
- package/dist/bridge/index.mjs +835 -28
- package/dist/bridge/index.mjs.map +1 -1
- package/dist/index.d.ts +27 -2
- package/dist/index.js +50 -5
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/src/bridge/create-emit-stream-event.ts +11 -1
- package/src/bridge/index.ts +66 -5
- package/src/deepagents-auth.ts +44 -7
- package/src/deepagents-bridge-protocol.ts +15 -0
- package/src/deepagents-harness.ts +34 -0
- package/src/index.ts +8 -2
package/src/deepagents-auth.ts
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import { getAiGatewayAuthFromEnv } from '@ai-sdk/harness/utils';
|
|
2
2
|
|
|
3
|
-
export type
|
|
3
|
+
export type DeepAgentsAuthenticationMode = 'auto' | 'anthropic' | 'ai-gateway';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* @deprecated Passing an object to auth options is deprecated. Use a `DeepAgentsAuthenticationMode` string value ("auto" | "anthropic" | "ai-gateway") instead, and pass credentials via environment variables.
|
|
7
|
+
*/
|
|
8
|
+
export type LegacyDeepAgentsAuthOptions = {
|
|
4
9
|
readonly anthropic?: {
|
|
5
10
|
readonly apiKey?: string;
|
|
6
11
|
readonly authToken?: string;
|
|
@@ -12,6 +17,10 @@ export type DeepAgentsAuthOptions = {
|
|
|
12
17
|
};
|
|
13
18
|
};
|
|
14
19
|
|
|
20
|
+
export type DeepAgentsAuthOptions =
|
|
21
|
+
| DeepAgentsAuthenticationMode
|
|
22
|
+
| LegacyDeepAgentsAuthOptions;
|
|
23
|
+
|
|
15
24
|
// DeepAgents always drives the Anthropic client. Non-Anthropic models reach it
|
|
16
25
|
// through AI Gateway's Anthropic-compatible endpoint, which translates to any
|
|
17
26
|
// model (Gemini, OpenAI, etc.), tool calls included.
|
|
@@ -22,13 +31,18 @@ export function resolveDeepAgentsEnv({
|
|
|
22
31
|
auth?: DeepAgentsAuthOptions;
|
|
23
32
|
processEnv?: Record<string, string | undefined>;
|
|
24
33
|
}): Record<string, string> {
|
|
25
|
-
|
|
26
|
-
|
|
34
|
+
const normalizedAuth = normalizeDeepAgentsAuthToLegacyAuth(auth);
|
|
35
|
+
|
|
36
|
+
if (normalizedAuth?.anthropic) {
|
|
37
|
+
return pickAnthropic({ explicit: normalizedAuth.anthropic, processEnv });
|
|
27
38
|
}
|
|
28
39
|
|
|
29
40
|
const gatewayAuthFromEnv = getAiGatewayAuthFromEnv({ env: processEnv });
|
|
30
|
-
if (
|
|
31
|
-
return pickGateway({
|
|
41
|
+
if (normalizedAuth?.gateway) {
|
|
42
|
+
return pickGateway({
|
|
43
|
+
explicit: normalizedAuth.gateway,
|
|
44
|
+
gatewayAuthFromEnv,
|
|
45
|
+
});
|
|
32
46
|
}
|
|
33
47
|
if (gatewayAuthFromEnv.apiKey) {
|
|
34
48
|
return pickGateway({ explicit: {}, gatewayAuthFromEnv });
|
|
@@ -37,11 +51,34 @@ export function resolveDeepAgentsEnv({
|
|
|
37
51
|
return pickAnthropic({ processEnv });
|
|
38
52
|
}
|
|
39
53
|
|
|
54
|
+
function normalizeDeepAgentsAuthToLegacyAuth(
|
|
55
|
+
auth: DeepAgentsAuthOptions | undefined,
|
|
56
|
+
): LegacyDeepAgentsAuthOptions | undefined {
|
|
57
|
+
if (auth == null || auth === 'auto') {
|
|
58
|
+
return undefined;
|
|
59
|
+
}
|
|
60
|
+
if (typeof auth === 'string') {
|
|
61
|
+
switch (auth) {
|
|
62
|
+
case 'anthropic':
|
|
63
|
+
return { anthropic: {} };
|
|
64
|
+
case 'ai-gateway':
|
|
65
|
+
return { gateway: {} };
|
|
66
|
+
default:
|
|
67
|
+
return undefined;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
console.warn(
|
|
72
|
+
'[deepagents] Passing an object to auth options is deprecated. Use a string mode ("auto" | "anthropic" | "ai-gateway") instead, and pass credentials via environment variables.',
|
|
73
|
+
);
|
|
74
|
+
return auth;
|
|
75
|
+
}
|
|
76
|
+
|
|
40
77
|
function pickAnthropic({
|
|
41
78
|
explicit,
|
|
42
79
|
processEnv,
|
|
43
80
|
}: {
|
|
44
|
-
explicit?: NonNullable<
|
|
81
|
+
explicit?: NonNullable<LegacyDeepAgentsAuthOptions['anthropic']>;
|
|
45
82
|
processEnv: Record<string, string | undefined>;
|
|
46
83
|
}): Record<string, string> {
|
|
47
84
|
const env: Record<string, string> = {};
|
|
@@ -58,7 +95,7 @@ function pickGateway({
|
|
|
58
95
|
explicit,
|
|
59
96
|
gatewayAuthFromEnv,
|
|
60
97
|
}: {
|
|
61
|
-
explicit: NonNullable<
|
|
98
|
+
explicit: NonNullable<LegacyDeepAgentsAuthOptions['gateway']>;
|
|
62
99
|
gatewayAuthFromEnv: ReturnType<typeof getAiGatewayAuthFromEnv>;
|
|
63
100
|
}): Record<string, string> {
|
|
64
101
|
const apiKey = explicit.apiKey ?? gatewayAuthFromEnv.apiKey;
|
|
@@ -10,6 +10,19 @@ import { z } from 'zod/v4';
|
|
|
10
10
|
export const outboundMessageSchema = harnessV1BridgeOutboundMessageSchema;
|
|
11
11
|
export type OutboundMessage = z.infer<typeof outboundMessageSchema>;
|
|
12
12
|
|
|
13
|
+
const thinkingSchema = z.discriminatedUnion('type', [
|
|
14
|
+
z.object({
|
|
15
|
+
type: z.literal('adaptive'),
|
|
16
|
+
display: z.enum(['summarized', 'omitted']).optional(),
|
|
17
|
+
}),
|
|
18
|
+
z.object({
|
|
19
|
+
type: z.literal('enabled'),
|
|
20
|
+
budget_tokens: z.number(),
|
|
21
|
+
display: z.enum(['summarized', 'omitted']).optional(),
|
|
22
|
+
}),
|
|
23
|
+
z.object({ type: z.literal('disabled') }),
|
|
24
|
+
]);
|
|
25
|
+
|
|
13
26
|
export const startMessageSchema = harnessV1BridgeStartBaseSchema.extend({
|
|
14
27
|
mcpServers: z.record(z.string(), z.unknown()).optional(),
|
|
15
28
|
/*
|
|
@@ -17,6 +30,8 @@ export const startMessageSchema = harnessV1BridgeStartBaseSchema.extend({
|
|
|
17
30
|
* the session's agent.
|
|
18
31
|
*/
|
|
19
32
|
instructions: z.string().optional(),
|
|
33
|
+
thinking: thinkingSchema.optional(),
|
|
34
|
+
effort: z.enum(['low', 'medium', 'high', 'xhigh', 'max']).optional(),
|
|
20
35
|
// In-backend skills source dirs ($HOME and <workDir>), passed to createDeepAgent({ skills }).
|
|
21
36
|
skillsPaths: z.array(z.string()).optional(),
|
|
22
37
|
// Max LangGraph super-steps per turn (streamEvents recursionLimit).
|
|
@@ -59,6 +59,20 @@ const BOOTSTRAP_DIR = '.harness-bootstrap/deepagents';
|
|
|
59
59
|
*/
|
|
60
60
|
const DEEPAGENTS_CLIENT_APP = `ai-sdk/harness-deepagents/${VERSION}`;
|
|
61
61
|
|
|
62
|
+
export type DeepAgentsThinkingConfig =
|
|
63
|
+
| {
|
|
64
|
+
readonly type: 'adaptive';
|
|
65
|
+
readonly display?: 'summarized' | 'omitted';
|
|
66
|
+
}
|
|
67
|
+
| {
|
|
68
|
+
readonly type: 'enabled';
|
|
69
|
+
readonly budget_tokens: number;
|
|
70
|
+
readonly display?: 'summarized' | 'omitted';
|
|
71
|
+
}
|
|
72
|
+
| {
|
|
73
|
+
readonly type: 'disabled';
|
|
74
|
+
};
|
|
75
|
+
|
|
62
76
|
// Pinned ripgrep release + per-arch tarball checksums (verified before install).
|
|
63
77
|
const RIPGREP_VERSION = '14.1.1';
|
|
64
78
|
const RIPGREP_SHA256_X64 =
|
|
@@ -92,6 +106,16 @@ export type DeepAgentsHarnessSettings = {
|
|
|
92
106
|
readonly auth?: DeepAgentsAuthOptions;
|
|
93
107
|
/** Model id for the DeepAgents runtime, e.g. `claude-sonnet-4` (converted to `provider:model`). */
|
|
94
108
|
readonly model?: string;
|
|
109
|
+
/**
|
|
110
|
+
* Controls Anthropic extended thinking for the Deep Agents model. Unset
|
|
111
|
+
* preserves the Deep Agents runtime default.
|
|
112
|
+
*/
|
|
113
|
+
readonly thinking?: DeepAgentsThinkingConfig;
|
|
114
|
+
/**
|
|
115
|
+
* Controls how much effort Claude applies when adaptive thinking is enabled.
|
|
116
|
+
* Unset uses the LangChain Anthropic client default.
|
|
117
|
+
*/
|
|
118
|
+
readonly effort?: 'low' | 'medium' | 'high' | 'xhigh' | 'max';
|
|
95
119
|
/** Bridge port override; defaults to the sandbox's first declared port. */
|
|
96
120
|
readonly port?: number;
|
|
97
121
|
/** Maximum milliseconds to wait for the bridge to advertise its port. Defaults to 120000. */
|
|
@@ -280,6 +304,8 @@ export function createDeepAgents(
|
|
|
280
304
|
channel: attachChannel,
|
|
281
305
|
proc: undefined,
|
|
282
306
|
model: settings.model,
|
|
307
|
+
thinking: settings.thinking,
|
|
308
|
+
effort: settings.effort,
|
|
283
309
|
bridgePort: coords.port,
|
|
284
310
|
bridgeToken: coords.token,
|
|
285
311
|
sandboxId,
|
|
@@ -397,6 +423,8 @@ export function createDeepAgents(
|
|
|
397
423
|
channel,
|
|
398
424
|
proc,
|
|
399
425
|
model: settings.model,
|
|
426
|
+
thinking: settings.thinking,
|
|
427
|
+
effort: settings.effort,
|
|
400
428
|
bridgePort: boundPort,
|
|
401
429
|
bridgeToken: token,
|
|
402
430
|
sandboxId,
|
|
@@ -496,6 +524,8 @@ function createSession({
|
|
|
496
524
|
channel,
|
|
497
525
|
proc,
|
|
498
526
|
model,
|
|
527
|
+
thinking,
|
|
528
|
+
effort,
|
|
499
529
|
bridgePort,
|
|
500
530
|
bridgeToken,
|
|
501
531
|
sandboxId,
|
|
@@ -512,6 +542,8 @@ function createSession({
|
|
|
512
542
|
// Undefined on attach — the live bridge was spawned by another process.
|
|
513
543
|
proc: Experimental_SandboxProcess | undefined;
|
|
514
544
|
model: string | undefined;
|
|
545
|
+
thinking: DeepAgentsThinkingConfig | undefined;
|
|
546
|
+
effort: 'low' | 'medium' | 'high' | 'xhigh' | 'max' | undefined;
|
|
515
547
|
bridgePort: number;
|
|
516
548
|
bridgeToken: string;
|
|
517
549
|
sandboxId: string;
|
|
@@ -678,6 +710,8 @@ function createSession({
|
|
|
678
710
|
inputSchema: t.inputSchema,
|
|
679
711
|
})),
|
|
680
712
|
...(model ? { model } : {}),
|
|
713
|
+
...(thinking ? { thinking } : {}),
|
|
714
|
+
...(effort ? { effort } : {}),
|
|
681
715
|
...(skillsPaths?.length ? { skillsPaths } : {}),
|
|
682
716
|
...(permissionMode ? { permissionMode } : {}),
|
|
683
717
|
...(builtinToolFiltering ? { builtinToolFiltering } : {}),
|
package/src/index.ts
CHANGED
|
@@ -5,5 +5,11 @@ export const deepAgents = createDeepAgents();
|
|
|
5
5
|
|
|
6
6
|
export { createDeepAgents } from './deepagents-harness';
|
|
7
7
|
export { VERSION } from './version';
|
|
8
|
-
export type {
|
|
9
|
-
|
|
8
|
+
export type {
|
|
9
|
+
DeepAgentsHarnessSettings,
|
|
10
|
+
DeepAgentsThinkingConfig,
|
|
11
|
+
} from './deepagents-harness';
|
|
12
|
+
export type {
|
|
13
|
+
DeepAgentsAuthenticationMode,
|
|
14
|
+
DeepAgentsAuthOptions,
|
|
15
|
+
} from './deepagents-auth';
|