@dudousxd/nestjs-agent-core 0.18.0 → 0.19.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/dist/index.d.cts CHANGED
@@ -1,5 +1,5 @@
1
- import { M as ModelMessage, a as ToolDefinition, b as ToolCallRequest, c as MessageUsage, d as AgentUiComponent, A as Actor, e as ThreadSummary, f as ThreadDetail, S as StoredMessage, g as ToolResult, h as MessageAttachment, i as ToolCallStatus, U as UsagePurpose, j as ToolSpec, Q as QuotaState, k as AgentRunInput, H as HumanReply, T as ToolHandler, l as HistoryPolicy, O as OutputProcessor, P as ProcessorContext, I as InputProcessor, m as ProcessedPrompt, n as ModelAnswer, o as PageContext, p as AgentDefinition, q as AgentDelegation, D as DetachedDelivery, r as AiToolCtx, s as PromptBuilder, t as PromptContributor, u as ToolTransientRetrySetting, v as AgentIntake, w as Decision, E as ElicitationRequest, L as LlmStepEnvelope, x as ToolStepEnvelope } from './tool-CHIw-aTx.cjs';
2
- export { y as ASK_TOOL_DESCRIPTION, z as ASK_TOOL_NAME, B as AgentApprovalRequest, C as AgentCatalogEntry, F as AgentHistoryWindow, G as AgentStreamEvent, J as AskToolInput, K as DEFAULT_INCREMENTAL_LOOKBACK_CHARS, N as DEFAULT_INTAKE_PREAMBLE, R as DEFAULT_TOOL_TRANSIENT_RETRY_ATTEMPTS, V as DEFAULT_TOOL_TRANSIENT_RETRY_BACKOFF_MS, W as ElicitationOption, X as ElicitationOutcome, Y as ElicitationQuestion, Z as ElicitationReply, _ as ElicitationResult, $ as HistoryPolicyContext, a0 as HistorySelection, a1 as HistorySummary, a2 as IncrementalGating, a3 as InvokeWithTransientRetryOptions, a4 as MAX_ASK_QUESTIONS, a5 as MessageRole, a6 as OutputRejectedError, a7 as OutputVerdict, a8 as ProcessorFailedError, a9 as PromptContext, aa as QuotaView, ab as ToolKind, ac as ToolStepCtx, ad as ToolTransientRetryNumbers, ae as ToolTransientRetryOptions, af as askInputSchema, ag as askToolDefinition, ah as decodeStreamEvent, ai as encodeStreamEvent, aj as invokeWithTransientRetry, ak as isTransientToolError, al as normalizeElicitationReply, am as renderElicitationAnswers, an as resolveElicitation, ao as resolveToolTransientRetryNumbers, ap as settleElicitation } from './tool-CHIw-aTx.cjs';
1
+ import { M as ModelMessage, a as ToolDefinition, b as ToolCallRequest, c as MessageUsage, d as AgentUiComponent, A as Actor, e as ThreadSummary, f as ThreadDetail, S as StoredMessage, g as ToolResult, h as MessageAttachment, i as ToolCallStatus, U as UsagePurpose, j as ToolSpec, Q as QuotaState, k as AgentRunInput, H as HumanReply, T as ToolHandler, l as HistoryPolicy, O as OutputProcessor, P as ProcessorContext, I as InputProcessor, m as ProcessedPrompt, n as ModelAnswer, o as PageContext, p as AgentDefinition, q as AgentDelegation, D as DetachedDelivery, r as AiToolCtx, s as PromptBuilder, t as PromptContributor, u as ToolTransientRetrySetting, v as AgentIntake, w as Decision, E as ElicitationRequest, L as LlmStepEnvelope, x as ToolStepEnvelope } from './tool-Q2rmGeaG.cjs';
2
+ export { y as ASK_TOOL_DESCRIPTION, z as ASK_TOOL_NAME, B as AgentApprovalRequest, C as AgentCatalogEntry, F as AgentHistoryWindow, G as AgentStreamEvent, J as AskToolInput, K as DEFAULT_INCREMENTAL_LOOKBACK_CHARS, N as DEFAULT_INTAKE_PREAMBLE, R as DEFAULT_TOOL_TRANSIENT_RETRY_ATTEMPTS, V as DEFAULT_TOOL_TRANSIENT_RETRY_BACKOFF_MS, W as ElicitationOption, X as ElicitationOutcome, Y as ElicitationQuestion, Z as ElicitationReply, _ as ElicitationResult, $ as HistoryPolicyContext, a0 as HistorySelection, a1 as HistorySummary, a2 as IncrementalGating, a3 as InvokeWithTransientRetryOptions, a4 as MAX_ASK_QUESTIONS, a5 as MessageRole, a6 as OutputRejectedError, a7 as OutputVerdict, a8 as ProcessorFailedError, a9 as PromptContext, aa as QuotaView, ab as ToolCatalogEntry, ac as ToolConfirmation, ad as ToolKind, ae as ToolPresentation, af as ToolPresentationTone, ag as ToolResultField, ah as ToolResultView, ai as ToolStepCtx, aj as ToolTransientRetryNumbers, ak as ToolTransientRetryOptions, al as askInputSchema, am as askToolDefinition, an as decodeStreamEvent, ao as encodeStreamEvent, ap as invokeWithTransientRetry, aq as isTransientToolError, ar as normalizeElicitationReply, as as renderElicitationAnswers, at as resolveElicitation, au as resolveToolTransientRetryNumbers, av as settleElicitation } from './tool-Q2rmGeaG.cjs';
3
3
  import { StandardSchemaV1 } from '@standard-schema/spec';
4
4
  import { ChannelRegistry } from '@dudousxd/nestjs-diagnostics';
5
5
 
@@ -2445,6 +2445,12 @@ declare class ToolRegistry {
2445
2445
  * tool the allow-list has already excluded is a call whose answer nothing reads.
2446
2446
  */
2447
2447
  definitionsFor(actor: Actor, policy: RolesPolicy, allowedTools?: string[]): Promise<ToolDefinition[]>;
2448
+ /**
2449
+ * The specs {@link definitionsFor} offers the model, whole — the same four gates (allow-list,
2450
+ * enabled, role, `canUse`) in the same order. For a surface that lists what an actor can reach
2451
+ * (`GET <base>/tools`), which must never disagree with what the model is actually shown.
2452
+ */
2453
+ visibleSpecs(actor: Actor, policy: RolesPolicy, allowedTools?: string[]): Promise<ToolSpec[]>;
2448
2454
  /**
2449
2455
  * Run a tool. Re-checks that the tool is enabled and that the role allows it (defense-in-depth —
2450
2456
  * a call can reach here from a replayed durable step or an approval granted before the flag
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { M as ModelMessage, a as ToolDefinition, b as ToolCallRequest, c as MessageUsage, d as AgentUiComponent, A as Actor, e as ThreadSummary, f as ThreadDetail, S as StoredMessage, g as ToolResult, h as MessageAttachment, i as ToolCallStatus, U as UsagePurpose, j as ToolSpec, Q as QuotaState, k as AgentRunInput, H as HumanReply, T as ToolHandler, l as HistoryPolicy, O as OutputProcessor, P as ProcessorContext, I as InputProcessor, m as ProcessedPrompt, n as ModelAnswer, o as PageContext, p as AgentDefinition, q as AgentDelegation, D as DetachedDelivery, r as AiToolCtx, s as PromptBuilder, t as PromptContributor, u as ToolTransientRetrySetting, v as AgentIntake, w as Decision, E as ElicitationRequest, L as LlmStepEnvelope, x as ToolStepEnvelope } from './tool-CHIw-aTx.js';
2
- export { y as ASK_TOOL_DESCRIPTION, z as ASK_TOOL_NAME, B as AgentApprovalRequest, C as AgentCatalogEntry, F as AgentHistoryWindow, G as AgentStreamEvent, J as AskToolInput, K as DEFAULT_INCREMENTAL_LOOKBACK_CHARS, N as DEFAULT_INTAKE_PREAMBLE, R as DEFAULT_TOOL_TRANSIENT_RETRY_ATTEMPTS, V as DEFAULT_TOOL_TRANSIENT_RETRY_BACKOFF_MS, W as ElicitationOption, X as ElicitationOutcome, Y as ElicitationQuestion, Z as ElicitationReply, _ as ElicitationResult, $ as HistoryPolicyContext, a0 as HistorySelection, a1 as HistorySummary, a2 as IncrementalGating, a3 as InvokeWithTransientRetryOptions, a4 as MAX_ASK_QUESTIONS, a5 as MessageRole, a6 as OutputRejectedError, a7 as OutputVerdict, a8 as ProcessorFailedError, a9 as PromptContext, aa as QuotaView, ab as ToolKind, ac as ToolStepCtx, ad as ToolTransientRetryNumbers, ae as ToolTransientRetryOptions, af as askInputSchema, ag as askToolDefinition, ah as decodeStreamEvent, ai as encodeStreamEvent, aj as invokeWithTransientRetry, ak as isTransientToolError, al as normalizeElicitationReply, am as renderElicitationAnswers, an as resolveElicitation, ao as resolveToolTransientRetryNumbers, ap as settleElicitation } from './tool-CHIw-aTx.js';
1
+ import { M as ModelMessage, a as ToolDefinition, b as ToolCallRequest, c as MessageUsage, d as AgentUiComponent, A as Actor, e as ThreadSummary, f as ThreadDetail, S as StoredMessage, g as ToolResult, h as MessageAttachment, i as ToolCallStatus, U as UsagePurpose, j as ToolSpec, Q as QuotaState, k as AgentRunInput, H as HumanReply, T as ToolHandler, l as HistoryPolicy, O as OutputProcessor, P as ProcessorContext, I as InputProcessor, m as ProcessedPrompt, n as ModelAnswer, o as PageContext, p as AgentDefinition, q as AgentDelegation, D as DetachedDelivery, r as AiToolCtx, s as PromptBuilder, t as PromptContributor, u as ToolTransientRetrySetting, v as AgentIntake, w as Decision, E as ElicitationRequest, L as LlmStepEnvelope, x as ToolStepEnvelope } from './tool-Q2rmGeaG.js';
2
+ export { y as ASK_TOOL_DESCRIPTION, z as ASK_TOOL_NAME, B as AgentApprovalRequest, C as AgentCatalogEntry, F as AgentHistoryWindow, G as AgentStreamEvent, J as AskToolInput, K as DEFAULT_INCREMENTAL_LOOKBACK_CHARS, N as DEFAULT_INTAKE_PREAMBLE, R as DEFAULT_TOOL_TRANSIENT_RETRY_ATTEMPTS, V as DEFAULT_TOOL_TRANSIENT_RETRY_BACKOFF_MS, W as ElicitationOption, X as ElicitationOutcome, Y as ElicitationQuestion, Z as ElicitationReply, _ as ElicitationResult, $ as HistoryPolicyContext, a0 as HistorySelection, a1 as HistorySummary, a2 as IncrementalGating, a3 as InvokeWithTransientRetryOptions, a4 as MAX_ASK_QUESTIONS, a5 as MessageRole, a6 as OutputRejectedError, a7 as OutputVerdict, a8 as ProcessorFailedError, a9 as PromptContext, aa as QuotaView, ab as ToolCatalogEntry, ac as ToolConfirmation, ad as ToolKind, ae as ToolPresentation, af as ToolPresentationTone, ag as ToolResultField, ah as ToolResultView, ai as ToolStepCtx, aj as ToolTransientRetryNumbers, ak as ToolTransientRetryOptions, al as askInputSchema, am as askToolDefinition, an as decodeStreamEvent, ao as encodeStreamEvent, ap as invokeWithTransientRetry, aq as isTransientToolError, ar as normalizeElicitationReply, as as renderElicitationAnswers, at as resolveElicitation, au as resolveToolTransientRetryNumbers, av as settleElicitation } from './tool-Q2rmGeaG.js';
3
3
  import { StandardSchemaV1 } from '@standard-schema/spec';
4
4
  import { ChannelRegistry } from '@dudousxd/nestjs-diagnostics';
5
5
 
@@ -2445,6 +2445,12 @@ declare class ToolRegistry {
2445
2445
  * tool the allow-list has already excluded is a call whose answer nothing reads.
2446
2446
  */
2447
2447
  definitionsFor(actor: Actor, policy: RolesPolicy, allowedTools?: string[]): Promise<ToolDefinition[]>;
2448
+ /**
2449
+ * The specs {@link definitionsFor} offers the model, whole — the same four gates (allow-list,
2450
+ * enabled, role, `canUse`) in the same order. For a surface that lists what an actor can reach
2451
+ * (`GET <base>/tools`), which must never disagree with what the model is actually shown.
2452
+ */
2453
+ visibleSpecs(actor: Actor, policy: RolesPolicy, allowedTools?: string[]): Promise<ToolSpec[]>;
2448
2454
  /**
2449
2455
  * Run a tool. Re-checks that the tool is enabled and that the role allows it (defense-in-depth —
2450
2456
  * a call can reach here from a replayed durable step or an approval granted before the flag
package/dist/index.js CHANGED
@@ -1877,6 +1877,19 @@ var ToolRegistry = class {
1877
1877
  * tool the allow-list has already excluded is a call whose answer nothing reads.
1878
1878
  */
1879
1879
  async definitionsFor(actor, policy, allowedTools) {
1880
+ return (await this.visibleSpecs(actor, policy, allowedTools)).map((spec) => ({
1881
+ name: spec.name,
1882
+ kind: spec.kind,
1883
+ description: spec.description,
1884
+ inputSchema: spec.inputSchema
1885
+ }));
1886
+ }
1887
+ /**
1888
+ * The specs {@link definitionsFor} offers the model, whole — the same four gates (allow-list,
1889
+ * enabled, role, `canUse`) in the same order. For a surface that lists what an actor can reach
1890
+ * (`GET <base>/tools`), which must never disagree with what the model is actually shown.
1891
+ */
1892
+ async visibleSpecs(actor, policy, allowedTools) {
1880
1893
  const pinnedNames = new Set(filterToolsByAllowList(this.allSpecs(), allowedTools).map((spec) => spec.name));
1881
1894
  const pinned = [
1882
1895
  ...this.entries.values()
@@ -1885,12 +1898,7 @@ var ToolRegistry = class {
1885
1898
  const allowedByRole = new Set((await filterToolsByRole(live.map((entry) => entry.spec), actor, policy)).map((spec) => spec.name));
1886
1899
  const roleScoped = live.filter((entry) => allowedByRole.has(entry.spec.name));
1887
1900
  const actorScoped = await filterToolsByCanUse(roleScoped, actor);
1888
- return actorScoped.map(({ spec }) => ({
1889
- name: spec.name,
1890
- kind: spec.kind,
1891
- description: spec.description,
1892
- inputSchema: spec.inputSchema
1893
- }));
1901
+ return actorScoped.map(({ spec }) => spec);
1894
1902
  }
1895
1903
  /**
1896
1904
  * Run a tool. Re-checks that the tool is enabled and that the role allows it (defense-in-depth —