@namzu/sdk 48.0.0 → 48.1.0
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 +26 -0
- package/dist/connector/mcp/adapter.d.ts.map +1 -1
- package/dist/connector/mcp/adapter.js +11 -0
- package/dist/connector/mcp/adapter.js.map +1 -1
- package/dist/connector/mcp/client.d.ts +19 -0
- package/dist/connector/mcp/client.d.ts.map +1 -1
- package/dist/connector/mcp/client.js +363 -2
- package/dist/connector/mcp/client.js.map +1 -1
- package/dist/connector/mcp/era.d.ts.map +1 -1
- package/dist/connector/mcp/era.js +7 -0
- package/dist/connector/mcp/era.js.map +1 -1
- package/dist/connector/mcp/streamable-http.d.ts +15 -0
- package/dist/connector/mcp/streamable-http.d.ts.map +1 -1
- package/dist/connector/mcp/streamable-http.js +281 -6
- package/dist/connector/mcp/streamable-http.js.map +1 -1
- package/dist/manager/agent/lifecycle.d.ts +1 -0
- package/dist/manager/agent/lifecycle.d.ts.map +1 -1
- package/dist/manager/agent/lifecycle.js +137 -18
- package/dist/manager/agent/lifecycle.js.map +1 -1
- package/dist/manager/resident/initiative.d.ts +6 -6
- package/dist/manager/resident/outbox.d.ts +4 -4
- package/dist/scheduler/local.d.ts.map +1 -1
- package/dist/scheduler/local.js +2 -0
- package/dist/scheduler/local.js.map +1 -1
- package/dist/session/retention/archive.js +1 -1
- package/dist/session/retention/archive.js.map +1 -1
- package/dist/store/session/disk.d.ts.map +1 -1
- package/dist/store/session/disk.js +2 -0
- package/dist/store/session/disk.js.map +1 -1
- package/dist/tools/builtins/browser.js +2 -2
- package/dist/tools/builtins/browser.js.map +1 -1
- package/dist/types/agent/scheduler.d.ts +6 -1
- package/dist/types/agent/scheduler.d.ts.map +1 -1
- package/dist/types/agent/task.d.ts +19 -1
- package/dist/types/agent/task.d.ts.map +1 -1
- package/dist/types/agent/task.js.map +1 -1
- package/dist/types/connector/mcp.d.ts +13 -0
- package/dist/types/connector/mcp.d.ts.map +1 -1
- package/dist/types/session/sub-session.d.ts +2 -0
- package/dist/types/session/sub-session.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/connector/mcp/adapter.ts +15 -0
- package/src/connector/mcp/client.ts +405 -2
- package/src/connector/mcp/era.ts +7 -0
- package/src/connector/mcp/streamable-http.ts +302 -5
- package/src/manager/agent/lifecycle.ts +158 -19
- package/src/scheduler/local.ts +2 -0
- package/src/session/retention/archive.ts +1 -1
- package/src/store/session/disk.ts +3 -0
- package/src/tools/builtins/browser.ts +2 -2
- package/src/types/agent/scheduler.ts +6 -1
- package/src/types/agent/task.ts +21 -1
- package/src/types/connector/mcp.ts +14 -0
- package/src/types/session/sub-session.ts +2 -0
|
@@ -223,7 +223,7 @@ export class ArchivalManager {
|
|
|
223
223
|
|
|
224
224
|
// 6. Dispose the workspace (idempotent — driver contract tolerates
|
|
225
225
|
// already-disposed refs; a missing ref is a no-op).
|
|
226
|
-
if (workspace) {
|
|
226
|
+
if (workspace && sub.workspaceRetention !== 'retain') {
|
|
227
227
|
try {
|
|
228
228
|
const driver = this.deps.workspaceRegistry.get(workspace.meta.backend)
|
|
229
229
|
await driver.dispose(workspace)
|
|
@@ -226,6 +226,7 @@ interface PersistedSubSession {
|
|
|
226
226
|
failureMode: SubSession['failureMode']
|
|
227
227
|
completionMode: SubSession['completionMode']
|
|
228
228
|
workspaceId: SubSession['workspaceId']
|
|
229
|
+
workspaceRetention?: SubSession['workspaceRetention']
|
|
229
230
|
broadcastGroupId?: string
|
|
230
231
|
summaryRef?: SubSession['summaryRef']
|
|
231
232
|
archiveRef?: SubSession['archiveRef']
|
|
@@ -1126,6 +1127,7 @@ function serializeSubSession(s: SubSession, tenantId: TenantId): PersistedSubSes
|
|
|
1126
1127
|
failureMode: s.failureMode,
|
|
1127
1128
|
completionMode: s.completionMode,
|
|
1128
1129
|
workspaceId: s.workspaceId,
|
|
1130
|
+
...(s.workspaceRetention !== undefined && { workspaceRetention: s.workspaceRetention }),
|
|
1129
1131
|
...(s.broadcastGroupId !== undefined && { broadcastGroupId: s.broadcastGroupId }),
|
|
1130
1132
|
...(s.summaryRef !== undefined && { summaryRef: s.summaryRef }),
|
|
1131
1133
|
...(s.archiveRef !== undefined && { archiveRef: s.archiveRef }),
|
|
@@ -1146,6 +1148,7 @@ function deserializeSubSession(s: PersistedSubSession): SubSession {
|
|
|
1146
1148
|
failureMode: s.failureMode,
|
|
1147
1149
|
completionMode: s.completionMode,
|
|
1148
1150
|
workspaceId: s.workspaceId,
|
|
1151
|
+
...(s.workspaceRetention !== undefined && { workspaceRetention: s.workspaceRetention }),
|
|
1149
1152
|
...(s.broadcastGroupId !== undefined && { broadcastGroupId: s.broadcastGroupId }),
|
|
1150
1153
|
...(s.summaryRef !== undefined && { summaryRef: s.summaryRef }),
|
|
1151
1154
|
...(s.archiveRef !== undefined && { archiveRef: s.archiveRef }),
|
|
@@ -508,7 +508,7 @@ const HUMAN_REASON_WORDS: Record<BrowserHumanRequired['reason'], string> = {
|
|
|
508
508
|
'two-factor': 'a second sign-in step',
|
|
509
509
|
captcha: 'a CAPTCHA',
|
|
510
510
|
'bot-block': 'a bot check',
|
|
511
|
-
'http-auth': '
|
|
511
|
+
'http-auth': 'an HTTP authentication challenge',
|
|
512
512
|
'credential-field': 'a password or one-time-code field',
|
|
513
513
|
}
|
|
514
514
|
|
|
@@ -527,7 +527,7 @@ function hostErrorToResult(tool: string, error: BrowserHostError): ToolResult {
|
|
|
527
527
|
case 'browser_human_required': {
|
|
528
528
|
const what = HUMAN_REASON_WORDS[error.reason] ?? 'something only a person can do'
|
|
529
529
|
const how = error.loginCommand
|
|
530
|
-
? ` The user can sign in with: ${oneLine(error.loginCommand, 300)}`
|
|
530
|
+
? ` The user can ${error.reason === 'http-auth' ? 'check access' : 'sign in'} with: ${oneLine(error.loginCommand, 300)}`
|
|
531
531
|
: ''
|
|
532
532
|
const detail = {
|
|
533
533
|
origin: error.origin,
|
|
@@ -3,8 +3,9 @@ import type { TaskId } from '../ids/index.js'
|
|
|
3
3
|
import type { AgentPersona } from '../persona/index.js'
|
|
4
4
|
import type { CancelCause } from '../session/cancel-cause.js'
|
|
5
5
|
import type { ChildSessionLifecycleEvent, SessionEventListener } from '../session/events.js'
|
|
6
|
+
import type { WorkspaceRef } from '../workspace/ref.js'
|
|
6
7
|
import type { AgentRuntimeContext, BaseAgentConfig, BaseAgentResult } from './base.js'
|
|
7
|
-
import type { AgentTaskState } from './task.js'
|
|
8
|
+
import type { AgentTaskState, ChildWorkspaceRequest } from './task.js'
|
|
8
9
|
|
|
9
10
|
export interface TaskHandle {
|
|
10
11
|
readonly taskId: TaskId
|
|
@@ -13,6 +14,8 @@ export interface TaskHandle {
|
|
|
13
14
|
readonly result?: BaseAgentResult
|
|
14
15
|
readonly createdAt: number
|
|
15
16
|
readonly completedAt?: number
|
|
17
|
+
/** The workspace assigned to an explicitly isolated child, when admitted. */
|
|
18
|
+
readonly workspace?: WorkspaceRef
|
|
16
19
|
}
|
|
17
20
|
|
|
18
21
|
/**
|
|
@@ -29,6 +32,8 @@ export interface TaskHandle {
|
|
|
29
32
|
export type SiblingFailurePolicy = 'continue' | 'cancel-siblings'
|
|
30
33
|
|
|
31
34
|
export interface CreateTaskOptions {
|
|
35
|
+
/** Per-task filesystem choice, forwarded to the local manager at admission. */
|
|
36
|
+
readonly workspace?: ChildWorkspaceRequest
|
|
32
37
|
/**
|
|
33
38
|
* Revalidate host authority at actual admission, including after a capacity wait.
|
|
34
39
|
* Queue retries may invoke this more than once; checks must tolerate repeated calls.
|
package/src/types/agent/task.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { SessionTokenBudget } from '../../store/budget/index.js'
|
|
2
2
|
import type { ActorRef } from '../../types/session/actor.js'
|
|
3
|
-
import type { WorkspaceBackendKind } from '../../types/workspace/ref.js'
|
|
3
|
+
import type { WorkspaceBackendKind, WorkspaceRef } from '../../types/workspace/ref.js'
|
|
4
4
|
import type { ResumeHandler } from '../hitl/index.js'
|
|
5
5
|
import type { SessionId, TaskId, TenantId, TurnId } from '../ids/index.js'
|
|
6
6
|
import type { Message } from '../message/index.js'
|
|
@@ -19,6 +19,19 @@ export type AgentTaskState =
|
|
|
19
19
|
| 'rejected'
|
|
20
20
|
| 'input-required'
|
|
21
21
|
|
|
22
|
+
/** Per-spawn filesystem choice. Omission preserves the manager's existing behavior. */
|
|
23
|
+
export type ChildWorkspaceRequest =
|
|
24
|
+
| { readonly mode: 'shared' }
|
|
25
|
+
| {
|
|
26
|
+
readonly mode: 'isolated'
|
|
27
|
+
readonly backend: 'git-worktree'
|
|
28
|
+
readonly baseRef?: string
|
|
29
|
+
/** Relative directory within the checkout where this child starts. */
|
|
30
|
+
readonly subdirectory?: string
|
|
31
|
+
/** The existing SDK behavior is `dispose`; CLI delegates select `retain`. */
|
|
32
|
+
readonly retention?: 'dispose' | 'retain'
|
|
33
|
+
}
|
|
34
|
+
|
|
22
35
|
export function isTerminalAgentTaskState(state: AgentTaskState): boolean {
|
|
23
36
|
return state === 'completed' || state === 'failed' || state === 'canceled' || state === 'rejected'
|
|
24
37
|
}
|
|
@@ -206,6 +219,8 @@ export interface AgentTask {
|
|
|
206
219
|
pendingMessages: Message[]
|
|
207
220
|
createdAt: number
|
|
208
221
|
completedAt?: number
|
|
222
|
+
/** Populated after an explicitly isolated spawn is admitted. */
|
|
223
|
+
workspace?: WorkspaceRef
|
|
209
224
|
|
|
210
225
|
evictAfter?: number
|
|
211
226
|
|
|
@@ -219,6 +234,8 @@ export interface AgentTask {
|
|
|
219
234
|
* WorkspaceRef triple atomically on every spawn.
|
|
220
235
|
*/
|
|
221
236
|
export interface SendMessageOptions {
|
|
237
|
+
/** Explicit child filesystem policy; omitted preserves legacy backend behavior. */
|
|
238
|
+
readonly workspace?: ChildWorkspaceRequest
|
|
222
239
|
/**
|
|
223
240
|
* Revalidate host authority before admission, including after a capacity wait.
|
|
224
241
|
* Queue retries may invoke this more than once; checks must tolerate repeated calls.
|
|
@@ -287,6 +304,9 @@ export interface SendMessageOptions {
|
|
|
287
304
|
}
|
|
288
305
|
|
|
289
306
|
export interface AgentManagerConfig {
|
|
307
|
+
/** When neither task workspace field is set, use the registered backend (legacy) or share cwd. */
|
|
308
|
+
workspaceDefault?: 'registered' | 'shared'
|
|
309
|
+
|
|
290
310
|
/** Reject a full parent immediately (default), or retain bounded pending task handles. */
|
|
291
311
|
capacityBehavior?: 'reject' | 'queue'
|
|
292
312
|
|
|
@@ -178,6 +178,14 @@ export interface MCPJsonRpcMessage {
|
|
|
178
178
|
error?: MCPJsonRpcError
|
|
179
179
|
}
|
|
180
180
|
|
|
181
|
+
/** A validated, bounded update from one MCP tool call. */
|
|
182
|
+
export interface MCPProgressUpdate {
|
|
183
|
+
readonly progress: number
|
|
184
|
+
readonly total?: number
|
|
185
|
+
/** Server text with terminal controls removed, limited to 512 UTF-8 bytes. */
|
|
186
|
+
readonly message?: string
|
|
187
|
+
}
|
|
188
|
+
|
|
181
189
|
/** Authority for one MCP JSON-RPC request. */
|
|
182
190
|
export interface MCPRequestOptions {
|
|
183
191
|
/**
|
|
@@ -187,6 +195,12 @@ export interface MCPRequestOptions {
|
|
|
187
195
|
* waiting, not that an already-started remote side effect was rolled back.
|
|
188
196
|
*/
|
|
189
197
|
readonly signal?: AbortSignal
|
|
198
|
+
/**
|
|
199
|
+
* Receive progress for this `tools/call` only. The client adds a unique
|
|
200
|
+
* `_meta.progressToken` when this is supplied and stops delivery as soon as
|
|
201
|
+
* the request completes, fails or is cancelled. Other methods ignore it.
|
|
202
|
+
*/
|
|
203
|
+
readonly onProgress?: (update: MCPProgressUpdate) => void
|
|
190
204
|
/**
|
|
191
205
|
* Extra headers for this one request, merged over the transport's static
|
|
192
206
|
* config headers (a collision resolves to this value) and under this same
|
|
@@ -100,6 +100,8 @@ export interface SubSession {
|
|
|
100
100
|
failureMode: FailureMode
|
|
101
101
|
completionMode: CompletionMode
|
|
102
102
|
workspaceId: WorkspaceId | null
|
|
103
|
+
/** Keep this delegated workspace when the child ends or its session is archived. */
|
|
104
|
+
workspaceRetention?: 'retain'
|
|
103
105
|
/**
|
|
104
106
|
* For interventions, the immutable artifact being addressed. Chains form
|
|
105
107
|
* a strict acyclic DAG — see session-hierarchy.md §4.5.
|