@warlock.js/ai 4.1.13 → 4.1.14
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/cjs/index.cjs +86 -86
- package/esm/agent/agent-config.type.d.mts +1 -1
- package/esm/agent/agent-input-builder.mjs +1 -1
- package/esm/agent/agent-log-event.mjs +1 -1
- package/esm/agent/agent-stream.d.mts +1 -1
- package/esm/agent/agent-stream.mjs +1 -1
- package/esm/agent/agent-to-stream-event.mjs +1 -1
- package/esm/agent/agent.d.mts +1 -1
- package/esm/agent/agent.mjs +1 -1
- package/esm/agent/json-stream-guard.mjs +1 -1
- package/esm/ai.d.mts +1 -1
- package/esm/ai.mjs +1 -1
- package/esm/config.d.mts +1 -1
- package/esm/config.mjs +1 -1
- package/esm/contracts/agent/agent-options.type.d.mts +1 -1
- package/esm/contracts/agent/agent.contract.d.mts +1 -1
- package/esm/contracts/attachment.type.d.mts +1 -1
- package/esm/contracts/content-part.type.d.mts +1 -1
- package/esm/contracts/conversation-message.type.d.mts +1 -1
- package/esm/contracts/embedder.contract.d.mts +1 -1
- package/esm/contracts/end.type.d.mts +1 -1
- package/esm/contracts/end.type.mjs +1 -1
- package/esm/contracts/events/agent-events.type.d.mts +1 -1
- package/esm/contracts/events/complete-event.type.d.mts +1 -1
- package/esm/contracts/events/event-identity.type.d.mts +1 -1
- package/esm/contracts/events/event-map.type.d.mts +1 -1
- package/esm/contracts/events/supervisor-events.type.d.mts +1 -1
- package/esm/contracts/events/usage-event.type.d.mts +1 -1
- package/esm/contracts/events/workflow-events.type.d.mts +1 -1
- package/esm/contracts/executable.contract.d.mts +1 -1
- package/esm/contracts/finish-reason.type.d.mts +1 -1
- package/esm/contracts/middleware/middleware-context.type.d.mts +1 -1
- package/esm/contracts/middleware/middleware-state.type.d.mts +1 -1
- package/esm/contracts/middleware/middleware.contract.d.mts +1 -1
- package/esm/contracts/model-tool-call-request.type.d.mts +1 -1
- package/esm/contracts/model.contract.d.mts +1 -1
- package/esm/contracts/placeholders.type.d.mts +1 -1
- package/esm/contracts/result/agent-result.type.d.mts +1 -1
- package/esm/contracts/result/attempt-entry.type.d.mts +1 -1
- package/esm/contracts/result/base-report.type.d.mts +1 -1
- package/esm/contracts/result/base-report.type.mjs +1 -1
- package/esm/contracts/result/base-result.type.d.mts +1 -1
- package/esm/contracts/result/execute-result.type.d.mts +1 -1
- package/esm/contracts/result/execution-report.type.d.mts +1 -1
- package/esm/contracts/result/llm-trip.type.d.mts +1 -1
- package/esm/contracts/result/model-pricing.type.d.mts +1 -1
- package/esm/contracts/result/session-send-result.type.d.mts +1 -1
- package/esm/contracts/result/step-result.type.d.mts +1 -1
- package/esm/contracts/result/supervisor-result.type.d.mts +1 -1
- package/esm/contracts/result/tool-call.type.d.mts +1 -1
- package/esm/contracts/result/usage.type.d.mts +1 -1
- package/esm/contracts/result/workflow-result.type.d.mts +1 -1
- package/esm/contracts/sdk-adapter.contract.d.mts +1 -1
- package/esm/contracts/stream/stream-event.type.d.mts +1 -1
- package/esm/contracts/stream/stream.contract.d.mts +1 -1
- package/esm/contracts/streaming-tool-guard-config.type.d.mts +1 -1
- package/esm/contracts/supervisor/ack-entry.type.d.mts +1 -1
- package/esm/contracts/supervisor/classifier-context.type.d.mts +1 -1
- package/esm/contracts/supervisor/dispatch-context.type.d.mts +1 -1
- package/esm/contracts/supervisor/evaluate-context.type.d.mts +1 -1
- package/esm/contracts/supervisor/intent-entry.type.d.mts +1 -1
- package/esm/contracts/supervisor/iteration-snapshot.type.d.mts +1 -1
- package/esm/contracts/supervisor/next.type.d.mts +1 -1
- package/esm/contracts/supervisor/route-context.type.d.mts +1 -1
- package/esm/contracts/supervisor/router-entry.type.d.mts +1 -1
- package/esm/contracts/supervisor/supervisor-config.type.d.mts +1 -1
- package/esm/contracts/supervisor/supervisor-execute-options.type.d.mts +1 -1
- package/esm/contracts/supervisor/supervisor-input.type.d.mts +1 -1
- package/esm/contracts/supervisor/supervisor-snapshot.type.d.mts +1 -1
- package/esm/contracts/supervisor/supervisor-stream-event.type.d.mts +1 -1
- package/esm/contracts/supervisor/supervisor.contract.d.mts +1 -1
- package/esm/contracts/system-prompt.contract.d.mts +1 -1
- package/esm/contracts/tool.contract.d.mts +1 -1
- package/esm/contracts/workflow/next-step-result.type.d.mts +1 -1
- package/esm/contracts/workflow/retry-config.type.d.mts +1 -1
- package/esm/contracts/workflow/step.contract.d.mts +1 -1
- package/esm/contracts/workflow/workflow-context.type.d.mts +1 -1
- package/esm/contracts/workflow/workflow-snapshot.type.d.mts +1 -1
- package/esm/contracts/workflow/workflow.contract.d.mts +1 -1
- package/esm/errors/agent-cancelled-error.d.mts +1 -1
- package/esm/errors/agent-cancelled-error.mjs +1 -1
- package/esm/errors/agent-execution-error.d.mts +1 -1
- package/esm/errors/agent-execution-error.mjs +1 -1
- package/esm/errors/agent-max-trips-error.d.mts +1 -1
- package/esm/errors/agent-max-trips-error.mjs +1 -1
- package/esm/errors/ai-error.d.mts +1 -1
- package/esm/errors/ai-error.mjs +1 -1
- package/esm/errors/budget-exceeded-error.d.mts +1 -1
- package/esm/errors/budget-exceeded-error.mjs +1 -1
- package/esm/errors/content-filter-error.d.mts +1 -1
- package/esm/errors/content-filter-error.mjs +1 -1
- package/esm/errors/context-length-exceeded-error.d.mts +1 -1
- package/esm/errors/context-length-exceeded-error.mjs +1 -1
- package/esm/errors/error-category.type.d.mts +1 -1
- package/esm/errors/error-code.type.d.mts +1 -1
- package/esm/errors/guardrail-violation-error.d.mts +1 -1
- package/esm/errors/guardrail-violation-error.mjs +1 -1
- package/esm/errors/invalid-request-error.d.mts +1 -1
- package/esm/errors/invalid-request-error.mjs +1 -1
- package/esm/errors/max-iterations-error.d.mts +1 -1
- package/esm/errors/max-iterations-error.mjs +1 -1
- package/esm/errors/max-steps-exceeded-error.d.mts +1 -1
- package/esm/errors/max-steps-exceeded-error.mjs +1 -1
- package/esm/errors/provider-auth-error.d.mts +1 -1
- package/esm/errors/provider-auth-error.mjs +1 -1
- package/esm/errors/provider-error.d.mts +1 -1
- package/esm/errors/provider-error.mjs +1 -1
- package/esm/errors/provider-rate-limit-error.d.mts +1 -1
- package/esm/errors/provider-rate-limit-error.mjs +1 -1
- package/esm/errors/provider-timeout-error.d.mts +1 -1
- package/esm/errors/provider-timeout-error.mjs +1 -1
- package/esm/errors/quota-exceeded-error.d.mts +1 -1
- package/esm/errors/quota-exceeded-error.mjs +1 -1
- package/esm/errors/routing-error.d.mts +1 -1
- package/esm/errors/routing-error.mjs +1 -1
- package/esm/errors/schema-validation-error.d.mts +1 -1
- package/esm/errors/schema-validation-error.mjs +1 -1
- package/esm/errors/step-failed-error.d.mts +1 -1
- package/esm/errors/step-failed-error.mjs +1 -1
- package/esm/errors/supervisor-cancelled-error.d.mts +1 -1
- package/esm/errors/supervisor-cancelled-error.mjs +1 -1
- package/esm/errors/supervisor-drift-error.d.mts +1 -1
- package/esm/errors/supervisor-drift-error.mjs +1 -1
- package/esm/errors/supervisor-failed-error.d.mts +1 -1
- package/esm/errors/supervisor-failed-error.mjs +1 -1
- package/esm/errors/supervisor-routing-error.d.mts +1 -1
- package/esm/errors/supervisor-routing-error.mjs +1 -1
- package/esm/errors/tool-execution-error.d.mts +1 -1
- package/esm/errors/tool-execution-error.mjs +1 -1
- package/esm/errors/workflow-cancelled-error.d.mts +1 -1
- package/esm/errors/workflow-cancelled-error.mjs +1 -1
- package/esm/errors/workflow-drift-error.d.mts +1 -1
- package/esm/errors/workflow-drift-error.mjs +1 -1
- package/esm/errors/workflow-error.d.mts +1 -1
- package/esm/errors/workflow-error.mjs +1 -1
- package/esm/middleware/builtins/budget.d.mts +1 -1
- package/esm/middleware/builtins/budget.mjs +1 -1
- package/esm/middleware/builtins/guardrail.d.mts +1 -1
- package/esm/middleware/builtins/guardrail.mjs +1 -1
- package/esm/middleware/builtins/semantic-cache.d.mts +1 -1
- package/esm/middleware/builtins/semantic-cache.mjs +1 -1
- package/esm/middleware/helpers/compose.d.mts +1 -1
- package/esm/middleware/helpers/compose.mjs +1 -1
- package/esm/middleware/helpers/for-tool.d.mts +1 -1
- package/esm/middleware/helpers/for-tool.mjs +1 -1
- package/esm/middleware/pipeline.d.mts +1 -1
- package/esm/middleware/pipeline.mjs +1 -1
- package/esm/middleware/utils/extract-user-text.d.mts +1 -1
- package/esm/middleware/utils/extract-user-text.mjs +1 -1
- package/esm/middleware/utils/namespaced-state.d.mts +1 -1
- package/esm/middleware/utils/namespaced-state.mjs +1 -1
- package/esm/mock/mock-agent.d.mts +1 -1
- package/esm/mock/mock-agent.mjs +1 -1
- package/esm/mock/mock-config.type.d.mts +1 -1
- package/esm/mock/mock-model.d.mts +1 -1
- package/esm/mock/mock-model.mjs +1 -1
- package/esm/mock/mock-sdk.d.mts +1 -1
- package/esm/mock/mock-sdk.mjs +1 -1
- package/esm/supervisor/as-tool.d.mts +1 -1
- package/esm/supervisor/as-tool.mjs +1 -1
- package/esm/supervisor/cancellation.d.mts +1 -1
- package/esm/supervisor/cancellation.mjs +1 -1
- package/esm/supervisor/decide.mjs +1 -1
- package/esm/supervisor/emitter.d.mts +1 -1
- package/esm/supervisor/emitter.mjs +1 -1
- package/esm/supervisor/entries.d.mts +1 -1
- package/esm/supervisor/entries.mjs +1 -1
- package/esm/supervisor/execution.d.mts +1 -1
- package/esm/supervisor/execution.mjs +1 -1
- package/esm/supervisor/router-prompt.d.mts +1 -1
- package/esm/supervisor/router-prompt.mjs +1 -1
- package/esm/supervisor/signature.d.mts +1 -1
- package/esm/supervisor/signature.mjs +1 -1
- package/esm/supervisor/snapshot.d.mts +1 -1
- package/esm/supervisor/snapshot.mjs +1 -1
- package/esm/supervisor/supervisor-stream.d.mts +1 -1
- package/esm/supervisor/supervisor-stream.mjs +1 -1
- package/esm/supervisor/supervisor.d.mts +1 -1
- package/esm/supervisor/supervisor.mjs +1 -1
- package/esm/system-prompt/instruction.d.mts +1 -1
- package/esm/system-prompt/instruction.mjs +1 -1
- package/esm/system-prompt/persona.d.mts +1 -1
- package/esm/system-prompt/persona.mjs +1 -1
- package/esm/system-prompt/render-placeholders.d.mts +1 -1
- package/esm/system-prompt/render-placeholders.mjs +1 -1
- package/esm/system-prompt/system-prompt.d.mts +1 -1
- package/esm/system-prompt/system-prompt.mjs +1 -1
- package/esm/tool/tool.d.mts +1 -1
- package/esm/tool/tool.mjs +1 -1
- package/esm/utils/compute-cost.d.mts +1 -1
- package/esm/utils/compute-cost.mjs +1 -1
- package/esm/utils/extract-json-payload.d.mts +1 -1
- package/esm/utils/extract-json-payload.mjs +1 -1
- package/esm/utils/generate-run-id.d.mts +1 -1
- package/esm/utils/generate-run-id.mjs +1 -1
- package/esm/utils/json-schema.d.mts +1 -1
- package/esm/utils/json-schema.mjs +1 -1
- package/esm/utils/prepare-attachment-part.d.mts +1 -1
- package/esm/utils/prepare-attachment-part.mjs +1 -1
- package/esm/utils/resolve-attachment.d.mts +1 -1
- package/esm/utils/resolve-attachment.mjs +1 -1
- package/esm/utils/safe-json-parse.d.mts +1 -1
- package/esm/utils/safe-json-parse.mjs +1 -1
- package/esm/utils/stamp-report-lineage.d.mts +1 -1
- package/esm/utils/stamp-report-lineage.mjs +1 -1
- package/esm/utils/token-count.d.mts +1 -1
- package/esm/utils/token-count.mjs +1 -1
- package/esm/workflow/as-tool.mjs +1 -1
- package/esm/workflow/cancellation.mjs +1 -1
- package/esm/workflow/emitter.mjs +1 -1
- package/esm/workflow/engine.mjs +1 -1
- package/esm/workflow/retry.mjs +1 -1
- package/esm/workflow/router.mjs +1 -1
- package/esm/workflow/run-scoped-emitter.mjs +1 -1
- package/esm/workflow/signature.d.mts +1 -1
- package/esm/workflow/signature.mjs +1 -1
- package/esm/workflow/snapshot.mjs +1 -1
- package/esm/workflow/state.mjs +1 -1
- package/esm/workflow/step-runner.mjs +1 -1
- package/esm/workflow/step.d.mts +1 -1
- package/esm/workflow/step.mjs +1 -1
- package/esm/workflow/workflow.d.mts +1 -1
- package/esm/workflow/workflow.mjs +1 -1
- package/package.json +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AIError } from "./ai-error.mjs";
|
|
2
2
|
|
|
3
|
-
//#region
|
|
3
|
+
//#region ../../@warlock.js/ai/src/errors/tool-execution-error.ts
|
|
4
4
|
/**
|
|
5
5
|
* A registered tool's `execute()` threw during dispatch — the tool
|
|
6
6
|
* code itself failed (not its input schema). The model's request was
|
|
@@ -2,7 +2,7 @@ import { ErrorCategory } from "./error-category.type.mjs";
|
|
|
2
2
|
import { AIErrorOptions } from "./ai-error.mjs";
|
|
3
3
|
import { WorkflowError } from "./workflow-error.mjs";
|
|
4
4
|
|
|
5
|
-
//#region
|
|
5
|
+
//#region ../../@warlock.js/ai/src/errors/workflow-cancelled-error.d.ts
|
|
6
6
|
type WorkflowCancelledErrorOptions = AIErrorOptions & {
|
|
7
7
|
cancelledAt: string;
|
|
8
8
|
reason?: string;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { WorkflowError } from "./workflow-error.mjs";
|
|
2
2
|
|
|
3
|
-
//#region
|
|
3
|
+
//#region ../../@warlock.js/ai/src/errors/workflow-cancelled-error.ts
|
|
4
4
|
/**
|
|
5
5
|
* Workflow was cancelled via `AbortSignal` before it could finish.
|
|
6
6
|
* `cancelledAt` is ISO timestamp at abort; `reason` carries the
|
|
@@ -2,7 +2,7 @@ import { ErrorCategory } from "./error-category.type.mjs";
|
|
|
2
2
|
import { AIErrorOptions } from "./ai-error.mjs";
|
|
3
3
|
import { WorkflowError } from "./workflow-error.mjs";
|
|
4
4
|
|
|
5
|
-
//#region
|
|
5
|
+
//#region ../../@warlock.js/ai/src/errors/workflow-drift-error.d.ts
|
|
6
6
|
type WorkflowDriftErrorOptions = AIErrorOptions & {
|
|
7
7
|
savedSignature: string;
|
|
8
8
|
currentSignature: string;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { WorkflowError } from "./workflow-error.mjs";
|
|
2
2
|
|
|
3
|
-
//#region
|
|
3
|
+
//#region ../../@warlock.js/ai/src/errors/workflow-drift-error.ts
|
|
4
4
|
/**
|
|
5
5
|
* `workflow.resume(runId)` found a snapshot whose structural signature
|
|
6
6
|
* doesn't match the current workflow definition. Thrown without
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { AIErrorCode } from "./error-code.type.mjs";
|
|
2
2
|
import { AIError, AIErrorOptions } from "./ai-error.mjs";
|
|
3
3
|
|
|
4
|
-
//#region
|
|
4
|
+
//#region ../../@warlock.js/ai/src/errors/workflow-error.d.ts
|
|
5
5
|
/**
|
|
6
6
|
* Base class for all workflow-specific failures. Subclasses carry
|
|
7
7
|
* precise codes; this base catches everything `workflow.execute()`
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AIError } from "./ai-error.mjs";
|
|
2
2
|
|
|
3
|
-
//#region
|
|
3
|
+
//#region ../../@warlock.js/ai/src/errors/workflow-error.ts
|
|
4
4
|
/**
|
|
5
5
|
* Base class for all workflow-specific failures. Subclasses carry
|
|
6
6
|
* precise codes; this base catches everything `workflow.execute()`
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AgentMiddleware } from "../../contracts/middleware/middleware.contract.mjs";
|
|
2
|
-
//#region
|
|
2
|
+
//#region ../../@warlock.js/ai/src/middleware/builtins/budget.d.ts
|
|
3
3
|
/**
|
|
4
4
|
* Per-model pricing used to compute USD cost from token counts.
|
|
5
5
|
* Caller-supplied — no bundled table. Keys are model names (the
|
|
@@ -2,7 +2,7 @@ import { BudgetExceededError } from "../../errors/budget-exceeded-error.mjs";
|
|
|
2
2
|
import "../../errors/index.mjs";
|
|
3
3
|
import { namespacedState } from "../utils/namespaced-state.mjs";
|
|
4
4
|
|
|
5
|
-
//#region
|
|
5
|
+
//#region ../../@warlock.js/ai/src/middleware/builtins/budget.ts
|
|
6
6
|
function breach(limit, actual, unit, name) {
|
|
7
7
|
throw new BudgetExceededError(`budget "${name}" exceeded — ${actual} ${unit} (cap: ${limit})`, {
|
|
8
8
|
limit,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { MiddlewareTripContext } from "../../contracts/middleware/middleware-context.type.mjs";
|
|
2
2
|
import { AgentMiddleware } from "../../contracts/middleware/middleware.contract.mjs";
|
|
3
|
-
//#region
|
|
3
|
+
//#region ../../@warlock.js/ai/src/middleware/builtins/guardrail.d.ts
|
|
4
4
|
/**
|
|
5
5
|
* Decision returned by a guardrail check function. `ok: true`
|
|
6
6
|
* permits the call; `ok: false` rejects with a human-readable
|
|
@@ -2,7 +2,7 @@ import { GuardrailViolationError } from "../../errors/guardrail-violation-error.
|
|
|
2
2
|
import "../../errors/index.mjs";
|
|
3
3
|
import { extractUserText } from "../utils/extract-user-text.mjs";
|
|
4
4
|
|
|
5
|
-
//#region
|
|
5
|
+
//#region ../../@warlock.js/ai/src/middleware/builtins/guardrail.ts
|
|
6
6
|
/**
|
|
7
7
|
* Pre/post content guardrail for an agent run.
|
|
8
8
|
*
|
|
@@ -2,7 +2,7 @@ import { EmbedderContract } from "../../contracts/embedder.contract.mjs";
|
|
|
2
2
|
import { AgentMiddleware } from "../../contracts/middleware/middleware.contract.mjs";
|
|
3
3
|
import { CacheDriver } from "@warlock.js/cache";
|
|
4
4
|
|
|
5
|
-
//#region
|
|
5
|
+
//#region ../../@warlock.js/ai/src/middleware/builtins/semantic-cache.d.ts
|
|
6
6
|
/**
|
|
7
7
|
* Configuration for `semanticCache()`.
|
|
8
8
|
*/
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { extractUserText } from "../utils/extract-user-text.mjs";
|
|
2
2
|
import { resolveDefaultStore } from "../../config.mjs";
|
|
3
3
|
|
|
4
|
-
//#region
|
|
4
|
+
//#region ../../@warlock.js/ai/src/middleware/builtins/semantic-cache.ts
|
|
5
5
|
const DEFAULT_NAMESPACE = "ai.cache";
|
|
6
6
|
/**
|
|
7
7
|
* Build a stable fingerprint for a prompt covering the full message
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AgentMiddleware } from "../../contracts/middleware/middleware.contract.mjs";
|
|
2
|
-
//#region
|
|
2
|
+
//#region ../../@warlock.js/ai/src/middleware/helpers/compose.d.ts
|
|
3
3
|
/**
|
|
4
4
|
* Flatten one or more middleware sources into a single ordered
|
|
5
5
|
* array suitable for `agent({ middleware: [...] })`.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AgentMiddleware } from "../../contracts/middleware/middleware.contract.mjs";
|
|
2
|
-
//#region
|
|
2
|
+
//#region ../../@warlock.js/ai/src/middleware/helpers/for-tool.d.ts
|
|
3
3
|
/**
|
|
4
4
|
* Scope a middleware's `tool`-level hooks to only fire for a
|
|
5
5
|
* specific tool name (or a set of names). `execute` and `trip`
|
|
@@ -2,7 +2,7 @@ import { MiddlewareExecuteContext, MiddlewareToolContext, MiddlewareTripContext
|
|
|
2
2
|
import { AgentMiddleware } from "../contracts/middleware/middleware.contract.mjs";
|
|
3
3
|
import { Logger } from "@warlock.js/logger";
|
|
4
4
|
|
|
5
|
-
//#region
|
|
5
|
+
//#region ../../@warlock.js/ai/src/middleware/pipeline.d.ts
|
|
6
6
|
/**
|
|
7
7
|
* The three levels at which agent middleware can hook — mirrors
|
|
8
8
|
* `AgentMiddleware`'s optional `execute` / `trip` / `tool` keys.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Message } from "../../contracts/conversation-message.type.mjs";
|
|
2
2
|
|
|
3
|
-
//#region
|
|
3
|
+
//#region ../../@warlock.js/ai/src/middleware/utils/extract-user-text.d.ts
|
|
4
4
|
/**
|
|
5
5
|
* Pull the text a content-inspection middleware should care about
|
|
6
6
|
* from the outbound message list.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { MiddlewareState } from "../../contracts/middleware/middleware-state.type.mjs";
|
|
2
|
-
//#region
|
|
2
|
+
//#region ../../@warlock.js/ai/src/middleware/utils/namespaced-state.d.ts
|
|
3
3
|
/**
|
|
4
4
|
* Typed accessor over `ctx.state` for a single namespace key. Wraps
|
|
5
5
|
* the raw `Map<string, unknown>` so middleware authors stop typing
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
//#region
|
|
1
|
+
//#region ../../@warlock.js/ai/src/middleware/utils/namespaced-state.ts
|
|
2
2
|
/**
|
|
3
3
|
* Typed accessor over `ctx.state` for a single namespace key. Wraps
|
|
4
4
|
* the raw `Map<string, unknown>` so middleware authors stop typing
|
|
@@ -2,7 +2,7 @@ import { AgentContract } from "../contracts/agent/agent.contract.mjs";
|
|
|
2
2
|
import { ToolContract } from "../tool/tool.mjs";
|
|
3
3
|
import { MockModelResponse } from "./mock-config.type.mjs";
|
|
4
4
|
|
|
5
|
-
//#region
|
|
5
|
+
//#region ../../@warlock.js/ai/src/mock/mock-agent.d.ts
|
|
6
6
|
/**
|
|
7
7
|
* Test helper that wires `MockSDK` → mock model → `agent()` in one call.
|
|
8
8
|
*
|
package/esm/mock/mock-agent.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { agent } from "../agent/agent.mjs";
|
|
2
2
|
import { MockSDK } from "./mock-sdk.mjs";
|
|
3
3
|
|
|
4
|
-
//#region
|
|
4
|
+
//#region ../../@warlock.js/ai/src/mock/mock-agent.ts
|
|
5
5
|
/**
|
|
6
6
|
* Test helper that wires `MockSDK` → mock model → `agent()` in one call.
|
|
7
7
|
*
|
|
@@ -2,7 +2,7 @@ import { ModelToolCallRequest } from "../contracts/model-tool-call-request.type.
|
|
|
2
2
|
import { Usage } from "../contracts/result/usage.type.mjs";
|
|
3
3
|
import { FinishReason } from "../contracts/finish-reason.type.mjs";
|
|
4
4
|
import { ModelCapabilities } from "../contracts/model.contract.mjs";
|
|
5
|
-
//#region
|
|
5
|
+
//#region ../../@warlock.js/ai/src/mock/mock-config.type.d.ts
|
|
6
6
|
/**
|
|
7
7
|
* Configuration for a single mock model response.
|
|
8
8
|
* Responses are consumed in order — last one repeats if list is exhausted.
|
|
@@ -2,7 +2,7 @@ import { Message } from "../contracts/conversation-message.type.mjs";
|
|
|
2
2
|
import { ModelCallOptions, ModelCapabilities, ModelContract, ModelResponse, ModelStreamChunk } from "../contracts/model.contract.mjs";
|
|
3
3
|
import { MockModelResponse } from "./mock-config.type.mjs";
|
|
4
4
|
|
|
5
|
-
//#region
|
|
5
|
+
//#region ../../@warlock.js/ai/src/mock/mock-model.d.ts
|
|
6
6
|
type RecordedCall = {
|
|
7
7
|
messages: Message[];
|
|
8
8
|
options?: ModelCallOptions;
|
package/esm/mock/mock-model.mjs
CHANGED
package/esm/mock/mock-sdk.d.mts
CHANGED
|
@@ -2,7 +2,7 @@ import { SDKAdapterContract } from "../contracts/sdk-adapter.contract.mjs";
|
|
|
2
2
|
import { MockSDKConfig } from "./mock-config.type.mjs";
|
|
3
3
|
import { MockModel } from "./mock-model.mjs";
|
|
4
4
|
|
|
5
|
-
//#region
|
|
5
|
+
//#region ../../@warlock.js/ai/src/mock/mock-sdk.d.ts
|
|
6
6
|
/**
|
|
7
7
|
* Creates a mock SDK adapter for testing — no HTTP calls, fully configurable.
|
|
8
8
|
*
|
package/esm/mock/mock-sdk.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { approximateTokenCount } from "../utils/token-count.mjs";
|
|
2
2
|
import { MockModel } from "./mock-model.mjs";
|
|
3
3
|
|
|
4
|
-
//#region
|
|
4
|
+
//#region ../../@warlock.js/ai/src/mock/mock-sdk.ts
|
|
5
5
|
/**
|
|
6
6
|
* Creates a mock SDK adapter for testing — no HTTP calls, fully configurable.
|
|
7
7
|
*
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ToolContract } from "../tool/tool.mjs";
|
|
2
2
|
import { SupervisorAsToolOptions, SupervisorContract } from "../contracts/supervisor/supervisor.contract.mjs";
|
|
3
3
|
|
|
4
|
-
//#region
|
|
4
|
+
//#region ../../@warlock.js/ai/src/supervisor/as-tool.d.ts
|
|
5
5
|
/**
|
|
6
6
|
* Wrap a `SupervisorContract` as a `ToolContract` so an outer agent
|
|
7
7
|
* can invoke it from its tool-call loop. Mirrors
|
|
@@ -2,7 +2,7 @@ import { SupervisorFailedError } from "../errors/supervisor-failed-error.mjs";
|
|
|
2
2
|
import "../errors/index.mjs";
|
|
3
3
|
import { compositeAsTool } from "../tool/tool.mjs";
|
|
4
4
|
|
|
5
|
-
//#region
|
|
5
|
+
//#region ../../@warlock.js/ai/src/supervisor/as-tool.ts
|
|
6
6
|
/**
|
|
7
7
|
* Wrap a `SupervisorContract` as a `ToolContract` so an outer agent
|
|
8
8
|
* can invoke it from its tool-call loop. Mirrors
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { SupervisorCancelledError } from "../errors/supervisor-cancelled-error.mjs";
|
|
2
|
-
//#region
|
|
2
|
+
//#region ../../@warlock.js/ai/src/supervisor/cancellation.d.ts
|
|
3
3
|
/**
|
|
4
4
|
* Build a `SupervisorCancelledError` from an `AbortSignal`. Extracts a
|
|
5
5
|
* human-readable reason from `signal.reason` whether it was a string,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { SupervisorCancelledError } from "../errors/supervisor-cancelled-error.mjs";
|
|
2
2
|
import "../errors/index.mjs";
|
|
3
3
|
|
|
4
|
-
//#region
|
|
4
|
+
//#region ../../@warlock.js/ai/src/supervisor/cancellation.ts
|
|
5
5
|
/**
|
|
6
6
|
* Build a `SupervisorCancelledError` from an `AbortSignal`. Extracts a
|
|
7
7
|
* human-readable reason from `signal.reason` whether it was a string,
|
|
@@ -5,7 +5,7 @@ import "../errors/index.mjs";
|
|
|
5
5
|
import { END } from "../contracts/end.type.mjs";
|
|
6
6
|
import { buildRouterContextMessage } from "./router-prompt.mjs";
|
|
7
7
|
|
|
8
|
-
//#region
|
|
8
|
+
//#region ../../@warlock.js/ai/src/supervisor/decide.ts
|
|
9
9
|
/**
|
|
10
10
|
* Unified dispatch decision entry — calls either the `route` callback
|
|
11
11
|
* or the `router` agent based on the supervisor's configured mode and
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { SupervisorEventHandler, SupervisorEventHandlers } from "../contracts/supervisor/supervisor-config.type.mjs";
|
|
2
2
|
import { SupervisorEventMap } from "../contracts/events/event-map.type.mjs";
|
|
3
3
|
|
|
4
|
-
//#region
|
|
4
|
+
//#region ../../@warlock.js/ai/src/supervisor/emitter.d.ts
|
|
5
5
|
/**
|
|
6
6
|
* Three-tier supervisor event emitter — factory (definition) → instance
|
|
7
7
|
* → per-execution. Mirrors `WorkflowEmitter` structurally; the only
|
|
@@ -7,7 +7,7 @@ import { IntentCallback, SupervisorIntentValue } from "../contracts/supervisor/i
|
|
|
7
7
|
import { DispatchContext } from "../contracts/supervisor/dispatch-context.type.mjs";
|
|
8
8
|
import { StandardSchemaV1 } from "@standard-schema/spec";
|
|
9
9
|
|
|
10
|
-
//#region
|
|
10
|
+
//#region ../../@warlock.js/ai/src/supervisor/entries.d.ts
|
|
11
11
|
/**
|
|
12
12
|
* Normalized internal representation of one entry in a supervisor's
|
|
13
13
|
* `intents` map — resolved at factory time from one of the accepted
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { SupervisorFailedError } from "../errors/supervisor-failed-error.mjs";
|
|
2
2
|
import "../errors/index.mjs";
|
|
3
3
|
|
|
4
|
-
//#region
|
|
4
|
+
//#region ../../@warlock.js/ai/src/supervisor/entries.ts
|
|
5
5
|
/**
|
|
6
6
|
* Validate and normalize the `intents` map into resolved entries.
|
|
7
7
|
* Runs at factory time — throws `SupervisorFailedError` on the first
|
|
@@ -7,7 +7,7 @@ import { SupervisorEmitter } from "./emitter.mjs";
|
|
|
7
7
|
import { ResolvedIntentEntry } from "./entries.mjs";
|
|
8
8
|
import { SupervisorStreamController } from "./supervisor-stream.mjs";
|
|
9
9
|
|
|
10
|
-
//#region
|
|
10
|
+
//#region ../../@warlock.js/ai/src/supervisor/execution.d.ts
|
|
11
11
|
type SupervisorExecutionParams<TOutput> = {
|
|
12
12
|
config: SupervisorConfig<TOutput>;
|
|
13
13
|
entries: Map<string, ResolvedIntentEntry>;
|
|
@@ -13,7 +13,7 @@ import { decide } from "./decide.mjs";
|
|
|
13
13
|
import { persistSupervisorSnapshot } from "./snapshot.mjs";
|
|
14
14
|
import { log } from "@warlock.js/logger";
|
|
15
15
|
|
|
16
|
-
//#region
|
|
16
|
+
//#region ../../@warlock.js/ai/src/supervisor/execution.ts
|
|
17
17
|
const DEFAULT_MAX_ITERATIONS = 10;
|
|
18
18
|
const LOG_MODULE_BASE = "ai.supervisor";
|
|
19
19
|
/**
|
|
@@ -2,7 +2,7 @@ import { IterationSnapshot } from "../contracts/supervisor/iteration-snapshot.ty
|
|
|
2
2
|
import { SupervisorInput } from "../contracts/supervisor/supervisor-input.type.mjs";
|
|
3
3
|
import { ResolvedIntentEntry } from "./entries.mjs";
|
|
4
4
|
|
|
5
|
-
//#region
|
|
5
|
+
//#region ../../@warlock.js/ai/src/supervisor/router-prompt.d.ts
|
|
6
6
|
/**
|
|
7
7
|
* Build the per-turn user message the supervisor feeds to the router
|
|
8
8
|
* agent. Carries everything the LLM needs to make a routing decision:
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { END } from "../contracts/end.type.mjs";
|
|
2
2
|
|
|
3
|
-
//#region
|
|
3
|
+
//#region ../../@warlock.js/ai/src/supervisor/router-prompt.ts
|
|
4
4
|
/**
|
|
5
5
|
* Build the per-turn user message the supervisor feeds to the router
|
|
6
6
|
* agent. Carries everything the LLM needs to make a routing decision:
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { SupervisorConfig } from "../contracts/supervisor/supervisor-config.type.mjs";
|
|
2
2
|
import { ResolvedIntentEntry } from "./entries.mjs";
|
|
3
3
|
|
|
4
|
-
//#region
|
|
4
|
+
//#region ../../@warlock.js/ai/src/supervisor/signature.d.ts
|
|
5
5
|
/**
|
|
6
6
|
* Deterministic structural fingerprint of a supervisor definition.
|
|
7
7
|
* Persisted on every snapshot so `resume()` can detect drift between
|
|
@@ -4,7 +4,7 @@ import { SupervisorConfig } from "../contracts/supervisor/supervisor-config.type
|
|
|
4
4
|
import { SupervisorResumeOptions } from "../contracts/supervisor/supervisor-execute-options.type.mjs";
|
|
5
5
|
import { SupervisorSnapshot, SupervisorSnapshotStatus } from "../contracts/supervisor/supervisor-snapshot.type.mjs";
|
|
6
6
|
|
|
7
|
-
//#region
|
|
7
|
+
//#region ../../@warlock.js/ai/src/supervisor/snapshot.d.ts
|
|
8
8
|
type PersistParams = {
|
|
9
9
|
config: SupervisorConfig<unknown>;
|
|
10
10
|
signature: string;
|
|
@@ -3,7 +3,7 @@ import { SupervisorDriftError } from "../errors/supervisor-drift-error.mjs";
|
|
|
3
3
|
import "../errors/index.mjs";
|
|
4
4
|
import { resolveDefaultStore } from "../config.mjs";
|
|
5
5
|
|
|
6
|
-
//#region
|
|
6
|
+
//#region ../../@warlock.js/ai/src/supervisor/snapshot.ts
|
|
7
7
|
/**
|
|
8
8
|
* Resolve the effective snapshot store: the supervisor's own
|
|
9
9
|
* `snapshotStore` field wins; absent that, fall back to the global
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { StreamContract } from "../contracts/stream/stream.contract.mjs";
|
|
2
2
|
import { SupervisorStreamEvent } from "../contracts/supervisor/supervisor-stream-event.type.mjs";
|
|
3
3
|
|
|
4
|
-
//#region
|
|
4
|
+
//#region ../../@warlock.js/ai/src/supervisor/supervisor-stream.d.ts
|
|
5
5
|
/**
|
|
6
6
|
* Internal async-queue controller driving `supervisor.stream()`.
|
|
7
7
|
* Mirrors `StreamController` from `agent-stream.ts` — same
|
|
@@ -2,7 +2,7 @@ import { SupervisorIntentValue } from "../contracts/supervisor/intent-entry.type
|
|
|
2
2
|
import { SupervisorConfig } from "../contracts/supervisor/supervisor-config.type.mjs";
|
|
3
3
|
import { SupervisorContract } from "../contracts/supervisor/supervisor.contract.mjs";
|
|
4
4
|
|
|
5
|
-
//#region
|
|
5
|
+
//#region ../../@warlock.js/ai/src/supervisor/supervisor.d.ts
|
|
6
6
|
/**
|
|
7
7
|
* `ai.supervisor(config)` — construct a `SupervisorContract`. Validates
|
|
8
8
|
* the config at author time (throws `SupervisorFailedError` on bad
|
|
@@ -8,7 +8,7 @@ import { SupervisorExecution } from "./execution.mjs";
|
|
|
8
8
|
import { computeSignature } from "./signature.mjs";
|
|
9
9
|
import { createSupervisorStream } from "./supervisor-stream.mjs";
|
|
10
10
|
|
|
11
|
-
//#region
|
|
11
|
+
//#region ../../@warlock.js/ai/src/supervisor/supervisor.ts
|
|
12
12
|
/**
|
|
13
13
|
* `ai.supervisor(config)` — construct a `SupervisorContract`. Validates
|
|
14
14
|
* the config at author time (throws `SupervisorFailedError` on bad
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Placeholders } from "../contracts/placeholders.type.mjs";
|
|
2
2
|
import { InstructionContract } from "../contracts/system-prompt.contract.mjs";
|
|
3
3
|
|
|
4
|
-
//#region
|
|
4
|
+
//#region ../../@warlock.js/ai/src/system-prompt/instruction.d.ts
|
|
5
5
|
/**
|
|
6
6
|
* Concrete `InstructionContract` — a reusable directive block.
|
|
7
7
|
*
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { renderPlaceholders } from "./render-placeholders.mjs";
|
|
2
2
|
|
|
3
|
-
//#region
|
|
3
|
+
//#region ../../@warlock.js/ai/src/system-prompt/instruction.ts
|
|
4
4
|
/**
|
|
5
5
|
* Concrete `InstructionContract` — a reusable directive block.
|
|
6
6
|
*
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Placeholders } from "../contracts/placeholders.type.mjs";
|
|
2
2
|
import { PersonaContract } from "../contracts/system-prompt.contract.mjs";
|
|
3
3
|
|
|
4
|
-
//#region
|
|
4
|
+
//#region ../../@warlock.js/ai/src/system-prompt/persona.d.ts
|
|
5
5
|
/**
|
|
6
6
|
* Concrete `PersonaContract` — a reusable "who the agent is" block.
|
|
7
7
|
*
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Placeholders } from "../contracts/placeholders.type.mjs";
|
|
2
2
|
|
|
3
|
-
//#region
|
|
3
|
+
//#region ../../@warlock.js/ai/src/system-prompt/render-placeholders.d.ts
|
|
4
4
|
/**
|
|
5
5
|
* Render a template string against a placeholders map, supporting dot-path
|
|
6
6
|
* lookups and inline fallback values.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
//#region
|
|
1
|
+
//#region ../../@warlock.js/ai/src/system-prompt/render-placeholders.ts
|
|
2
2
|
const PLACEHOLDER_PATTERN = /\{\{\s*([^{}]+?)\s*\}\}/g;
|
|
3
3
|
/**
|
|
4
4
|
* Render a template string against a placeholders map, supporting dot-path
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Placeholders } from "../contracts/placeholders.type.mjs";
|
|
2
2
|
import { InstructionContract, PersonaContract, SystemPromptBlockContract, SystemPromptContract } from "../contracts/system-prompt.contract.mjs";
|
|
3
3
|
|
|
4
|
-
//#region
|
|
4
|
+
//#region ../../@warlock.js/ai/src/system-prompt/system-prompt.d.ts
|
|
5
5
|
/**
|
|
6
6
|
* Concrete `SystemPromptContract` — an immutable layered prompt builder.
|
|
7
7
|
*
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Instruction } from "./instruction.mjs";
|
|
2
2
|
import { Persona } from "./persona.mjs";
|
|
3
3
|
|
|
4
|
-
//#region
|
|
4
|
+
//#region ../../@warlock.js/ai/src/system-prompt/system-prompt.ts
|
|
5
5
|
/**
|
|
6
6
|
* Concrete `SystemPromptContract` — an immutable layered prompt builder.
|
|
7
7
|
*
|
package/esm/tool/tool.d.mts
CHANGED
|
@@ -4,7 +4,7 @@ import { BaseReport } from "../contracts/result/base-report.type.mjs";
|
|
|
4
4
|
import { ToolConfig, ToolContext } from "../contracts/tool.contract.mjs";
|
|
5
5
|
import { StandardSchemaV1 } from "@standard-schema/spec";
|
|
6
6
|
|
|
7
|
-
//#region
|
|
7
|
+
//#region ../../@warlock.js/ai/src/tool/tool.d.ts
|
|
8
8
|
/**
|
|
9
9
|
* Result returned by `ToolContract.invoke()`.
|
|
10
10
|
*
|
package/esm/tool/tool.mjs
CHANGED
|
@@ -3,7 +3,7 @@ import { ToolExecutionError } from "../errors/tool-execution-error.mjs";
|
|
|
3
3
|
import "../errors/index.mjs";
|
|
4
4
|
import { generateRunId } from "../utils/generate-run-id.mjs";
|
|
5
5
|
|
|
6
|
-
//#region
|
|
6
|
+
//#region ../../@warlock.js/ai/src/tool/tool.ts
|
|
7
7
|
/**
|
|
8
8
|
* Degraded `ToolContext` supplied when no caller threads one through
|
|
9
9
|
* (`tool.invoke(input)` standalone, batch scripts, tests). Per
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ModelPricing } from "../contracts/result/model-pricing.type.mjs";
|
|
2
2
|
import { Usage } from "../contracts/result/usage.type.mjs";
|
|
3
3
|
|
|
4
|
-
//#region
|
|
4
|
+
//#region ../../@warlock.js/ai/src/utils/compute-cost.d.ts
|
|
5
5
|
/**
|
|
6
6
|
* Compute a per-channel USD cost breakdown for a single `Usage` against
|
|
7
7
|
* a model's pricing table. Returns `undefined` when no pricing is
|