@librechat/agents 4.2.9 → 4.2.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/agents/AgentContext.cjs +32 -2
- package/dist/cjs/agents/AgentContext.cjs.map +1 -1
- package/dist/cjs/harness/fileBindings.cjs +93 -0
- package/dist/cjs/harness/fileBindings.cjs.map +1 -0
- package/dist/cjs/harness/fileService.cjs +141 -0
- package/dist/cjs/harness/fileService.cjs.map +1 -0
- package/dist/cjs/harness/fileStream.cjs +76 -0
- package/dist/cjs/harness/fileStream.cjs.map +1 -0
- package/dist/cjs/harness/files.cjs +106 -0
- package/dist/cjs/harness/files.cjs.map +1 -0
- package/dist/cjs/harness/index.cjs +3 -0
- package/dist/cjs/harness/index.cjs.map +1 -1
- package/dist/cjs/llm/google/utils/signatures.cjs +5 -3
- package/dist/cjs/llm/google/utils/signatures.cjs.map +1 -1
- package/dist/cjs/main.cjs +13 -0
- package/dist/cjs/tools/BashProgrammaticToolCalling.cjs +3 -2
- package/dist/cjs/tools/BashProgrammaticToolCalling.cjs.map +1 -1
- package/dist/cjs/tools/ProgrammaticCallerPolicy.cjs +24 -1
- package/dist/cjs/tools/ProgrammaticCallerPolicy.cjs.map +1 -1
- package/dist/cjs/tools/ProgrammaticToolCalling.cjs +3 -2
- package/dist/cjs/tools/ProgrammaticToolCalling.cjs.map +1 -1
- package/dist/cjs/tools/local/LocalProgrammaticToolCalling.cjs +2 -1
- package/dist/cjs/tools/local/LocalProgrammaticToolCalling.cjs.map +1 -1
- package/dist/cjs/tools/subagent/SubagentExecutor.cjs +15 -3
- package/dist/cjs/tools/subagent/SubagentExecutor.cjs.map +1 -1
- package/dist/cjs/tools/subagent/childGraphConfig.cjs +13 -1
- package/dist/cjs/tools/subagent/childGraphConfig.cjs.map +1 -1
- package/dist/cjs/tools/subagent/hostArgs.cjs +2 -0
- package/dist/cjs/tools/subagent/hostArgs.cjs.map +1 -1
- package/dist/esm/agents/AgentContext.mjs +32 -2
- package/dist/esm/agents/AgentContext.mjs.map +1 -1
- package/dist/esm/harness/fileBindings.mjs +93 -0
- package/dist/esm/harness/fileBindings.mjs.map +1 -0
- package/dist/esm/harness/fileService.mjs +140 -0
- package/dist/esm/harness/fileService.mjs.map +1 -0
- package/dist/esm/harness/fileStream.mjs +76 -0
- package/dist/esm/harness/fileStream.mjs.map +1 -0
- package/dist/esm/harness/files.mjs +97 -0
- package/dist/esm/harness/files.mjs.map +1 -0
- package/dist/esm/harness/index.mjs +3 -0
- package/dist/esm/harness/index.mjs.map +1 -1
- package/dist/esm/llm/google/utils/signatures.mjs +5 -3
- package/dist/esm/llm/google/utils/signatures.mjs.map +1 -1
- package/dist/esm/main.mjs +5 -2
- package/dist/esm/tools/BashProgrammaticToolCalling.mjs +3 -2
- package/dist/esm/tools/BashProgrammaticToolCalling.mjs.map +1 -1
- package/dist/esm/tools/ProgrammaticCallerPolicy.mjs +24 -1
- package/dist/esm/tools/ProgrammaticCallerPolicy.mjs.map +1 -1
- package/dist/esm/tools/ProgrammaticToolCalling.mjs +3 -2
- package/dist/esm/tools/ProgrammaticToolCalling.mjs.map +1 -1
- package/dist/esm/tools/local/LocalProgrammaticToolCalling.mjs +2 -1
- package/dist/esm/tools/local/LocalProgrammaticToolCalling.mjs.map +1 -1
- package/dist/esm/tools/subagent/SubagentExecutor.mjs +15 -3
- package/dist/esm/tools/subagent/SubagentExecutor.mjs.map +1 -1
- package/dist/esm/tools/subagent/childGraphConfig.mjs +13 -1
- package/dist/esm/tools/subagent/childGraphConfig.mjs.map +1 -1
- package/dist/esm/tools/subagent/hostArgs.mjs +2 -1
- package/dist/esm/tools/subagent/hostArgs.mjs.map +1 -1
- package/dist/types/harness/fileBindings.d.ts +13 -0
- package/dist/types/harness/fileService.d.ts +37 -0
- package/dist/types/harness/fileStream.d.ts +7 -0
- package/dist/types/harness/files.d.ts +108 -0
- package/dist/types/harness/index.d.ts +6 -0
- package/dist/types/tools/ProgrammaticCallerPolicy.d.ts +1 -0
- package/dist/types/tools/subagent/hostArgs.d.ts +6 -0
- package/dist/types/tools/subagent/index.d.ts +1 -1
- package/dist/types/types/graph.d.ts +6 -3
- package/package.json +1 -1
- package/src/agents/AgentContext.ts +68 -2
- package/src/harness/fileBindings.ts +156 -0
- package/src/harness/fileService.ts +217 -0
- package/src/harness/fileStream.ts +99 -0
- package/src/harness/files.ts +185 -0
- package/src/harness/index.ts +24 -0
- package/src/llm/google/utils/signatures.ts +10 -3
- package/src/tools/BashProgrammaticToolCalling.ts +5 -2
- package/src/tools/ProgrammaticCallerPolicy.ts +42 -3
- package/src/tools/ProgrammaticToolCalling.ts +4 -1
- package/src/tools/local/LocalProgrammaticToolCalling.ts +4 -0
- package/src/tools/subagent/SubagentExecutor.ts +98 -32
- package/src/tools/subagent/childGraphConfig.ts +33 -1
- package/src/tools/subagent/hostArgs.ts +7 -0
- package/src/tools/subagent/index.ts +1 -0
- package/src/types/graph.ts +6 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hostArgs.mjs","names":[],"sources":["../../../../src/tools/subagent/hostArgs.ts"],"mappings":";;
|
|
1
|
+
{"version":3,"file":"hostArgs.mjs","names":[],"sources":["../../../../src/tools/subagent/hostArgs.ts"],"mappings":";;AAaA,MAAa,oCAAoC;AAGjD,MAAa,2BAA2B,OAAO,OAAO;CACpD,iBAAiB;CACjB,cAAc;CACd,YAAY;CACZ,kBAAkB;CAClB,aAAa;CACb,mBAAmB;AACrB,CAAC;AAED,MAAM,wBAAwB;AAE9B,MAAM,2BAA2B;AACjC,MAAM,0BAA+C,IAAI,IAAI;CAC3D;CACA;CACA;CACA;CACA;AACF,CAAC;AAuBD,SAAgB,sBAAsB,MAAuB;CAC3D,OAAO,sBAAsB,KAAK,IAAI,KAAK,CAAC,wBAAwB,IAAI,IAAI;AAC9E;AAGA,SAAS,gBAAgB,OAAuB;CAC9C,IAAI,QAAQ;CACZ,KAAK,MAAM,KAAK,OACd,SAAS;CA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BACd,QACA,UACwB;CACxB,IAAI,YAAY,MACd,OAAO,EAAE,IAAI,KAAK;CAEpB,MAAM,QAAQ,OAAO,KAAK,QAAQ,CAAC,CAAC,KAAK;CACzC,IAAI,MAAM,WAAW,GACnB,OAAO,EAAE,IAAI,KAAK;CAEpB,MAAM,QAAQ,IAAI,IAAI,wBAAwB,MAAM,CAAC;CACrD,MAAM,WAAmC,CAAC;CAC1C,KAAK,MAAM,QAAQ,OAAO;EACxB,MAAM,OAAO,MAAM,IAAI,IAAI;EAC3B,IAAI,QAAQ,MACV,OAAO;GACL,IAAI;GACJ,SAAS,sBAAsB,IAAI,IAC/B,oBAAoB,OAAO,KAAK,qBAAqB,KAAK,sCAC1D,oBAAoB,OAAO,KAAK;EACtC;EAEF,MAAM,QAAQ,SAAS;EACvB,IAAI,OAAO,UAAU,UACnB,OAAO;GAAE,IAAI;GAAO,SAAS,WAAW,KAAK;EAAqB;EAEpE,MAAM,QAAQ,WAAW,OAAO,MAAM,MAAM,MAAM,KAAK;EACvD,IAAI,SAAS,MACX,OAAO;GAAE,IAAI;GAAO,SAAS;EAAM;EAErC,SAAS,QAAQ;CACnB;CACA,OAAO;EAAE,IAAI;EAAM,UAAU,OAAO,OAAO,QAAQ;CAAE;AACvD;AAGA,SAAgB,0BACd,UACoB;CACpB,IAAI,YAAY,MACd;CAEF,MAAM,UAAU,OAAO,QAAQ,QAAQ,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,WACtD,OAAO,QAAQ,KAAK,CACtB;CACA,IAAI,QAAQ,WAAW,GACrB;CAEF,OAAO,WAAW,QAAQ,CAAC,CAAC,OAAO,KAAK,UAAU,OAAO,CAAC,CAAC,CAAC,OAAO,KAAK;AAC1E"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { HostFileDescriptor, HostFileStageRequest, HostFilePublication, HostFileServiceDescriptor, HostFileService } from './files';
|
|
2
|
+
import type { ExecutionIdentity } from './identity';
|
|
3
|
+
export interface HostFileBindings {
|
|
4
|
+
read(file: HostFileDescriptor, signal?: AbortSignal): AsyncIterable<Uint8Array>;
|
|
5
|
+
stage(artifact: Omit<HostFileStageRequest, 'version' | 'identity'>, content: AsyncIterable<Uint8Array>, signal?: AbortSignal): Promise<HostFileDescriptor>;
|
|
6
|
+
publish(file: HostFileDescriptor, operationId: string, signal?: AbortSignal): Promise<HostFilePublication>;
|
|
7
|
+
}
|
|
8
|
+
/** Pull-based graph adapter; at most one range or upload chunk is requested at a time. */
|
|
9
|
+
export declare function createHostFileBindings(options: {
|
|
10
|
+
identity: Readonly<ExecutionIdentity>;
|
|
11
|
+
descriptor: HostFileServiceDescriptor;
|
|
12
|
+
service: HostFileService;
|
|
13
|
+
}): HostFileBindings;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { HostFileService, HostFileServiceDescriptor } from './files';
|
|
2
|
+
import type { ExecutionIdentity } from './identity';
|
|
3
|
+
/** Share across bindings in the host's quota scope. Hung storage retains its slot and byte reservation. */
|
|
4
|
+
export declare class HostFileAdmission {
|
|
5
|
+
private operations;
|
|
6
|
+
private bytes;
|
|
7
|
+
private readonly maxConcurrentOperations;
|
|
8
|
+
private readonly maxBufferedBytes;
|
|
9
|
+
constructor(limits: {
|
|
10
|
+
maxConcurrentOperations: number;
|
|
11
|
+
maxBufferedBytes: number;
|
|
12
|
+
});
|
|
13
|
+
snapshot(): Readonly<{
|
|
14
|
+
operations: number;
|
|
15
|
+
reservedBytes: number;
|
|
16
|
+
}>;
|
|
17
|
+
/** @internal Reservations are released only when storage and input cleanup settle. */
|
|
18
|
+
acquire(bytes: number): () => void;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* The host adapter owns canonical ACL/revision checks on every operation, durable operation-ID
|
|
22
|
+
* reconciliation, private staging/cleanup, and publication through the native file pipeline.
|
|
23
|
+
* A request identity is asserted against the authenticated binding before any adapter call.
|
|
24
|
+
*/
|
|
25
|
+
export type HostFileStore = Omit<HostFileService, 'version'>;
|
|
26
|
+
export declare function createHostFileService(options: {
|
|
27
|
+
identity: Readonly<ExecutionIdentity>;
|
|
28
|
+
descriptor: HostFileServiceDescriptor;
|
|
29
|
+
store: HostFileStore;
|
|
30
|
+
admission: HostFileAdmission;
|
|
31
|
+
timeoutMs: number;
|
|
32
|
+
/** Lifetime of the authenticated execution, independent of individual RPC cancellation. */
|
|
33
|
+
signal?: AbortSignal;
|
|
34
|
+
}): {
|
|
35
|
+
descriptor: HostFileServiceDescriptor;
|
|
36
|
+
service: HostFileService;
|
|
37
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { HostFileStageRequest } from './files';
|
|
2
|
+
/** Single-consumer, bounded upload. Cleanup is owned by the operation, not the transport. */
|
|
3
|
+
export declare function createFileUpload(source: AsyncIterable<Uint8Array>, request: Pick<HostFileStageRequest, 'bytes' | 'sha256'>, maxChunkBytes: number, signal?: AbortSignal, hash?: boolean): {
|
|
4
|
+
content: AsyncIterable<Uint8Array>;
|
|
5
|
+
finish: () => string | undefined;
|
|
6
|
+
close: () => Promise<void>;
|
|
7
|
+
};
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
/** Opaque host references and immutable revisions, never filesystem paths or signed URLs. */
|
|
3
|
+
export declare const hostFileDescriptorSchema: z.ZodObject<{
|
|
4
|
+
reference: z.ZodString;
|
|
5
|
+
revision: z.ZodString;
|
|
6
|
+
filename: z.ZodString;
|
|
7
|
+
mediaType: z.ZodString;
|
|
8
|
+
bytes: z.ZodNumber;
|
|
9
|
+
sha256: z.ZodOptional<z.ZodString>;
|
|
10
|
+
}, z.core.$strip>;
|
|
11
|
+
export type HostFileDescriptor = Readonly<z.infer<typeof hostFileDescriptorSchema>>;
|
|
12
|
+
export declare const hostFileServiceDescriptorSchema: z.ZodObject<{
|
|
13
|
+
version: z.ZodLiteral<1>;
|
|
14
|
+
operations: z.ZodArray<z.ZodEnum<{
|
|
15
|
+
read: "read";
|
|
16
|
+
stage: "stage";
|
|
17
|
+
publish: "publish";
|
|
18
|
+
}>>;
|
|
19
|
+
maxFileBytes: z.ZodNumber;
|
|
20
|
+
maxChunkBytes: z.ZodNumber;
|
|
21
|
+
}, z.core.$strip>;
|
|
22
|
+
export type HostFileServiceDescriptor = Readonly<Omit<z.infer<typeof hostFileServiceDescriptorSchema>, 'operations'>> & {
|
|
23
|
+
readonly operations: readonly ('read' | 'stage' | 'publish')[];
|
|
24
|
+
};
|
|
25
|
+
export declare const hostFileReadRequestSchema: z.ZodObject<{
|
|
26
|
+
version: z.ZodLiteral<1>;
|
|
27
|
+
identity: z.ZodObject<{
|
|
28
|
+
runtimeId: z.ZodString;
|
|
29
|
+
agentId: z.ZodString;
|
|
30
|
+
runId: z.ZodString;
|
|
31
|
+
userId: z.ZodString;
|
|
32
|
+
tenantId: z.ZodOptional<z.ZodString>;
|
|
33
|
+
conversationId: z.ZodOptional<z.ZodString>;
|
|
34
|
+
}, z.core.$strip>;
|
|
35
|
+
reference: z.ZodString;
|
|
36
|
+
revision: z.ZodString;
|
|
37
|
+
offset: z.ZodNumber;
|
|
38
|
+
length: z.ZodNumber;
|
|
39
|
+
}, z.core.$strip>;
|
|
40
|
+
export declare const hostFileStageRequestSchema: z.ZodObject<{
|
|
41
|
+
version: z.ZodLiteral<1>;
|
|
42
|
+
identity: z.ZodObject<{
|
|
43
|
+
runtimeId: z.ZodString;
|
|
44
|
+
agentId: z.ZodString;
|
|
45
|
+
runId: z.ZodString;
|
|
46
|
+
userId: z.ZodString;
|
|
47
|
+
tenantId: z.ZodOptional<z.ZodString>;
|
|
48
|
+
conversationId: z.ZodOptional<z.ZodString>;
|
|
49
|
+
}, z.core.$strip>;
|
|
50
|
+
operationId: z.ZodString;
|
|
51
|
+
filename: z.ZodString;
|
|
52
|
+
mediaType: z.ZodString;
|
|
53
|
+
bytes: z.ZodNumber;
|
|
54
|
+
sha256: z.ZodOptional<z.ZodString>;
|
|
55
|
+
}, z.core.$strip>;
|
|
56
|
+
export declare const hostFilePublishRequestSchema: z.ZodObject<{
|
|
57
|
+
version: z.ZodLiteral<1>;
|
|
58
|
+
identity: z.ZodObject<{
|
|
59
|
+
runtimeId: z.ZodString;
|
|
60
|
+
agentId: z.ZodString;
|
|
61
|
+
runId: z.ZodString;
|
|
62
|
+
userId: z.ZodString;
|
|
63
|
+
tenantId: z.ZodOptional<z.ZodString>;
|
|
64
|
+
conversationId: z.ZodOptional<z.ZodString>;
|
|
65
|
+
}, z.core.$strip>;
|
|
66
|
+
operationId: z.ZodString;
|
|
67
|
+
reference: z.ZodString;
|
|
68
|
+
revision: z.ZodString;
|
|
69
|
+
}, z.core.$strip>;
|
|
70
|
+
export type HostFileReadRequest = Readonly<z.infer<typeof hostFileReadRequestSchema>>;
|
|
71
|
+
export type HostFileStageRequest = Readonly<z.infer<typeof hostFileStageRequestSchema>>;
|
|
72
|
+
export type HostFilePublishRequest = Readonly<z.infer<typeof hostFilePublishRequestSchema>>;
|
|
73
|
+
export interface HostFileChunk {
|
|
74
|
+
readonly reference: string;
|
|
75
|
+
readonly revision: string;
|
|
76
|
+
readonly offset: number;
|
|
77
|
+
readonly data: Uint8Array;
|
|
78
|
+
}
|
|
79
|
+
export interface HostFilePublication {
|
|
80
|
+
readonly operationId: string;
|
|
81
|
+
readonly file: HostFileDescriptor;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Authenticate the transport separately. Each operation must authorize the bound identity,
|
|
85
|
+
* reference and revision against canonical host storage. Staging is private; only publish
|
|
86
|
+
* enters the host's native attachment/event pipeline. Mutations are never automatically retried.
|
|
87
|
+
*/
|
|
88
|
+
export interface HostFileService {
|
|
89
|
+
readonly version: 1;
|
|
90
|
+
read(request: HostFileReadRequest, signal?: AbortSignal): Promise<HostFileChunk>;
|
|
91
|
+
stage(request: HostFileStageRequest, content: AsyncIterable<Uint8Array>, signal?: AbortSignal): Promise<HostFileDescriptor>;
|
|
92
|
+
publish(request: HostFilePublishRequest, signal?: AbortSignal): Promise<HostFilePublication>;
|
|
93
|
+
}
|
|
94
|
+
declare const codes: readonly ["incompatible", "forbidden", "conflict", "overflow", "cancelled", "timeout", "unavailable"];
|
|
95
|
+
export type HostFileErrorCode = (typeof codes)[number];
|
|
96
|
+
export declare class HostFileServiceError extends Error {
|
|
97
|
+
readonly code: HostFileErrorCode;
|
|
98
|
+
constructor(code: HostFileErrorCode);
|
|
99
|
+
}
|
|
100
|
+
/** @internal Never forward adapter error text or abort reasons over the service boundary. */
|
|
101
|
+
export declare function normalizeHostFileError(error: unknown, signal?: AbortSignal): HostFileServiceError;
|
|
102
|
+
/** @internal Snapshot only public metadata, dropping host-specific fields. */
|
|
103
|
+
export declare function checkedHostFile(value: HostFileDescriptor): HostFileDescriptor;
|
|
104
|
+
/** @internal Reject mismatched/stale ranges before bytes enter a graph. */
|
|
105
|
+
export declare function checkedHostFileChunk(value: HostFileChunk, input: HostFileReadRequest): HostFileChunk;
|
|
106
|
+
/** @internal Negotiation validates limits before constructing any graph adapter. */
|
|
107
|
+
export declare function checkedHostFileService(value: HostFileServiceDescriptor): HostFileServiceDescriptor;
|
|
108
|
+
export {};
|
|
@@ -55,3 +55,9 @@ export type { ModelInvocationContext } from '@/llm/invocation';
|
|
|
55
55
|
export type { HostModelDescriptor, HostModelRequest, HostModelService, HostModelToolChoice, HostModelErrorCode, } from './model';
|
|
56
56
|
export { createHostModelService, HostModelAdmission } from './modelService';
|
|
57
57
|
export type { HostModelLimits } from './modelService';
|
|
58
|
+
export { createHostFileService, HostFileAdmission } from './fileService';
|
|
59
|
+
export type { HostFileStore } from './fileService';
|
|
60
|
+
export { createHostFileBindings } from './fileBindings';
|
|
61
|
+
export type { HostFileBindings } from './fileBindings';
|
|
62
|
+
export { HostFileServiceError, hostFileDescriptorSchema, hostFileServiceDescriptorSchema, hostFileReadRequestSchema, hostFileStageRequestSchema, hostFilePublishRequestSchema, } from './files';
|
|
63
|
+
export type { HostFileDescriptor, HostFileServiceDescriptor, HostFileService, HostFileReadRequest, HostFileStageRequest, HostFilePublishRequest, HostFileChunk, HostFilePublication, HostFileErrorCode, } from './files';
|
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
import type { SubagentHostArgs, SubagentHostArgSpec, SubagentHostArgSpecs } from '@/types/graph';
|
|
2
2
|
import type { JsonSchemaType } from '@/types/tools';
|
|
3
|
+
/**
|
|
4
|
+
* Feature probe: `self` subagent configs may declare `hostArgs` together with
|
|
5
|
+
* `resolveAgentInputs` and a `configId`. Calls that pass host arguments are
|
|
6
|
+
* resolved through the resolver; calls that pass none reuse the self inputs.
|
|
7
|
+
*/
|
|
8
|
+
export declare const SELF_SUBAGENT_HOST_ARGS_SUPPORTED = true;
|
|
3
9
|
/** Bounds on host-declared subagent call arguments and their values. */
|
|
4
10
|
export declare const SUBAGENT_HOST_ARG_LIMITS: Readonly<{
|
|
5
11
|
argsPerSubagent: 8;
|
|
@@ -3,5 +3,5 @@ export type { SubagentExecuteParams, SubagentExecuteResult, SubagentExecutorOpti
|
|
|
3
3
|
export { InMemorySubagentTaskStore } from './InMemorySubagentTaskStore';
|
|
4
4
|
export type { InMemorySubagentTaskStoreOptions } from './InMemorySubagentTaskStore';
|
|
5
5
|
export { SubagentResolutionError, SubagentHostArgumentError, getSubagentResolutionFailureMessage, getSubagentHostArgumentFailureMessage, } from './diagnostics';
|
|
6
|
-
export { SUBAGENT_HOST_ARG_LIMITS, buildSubagentHostArgProperties, resolveSubagentHostArgs, } from './hostArgs';
|
|
6
|
+
export { SUBAGENT_HOST_ARG_LIMITS, SELF_SUBAGENT_HOST_ARGS_SUPPORTED, buildSubagentHostArgProperties, resolveSubagentHostArgs, } from './hostArgs';
|
|
7
7
|
export type { SubagentHostArgumentFailure, SubagentHostArgumentRejection, SubagentResolutionPhase, SubagentResolutionCause, SubagentResolutionContext, SubagentResolutionDiagnostic, SubagentResolutionFailureHandler, } from './diagnostics';
|
|
@@ -497,8 +497,10 @@ export interface SubagentConfig extends SubagentConfigBase {
|
|
|
497
497
|
agentInputs?: AgentInputs;
|
|
498
498
|
/**
|
|
499
499
|
* Resolve the full child config only after this descriptor is selected.
|
|
500
|
-
* Eager `agentInputs` take precedence when also supplied. `self`
|
|
501
|
-
* resolver
|
|
500
|
+
* Eager `agentInputs` take precedence when also supplied. A `self` config
|
|
501
|
+
* may set a resolver only together with `hostArgs` and a `configId`; it then
|
|
502
|
+
* runs only for calls that pass host arguments, and every other call reuses
|
|
503
|
+
* the self inputs. Normalization rejects any other `self` + resolver pairing.
|
|
502
504
|
*
|
|
503
505
|
* Resolvers should rebuild inputs from the stable execution context instead
|
|
504
506
|
* of retaining request-owned state. The SDK keeps resolved inputs in memory
|
|
@@ -512,7 +514,8 @@ export interface SubagentConfig extends SubagentConfigBase {
|
|
|
512
514
|
/**
|
|
513
515
|
* Optional per-call arguments the parent model may pass for this subagent,
|
|
514
516
|
* delivered to `resolveAgentInputs` as `context.hostArgs`. Only lazy
|
|
515
|
-
* configs accept them. Declaring none
|
|
517
|
+
* configs and `self` configs with a resolver accept them. Declaring none
|
|
518
|
+
* leaves the tool schema unchanged.
|
|
516
519
|
*/
|
|
517
520
|
hostArgs?: SubagentHostArgSpecs;
|
|
518
521
|
/** When true, reuse the parent's AgentInputs (context isolation without separate config). */
|
package/package.json
CHANGED
|
@@ -57,7 +57,9 @@ import {
|
|
|
57
57
|
Providers,
|
|
58
58
|
} from '@/common';
|
|
59
59
|
import { isTokenCounterCacheCompatible } from '@/llm/tokenCounterCacheCompatibility';
|
|
60
|
+
import { normalizeToBashIdentifier } from '@/tools/BashProgrammaticToolCalling';
|
|
60
61
|
import { snapshotCompactionSemanticIndex } from '@/summarization/semanticIndex';
|
|
62
|
+
import { normalizeToPythonIdentifier } from '@/tools/ProgrammaticToolCalling';
|
|
61
63
|
import { createExactTokenCountCache } from '@/llm/contextPressureMeter';
|
|
62
64
|
import { markProviderTextInput } from '@/protection/providerTextInput';
|
|
63
65
|
import { buildSummaryCarrierText } from '@/summarization/shared';
|
|
@@ -81,6 +83,7 @@ type PromptCacheProvider = Providers.ANTHROPIC | Providers.OPENROUTER;
|
|
|
81
83
|
type ProgrammaticToolInstructionTarget = {
|
|
82
84
|
name: string;
|
|
83
85
|
codeGuidance: string;
|
|
86
|
+
runtimes: Array<'Bash' | 'Python'>;
|
|
84
87
|
executesDirectly: boolean;
|
|
85
88
|
};
|
|
86
89
|
|
|
@@ -680,12 +683,73 @@ export class AgentContext {
|
|
|
680
683
|
.map((name) => `\`${name}\``)
|
|
681
684
|
.join(
|
|
682
685
|
', '
|
|
683
|
-
)}. Every ${programmaticRunnerNames} call must include a \`tool_manifest\` containing the
|
|
686
|
+
)}. Every ${programmaticRunnerNames} call must include a \`tool_manifest\` containing the registered names or sandbox names used by its code; the manifest is validated before execution starts.`
|
|
684
687
|
: '';
|
|
688
|
+
const runtimes = new Set(
|
|
689
|
+
programmaticTools.flatMap((tool) => tool.runtimes)
|
|
690
|
+
);
|
|
691
|
+
const identifierOwners = new Map<string, string | null>();
|
|
692
|
+
for (const runtime of runtimes) {
|
|
693
|
+
const normalizeIdentifier =
|
|
694
|
+
runtime === 'Bash'
|
|
695
|
+
? normalizeToBashIdentifier
|
|
696
|
+
: normalizeToPythonIdentifier;
|
|
697
|
+
for (const toolDefs of [
|
|
698
|
+
capabilities.codeExecutionTools,
|
|
699
|
+
capabilities.directOnlyTools,
|
|
700
|
+
]) {
|
|
701
|
+
for (const toolDef of toolDefs) {
|
|
702
|
+
const key = `${runtime}:${normalizeIdentifier(toolDef.name)}`;
|
|
703
|
+
const owner = identifierOwners.get(key);
|
|
704
|
+
identifierOwners.set(
|
|
705
|
+
key,
|
|
706
|
+
owner === undefined || owner === toolDef.name ? toolDef.name : null
|
|
707
|
+
);
|
|
708
|
+
}
|
|
709
|
+
}
|
|
710
|
+
}
|
|
711
|
+
const sandboxNames: string[] = [];
|
|
712
|
+
const collidingNames: string[] = [];
|
|
713
|
+
for (const toolDef of capabilities.codeExecutionTools) {
|
|
714
|
+
const names: string[] = [];
|
|
715
|
+
const collisions: string[] = [];
|
|
716
|
+
for (const runtime of runtimes) {
|
|
717
|
+
const identifier =
|
|
718
|
+
runtime === 'Bash'
|
|
719
|
+
? normalizeToBashIdentifier(toolDef.name)
|
|
720
|
+
: normalizeToPythonIdentifier(toolDef.name);
|
|
721
|
+
if (identifier === toolDef.name) {
|
|
722
|
+
continue;
|
|
723
|
+
}
|
|
724
|
+
if (identifierOwners.get(`${runtime}:${identifier}`) !== toolDef.name) {
|
|
725
|
+
collisions.push(`${runtime} code \`${identifier}\``);
|
|
726
|
+
} else {
|
|
727
|
+
names.push(`${runtime} \`${identifier}\``);
|
|
728
|
+
}
|
|
729
|
+
}
|
|
730
|
+
if (names.length > 0) {
|
|
731
|
+
sandboxNames.push(`- \`${toolDef.name}\`: ${names.join('; ')}`);
|
|
732
|
+
}
|
|
733
|
+
if (collisions.length > 0) {
|
|
734
|
+
collidingNames.push(`- \`${toolDef.name}\`: ${collisions.join('; ')}`);
|
|
735
|
+
}
|
|
736
|
+
}
|
|
737
|
+
const sandboxNameGuidance =
|
|
738
|
+
sandboxNames.length === 0
|
|
739
|
+
? ''
|
|
740
|
+
: '\n\nUse sandbox names in both code and `tool_manifest` for the tools below; registered names are also accepted in `tool_manifest`:\n' +
|
|
741
|
+
sandboxNames.join('\n');
|
|
742
|
+
const collidingNameGuidance =
|
|
743
|
+
collidingNames.length === 0
|
|
744
|
+
? ''
|
|
745
|
+
: '\n\nFor colliding sandbox names, use registered names in `tool_manifest` and sandbox names in code. Select only one tool per sandbox name:\n' +
|
|
746
|
+
collidingNames.join('\n');
|
|
685
747
|
const boundary =
|
|
686
748
|
'\n\n' +
|
|
687
749
|
`Only these tools may be invoked inside ${programmaticRunnerNames}: ${quotedProgrammaticNames}.` +
|
|
688
|
-
directOnlyBoundary
|
|
750
|
+
directOnlyBoundary +
|
|
751
|
+
sandboxNameGuidance +
|
|
752
|
+
collidingNameGuidance;
|
|
689
753
|
|
|
690
754
|
if (programmaticOnlyTools.length === 0) {
|
|
691
755
|
return boundary;
|
|
@@ -730,6 +794,7 @@ export class AgentContext {
|
|
|
730
794
|
targets.push({
|
|
731
795
|
name: Constants.BASH_PROGRAMMATIC_TOOL_CALLING,
|
|
732
796
|
codeGuidance: 'Bash code',
|
|
797
|
+
runtimes: ['Bash'],
|
|
733
798
|
executesDirectly: this.isProgrammaticRunnerDirectlyBound(
|
|
734
799
|
Constants.BASH_PROGRAMMATIC_TOOL_CALLING
|
|
735
800
|
),
|
|
@@ -751,6 +816,7 @@ export class AgentContext {
|
|
|
751
816
|
codeGuidance: localDefault
|
|
752
817
|
? 'Bash code by default, or set `lang: "py"` to use Python code'
|
|
753
818
|
: 'Python code',
|
|
819
|
+
runtimes: localDefault ? ['Bash', 'Python'] : ['Python'],
|
|
754
820
|
executesDirectly: this.isProgrammaticRunnerDirectlyBound(
|
|
755
821
|
Constants.PROGRAMMATIC_TOOL_CALLING
|
|
756
822
|
),
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
HostFileDescriptor,
|
|
3
|
+
HostFileStageRequest,
|
|
4
|
+
HostFileReadRequest,
|
|
5
|
+
HostFilePublication,
|
|
6
|
+
HostFileServiceDescriptor,
|
|
7
|
+
HostFileService,
|
|
8
|
+
} from './files';
|
|
9
|
+
import type { ExecutionIdentity } from './identity';
|
|
10
|
+
import {
|
|
11
|
+
HostFileServiceError,
|
|
12
|
+
normalizeHostFileError,
|
|
13
|
+
checkedHostFile,
|
|
14
|
+
checkedHostFileChunk,
|
|
15
|
+
checkedHostFileService,
|
|
16
|
+
hostFileStageRequestSchema,
|
|
17
|
+
hostFilePublishRequestSchema,
|
|
18
|
+
} from './files';
|
|
19
|
+
import { snapshotExecutionIdentity } from './identity';
|
|
20
|
+
import { createFileUpload } from './fileStream';
|
|
21
|
+
|
|
22
|
+
export interface HostFileBindings {
|
|
23
|
+
read(
|
|
24
|
+
file: HostFileDescriptor,
|
|
25
|
+
signal?: AbortSignal
|
|
26
|
+
): AsyncIterable<Uint8Array>;
|
|
27
|
+
stage(
|
|
28
|
+
artifact: Omit<HostFileStageRequest, 'version' | 'identity'>,
|
|
29
|
+
content: AsyncIterable<Uint8Array>,
|
|
30
|
+
signal?: AbortSignal
|
|
31
|
+
): Promise<HostFileDescriptor>;
|
|
32
|
+
publish(
|
|
33
|
+
file: HostFileDescriptor,
|
|
34
|
+
operationId: string,
|
|
35
|
+
signal?: AbortSignal
|
|
36
|
+
): Promise<HostFilePublication>;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/** Pull-based graph adapter; at most one range or upload chunk is requested at a time. */
|
|
40
|
+
export function createHostFileBindings(options: {
|
|
41
|
+
identity: Readonly<ExecutionIdentity>;
|
|
42
|
+
descriptor: HostFileServiceDescriptor;
|
|
43
|
+
service: HostFileService;
|
|
44
|
+
}): HostFileBindings {
|
|
45
|
+
const identity = snapshotExecutionIdentity(options.identity);
|
|
46
|
+
const descriptor = checkedHostFileService(options.descriptor);
|
|
47
|
+
const service = options.service;
|
|
48
|
+
if (Number(service.version) !== 1)
|
|
49
|
+
throw new HostFileServiceError('incompatible');
|
|
50
|
+
function allow(
|
|
51
|
+
operation: HostFileServiceDescriptor['operations'][number],
|
|
52
|
+
signal?: AbortSignal
|
|
53
|
+
): void {
|
|
54
|
+
if (!descriptor.operations.includes(operation))
|
|
55
|
+
throw new HostFileServiceError('forbidden');
|
|
56
|
+
if (signal?.aborted === true) throw new HostFileServiceError('cancelled');
|
|
57
|
+
}
|
|
58
|
+
return {
|
|
59
|
+
read: async function* (source, signal): AsyncGenerator<Uint8Array> {
|
|
60
|
+
try {
|
|
61
|
+
allow('read', signal);
|
|
62
|
+
const file = checkedHostFile(source);
|
|
63
|
+
if (file.bytes > descriptor.maxFileBytes)
|
|
64
|
+
throw new HostFileServiceError('overflow');
|
|
65
|
+
for (let offset = 0; offset < file.bytes; ) {
|
|
66
|
+
allow('read', signal);
|
|
67
|
+
const input: HostFileReadRequest = {
|
|
68
|
+
version: 1,
|
|
69
|
+
identity,
|
|
70
|
+
reference: file.reference,
|
|
71
|
+
revision: file.revision,
|
|
72
|
+
offset,
|
|
73
|
+
length: Math.min(descriptor.maxChunkBytes, file.bytes - offset),
|
|
74
|
+
};
|
|
75
|
+
const chunk = checkedHostFileChunk(
|
|
76
|
+
await service.read(input, signal),
|
|
77
|
+
input
|
|
78
|
+
);
|
|
79
|
+
allow('read', signal);
|
|
80
|
+
offset += chunk.data.byteLength;
|
|
81
|
+
yield chunk.data;
|
|
82
|
+
}
|
|
83
|
+
} catch (error) {
|
|
84
|
+
throw normalizeHostFileError(error, signal);
|
|
85
|
+
}
|
|
86
|
+
},
|
|
87
|
+
stage: async (artifact, content, signal): Promise<HostFileDescriptor> => {
|
|
88
|
+
try {
|
|
89
|
+
allow('stage', signal);
|
|
90
|
+
const parsed = hostFileStageRequestSchema.safeParse({
|
|
91
|
+
...artifact,
|
|
92
|
+
version: 1,
|
|
93
|
+
identity,
|
|
94
|
+
});
|
|
95
|
+
if (!parsed.success) throw new HostFileServiceError('incompatible');
|
|
96
|
+
if (parsed.data.bytes > descriptor.maxFileBytes)
|
|
97
|
+
throw new HostFileServiceError('overflow');
|
|
98
|
+
const upload = createFileUpload(
|
|
99
|
+
content,
|
|
100
|
+
parsed.data,
|
|
101
|
+
descriptor.maxChunkBytes,
|
|
102
|
+
signal
|
|
103
|
+
);
|
|
104
|
+
try {
|
|
105
|
+
const file = checkedHostFile(
|
|
106
|
+
await service.stage(parsed.data, upload.content, signal)
|
|
107
|
+
);
|
|
108
|
+
upload.finish();
|
|
109
|
+
allow('stage', signal);
|
|
110
|
+
if (
|
|
111
|
+
file.sha256 === undefined ||
|
|
112
|
+
file.bytes !== parsed.data.bytes ||
|
|
113
|
+
(parsed.data.sha256 !== undefined &&
|
|
114
|
+
file.sha256 !== parsed.data.sha256)
|
|
115
|
+
)
|
|
116
|
+
throw new HostFileServiceError('incompatible');
|
|
117
|
+
return file;
|
|
118
|
+
} finally {
|
|
119
|
+
/** The host retains admission until source cleanup settles. Do not delay
|
|
120
|
+
* a cancellation/timeout response on an uncooperative producer here. */
|
|
121
|
+
void upload.close().catch(() => undefined);
|
|
122
|
+
}
|
|
123
|
+
} catch (error) {
|
|
124
|
+
throw normalizeHostFileError(error, signal);
|
|
125
|
+
}
|
|
126
|
+
},
|
|
127
|
+
publish: async (
|
|
128
|
+
source,
|
|
129
|
+
operationId,
|
|
130
|
+
signal
|
|
131
|
+
): Promise<HostFilePublication> => {
|
|
132
|
+
try {
|
|
133
|
+
allow('publish', signal);
|
|
134
|
+
const file = checkedHostFile(source);
|
|
135
|
+
const parsed = hostFilePublishRequestSchema.safeParse({
|
|
136
|
+
version: 1,
|
|
137
|
+
identity,
|
|
138
|
+
operationId,
|
|
139
|
+
reference: file.reference,
|
|
140
|
+
revision: file.revision,
|
|
141
|
+
});
|
|
142
|
+
if (!parsed.success) throw new HostFileServiceError('incompatible');
|
|
143
|
+
const result = await service.publish(parsed.data, signal);
|
|
144
|
+
allow('publish', signal);
|
|
145
|
+
if (result.operationId !== operationId)
|
|
146
|
+
throw new HostFileServiceError('incompatible');
|
|
147
|
+
const published = checkedHostFile(result.file);
|
|
148
|
+
if (published.bytes > descriptor.maxFileBytes)
|
|
149
|
+
throw new HostFileServiceError('overflow');
|
|
150
|
+
return { operationId, file: published };
|
|
151
|
+
} catch (error) {
|
|
152
|
+
throw normalizeHostFileError(error, signal);
|
|
153
|
+
}
|
|
154
|
+
},
|
|
155
|
+
};
|
|
156
|
+
}
|