@finalai/agent-definition 0.1.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.
Potentially problematic release.
This version of @finalai/agent-definition might be problematic. Click here for more details.
- package/README.md +16 -0
- package/THIRD_PARTY_NOTICES.md +303 -0
- package/dist/compiler-assets/chunk-2CZRHOLL.ts +10 -0
- package/dist/compiler-assets/chunk-32O3ODZE.ts +39 -0
- package/dist/compiler-assets/chunk-5BK6FVRE.ts +75 -0
- package/dist/compiler-assets/chunk-6WR3PGNF.ts +0 -0
- package/dist/compiler-assets/chunk-7QP2CKPI.ts +30 -0
- package/dist/compiler-assets/chunk-7VSSVZM4.ts +55 -0
- package/dist/compiler-assets/chunk-7WGYG73V.ts +42 -0
- package/dist/compiler-assets/chunk-BLB6JGLO.ts +481 -0
- package/dist/compiler-assets/chunk-CWWRTRWW.ts +76 -0
- package/dist/compiler-assets/chunk-EVQIK62B.ts +188 -0
- package/dist/compiler-assets/chunk-GNR7XBPN.ts +3364 -0
- package/dist/compiler-assets/chunk-GTUZOATD.ts +10 -0
- package/dist/compiler-assets/chunk-HFS4KLEL.ts +10 -0
- package/dist/compiler-assets/chunk-HGW4YHAY.ts +6865 -0
- package/dist/compiler-assets/chunk-HNPUTP35.ts +172 -0
- package/dist/compiler-assets/chunk-JIPNTA56.ts +59 -0
- package/dist/compiler-assets/chunk-JNJE72EH.ts +10 -0
- package/dist/compiler-assets/chunk-JPY4L2UJ.ts +349 -0
- package/dist/compiler-assets/chunk-JTGTLYDT.ts +0 -0
- package/dist/compiler-assets/chunk-LUSAAV4L.ts +33 -0
- package/dist/compiler-assets/chunk-MZMSKIKU.ts +472 -0
- package/dist/compiler-assets/chunk-NMYHO2QN.ts +25 -0
- package/dist/compiler-assets/chunk-NYTOYKKF.ts +28 -0
- package/dist/compiler-assets/chunk-OWC6SFFF.ts +295 -0
- package/dist/compiler-assets/chunk-QMKWAFVZ.ts +59 -0
- package/dist/compiler-assets/chunk-QMWTDPNT.ts +79 -0
- package/dist/compiler-assets/chunk-RWUIMTBI.ts +13 -0
- package/dist/compiler-assets/chunk-SKTNMUO7.ts +64 -0
- package/dist/compiler-assets/chunk-T6WG4L4M.ts +19 -0
- package/dist/compiler-assets/chunk-TATN3PYK.ts +81 -0
- package/dist/compiler-assets/chunk-VHXHUU7L.ts +16 -0
- package/dist/compiler-assets/chunk-WMXMVFHM.ts +121 -0
- package/dist/compiler-assets/chunk-XHKPWT3G.ts +55 -0
- package/dist/compiler-assets/chunk-ZDLVA6XF.ts +476 -0
- package/dist/compiler-assets/src/authoring/agent.ts +10 -0
- package/dist/compiler-assets/src/authoring/approval.ts +19 -0
- package/dist/compiler-assets/src/authoring/brand.ts +23 -0
- package/dist/compiler-assets/src/authoring/channels.ts +26 -0
- package/dist/compiler-assets/src/authoring/connections.ts +10 -0
- package/dist/compiler-assets/src/authoring/context.ts +7 -0
- package/dist/compiler-assets/src/authoring/credentials.ts +21 -0
- package/dist/compiler-assets/src/authoring/dynamic.ts +10 -0
- package/dist/compiler-assets/src/authoring/harness.ts +17 -0
- package/dist/compiler-assets/src/authoring/hooks.ts +28 -0
- package/dist/compiler-assets/src/authoring/index.ts +110 -0
- package/dist/compiler-assets/src/authoring/instructions.ts +14 -0
- package/dist/compiler-assets/src/authoring/sandbox.ts +25 -0
- package/dist/compiler-assets/src/authoring/schedules.ts +10 -0
- package/dist/compiler-assets/src/authoring/skills.ts +10 -0
- package/dist/compiler-assets/src/authoring/tools.ts +23 -0
- package/dist/compiler-assets/src/compatibility.ts +14810 -0
- package/dist/compiler-assets/src/compiler/evaluate-child.mjs +77 -0
- package/dist/compiler-assets/src/index.ts +195 -0
- package/dist/compiler-assets/src/manifest.ts +72 -0
- package/dist/compiler-assets/src/resolve.ts +19 -0
- package/dist/compiler-assets/src/runtime/bundle.ts +72 -0
- package/dist/compiler-assets/src/runtime/describe.ts +31 -0
- package/dist/compiler-assets/src/runtime/described.ts +142 -0
- package/dist/compiler-assets/src/runtime/isolate.ts +28 -0
- package/dist/compiler-assets/src/runtime/layout.ts +15 -0
- package/dist/compiler-assets/src/runtime/lower.ts +52 -0
- package/dist/compiler-assets/src/runtime/schema-validation.ts +21 -0
- package/dist/compiler-assets/src/runtime/values.ts +38 -0
- package/dist/modules/authoring/agent.d.mts +22 -0
- package/dist/modules/authoring/agent.mjs +6 -0
- package/dist/modules/authoring/agent.mjs.map +7 -0
- package/dist/modules/authoring/approval.d.mts +17 -0
- package/dist/modules/authoring/approval.mjs +42 -0
- package/dist/modules/authoring/approval.mjs.map +7 -0
- package/dist/modules/authoring/brand.d.mts +27 -0
- package/dist/modules/authoring/brand.mjs +51 -0
- package/dist/modules/authoring/brand.mjs.map +7 -0
- package/dist/modules/authoring/channels.d.mts +41 -0
- package/dist/modules/authoring/channels.mjs +65 -0
- package/dist/modules/authoring/channels.mjs.map +7 -0
- package/dist/modules/authoring/connections.d.mts +23 -0
- package/dist/modules/authoring/connections.mjs +6 -0
- package/dist/modules/authoring/connections.mjs.map +7 -0
- package/dist/modules/authoring/context.d.mts +83 -0
- package/dist/modules/authoring/context.mjs +12 -0
- package/dist/modules/authoring/context.mjs.map +7 -0
- package/dist/modules/authoring/credentials.d.mts +10 -0
- package/dist/modules/authoring/credentials.mjs +31 -0
- package/dist/modules/authoring/credentials.mjs.map +7 -0
- package/dist/modules/authoring/dynamic.d.mts +30 -0
- package/dist/modules/authoring/dynamic.mjs +15 -0
- package/dist/modules/authoring/dynamic.mjs.map +7 -0
- package/dist/modules/authoring/harness.d.mts +85 -0
- package/dist/modules/authoring/harness.mjs +55 -0
- package/dist/modules/authoring/harness.mjs.map +7 -0
- package/dist/modules/authoring/hooks.d.mts +120 -0
- package/dist/modules/authoring/hooks.mjs +72 -0
- package/dist/modules/authoring/hooks.mjs.map +7 -0
- package/dist/modules/authoring/index.d.mts +27 -0
- package/dist/modules/authoring/index.mjs +63 -0
- package/dist/modules/authoring/index.mjs.map +7 -0
- package/dist/modules/authoring/instructions.d.mts +13 -0
- package/dist/modules/authoring/instructions.mjs +15 -0
- package/dist/modules/authoring/instructions.mjs.map +7 -0
- package/dist/modules/authoring/sandbox.d.mts +21 -0
- package/dist/modules/authoring/sandbox.mjs +13 -0
- package/dist/modules/authoring/sandbox.mjs.map +7 -0
- package/dist/modules/authoring/schedules.d.mts +8 -0
- package/dist/modules/authoring/schedules.mjs +6 -0
- package/dist/modules/authoring/schedules.mjs.map +7 -0
- package/dist/modules/authoring/skills.d.mts +8 -0
- package/dist/modules/authoring/skills.mjs +6 -0
- package/dist/modules/authoring/skills.mjs.map +7 -0
- package/dist/modules/authoring/tools.d.mts +80 -0
- package/dist/modules/authoring/tools.mjs +70 -0
- package/dist/modules/authoring/tools.mjs.map +7 -0
- package/dist/modules/compatibility.d.mts +36 -0
- package/dist/modules/compatibility.mjs +536 -0
- package/dist/modules/compatibility.mjs.map +7 -0
- package/dist/modules/compiler/assemble.d.mts +30 -0
- package/dist/modules/compiler/assemble.mjs +923 -0
- package/dist/modules/compiler/assemble.mjs.map +7 -0
- package/dist/modules/compiler/bundle.d.mts +22 -0
- package/dist/modules/compiler/bundle.mjs +385 -0
- package/dist/modules/compiler/bundle.mjs.map +7 -0
- package/dist/modules/compiler/diagnostics.d.mts +40 -0
- package/dist/modules/compiler/diagnostics.mjs +38 -0
- package/dist/modules/compiler/diagnostics.mjs.map +7 -0
- package/dist/modules/compiler/discovery.d.mts +36 -0
- package/dist/modules/compiler/discovery.mjs +158 -0
- package/dist/modules/compiler/discovery.mjs.map +7 -0
- package/dist/modules/compiler/evaluate.d.mts +13 -0
- package/dist/modules/compiler/evaluate.mjs +194 -0
- package/dist/modules/compiler/evaluate.mjs.map +7 -0
- package/dist/modules/compiler/files.d.mts +19 -0
- package/dist/modules/compiler/files.mjs +90 -0
- package/dist/modules/compiler/files.mjs.map +7 -0
- package/dist/modules/compiler/frontmatter.d.mts +9 -0
- package/dist/modules/compiler/frontmatter.mjs +34 -0
- package/dist/modules/compiler/frontmatter.mjs.map +7 -0
- package/dist/modules/compiler/index.d.mts +49 -0
- package/dist/modules/compiler/index.mjs +244 -0
- package/dist/modules/compiler/index.mjs.map +7 -0
- package/dist/modules/compiler/load.d.mts +8 -0
- package/dist/modules/compiler/load.mjs +45 -0
- package/dist/modules/compiler/load.mjs.map +7 -0
- package/dist/modules/compiler/local-isolate.d.mts +20 -0
- package/dist/modules/compiler/local-isolate.mjs +93 -0
- package/dist/modules/compiler/local-isolate.mjs.map +7 -0
- package/dist/modules/compiler/packages.d.mts +66 -0
- package/dist/modules/compiler/packages.mjs +307 -0
- package/dist/modules/compiler/packages.mjs.map +7 -0
- package/dist/modules/index.d.mts +7 -0
- package/dist/modules/index.mjs +25 -0
- package/dist/modules/index.mjs.map +7 -0
- package/dist/modules/manifest.d.mts +2 -0
- package/dist/modules/manifest.mjs +67 -0
- package/dist/modules/manifest.mjs.map +7 -0
- package/dist/modules/resolve.d.mts +24 -0
- package/dist/modules/resolve.mjs +176 -0
- package/dist/modules/resolve.mjs.map +7 -0
- package/dist/modules/runtime/bundle.d.mts +12 -0
- package/dist/modules/runtime/bundle.mjs +48 -0
- package/dist/modules/runtime/bundle.mjs.map +7 -0
- package/dist/modules/runtime/describe.d.mts +19 -0
- package/dist/modules/runtime/describe.mjs +471 -0
- package/dist/modules/runtime/describe.mjs.map +7 -0
- package/dist/modules/runtime/described.d.mts +376 -0
- package/dist/modules/runtime/described.mjs +116 -0
- package/dist/modules/runtime/described.mjs.map +7 -0
- package/dist/modules/runtime/isolate.d.mts +70 -0
- package/dist/modules/runtime/isolate.mjs +454 -0
- package/dist/modules/runtime/isolate.mjs.map +7 -0
- package/dist/modules/runtime/layout.d.mts +21 -0
- package/dist/modules/runtime/layout.mjs +24 -0
- package/dist/modules/runtime/layout.mjs.map +7 -0
- package/dist/modules/runtime/lower.d.mts +73 -0
- package/dist/modules/runtime/lower.mjs +463 -0
- package/dist/modules/runtime/lower.mjs.map +7 -0
- package/dist/modules/runtime/schema-validation.d.mts +21 -0
- package/dist/modules/runtime/schema-validation.mjs +238 -0
- package/dist/modules/runtime/schema-validation.mjs.map +7 -0
- package/dist/modules/runtime/values.d.mts +20 -0
- package/dist/modules/runtime/values.mjs +48 -0
- package/dist/modules/runtime/values.mjs.map +7 -0
- package/fixtures/acme-fleet/agent/agent.ts +74 -0
- package/fixtures/acme-fleet/agent/instructions.md +1 -0
- package/fixtures/assistant/agent/agent.ts +16 -0
- package/fixtures/assistant/agent/instructions.md +1 -0
- package/fixtures/assistant/agent/tools/current_time.ts +9 -0
- package/fixtures/assistant-with-tools/agent/agent.ts +16 -0
- package/fixtures/assistant-with-tools/agent/instructions.md +1 -0
- package/fixtures/assistant-with-tools/agent/tools/current_time.ts +9 -0
- package/fixtures/final-connection/agent/agent.ts +15 -0
- package/fixtures/final-connection/agent/connections/final.ts +9 -0
- package/fixtures/release-scout/agent/agent.ts +22 -0
- package/fixtures/release-scout/agent/channels/github-signature.ts +27 -0
- package/fixtures/release-scout/agent/channels/github.ts +38 -0
- package/fixtures/release-scout/agent/connections/linear.ts +9 -0
- package/fixtures/release-scout/agent/hooks/audit.ts +24 -0
- package/fixtures/release-scout/agent/instructions/org-context.ts +26 -0
- package/fixtures/release-scout/agent/instructions.md +2 -0
- package/fixtures/release-scout/agent/sandbox.ts +20 -0
- package/fixtures/release-scout/agent/schedules/daily-digest.md +7 -0
- package/fixtures/release-scout/agent/skills/triage/SKILL.md +8 -0
- package/fixtures/release-scout/agent/skills/triage/checklist.md +3 -0
- package/fixtures/release-scout/agent/tools/lookup_release_notes.ts +24 -0
- package/fixtures/tsconfig.json +5 -0
- package/package.json +94 -0
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../src/authoring/sandbox.ts"],
|
|
4
|
+
"sourcesContent": ["import type {\n BaseCapability,\n NetworkSandboxSessionIface,\n SandboxEnvironmentIface,\n SandboxOpenRequestIface,\n} from '@finalai/agent-provider';\nimport { AuthoredKind, stamp } from \"./brand.mjs\";\nimport type { AgentSessionInfoIface, SecretsIface } from \"./context.mjs\";\nimport type { DynamicSentinelIface } from \"./dynamic.mjs\";\n\nexport { defineSandboxProvider, SandboxWire } from '@finalai/agent-provider';\n\n// sandbox.ts: named exports are sandbox targets (an\n// environment such as `computerSetupGuide({...})`, or a defineDynamic resolving\n// to one); the default export is the default target, either an environment\n// or a selector that opens it per session.\n\nexport interface SandboxSelectorContextIface {\n readonly session: AgentSessionInfoIface;\n readonly secrets: SecretsIface;\n // Starts (or reattaches to) the requested environment and returns the live\n // session, so a selector can prepare it before the agent uses it.\n open(request: SandboxOpenRequestIface<unknown, unknown>): Promise<NetworkSandboxSessionIface>;\n}\n\nexport type SandboxSelector = (\n ctx: SandboxSelectorContextIface,\n) =>\n | NetworkSandboxSessionIface\n | SandboxOpenRequestIface<unknown, unknown>\n | Promise<NetworkSandboxSessionIface | SandboxOpenRequestIface<unknown, unknown>>;\n\n// The harness's own host as a base-tool binding: the capability is the\n// harness's native one where it runs, with no sandbox target. Only\n// harnesses that provide it natively (host-disableable, host-fixed) can serve it.\nexport interface HarnessHostIface {\n readonly harnessHost: true;\n}\n\nexport const harnessHost: HarnessHostIface = stamp({ harnessHost: true }, AuthoredKind.HarnessHost);\n\nexport type SandboxTargetValue =\n | HarnessHostIface\n | SandboxEnvironmentIface<unknown, unknown>\n | SandboxOpenRequestIface<unknown, unknown>\n | DynamicSentinelIface\n | SandboxSelector\n // A target name, for targets that are not imported (Build forms).\n | string;\n\nexport const defineSandbox = <\n T extends SandboxSelector | SandboxEnvironmentIface<unknown, unknown>,\n>(\n value: T,\n): T => (value instanceof Function ? stamp(value, AuthoredKind.SandboxSelector) : value);\n\nexport type BaseToolsInputIface = Partial<\n Record<BaseCapability | `${BaseCapability}`, SandboxTargetValue>\n>;\n\nexport interface BaseToolsValueIface {\n readonly base: BaseToolsInputIface;\n}\n\n// Declares base tool capabilities, each bound to a sandbox target exported\n// from sandbox.ts or to `harnessHost`. Targets are\n// resolved by identity to their export name at compile time.\nexport const baseTools = (base: BaseToolsInputIface): BaseToolsValueIface =>\n stamp({ base: { ...base } }, AuthoredKind.BaseTools);\n"],
|
|
5
|
+
"mappings": "AAMA,SAAS,cAAc,aAAa;AAIpC,SAAS,uBAAuB,mBAAmB;AA6B5C,MAAM,cAAgC,MAAM,EAAE,aAAa,KAAK,GAAG,aAAa,WAAW;AAW3F,MAAM,gBAAgB,CAG3B,UACO,iBAAiB,WAAW,MAAM,OAAO,aAAa,eAAe,IAAI;AAa3E,MAAM,YAAY,CAAC,SACxB,MAAM,EAAE,MAAM,EAAE,GAAG,KAAK,EAAE,GAAG,aAAa,SAAS;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { ScheduleTarget } from '@finalai/agent-provider';
|
|
2
|
+
export interface ScheduleInputIface {
|
|
3
|
+
readonly cron: string;
|
|
4
|
+
readonly markdown?: string;
|
|
5
|
+
readonly timezone?: string;
|
|
6
|
+
readonly target?: ScheduleTarget | `${ScheduleTarget}`;
|
|
7
|
+
}
|
|
8
|
+
export declare const defineSchedule: <TSchedule extends ScheduleInputIface>(definition: TSchedule) => TSchedule;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../src/authoring/schedules.ts"],
|
|
4
|
+
"sourcesContent": ["import type { ScheduleTarget } from '@finalai/agent-provider';\nimport { AuthoredKind, stamp } from \"./brand.mjs\";\n\n// A schedule authored in TypeScript (`schedules/<key>.ts`); the markdown form\n// (`schedules/<key>.md` with cron/timezone/target front matter) compiles the\n// same: a schedule is a prompt delivered to its target.\nexport interface ScheduleInputIface {\n readonly cron: string;\n readonly markdown?: string;\n readonly timezone?: string;\n readonly target?: ScheduleTarget | `${ScheduleTarget}`;\n}\n\nexport const defineSchedule = <TSchedule extends ScheduleInputIface>(\n definition: TSchedule,\n): TSchedule => stamp({ ...definition }, AuthoredKind.Schedule);\n"],
|
|
5
|
+
"mappings": "AACA,SAAS,cAAc,aAAa;AAY7B,MAAM,iBAAiB,CAC5B,eACc,MAAM,EAAE,GAAG,WAAW,GAAG,aAAa,QAAQ;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export interface SkillDefinitionIface {
|
|
2
|
+
readonly description: string;
|
|
3
|
+
readonly markdown: string;
|
|
4
|
+
readonly license?: string;
|
|
5
|
+
readonly metadata?: Record<string, string>;
|
|
6
|
+
readonly files?: Readonly<Record<string, string | Uint8Array>>;
|
|
7
|
+
}
|
|
8
|
+
export declare const defineSkill: <TSkill extends SkillDefinitionIface>(definition: TSkill) => TSkill;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../src/authoring/skills.ts"],
|
|
4
|
+
"sourcesContent": ["import { AuthoredKind, stamp } from \"./brand.mjs\";\n\n// defineSkill: a skill package whose name comes from its path under\n// skills/ (or the dynamic resolver's slug). Compiles into one entry of\n// `harness.config.skills` with SKILL.md first.\nexport interface SkillDefinitionIface {\n readonly description: string;\n readonly markdown: string;\n readonly license?: string;\n readonly metadata?: Record<string, string>;\n // Package-relative sibling files. Binary content is not supported.\n readonly files?: Readonly<Record<string, string | Uint8Array>>;\n}\n\nexport const defineSkill = <TSkill extends SkillDefinitionIface>(definition: TSkill): TSkill =>\n stamp({ ...definition }, AuthoredKind.Skill);\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,cAAc,aAAa;AAc7B,MAAM,cAAc,CAAsC,eAC/D,MAAM,EAAE,GAAG,WAAW,GAAG,aAAa,KAAK;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import type { JsonObject, JsonValue } from '@finalai/agent-provider';
|
|
2
|
+
import * as z from 'zod';
|
|
3
|
+
import { type AuthoredValue } from "../runtime/values.mjs";
|
|
4
|
+
import type { ApprovalPolicyIface } from "./approval.mjs";
|
|
5
|
+
import type { ToolContextIface } from "./context.mjs";
|
|
6
|
+
export interface StandardSchemaLikeIface<Input = AuthoredValue, Output = Input> {
|
|
7
|
+
readonly '~standard': {
|
|
8
|
+
readonly version: 1;
|
|
9
|
+
readonly vendor: string;
|
|
10
|
+
readonly validate: (value: AuthoredValue) => AuthoredValue;
|
|
11
|
+
readonly types?: {
|
|
12
|
+
readonly input: Input;
|
|
13
|
+
readonly output: Output;
|
|
14
|
+
} | undefined;
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
export type ToolInputSchema = StandardSchemaLikeIface | JsonObject;
|
|
18
|
+
export type InferSchemaOutput<TSchema> = TSchema extends {
|
|
19
|
+
readonly '~standard': {
|
|
20
|
+
readonly types?: infer TTypes;
|
|
21
|
+
};
|
|
22
|
+
} ? NonNullable<TTypes> extends {
|
|
23
|
+
readonly output: infer TOutput;
|
|
24
|
+
} ? TOutput : JsonObject : JsonObject;
|
|
25
|
+
export type ToolOutputOf<TReturn> = TReturn extends Promise<infer TOutput> ? TOutput : TReturn extends AsyncIterable<infer TOutput> ? TOutput : TReturn;
|
|
26
|
+
export interface ToolLabelIface<TInput, TOutput, TPartial = TOutput> {
|
|
27
|
+
start(input: Readonly<TInput>): string;
|
|
28
|
+
delta?(input: Readonly<TInput>, partial: Readonly<TPartial>): string;
|
|
29
|
+
complete?(input: Readonly<TInput>, output: Readonly<TOutput>): string;
|
|
30
|
+
}
|
|
31
|
+
export declare const toolLabelSchema: z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
|
|
32
|
+
start: z.ZodCustom<import("../runtime/values.mjs").AuthoredCallable, import("../runtime/values.mjs").AuthoredCallable>;
|
|
33
|
+
delta: z.ZodOptional<z.ZodCustom<import("../runtime/values.mjs").AuthoredCallable, import("../runtime/values.mjs").AuthoredCallable>>;
|
|
34
|
+
complete: z.ZodOptional<z.ZodCustom<import("../runtime/values.mjs").AuthoredCallable, import("../runtime/values.mjs").AuthoredCallable>>;
|
|
35
|
+
}, z.core.$strip>]>;
|
|
36
|
+
export interface ToolAnnotationsIface {
|
|
37
|
+
title?: string;
|
|
38
|
+
readOnlyHint?: boolean;
|
|
39
|
+
destructiveHint?: boolean;
|
|
40
|
+
idempotentHint?: boolean;
|
|
41
|
+
openWorldHint?: boolean;
|
|
42
|
+
}
|
|
43
|
+
export interface ToolDefinitionIface<TInput, TOutput, TReturn = unknown> {
|
|
44
|
+
readonly description: string;
|
|
45
|
+
readonly inputSchema: ToolInputSchema;
|
|
46
|
+
readonly outputSchema?: ToolInputSchema;
|
|
47
|
+
execute(input: TInput, ctx: ToolContextIface): TReturn;
|
|
48
|
+
readonly approval?: ApprovalPolicyIface<TInput>;
|
|
49
|
+
readonly label?: string | ToolLabelIface<TInput, TOutput, ToolOutputOf<TReturn>>;
|
|
50
|
+
readonly toModelOutput?: (output: TOutput) => JsonValue | Promise<JsonValue>;
|
|
51
|
+
readonly annotations?: ToolAnnotationsIface;
|
|
52
|
+
readonly endsTurn?: boolean | ((output: TOutput) => boolean | Promise<boolean>);
|
|
53
|
+
}
|
|
54
|
+
export interface DefinedToolIface<TInput, TOutput, TReturn = unknown> extends ToolDefinitionIface<TInput, TOutput, TReturn> {
|
|
55
|
+
readonly __output?: TOutput;
|
|
56
|
+
}
|
|
57
|
+
type ValidatedToolOutput<TSchema, TReturn> = ToolInputSchema extends TSchema ? ToolOutputOf<TReturn> : TSchema extends {
|
|
58
|
+
readonly '~standard': object;
|
|
59
|
+
} ? InferSchemaOutput<TSchema> : ToolOutputOf<TReturn>;
|
|
60
|
+
export declare const defineTool: <TSchema extends ToolInputSchema, TReturn, TOutputSchema extends ToolInputSchema | undefined = ToolInputSchema | undefined>(definition: ToolDefinitionIface<InferSchemaOutput<TSchema>, ValidatedToolOutput<TOutputSchema, TReturn>, TReturn> & {
|
|
61
|
+
readonly inputSchema: TSchema;
|
|
62
|
+
readonly outputSchema?: TOutputSchema;
|
|
63
|
+
}) => DefinedToolIface<InferSchemaOutput<TSchema>, ValidatedToolOutput<TOutputSchema, TReturn>, TReturn>;
|
|
64
|
+
export declare const registerToolName: (tool: AuthoredValue, name: string) => void;
|
|
65
|
+
export interface ToolCallEventDataIface {
|
|
66
|
+
toolCallId: string;
|
|
67
|
+
status: string | null;
|
|
68
|
+
toolName: string | null;
|
|
69
|
+
title: string | null;
|
|
70
|
+
rawInput: Record<string, JsonValue>;
|
|
71
|
+
rawOutput: JsonValue | null;
|
|
72
|
+
}
|
|
73
|
+
export declare const toolResultFrom: <TOutput>(event: {
|
|
74
|
+
readonly type: string;
|
|
75
|
+
readonly data: AuthoredValue;
|
|
76
|
+
}, tool: {
|
|
77
|
+
readonly __output?: TOutput;
|
|
78
|
+
readonly outputSchema?: ToolInputSchema;
|
|
79
|
+
}) => TOutput | undefined;
|
|
80
|
+
export { defineDynamic } from "./dynamic.mjs";
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import * as z from "zod";
|
|
2
|
+
import { resultMatchesSchema } from "../runtime/schema-validation.mjs";
|
|
3
|
+
import {
|
|
4
|
+
callableSchema,
|
|
5
|
+
isObjectLike,
|
|
6
|
+
optionalValueSchema
|
|
7
|
+
} from "../runtime/values.mjs";
|
|
8
|
+
import { AuthoredKind, stamp } from "./brand.mjs";
|
|
9
|
+
const toolLabelSchema = z.union([
|
|
10
|
+
z.string(),
|
|
11
|
+
z.object({
|
|
12
|
+
start: callableSchema,
|
|
13
|
+
delta: callableSchema.optional(),
|
|
14
|
+
complete: callableSchema.optional()
|
|
15
|
+
})
|
|
16
|
+
]);
|
|
17
|
+
const defineTool = (definition) => stamp({ ...definition }, AuthoredKind.Tool);
|
|
18
|
+
const toolNames = /* @__PURE__ */ new WeakMap();
|
|
19
|
+
const registerToolName = (tool, name) => {
|
|
20
|
+
if (!isObjectLike(tool)) return;
|
|
21
|
+
toolNames.set(tool, [...toolNames.get(tool) ?? [], name]);
|
|
22
|
+
};
|
|
23
|
+
const nameMatches = (qualified, name) => qualified === name || qualified.endsWith(`/${name}`) || qualified.endsWith(`__${name}`);
|
|
24
|
+
const toolCallUpdateSchema = z.looseObject({
|
|
25
|
+
status: z.string().nullish(),
|
|
26
|
+
toolName: z.string(),
|
|
27
|
+
rawOutput: optionalValueSchema
|
|
28
|
+
});
|
|
29
|
+
const mcpResultSchema = z.looseObject({
|
|
30
|
+
isError: z.boolean().optional(),
|
|
31
|
+
structuredContent: optionalValueSchema,
|
|
32
|
+
content: z.array(z.looseObject({ type: z.string(), text: z.string().optional() })).optional()
|
|
33
|
+
});
|
|
34
|
+
const toolOutputOf = (rawOutput) => {
|
|
35
|
+
const result = mcpResultSchema.safeParse(rawOutput);
|
|
36
|
+
if (!result.success) return { output: rawOutput, failed: false };
|
|
37
|
+
if (result.data.isError === true) return { output: null, failed: true };
|
|
38
|
+
if (result.data.structuredContent != null)
|
|
39
|
+
return { output: result.data.structuredContent, failed: false };
|
|
40
|
+
const text = result.data.content?.find((block) => block.type === "text")?.text;
|
|
41
|
+
if (text == null) return { output: rawOutput, failed: false };
|
|
42
|
+
try {
|
|
43
|
+
const parsed = JSON.parse(text);
|
|
44
|
+
return { output: parsed, failed: false };
|
|
45
|
+
} catch {
|
|
46
|
+
return { output: text, failed: false };
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
const isToolOutput = (tool, value) => resultMatchesSchema(tool.outputSchema, value);
|
|
50
|
+
const toolResultFrom = (event, tool) => {
|
|
51
|
+
if (event.type !== "tool_call_update") return void 0;
|
|
52
|
+
const data = toolCallUpdateSchema.safeParse(event.data);
|
|
53
|
+
if (!data.success) return void 0;
|
|
54
|
+
if (data.data.status != null && data.data.status !== "completed") return void 0;
|
|
55
|
+
const qualified = data.data.toolName;
|
|
56
|
+
const names = isObjectLike(tool) ? toolNames.get(tool) ?? [] : [];
|
|
57
|
+
if (!names.some((name) => nameMatches(qualified, name))) return void 0;
|
|
58
|
+
const { output, failed } = toolOutputOf(data.data.rawOutput);
|
|
59
|
+
if (failed) return void 0;
|
|
60
|
+
return isToolOutput(tool, output) ? output : void 0;
|
|
61
|
+
};
|
|
62
|
+
import { defineDynamic } from "./dynamic.mjs";
|
|
63
|
+
export {
|
|
64
|
+
defineDynamic,
|
|
65
|
+
defineTool,
|
|
66
|
+
registerToolName,
|
|
67
|
+
toolLabelSchema,
|
|
68
|
+
toolResultFrom
|
|
69
|
+
};
|
|
70
|
+
//# sourceMappingURL=tools.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../src/authoring/tools.ts"],
|
|
4
|
+
"sourcesContent": ["import type { JsonObject, JsonValue } from '@finalai/agent-provider';\nimport * as z from 'zod';\nimport { resultMatchesSchema } from \"../runtime/schema-validation.mjs\";\nimport {\n callableSchema,\n isObjectLike,\n optionalValueSchema,\n type AuthoredValue,\n} from \"../runtime/values.mjs\";\nimport type { ApprovalPolicyIface } from \"./approval.mjs\";\nimport { AuthoredKind, stamp } from \"./brand.mjs\";\nimport type { ToolContextIface } from \"./context.mjs\";\n\n// Authored tools are exposed through MCP. `endsTurn` is rejected at compile\n// time because the harness owns the loop.\n\n// The Standard Schema surface (zod 4, valibot, arktype) that tools accept.\nexport interface StandardSchemaLikeIface<Input = AuthoredValue, Output = Input> {\n readonly '~standard': {\n readonly version: 1;\n readonly vendor: string;\n readonly validate: (value: AuthoredValue) => AuthoredValue;\n readonly types?: { readonly input: Input; readonly output: Output } | undefined;\n };\n}\n\nexport type ToolInputSchema = StandardSchemaLikeIface | JsonObject;\n\nexport type InferSchemaOutput<TSchema> = TSchema extends {\n readonly '~standard': { readonly types?: infer TTypes };\n}\n ? NonNullable<TTypes> extends { readonly output: infer TOutput }\n ? TOutput\n : JsonObject\n : JsonObject;\n\nexport type ToolOutputOf<TReturn> =\n TReturn extends Promise<infer TOutput>\n ? TOutput\n : TReturn extends AsyncIterable<infer TOutput>\n ? TOutput\n : TReturn;\n\nexport interface ToolLabelIface<TInput, TOutput, TPartial = TOutput> {\n start(input: Readonly<TInput>): string;\n delta?(input: Readonly<TInput>, partial: Readonly<TPartial>): string;\n complete?(input: Readonly<TInput>, output: Readonly<TOutput>): string;\n}\n\nexport const toolLabelSchema = z.union([\n z.string(),\n z.object({\n start: callableSchema,\n delta: callableSchema.optional(),\n complete: callableSchema.optional(),\n }),\n]);\n\nexport interface ToolAnnotationsIface {\n title?: string;\n readOnlyHint?: boolean;\n destructiveHint?: boolean;\n idempotentHint?: boolean;\n openWorldHint?: boolean;\n}\n\nexport interface ToolDefinitionIface<TInput, TOutput, TReturn = unknown> {\n readonly description: string;\n readonly inputSchema: ToolInputSchema;\n readonly outputSchema?: ToolInputSchema;\n // Returns the output, a promise of it, or an async iterable whose yields are\n // progress and whose last value is the output.\n execute(input: TInput, ctx: ToolContextIface): TReturn;\n readonly approval?: ApprovalPolicyIface<TInput>;\n // A plain string becomes the MCP tool title.\n readonly label?: string | ToolLabelIface<TInput, TOutput, ToolOutputOf<TReturn>>;\n readonly toModelOutput?: (output: TOutput) => JsonValue | Promise<JsonValue>;\n readonly annotations?: ToolAnnotationsIface;\n // Rejected at compile time: the harness owns the loop.\n readonly endsTurn?: boolean | ((output: TOutput) => boolean | Promise<boolean>);\n}\n\nexport interface DefinedToolIface<TInput, TOutput, TReturn = unknown> extends ToolDefinitionIface<\n TInput,\n TOutput,\n TReturn\n> {\n // Type-level only: lets toolResultFrom narrow to this tool's output.\n readonly __output?: TOutput;\n}\n\ntype ValidatedToolOutput<TSchema, TReturn> = ToolInputSchema extends TSchema\n ? ToolOutputOf<TReturn>\n : TSchema extends { readonly '~standard': object }\n ? InferSchemaOutput<TSchema>\n : ToolOutputOf<TReturn>;\n\nexport const defineTool = <\n TSchema extends ToolInputSchema,\n TReturn,\n TOutputSchema extends ToolInputSchema | undefined = ToolInputSchema | undefined,\n>(\n definition: ToolDefinitionIface<\n InferSchemaOutput<TSchema>,\n ValidatedToolOutput<TOutputSchema, TReturn>,\n TReturn\n > & {\n readonly inputSchema: TSchema;\n readonly outputSchema?: TOutputSchema;\n },\n): DefinedToolIface<\n InferSchemaOutput<TSchema>,\n ValidatedToolOutput<TOutputSchema, TReturn>,\n TReturn\n> => stamp({ ...definition }, AuthoredKind.Tool);\n\nconst toolNames = new WeakMap<object, string[]>();\n\n// Called by the bundle for every authored tool, so hooks can match tool_call\n// updates to the tool definitions they import.\nexport const registerToolName = (tool: AuthoredValue, name: string): void => {\n if (!isObjectLike(tool)) return;\n toolNames.set(tool, [...(toolNames.get(tool) ?? []), name]);\n};\n\nexport interface ToolCallEventDataIface {\n toolCallId: string;\n status: string | null;\n // Qualified name (`<serverKey>/<tool>`) the session service attaches from the\n // MCP host's call record; null for harness-native tools.\n toolName: string | null;\n title: string | null;\n rawInput: Record<string, JsonValue>;\n rawOutput: JsonValue | null;\n}\n\nconst nameMatches = (qualified: string, name: string): boolean =>\n qualified === name || qualified.endsWith(`/${name}`) || qualified.endsWith(`__${name}`);\n\nconst toolCallUpdateSchema = z.looseObject({\n status: z.string().nullish(),\n toolName: z.string(),\n rawOutput: optionalValueSchema,\n});\n\nconst mcpResultSchema = z.looseObject({\n isError: z.boolean().optional(),\n structuredContent: optionalValueSchema,\n content: z.array(z.looseObject({ type: z.string(), text: z.string().optional() })).optional(),\n});\n\n// An MCP call result's structured content, or its first text block parsed as JSON.\ninterface ParsedToolOutputIface {\n output: AuthoredValue;\n failed: boolean;\n}\n\nconst toolOutputOf = (rawOutput: AuthoredValue): ParsedToolOutputIface => {\n const result = mcpResultSchema.safeParse(rawOutput);\n if (!result.success) return { output: rawOutput, failed: false };\n if (result.data.isError === true) return { output: null, failed: true };\n if (result.data.structuredContent != null)\n return { output: result.data.structuredContent, failed: false };\n const text = result.data.content?.find((block) => block.type === 'text')?.text;\n if (text == null) return { output: rawOutput, failed: false };\n try {\n const parsed: AuthoredValue = JSON.parse(text);\n return { output: parsed, failed: false };\n } catch {\n return { output: text, failed: false };\n }\n};\n\n// A tool without an output schema is trusted, as first-party tRPC responses are.\nconst isToolOutput = <TOutput>(\n tool: { readonly __output?: TOutput; readonly outputSchema?: ToolInputSchema },\n value: AuthoredValue,\n): value is TOutput => resultMatchesSchema(tool.outputSchema, value);\n\n// Narrows a completed tool_call update to one authored tool's output.\n// Returns undefined for other tools, unfinished calls and errors.\nexport const toolResultFrom = <TOutput>(\n event: { readonly type: string; readonly data: AuthoredValue },\n tool: { readonly __output?: TOutput; readonly outputSchema?: ToolInputSchema },\n): TOutput | undefined => {\n if (event.type !== 'tool_call_update') return undefined;\n const data = toolCallUpdateSchema.safeParse(event.data);\n if (!data.success) return undefined;\n if (data.data.status != null && data.data.status !== 'completed') return undefined;\n const qualified = data.data.toolName;\n const names = isObjectLike(tool) ? (toolNames.get(tool) ?? []) : [];\n if (!names.some((name) => nameMatches(qualified, name))) return undefined;\n const { output, failed } = toolOutputOf(data.data.rawOutput);\n if (failed) return undefined;\n return isToolOutput(tool, output) ? output : undefined;\n};\n\nexport { defineDynamic } from \"./dynamic.mjs\";\n"],
|
|
5
|
+
"mappings": "AACA,YAAY,OAAO;AACnB,SAAS,2BAA2B;AACpC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OAEK;AAEP,SAAS,cAAc,aAAa;AAuC7B,MAAM,kBAAkB,EAAE,MAAM;AAAA,EACrC,EAAE,OAAO;AAAA,EACT,EAAE,OAAO;AAAA,IACP,OAAO;AAAA,IACP,OAAO,eAAe,SAAS;AAAA,IAC/B,UAAU,eAAe,SAAS;AAAA,EACpC,CAAC;AACH,CAAC;AAyCM,MAAM,aAAa,CAKxB,eAYG,MAAM,EAAE,GAAG,WAAW,GAAG,aAAa,IAAI;AAE/C,MAAM,YAAY,oBAAI,QAA0B;AAIzC,MAAM,mBAAmB,CAAC,MAAqB,SAAuB;AAC3E,MAAI,CAAC,aAAa,IAAI,EAAG;AACzB,YAAU,IAAI,MAAM,CAAC,GAAI,UAAU,IAAI,IAAI,KAAK,CAAC,GAAI,IAAI,CAAC;AAC5D;AAaA,MAAM,cAAc,CAAC,WAAmB,SACtC,cAAc,QAAQ,UAAU,SAAS,IAAI,IAAI,EAAE,KAAK,UAAU,SAAS,KAAK,IAAI,EAAE;AAExF,MAAM,uBAAuB,EAAE,YAAY;AAAA,EACzC,QAAQ,EAAE,OAAO,EAAE,QAAQ;AAAA,EAC3B,UAAU,EAAE,OAAO;AAAA,EACnB,WAAW;AACb,CAAC;AAED,MAAM,kBAAkB,EAAE,YAAY;AAAA,EACpC,SAAS,EAAE,QAAQ,EAAE,SAAS;AAAA,EAC9B,mBAAmB;AAAA,EACnB,SAAS,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,OAAO,GAAG,MAAM,EAAE,OAAO,EAAE,SAAS,EAAE,CAAC,CAAC,EAAE,SAAS;AAC9F,CAAC;AAQD,MAAM,eAAe,CAAC,cAAoD;AACxE,QAAM,SAAS,gBAAgB,UAAU,SAAS;AAClD,MAAI,CAAC,OAAO,QAAS,QAAO,EAAE,QAAQ,WAAW,QAAQ,MAAM;AAC/D,MAAI,OAAO,KAAK,YAAY,KAAM,QAAO,EAAE,QAAQ,MAAM,QAAQ,KAAK;AACtE,MAAI,OAAO,KAAK,qBAAqB;AACnC,WAAO,EAAE,QAAQ,OAAO,KAAK,mBAAmB,QAAQ,MAAM;AAChE,QAAM,OAAO,OAAO,KAAK,SAAS,KAAK,CAAC,UAAU,MAAM,SAAS,MAAM,GAAG;AAC1E,MAAI,QAAQ,KAAM,QAAO,EAAE,QAAQ,WAAW,QAAQ,MAAM;AAC5D,MAAI;AACF,UAAM,SAAwB,KAAK,MAAM,IAAI;AAC7C,WAAO,EAAE,QAAQ,QAAQ,QAAQ,MAAM;AAAA,EACzC,QAAQ;AACN,WAAO,EAAE,QAAQ,MAAM,QAAQ,MAAM;AAAA,EACvC;AACF;AAGA,MAAM,eAAe,CACnB,MACA,UACqB,oBAAoB,KAAK,cAAc,KAAK;AAI5D,MAAM,iBAAiB,CAC5B,OACA,SACwB;AACxB,MAAI,MAAM,SAAS,mBAAoB,QAAO;AAC9C,QAAM,OAAO,qBAAqB,UAAU,MAAM,IAAI;AACtD,MAAI,CAAC,KAAK,QAAS,QAAO;AAC1B,MAAI,KAAK,KAAK,UAAU,QAAQ,KAAK,KAAK,WAAW,YAAa,QAAO;AACzE,QAAM,YAAY,KAAK,KAAK;AAC5B,QAAM,QAAQ,aAAa,IAAI,IAAK,UAAU,IAAI,IAAI,KAAK,CAAC,IAAK,CAAC;AAClE,MAAI,CAAC,MAAM,KAAK,CAAC,SAAS,YAAY,WAAW,IAAI,CAAC,EAAG,QAAO;AAChE,QAAM,EAAE,QAAQ,OAAO,IAAI,aAAa,KAAK,KAAK,SAAS;AAC3D,MAAI,OAAQ,QAAO;AACnB,SAAO,aAAa,MAAM,MAAM,IAAI,SAAS;AAC/C;AAEA,SAAS,qBAAqB;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { type AgentManifestIface, type HarnessDescriptionIface, type JsonValue, type ProviderRef } from '@finalai/agent-provider';
|
|
2
|
+
export declare enum CompatibilityResult {
|
|
3
|
+
Valid = "valid",
|
|
4
|
+
Invalid = "invalid",
|
|
5
|
+
Applies = "applies",
|
|
6
|
+
Unused = "unused",
|
|
7
|
+
Transformed = "transformed",
|
|
8
|
+
Unavailable = "unavailable",
|
|
9
|
+
Host = "host",
|
|
10
|
+
Absent = "absent",
|
|
11
|
+
Dynamic = "dynamic"
|
|
12
|
+
}
|
|
13
|
+
export interface CompatibilityRowIface {
|
|
14
|
+
item: string;
|
|
15
|
+
result: CompatibilityResult;
|
|
16
|
+
why: string;
|
|
17
|
+
}
|
|
18
|
+
export interface CompatibilityReportIface {
|
|
19
|
+
harness: ProviderRef;
|
|
20
|
+
ok: boolean;
|
|
21
|
+
rows: CompatibilityRowIface[];
|
|
22
|
+
}
|
|
23
|
+
export interface DirectoryFieldFilesIface {
|
|
24
|
+
instructions: string[];
|
|
25
|
+
skills: string[];
|
|
26
|
+
}
|
|
27
|
+
export interface CompatibilityReportArgsIface {
|
|
28
|
+
manifest: AgentManifestIface;
|
|
29
|
+
description: HarnessDescriptionIface;
|
|
30
|
+
directoryFiles?: DirectoryFieldFilesIface;
|
|
31
|
+
}
|
|
32
|
+
export declare const harnessConfigError: (args: {
|
|
33
|
+
config: JsonValue;
|
|
34
|
+
description: HarnessDescriptionIface;
|
|
35
|
+
}) => string | null;
|
|
36
|
+
export declare const compatibilityReport: (args: CompatibilityReportArgsIface) => CompatibilityReportIface;
|