bazis 0.98.33 → 0.99.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/cli/templates/module.ts +4 -64
- package/cli/templates/passport.ts +14 -18
- package/core/agent/AgentContextBuilder.ts +4 -98
- package/core/agent/AgentRegistry.ts +79 -473
- package/core/agent/AgentRuntime.ts +47 -19
- package/core/agent/AgentToolExecutor.ts +3 -3
- package/core/agent/README.md +89 -181
- package/core/agent/index.ts +3 -31
- package/core/agent/internal/AgentExecutionDriver.ts +37 -392
- package/core/agent/internal/AgentExecutionState.ts +1 -9
- package/core/agent/metadata.ts +8 -303
- package/core/agent/semantic.ts +0 -4
- package/core/agent/session/contracts.ts +5 -7
- package/core/agent/session/entities.ts +0 -1
- package/core/cache/COMPATIBILITY.md +4 -4
- package/core/cache/README.md +2 -2
- package/core/cache/SPEC.md +30 -48
- package/core/cache/decorators/Cacheable.ts +4 -3
- package/core/cache/decorators/CacheableRedis.ts +3 -4
- package/core/cache/di/classProviderHook.ts +31 -0
- package/core/cache/distributed/DistributedCache.ts +96 -25
- package/core/cache/distributed/IDistributedCache.ts +9 -0
- package/core/cache/distributed/codecs.ts +49 -2
- package/core/cache/distributed/index.ts +1 -1
- package/core/cache/errors/CacheError.ts +17 -2
- package/core/cache/http/outputRedisCacheMiddleware.ts +11 -2
- package/core/cache/index.ts +2 -6
- package/core/cache/services/cacheProxy.ts +6 -2
- package/core/generatedRuntime.ts +0 -31
- package/core/infra/cache/RedisDistributedCacheBackend.ts +3 -0
- package/core/infra/connectors/codex/CodexAppServerClient.ts +1 -1
- package/core/infra/connectors/llm.ts +15 -1
- package/core/infra/connectors/llmRouter.ts +4 -0
- package/core/infra/connectors/redis.ts +9 -1
- package/core/scripts/di-generate.ts +28 -42
- package/core/scripts/tool-codegen.ts +122 -0
- package/index.ts +3 -24
- package/package.json +1 -1
- package/core/agent/decorators/Agent.ts +0 -11
- package/core/agent/decorators/Prompt.ts +0 -11
- package/core/agent/decorators/Task.ts +0 -29
- package/core/agent/generated/catalog.ts +0 -26
- package/core/scripts/agent-codegen.ts +0 -1166
|
@@ -39,10 +39,8 @@ const issuedCheckpoints = new WeakSet<object>();
|
|
|
39
39
|
export type AgentExecutionPhase = "ready-model" | "pending-tools" | "terminal";
|
|
40
40
|
|
|
41
41
|
export interface AgentExecutionInvocationState {
|
|
42
|
-
readonly kind: "agent" | "task";
|
|
43
42
|
readonly invocationId: string;
|
|
44
43
|
readonly agentName: string;
|
|
45
|
-
readonly taskName?: string;
|
|
46
44
|
readonly input: JsonValue;
|
|
47
45
|
readonly metadata: JsonObject;
|
|
48
46
|
/** Resolved Session data only; never classes, callbacks, DI or policies. */
|
|
@@ -239,14 +237,10 @@ function checkpointFromBoundary(value: BoundaryJsonValue): AgentExecutionCheckpo
|
|
|
239
237
|
}
|
|
240
238
|
|
|
241
239
|
function parseInvocation(value: BoundaryJsonValue): AgentExecutionInvocationState {
|
|
242
|
-
const record = closed(value, ["
|
|
243
|
-
if (record.kind !== "agent" && record.kind !== "task") throw invalid();
|
|
244
|
-
if ((record.kind === "agent" && record.taskName !== null) || (record.kind === "task" && typeof record.taskName !== "string")) throw invalid();
|
|
240
|
+
const record = closed(value, ["invocationId", "agentName", "input", "metadata", "options"]);
|
|
245
241
|
return Object.freeze({
|
|
246
|
-
kind: record.kind,
|
|
247
242
|
invocationId: requiredString(record.invocationId),
|
|
248
243
|
agentName: requiredString(record.agentName),
|
|
249
|
-
taskName: record.taskName === null ? undefined : requiredString(record.taskName),
|
|
250
244
|
input: asJsonValue(record.input),
|
|
251
245
|
metadata: asJsonObject(record.metadata),
|
|
252
246
|
options: parseResolvedOptions(record.options),
|
|
@@ -610,10 +604,8 @@ function checkpointRecord(checkpoint: AgentExecutionCheckpointV1): Record<string
|
|
|
610
604
|
return {
|
|
611
605
|
version: checkpoint.version,
|
|
612
606
|
invocation: {
|
|
613
|
-
kind: checkpoint.invocation.kind,
|
|
614
607
|
invocationId: checkpoint.invocation.invocationId,
|
|
615
608
|
agentName: checkpoint.invocation.agentName,
|
|
616
|
-
taskName: checkpoint.invocation.taskName ?? null,
|
|
617
609
|
input: checkpoint.invocation.input,
|
|
618
610
|
metadata: checkpoint.invocation.metadata,
|
|
619
611
|
options: checkpoint.invocation.options,
|
package/core/agent/metadata.ts
CHANGED
|
@@ -5,77 +5,10 @@ import { AgentSetupError } from "./errors";
|
|
|
5
5
|
// the runtime. Keep the same tiny polyfill used by HTTP/background metadata.
|
|
6
6
|
(Symbol as { metadata?: symbol }).metadata ??= Symbol.for("Symbol.metadata");
|
|
7
7
|
|
|
8
|
-
const AGENT_META = Symbol.for("bazis:agent:agent");
|
|
9
8
|
const TOOL_META = Symbol.for("bazis:agent:tool");
|
|
10
|
-
const PROMPT_META = Symbol.for("bazis:agent:prompt");
|
|
11
|
-
const TASK_META = Symbol.for("bazis:agent:task");
|
|
12
9
|
|
|
13
10
|
export type ToolSideEffect = "none" | "read" | "write" | "external";
|
|
14
11
|
export type ToolApproval = "never" | "policy" | "required";
|
|
15
|
-
export type PromptSectionKind =
|
|
16
|
-
| "system"
|
|
17
|
-
| "developer"
|
|
18
|
-
| "role"
|
|
19
|
-
| "task"
|
|
20
|
-
| "instructions"
|
|
21
|
-
| "constraints"
|
|
22
|
-
| "examples"
|
|
23
|
-
| "output"
|
|
24
|
-
| "tool-policy"
|
|
25
|
-
| "memory"
|
|
26
|
-
| "knowledge";
|
|
27
|
-
|
|
28
|
-
export interface AgentOptions {
|
|
29
|
-
readonly name?: string;
|
|
30
|
-
readonly description?: string;
|
|
31
|
-
readonly role?: string;
|
|
32
|
-
readonly goal?: string;
|
|
33
|
-
readonly instructions?: readonly string[];
|
|
34
|
-
readonly constraints?: readonly string[];
|
|
35
|
-
readonly sections?: readonly PromptSectionOptions[];
|
|
36
|
-
readonly prompt?: Class<object>;
|
|
37
|
-
readonly tools?: readonly Class<object>[];
|
|
38
|
-
readonly input?: Class<object>;
|
|
39
|
-
readonly output?: Class<object>;
|
|
40
|
-
readonly modelProfile?: string;
|
|
41
|
-
readonly maxSteps?: number;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
export interface AgentMetadata {
|
|
45
|
-
readonly name: string;
|
|
46
|
-
readonly description?: string;
|
|
47
|
-
readonly role?: string;
|
|
48
|
-
readonly goal?: string;
|
|
49
|
-
readonly instructions: readonly string[];
|
|
50
|
-
readonly constraints: readonly string[];
|
|
51
|
-
readonly sections: readonly PromptSectionMetadata[];
|
|
52
|
-
readonly prompt?: Class<object>;
|
|
53
|
-
readonly tools: readonly Class<object>[];
|
|
54
|
-
readonly input?: Class<object>;
|
|
55
|
-
readonly output?: Class<object>;
|
|
56
|
-
readonly modelProfile?: string;
|
|
57
|
-
readonly maxSteps?: number;
|
|
58
|
-
readonly tasks: readonly AgentTaskMetadata[];
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
export interface AgentTaskOptions {
|
|
62
|
-
readonly name?: string;
|
|
63
|
-
readonly description?: string;
|
|
64
|
-
readonly input?: Class<object>;
|
|
65
|
-
readonly output?: Class<object>;
|
|
66
|
-
readonly modelProfile?: string;
|
|
67
|
-
readonly maxSteps?: number;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
export interface AgentTaskMetadata {
|
|
71
|
-
readonly name: string;
|
|
72
|
-
readonly methodName: string;
|
|
73
|
-
readonly description?: string;
|
|
74
|
-
readonly input?: Class<object>;
|
|
75
|
-
readonly output?: Class<object>;
|
|
76
|
-
readonly modelProfile?: string;
|
|
77
|
-
readonly maxSteps?: number;
|
|
78
|
-
}
|
|
79
12
|
|
|
80
13
|
export interface ToolOptions {
|
|
81
14
|
readonly name: string;
|
|
@@ -99,155 +32,23 @@ export interface ToolMetadata {
|
|
|
99
32
|
readonly tags: readonly string[];
|
|
100
33
|
}
|
|
101
34
|
|
|
102
|
-
export interface PromptOptions {
|
|
103
|
-
readonly name?: string;
|
|
104
|
-
readonly description?: string;
|
|
105
|
-
readonly version?: string;
|
|
106
|
-
readonly role?: string;
|
|
107
|
-
readonly goal?: string;
|
|
108
|
-
readonly instructions?: readonly string[];
|
|
109
|
-
readonly constraints?: readonly string[];
|
|
110
|
-
readonly sections?: readonly PromptSectionOptions[];
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
export interface PromptMetadata {
|
|
114
|
-
readonly name: string;
|
|
115
|
-
readonly description?: string;
|
|
116
|
-
readonly version?: string;
|
|
117
|
-
readonly role?: string;
|
|
118
|
-
readonly goal?: string;
|
|
119
|
-
readonly instructions: readonly string[];
|
|
120
|
-
readonly constraints: readonly string[];
|
|
121
|
-
readonly sections: readonly PromptSectionMetadata[];
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
export interface PromptSectionOptions {
|
|
125
|
-
readonly kind: PromptSectionKind;
|
|
126
|
-
readonly title?: string;
|
|
127
|
-
readonly content: string | readonly string[];
|
|
128
|
-
readonly priority?: number;
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
export interface PromptSectionMetadata {
|
|
132
|
-
readonly kind: PromptSectionKind;
|
|
133
|
-
readonly title?: string;
|
|
134
|
-
readonly content: readonly string[];
|
|
135
|
-
readonly priority?: number;
|
|
136
|
-
}
|
|
137
|
-
|
|
138
35
|
interface MetadataCarrier {
|
|
139
|
-
[AGENT_META]?: AgentMetadata;
|
|
140
36
|
[TOOL_META]?: ToolMetadata;
|
|
141
|
-
[PROMPT_META]?: PromptMetadata;
|
|
142
|
-
[TASK_META]?: readonly AgentTaskMetadata[];
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
interface NamedConstructor {
|
|
146
|
-
readonly name?: string;
|
|
147
37
|
}
|
|
148
38
|
|
|
149
|
-
function
|
|
150
|
-
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
function text(value: string | undefined, fallback: string, field: string): string {
|
|
154
|
-
const resolved = value ?? fallback;
|
|
155
|
-
const trimmed = resolved.trim();
|
|
39
|
+
function text(value: string | undefined, field: string): string {
|
|
40
|
+
const trimmed = (value ?? "").trim();
|
|
156
41
|
if (trimmed.length === 0) {
|
|
157
42
|
throw new AgentSetupError(`${field} must be a non-empty string.`);
|
|
158
43
|
}
|
|
159
44
|
return trimmed;
|
|
160
45
|
}
|
|
161
46
|
|
|
162
|
-
function optionalText(value: string | undefined, field: string): string | undefined {
|
|
163
|
-
if (value === undefined) {
|
|
164
|
-
return undefined;
|
|
165
|
-
}
|
|
166
|
-
const trimmed = value.trim();
|
|
167
|
-
if (trimmed.length === 0) {
|
|
168
|
-
throw new AgentSetupError(`${field} must be a non-empty string when provided.`);
|
|
169
|
-
}
|
|
170
|
-
return trimmed;
|
|
171
|
-
}
|
|
172
|
-
|
|
173
47
|
function readonlyTextList(values: readonly string[] | undefined, field: string): readonly string[] {
|
|
174
48
|
if (values === undefined) {
|
|
175
49
|
return Object.freeze([]);
|
|
176
50
|
}
|
|
177
|
-
|
|
178
|
-
for (let index = 0; index < values.length; index += 1) {
|
|
179
|
-
normalized.push(text(values[index] as string, "", field));
|
|
180
|
-
}
|
|
181
|
-
return Object.freeze(normalized);
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
function promptSectionKind(value: string, field: string): PromptSectionKind {
|
|
185
|
-
if (
|
|
186
|
-
value !== "system" &&
|
|
187
|
-
value !== "developer" &&
|
|
188
|
-
value !== "role" &&
|
|
189
|
-
value !== "task" &&
|
|
190
|
-
value !== "instructions" &&
|
|
191
|
-
value !== "constraints" &&
|
|
192
|
-
value !== "examples" &&
|
|
193
|
-
value !== "output" &&
|
|
194
|
-
value !== "tool-policy" &&
|
|
195
|
-
value !== "memory" &&
|
|
196
|
-
value !== "knowledge"
|
|
197
|
-
) {
|
|
198
|
-
throw new AgentSetupError(
|
|
199
|
-
`${field} must be system, developer, role, task, instructions, constraints, examples, output, tool-policy, memory or knowledge.`,
|
|
200
|
-
);
|
|
201
|
-
}
|
|
202
|
-
return value;
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
function readonlyPromptSectionContent(value: string | readonly string[], field: string): readonly string[] {
|
|
206
|
-
if (typeof value === "string") {
|
|
207
|
-
return Object.freeze([text(value, "", field)]);
|
|
208
|
-
}
|
|
209
|
-
if (!Array.isArray(value)) {
|
|
210
|
-
throw new AgentSetupError(`${field} must be a string or an array of strings.`);
|
|
211
|
-
}
|
|
212
|
-
return readonlyTextList(value, field);
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
function readonlyPromptSections(
|
|
216
|
-
values: readonly PromptSectionOptions[] | undefined,
|
|
217
|
-
field: string,
|
|
218
|
-
): readonly PromptSectionMetadata[] {
|
|
219
|
-
if (values === undefined) {
|
|
220
|
-
return Object.freeze([]);
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
const normalized: PromptSectionMetadata[] = [];
|
|
224
|
-
for (let index = 0; index < values.length; index += 1) {
|
|
225
|
-
const value = values[index] as PromptSectionOptions;
|
|
226
|
-
if (!value || typeof value !== "object") {
|
|
227
|
-
throw new AgentSetupError(`${field}[${index}] must be a prompt section object.`);
|
|
228
|
-
}
|
|
229
|
-
normalized.push(freezeWithoutUndefined({
|
|
230
|
-
kind: promptSectionKind(value.kind, `${field}[${index}].kind`),
|
|
231
|
-
title: optionalText(value.title, `${field}[${index}].title`),
|
|
232
|
-
content: readonlyPromptSectionContent(value.content, `${field}[${index}].content`),
|
|
233
|
-
priority: positiveInteger(value.priority, `${field}[${index}].priority`),
|
|
234
|
-
}));
|
|
235
|
-
}
|
|
236
|
-
return Object.freeze(normalized);
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
function readonlyClassList(values: readonly Class<object>[] | undefined): readonly Class<object>[] {
|
|
240
|
-
if (values === undefined) {
|
|
241
|
-
return Object.freeze([]);
|
|
242
|
-
}
|
|
243
|
-
return Object.freeze([...values]);
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
function readonlyTaskList(values: readonly AgentTaskMetadata[] | undefined): readonly AgentTaskMetadata[] {
|
|
247
|
-
if (values === undefined) {
|
|
248
|
-
return Object.freeze([]);
|
|
249
|
-
}
|
|
250
|
-
return Object.freeze([...values]);
|
|
51
|
+
return Object.freeze(values.map((value) => text(value, field)));
|
|
251
52
|
}
|
|
252
53
|
|
|
253
54
|
function positiveInteger(value: number | undefined, field: string): number | undefined {
|
|
@@ -260,16 +61,6 @@ function positiveInteger(value: number | undefined, field: string): number | und
|
|
|
260
61
|
return value;
|
|
261
62
|
}
|
|
262
63
|
|
|
263
|
-
function freezeWithoutUndefined<T extends Record<string, unknown>>(value: T): T {
|
|
264
|
-
const copy: Record<string, unknown> = {};
|
|
265
|
-
for (const [key, item] of Object.entries(value)) {
|
|
266
|
-
if (item !== undefined) {
|
|
267
|
-
copy[key] = item;
|
|
268
|
-
}
|
|
269
|
-
}
|
|
270
|
-
return Object.freeze(copy) as T;
|
|
271
|
-
}
|
|
272
|
-
|
|
273
64
|
function approvalFor(sideEffect: ToolSideEffect, requested: ToolApproval | undefined): ToolApproval {
|
|
274
65
|
if (requested === undefined) {
|
|
275
66
|
return sideEffect === "write" || sideEffect === "external" ? "required" : "policy";
|
|
@@ -282,57 +73,6 @@ function approvalFor(sideEffect: ToolSideEffect, requested: ToolApproval | undef
|
|
|
282
73
|
return requested;
|
|
283
74
|
}
|
|
284
75
|
|
|
285
|
-
function ownCarrier(metadata: object): MetadataCarrier {
|
|
286
|
-
return metadata as MetadataCarrier;
|
|
287
|
-
}
|
|
288
|
-
|
|
289
|
-
function readCarrier(ctor: object): MetadataCarrier | undefined {
|
|
290
|
-
return (ctor as { [key: symbol]: unknown })[Symbol.metadata as unknown as symbol] as MetadataCarrier | undefined;
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
function hasOwnMeta(carrier: MetadataCarrier, key: symbol): boolean {
|
|
294
|
-
return Object.prototype.hasOwnProperty.call(carrier, key);
|
|
295
|
-
}
|
|
296
|
-
|
|
297
|
-
export function defineAgentMetadata(target: object, metadata: object, options: AgentOptions): void {
|
|
298
|
-
const carrier = ownCarrier(metadata);
|
|
299
|
-
const normalized: AgentMetadata = Object.freeze({
|
|
300
|
-
name: text(options.name, classNameOf(target), "@Agent.name"),
|
|
301
|
-
description: optionalText(options.description, "@Agent.description"),
|
|
302
|
-
role: optionalText(options.role, "@Agent.role"),
|
|
303
|
-
goal: optionalText(options.goal, "@Agent.goal"),
|
|
304
|
-
instructions: readonlyTextList(options.instructions, "@Agent.instructions"),
|
|
305
|
-
constraints: readonlyTextList(options.constraints, "@Agent.constraints"),
|
|
306
|
-
sections: readonlyPromptSections(options.sections, "@Agent.sections"),
|
|
307
|
-
prompt: options.prompt,
|
|
308
|
-
tools: readonlyClassList(options.tools),
|
|
309
|
-
input: options.input,
|
|
310
|
-
output: options.output,
|
|
311
|
-
modelProfile: optionalText(options.modelProfile, "@Agent.modelProfile"),
|
|
312
|
-
maxSteps: positiveInteger(options.maxSteps, "@Agent.maxSteps"),
|
|
313
|
-
tasks: readonlyTaskList(carrier[TASK_META]),
|
|
314
|
-
});
|
|
315
|
-
carrier[AGENT_META] = normalized;
|
|
316
|
-
}
|
|
317
|
-
|
|
318
|
-
export function defineAgentTaskMetadata(methodName: string | symbol, metadata: object, options: AgentTaskOptions): void {
|
|
319
|
-
if (typeof methodName !== "string") {
|
|
320
|
-
throw new AgentSetupError("@Task supports string method names only.");
|
|
321
|
-
}
|
|
322
|
-
const normalized: AgentTaskMetadata = freezeWithoutUndefined({
|
|
323
|
-
name: text(options.name, methodName, "@Task.name"),
|
|
324
|
-
methodName,
|
|
325
|
-
description: optionalText(options.description, "@Task.description"),
|
|
326
|
-
input: options.input,
|
|
327
|
-
output: options.output,
|
|
328
|
-
modelProfile: optionalText(options.modelProfile, "@Task.modelProfile"),
|
|
329
|
-
maxSteps: positiveInteger(options.maxSteps, "@Task.maxSteps"),
|
|
330
|
-
});
|
|
331
|
-
const carrier = ownCarrier(metadata);
|
|
332
|
-
const existing = carrier[TASK_META] ?? Object.freeze([]);
|
|
333
|
-
carrier[TASK_META] = Object.freeze([...existing, normalized]);
|
|
334
|
-
}
|
|
335
|
-
|
|
336
76
|
export function defineToolMetadata(_target: object, metadata: object, options: ToolOptions): void {
|
|
337
77
|
const sideEffect = options.sideEffect ?? "none";
|
|
338
78
|
if (sideEffect !== "none" && sideEffect !== "read" && sideEffect !== "write" && sideEffect !== "external") {
|
|
@@ -342,8 +82,8 @@ export function defineToolMetadata(_target: object, metadata: object, options: T
|
|
|
342
82
|
throw new AgentSetupError("@Tool.approval must be never, policy or required.");
|
|
343
83
|
}
|
|
344
84
|
const normalized: ToolMetadata = Object.freeze({
|
|
345
|
-
name: text(options.name, "
|
|
346
|
-
description: text(options.description, "
|
|
85
|
+
name: text(options.name, "@Tool.name"),
|
|
86
|
+
description: text(options.description, "@Tool.description"),
|
|
347
87
|
input: options.input,
|
|
348
88
|
output: options.output,
|
|
349
89
|
sideEffect,
|
|
@@ -351,48 +91,13 @@ export function defineToolMetadata(_target: object, metadata: object, options: T
|
|
|
351
91
|
timeoutMs: positiveInteger(options.timeoutMs, "@Tool.timeoutMs"),
|
|
352
92
|
tags: readonlyTextList(options.tags, "@Tool.tags"),
|
|
353
93
|
});
|
|
354
|
-
|
|
355
|
-
}
|
|
356
|
-
|
|
357
|
-
export function definePromptMetadata(target: object, metadata: object, options: PromptOptions): void {
|
|
358
|
-
const normalized: PromptMetadata = Object.freeze({
|
|
359
|
-
name: text(options.name, classNameOf(target), "@Prompt.name"),
|
|
360
|
-
description: optionalText(options.description, "@Prompt.description"),
|
|
361
|
-
version: optionalText(options.version, "@Prompt.version"),
|
|
362
|
-
role: optionalText(options.role, "@Prompt.role"),
|
|
363
|
-
goal: optionalText(options.goal, "@Prompt.goal"),
|
|
364
|
-
instructions: readonlyTextList(options.instructions, "@Prompt.instructions"),
|
|
365
|
-
constraints: readonlyTextList(options.constraints, "@Prompt.constraints"),
|
|
366
|
-
sections: readonlyPromptSections(options.sections, "@Prompt.sections"),
|
|
367
|
-
});
|
|
368
|
-
ownCarrier(metadata)[PROMPT_META] = normalized;
|
|
369
|
-
}
|
|
370
|
-
|
|
371
|
-
export function agentMetadataOf(ctor: object): AgentMetadata | undefined {
|
|
372
|
-
const metadata = readCarrier(ctor);
|
|
373
|
-
if (!metadata || !hasOwnMeta(metadata, AGENT_META)) {
|
|
374
|
-
return undefined;
|
|
375
|
-
}
|
|
376
|
-
return metadata[AGENT_META];
|
|
377
|
-
}
|
|
378
|
-
|
|
379
|
-
export function agentTaskMetadataOf(ctor: object): readonly AgentTaskMetadata[] {
|
|
380
|
-
const metadata = readCarrier(ctor);
|
|
381
|
-
return metadata?.[TASK_META] ?? Object.freeze([]);
|
|
94
|
+
(metadata as MetadataCarrier)[TOOL_META] = normalized;
|
|
382
95
|
}
|
|
383
96
|
|
|
384
97
|
export function toolMetadataOf(ctor: object): ToolMetadata | undefined {
|
|
385
|
-
const metadata =
|
|
386
|
-
if (!metadata || !
|
|
98
|
+
const metadata = (ctor as { [key: symbol]: unknown })[Symbol.metadata as unknown as symbol] as MetadataCarrier | undefined;
|
|
99
|
+
if (!metadata || !Object.prototype.hasOwnProperty.call(metadata, TOOL_META)) {
|
|
387
100
|
return undefined;
|
|
388
101
|
}
|
|
389
102
|
return metadata[TOOL_META];
|
|
390
103
|
}
|
|
391
|
-
|
|
392
|
-
export function promptMetadataOf(ctor: object): PromptMetadata | undefined {
|
|
393
|
-
const metadata = readCarrier(ctor);
|
|
394
|
-
if (!metadata || !hasOwnMeta(metadata, PROMPT_META)) {
|
|
395
|
-
return undefined;
|
|
396
|
-
}
|
|
397
|
-
return metadata[PROMPT_META];
|
|
398
|
-
}
|
package/core/agent/semantic.ts
CHANGED
|
@@ -368,10 +368,6 @@ export function normalizeJsonValue(value: unknown, field = "value"): JsonValue {
|
|
|
368
368
|
throw new AgentSemanticError(`${field} must be JSON-serializable.`);
|
|
369
369
|
}
|
|
370
370
|
|
|
371
|
-
export function agentOutput<T = never>(): T {
|
|
372
|
-
throw new AgentSemanticError("agentOutput() is an agent task marker and must not be called directly.");
|
|
373
|
-
}
|
|
374
|
-
|
|
375
371
|
export function agentText(text: string): AgentTextPart {
|
|
376
372
|
const value = requiredContentText(text, "text");
|
|
377
373
|
return Object.freeze({ kind: "text", text: value });
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Secret } from "../../kernel";
|
|
2
2
|
import type { BazisModuleRef } from "../../di";
|
|
3
|
-
import type { AgentToolExecutorOptions
|
|
3
|
+
import type { AgentToolExecutorOptions } from "../AgentToolExecutor";
|
|
4
4
|
import { normalizeJsonValue, type JsonObject, type JsonValue } from "../semantic";
|
|
5
5
|
import { Validator } from "../../../library/validation";
|
|
6
6
|
|
|
@@ -16,8 +16,6 @@ export class CreateAgentSessionRequestV1 {
|
|
|
16
16
|
requestId!: string;
|
|
17
17
|
@Validator({ required: true, minLength: 1, maxLength: 128 })
|
|
18
18
|
agentName!: string;
|
|
19
|
-
@Validator({ minLength: 1, maxLength: 128 })
|
|
20
|
-
taskName?: string;
|
|
21
19
|
@Validator({
|
|
22
20
|
required: true,
|
|
23
21
|
// JsonValue deliberately includes null. Keep absence invalid while
|
|
@@ -55,7 +53,7 @@ export type AgentSessionStateV1 = "created" | "running" | "stop-requested" | "st
|
|
|
55
53
|
export type AgentSessionCursorV1 = string;
|
|
56
54
|
export interface AgentSessionOutcomeV1 { readonly status: "completed" | "failed" | "outcome-unknown"; readonly finalText?: string; readonly output?: JsonValue; readonly error?: { readonly code: string; readonly message: string }; }
|
|
57
55
|
export interface AgentSessionViewV1 {
|
|
58
|
-
readonly version: 1; readonly sessionId: string; readonly invocationId: string; readonly agentName: string;
|
|
56
|
+
readonly version: 1; readonly sessionId: string; readonly invocationId: string; readonly agentName: string;
|
|
59
57
|
readonly tenant?: string; readonly state: AgentSessionStateV1; readonly revision: number; readonly steps: number; readonly stopRequested: boolean;
|
|
60
58
|
readonly resumeAllowed: boolean; readonly createdAt: string; readonly updatedAt: string; readonly outcome?: AgentSessionOutcomeV1;
|
|
61
59
|
}
|
|
@@ -74,7 +72,7 @@ export abstract class AgentSessions {
|
|
|
74
72
|
abstract readEvents(request: ReadAgentSessionEventsRequestV1, context: AgentSessionCallContextV1): Promise<AgentSessionEventPageV1>;
|
|
75
73
|
}
|
|
76
74
|
|
|
77
|
-
export interface AgentSessionAuthorizationTargetV1 { readonly sessionId: string; readonly ownerSubject: string; readonly tenant?: string; readonly agentName: string;
|
|
75
|
+
export interface AgentSessionAuthorizationTargetV1 { readonly sessionId: string; readonly ownerSubject: string; readonly tenant?: string; readonly agentName: string; }
|
|
78
76
|
export type AgentSessionAuthorizationRequestV1 =
|
|
79
77
|
| { readonly action: "create"; readonly principal: AgentSessionPrincipalV1; readonly candidate: AgentSessionAuthorizationTargetV1 }
|
|
80
78
|
| { readonly action: "run" | "read" | "read-events" | "stop" | "resume"; readonly principal: AgentSessionPrincipalV1; readonly session: AgentSessionAuthorizationTargetV1 & { readonly state: AgentSessionStateV1 } };
|
|
@@ -87,9 +85,9 @@ export interface AgentSessionOpenRequestV1 { readonly expectedSessionId: string;
|
|
|
87
85
|
export abstract class AgentSessionCheckpointProtectorV1 { abstract seal(request: AgentSessionSealRequestV1): Promise<AgentSessionSealedCheckpointV1>; abstract open(request: AgentSessionOpenRequestV1): Promise<string>; }
|
|
88
86
|
|
|
89
87
|
export interface AgentSessionModuleOptionsV1 {
|
|
90
|
-
readonly imports?: readonly BazisModuleRef[]; readonly
|
|
88
|
+
readonly imports?: readonly BazisModuleRef[]; readonly implementationVersion: string;
|
|
91
89
|
readonly admission: { readonly bucket: string; readonly maxActiveRuns?: number };
|
|
92
|
-
readonly execution?: { readonly providerCallTimeoutMs?: number; readonly
|
|
90
|
+
readonly execution?: { readonly providerCallTimeoutMs?: number; readonly toolExecutorOptions?: Pick<AgentToolExecutorOptions, "approvalPolicy" | "schemaValidator" | "auditSink" | "defaultTimeoutMs" | "scopeDisposeTimeoutMs" | "requiredPlatformHooks" | "hookRedaction">; };
|
|
93
91
|
readonly limits?: { readonly runTimeoutMs?: number; readonly maxSessionSteps?: number; readonly maxToolCallsPerStep?: number; readonly ownerLeaseMs?: number; readonly ownerHeartbeatMs?: number; readonly ownerStopGraceMs?: number; readonly authorizationTimeoutMs?: number; readonly checkpointProtectionTimeoutMs?: number; readonly databaseLockTimeoutMs?: number; readonly databaseStatementTimeoutMs?: number; readonly databaseWaitTimeoutMs?: number; readonly stopCheckIntervalMs?: number; readonly maxInputBytes?: number; readonly maxCheckpointBytes?: number; readonly maxJournalPayloadBytes?: number; readonly maxJournalEntries?: number; readonly reservedControlJournalEntries?: number; readonly defaultJournalPageSize?: number; readonly maxJournalPageSize?: number; };
|
|
94
92
|
}
|
|
95
93
|
export type AgentSessionErrorCodeV1 = `AGENT_SESSION_${"INVALID_REQUEST" | "FORBIDDEN" | "NOT_FOUND" | "CONFLICT" | "OWNER_ACTIVE" | "ADMISSION_UNAVAILABLE" | "NOT_RESUMABLE" | "DEADLINE_EXCEEDED" | "LIMIT_EXCEEDED" | "AMBIENT_TRANSACTION_FORBIDDEN" | "BINDING_MISMATCH" | "CHECKPOINT_UNAVAILABLE" | "CHECKPOINT_CORRUPT" | "OUTCOME_UNKNOWN" | "STORE_CORRUPT" | "STORE_UNAVAILABLE" | "AUTHORIZATION_UNAVAILABLE" | "HOST_STOPPING" | "UNSUPPORTED_VERSION" | "IDEMPOTENCY_CONFLICT" | "COMMIT_OUTCOME_UNKNOWN" | "CONFIG_MISMATCH"}`;
|
|
@@ -13,7 +13,6 @@ export class AgentSessionRowV1 {
|
|
|
13
13
|
@Column({ type: "text" }) ownerSubject = "";
|
|
14
14
|
@Column({ type: "text", nullable: true }) tenant?: string;
|
|
15
15
|
@Column({ type: "text" }) agentName = "";
|
|
16
|
-
@Column({ type: "text", nullable: true }) taskName?: string;
|
|
17
16
|
@Column({ type: "text" }) implementationVersion = "";
|
|
18
17
|
@Column({ type: "text" }) bindingHash = "";
|
|
19
18
|
@Column({ type: "text" }) state = "created";
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
# Cache Compatibility
|
|
2
2
|
|
|
3
|
-
The
|
|
4
|
-
|
|
3
|
+
The names below were removed; use the replacement. The `cached*` helpers were
|
|
4
|
+
public until 0.98.34, the others were removed in 0.96.1 before the first npm release.
|
|
5
5
|
|
|
6
6
|
| Removed name | Kind | Replacement |
|
|
7
7
|
| --- | --- | --- |
|
|
8
|
-
| `autoCachedScoped` | public
|
|
9
|
-
| `autoCachedSingleton` | public
|
|
8
|
+
| `autoCachedScoped`, `cachedScoped` | public helpers, removed in 0.98.34 | `scoped(...)`: the cache hook wraps it |
|
|
9
|
+
| `autoCachedSingleton`, `cachedSingleton` | public helpers, removed in 0.98.34 | `singleton(...)` |
|
|
10
10
|
| `warnInsecureOutputCacheRoute` | public alias | `guardInsecureOutputCacheRoute` |
|
|
11
11
|
| `warnOnAuthorizedRoutesWithoutVaryByUser` | config switch | `insecureAuthorizedRouteBehavior` (`false` was `"ignore"`) |
|
|
12
12
|
| `DEFAULT_CACHEABLE_METHODS` | internal alias | `DEFAULT_OUTPUT_CACHE_METHODS` |
|
package/core/cache/README.md
CHANGED
|
@@ -79,5 +79,5 @@ The `@/core/cache` core does not import Redis at all, only the
|
|
|
79
79
|
|
|
80
80
|
## Compatibility
|
|
81
81
|
|
|
82
|
-
|
|
83
|
-
|
|
82
|
+
Cached services are registered with the regular `scoped` / `singleton`; the cache
|
|
83
|
+
hook wraps them. Removed names are listed in [COMPATIBILITY.md](./COMPATIBILITY.md).
|