@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,21 @@
|
|
|
1
|
+
import {
|
|
2
|
+
SchemaIo,
|
|
3
|
+
jsonSchemaDeclarationError,
|
|
4
|
+
jsonSchemaError,
|
|
5
|
+
resultMatchesSchema,
|
|
6
|
+
standardValidatorSchema,
|
|
7
|
+
validateSchemaValue
|
|
8
|
+
} from "../../chunk-GNR7XBPN.ts";
|
|
9
|
+
import "../../chunk-7WGYG73V.ts";
|
|
10
|
+
import "../../chunk-7QP2CKPI.ts";
|
|
11
|
+
import "../../chunk-JIPNTA56.ts";
|
|
12
|
+
import "../../chunk-HGW4YHAY.ts";
|
|
13
|
+
import "../../chunk-32O3ODZE.ts";
|
|
14
|
+
export {
|
|
15
|
+
SchemaIo,
|
|
16
|
+
jsonSchemaDeclarationError,
|
|
17
|
+
jsonSchemaError,
|
|
18
|
+
resultMatchesSchema,
|
|
19
|
+
standardValidatorSchema,
|
|
20
|
+
validateSchemaValue
|
|
21
|
+
};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import {
|
|
2
|
+
authoredRecordSchema,
|
|
3
|
+
authoredValueSchema,
|
|
4
|
+
callableSchema,
|
|
5
|
+
entriesOf,
|
|
6
|
+
fieldOf,
|
|
7
|
+
isAsyncIterable,
|
|
8
|
+
isBoolean,
|
|
9
|
+
isCallable,
|
|
10
|
+
isNumber,
|
|
11
|
+
isObjectLike,
|
|
12
|
+
isPlainObject,
|
|
13
|
+
isPromiseLike,
|
|
14
|
+
isString,
|
|
15
|
+
messageOf,
|
|
16
|
+
optionalValueSchema,
|
|
17
|
+
stringOrNull
|
|
18
|
+
} from "../../chunk-JIPNTA56.ts";
|
|
19
|
+
import "../../chunk-HGW4YHAY.ts";
|
|
20
|
+
import "../../chunk-32O3ODZE.ts";
|
|
21
|
+
export {
|
|
22
|
+
authoredRecordSchema,
|
|
23
|
+
authoredValueSchema,
|
|
24
|
+
callableSchema,
|
|
25
|
+
entriesOf,
|
|
26
|
+
fieldOf,
|
|
27
|
+
isAsyncIterable,
|
|
28
|
+
isBoolean,
|
|
29
|
+
isCallable,
|
|
30
|
+
isNumber,
|
|
31
|
+
isObjectLike,
|
|
32
|
+
isPlainObject,
|
|
33
|
+
isPromiseLike,
|
|
34
|
+
isString,
|
|
35
|
+
messageOf,
|
|
36
|
+
optionalValueSchema,
|
|
37
|
+
stringOrNull
|
|
38
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { JsonObject, ProviderRef, ToolApproval } from '@finalai/agent-provider';
|
|
2
|
+
import type { BaseToolsValueIface } from "./sandbox.mjs";
|
|
3
|
+
export interface HarnessBindingValueIface {
|
|
4
|
+
readonly harness: ProviderRef;
|
|
5
|
+
readonly config: unknown;
|
|
6
|
+
}
|
|
7
|
+
export interface ChannelBindingValueIface {
|
|
8
|
+
readonly channel: ProviderRef;
|
|
9
|
+
readonly config?: JsonObject;
|
|
10
|
+
readonly key?: string;
|
|
11
|
+
}
|
|
12
|
+
export interface AgentDefinitionInputIface {
|
|
13
|
+
readonly name?: string;
|
|
14
|
+
readonly description?: string;
|
|
15
|
+
readonly avatarUrl?: string;
|
|
16
|
+
readonly harness: HarnessBindingValueIface;
|
|
17
|
+
readonly tools?: BaseToolsValueIface;
|
|
18
|
+
readonly toolPolicy?: Readonly<Record<string, ToolApproval | `${ToolApproval}`>>;
|
|
19
|
+
readonly secrets?: readonly string[];
|
|
20
|
+
readonly channels?: readonly ChannelBindingValueIface[];
|
|
21
|
+
}
|
|
22
|
+
export declare const defineAgent: <TAgent extends AgentDefinitionInputIface>(definition: TAgent) => TAgent;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../src/authoring/agent.ts"],
|
|
4
|
+
"sourcesContent": ["import type { JsonObject, ProviderRef, ToolApproval } from '@finalai/agent-provider';\nimport { AuthoredKind, stamp } from \"./brand.mjs\";\nimport type { BaseToolsValueIface } from \"./sandbox.mjs\";\n\n// A harness binding as authoring helpers produce it: an installed harness\n// helper (`serverlessPi({...})`), a defineHarness result, or a literal.\nexport interface HarnessBindingValueIface {\n readonly harness: ProviderRef;\n readonly config: unknown;\n}\n\nexport interface ChannelBindingValueIface {\n readonly channel: ProviderRef;\n readonly config?: JsonObject;\n readonly key?: string;\n}\n\n// agent.ts. The agent names its harness; everything\n// the harness has an opinion about (model, reasoning, credentials, permission\n// mode, instructions, skills) lives in `harness.config`.\nexport interface AgentDefinitionInputIface {\n readonly name?: string;\n readonly description?: string;\n readonly avatarUrl?: string;\n readonly harness: HarnessBindingValueIface;\n // Base tool capabilities bound to sandbox targets; none unless declared.\n readonly tools?: BaseToolsValueIface;\n // Extra approval policy for MCP tools (`<server>/<tool>`) and base\n // capabilities (`shell`, `files.write`).\n readonly toolPolicy?: Readonly<Record<string, ToolApproval | `${ToolApproval}`>>;\n // Organization secrets this agent's code may read with `ctx.secrets.get(name)`\n // (tools, hooks, resolvers, channel routes). Names referenced elsewhere in the\n // definition (connection `auth.secretKey`, `credentials.apiKey({ secret })`)\n // are added by the compiler; any other secret must be listed here, or reading\n // it fails at run time.\n readonly secrets?: readonly string[];\n // Installed channels (custom channels are files under channels/).\n readonly channels?: readonly ChannelBindingValueIface[];\n}\n\nexport const defineAgent = <TAgent extends AgentDefinitionInputIface>(definition: TAgent): TAgent =>\n stamp({ ...definition }, AuthoredKind.Agent);\n"],
|
|
5
|
+
"mappings": "AACA,SAAS,cAAc,aAAa;AAuC7B,MAAM,cAAc,CAA2C,eACpE,MAAM,EAAE,GAAG,WAAW,GAAG,aAAa,KAAK;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { ToolApproval } from '@finalai/agent-provider';
|
|
2
|
+
import { type AuthoredValue } from "../runtime/values.mjs";
|
|
3
|
+
export interface ApprovalPolicyIface<TInput = unknown> {
|
|
4
|
+
readonly policy: ToolApproval;
|
|
5
|
+
readonly note: string | null;
|
|
6
|
+
readonly predicate?: (input: Readonly<TInput>) => boolean;
|
|
7
|
+
}
|
|
8
|
+
export declare const always: <TInput = unknown>() => ApprovalPolicyIface<TInput>;
|
|
9
|
+
export declare const never: <TInput = unknown>() => ApprovalPolicyIface<TInput>;
|
|
10
|
+
export declare const whenInput: <TInput = unknown>(predicate: (input: Readonly<TInput>) => boolean) => ApprovalPolicyIface<TInput>;
|
|
11
|
+
export interface LoweredApprovalIface {
|
|
12
|
+
policy: ToolApproval;
|
|
13
|
+
note: string | null;
|
|
14
|
+
error: string | null;
|
|
15
|
+
inputDependent: boolean;
|
|
16
|
+
}
|
|
17
|
+
export declare const lowerApproval: (value: AuthoredValue) => LoweredApprovalIface;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { ToolApproval } from "@finalai/agent-provider";
|
|
2
|
+
import * as z from "zod";
|
|
3
|
+
import { callableSchema } from "../runtime/values.mjs";
|
|
4
|
+
import { AuthoredKind, authoredKindOf, stamp } from "./brand.mjs";
|
|
5
|
+
const policy = (value, note = null) => stamp({ policy: value, note }, AuthoredKind.Approval);
|
|
6
|
+
const always = () => policy(ToolApproval.Ask);
|
|
7
|
+
const never = () => policy(ToolApproval.Allow);
|
|
8
|
+
const whenInput = (predicate) => stamp({ policy: ToolApproval.Ask, note: null, predicate }, AuthoredKind.Approval);
|
|
9
|
+
const approvalSchema = z.object({
|
|
10
|
+
policy: z.nativeEnum(ToolApproval),
|
|
11
|
+
note: z.string().nullable(),
|
|
12
|
+
predicate: callableSchema.optional()
|
|
13
|
+
});
|
|
14
|
+
const lowerApproval = (value) => {
|
|
15
|
+
if (value == null)
|
|
16
|
+
return { policy: ToolApproval.Allow, note: null, error: null, inputDependent: false };
|
|
17
|
+
const parsed = approvalSchema.safeParse(value);
|
|
18
|
+
if (authoredKindOf(value) === AuthoredKind.Approval && parsed.success) {
|
|
19
|
+
return {
|
|
20
|
+
policy: parsed.data.policy,
|
|
21
|
+
note: parsed.data.note,
|
|
22
|
+
error: null,
|
|
23
|
+
inputDependent: parsed.data.predicate != null
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
if (value === ToolApproval.Ask || value === ToolApproval.Allow) {
|
|
27
|
+
return { policy: value, note: null, error: null, inputDependent: false };
|
|
28
|
+
}
|
|
29
|
+
return {
|
|
30
|
+
policy: ToolApproval.Ask,
|
|
31
|
+
note: null,
|
|
32
|
+
inputDependent: false,
|
|
33
|
+
error: "approval callbacks are not supported; use always(), never() or whenInput() from @finalai/agents/approval"
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
export {
|
|
37
|
+
always,
|
|
38
|
+
lowerApproval,
|
|
39
|
+
never,
|
|
40
|
+
whenInput
|
|
41
|
+
};
|
|
42
|
+
//# sourceMappingURL=approval.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../src/authoring/approval.ts"],
|
|
4
|
+
"sourcesContent": ["import { ToolApproval } from '@finalai/agent-provider';\nimport * as z from 'zod';\nimport { callableSchema, type AuthoredValue } from \"../runtime/values.mjs\";\nimport { AuthoredKind, authoredKindOf, stamp } from \"./brand.mjs\";\n\n// Approval helpers. They compile to the manifest's\n// 'allow' | 'ask'; the MCP host enforces 'ask' by raising MCP elicitation.\n// Input predicates run in the pinned bundle isolate before the host asks.\n\nexport interface ApprovalPolicyIface<TInput = unknown> {\n readonly policy: ToolApproval;\n // Why a richer policy was lowered to 'ask'; surfaced as a compiler note.\n readonly note: string | null;\n readonly predicate?: (input: Readonly<TInput>) => boolean;\n}\n\nconst policy = <TInput>(\n value: ToolApproval,\n note: string | null = null,\n): ApprovalPolicyIface<TInput> => stamp({ policy: value, note }, AuthoredKind.Approval);\n\nexport const always = <TInput = unknown>(): ApprovalPolicyIface<TInput> => policy(ToolApproval.Ask);\n\nexport const never = <TInput = unknown>(): ApprovalPolicyIface<TInput> =>\n policy(ToolApproval.Allow);\n\nexport const whenInput = <TInput = unknown>(\n predicate: (input: Readonly<TInput>) => boolean,\n): ApprovalPolicyIface<TInput> =>\n stamp({ policy: ToolApproval.Ask, note: null, predicate }, AuthoredKind.Approval);\n\nexport interface LoweredApprovalIface {\n policy: ToolApproval;\n note: string | null;\n error: string | null;\n inputDependent: boolean;\n}\n\nconst approvalSchema = z.object({\n policy: z.nativeEnum(ToolApproval),\n note: z.string().nullable(),\n predicate: callableSchema.optional(),\n});\n\nexport const lowerApproval = (value: AuthoredValue): LoweredApprovalIface => {\n if (value == null)\n return { policy: ToolApproval.Allow, note: null, error: null, inputDependent: false };\n const parsed = approvalSchema.safeParse(value);\n if (authoredKindOf(value) === AuthoredKind.Approval && parsed.success) {\n return {\n policy: parsed.data.policy,\n note: parsed.data.note,\n error: null,\n inputDependent: parsed.data.predicate != null,\n };\n }\n if (value === ToolApproval.Ask || value === ToolApproval.Allow) {\n return { policy: value, note: null, error: null, inputDependent: false };\n }\n return {\n policy: ToolApproval.Ask,\n note: null,\n inputDependent: false,\n error:\n 'approval callbacks are not supported; use always(), never() or whenInput() from @finalai/agents/approval',\n };\n};\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,oBAAoB;AAC7B,YAAY,OAAO;AACnB,SAAS,sBAA0C;AACnD,SAAS,cAAc,gBAAgB,aAAa;AAapD,MAAM,SAAS,CACb,OACA,OAAsB,SACU,MAAM,EAAE,QAAQ,OAAO,KAAK,GAAG,aAAa,QAAQ;AAE/E,MAAM,SAAS,MAAqD,OAAO,aAAa,GAAG;AAE3F,MAAM,QAAQ,MACnB,OAAO,aAAa,KAAK;AAEpB,MAAM,YAAY,CACvB,cAEA,MAAM,EAAE,QAAQ,aAAa,KAAK,MAAM,MAAM,UAAU,GAAG,aAAa,QAAQ;AASlF,MAAM,iBAAiB,EAAE,OAAO;AAAA,EAC9B,QAAQ,EAAE,WAAW,YAAY;AAAA,EACjC,MAAM,EAAE,OAAO,EAAE,SAAS;AAAA,EAC1B,WAAW,eAAe,SAAS;AACrC,CAAC;AAEM,MAAM,gBAAgB,CAAC,UAA+C;AAC3E,MAAI,SAAS;AACX,WAAO,EAAE,QAAQ,aAAa,OAAO,MAAM,MAAM,OAAO,MAAM,gBAAgB,MAAM;AACtF,QAAM,SAAS,eAAe,UAAU,KAAK;AAC7C,MAAI,eAAe,KAAK,MAAM,aAAa,YAAY,OAAO,SAAS;AACrE,WAAO;AAAA,MACL,QAAQ,OAAO,KAAK;AAAA,MACpB,MAAM,OAAO,KAAK;AAAA,MAClB,OAAO;AAAA,MACP,gBAAgB,OAAO,KAAK,aAAa;AAAA,IAC3C;AAAA,EACF;AACA,MAAI,UAAU,aAAa,OAAO,UAAU,aAAa,OAAO;AAC9D,WAAO,EAAE,QAAQ,OAAO,MAAM,MAAM,OAAO,MAAM,gBAAgB,MAAM;AAAA,EACzE;AACA,SAAO;AAAA,IACL,QAAQ,aAAa;AAAA,IACrB,MAAM;AAAA,IACN,gBAAgB;AAAA,IAChB,OACE;AAAA,EACJ;AACF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { type AuthoredValue } from "../runtime/values.mjs";
|
|
2
|
+
export declare enum AuthoredKind {
|
|
3
|
+
Agent = "agent",
|
|
4
|
+
Tool = "tool",
|
|
5
|
+
Dynamic = "dynamic",
|
|
6
|
+
Instructions = "instructions",
|
|
7
|
+
Skill = "skill",
|
|
8
|
+
Connection = "connection",
|
|
9
|
+
Schedule = "schedule",
|
|
10
|
+
SandboxSelector = "sandbox-selector",
|
|
11
|
+
BaseTools = "base-tools",
|
|
12
|
+
HarnessHost = "harness-host",
|
|
13
|
+
Hook = "hook",
|
|
14
|
+
Channel = "channel",
|
|
15
|
+
Approval = "approval"
|
|
16
|
+
}
|
|
17
|
+
export declare const stamp: <T extends object>(value: T, kind: AuthoredKind) => T;
|
|
18
|
+
export declare const authoredKindOf: (value: AuthoredValue) => AuthoredKind | null;
|
|
19
|
+
export declare const isAuthored: (value: AuthoredValue, kind: AuthoredKind) => boolean;
|
|
20
|
+
export declare const registerPending: (value: AuthoredValue) => string;
|
|
21
|
+
export declare const pendingEntries: () => {
|
|
22
|
+
placeholder: string;
|
|
23
|
+
index: number;
|
|
24
|
+
value: AuthoredValue;
|
|
25
|
+
}[];
|
|
26
|
+
export declare const pendingIndexOf: (placeholder: string) => number | null;
|
|
27
|
+
export declare const pendingExportName: (index: number) => string;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { isObjectLike } from "../runtime/values.mjs";
|
|
2
|
+
var AuthoredKind = /* @__PURE__ */ ((AuthoredKind2) => {
|
|
3
|
+
AuthoredKind2["Agent"] = "agent";
|
|
4
|
+
AuthoredKind2["Tool"] = "tool";
|
|
5
|
+
AuthoredKind2["Dynamic"] = "dynamic";
|
|
6
|
+
AuthoredKind2["Instructions"] = "instructions";
|
|
7
|
+
AuthoredKind2["Skill"] = "skill";
|
|
8
|
+
AuthoredKind2["Connection"] = "connection";
|
|
9
|
+
AuthoredKind2["Schedule"] = "schedule";
|
|
10
|
+
AuthoredKind2["SandboxSelector"] = "sandbox-selector";
|
|
11
|
+
AuthoredKind2["BaseTools"] = "base-tools";
|
|
12
|
+
AuthoredKind2["HarnessHost"] = "harness-host";
|
|
13
|
+
AuthoredKind2["Hook"] = "hook";
|
|
14
|
+
AuthoredKind2["Channel"] = "channel";
|
|
15
|
+
AuthoredKind2["Approval"] = "approval";
|
|
16
|
+
return AuthoredKind2;
|
|
17
|
+
})(AuthoredKind || {});
|
|
18
|
+
const kinds = /* @__PURE__ */ new WeakMap();
|
|
19
|
+
const stamp = (value, kind) => {
|
|
20
|
+
kinds.set(value, kind);
|
|
21
|
+
return value;
|
|
22
|
+
};
|
|
23
|
+
const authoredKindOf = (value) => isObjectLike(value) ? kinds.get(value) ?? null : null;
|
|
24
|
+
const isAuthored = (value, kind) => authoredKindOf(value) === kind;
|
|
25
|
+
const PENDING_PREFIX = "<pending:";
|
|
26
|
+
const pendingValues = [];
|
|
27
|
+
const registerPending = (value) => {
|
|
28
|
+
pendingValues.push(value);
|
|
29
|
+
return `${PENDING_PREFIX}${pendingValues.length - 1}>`;
|
|
30
|
+
};
|
|
31
|
+
const pendingEntries = () => pendingValues.map((value, index) => ({
|
|
32
|
+
placeholder: `${PENDING_PREFIX}${index}>`,
|
|
33
|
+
index,
|
|
34
|
+
value
|
|
35
|
+
}));
|
|
36
|
+
const pendingIndexOf = (placeholder) => {
|
|
37
|
+
const match = /^<pending:(\d+)>$/.exec(placeholder);
|
|
38
|
+
return match?.[1] == null ? null : Number(match[1]);
|
|
39
|
+
};
|
|
40
|
+
const pendingExportName = (index) => `pending:${index}`;
|
|
41
|
+
export {
|
|
42
|
+
AuthoredKind,
|
|
43
|
+
authoredKindOf,
|
|
44
|
+
isAuthored,
|
|
45
|
+
pendingEntries,
|
|
46
|
+
pendingExportName,
|
|
47
|
+
pendingIndexOf,
|
|
48
|
+
registerPending,
|
|
49
|
+
stamp
|
|
50
|
+
};
|
|
51
|
+
//# sourceMappingURL=brand.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../src/authoring/brand.ts"],
|
|
4
|
+
"sourcesContent": ["import { isObjectLike, type AuthoredValue } from \"../runtime/values.mjs\";\n\n// Authored values are plain objects (or functions) registered with their\n// kind, so the compiler's evaluation realm and the isolate runtime recognize\n// them without classes or instanceof. The registry lives in the same realm as\n// the authored code, because the authoring module is bundled with it.\n\nexport enum AuthoredKind {\n Agent = 'agent',\n Tool = 'tool',\n Dynamic = 'dynamic',\n Instructions = 'instructions',\n Skill = 'skill',\n Connection = 'connection',\n Schedule = 'schedule',\n SandboxSelector = 'sandbox-selector',\n BaseTools = 'base-tools',\n HarnessHost = 'harness-host',\n Hook = 'hook',\n Channel = 'channel',\n Approval = 'approval',\n}\n\nconst kinds = new WeakMap<object, AuthoredKind>();\n\nexport const stamp = <T extends object>(value: T, kind: AuthoredKind): T => {\n kinds.set(value, kind);\n return value;\n};\n\nexport const authoredKindOf = (value: AuthoredValue): AuthoredKind | null =>\n isObjectLike(value) ? (kinds.get(value) ?? null) : null;\n\nexport const isAuthored = (value: AuthoredValue, kind: AuthoredKind): boolean =>\n authoredKindOf(value) === kind;\n\n// Values whose bundle export is unknown where they are created (a custom\n// harness, a custom credential resolver): authoring records them in order and\n// hands out a placeholder; the compiler maps each placeholder to a synthesized\n// bundle export. Evaluation order is the bundle's module order, so the\n// compile-time evaluation and the isolate agree on the numbering.\nconst PENDING_PREFIX = '<pending:';\nconst pendingValues: AuthoredValue[] = [];\n\nexport const registerPending = (value: AuthoredValue): string => {\n pendingValues.push(value);\n return `${PENDING_PREFIX}${pendingValues.length - 1}>`;\n};\n\nexport const pendingEntries = (): { placeholder: string; index: number; value: AuthoredValue }[] =>\n pendingValues.map((value, index) => ({\n placeholder: `${PENDING_PREFIX}${index}>`,\n index,\n value,\n }));\n\nexport const pendingIndexOf = (placeholder: string): number | null => {\n const match = /^<pending:(\\d+)>$/.exec(placeholder);\n return match?.[1] == null ? null : Number(match[1]);\n};\n\nexport const pendingExportName = (index: number): string => `pending:${index}`;\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,oBAAwC;AAO1C,IAAK,eAAL,kBAAKA,kBAAL;AACL,EAAAA,cAAA,WAAQ;AACR,EAAAA,cAAA,UAAO;AACP,EAAAA,cAAA,aAAU;AACV,EAAAA,cAAA,kBAAe;AACf,EAAAA,cAAA,WAAQ;AACR,EAAAA,cAAA,gBAAa;AACb,EAAAA,cAAA,cAAW;AACX,EAAAA,cAAA,qBAAkB;AAClB,EAAAA,cAAA,eAAY;AACZ,EAAAA,cAAA,iBAAc;AACd,EAAAA,cAAA,UAAO;AACP,EAAAA,cAAA,aAAU;AACV,EAAAA,cAAA,cAAW;AAbD,SAAAA;AAAA,GAAA;AAgBZ,MAAM,QAAQ,oBAAI,QAA8B;AAEzC,MAAM,QAAQ,CAAmB,OAAU,SAA0B;AAC1E,QAAM,IAAI,OAAO,IAAI;AACrB,SAAO;AACT;AAEO,MAAM,iBAAiB,CAAC,UAC7B,aAAa,KAAK,IAAK,MAAM,IAAI,KAAK,KAAK,OAAQ;AAE9C,MAAM,aAAa,CAAC,OAAsB,SAC/C,eAAe,KAAK,MAAM;AAO5B,MAAM,iBAAiB;AACvB,MAAM,gBAAiC,CAAC;AAEjC,MAAM,kBAAkB,CAAC,UAAiC;AAC/D,gBAAc,KAAK,KAAK;AACxB,SAAO,GAAG,cAAc,GAAG,cAAc,SAAS,CAAC;AACrD;AAEO,MAAM,iBAAiB,MAC5B,cAAc,IAAI,CAAC,OAAO,WAAW;AAAA,EACnC,aAAa,GAAG,cAAc,GAAG,KAAK;AAAA,EACtC;AAAA,EACA;AACF,EAAE;AAEG,MAAM,iBAAiB,CAAC,gBAAuC;AACpE,QAAM,QAAQ,oBAAoB,KAAK,WAAW;AAClD,SAAO,QAAQ,CAAC,KAAK,OAAO,OAAO,OAAO,MAAM,CAAC,CAAC;AACpD;AAEO,MAAM,oBAAoB,CAAC,UAA0B,WAAW,KAAK;",
|
|
6
|
+
"names": ["AuthoredKind"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { AcpUpdateKind, ChannelAddressContextIface, ChannelDefinitionIface, ChannelEventHandler, ChannelReceiveContextIface, ChannelReceiveResult, ChannelSemanticDataByKindIface, HttpChannelRouteDefinitionIface, JsonObject, JsonValue, PendingEventKind, ProjectionContextIface, TurnPolicy, WebSocketChannelRouteDefinitionIface } from '@finalai/agent-provider';
|
|
2
|
+
export type RouteHandler = HttpChannelRouteDefinitionIface['handler'];
|
|
3
|
+
export type RouteHandlerArgsIface = Parameters<RouteHandler>[0];
|
|
4
|
+
export type AuthoredChannelDefinitionIface = Partial<Omit<ChannelDefinitionIface<JsonValue, JsonValue>, 'turnPolicy' | 'events' | 'receive'>> & {
|
|
5
|
+
receive?: (input: JsonValue, ctx: ChannelReceiveContextIface & ChannelAddressContextIface) => Promise<ChannelReceiveResult>;
|
|
6
|
+
events?: Partial<Record<AcpUpdateKind | `${PendingEventKind}`, ChannelEventHandler>> & AuthoredSemanticEventsIface;
|
|
7
|
+
readonly turnPolicy?: TurnPolicy | `${TurnPolicy}`;
|
|
8
|
+
readonly config?: JsonObject;
|
|
9
|
+
readonly disabled?: boolean;
|
|
10
|
+
};
|
|
11
|
+
export interface AuthoredChannelContextIface extends ChannelAddressContextIface {
|
|
12
|
+
platform: ProjectionContextIface['platform'];
|
|
13
|
+
}
|
|
14
|
+
export interface AuthoredSessionContextIface {
|
|
15
|
+
sessionId: string | null;
|
|
16
|
+
turnId: string;
|
|
17
|
+
state: ProjectionContextIface['state'];
|
|
18
|
+
}
|
|
19
|
+
export type AuthoredSemanticEventsIface = {
|
|
20
|
+
[Kind in keyof ChannelSemanticDataByKindIface]?: (data: ChannelSemanticDataByKindIface[Kind], channel: AuthoredChannelContextIface, ctx: AuthoredSessionContextIface) => void | Promise<void>;
|
|
21
|
+
};
|
|
22
|
+
export declare const defineChannel: <TChannel extends AuthoredChannelDefinitionIface>(definition: TChannel) => Omit<TChannel, "installed" | "configure"> & {
|
|
23
|
+
configure: ((config: JsonObject) => ChannelDefinitionIface<JsonValue, JsonValue>) | undefined;
|
|
24
|
+
events: {
|
|
25
|
+
[x: string]: ChannelEventHandler | undefined;
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
export declare const disableChannel: () => Omit<{
|
|
29
|
+
disabled: true;
|
|
30
|
+
}, "installed" | "configure"> & {
|
|
31
|
+
configure: ((config: JsonObject) => ChannelDefinitionIface<JsonValue, JsonValue>) | undefined;
|
|
32
|
+
events: {
|
|
33
|
+
[x: string]: ChannelEventHandler | undefined;
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
export declare const GET: (path: string, handler: RouteHandler) => HttpChannelRouteDefinitionIface;
|
|
37
|
+
export declare const POST: (path: string, handler: RouteHandler) => HttpChannelRouteDefinitionIface;
|
|
38
|
+
export declare const PUT: (path: string, handler: RouteHandler) => HttpChannelRouteDefinitionIface;
|
|
39
|
+
export declare const DELETE: (path: string, handler: RouteHandler) => HttpChannelRouteDefinitionIface;
|
|
40
|
+
export declare const WS: (path: string, handler: WebSocketChannelRouteDefinitionIface["handler"]) => WebSocketChannelRouteDefinitionIface;
|
|
41
|
+
export declare const defineProviderChannel: <T extends ChannelDefinitionIface<JsonValue, JsonValue>>(definition: T) => T;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import {
|
|
2
|
+
channelAccessors,
|
|
3
|
+
channelMessageCompletedSchema,
|
|
4
|
+
jsonObjectSchema
|
|
5
|
+
} from "@finalai/agent-provider";
|
|
6
|
+
import * as z from "zod";
|
|
7
|
+
import { AuthoredKind, stamp } from "./brand.mjs";
|
|
8
|
+
const defineChannel = (definition) => {
|
|
9
|
+
const {
|
|
10
|
+
"message.delta": delta,
|
|
11
|
+
"message.completed": completed,
|
|
12
|
+
"turn.started": started,
|
|
13
|
+
"turn.completed": ended,
|
|
14
|
+
...raw
|
|
15
|
+
} = definition.events ?? {};
|
|
16
|
+
const events = { ...raw };
|
|
17
|
+
const wrap = (schema, handler) => handler == null ? void 0 : async (event, ctx) => handler(
|
|
18
|
+
schema.parse(event.data),
|
|
19
|
+
{ ...channelAccessors(ctx.platform), platform: ctx.platform },
|
|
20
|
+
{
|
|
21
|
+
sessionId: ctx.sessionId ?? null,
|
|
22
|
+
turnId: ctx.turn.id,
|
|
23
|
+
state: ctx.state
|
|
24
|
+
}
|
|
25
|
+
);
|
|
26
|
+
const semantic = {
|
|
27
|
+
"message.delta": wrap(z.object({ messageId: z.string(), delta: jsonObjectSchema }), delta),
|
|
28
|
+
"message.completed": wrap(channelMessageCompletedSchema, completed),
|
|
29
|
+
"turn.started": wrap(z.object({ turnId: z.string() }), started),
|
|
30
|
+
"turn.completed": wrap(
|
|
31
|
+
z.object({ turnId: z.string(), stopReason: z.string().nullable() }),
|
|
32
|
+
ended
|
|
33
|
+
)
|
|
34
|
+
};
|
|
35
|
+
for (const [kind, handler] of Object.entries(semantic))
|
|
36
|
+
if (handler != null) events[kind] = handler;
|
|
37
|
+
const { installed, configure, ...authored } = definition;
|
|
38
|
+
return stamp(
|
|
39
|
+
{ ...authored, configure: installed == null ? configure : void 0, events },
|
|
40
|
+
AuthoredKind.Channel
|
|
41
|
+
);
|
|
42
|
+
};
|
|
43
|
+
const disableChannel = () => defineChannel({ disabled: true });
|
|
44
|
+
const route = (method) => (path, handler) => ({
|
|
45
|
+
method,
|
|
46
|
+
path,
|
|
47
|
+
handler
|
|
48
|
+
});
|
|
49
|
+
const GET = route("GET");
|
|
50
|
+
const POST = route("POST");
|
|
51
|
+
const PUT = route("PUT");
|
|
52
|
+
const DELETE = route("DELETE");
|
|
53
|
+
const WS = (path, handler) => ({ method: "WS", path, handler });
|
|
54
|
+
const defineProviderChannel = (definition) => stamp(definition, AuthoredKind.Channel);
|
|
55
|
+
export {
|
|
56
|
+
DELETE,
|
|
57
|
+
GET,
|
|
58
|
+
POST,
|
|
59
|
+
PUT,
|
|
60
|
+
WS,
|
|
61
|
+
defineChannel,
|
|
62
|
+
defineProviderChannel,
|
|
63
|
+
disableChannel
|
|
64
|
+
};
|
|
65
|
+
//# sourceMappingURL=channels.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../src/authoring/channels.ts"],
|
|
4
|
+
"sourcesContent": ["import type {\n AcpUpdateKind,\n ChannelAddressContextIface,\n ChannelDefinitionIface,\n ChannelEventHandler,\n ChannelReceiveContextIface,\n ChannelReceiveResult,\n ChannelSemanticDataByKindIface,\n HttpChannelRouteDefinitionIface,\n JsonObject,\n JsonValue,\n PendingEventKind,\n ProjectionContextIface,\n TurnPolicy,\n WebSocketChannelRouteDefinitionIface,\n} from '@finalai/agent-provider';\nimport {\n channelAccessors,\n channelMessageCompletedSchema,\n jsonObjectSchema,\n} from '@finalai/agent-provider';\nimport * as z from 'zod';\nimport { AuthoredKind, stamp } from \"./brand.mjs\";\n\n// A custom channel in channels/<stem>.ts. Its routes run\n// in the agent's Worker isolate and are mounted by the session service's\n// front door at /<org>/<agent>/<stem><path> (and /b/<bindingId><path>);\n// the members it authors (receive, route, project, events) run there too,\n// driven by the session service exactly like a built-in channel's. What it\n// leaves out is the platform default: receive takes `{ target, content }`,\n// route follows the default routing rules, and the conversation's own channel projects.\n//\n// A bundle channel sees wire ids everywhere (conversations `conv_\u2026`,\n// participants `cpart_\u2026`, messages `cnmsg_\u2026`, users `usr_\u2026`, its binding\n// `chbind_\u2026`, turns `atrn_\u2026`, pending requests `apnd_\u2026`), the same strings the\n// public API returns, and must pass wire ids back to `ctx.platform`, `receive`\n// results and route decisions; raw UUIDs are refused.\n\nexport type RouteHandler = HttpChannelRouteDefinitionIface['handler'];\nexport type RouteHandlerArgsIface = Parameters<RouteHandler>[0];\n\nexport type AuthoredChannelDefinitionIface = Partial<\n Omit<ChannelDefinitionIface<JsonValue, JsonValue>, 'turnPolicy' | 'events' | 'receive'>\n> & {\n receive?: (\n input: JsonValue,\n ctx: ChannelReceiveContextIface & ChannelAddressContextIface,\n ) => Promise<ChannelReceiveResult>;\n events?: Partial<Record<AcpUpdateKind | `${PendingEventKind}`, ChannelEventHandler>> &\n AuthoredSemanticEventsIface;\n readonly turnPolicy?: TurnPolicy | `${TurnPolicy}`;\n // Static binding config recorded in the manifest.\n readonly config?: JsonObject;\n readonly disabled?: boolean;\n};\n\nexport interface AuthoredChannelContextIface extends ChannelAddressContextIface {\n platform: ProjectionContextIface['platform'];\n}\nexport interface AuthoredSessionContextIface {\n sessionId: string | null;\n turnId: string;\n state: ProjectionContextIface['state'];\n}\nexport type AuthoredSemanticEventsIface = {\n [Kind in keyof ChannelSemanticDataByKindIface]?: (\n data: ChannelSemanticDataByKindIface[Kind],\n channel: AuthoredChannelContextIface,\n ctx: AuthoredSessionContextIface,\n ) => void | Promise<void>;\n};\n\nexport const defineChannel = <TChannel extends AuthoredChannelDefinitionIface>(\n definition: TChannel,\n) => {\n const {\n 'message.delta': delta,\n 'message.completed': completed,\n 'turn.started': started,\n 'turn.completed': ended,\n ...raw\n } = definition.events ?? {};\n const events = { ...raw };\n const wrap = <Data>(\n schema: z.ZodType<Data>,\n handler:\n | ((\n data: Data,\n channel: AuthoredChannelContextIface,\n ctx: AuthoredSessionContextIface,\n ) => void | Promise<void>)\n | undefined,\n ): ChannelEventHandler | undefined =>\n handler == null\n ? undefined\n : async (event, ctx) =>\n handler(\n schema.parse(event.data),\n { ...channelAccessors(ctx.platform), platform: ctx.platform },\n {\n sessionId: ctx.sessionId ?? null,\n turnId: ctx.turn.id,\n state: ctx.state,\n },\n );\n const semantic = {\n 'message.delta': wrap(z.object({ messageId: z.string(), delta: jsonObjectSchema }), delta),\n 'message.completed': wrap(channelMessageCompletedSchema, completed),\n 'turn.started': wrap(z.object({ turnId: z.string() }), started),\n 'turn.completed': wrap(\n z.object({ turnId: z.string(), stopReason: z.string().nullable() }),\n ended,\n ),\n };\n for (const [kind, handler] of Object.entries(semantic))\n if (handler != null) events[kind] = handler;\n const { installed, configure, ...authored } = definition;\n return stamp(\n { ...authored, configure: installed == null ? configure : undefined, events },\n AuthoredKind.Channel,\n );\n};\n\nexport const disableChannel = () => defineChannel({ disabled: true });\n\nconst route =\n (method: HttpChannelRouteDefinitionIface['method']) =>\n (path: string, handler: RouteHandler): HttpChannelRouteDefinitionIface => ({\n method,\n path,\n handler,\n });\n\nexport const GET = route('GET');\nexport const POST = route('POST');\nexport const PUT = route('PUT');\nexport const DELETE = route('DELETE');\n\nexport const WS = (\n path: string,\n handler: WebSocketChannelRouteDefinitionIface['handler'],\n): WebSocketChannelRouteDefinitionIface => ({ method: 'WS', path, handler });\n\n// Provider factories already own their installed reference and runtime handlers.\nexport const defineProviderChannel = <T extends ChannelDefinitionIface<JsonValue, JsonValue>>(\n definition: T,\n): T => stamp(definition, AuthoredKind.Channel);\n"],
|
|
5
|
+
"mappings": "AAgBA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,YAAY,OAAO;AACnB,SAAS,cAAc,aAAa;AAkD7B,MAAM,gBAAgB,CAC3B,eACG;AACH,QAAM;AAAA,IACJ,iBAAiB;AAAA,IACjB,qBAAqB;AAAA,IACrB,gBAAgB;AAAA,IAChB,kBAAkB;AAAA,IAClB,GAAG;AAAA,EACL,IAAI,WAAW,UAAU,CAAC;AAC1B,QAAM,SAAS,EAAE,GAAG,IAAI;AACxB,QAAM,OAAO,CACX,QACA,YAQA,WAAW,OACP,SACA,OAAO,OAAO,QACZ;AAAA,IACE,OAAO,MAAM,MAAM,IAAI;AAAA,IACvB,EAAE,GAAG,iBAAiB,IAAI,QAAQ,GAAG,UAAU,IAAI,SAAS;AAAA,IAC5D;AAAA,MACE,WAAW,IAAI,aAAa;AAAA,MAC5B,QAAQ,IAAI,KAAK;AAAA,MACjB,OAAO,IAAI;AAAA,IACb;AAAA,EACF;AACR,QAAM,WAAW;AAAA,IACf,iBAAiB,KAAK,EAAE,OAAO,EAAE,WAAW,EAAE,OAAO,GAAG,OAAO,iBAAiB,CAAC,GAAG,KAAK;AAAA,IACzF,qBAAqB,KAAK,+BAA+B,SAAS;AAAA,IAClE,gBAAgB,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAC,GAAG,OAAO;AAAA,IAC9D,kBAAkB;AAAA,MAChB,EAAE,OAAO,EAAE,QAAQ,EAAE,OAAO,GAAG,YAAY,EAAE,OAAO,EAAE,SAAS,EAAE,CAAC;AAAA,MAClE;AAAA,IACF;AAAA,EACF;AACA,aAAW,CAAC,MAAM,OAAO,KAAK,OAAO,QAAQ,QAAQ;AACnD,QAAI,WAAW,KAAM,QAAO,IAAI,IAAI;AACtC,QAAM,EAAE,WAAW,WAAW,GAAG,SAAS,IAAI;AAC9C,SAAO;AAAA,IACL,EAAE,GAAG,UAAU,WAAW,aAAa,OAAO,YAAY,QAAW,OAAO;AAAA,IAC5E,aAAa;AAAA,EACf;AACF;AAEO,MAAM,iBAAiB,MAAM,cAAc,EAAE,UAAU,KAAK,CAAC;AAEpE,MAAM,QACJ,CAAC,WACD,CAAC,MAAc,aAA4D;AAAA,EACzE;AAAA,EACA;AAAA,EACA;AACF;AAEK,MAAM,MAAM,MAAM,KAAK;AACvB,MAAM,OAAO,MAAM,MAAM;AACzB,MAAM,MAAM,MAAM,KAAK;AACvB,MAAM,SAAS,MAAM,QAAQ;AAE7B,MAAM,KAAK,CAChB,MACA,aAC0C,EAAE,QAAQ,MAAM,MAAM,QAAQ;AAGnE,MAAM,wBAAwB,CACnC,eACM,MAAM,YAAY,aAAa,OAAO;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { ApprovalPolicyIface } from "./approval.mjs";
|
|
2
|
+
export type McpConnectionAuthIface = {
|
|
3
|
+
readonly secretKey: string;
|
|
4
|
+
readonly headerName: string | null;
|
|
5
|
+
} | {
|
|
6
|
+
readonly kind: 'final-session';
|
|
7
|
+
};
|
|
8
|
+
export interface McpConnectionToolsIface {
|
|
9
|
+
readonly allow?: readonly string[];
|
|
10
|
+
readonly deny?: readonly string[];
|
|
11
|
+
readonly approval?: Readonly<Record<string, ApprovalPolicyIface<never>>>;
|
|
12
|
+
}
|
|
13
|
+
export interface McpClientConnectionDefinitionIface {
|
|
14
|
+
readonly url: string;
|
|
15
|
+
readonly description?: string;
|
|
16
|
+
readonly auth?: McpConnectionAuthIface;
|
|
17
|
+
readonly headers?: Readonly<Record<string, string>>;
|
|
18
|
+
readonly tools?: McpConnectionToolsIface;
|
|
19
|
+
readonly approval?: ApprovalPolicyIface<never>;
|
|
20
|
+
readonly protocolVersionDiscovery?: boolean;
|
|
21
|
+
readonly instanceKey?: string;
|
|
22
|
+
}
|
|
23
|
+
export declare const defineMcpClientConnection: <TConnection extends McpClientConnectionDefinitionIface>(definition: TConnection) => TConnection;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../src/authoring/connections.ts"],
|
|
4
|
+
"sourcesContent": ["import type { ApprovalPolicyIface } from \"./approval.mjs\";\nimport { AuthoredKind, stamp } from \"./brand.mjs\";\n\n// An MCP connection. Secrets are references by\n// name: the MCP host injects them, so they never reach the harness. Final's\n// own MCP server is an ordinary connection with `auth: { kind: 'final-session' }`.\n\nexport type McpConnectionAuthIface =\n // Sent as `Authorization: Bearer <secret>` when headerName is null.\n | { readonly secretKey: string; readonly headerName: string | null }\n | { readonly kind: 'final-session' };\n\nexport interface McpConnectionToolsIface {\n // Only these tools are exposed; omit to expose every tool the server lists.\n readonly allow?: readonly string[];\n // These tools are hidden, whatever `allow` says.\n readonly deny?: readonly string[];\n // Per-tool approval; tools not listed use the connection's `approval`.\n readonly approval?: Readonly<Record<string, ApprovalPolicyIface<never>>>;\n}\n\nexport interface McpClientConnectionDefinitionIface {\n readonly url: string;\n readonly description?: string;\n readonly auth?: McpConnectionAuthIface;\n readonly headers?: Readonly<Record<string, string>>;\n readonly tools?: McpConnectionToolsIface;\n // Default approval for every tool of this connection.\n readonly approval?: ApprovalPolicyIface<never>;\n readonly protocolVersionDiscovery?: boolean;\n readonly instanceKey?: string;\n}\n\nexport const defineMcpClientConnection = <TConnection extends McpClientConnectionDefinitionIface>(\n definition: TConnection,\n): TConnection => stamp({ ...definition }, AuthoredKind.Connection);\n"],
|
|
5
|
+
"mappings": "AACA,SAAS,cAAc,aAAa;AAgC7B,MAAM,4BAA4B,CACvC,eACgB,MAAM,EAAE,GAAG,WAAW,GAAG,aAAa,UAAU;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import type { ConversationMessageIface } from '@finalai/agent-protocol/agent-platform';
|
|
2
|
+
import type { ConversationKind, JsonObject, JsonValue, NetworkSandboxSessionIface, ParticipantKind, ProviderRef } from '@finalai/agent-provider';
|
|
3
|
+
export interface ParticipantInfoIface {
|
|
4
|
+
id: string;
|
|
5
|
+
kind: ParticipantKind;
|
|
6
|
+
displayName: string;
|
|
7
|
+
userId: string | null;
|
|
8
|
+
}
|
|
9
|
+
export interface ConversationInfoIface {
|
|
10
|
+
id: string;
|
|
11
|
+
kind: ConversationKind;
|
|
12
|
+
title: string | null;
|
|
13
|
+
metadata: JsonObject;
|
|
14
|
+
participants: ParticipantInfoIface[];
|
|
15
|
+
}
|
|
16
|
+
export interface PromptAuthorIface {
|
|
17
|
+
participantId: string | null;
|
|
18
|
+
userId: string | null;
|
|
19
|
+
displayName: string;
|
|
20
|
+
}
|
|
21
|
+
export interface AgentSessionInfoIface {
|
|
22
|
+
id: string;
|
|
23
|
+
organizationId: string;
|
|
24
|
+
definitionId: string;
|
|
25
|
+
revisionId: string;
|
|
26
|
+
conversation: ConversationInfoIface | null;
|
|
27
|
+
author: PromptAuthorIface | null;
|
|
28
|
+
turn: {
|
|
29
|
+
id: string;
|
|
30
|
+
} | null;
|
|
31
|
+
harness: ProviderRef;
|
|
32
|
+
}
|
|
33
|
+
export declare enum TranscriptRole {
|
|
34
|
+
User = "user",
|
|
35
|
+
Assistant = "assistant",
|
|
36
|
+
Tool = "tool",
|
|
37
|
+
Thought = "thought",
|
|
38
|
+
Summary = "summary"
|
|
39
|
+
}
|
|
40
|
+
export interface TranscriptMessageIface {
|
|
41
|
+
role: TranscriptRole;
|
|
42
|
+
content: JsonValue[];
|
|
43
|
+
toolCallId: string | null;
|
|
44
|
+
seq: number;
|
|
45
|
+
}
|
|
46
|
+
export interface SecretsIface {
|
|
47
|
+
get(name: string): Promise<string | null>;
|
|
48
|
+
}
|
|
49
|
+
export interface PostMessageInputIface {
|
|
50
|
+
text?: string;
|
|
51
|
+
content?: JsonValue[];
|
|
52
|
+
conversationId?: string;
|
|
53
|
+
}
|
|
54
|
+
export interface FinalPlatformClientIface {
|
|
55
|
+
post(input: PostMessageInputIface): Promise<{
|
|
56
|
+
messageId: string;
|
|
57
|
+
}>;
|
|
58
|
+
conversation(): Promise<ConversationInfoIface | null>;
|
|
59
|
+
read(options?: {
|
|
60
|
+
conversationId?: string;
|
|
61
|
+
limit?: number;
|
|
62
|
+
before?: string;
|
|
63
|
+
}): Promise<ConversationMessageIface[]>;
|
|
64
|
+
}
|
|
65
|
+
export interface ToolContextIface {
|
|
66
|
+
readonly session: AgentSessionInfoIface;
|
|
67
|
+
readonly callId: string;
|
|
68
|
+
readonly toolName: string;
|
|
69
|
+
readonly abortSignal: AbortSignal;
|
|
70
|
+
getSandbox(target?: string): Promise<NetworkSandboxSessionIface>;
|
|
71
|
+
readonly messages: readonly TranscriptMessageIface[];
|
|
72
|
+
readonly secrets: SecretsIface;
|
|
73
|
+
readonly final: FinalPlatformClientIface;
|
|
74
|
+
}
|
|
75
|
+
export interface DynamicResolveContextIface {
|
|
76
|
+
readonly previousValue?: JsonValue | null;
|
|
77
|
+
readonly session: AgentSessionInfoIface;
|
|
78
|
+
readonly messages: readonly TranscriptMessageIface[];
|
|
79
|
+
readonly channel: {
|
|
80
|
+
kind: string | null;
|
|
81
|
+
};
|
|
82
|
+
readonly secrets: SecretsIface;
|
|
83
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
var TranscriptRole = /* @__PURE__ */ ((TranscriptRole2) => {
|
|
2
|
+
TranscriptRole2["User"] = "user";
|
|
3
|
+
TranscriptRole2["Assistant"] = "assistant";
|
|
4
|
+
TranscriptRole2["Tool"] = "tool";
|
|
5
|
+
TranscriptRole2["Thought"] = "thought";
|
|
6
|
+
TranscriptRole2["Summary"] = "summary";
|
|
7
|
+
return TranscriptRole2;
|
|
8
|
+
})(TranscriptRole || {});
|
|
9
|
+
export {
|
|
10
|
+
TranscriptRole
|
|
11
|
+
};
|
|
12
|
+
//# sourceMappingURL=context.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../src/authoring/context.ts"],
|
|
4
|
+
"sourcesContent": ["import type { ConversationMessageIface } from '@finalai/agent-protocol/agent-platform';\nimport type {\n ConversationKind,\n JsonObject,\n JsonValue,\n NetworkSandboxSessionIface,\n ParticipantKind,\n ProviderRef,\n} from '@finalai/agent-provider';\n\n// What authored code (tools, hooks, dynamic resolvers, channel routes) sees of\n// the session it runs for. Everything is provided by\n// the session service through the Worker isolate; none of it is harness state.\n//\n// Ids are the public API's wire ids (`<prefix>_<base58>`), the same strings the\n// client SDK and `/api/v1` return: a session is `ases_\u2026`, a conversation\n// `conv_\u2026`, a participant `cpart_\u2026`, a turn `atrn_\u2026`, a user `usr_\u2026`. Pass them\n// back unchanged (`ctx.final.post({ conversationId })`, channel platform\n// calls); raw UUIDs are refused. ACP ids (`toolCallId`, prompt message ids)\n// and provider or model ids are passed through as the harness sent them.\n\nexport interface ParticipantInfoIface {\n // `cpart_\u2026`; `userId` is `usr_\u2026`.\n id: string;\n kind: ParticipantKind;\n displayName: string;\n userId: string | null;\n}\n\nexport interface ConversationInfoIface {\n // `conv_\u2026`, as `client` and `/api/v1/conversations` name it.\n id: string;\n kind: ConversationKind;\n title: string | null;\n metadata: JsonObject;\n participants: ParticipantInfoIface[];\n}\n\nexport interface PromptAuthorIface {\n participantId: string | null;\n userId: string | null;\n displayName: string;\n}\n\nexport interface AgentSessionInfoIface {\n // `ases_\u2026`: what `client.sessions.attach(id)` takes.\n id: string;\n // `org_\u2026`.\n organizationId: string;\n // The agent (`adef_\u2026`) and its published revision (`arev_\u2026`).\n definitionId: string;\n revisionId: string;\n conversation: ConversationInfoIface | null;\n // Who prompted the current turn; null outside a turn and for system input.\n author: PromptAuthorIface | null;\n // `atrn_\u2026`.\n turn: { id: string } | null;\n harness: ProviderRef;\n}\n\nexport enum TranscriptRole {\n User = 'user',\n Assistant = 'assistant',\n Tool = 'tool',\n Thought = 'thought',\n Summary = 'summary',\n}\n\n// One entry of the transcript rebuilt from the session's ACP log. Not the\n// harness's byte-exact model input (no system prompt).\nexport interface TranscriptMessageIface {\n role: TranscriptRole;\n // ACP content blocks.\n content: JsonValue[];\n toolCallId: string | null;\n seq: number;\n}\n\nexport interface SecretsIface {\n get(name: string): Promise<string | null>;\n}\n\nexport interface PostMessageInputIface {\n text?: string;\n // ACP content blocks; appended after `text` when both are given.\n content?: JsonValue[];\n // A `conv_\u2026` id; defaults to the session's conversation.\n conversationId?: string;\n}\n\n// The agent-platform client handed to authored code (a Final addition).\nexport interface FinalPlatformClientIface {\n // Resolves the posted message's `cnmsg_\u2026` id.\n post(input: PostMessageInputIface): Promise<{ messageId: string }>;\n conversation(): Promise<ConversationInfoIface | null>;\n // The current conversation's visible history, oldest first within the page.\n // `before` is a cnmsg_\u2026 id; other conversations are refused by the platform.\n read(options?: {\n conversationId?: string;\n limit?: number;\n before?: string;\n }): Promise<ConversationMessageIface[]>;\n}\n\nexport interface ToolContextIface {\n readonly session: AgentSessionInfoIface;\n // The MCP request id the harness chose; shows up as the ACP toolCallId.\n readonly callId: string;\n // Qualified name as the harness saw it.\n readonly toolName: string;\n readonly abortSignal: AbortSignal;\n // The same handle the sandbox MCP server uses; the first call starts the\n // sandbox. Defaults to the definition's default target.\n getSandbox(target?: string): Promise<NetworkSandboxSessionIface>;\n readonly messages: readonly TranscriptMessageIface[];\n readonly secrets: SecretsIface;\n readonly final: FinalPlatformClientIface;\n}\n\nexport interface DynamicResolveContextIface {\n // The persisted value of this slot at its previous lifecycle boundary.\n readonly previousValue?: JsonValue | null;\n readonly session: AgentSessionInfoIface;\n // The transcript at the boundary (empty at session.started for a new session).\n readonly messages: readonly TranscriptMessageIface[];\n readonly channel: { kind: string | null };\n readonly secrets: SecretsIface;\n}\n"],
|
|
5
|
+
"mappings": "AA4DO,IAAK,iBAAL,kBAAKA,oBAAL;AACL,EAAAA,gBAAA,UAAO;AACP,EAAAA,gBAAA,eAAY;AACZ,EAAAA,gBAAA,UAAO;AACP,EAAAA,gBAAA,aAAU;AACV,EAAAA,gBAAA,aAAU;AALA,SAAAA;AAAA,GAAA;",
|
|
6
|
+
"names": ["TranscriptRole"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { credentials as contractCredentials, type CustomNodeIface } from '@finalai/agent-provider';
|
|
2
|
+
import type { DynamicSentinelIface } from "./dynamic.mjs";
|
|
3
|
+
type CustomResolverInput = DynamicSentinelIface | Parameters<typeof contractCredentials.custom>[0];
|
|
4
|
+
declare const custom: (resolver: CustomResolverInput) => CustomNodeIface;
|
|
5
|
+
export interface AuthoredCredentialsIface extends Omit<typeof contractCredentials, 'custom'> {
|
|
6
|
+
custom: typeof custom;
|
|
7
|
+
}
|
|
8
|
+
export declare const credentials: AuthoredCredentialsIface;
|
|
9
|
+
export { CredentialOwner, CredentialPayer, defaultOrganizationCredentialPolicy, defaultPersonalCredentialPolicy, } from '@finalai/agent-provider';
|
|
10
|
+
export type { CredentialNode, CredentialPolicyIface } from '@finalai/agent-provider';
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import {
|
|
2
|
+
credentials as contractCredentials,
|
|
3
|
+
DynamicEvent
|
|
4
|
+
} from "@finalai/agent-provider";
|
|
5
|
+
import { AuthoredKind, isAuthored, registerPending } from "./brand.mjs";
|
|
6
|
+
const DYNAMIC_EVENTS = Object.values(DynamicEvent);
|
|
7
|
+
const eventsOf = (sentinel) => DYNAMIC_EVENTS.filter((event) => sentinel.events[event] != null);
|
|
8
|
+
const isSentinel = (value) => isAuthored(value, AuthoredKind.Dynamic);
|
|
9
|
+
const custom = (resolver) => {
|
|
10
|
+
if (!isSentinel(resolver)) return contractCredentials.custom(resolver);
|
|
11
|
+
const events = eventsOf(resolver);
|
|
12
|
+
return contractCredentials.custom({
|
|
13
|
+
resolverExport: registerPending(resolver),
|
|
14
|
+
events: events.length === 0 ? [DynamicEvent.SessionStarted] : events
|
|
15
|
+
});
|
|
16
|
+
};
|
|
17
|
+
const credentials = { ...contractCredentials, custom };
|
|
18
|
+
import {
|
|
19
|
+
CredentialOwner,
|
|
20
|
+
CredentialPayer,
|
|
21
|
+
defaultOrganizationCredentialPolicy,
|
|
22
|
+
defaultPersonalCredentialPolicy
|
|
23
|
+
} from "@finalai/agent-provider";
|
|
24
|
+
export {
|
|
25
|
+
CredentialOwner,
|
|
26
|
+
CredentialPayer,
|
|
27
|
+
credentials,
|
|
28
|
+
defaultOrganizationCredentialPolicy,
|
|
29
|
+
defaultPersonalCredentialPolicy
|
|
30
|
+
};
|
|
31
|
+
//# sourceMappingURL=credentials.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../src/authoring/credentials.ts"],
|
|
4
|
+
"sourcesContent": ["import {\n credentials as contractCredentials,\n DynamicEvent,\n type CustomNodeIface,\n} from '@finalai/agent-provider';\nimport { AuthoredKind, isAuthored, registerPending } from \"./brand.mjs\";\nimport type { DynamicSentinelIface } from \"./dynamic.mjs\";\n\nconst DYNAMIC_EVENTS: readonly DynamicEvent[] = Object.values(DynamicEvent);\n\nconst eventsOf = (sentinel: DynamicSentinelIface): DynamicEvent[] =>\n DYNAMIC_EVENTS.filter((event) => sentinel.events[event] != null);\n\ntype CustomResolverInput = DynamicSentinelIface | Parameters<typeof contractCredentials.custom>[0];\n\nconst isSentinel = (value: CustomResolverInput): value is DynamicSentinelIface =>\n isAuthored(value, AuthoredKind.Dynamic);\n\n// `credentials.custom(defineDynamic({...}))`: the resolver\n// stays in the bundle; the manifest records its synthesized export name.\nconst custom = (resolver: CustomResolverInput): CustomNodeIface => {\n if (!isSentinel(resolver)) return contractCredentials.custom(resolver);\n const events = eventsOf(resolver);\n return contractCredentials.custom({\n resolverExport: registerPending(resolver),\n events: events.length === 0 ? [DynamicEvent.SessionStarted] : events,\n });\n};\n\nexport interface AuthoredCredentialsIface extends Omit<typeof contractCredentials, 'custom'> {\n custom: typeof custom;\n}\n\nexport const credentials: AuthoredCredentialsIface = { ...contractCredentials, custom };\n\nexport {\n CredentialOwner,\n CredentialPayer,\n defaultOrganizationCredentialPolicy,\n defaultPersonalCredentialPolicy,\n} from '@finalai/agent-provider';\nexport type { CredentialNode, CredentialPolicyIface } from '@finalai/agent-provider';\n"],
|
|
5
|
+
"mappings": "AAAA;AAAA,EACE,eAAe;AAAA,EACf;AAAA,OAEK;AACP,SAAS,cAAc,YAAY,uBAAuB;AAG1D,MAAM,iBAA0C,OAAO,OAAO,YAAY;AAE1E,MAAM,WAAW,CAAC,aAChB,eAAe,OAAO,CAAC,UAAU,SAAS,OAAO,KAAK,KAAK,IAAI;AAIjE,MAAM,aAAa,CAAC,UAClB,WAAW,OAAO,aAAa,OAAO;AAIxC,MAAM,SAAS,CAAC,aAAmD;AACjE,MAAI,CAAC,WAAW,QAAQ,EAAG,QAAO,oBAAoB,OAAO,QAAQ;AACrE,QAAM,SAAS,SAAS,QAAQ;AAChC,SAAO,oBAAoB,OAAO;AAAA,IAChC,gBAAgB,gBAAgB,QAAQ;AAAA,IACxC,QAAQ,OAAO,WAAW,IAAI,CAAC,aAAa,cAAc,IAAI;AAAA,EAChE,CAAC;AACH;AAMO,MAAM,cAAwC,EAAE,GAAG,qBAAqB,OAAO;AAEtF;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|