@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,30 @@
|
|
|
1
|
+
import type { ProviderRef } from '@finalai/agent-provider';
|
|
2
|
+
import type { DynamicResolveContextIface } from "./context.mjs";
|
|
3
|
+
export type DynamicHandler<TResult> = (event: DynamicBoundaryEventIface, ctx: DynamicResolveContextIface) => TResult | Promise<TResult>;
|
|
4
|
+
export interface DynamicBoundaryEventIface {
|
|
5
|
+
type: 'session.started' | 'turn.started';
|
|
6
|
+
prompt: unknown[] | null;
|
|
7
|
+
}
|
|
8
|
+
export interface DynamicEventsIface<TResult> {
|
|
9
|
+
readonly 'session.started'?: DynamicHandler<TResult>;
|
|
10
|
+
readonly 'turn.started'?: DynamicHandler<TResult>;
|
|
11
|
+
}
|
|
12
|
+
export type DynamicProviderHint = ProviderRef | {
|
|
13
|
+
readonly name: string;
|
|
14
|
+
} | {
|
|
15
|
+
readonly providerRef: ProviderRef;
|
|
16
|
+
};
|
|
17
|
+
export interface DynamicDefinitionIface<TResult> {
|
|
18
|
+
readonly events: DynamicEventsIface<TResult>;
|
|
19
|
+
readonly description?: string;
|
|
20
|
+
readonly preview?: string;
|
|
21
|
+
readonly provider?: DynamicProviderHint;
|
|
22
|
+
}
|
|
23
|
+
export interface DynamicSentinelIface<TResult = unknown> {
|
|
24
|
+
readonly kind: 'final:dynamic';
|
|
25
|
+
readonly events: DynamicEventsIface<TResult>;
|
|
26
|
+
readonly description?: string;
|
|
27
|
+
readonly preview?: string;
|
|
28
|
+
readonly provider?: DynamicProviderHint;
|
|
29
|
+
}
|
|
30
|
+
export declare const defineDynamic: <TResult>(definition: DynamicDefinitionIface<TResult>) => DynamicSentinelIface<TResult>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { AuthoredKind, stamp } from "./brand.mjs";
|
|
2
|
+
const defineDynamic = (definition) => {
|
|
3
|
+
const sentinel = {
|
|
4
|
+
kind: "final:dynamic",
|
|
5
|
+
events: definition.events
|
|
6
|
+
};
|
|
7
|
+
if (definition.description != null) sentinel.description = definition.description;
|
|
8
|
+
if (definition.preview != null) sentinel.preview = definition.preview;
|
|
9
|
+
if (definition.provider != null) sentinel.provider = definition.provider;
|
|
10
|
+
return stamp(sentinel, AuthoredKind.Dynamic);
|
|
11
|
+
};
|
|
12
|
+
export {
|
|
13
|
+
defineDynamic
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=dynamic.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../src/authoring/dynamic.ts"],
|
|
4
|
+
"sourcesContent": ["import type { ProviderRef } from '@finalai/agent-provider';\nimport { AuthoredKind, stamp } from \"./brand.mjs\";\nimport type { DynamicResolveContextIface } from \"./context.mjs\";\n\n// defineDynamic: a definition computed at a lifecycle\n// boundary. The directory a file sits in decides what a handler must return.\n// `description` and `preview` are Final additions so Build can render a slot\n// without resolving it.\n\nexport type DynamicHandler<TResult> = (\n event: DynamicBoundaryEventIface,\n ctx: DynamicResolveContextIface,\n) => TResult | Promise<TResult>;\n\nexport interface DynamicBoundaryEventIface {\n type: 'session.started' | 'turn.started';\n // The prompt that started the turn (turn.started only), as ACP content blocks.\n prompt: unknown[] | null;\n}\n\nexport interface DynamicEventsIface<TResult> {\n readonly 'session.started'?: DynamicHandler<TResult>;\n readonly 'turn.started'?: DynamicHandler<TResult>;\n}\n\n// A sandbox target whose environment is dynamic still needs its provider at\n// compile time: an installed provider helper, a provider defined with\n// defineSandboxProvider, or a provider reference.\nexport type DynamicProviderHint =\n | ProviderRef\n | { readonly name: string }\n | { readonly providerRef: ProviderRef };\n\nexport interface DynamicDefinitionIface<TResult> {\n readonly events: DynamicEventsIface<TResult>;\n readonly description?: string;\n readonly preview?: string;\n readonly provider?: DynamicProviderHint;\n}\n\nexport interface DynamicSentinelIface<TResult = unknown> {\n readonly kind: 'final:dynamic';\n readonly events: DynamicEventsIface<TResult>;\n readonly description?: string;\n readonly preview?: string;\n readonly provider?: DynamicProviderHint;\n}\n\ninterface DynamicSentinelFieldsIface<TResult> {\n kind: 'final:dynamic';\n events: DynamicEventsIface<TResult>;\n description?: string;\n preview?: string;\n provider?: DynamicProviderHint;\n}\n\nexport const defineDynamic = <TResult>(\n definition: DynamicDefinitionIface<TResult>,\n): DynamicSentinelIface<TResult> => {\n const sentinel: DynamicSentinelFieldsIface<TResult> = {\n kind: 'final:dynamic',\n events: definition.events,\n };\n if (definition.description != null) sentinel.description = definition.description;\n if (definition.preview != null) sentinel.preview = definition.preview;\n if (definition.provider != null) sentinel.provider = definition.provider;\n return stamp(sentinel, AuthoredKind.Dynamic);\n};\n"],
|
|
5
|
+
"mappings": "AACA,SAAS,cAAc,aAAa;AAuD7B,MAAM,gBAAgB,CAC3B,eACkC;AAClC,QAAM,WAAgD;AAAA,IACpD,MAAM;AAAA,IACN,QAAQ,WAAW;AAAA,EACrB;AACA,MAAI,WAAW,eAAe,KAAM,UAAS,cAAc,WAAW;AACtE,MAAI,WAAW,WAAW,KAAM,UAAS,UAAU,WAAW;AAC9D,MAAI,WAAW,YAAY,KAAM,UAAS,WAAW,WAAW;AAChE,SAAO,MAAM,UAAU,aAAa,OAAO;AAC7C;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { CredentialDelivery, InferenceCredentialKind, type AcpTransport, type DefinedHarnessBindingIface, type DescribeHarnessArgsIface, type HarnessClientTlsIface, type HarnessDescriptionIface, type HarnessSessionRefIface, type JsonSchema, type JsonValue, type McpTransportKind, type OpenHarnessSessionArgsIface, type PromptWhileRunning, type SandboxWire, type SecretReaderIface, type UserInstructionDelivery } from '@finalai/agent-provider';
|
|
2
|
+
type EnumInput<E extends string> = E | `${E}`;
|
|
3
|
+
export interface AuthoredHarnessDescriptionIface {
|
|
4
|
+
configSchema: JsonSchema;
|
|
5
|
+
userInstructionDelivery?: EnumInput<UserInstructionDelivery>;
|
|
6
|
+
acp: {
|
|
7
|
+
transports: readonly EnumInput<AcpTransport.Ws | AcpTransport.Http>[];
|
|
8
|
+
mcp?: readonly EnumInput<McpTransportKind>[];
|
|
9
|
+
};
|
|
10
|
+
baseTools?: HarnessDescriptionIface['baseTools'];
|
|
11
|
+
consumes?: readonly EnumInput<SandboxWire>[];
|
|
12
|
+
inference?: {
|
|
13
|
+
vendors?: readonly string[];
|
|
14
|
+
kinds?: readonly EnumInput<InferenceCredentialKind>[];
|
|
15
|
+
delivery?: EnumInput<CredentialDelivery>;
|
|
16
|
+
};
|
|
17
|
+
supports?: Partial<HarnessDescriptionIface['supports']>;
|
|
18
|
+
promptWhileRunning?: EnumInput<PromptWhileRunning>;
|
|
19
|
+
sessionSurvivesDisconnect?: boolean;
|
|
20
|
+
}
|
|
21
|
+
export interface AuthoredHarnessSessionRefIface {
|
|
22
|
+
harnessSessionRef: string;
|
|
23
|
+
generation: number;
|
|
24
|
+
}
|
|
25
|
+
export type AuthoredHarnessEndpointIface = {
|
|
26
|
+
ref: AuthoredHarnessSessionRefIface;
|
|
27
|
+
transport: EnumInput<AcpTransport.Ws>;
|
|
28
|
+
url: string;
|
|
29
|
+
headers?: Record<string, string>;
|
|
30
|
+
tls?: HarnessClientTlsIface;
|
|
31
|
+
} | {
|
|
32
|
+
ref: AuthoredHarnessSessionRefIface;
|
|
33
|
+
transport: EnumInput<AcpTransport.Http>;
|
|
34
|
+
url: string;
|
|
35
|
+
headers?: Record<string, string>;
|
|
36
|
+
tls?: HarnessClientTlsIface;
|
|
37
|
+
};
|
|
38
|
+
export interface AuthoredHarnessOpenArgsIface<Config> extends Omit<OpenHarnessSessionArgsIface, 'config' | 'observer'> {
|
|
39
|
+
config: Config;
|
|
40
|
+
sessionId: string;
|
|
41
|
+
}
|
|
42
|
+
export interface AuthoredHarnessResumeArgsIface<Config> extends AuthoredHarnessOpenArgsIface<Config> {
|
|
43
|
+
ref: HarnessSessionRefIface;
|
|
44
|
+
lastSeq: number;
|
|
45
|
+
}
|
|
46
|
+
export type HarnessOpenCallIface<Config> = Omit<AuthoredHarnessOpenArgsIface<Config>, 'sessionId'>;
|
|
47
|
+
export type HarnessResumeCallIface<Config> = Omit<AuthoredHarnessResumeArgsIface<Config>, 'sessionId'>;
|
|
48
|
+
export interface AuthoredHarnessRefContextIface {
|
|
49
|
+
secrets: SecretReaderIface;
|
|
50
|
+
}
|
|
51
|
+
export interface AuthoredHarnessCloseContextIface extends AuthoredHarnessRefContextIface {
|
|
52
|
+
force: boolean;
|
|
53
|
+
}
|
|
54
|
+
export type AuthoredHarnessRefArgIface<Context extends AuthoredHarnessRefContextIface> = HarnessSessionRefIface & Context & {
|
|
55
|
+
ref: HarnessSessionRefIface;
|
|
56
|
+
};
|
|
57
|
+
export interface AuthoredHarnessHealthIface {
|
|
58
|
+
ok: boolean;
|
|
59
|
+
detail?: string;
|
|
60
|
+
checkedAt?: string;
|
|
61
|
+
}
|
|
62
|
+
export interface AuthoredHarnessIface<Config> {
|
|
63
|
+
describe(binding?: DescribeHarnessArgsIface): Promise<AuthoredHarnessDescriptionIface>;
|
|
64
|
+
open(args: AuthoredHarnessOpenArgsIface<Config>): Promise<AuthoredHarnessEndpointIface>;
|
|
65
|
+
resume(args: AuthoredHarnessResumeArgsIface<Config>): Promise<AuthoredHarnessEndpointIface>;
|
|
66
|
+
park(ref: AuthoredHarnessRefArgIface<AuthoredHarnessRefContextIface>, ctx: AuthoredHarnessRefContextIface): Promise<void>;
|
|
67
|
+
close(ref: AuthoredHarnessRefArgIface<AuthoredHarnessCloseContextIface>, ctx: AuthoredHarnessCloseContextIface): Promise<void>;
|
|
68
|
+
health(ref: AuthoredHarnessRefArgIface<AuthoredHarnessRefContextIface>, ctx: AuthoredHarnessRefContextIface): Promise<AuthoredHarnessHealthIface>;
|
|
69
|
+
}
|
|
70
|
+
export interface DefinedAuthoredHarnessIface<Config> {
|
|
71
|
+
(config: Config): DefinedHarnessBindingIface;
|
|
72
|
+
describe(binding?: DescribeHarnessArgsIface): Promise<HarnessDescriptionIface>;
|
|
73
|
+
open(args: HarnessOpenCallIface<Config>): Promise<AuthoredHarnessEndpointIface>;
|
|
74
|
+
resume(args: HarnessResumeCallIface<Config>): Promise<AuthoredHarnessEndpointIface>;
|
|
75
|
+
park(ref: HarnessSessionRefIface, ctx: AuthoredHarnessRefContextIface): Promise<void>;
|
|
76
|
+
close(ref: HarnessSessionRefIface, ctx: AuthoredHarnessCloseContextIface): Promise<void>;
|
|
77
|
+
health(ref: HarnessSessionRefIface, ctx: AuthoredHarnessRefContextIface): Promise<{
|
|
78
|
+
ok: boolean;
|
|
79
|
+
detail?: string;
|
|
80
|
+
checkedAt: string;
|
|
81
|
+
}>;
|
|
82
|
+
}
|
|
83
|
+
export declare const completeHarnessDescription: (authored: AuthoredHarnessDescriptionIface) => HarnessDescriptionIface;
|
|
84
|
+
export declare const defineHarness: <Config extends JsonValue = JsonValue>(implementation: AuthoredHarnessIface<Config>) => DefinedAuthoredHarnessIface<Config>;
|
|
85
|
+
export {};
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import {
|
|
2
|
+
bundleRef,
|
|
3
|
+
CredentialDelivery,
|
|
4
|
+
harnessDescriptionSchema,
|
|
5
|
+
InferenceCredentialKind
|
|
6
|
+
} from "@finalai/agent-provider";
|
|
7
|
+
import { registerPending } from "./brand.mjs";
|
|
8
|
+
const completeHarnessDescription = (authored) => {
|
|
9
|
+
const supports = {
|
|
10
|
+
observe: authored.supports?.observe ?? false,
|
|
11
|
+
resumeReplay: authored.supports?.resumeReplay ?? false,
|
|
12
|
+
fork: authored.supports?.fork ?? false,
|
|
13
|
+
authorMeta: authored.supports?.authorMeta ?? false
|
|
14
|
+
};
|
|
15
|
+
if (authored.supports?.nativeToolPolicy != null)
|
|
16
|
+
supports.nativeToolPolicy = authored.supports.nativeToolPolicy;
|
|
17
|
+
return harnessDescriptionSchema.parse({
|
|
18
|
+
...authored,
|
|
19
|
+
acp: { transports: authored.acp.transports, mcp: authored.acp.mcp ?? [] },
|
|
20
|
+
baseTools: authored.baseTools ?? {},
|
|
21
|
+
consumes: authored.consumes ?? [],
|
|
22
|
+
inference: {
|
|
23
|
+
vendors: authored.inference?.vendors ?? [],
|
|
24
|
+
kinds: authored.inference?.kinds ?? [InferenceCredentialKind.HarnessOwned],
|
|
25
|
+
delivery: authored.inference?.delivery ?? CredentialDelivery.AtOpen
|
|
26
|
+
},
|
|
27
|
+
supports
|
|
28
|
+
});
|
|
29
|
+
};
|
|
30
|
+
const defineHarness = (implementation) => {
|
|
31
|
+
let placeholder = null;
|
|
32
|
+
const binding = (config) => ({
|
|
33
|
+
harness: placeholder ?? bundleRef("<pending>"),
|
|
34
|
+
config,
|
|
35
|
+
definedHarness: true
|
|
36
|
+
});
|
|
37
|
+
const defined = Object.assign(binding, {
|
|
38
|
+
describe: async (args) => completeHarnessDescription(await implementation.describe(args)),
|
|
39
|
+
open: (args) => implementation.open({ ...args, sessionId: args.session.sessionId }),
|
|
40
|
+
resume: (args) => implementation.resume({ ...args, sessionId: args.session.sessionId }),
|
|
41
|
+
park: (ref, ctx) => implementation.park({ ...ref, ...ctx, ref }, ctx),
|
|
42
|
+
close: (ref, ctx) => implementation.close({ ...ref, ...ctx, ref }, ctx),
|
|
43
|
+
health: async (ref, ctx) => {
|
|
44
|
+
const health = await implementation.health({ ...ref, ...ctx, ref }, ctx);
|
|
45
|
+
return { ...health, checkedAt: health.checkedAt ?? (/* @__PURE__ */ new Date()).toISOString() };
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
placeholder = bundleRef(registerPending(defined));
|
|
49
|
+
return defined;
|
|
50
|
+
};
|
|
51
|
+
export {
|
|
52
|
+
completeHarnessDescription,
|
|
53
|
+
defineHarness
|
|
54
|
+
};
|
|
55
|
+
//# sourceMappingURL=harness.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../src/authoring/harness.ts"],
|
|
4
|
+
"sourcesContent": ["import {\n bundleRef,\n CredentialDelivery,\n harnessDescriptionSchema,\n InferenceCredentialKind,\n type AcpTransport,\n type DefinedHarnessBindingIface,\n type DescribeHarnessArgsIface,\n type HarnessClientTlsIface,\n type HarnessDescriptionIface,\n type HarnessSessionRefIface,\n type JsonSchema,\n type JsonValue,\n type McpTransportKind,\n type OpenHarnessSessionArgsIface,\n type PromptWhileRunning,\n type ProviderRef,\n type SandboxWire,\n type SecretReaderIface,\n type UserInstructionDelivery,\n} from '@finalai/agent-provider';\nimport { registerPending } from \"./brand.mjs\";\n\n// A harness declared in the definition's bundle. Its\n// methods run in the agent's Worker isolate; the session service dials the\n// endpoints they return like any other harness's.\n\ntype EnumInput<E extends string> = E | `${E}`;\n\n// What `describe` may return: what the session service needs to dial and\n// report on the harness. Omitted fields take the defaults of a third-party\n// harness that owns its model and native tools: no base tools, no sandbox\n// wires, harness-owned inference, and none of observe, resume replay, fork or\n// author metadata.\nexport interface AuthoredHarnessDescriptionIface {\n configSchema: JsonSchema;\n userInstructionDelivery?: EnumInput<UserInstructionDelivery>;\n acp: {\n transports: readonly EnumInput<AcpTransport.Ws | AcpTransport.Http>[];\n mcp?: readonly EnumInput<McpTransportKind>[];\n };\n baseTools?: HarnessDescriptionIface['baseTools'];\n consumes?: readonly EnumInput<SandboxWire>[];\n inference?: {\n vendors?: readonly string[];\n kinds?: readonly EnumInput<InferenceCredentialKind>[];\n delivery?: EnumInput<CredentialDelivery>;\n };\n supports?: Partial<HarnessDescriptionIface['supports']>;\n promptWhileRunning?: EnumInput<PromptWhileRunning>;\n sessionSurvivesDisconnect?: boolean;\n}\n\n// The harness's own session reference; the session service adds which\n// harness it belongs to.\nexport interface AuthoredHarnessSessionRefIface {\n harnessSessionRef: string;\n generation: number;\n}\n\nexport type AuthoredHarnessEndpointIface =\n | {\n ref: AuthoredHarnessSessionRefIface;\n transport: EnumInput<AcpTransport.Ws>;\n url: string;\n headers?: Record<string, string>;\n tls?: HarnessClientTlsIface;\n }\n | {\n ref: AuthoredHarnessSessionRefIface;\n transport: EnumInput<AcpTransport.Http>;\n url: string;\n headers?: Record<string, string>;\n tls?: HarnessClientTlsIface;\n };\n\nexport interface AuthoredHarnessOpenArgsIface<Config> extends Omit<\n OpenHarnessSessionArgsIface,\n 'config' | 'observer'\n> {\n config: Config;\n // The agent session's id (`session.sessionId`), for keying the harness's own state.\n sessionId: string;\n}\n\nexport interface AuthoredHarnessResumeArgsIface<\n Config,\n> extends AuthoredHarnessOpenArgsIface<Config> {\n ref: HarnessSessionRefIface;\n lastSeq: number;\n}\n\n// What the session service sends: the open and resume arguments before\n// `sessionId` is filled in from `session`.\nexport type HarnessOpenCallIface<Config> = Omit<AuthoredHarnessOpenArgsIface<Config>, 'sessionId'>;\nexport type HarnessResumeCallIface<Config> = Omit<\n AuthoredHarnessResumeArgsIface<Config>,\n 'sessionId'\n>;\n\n// park, close and health get the session reference and the definition's\n// secret reader (the isolate's `secrets`, limited to manifest.secrets).\nexport interface AuthoredHarnessRefContextIface {\n secrets: SecretReaderIface;\n}\n\n// close is graceful unless `force` (the contract's close options).\nexport interface AuthoredHarnessCloseContextIface extends AuthoredHarnessRefContextIface {\n force: boolean;\n}\n\n// The first argument of park, close and health: the session reference itself,\n// also under `ref`, with the context's fields, so both `park(ref)` and\n// `park({ ref, secrets })` read naturally.\nexport type AuthoredHarnessRefArgIface<Context extends AuthoredHarnessRefContextIface> =\n HarnessSessionRefIface & Context & { ref: HarnessSessionRefIface };\n\nexport interface AuthoredHarnessHealthIface {\n ok: boolean;\n detail?: string;\n // Defaults to when the check returned.\n checkedAt?: string;\n}\n\nexport interface AuthoredHarnessIface<Config> {\n describe(binding?: DescribeHarnessArgsIface): Promise<AuthoredHarnessDescriptionIface>;\n open(args: AuthoredHarnessOpenArgsIface<Config>): Promise<AuthoredHarnessEndpointIface>;\n resume(args: AuthoredHarnessResumeArgsIface<Config>): Promise<AuthoredHarnessEndpointIface>;\n park(\n ref: AuthoredHarnessRefArgIface<AuthoredHarnessRefContextIface>,\n ctx: AuthoredHarnessRefContextIface,\n ): Promise<void>;\n close(\n ref: AuthoredHarnessRefArgIface<AuthoredHarnessCloseContextIface>,\n ctx: AuthoredHarnessCloseContextIface,\n ): Promise<void>;\n health(\n ref: AuthoredHarnessRefArgIface<AuthoredHarnessRefContextIface>,\n ctx: AuthoredHarnessRefContextIface,\n ): Promise<AuthoredHarnessHealthIface>;\n}\n\nexport interface DefinedAuthoredHarnessIface<Config> {\n (config: Config): DefinedHarnessBindingIface;\n describe(binding?: DescribeHarnessArgsIface): Promise<HarnessDescriptionIface>;\n open(args: HarnessOpenCallIface<Config>): Promise<AuthoredHarnessEndpointIface>;\n resume(args: HarnessResumeCallIface<Config>): Promise<AuthoredHarnessEndpointIface>;\n park(ref: HarnessSessionRefIface, ctx: AuthoredHarnessRefContextIface): Promise<void>;\n close(ref: HarnessSessionRefIface, ctx: AuthoredHarnessCloseContextIface): Promise<void>;\n health(\n ref: HarnessSessionRefIface,\n ctx: AuthoredHarnessRefContextIface,\n ): Promise<{ ok: boolean; detail?: string; checkedAt: string }>;\n}\n\n// Fills the omitted description fields (see AuthoredHarnessDescriptionIface)\n// and validates the result against the contract's schema, which also applies\n// its own defaults and turns enum literals into members.\nexport const completeHarnessDescription = (\n authored: AuthoredHarnessDescriptionIface,\n): HarnessDescriptionIface => {\n const supports: HarnessDescriptionIface['supports'] = {\n observe: authored.supports?.observe ?? false,\n resumeReplay: authored.supports?.resumeReplay ?? false,\n fork: authored.supports?.fork ?? false,\n authorMeta: authored.supports?.authorMeta ?? false,\n };\n if (authored.supports?.nativeToolPolicy != null)\n supports.nativeToolPolicy = authored.supports.nativeToolPolicy;\n return harnessDescriptionSchema.parse({\n ...authored,\n acp: { transports: authored.acp.transports, mcp: authored.acp.mcp ?? [] },\n baseTools: authored.baseTools ?? {},\n consumes: authored.consumes ?? [],\n inference: {\n vendors: authored.inference?.vendors ?? [],\n kinds: authored.inference?.kinds ?? [InferenceCredentialKind.HarnessOwned],\n delivery: authored.inference?.delivery ?? CredentialDelivery.AtOpen,\n },\n supports,\n });\n};\n\n// The contract's binding shape, with the bundle export placeholder made\n// unique per harness so the compiler can bind it to a synthesized bundle\n// export even when the harness is not exported.\nexport const defineHarness = <Config extends JsonValue = JsonValue>(\n implementation: AuthoredHarnessIface<Config>,\n): DefinedAuthoredHarnessIface<Config> => {\n let placeholder: ProviderRef | null = null;\n const binding = (config: Config): DefinedHarnessBindingIface => ({\n harness: placeholder ?? bundleRef('<pending>'),\n config,\n definedHarness: true,\n });\n const defined = Object.assign(binding, {\n describe: async (args?: DescribeHarnessArgsIface): Promise<HarnessDescriptionIface> =>\n completeHarnessDescription(await implementation.describe(args)),\n open: (args: HarnessOpenCallIface<Config>) =>\n implementation.open({ ...args, sessionId: args.session.sessionId }),\n resume: (args: HarnessResumeCallIface<Config>) =>\n implementation.resume({ ...args, sessionId: args.session.sessionId }),\n park: (ref: HarnessSessionRefIface, ctx: AuthoredHarnessRefContextIface) =>\n implementation.park({ ...ref, ...ctx, ref }, ctx),\n close: (ref: HarnessSessionRefIface, ctx: AuthoredHarnessCloseContextIface) =>\n implementation.close({ ...ref, ...ctx, ref }, ctx),\n health: async (ref: HarnessSessionRefIface, ctx: AuthoredHarnessRefContextIface) => {\n const health = await implementation.health({ ...ref, ...ctx, ref }, ctx);\n return { ...health, checkedAt: health.checkedAt ?? new Date().toISOString() };\n },\n });\n placeholder = bundleRef(registerPending(defined));\n return defined;\n};\n"],
|
|
5
|
+
"mappings": "AAAA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAgBK;AACP,SAAS,uBAAuB;AAyIzB,MAAM,6BAA6B,CACxC,aAC4B;AAC5B,QAAM,WAAgD;AAAA,IACpD,SAAS,SAAS,UAAU,WAAW;AAAA,IACvC,cAAc,SAAS,UAAU,gBAAgB;AAAA,IACjD,MAAM,SAAS,UAAU,QAAQ;AAAA,IACjC,YAAY,SAAS,UAAU,cAAc;AAAA,EAC/C;AACA,MAAI,SAAS,UAAU,oBAAoB;AACzC,aAAS,mBAAmB,SAAS,SAAS;AAChD,SAAO,yBAAyB,MAAM;AAAA,IACpC,GAAG;AAAA,IACH,KAAK,EAAE,YAAY,SAAS,IAAI,YAAY,KAAK,SAAS,IAAI,OAAO,CAAC,EAAE;AAAA,IACxE,WAAW,SAAS,aAAa,CAAC;AAAA,IAClC,UAAU,SAAS,YAAY,CAAC;AAAA,IAChC,WAAW;AAAA,MACT,SAAS,SAAS,WAAW,WAAW,CAAC;AAAA,MACzC,OAAO,SAAS,WAAW,SAAS,CAAC,wBAAwB,YAAY;AAAA,MACzE,UAAU,SAAS,WAAW,YAAY,mBAAmB;AAAA,IAC/D;AAAA,IACA;AAAA,EACF,CAAC;AACH;AAKO,MAAM,gBAAgB,CAC3B,mBACwC;AACxC,MAAI,cAAkC;AACtC,QAAM,UAAU,CAAC,YAAgD;AAAA,IAC/D,SAAS,eAAe,UAAU,WAAW;AAAA,IAC7C;AAAA,IACA,gBAAgB;AAAA,EAClB;AACA,QAAM,UAAU,OAAO,OAAO,SAAS;AAAA,IACrC,UAAU,OAAO,SACf,2BAA2B,MAAM,eAAe,SAAS,IAAI,CAAC;AAAA,IAChE,MAAM,CAAC,SACL,eAAe,KAAK,EAAE,GAAG,MAAM,WAAW,KAAK,QAAQ,UAAU,CAAC;AAAA,IACpE,QAAQ,CAAC,SACP,eAAe,OAAO,EAAE,GAAG,MAAM,WAAW,KAAK,QAAQ,UAAU,CAAC;AAAA,IACtE,MAAM,CAAC,KAA6B,QAClC,eAAe,KAAK,EAAE,GAAG,KAAK,GAAG,KAAK,IAAI,GAAG,GAAG;AAAA,IAClD,OAAO,CAAC,KAA6B,QACnC,eAAe,MAAM,EAAE,GAAG,KAAK,GAAG,KAAK,IAAI,GAAG,GAAG;AAAA,IACnD,QAAQ,OAAO,KAA6B,QAAwC;AAClF,YAAM,SAAS,MAAM,eAAe,OAAO,EAAE,GAAG,KAAK,GAAG,KAAK,IAAI,GAAG,GAAG;AACvE,aAAO,EAAE,GAAG,QAAQ,WAAW,OAAO,cAAa,oBAAI,KAAK,GAAE,YAAY,EAAE;AAAA,IAC9E;AAAA,EACF,CAAC;AACD,gBAAc,UAAU,gBAAgB,OAAO,CAAC;AAChD,SAAO;AACT;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import type { JsonValue, NetworkSandboxSessionIface } from '@finalai/agent-provider';
|
|
2
|
+
import { type AuthoredValue } from "../runtime/values.mjs";
|
|
3
|
+
import type { AgentSessionInfoIface, FinalPlatformClientIface, SecretsIface, TranscriptMessageIface } from "./context.mjs";
|
|
4
|
+
import type { ToolCallEventDataIface } from "./tools.mjs";
|
|
5
|
+
export { toolResultFrom } from "./tools.mjs";
|
|
6
|
+
export declare enum HookEvent {
|
|
7
|
+
SessionOpened = "session.opened",
|
|
8
|
+
TurnStarted = "turn.started",
|
|
9
|
+
TurnEnded = "turn.ended",
|
|
10
|
+
UserMessageChunk = "user_message_chunk",
|
|
11
|
+
AgentMessageChunk = "agent_message_chunk",
|
|
12
|
+
AgentMessage = "agent_message",
|
|
13
|
+
AgentThoughtChunk = "agent_thought_chunk",
|
|
14
|
+
ToolCall = "tool_call",
|
|
15
|
+
ToolCallUpdate = "tool_call_update",
|
|
16
|
+
ToolCallContentChunk = "tool_call_content_chunk",
|
|
17
|
+
Plan = "plan",
|
|
18
|
+
PendingCreated = "pending.created",
|
|
19
|
+
PendingResolved = "pending.resolved",
|
|
20
|
+
StateUpdate = "state_update",
|
|
21
|
+
SessionFailed = "session.failed",
|
|
22
|
+
SessionClosed = "session.closed",
|
|
23
|
+
CompactionUpdate = "compaction_update",
|
|
24
|
+
UsageUpdate = "usage_update",
|
|
25
|
+
AvailableCommandsUpdate = "available_commands_update",
|
|
26
|
+
CurrentModeUpdate = "current_mode_update",
|
|
27
|
+
ConfigOptionUpdate = "config_option_update",
|
|
28
|
+
SessionInfoUpdate = "session_info_update",
|
|
29
|
+
Notice = "notice"
|
|
30
|
+
}
|
|
31
|
+
export declare const HOOK_WILDCARD = "*";
|
|
32
|
+
export declare enum HookEventKeyKind {
|
|
33
|
+
Canonical = "canonical",
|
|
34
|
+
Wildcard = "wildcard",
|
|
35
|
+
Unknown = "unknown"
|
|
36
|
+
}
|
|
37
|
+
export interface NormalizedHookKeyIface {
|
|
38
|
+
key: string;
|
|
39
|
+
kind: HookEventKeyKind;
|
|
40
|
+
events: string[];
|
|
41
|
+
}
|
|
42
|
+
export declare const normalizeHookKey: (key: string) => NormalizedHookKeyIface;
|
|
43
|
+
export interface HookEventMetaIface {
|
|
44
|
+
id: string;
|
|
45
|
+
at: string;
|
|
46
|
+
seq: number;
|
|
47
|
+
}
|
|
48
|
+
export interface HookEventIface<TType extends string = string, TData = AuthoredValue> {
|
|
49
|
+
type: TType;
|
|
50
|
+
data: TData;
|
|
51
|
+
meta: HookEventMetaIface;
|
|
52
|
+
}
|
|
53
|
+
export interface HookEventDataMapIface {
|
|
54
|
+
'session.opened': {
|
|
55
|
+
sessionId: string;
|
|
56
|
+
};
|
|
57
|
+
'turn.started': {
|
|
58
|
+
turnId: string;
|
|
59
|
+
promptMessageId: string | null;
|
|
60
|
+
authorParticipantId: string | null;
|
|
61
|
+
};
|
|
62
|
+
'turn.ended': {
|
|
63
|
+
turnId: string;
|
|
64
|
+
stopReason: string | null;
|
|
65
|
+
};
|
|
66
|
+
tool_call: ToolCallEventDataIface;
|
|
67
|
+
tool_call_update: ToolCallEventDataIface;
|
|
68
|
+
tool_call_content_chunk: ToolCallEventDataIface;
|
|
69
|
+
'pending.created': {
|
|
70
|
+
pendingId: string;
|
|
71
|
+
kind: 'permission' | 'elicitation' | 'authorization';
|
|
72
|
+
request: JsonValue;
|
|
73
|
+
};
|
|
74
|
+
'pending.resolved': {
|
|
75
|
+
pendingId: string;
|
|
76
|
+
outcome: JsonValue;
|
|
77
|
+
};
|
|
78
|
+
'session.failed': {
|
|
79
|
+
reason: string | null;
|
|
80
|
+
};
|
|
81
|
+
'session.closed': {
|
|
82
|
+
reason: string | null;
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
type CanonicalData<TKey extends string> = TKey extends keyof HookEventDataMapIface ? HookEventDataMapIface[TKey] : Record<string, JsonValue>;
|
|
86
|
+
export type HookEventKey = `${HookEvent}` | typeof HOOK_WILDCARD | `_final/${string}`;
|
|
87
|
+
export type HookEventFor<TKey extends string> = TKey extends typeof HOOK_WILDCARD ? HookEventIface : HookEventIface<TKey, CanonicalData<TKey>>;
|
|
88
|
+
export interface HookSessionInfoIface extends AgentSessionInfoIface {
|
|
89
|
+
readonly messages: readonly TranscriptMessageIface[];
|
|
90
|
+
}
|
|
91
|
+
export interface HookContextIface {
|
|
92
|
+
readonly session: HookSessionInfoIface;
|
|
93
|
+
readonly agent: {
|
|
94
|
+
readonly definitionId: string;
|
|
95
|
+
readonly name: string;
|
|
96
|
+
readonly revisionId: string;
|
|
97
|
+
};
|
|
98
|
+
readonly channel: {
|
|
99
|
+
readonly kind: string | null;
|
|
100
|
+
};
|
|
101
|
+
getSandbox(target?: string): Promise<NetworkSandboxSessionIface>;
|
|
102
|
+
cancel(): void;
|
|
103
|
+
readonly secrets: SecretsIface;
|
|
104
|
+
readonly final: FinalPlatformClientIface;
|
|
105
|
+
}
|
|
106
|
+
export type HookHandler<TKey extends string> = (event: HookEventFor<TKey>, ctx: HookContextIface) => void | Promise<void>;
|
|
107
|
+
export type HookHandlersIface = {
|
|
108
|
+
readonly [TKey in HookEventKey]?: HookHandler<TKey>;
|
|
109
|
+
};
|
|
110
|
+
export interface HookDefinitionIface {
|
|
111
|
+
readonly events?: HookHandlersIface;
|
|
112
|
+
}
|
|
113
|
+
export declare const defineHook: (definition: HookDefinitionIface) => HookDefinitionIface;
|
|
114
|
+
export interface HookDispatchEventIface {
|
|
115
|
+
type: string;
|
|
116
|
+
data: AuthoredValue;
|
|
117
|
+
meta: HookEventMetaIface;
|
|
118
|
+
}
|
|
119
|
+
export type HookInvocable = (event: HookDispatchEventIface, ctx: HookContextIface) => AuthoredValue;
|
|
120
|
+
export declare const hookHandlersFor: (hook: AuthoredValue, event: HookDispatchEventIface) => HookInvocable[];
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import * as z from "zod";
|
|
2
|
+
import { authoredRecordSchema, isCallable } from "../runtime/values.mjs";
|
|
3
|
+
import { AuthoredKind, stamp } from "./brand.mjs";
|
|
4
|
+
import { toolResultFrom } from "./tools.mjs";
|
|
5
|
+
var HookEvent = /* @__PURE__ */ ((HookEvent2) => {
|
|
6
|
+
HookEvent2["SessionOpened"] = "session.opened";
|
|
7
|
+
HookEvent2["TurnStarted"] = "turn.started";
|
|
8
|
+
HookEvent2["TurnEnded"] = "turn.ended";
|
|
9
|
+
HookEvent2["UserMessageChunk"] = "user_message_chunk";
|
|
10
|
+
HookEvent2["AgentMessageChunk"] = "agent_message_chunk";
|
|
11
|
+
HookEvent2["AgentMessage"] = "agent_message";
|
|
12
|
+
HookEvent2["AgentThoughtChunk"] = "agent_thought_chunk";
|
|
13
|
+
HookEvent2["ToolCall"] = "tool_call";
|
|
14
|
+
HookEvent2["ToolCallUpdate"] = "tool_call_update";
|
|
15
|
+
HookEvent2["ToolCallContentChunk"] = "tool_call_content_chunk";
|
|
16
|
+
HookEvent2["Plan"] = "plan";
|
|
17
|
+
HookEvent2["PendingCreated"] = "pending.created";
|
|
18
|
+
HookEvent2["PendingResolved"] = "pending.resolved";
|
|
19
|
+
HookEvent2["StateUpdate"] = "state_update";
|
|
20
|
+
HookEvent2["SessionFailed"] = "session.failed";
|
|
21
|
+
HookEvent2["SessionClosed"] = "session.closed";
|
|
22
|
+
HookEvent2["CompactionUpdate"] = "compaction_update";
|
|
23
|
+
HookEvent2["UsageUpdate"] = "usage_update";
|
|
24
|
+
HookEvent2["AvailableCommandsUpdate"] = "available_commands_update";
|
|
25
|
+
HookEvent2["CurrentModeUpdate"] = "current_mode_update";
|
|
26
|
+
HookEvent2["ConfigOptionUpdate"] = "config_option_update";
|
|
27
|
+
HookEvent2["SessionInfoUpdate"] = "session_info_update";
|
|
28
|
+
HookEvent2["Notice"] = "notice";
|
|
29
|
+
return HookEvent2;
|
|
30
|
+
})(HookEvent || {});
|
|
31
|
+
const HOOK_WILDCARD = "*";
|
|
32
|
+
const CANONICAL_EVENTS = new Set(Object.values(HookEvent));
|
|
33
|
+
var HookEventKeyKind = /* @__PURE__ */ ((HookEventKeyKind2) => {
|
|
34
|
+
HookEventKeyKind2["Canonical"] = "canonical";
|
|
35
|
+
HookEventKeyKind2["Wildcard"] = "wildcard";
|
|
36
|
+
HookEventKeyKind2["Unknown"] = "unknown";
|
|
37
|
+
return HookEventKeyKind2;
|
|
38
|
+
})(HookEventKeyKind || {});
|
|
39
|
+
const normalizeHookKey = (key) => {
|
|
40
|
+
if (key === HOOK_WILDCARD)
|
|
41
|
+
return { key, kind: "wildcard" /* Wildcard */, events: [HOOK_WILDCARD] };
|
|
42
|
+
if (CANONICAL_EVENTS.has(key) || key.startsWith("_final/")) {
|
|
43
|
+
return { key, kind: "canonical" /* Canonical */, events: [key] };
|
|
44
|
+
}
|
|
45
|
+
return { key, kind: "unknown" /* Unknown */, events: [] };
|
|
46
|
+
};
|
|
47
|
+
const defineHook = (definition) => stamp({ ...definition }, AuthoredKind.Hook);
|
|
48
|
+
const keyMatches = (key, event) => key === event.type && (CANONICAL_EVENTS.has(key) || key.startsWith("_final/"));
|
|
49
|
+
const hookEventsSchema = z.looseObject({ events: authoredRecordSchema });
|
|
50
|
+
const hookHandlersFor = (hook, event) => {
|
|
51
|
+
const parsed = hookEventsSchema.safeParse(hook);
|
|
52
|
+
if (!parsed.success) return [];
|
|
53
|
+
const typed = [];
|
|
54
|
+
let wildcard = null;
|
|
55
|
+
for (const [key, handler] of Object.entries(parsed.data.events)) {
|
|
56
|
+
if (!isCallable(handler)) continue;
|
|
57
|
+
const invoke = (dispatched, ctx) => handler(dispatched, ctx);
|
|
58
|
+
if (key === HOOK_WILDCARD) wildcard = invoke;
|
|
59
|
+
else if (keyMatches(key, event)) typed.push(invoke);
|
|
60
|
+
}
|
|
61
|
+
return wildcard == null ? typed : [...typed, wildcard];
|
|
62
|
+
};
|
|
63
|
+
export {
|
|
64
|
+
HOOK_WILDCARD,
|
|
65
|
+
HookEvent,
|
|
66
|
+
HookEventKeyKind,
|
|
67
|
+
defineHook,
|
|
68
|
+
hookHandlersFor,
|
|
69
|
+
normalizeHookKey,
|
|
70
|
+
toolResultFrom
|
|
71
|
+
};
|
|
72
|
+
//# sourceMappingURL=hooks.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../src/authoring/hooks.ts"],
|
|
4
|
+
"sourcesContent": ["import type { JsonValue, NetworkSandboxSessionIface } from '@finalai/agent-provider';\nimport * as z from 'zod';\nimport { authoredRecordSchema, isCallable, type AuthoredValue } from \"../runtime/values.mjs\";\nimport { AuthoredKind, stamp } from \"./brand.mjs\";\nimport type {\n AgentSessionInfoIface,\n FinalPlatformClientIface,\n SecretsIface,\n TranscriptMessageIface,\n} from \"./context.mjs\";\nimport type { ToolCallEventDataIface } from \"./tools.mjs\";\n\nexport { toolResultFrom } from \"./tools.mjs\";\n\n// Observe-only subscribers to the session's ACP log. Event\n// names are ACP update kinds and request methods plus a few session-service\n// lifecycle events. Only these canonical names are accepted.\n\nexport enum HookEvent {\n SessionOpened = 'session.opened',\n TurnStarted = 'turn.started',\n TurnEnded = 'turn.ended',\n UserMessageChunk = 'user_message_chunk',\n AgentMessageChunk = 'agent_message_chunk',\n AgentMessage = 'agent_message',\n AgentThoughtChunk = 'agent_thought_chunk',\n ToolCall = 'tool_call',\n ToolCallUpdate = 'tool_call_update',\n ToolCallContentChunk = 'tool_call_content_chunk',\n Plan = 'plan',\n PendingCreated = 'pending.created',\n PendingResolved = 'pending.resolved',\n StateUpdate = 'state_update',\n SessionFailed = 'session.failed',\n SessionClosed = 'session.closed',\n CompactionUpdate = 'compaction_update',\n UsageUpdate = 'usage_update',\n AvailableCommandsUpdate = 'available_commands_update',\n CurrentModeUpdate = 'current_mode_update',\n ConfigOptionUpdate = 'config_option_update',\n SessionInfoUpdate = 'session_info_update',\n Notice = 'notice',\n}\n\nexport const HOOK_WILDCARD = '*';\n\nconst CANONICAL_EVENTS: ReadonlySet<string> = new Set(Object.values(HookEvent));\n\nexport enum HookEventKeyKind {\n Canonical = 'canonical',\n Wildcard = 'wildcard',\n Unknown = 'unknown',\n}\n\nexport interface NormalizedHookKeyIface {\n key: string;\n kind: HookEventKeyKind;\n // Canonical event names this key subscribes to ('*' for the wildcard).\n events: string[];\n}\n\nexport const normalizeHookKey = (key: string): NormalizedHookKeyIface => {\n if (key === HOOK_WILDCARD)\n return { key, kind: HookEventKeyKind.Wildcard, events: [HOOK_WILDCARD] };\n if (CANONICAL_EVENTS.has(key) || key.startsWith('_final/')) {\n return { key, kind: HookEventKeyKind.Canonical, events: [key] };\n }\n return { key, kind: HookEventKeyKind.Unknown, events: [] };\n};\n\nexport interface HookEventMetaIface {\n // '<sessionId>:<seq>' with the session's wire id (`ases_\u2026:12`): sortable\n // within a session and stable across redelivery.\n id: string;\n at: string;\n seq: number;\n}\n\nexport interface HookEventIface<TType extends string = string, TData = AuthoredValue> {\n type: TType;\n data: TData;\n meta: HookEventMetaIface;\n}\n\n// Lifecycle event data names platform objects by their wire ids, as the public\n// API does: sessions `ases_\u2026`, turns `atrn_\u2026`, participants `cpart_\u2026`, pending\n// requests `apnd_\u2026`. `promptMessageId` is the harness's ACP message id. ACP\n// update events (tool_call, agent_message_chunk, \u2026) carry the ACP payload as is.\nexport interface HookEventDataMapIface {\n 'session.opened': { sessionId: string };\n 'turn.started': {\n turnId: string;\n promptMessageId: string | null;\n authorParticipantId: string | null;\n };\n 'turn.ended': { turnId: string; stopReason: string | null };\n tool_call: ToolCallEventDataIface;\n tool_call_update: ToolCallEventDataIface;\n tool_call_content_chunk: ToolCallEventDataIface;\n 'pending.created': {\n pendingId: string;\n kind: 'permission' | 'elicitation' | 'authorization';\n request: JsonValue;\n };\n 'pending.resolved': { pendingId: string; outcome: JsonValue };\n 'session.failed': { reason: string | null };\n 'session.closed': { reason: string | null };\n}\n\ntype CanonicalData<TKey extends string> = TKey extends keyof HookEventDataMapIface\n ? HookEventDataMapIface[TKey]\n : Record<string, JsonValue>;\n\nexport type HookEventKey = `${HookEvent}` | typeof HOOK_WILDCARD | `_final/${string}`;\n\nexport type HookEventFor<TKey extends string> = TKey extends typeof HOOK_WILDCARD\n ? HookEventIface\n : HookEventIface<TKey, CanonicalData<TKey>>;\n\nexport interface HookSessionInfoIface extends AgentSessionInfoIface {\n readonly messages: readonly TranscriptMessageIface[];\n}\n\nexport interface HookContextIface {\n readonly session: HookSessionInfoIface;\n readonly agent: {\n readonly definitionId: string;\n readonly name: string;\n readonly revisionId: string;\n };\n readonly channel: { readonly kind: string | null };\n getSandbox(target?: string): Promise<NetworkSandboxSessionIface>;\n // Sends session/cancel for the running turn.\n cancel(): void;\n readonly secrets: SecretsIface;\n readonly final: FinalPlatformClientIface;\n}\n\nexport type HookHandler<TKey extends string> = (\n event: HookEventFor<TKey>,\n ctx: HookContextIface,\n) => void | Promise<void>;\n\nexport type HookHandlersIface = { readonly [TKey in HookEventKey]?: HookHandler<TKey> };\n\nexport interface HookDefinitionIface {\n readonly events?: HookHandlersIface;\n}\n\nexport const defineHook = (definition: HookDefinitionIface): HookDefinitionIface =>\n stamp({ ...definition }, AuthoredKind.Hook);\n\nexport interface HookDispatchEventIface {\n type: string;\n data: AuthoredValue;\n meta: HookEventMetaIface;\n}\n\nconst keyMatches = (key: string, event: HookDispatchEventIface): boolean =>\n key === event.type && (CANONICAL_EVENTS.has(key) || key.startsWith('_final/'));\n\nexport type HookInvocable = (event: HookDispatchEventIface, ctx: HookContextIface) => AuthoredValue;\n\nconst hookEventsSchema = z.looseObject({ events: authoredRecordSchema });\n\n// Handlers for one event: typed handlers in declaration order, then the\n// wildcard.\nexport const hookHandlersFor = (\n hook: AuthoredValue,\n event: HookDispatchEventIface,\n): HookInvocable[] => {\n const parsed = hookEventsSchema.safeParse(hook);\n if (!parsed.success) return [];\n const typed: HookInvocable[] = [];\n let wildcard: HookInvocable | null = null;\n for (const [key, handler] of Object.entries(parsed.data.events)) {\n if (!isCallable(handler)) continue;\n const invoke: HookInvocable = (dispatched, ctx) => handler(dispatched, ctx);\n if (key === HOOK_WILDCARD) wildcard = invoke;\n else if (keyMatches(key, event)) typed.push(invoke);\n }\n return wildcard == null ? typed : [...typed, wildcard];\n};\n"],
|
|
5
|
+
"mappings": "AACA,YAAY,OAAO;AACnB,SAAS,sBAAsB,kBAAsC;AACrE,SAAS,cAAc,aAAa;AASpC,SAAS,sBAAsB;AAMxB,IAAK,YAAL,kBAAKA,eAAL;AACL,EAAAA,WAAA,mBAAgB;AAChB,EAAAA,WAAA,iBAAc;AACd,EAAAA,WAAA,eAAY;AACZ,EAAAA,WAAA,sBAAmB;AACnB,EAAAA,WAAA,uBAAoB;AACpB,EAAAA,WAAA,kBAAe;AACf,EAAAA,WAAA,uBAAoB;AACpB,EAAAA,WAAA,cAAW;AACX,EAAAA,WAAA,oBAAiB;AACjB,EAAAA,WAAA,0BAAuB;AACvB,EAAAA,WAAA,UAAO;AACP,EAAAA,WAAA,oBAAiB;AACjB,EAAAA,WAAA,qBAAkB;AAClB,EAAAA,WAAA,iBAAc;AACd,EAAAA,WAAA,mBAAgB;AAChB,EAAAA,WAAA,mBAAgB;AAChB,EAAAA,WAAA,sBAAmB;AACnB,EAAAA,WAAA,iBAAc;AACd,EAAAA,WAAA,6BAA0B;AAC1B,EAAAA,WAAA,uBAAoB;AACpB,EAAAA,WAAA,wBAAqB;AACrB,EAAAA,WAAA,uBAAoB;AACpB,EAAAA,WAAA,YAAS;AAvBC,SAAAA;AAAA,GAAA;AA0BL,MAAM,gBAAgB;AAE7B,MAAM,mBAAwC,IAAI,IAAI,OAAO,OAAO,SAAS,CAAC;AAEvE,IAAK,mBAAL,kBAAKC,sBAAL;AACL,EAAAA,kBAAA,eAAY;AACZ,EAAAA,kBAAA,cAAW;AACX,EAAAA,kBAAA,aAAU;AAHA,SAAAA;AAAA,GAAA;AAaL,MAAM,mBAAmB,CAAC,QAAwC;AACvE,MAAI,QAAQ;AACV,WAAO,EAAE,KAAK,MAAM,2BAA2B,QAAQ,CAAC,aAAa,EAAE;AACzE,MAAI,iBAAiB,IAAI,GAAG,KAAK,IAAI,WAAW,SAAS,GAAG;AAC1D,WAAO,EAAE,KAAK,MAAM,6BAA4B,QAAQ,CAAC,GAAG,EAAE;AAAA,EAChE;AACA,SAAO,EAAE,KAAK,MAAM,yBAA0B,QAAQ,CAAC,EAAE;AAC3D;AAiFO,MAAM,aAAa,CAAC,eACzB,MAAM,EAAE,GAAG,WAAW,GAAG,aAAa,IAAI;AAQ5C,MAAM,aAAa,CAAC,KAAa,UAC/B,QAAQ,MAAM,SAAS,iBAAiB,IAAI,GAAG,KAAK,IAAI,WAAW,SAAS;AAI9E,MAAM,mBAAmB,EAAE,YAAY,EAAE,QAAQ,qBAAqB,CAAC;AAIhE,MAAM,kBAAkB,CAC7B,MACA,UACoB;AACpB,QAAM,SAAS,iBAAiB,UAAU,IAAI;AAC9C,MAAI,CAAC,OAAO,QAAS,QAAO,CAAC;AAC7B,QAAM,QAAyB,CAAC;AAChC,MAAI,WAAiC;AACrC,aAAW,CAAC,KAAK,OAAO,KAAK,OAAO,QAAQ,OAAO,KAAK,MAAM,GAAG;AAC/D,QAAI,CAAC,WAAW,OAAO,EAAG;AAC1B,UAAM,SAAwB,CAAC,YAAY,QAAQ,QAAQ,YAAY,GAAG;AAC1E,QAAI,QAAQ,cAAe,YAAW;AAAA,aAC7B,WAAW,KAAK,KAAK,EAAG,OAAM,KAAK,MAAM;AAAA,EACpD;AACA,SAAO,YAAY,OAAO,QAAQ,CAAC,GAAG,OAAO,QAAQ;AACvD;",
|
|
6
|
+
"names": ["HookEvent", "HookEventKeyKind"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export { defineAgent } from "./agent.mjs";
|
|
2
|
+
export type { AgentDefinitionInputIface, ChannelBindingValueIface, HarnessBindingValueIface, } from "./agent.mjs";
|
|
3
|
+
export { always, never, whenInput } from "./approval.mjs";
|
|
4
|
+
export type { ApprovalPolicyIface } from "./approval.mjs";
|
|
5
|
+
export { DELETE, GET, POST, PUT, WS, defineChannel, defineProviderChannel, disableChannel, } from "./channels.mjs";
|
|
6
|
+
export type { AuthoredChannelDefinitionIface, RouteHandler, RouteHandlerArgsIface, } from "./channels.mjs";
|
|
7
|
+
export { defineMcpClientConnection } from "./connections.mjs";
|
|
8
|
+
export type { McpClientConnectionDefinitionIface, McpConnectionAuthIface } from "./connections.mjs";
|
|
9
|
+
export * from "./context.mjs";
|
|
10
|
+
export { CredentialOwner, CredentialPayer, credentials } from "./credentials.mjs";
|
|
11
|
+
export type { CredentialNode, CredentialPolicyIface } from "./credentials.mjs";
|
|
12
|
+
export { defineDynamic } from "./dynamic.mjs";
|
|
13
|
+
export type { DynamicDefinitionIface, DynamicEventsIface, DynamicSentinelIface } from "./dynamic.mjs";
|
|
14
|
+
export { completeHarnessDescription, defineHarness } from "./harness.mjs";
|
|
15
|
+
export type { AuthoredHarnessCloseContextIface, AuthoredHarnessDescriptionIface, AuthoredHarnessEndpointIface, AuthoredHarnessHealthIface, AuthoredHarnessIface, AuthoredHarnessOpenArgsIface, AuthoredHarnessRefContextIface, AuthoredHarnessResumeArgsIface, AuthoredHarnessSessionRefIface, DefinedAuthoredHarnessIface, } from "./harness.mjs";
|
|
16
|
+
export { HookEvent, defineHook } from "./hooks.mjs";
|
|
17
|
+
export type { HookContextIface, HookDefinitionIface, HookEventFor, HookEventIface, HookEventKey, } from "./hooks.mjs";
|
|
18
|
+
export { defineInstructions } from "./instructions.mjs";
|
|
19
|
+
export type { DefinedInstructionsIface, InstructionsDefinitionIface } from "./instructions.mjs";
|
|
20
|
+
export { SandboxWire, baseTools, defineSandbox, defineSandboxProvider, harnessHost, } from "./sandbox.mjs";
|
|
21
|
+
export type { BaseToolsValueIface, HarnessHostIface, SandboxSelector, SandboxSelectorContextIface, SandboxTargetValue, } from "./sandbox.mjs";
|
|
22
|
+
export { defineSchedule } from "./schedules.mjs";
|
|
23
|
+
export type { ScheduleInputIface } from "./schedules.mjs";
|
|
24
|
+
export { defineSkill } from "./skills.mjs";
|
|
25
|
+
export type { SkillDefinitionIface } from "./skills.mjs";
|
|
26
|
+
export { defineTool, toolResultFrom } from "./tools.mjs";
|
|
27
|
+
export type { DefinedToolIface, StandardSchemaLikeIface, ToolCallEventDataIface, ToolDefinitionIface, ToolInputSchema, } from "./tools.mjs";
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { defineAgent } from "./agent.mjs";
|
|
2
|
+
import { always, never, whenInput } from "./approval.mjs";
|
|
3
|
+
import {
|
|
4
|
+
DELETE,
|
|
5
|
+
GET,
|
|
6
|
+
POST,
|
|
7
|
+
PUT,
|
|
8
|
+
WS,
|
|
9
|
+
defineChannel,
|
|
10
|
+
defineProviderChannel,
|
|
11
|
+
disableChannel
|
|
12
|
+
} from "./channels.mjs";
|
|
13
|
+
import { defineMcpClientConnection } from "./connections.mjs";
|
|
14
|
+
export * from "./context.mjs";
|
|
15
|
+
import { CredentialOwner, CredentialPayer, credentials } from "./credentials.mjs";
|
|
16
|
+
import { defineDynamic } from "./dynamic.mjs";
|
|
17
|
+
import { completeHarnessDescription, defineHarness } from "./harness.mjs";
|
|
18
|
+
import { HookEvent, defineHook } from "./hooks.mjs";
|
|
19
|
+
import { defineInstructions } from "./instructions.mjs";
|
|
20
|
+
import {
|
|
21
|
+
SandboxWire,
|
|
22
|
+
baseTools,
|
|
23
|
+
defineSandbox,
|
|
24
|
+
defineSandboxProvider,
|
|
25
|
+
harnessHost
|
|
26
|
+
} from "./sandbox.mjs";
|
|
27
|
+
import { defineSchedule } from "./schedules.mjs";
|
|
28
|
+
import { defineSkill } from "./skills.mjs";
|
|
29
|
+
import { defineTool, toolResultFrom } from "./tools.mjs";
|
|
30
|
+
export {
|
|
31
|
+
CredentialOwner,
|
|
32
|
+
CredentialPayer,
|
|
33
|
+
DELETE,
|
|
34
|
+
GET,
|
|
35
|
+
HookEvent,
|
|
36
|
+
POST,
|
|
37
|
+
PUT,
|
|
38
|
+
SandboxWire,
|
|
39
|
+
WS,
|
|
40
|
+
always,
|
|
41
|
+
baseTools,
|
|
42
|
+
completeHarnessDescription,
|
|
43
|
+
credentials,
|
|
44
|
+
defineAgent,
|
|
45
|
+
defineChannel,
|
|
46
|
+
defineDynamic,
|
|
47
|
+
defineHarness,
|
|
48
|
+
defineHook,
|
|
49
|
+
defineInstructions,
|
|
50
|
+
defineMcpClientConnection,
|
|
51
|
+
defineProviderChannel,
|
|
52
|
+
defineSandbox,
|
|
53
|
+
defineSandboxProvider,
|
|
54
|
+
defineSchedule,
|
|
55
|
+
defineSkill,
|
|
56
|
+
defineTool,
|
|
57
|
+
disableChannel,
|
|
58
|
+
harnessHost,
|
|
59
|
+
never,
|
|
60
|
+
toolResultFrom,
|
|
61
|
+
whenInput
|
|
62
|
+
};
|
|
63
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../src/authoring/index.ts"],
|
|
4
|
+
"sourcesContent": ["export { defineAgent } from \"./agent.mjs\";\nexport type {\n AgentDefinitionInputIface,\n ChannelBindingValueIface,\n HarnessBindingValueIface,\n} from \"./agent.mjs\";\nexport { always, never, whenInput } from \"./approval.mjs\";\nexport type { ApprovalPolicyIface } from \"./approval.mjs\";\nexport {\n DELETE,\n GET,\n POST,\n PUT,\n WS,\n defineChannel,\n defineProviderChannel,\n disableChannel,\n} from \"./channels.mjs\";\nexport type {\n AuthoredChannelDefinitionIface,\n RouteHandler,\n RouteHandlerArgsIface,\n} from \"./channels.mjs\";\nexport { defineMcpClientConnection } from \"./connections.mjs\";\nexport type { McpClientConnectionDefinitionIface, McpConnectionAuthIface } from \"./connections.mjs\";\nexport * from \"./context.mjs\";\nexport { CredentialOwner, CredentialPayer, credentials } from \"./credentials.mjs\";\nexport type { CredentialNode, CredentialPolicyIface } from \"./credentials.mjs\";\nexport { defineDynamic } from \"./dynamic.mjs\";\nexport type { DynamicDefinitionIface, DynamicEventsIface, DynamicSentinelIface } from \"./dynamic.mjs\";\nexport { completeHarnessDescription, defineHarness } from \"./harness.mjs\";\nexport type {\n AuthoredHarnessCloseContextIface,\n AuthoredHarnessDescriptionIface,\n AuthoredHarnessEndpointIface,\n AuthoredHarnessHealthIface,\n AuthoredHarnessIface,\n AuthoredHarnessOpenArgsIface,\n AuthoredHarnessRefContextIface,\n AuthoredHarnessResumeArgsIface,\n AuthoredHarnessSessionRefIface,\n DefinedAuthoredHarnessIface,\n} from \"./harness.mjs\";\nexport { HookEvent, defineHook } from \"./hooks.mjs\";\nexport type {\n HookContextIface,\n HookDefinitionIface,\n HookEventFor,\n HookEventIface,\n HookEventKey,\n} from \"./hooks.mjs\";\nexport { defineInstructions } from \"./instructions.mjs\";\nexport type { DefinedInstructionsIface, InstructionsDefinitionIface } from \"./instructions.mjs\";\nexport {\n SandboxWire,\n baseTools,\n defineSandbox,\n defineSandboxProvider,\n harnessHost,\n} from \"./sandbox.mjs\";\nexport type {\n BaseToolsValueIface,\n HarnessHostIface,\n SandboxSelector,\n SandboxSelectorContextIface,\n SandboxTargetValue,\n} from \"./sandbox.mjs\";\nexport { defineSchedule } from \"./schedules.mjs\";\nexport type { ScheduleInputIface } from \"./schedules.mjs\";\nexport { defineSkill } from \"./skills.mjs\";\nexport type { SkillDefinitionIface } from \"./skills.mjs\";\nexport { defineTool, toolResultFrom } from \"./tools.mjs\";\nexport type {\n DefinedToolIface,\n StandardSchemaLikeIface,\n ToolCallEventDataIface,\n ToolDefinitionIface,\n ToolInputSchema,\n} from \"./tools.mjs\";\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,mBAAmB;AAM5B,SAAS,QAAQ,OAAO,iBAAiB;AAEzC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAMP,SAAS,iCAAiC;AAE1C,cAAc;AACd,SAAS,iBAAiB,iBAAiB,mBAAmB;AAE9D,SAAS,qBAAqB;AAE9B,SAAS,4BAA4B,qBAAqB;AAa1D,SAAS,WAAW,kBAAkB;AAQtC,SAAS,0BAA0B;AAEnC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAQP,SAAS,sBAAsB;AAE/B,SAAS,mBAAmB;AAE5B,SAAS,YAAY,sBAAsB;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { InstructionRole } from '@finalai/agent-provider';
|
|
2
|
+
export type { DynamicResolveContextIface } from "./context.mjs";
|
|
3
|
+
export { defineDynamic } from "./dynamic.mjs";
|
|
4
|
+
export type { DynamicDefinitionIface, DynamicSentinelIface } from "./dynamic.mjs";
|
|
5
|
+
export interface InstructionsDefinitionIface {
|
|
6
|
+
readonly content: string;
|
|
7
|
+
readonly role?: InstructionRole | `${InstructionRole}`;
|
|
8
|
+
}
|
|
9
|
+
export interface DefinedInstructionsIface {
|
|
10
|
+
readonly content: string;
|
|
11
|
+
readonly role: InstructionRole;
|
|
12
|
+
}
|
|
13
|
+
export declare const defineInstructions: (definition: InstructionsDefinitionIface) => DefinedInstructionsIface;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { InstructionRole } from "@finalai/agent-provider";
|
|
2
|
+
import { AuthoredKind, stamp } from "./brand.mjs";
|
|
3
|
+
import { defineDynamic } from "./dynamic.mjs";
|
|
4
|
+
const defineInstructions = (definition) => stamp(
|
|
5
|
+
{
|
|
6
|
+
content: definition.content,
|
|
7
|
+
role: definition.role === InstructionRole.User ? InstructionRole.User : InstructionRole.System
|
|
8
|
+
},
|
|
9
|
+
AuthoredKind.Instructions
|
|
10
|
+
);
|
|
11
|
+
export {
|
|
12
|
+
defineDynamic,
|
|
13
|
+
defineInstructions
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=instructions.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../src/authoring/instructions.ts"],
|
|
4
|
+
"sourcesContent": ["import { InstructionRole } from '@finalai/agent-provider';\nimport { AuthoredKind, stamp } from \"./brand.mjs\";\n\nexport type { DynamicResolveContextIface } from \"./context.mjs\";\nexport { defineDynamic } from \"./dynamic.mjs\";\nexport type { DynamicDefinitionIface, DynamicSentinelIface } from \"./dynamic.mjs\";\n\n// defineInstructions: one fragment of `harness.config.instructions`.\n// Omitted `role` defaults to system.\nexport interface InstructionsDefinitionIface {\n readonly content: string;\n readonly role?: InstructionRole | `${InstructionRole}`;\n}\n\nexport interface DefinedInstructionsIface {\n readonly content: string;\n readonly role: InstructionRole;\n}\n\nexport const defineInstructions = (\n definition: InstructionsDefinitionIface,\n): DefinedInstructionsIface =>\n stamp(\n {\n content: definition.content,\n role:\n definition.role === InstructionRole.User ? InstructionRole.User : InstructionRole.System,\n },\n AuthoredKind.Instructions,\n );\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,uBAAuB;AAChC,SAAS,cAAc,aAAa;AAGpC,SAAS,qBAAqB;AAevB,MAAM,qBAAqB,CAChC,eAEA;AAAA,EACE;AAAA,IACE,SAAS,WAAW;AAAA,IACpB,MACE,WAAW,SAAS,gBAAgB,OAAO,gBAAgB,OAAO,gBAAgB;AAAA,EACtF;AAAA,EACA,aAAa;AACf;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { BaseCapability, NetworkSandboxSessionIface, SandboxEnvironmentIface, SandboxOpenRequestIface } from '@finalai/agent-provider';
|
|
2
|
+
import type { AgentSessionInfoIface, SecretsIface } from "./context.mjs";
|
|
3
|
+
import type { DynamicSentinelIface } from "./dynamic.mjs";
|
|
4
|
+
export { defineSandboxProvider, SandboxWire } from '@finalai/agent-provider';
|
|
5
|
+
export interface SandboxSelectorContextIface {
|
|
6
|
+
readonly session: AgentSessionInfoIface;
|
|
7
|
+
readonly secrets: SecretsIface;
|
|
8
|
+
open(request: SandboxOpenRequestIface<unknown, unknown>): Promise<NetworkSandboxSessionIface>;
|
|
9
|
+
}
|
|
10
|
+
export type SandboxSelector = (ctx: SandboxSelectorContextIface) => NetworkSandboxSessionIface | SandboxOpenRequestIface<unknown, unknown> | Promise<NetworkSandboxSessionIface | SandboxOpenRequestIface<unknown, unknown>>;
|
|
11
|
+
export interface HarnessHostIface {
|
|
12
|
+
readonly harnessHost: true;
|
|
13
|
+
}
|
|
14
|
+
export declare const harnessHost: HarnessHostIface;
|
|
15
|
+
export type SandboxTargetValue = HarnessHostIface | SandboxEnvironmentIface<unknown, unknown> | SandboxOpenRequestIface<unknown, unknown> | DynamicSentinelIface | SandboxSelector | string;
|
|
16
|
+
export declare const defineSandbox: <T extends SandboxSelector | SandboxEnvironmentIface<unknown, unknown>>(value: T) => T;
|
|
17
|
+
export type BaseToolsInputIface = Partial<Record<BaseCapability | `${BaseCapability}`, SandboxTargetValue>>;
|
|
18
|
+
export interface BaseToolsValueIface {
|
|
19
|
+
readonly base: BaseToolsInputIface;
|
|
20
|
+
}
|
|
21
|
+
export declare const baseTools: (base: BaseToolsInputIface) => BaseToolsValueIface;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { AuthoredKind, stamp } from "./brand.mjs";
|
|
2
|
+
import { defineSandboxProvider, SandboxWire } from "@finalai/agent-provider";
|
|
3
|
+
const harnessHost = stamp({ harnessHost: true }, AuthoredKind.HarnessHost);
|
|
4
|
+
const defineSandbox = (value) => value instanceof Function ? stamp(value, AuthoredKind.SandboxSelector) : value;
|
|
5
|
+
const baseTools = (base) => stamp({ base: { ...base } }, AuthoredKind.BaseTools);
|
|
6
|
+
export {
|
|
7
|
+
SandboxWire,
|
|
8
|
+
baseTools,
|
|
9
|
+
defineSandbox,
|
|
10
|
+
defineSandboxProvider,
|
|
11
|
+
harnessHost
|
|
12
|
+
};
|
|
13
|
+
//# sourceMappingURL=sandbox.mjs.map
|