@voltagent/core 2.3.5 → 2.3.6

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/index.d.mts CHANGED
@@ -6757,6 +6757,7 @@ type WorkspaceSandboxExecuteOptions = {
6757
6757
  signal?: AbortSignal;
6758
6758
  onStdout?: (chunk: string) => void;
6759
6759
  onStderr?: (chunk: string) => void;
6760
+ operationContext?: OperationContext;
6760
6761
  };
6761
6762
  type WorkspaceSandboxStatus = "idle" | "ready" | "destroyed" | "error";
6762
6763
  type WorkspaceSandboxResult = {
@@ -6878,6 +6879,7 @@ type WorkspaceSearchOptions = {
6878
6879
  snippetLength?: number;
6879
6880
  lexicalWeight?: number;
6880
6881
  vectorWeight?: number;
6882
+ context?: WorkspaceFilesystemCallContext;
6881
6883
  };
6882
6884
  type WorkspaceSearchResult = {
6883
6885
  id: string;
@@ -6912,6 +6914,7 @@ type WorkspaceSkillSearchHybridWeights = {
6912
6914
  type WorkspaceSkillsRootResolverContext = {
6913
6915
  workspace: WorkspaceIdentity;
6914
6916
  filesystem: WorkspaceFilesystem;
6917
+ operationContext?: OperationContext;
6915
6918
  };
6916
6919
  type WorkspaceSkillsRootResolver = (context?: WorkspaceSkillsRootResolverContext) => string[] | undefined | null | Promise<string[] | undefined | null>;
6917
6920
  type WorkspaceSkillsConfig = {
@@ -6950,6 +6953,7 @@ type WorkspaceSkillSearchOptions = {
6950
6953
  snippetLength?: number;
6951
6954
  lexicalWeight?: number;
6952
6955
  vectorWeight?: number;
6956
+ context?: WorkspaceFilesystemCallContext;
6953
6957
  };
6954
6958
  type WorkspaceSkillSearchResult = {
6955
6959
  id: string;
@@ -7302,9 +7306,12 @@ declare class WorkspaceSearch {
7302
7306
  private ensureAutoIndex;
7303
7307
  indexPaths(paths?: Array<WorkspaceSearchIndexPath | string>, options?: {
7304
7308
  maxFileBytes?: number;
7309
+ context?: WorkspaceFilesystemCallContext;
7305
7310
  }): Promise<WorkspaceSearchIndexSummary>;
7306
7311
  indexDocuments(docs: WorkspaceSearchDocument[]): Promise<WorkspaceSearchIndexSummary>;
7307
- indexContent(path: string, content: string, metadata?: Record<string, unknown>): Promise<WorkspaceSearchIndexSummary>;
7312
+ indexContent(path: string, content: string, metadata?: Record<string, unknown>, _options?: {
7313
+ context?: WorkspaceFilesystemCallContext;
7314
+ }): Promise<WorkspaceSearchIndexSummary>;
7308
7315
  search(query: string, options?: WorkspaceSearchOptions): Promise<WorkspaceSearchResult[]>;
7309
7316
  private resolveMode;
7310
7317
  private searchVector;
@@ -7509,6 +7516,9 @@ type WorkspaceSkillsToolName = "workspace_list_skills" | "workspace_search_skill
7509
7516
  type WorkspaceSkillsPromptHookContext = {
7510
7517
  skills?: WorkspaceSkills;
7511
7518
  };
7519
+ type WorkspaceSkillsOperationOptions = {
7520
+ context?: WorkspaceFilesystemCallContext;
7521
+ };
7512
7522
  declare class WorkspaceSkills {
7513
7523
  private readonly filesystem;
7514
7524
  private readonly workspaceIdentity;
@@ -7548,22 +7558,25 @@ declare class WorkspaceSkills {
7548
7558
  private ensureIndexed;
7549
7559
  discoverSkills(options?: {
7550
7560
  refresh?: boolean;
7561
+ context?: WorkspaceFilesystemCallContext;
7551
7562
  }): Promise<WorkspaceSkillMetadata[]>;
7552
- loadSkill(identifier: string): Promise<WorkspaceSkill | null>;
7553
- activateSkill(identifier: string): Promise<WorkspaceSkillMetadata | null>;
7554
- deactivateSkill(identifier: string): Promise<boolean>;
7563
+ loadSkill(identifier: string, options?: WorkspaceSkillsOperationOptions): Promise<WorkspaceSkill | null>;
7564
+ activateSkill(identifier: string, options?: WorkspaceSkillsOperationOptions): Promise<WorkspaceSkillMetadata | null>;
7565
+ deactivateSkill(identifier: string, options?: WorkspaceSkillsOperationOptions): Promise<boolean>;
7555
7566
  getActiveSkills(): WorkspaceSkillMetadata[];
7556
- indexSkills(): Promise<WorkspaceSkillIndexSummary>;
7567
+ indexSkills(options?: WorkspaceSkillsOperationOptions): Promise<WorkspaceSkillIndexSummary>;
7557
7568
  search(query: string, options?: WorkspaceSkillSearchOptions): Promise<WorkspaceSkillSearchResult[]>;
7558
- buildPrompt(options?: WorkspaceSkillsPromptOptions): Promise<string | null>;
7569
+ buildPrompt(options?: WorkspaceSkillsPromptOptions & {
7570
+ context?: WorkspaceFilesystemCallContext;
7571
+ }): Promise<string | null>;
7559
7572
  private resolveMode;
7560
7573
  private searchVector;
7561
7574
  private formatResults;
7562
7575
  private resolveSkillId;
7563
7576
  resolveSkillFilePath(skill: WorkspaceSkillMetadata, relativePath: string, allowed: string[] | undefined): string | null;
7564
- readFileContent(filePath: string): Promise<string>;
7577
+ readFileContent(filePath: string, options?: WorkspaceSkillsOperationOptions): Promise<string>;
7565
7578
  }
7566
- declare const createWorkspaceSkillsPromptHook: (context: WorkspaceSkillsPromptHookContext, options?: WorkspaceSkillsPromptOptions) => AgentHooks;
7579
+ declare const createWorkspaceSkillsPromptHook: (hookContext: WorkspaceSkillsPromptHookContext, options?: WorkspaceSkillsPromptOptions) => AgentHooks;
7567
7580
  declare const createWorkspaceSkillsToolkit: (context: WorkspaceSkillsToolkitContext, options?: WorkspaceSkillsToolkitOptions) => Toolkit;
7568
7581
 
7569
7582
  declare class Workspace {
package/dist/index.d.ts CHANGED
@@ -6757,6 +6757,7 @@ type WorkspaceSandboxExecuteOptions = {
6757
6757
  signal?: AbortSignal;
6758
6758
  onStdout?: (chunk: string) => void;
6759
6759
  onStderr?: (chunk: string) => void;
6760
+ operationContext?: OperationContext;
6760
6761
  };
6761
6762
  type WorkspaceSandboxStatus = "idle" | "ready" | "destroyed" | "error";
6762
6763
  type WorkspaceSandboxResult = {
@@ -6878,6 +6879,7 @@ type WorkspaceSearchOptions = {
6878
6879
  snippetLength?: number;
6879
6880
  lexicalWeight?: number;
6880
6881
  vectorWeight?: number;
6882
+ context?: WorkspaceFilesystemCallContext;
6881
6883
  };
6882
6884
  type WorkspaceSearchResult = {
6883
6885
  id: string;
@@ -6912,6 +6914,7 @@ type WorkspaceSkillSearchHybridWeights = {
6912
6914
  type WorkspaceSkillsRootResolverContext = {
6913
6915
  workspace: WorkspaceIdentity;
6914
6916
  filesystem: WorkspaceFilesystem;
6917
+ operationContext?: OperationContext;
6915
6918
  };
6916
6919
  type WorkspaceSkillsRootResolver = (context?: WorkspaceSkillsRootResolverContext) => string[] | undefined | null | Promise<string[] | undefined | null>;
6917
6920
  type WorkspaceSkillsConfig = {
@@ -6950,6 +6953,7 @@ type WorkspaceSkillSearchOptions = {
6950
6953
  snippetLength?: number;
6951
6954
  lexicalWeight?: number;
6952
6955
  vectorWeight?: number;
6956
+ context?: WorkspaceFilesystemCallContext;
6953
6957
  };
6954
6958
  type WorkspaceSkillSearchResult = {
6955
6959
  id: string;
@@ -7302,9 +7306,12 @@ declare class WorkspaceSearch {
7302
7306
  private ensureAutoIndex;
7303
7307
  indexPaths(paths?: Array<WorkspaceSearchIndexPath | string>, options?: {
7304
7308
  maxFileBytes?: number;
7309
+ context?: WorkspaceFilesystemCallContext;
7305
7310
  }): Promise<WorkspaceSearchIndexSummary>;
7306
7311
  indexDocuments(docs: WorkspaceSearchDocument[]): Promise<WorkspaceSearchIndexSummary>;
7307
- indexContent(path: string, content: string, metadata?: Record<string, unknown>): Promise<WorkspaceSearchIndexSummary>;
7312
+ indexContent(path: string, content: string, metadata?: Record<string, unknown>, _options?: {
7313
+ context?: WorkspaceFilesystemCallContext;
7314
+ }): Promise<WorkspaceSearchIndexSummary>;
7308
7315
  search(query: string, options?: WorkspaceSearchOptions): Promise<WorkspaceSearchResult[]>;
7309
7316
  private resolveMode;
7310
7317
  private searchVector;
@@ -7509,6 +7516,9 @@ type WorkspaceSkillsToolName = "workspace_list_skills" | "workspace_search_skill
7509
7516
  type WorkspaceSkillsPromptHookContext = {
7510
7517
  skills?: WorkspaceSkills;
7511
7518
  };
7519
+ type WorkspaceSkillsOperationOptions = {
7520
+ context?: WorkspaceFilesystemCallContext;
7521
+ };
7512
7522
  declare class WorkspaceSkills {
7513
7523
  private readonly filesystem;
7514
7524
  private readonly workspaceIdentity;
@@ -7548,22 +7558,25 @@ declare class WorkspaceSkills {
7548
7558
  private ensureIndexed;
7549
7559
  discoverSkills(options?: {
7550
7560
  refresh?: boolean;
7561
+ context?: WorkspaceFilesystemCallContext;
7551
7562
  }): Promise<WorkspaceSkillMetadata[]>;
7552
- loadSkill(identifier: string): Promise<WorkspaceSkill | null>;
7553
- activateSkill(identifier: string): Promise<WorkspaceSkillMetadata | null>;
7554
- deactivateSkill(identifier: string): Promise<boolean>;
7563
+ loadSkill(identifier: string, options?: WorkspaceSkillsOperationOptions): Promise<WorkspaceSkill | null>;
7564
+ activateSkill(identifier: string, options?: WorkspaceSkillsOperationOptions): Promise<WorkspaceSkillMetadata | null>;
7565
+ deactivateSkill(identifier: string, options?: WorkspaceSkillsOperationOptions): Promise<boolean>;
7555
7566
  getActiveSkills(): WorkspaceSkillMetadata[];
7556
- indexSkills(): Promise<WorkspaceSkillIndexSummary>;
7567
+ indexSkills(options?: WorkspaceSkillsOperationOptions): Promise<WorkspaceSkillIndexSummary>;
7557
7568
  search(query: string, options?: WorkspaceSkillSearchOptions): Promise<WorkspaceSkillSearchResult[]>;
7558
- buildPrompt(options?: WorkspaceSkillsPromptOptions): Promise<string | null>;
7569
+ buildPrompt(options?: WorkspaceSkillsPromptOptions & {
7570
+ context?: WorkspaceFilesystemCallContext;
7571
+ }): Promise<string | null>;
7559
7572
  private resolveMode;
7560
7573
  private searchVector;
7561
7574
  private formatResults;
7562
7575
  private resolveSkillId;
7563
7576
  resolveSkillFilePath(skill: WorkspaceSkillMetadata, relativePath: string, allowed: string[] | undefined): string | null;
7564
- readFileContent(filePath: string): Promise<string>;
7577
+ readFileContent(filePath: string, options?: WorkspaceSkillsOperationOptions): Promise<string>;
7565
7578
  }
7566
- declare const createWorkspaceSkillsPromptHook: (context: WorkspaceSkillsPromptHookContext, options?: WorkspaceSkillsPromptOptions) => AgentHooks;
7579
+ declare const createWorkspaceSkillsPromptHook: (hookContext: WorkspaceSkillsPromptHookContext, options?: WorkspaceSkillsPromptOptions) => AgentHooks;
7567
7580
  declare const createWorkspaceSkillsToolkit: (context: WorkspaceSkillsToolkitContext, options?: WorkspaceSkillsToolkitOptions) => Toolkit;
7568
7581
 
7569
7582
  declare class Workspace {
package/dist/index.js CHANGED
@@ -19985,7 +19985,8 @@ var createWorkspaceSandboxToolkit = /* @__PURE__ */ __name((context8, options =
19985
19985
  timeoutMs: input.timeout_ms,
19986
19986
  maxOutputBytes: input.max_output_bytes,
19987
19987
  stdin: input.stdin,
19988
- signal: operationContext.abortController?.signal
19988
+ signal: operationContext.abortController?.signal,
19989
+ operationContext
19989
19990
  });
19990
19991
  setWorkspaceSpanAttributes2(operationContext, {
19991
19992
  "workspace.sandbox.exit_code": result.exitCode ?? void 0
@@ -20345,12 +20346,12 @@ var WorkspaceSearch = class {
20345
20346
  getInstructions() {
20346
20347
  return WORKSPACE_SEARCH_SYSTEM_PROMPT;
20347
20348
  }
20348
- async ensureAutoIndex() {
20349
+ async ensureAutoIndex(context8) {
20349
20350
  if (!this.autoIndexPaths || this.autoIndexPaths.length === 0) {
20350
20351
  return;
20351
20352
  }
20352
20353
  if (!this.autoIndexPromise) {
20353
- this.autoIndexPromise = this.indexPaths(this.autoIndexPaths).then(() => void 0).catch((error) => {
20354
+ this.autoIndexPromise = this.indexPaths(this.autoIndexPaths, { context: context8 }).then(() => void 0).catch((error) => {
20354
20355
  console.error("Workspace search auto-index failed:", error);
20355
20356
  return void 0;
20356
20357
  });
@@ -20375,7 +20376,9 @@ var WorkspaceSearch = class {
20375
20376
  const glob = target.glob ?? "**/*";
20376
20377
  let infos;
20377
20378
  try {
20378
- infos = await this.filesystem.globInfo(glob, basePath);
20379
+ infos = await this.filesystem.globInfo(glob, basePath, {
20380
+ context: options?.context
20381
+ });
20379
20382
  } catch (error) {
20380
20383
  summary.errors.push(
20381
20384
  `Failed to glob ${basePath}: ${error?.message ? String(error.message) : "unknown error"}`
@@ -20389,7 +20392,9 @@ var WorkspaceSearch = class {
20389
20392
  continue;
20390
20393
  }
20391
20394
  try {
20392
- const data = await this.filesystem.readRaw(info.path);
20395
+ const data = await this.filesystem.readRaw(info.path, {
20396
+ context: options?.context
20397
+ });
20393
20398
  const content = data.content.join("\n");
20394
20399
  const contentBytes = Buffer.byteLength(content, "utf-8");
20395
20400
  if (maxFileBytes > 0 && contentBytes > maxFileBytes) {
@@ -20461,7 +20466,7 @@ var WorkspaceSearch = class {
20461
20466
  }
20462
20467
  return summary;
20463
20468
  }
20464
- async indexContent(path6, content, metadata) {
20469
+ async indexContent(path6, content, metadata, _options) {
20465
20470
  const normalizedPath = normalizeDocumentPath(path6);
20466
20471
  return this.indexDocuments([
20467
20472
  {
@@ -20473,7 +20478,7 @@ var WorkspaceSearch = class {
20473
20478
  ]);
20474
20479
  }
20475
20480
  async search(query, options = {}) {
20476
- await this.ensureAutoIndex();
20481
+ await this.ensureAutoIndex(options.context);
20477
20482
  const mode = this.resolveMode(options.mode);
20478
20483
  const topK = options.topK ?? DEFAULT_TOP_K;
20479
20484
  const basePath = normalizePath(options.path);
@@ -20728,7 +20733,10 @@ var createWorkspaceSearchToolkit = /* @__PURE__ */ __name((context8, options = {
20728
20733
  }
20729
20734
  const summary = await context8.search.indexPaths(
20730
20735
  [{ path: input.path || "/", glob: input.glob }],
20731
- { maxFileBytes: input.max_file_bytes }
20736
+ {
20737
+ maxFileBytes: input.max_file_bytes,
20738
+ context: { agent: context8.agent, operationContext }
20739
+ }
20732
20740
  );
20733
20741
  setWorkspaceSpanAttributes3(operationContext, {
20734
20742
  "workspace.search.results": summary.indexed
@@ -20763,7 +20771,8 @@ var createWorkspaceSearchToolkit = /* @__PURE__ */ __name((context8, options = {
20763
20771
  const summary = await context8.search.indexContent(
20764
20772
  input.path,
20765
20773
  input.content,
20766
- input.metadata
20774
+ input.metadata,
20775
+ { context: { agent: context8.agent, operationContext } }
20767
20776
  );
20768
20777
  setWorkspaceSpanAttributes3(operationContext, {
20769
20778
  "workspace.search.results": summary.indexed
@@ -20826,7 +20835,8 @@ var createWorkspaceSearchToolkit = /* @__PURE__ */ __name((context8, options = {
20826
20835
  glob: input.glob,
20827
20836
  snippetLength: input.snippet_length,
20828
20837
  lexicalWeight: input.lexical_weight,
20829
- vectorWeight: input.vector_weight
20838
+ vectorWeight: input.vector_weight,
20839
+ context: { agent: context8.agent, operationContext }
20830
20840
  });
20831
20841
  setWorkspaceSpanAttributes3(operationContext, {
20832
20842
  "workspace.search.results": results.length
@@ -21191,12 +21201,12 @@ var WorkspaceSkills = class {
21191
21201
  getInstructions() {
21192
21202
  return SKILLS_SYSTEM_PROMPT;
21193
21203
  }
21194
- async ensureDiscovered() {
21204
+ async ensureDiscovered(options = {}) {
21195
21205
  if (this.discovered) {
21196
21206
  return;
21197
21207
  }
21198
21208
  if (!this.autoDiscoverPromise) {
21199
- const promise2 = this.discoverSkills().then(() => void 0);
21209
+ const promise2 = this.discoverSkills({ context: options.context }).then(() => void 0);
21200
21210
  this.autoDiscoverPromise = promise2;
21201
21211
  promise2.catch(() => {
21202
21212
  if (this.autoDiscoverPromise === promise2) {
@@ -21214,7 +21224,7 @@ var WorkspaceSkills = class {
21214
21224
  throw error;
21215
21225
  }
21216
21226
  }
21217
- async ensureRootPaths() {
21227
+ async ensureRootPaths(options = {}) {
21218
21228
  if (this.rootResolved) {
21219
21229
  return;
21220
21230
  }
@@ -21230,7 +21240,8 @@ var WorkspaceSkills = class {
21230
21240
  try {
21231
21241
  const resolved = await this.rootResolver?.({
21232
21242
  workspace: this.workspaceIdentity,
21233
- filesystem: this.filesystem
21243
+ filesystem: this.filesystem,
21244
+ operationContext: options.context?.operationContext
21234
21245
  });
21235
21246
  const normalized = normalizeStringArray2(resolved) ?? DEFAULT_SKILL_ROOTS;
21236
21247
  this.rootPaths = normalized.map(normalizeRootPath);
@@ -21243,12 +21254,12 @@ var WorkspaceSkills = class {
21243
21254
  }
21244
21255
  await this.rootResolvePromise;
21245
21256
  }
21246
- async ensureIndexed() {
21257
+ async ensureIndexed(options = {}) {
21247
21258
  if (this.indexed) {
21248
21259
  return;
21249
21260
  }
21250
21261
  if (!this.autoIndexPromise) {
21251
- const promise2 = this.indexSkills().then(() => void 0);
21262
+ const promise2 = this.indexSkills({ context: options.context }).then(() => void 0);
21252
21263
  this.autoIndexPromise = promise2;
21253
21264
  promise2.catch(() => {
21254
21265
  if (this.autoIndexPromise === promise2) {
@@ -21270,7 +21281,7 @@ var WorkspaceSkills = class {
21270
21281
  if (this.discovered && !options.refresh) {
21271
21282
  return Array.from(this.skillsById.values());
21272
21283
  }
21273
- await this.ensureRootPaths();
21284
+ await this.ensureRootPaths({ context: options.context });
21274
21285
  this.skillsById.clear();
21275
21286
  this.skillNameMap.clear();
21276
21287
  this.skillCache.clear();
@@ -21281,7 +21292,9 @@ var WorkspaceSkills = class {
21281
21292
  for (const root of this.rootPaths) {
21282
21293
  let infos;
21283
21294
  try {
21284
- infos = await this.filesystem.globInfo(this.glob, root);
21295
+ infos = await this.filesystem.globInfo(this.glob, root, {
21296
+ context: options.context
21297
+ });
21285
21298
  } catch {
21286
21299
  continue;
21287
21300
  }
@@ -21291,7 +21304,9 @@ var WorkspaceSkills = class {
21291
21304
  continue;
21292
21305
  }
21293
21306
  try {
21294
- const data = await this.filesystem.readRaw(skillPath);
21307
+ const data = await this.filesystem.readRaw(skillPath, {
21308
+ context: options.context
21309
+ });
21295
21310
  const content = data.content.join("\n");
21296
21311
  const contentBytes = Buffer.byteLength(content, "utf-8");
21297
21312
  if (this.maxFileBytes > 0 && contentBytes > this.maxFileBytes) {
@@ -21336,8 +21351,8 @@ var WorkspaceSkills = class {
21336
21351
  this.discovered = true;
21337
21352
  return Array.from(this.skillsById.values());
21338
21353
  }
21339
- async loadSkill(identifier) {
21340
- await this.ensureDiscovered();
21354
+ async loadSkill(identifier, options = {}) {
21355
+ await this.ensureDiscovered({ context: options.context });
21341
21356
  const id = this.resolveSkillId(identifier);
21342
21357
  if (!id) {
21343
21358
  return null;
@@ -21350,7 +21365,9 @@ var WorkspaceSkills = class {
21350
21365
  if (!metadata) {
21351
21366
  return null;
21352
21367
  }
21353
- const data = await this.filesystem.readRaw(metadata.path);
21368
+ const data = await this.filesystem.readRaw(metadata.path, {
21369
+ context: options.context
21370
+ });
21354
21371
  const content = data.content.join("\n");
21355
21372
  const { data: frontmatter, instructions } = parseSkillFile(content);
21356
21373
  const detail = {
@@ -21366,8 +21383,8 @@ var WorkspaceSkills = class {
21366
21383
  this.skillCache.set(id, detail);
21367
21384
  return detail;
21368
21385
  }
21369
- async activateSkill(identifier) {
21370
- await this.ensureDiscovered();
21386
+ async activateSkill(identifier, options = {}) {
21387
+ await this.ensureDiscovered({ context: options.context });
21371
21388
  const id = this.resolveSkillId(identifier);
21372
21389
  if (!id) {
21373
21390
  return null;
@@ -21375,8 +21392,8 @@ var WorkspaceSkills = class {
21375
21392
  this.activeSkills.add(id);
21376
21393
  return this.skillsById.get(id) ?? null;
21377
21394
  }
21378
- async deactivateSkill(identifier) {
21379
- await this.ensureDiscovered();
21395
+ async deactivateSkill(identifier, options = {}) {
21396
+ await this.ensureDiscovered({ context: options.context });
21380
21397
  const id = this.resolveSkillId(identifier);
21381
21398
  if (!id) {
21382
21399
  return false;
@@ -21386,8 +21403,8 @@ var WorkspaceSkills = class {
21386
21403
  getActiveSkills() {
21387
21404
  return Array.from(this.activeSkills).map((id) => this.skillsById.get(id)).filter((skill) => Boolean(skill));
21388
21405
  }
21389
- async indexSkills() {
21390
- await this.ensureDiscovered();
21406
+ async indexSkills(options = {}) {
21407
+ await this.ensureDiscovered({ context: options.context });
21391
21408
  const summary = {
21392
21409
  indexed: 0,
21393
21410
  skipped: 0,
@@ -21413,7 +21430,7 @@ var WorkspaceSkills = class {
21413
21430
  const docs = [];
21414
21431
  for (const metadata of this.skillsById.values()) {
21415
21432
  try {
21416
- const skill = await this.loadSkill(metadata.id);
21433
+ const skill = await this.loadSkill(metadata.id, { context: options.context });
21417
21434
  if (!skill) {
21418
21435
  summary.skipped += 1;
21419
21436
  continue;
@@ -21486,7 +21503,7 @@ var WorkspaceSkills = class {
21486
21503
  return summary;
21487
21504
  }
21488
21505
  async search(query, options = {}) {
21489
- await this.ensureIndexed();
21506
+ await this.ensureIndexed({ context: options.context });
21490
21507
  const mode = this.resolveMode(options.mode);
21491
21508
  const topK = options.topK ?? DEFAULT_TOP_K2;
21492
21509
  const snippetLength = options.snippetLength ?? DEFAULT_SNIPPET_LENGTH2;
@@ -21546,7 +21563,7 @@ var WorkspaceSkills = class {
21546
21563
  );
21547
21564
  }
21548
21565
  async buildPrompt(options = {}) {
21549
- await this.ensureDiscovered();
21566
+ await this.ensureDiscovered({ context: options.context });
21550
21567
  const includeAvailable = options.includeAvailable ?? true;
21551
21568
  const includeActivated = options.includeActivated ?? true;
21552
21569
  const maxAvailable = options.maxAvailable ?? DEFAULT_MAX_AVAILABLE;
@@ -21570,7 +21587,7 @@ ${lines.join("\n")}`);
21570
21587
  if (activeIds.length > 0) {
21571
21588
  const entries = [];
21572
21589
  for (const id of activeIds) {
21573
- const skill = await this.loadSkill(id);
21590
+ const skill = await this.loadSkill(id, { context: options.context });
21574
21591
  if (!skill) {
21575
21592
  continue;
21576
21593
  }
@@ -21669,17 +21686,26 @@ ${sections.join("\n\n")}
21669
21686
  }
21670
21687
  return joinPaths(skill.root, cleaned);
21671
21688
  }
21672
- async readFileContent(filePath) {
21673
- const data = await this.filesystem.readRaw(filePath);
21689
+ async readFileContent(filePath, options = {}) {
21690
+ const data = await this.filesystem.readRaw(filePath, {
21691
+ context: options.context
21692
+ });
21674
21693
  return data.content.join("\n");
21675
21694
  }
21676
21695
  };
21677
- var createWorkspaceSkillsPromptHook = /* @__PURE__ */ __name((context8, options = {}) => ({
21678
- onPrepareMessages: /* @__PURE__ */ __name(async ({ messages }) => {
21679
- if (!context8.skills) {
21696
+ var createWorkspaceSkillsPromptHook = /* @__PURE__ */ __name((hookContext, options = {}) => ({
21697
+ onPrepareMessages: /* @__PURE__ */ __name(async ({
21698
+ messages,
21699
+ context: operationContext,
21700
+ agent
21701
+ }) => {
21702
+ if (!hookContext.skills) {
21680
21703
  return { messages };
21681
21704
  }
21682
- const prompt = await context8.skills.buildPrompt(options);
21705
+ const prompt = await hookContext.skills.buildPrompt({
21706
+ ...options,
21707
+ context: { agent, operationContext }
21708
+ });
21683
21709
  if (!prompt) {
21684
21710
  return { messages };
21685
21711
  }
@@ -21727,7 +21753,10 @@ var createWorkspaceSkillsToolkit = /* @__PURE__ */ __name((context8, options = {
21727
21753
  if (!context8.skills) {
21728
21754
  return "Workspace skills are not configured.";
21729
21755
  }
21730
- const skills = await context8.skills.discoverSkills({ refresh: Boolean(input.refresh) });
21756
+ const skills = await context8.skills.discoverSkills({
21757
+ refresh: Boolean(input.refresh),
21758
+ context: { agent: context8.agent, operationContext }
21759
+ });
21731
21760
  const activeIds = new Set(context8.skills.getActiveSkills().map((skill) => skill.id));
21732
21761
  const listed = input.active_only ? skills.filter((skill) => activeIds.has(skill.id)) : skills;
21733
21762
  return formatSkillList(listed, activeIds);
@@ -21768,7 +21797,8 @@ var createWorkspaceSkillsToolkit = /* @__PURE__ */ __name((context8, options = {
21768
21797
  topK: input.top_k,
21769
21798
  snippetLength: input.snippet_length,
21770
21799
  lexicalWeight: input.lexical_weight,
21771
- vectorWeight: input.vector_weight
21800
+ vectorWeight: input.vector_weight,
21801
+ context: { agent: context8.agent, operationContext }
21772
21802
  });
21773
21803
  setWorkspaceSpanAttributes4(operationContext, {
21774
21804
  "workspace.search.results": results.length
@@ -21802,7 +21832,9 @@ var createWorkspaceSkillsToolkit = /* @__PURE__ */ __name((context8, options = {
21802
21832
  if (!context8.skills) {
21803
21833
  return "Workspace skills are not configured.";
21804
21834
  }
21805
- const skill = await context8.skills.loadSkill(input.skill_id);
21835
+ const skill = await context8.skills.loadSkill(input.skill_id, {
21836
+ context: { agent: context8.agent, operationContext }
21837
+ });
21806
21838
  if (!skill) {
21807
21839
  return `Skill not found: ${input.skill_id}`;
21808
21840
  }
@@ -21835,7 +21867,9 @@ var createWorkspaceSkillsToolkit = /* @__PURE__ */ __name((context8, options = {
21835
21867
  if (!context8.skills) {
21836
21868
  return "Workspace skills are not configured.";
21837
21869
  }
21838
- const skill = await context8.skills.activateSkill(input.skill_id);
21870
+ const skill = await context8.skills.activateSkill(input.skill_id, {
21871
+ context: { agent: context8.agent, operationContext }
21872
+ });
21839
21873
  if (!skill) {
21840
21874
  return `Skill not found: ${input.skill_id}`;
21841
21875
  }
@@ -21868,7 +21902,9 @@ var createWorkspaceSkillsToolkit = /* @__PURE__ */ __name((context8, options = {
21868
21902
  if (!context8.skills) {
21869
21903
  return "Workspace skills are not configured.";
21870
21904
  }
21871
- const success = await context8.skills.deactivateSkill(input.skill_id);
21905
+ const success = await context8.skills.deactivateSkill(input.skill_id, {
21906
+ context: { agent: context8.agent, operationContext }
21907
+ });
21872
21908
  if (!success) {
21873
21909
  return `Skill not found: ${input.skill_id}`;
21874
21910
  }
@@ -21888,7 +21924,9 @@ var createWorkspaceSkillsToolkit = /* @__PURE__ */ __name((context8, options = {
21888
21924
  if (!context8.skills) {
21889
21925
  return "Workspace skills are not configured.";
21890
21926
  }
21891
- const skill = await context8.skills.loadSkill(skillId);
21927
+ const skill = await context8.skills.loadSkill(skillId, {
21928
+ context: { agent: context8.agent, operationContext }
21929
+ });
21892
21930
  if (!skill) {
21893
21931
  return `Skill not found: ${skillId}`;
21894
21932
  }
@@ -21904,7 +21942,9 @@ var createWorkspaceSkillsToolkit = /* @__PURE__ */ __name((context8, options = {
21904
21942
  "workspace.fs.path": resolvedPath
21905
21943
  });
21906
21944
  try {
21907
- const content = await context8.skills.readFileContent(resolvedPath);
21945
+ const content = await context8.skills.readFileContent(resolvedPath, {
21946
+ context: { agent: context8.agent, operationContext }
21947
+ });
21908
21948
  return content || "(empty)";
21909
21949
  } catch (error) {
21910
21950
  const message = error instanceof Error ? error.message : String(error);
@@ -27607,7 +27647,8 @@ Context: ${(0, import_utils32.safeStringify)(contextObj, { indentation: 2 })}`;
27607
27647
  currentHistoryEntryId,
27608
27648
  maxSteps,
27609
27649
  conversationId,
27610
- userId
27650
+ userId,
27651
+ parentToolSpan
27611
27652
  } = options;
27612
27653
  return createTool({
27613
27654
  id: "delegate_task",
@@ -27618,8 +27659,8 @@ Context: ${(0, import_utils32.safeStringify)(contextObj, { indentation: 2 })}`;
27618
27659
  targetAgents: import_zod6.z.array(import_zod6.z.string()).describe("List of agent names to delegate the task to"),
27619
27660
  context: import_zod6.z.record(import_zod6.z.string(), import_zod6.z.any()).optional().describe("Additional context for the task")
27620
27661
  }),
27621
- execute: /* @__PURE__ */ __name(async ({ task, targetAgents, context: context8 = {} }, options2) => {
27622
- const currentOperationContext = options2;
27662
+ execute: /* @__PURE__ */ __name(async ({ task, targetAgents, context: context8 = {} }, executeOptions) => {
27663
+ const currentOperationContext = executeOptions;
27623
27664
  const effectiveOperationContext = currentOperationContext || operationContext;
27624
27665
  const logger = effectiveOperationContext?.logger || getGlobalLogger().child({ component: "subagent-manager" });
27625
27666
  try {
@@ -27664,7 +27705,7 @@ Context: ${(0, import_utils32.safeStringify)(contextObj, { indentation: 2 })}`;
27664
27705
  // Pass maxSteps from parent to subagents
27665
27706
  maxSteps,
27666
27707
  // Pass the parentToolSpan from executeOptions for proper span hierarchy
27667
- parentSpan: effectiveOperationContext?.systemContext?.get("parentToolSpan")
27708
+ parentSpan: executeOptions?.parentToolSpan || parentToolSpan || effectiveOperationContext?.systemContext?.get("parentToolSpan")
27668
27709
  });
27669
27710
  const structuredResults = results.map((result, index) => {
27670
27711
  return {
@@ -31429,7 +31470,7 @@ ${retrieverContext}`;
31429
31470
  });
31430
31471
  oc.systemContext.set("agentId", this.id);
31431
31472
  oc.systemContext.set("historyEntryId", oc.operationId);
31432
- oc.systemContext.set("parentToolSpan", toolSpan);
31473
+ executionOptions.parentToolSpan = toolSpan;
31433
31474
  const hasOutputOverride = /* @__PURE__ */ __name((value) => {
31434
31475
  if (!value || typeof value !== "object") {
31435
31476
  return false;
@@ -31798,7 +31839,7 @@ ${retrieverContext}`;
31798
31839
  topK ?? toolRouting?.topK ?? embeddingTopK ?? DEFAULT_TOOL_SEARCH_TOP_K
31799
31840
  );
31800
31841
  const candidates = this.buildToolSearchCandidates();
31801
- const parentToolSpan = oc.systemContext.get("parentToolSpan");
31842
+ const parentToolSpan = options.parentToolSpan || oc.systemContext.get("parentToolSpan");
31802
31843
  const selectionSpanAttributes = {
31803
31844
  "tool.name": TOOL_ROUTING_SEARCH_TOOL_NAME,
31804
31845
  "tool.search.name": TOOL_ROUTING_SEARCH_TOOL_NAME,
@@ -33709,7 +33750,7 @@ function createPlanningToolkit(agent, options = {}) {
33709
33750
  });
33710
33751
  await resolvedBackend.setTodos(guardedTodos);
33711
33752
  operationContext.systemContext.set(PLAN_PROGRESS_CONTEXT_KEY, false);
33712
- const toolSpan = operationContext.systemContext.get("parentToolSpan");
33753
+ const toolSpan = executeOptions.parentToolSpan || operationContext.systemContext.get("parentToolSpan");
33713
33754
  if (toolSpan) {
33714
33755
  const pendingCount = guardedTodos.filter((todo) => todo.status === "pending").length;
33715
33756
  const inProgressCount = guardedTodos.filter((todo) => todo.status === "in_progress").length;
@@ -34275,7 +34316,7 @@ function createTaskToolkit(options) {
34275
34316
  }),
34276
34317
  execute: /* @__PURE__ */ __name(async (input, executeOptions) => {
34277
34318
  const operationContext = executeOptions;
34278
- const toolSpan = operationContext.systemContext.get("parentToolSpan");
34319
+ const toolSpan = executeOptions.parentToolSpan || operationContext.systemContext.get("parentToolSpan");
34279
34320
  if (toolSpan) {
34280
34321
  toolSpan.setAttribute("voltagent.label", `task:${input.subagent_type}`);
34281
34322
  toolSpan.setAttribute("planagent.task.subagent_type", input.subagent_type);
@@ -34295,7 +34336,7 @@ function createTaskToolkit(options) {
34295
34336
  conversationId: operationContext.conversationId,
34296
34337
  parentOperationContext: operationContext,
34297
34338
  maxSteps: taskOptions?.maxSteps,
34298
- parentSpan: operationContext.systemContext.get("parentToolSpan")
34339
+ parentSpan: toolSpan
34299
34340
  });
34300
34341
  if (toolSpan) {
34301
34342
  const responsePreview = typeof result.result === "string" ? truncateText3(result.result, 500) : truncateText3((0, import_utils38.safeStringify)(result.result), 500);
@@ -36482,7 +36523,7 @@ var createRetrieverTool = /* @__PURE__ */ __name((retriever, options = {}) => {
36482
36523
  }),
36483
36524
  execute: /* @__PURE__ */ __name(async ({ query }, options2) => {
36484
36525
  const startTime = Date.now();
36485
- const toolSpan = options2?.systemContext?.get("parentToolSpan");
36526
+ const toolSpan = options2?.parentToolSpan || options2?.systemContext?.get("parentToolSpan");
36486
36527
  const normalizeAttributeValue3 = /* @__PURE__ */ __name((value) => {
36487
36528
  if (value === null || value === void 0) return null;
36488
36529
  if (typeof value === "string" || typeof value === "number" || typeof value === "boolean") {