From bdfff9263bd53399f31ad8254e9549b508d449d6 Mon Sep 17 00:00:00 2001 From: John Smith Date: Mon, 9 Dec 2024 12:59:03 +1030 Subject: [PATCH] feat: Customer auth toggle --- .../[clusterId]/settings/details/page.tsx | 36 ++++- app/client/contract.ts | 126 +++++++++--------- control-plane/src/modules/contract.ts | 2 + control-plane/src/modules/management.ts | 6 + control-plane/src/modules/router.ts | 2 + 5 files changed, 101 insertions(+), 71 deletions(-) diff --git a/app/app/clusters/[clusterId]/settings/details/page.tsx b/app/app/clusters/[clusterId]/settings/details/page.tsx index 29ad8dc1..b10759ed 100644 --- a/app/app/clusters/[clusterId]/settings/details/page.tsx +++ b/app/app/clusters/[clusterId]/settings/details/page.tsx @@ -29,11 +29,13 @@ import toast from "react-hot-toast"; import { z } from "zod"; import { Loading } from "@/components/loading"; import { useRouter } from "next/navigation"; +import Link from "next/link"; const formSchema = z.object({ name: z.string(), description: z.string().default(""), debug: z.boolean().default(false), + enableCustomerAuth: z.boolean().default(false), enableRunConfigs: z.boolean().default(false), enableKnowledgebase: z.boolean().default(false), }); @@ -62,6 +64,10 @@ export default function DetailsPage({ form.setValue("name", details.body.name); form.setValue("description", details.body.description ?? ""); form.setValue("debug", details.body.debug ?? false); + form.setValue( + "enableCustomerAuth", + details.body.enableCustomerAuth ?? false, + ); form.setValue( "enableRunConfigs", details.body.enableRunConfigs ?? false, @@ -90,6 +96,7 @@ export default function DetailsPage({ name: data.name, description: data.description, debug: data.debug, + enableCustomerAuth: data.enableCustomerAuth, enableRunConfigs: data.enableRunConfigs, enableKnowledgebase: data.enableKnowledgebase, }, @@ -159,8 +166,7 @@ export default function DetailsPage({ Create and edit templates for runs directly in the UI. - This allows you to create and edit configurations for - runs from the UI. + This allows you to create and edit configurations for runs from the UI. @@ -202,6 +208,28 @@ export default function DetailsPage({
Advanced Settings
+ ( + +
+ + Customer Provided Auth + + + Allow this cluster to be authenticated with customer provided authentication tokens. + +
+ + + +
+ )} + /> Debug Logging - Allow Inferable to capture additional debug logs for the - purpose of troubleshooting. This applies to all runs - created from this cluster while enabled. + Allow Inferable to capture additional debug logs for the purpose of troubleshooting.
diff --git a/app/client/contract.ts b/app/client/contract.ts index 1d0927c4..f8d3410a 100644 --- a/app/client/contract.ts +++ b/app/client/contract.ts @@ -48,7 +48,7 @@ export const VersionedTextsSchema = z.object({ z.object({ version: z.string(), content: z.string(), - }) + }), ), }); @@ -88,7 +88,7 @@ export const learningSchema = z.object({ summary: z .string() .describe( - "The new information that was learned. Be generic, do not refer to the entities." + "The new information that was learned. Be generic, do not refer to the entities.", ), entities: z .array( @@ -97,7 +97,7 @@ export const learningSchema = z.object({ .string() .describe("The name of the entity this learning relates to."), type: z.enum(["tool"]), - }) + }), ) .describe("The entities this learning relates to."), relevance: z.object({ @@ -121,7 +121,7 @@ export const agentDataSchema = z toolName: z.string(), reasoning: z.string().optional(), input: z.object({}).passthrough(), - }) + }), ) .optional(), }) @@ -162,7 +162,7 @@ export const definition = { description: z.string().optional(), schema: z.string().optional(), config: FunctionConfigSchema.optional(), - }) + }), ) .optional(), }), @@ -231,7 +231,7 @@ export const definition = { .and( z.object({ data: z.string(), - }) + }), ), }, getContract: { @@ -256,7 +256,7 @@ export const definition = { name: z.string(), createdAt: z.date(), description: z.string().nullable(), - }) + }), ), 401: z.undefined(), }, @@ -332,14 +332,15 @@ export const definition = { name: z.string().optional(), description: z.string().optional(), additionalContext: VersionedTextsSchema.optional().describe( - "Additional cluster context which is included in all runs" + "Additional cluster context which is included in all runs", ), debug: z .boolean() .optional() .describe( - "Enable additional logging (Including prompts and results) for use by Inferable support" + "Enable additional logging (Including prompts and results) for use by Inferable support", ), + enableCustomerAuth: z.boolean().optional(), enableRunConfigs: z.boolean().optional(), enableKnowledgebase: z.boolean().optional(), }), @@ -358,6 +359,7 @@ export const definition = { additionalContext: VersionedTextsSchema.nullable(), createdAt: z.date(), debug: z.boolean(), + enableCustomerAuth: z.boolean(), enableRunConfigs: z.boolean(), enableKnowledgebase: z.boolean(), lastPingAt: z.date().nullable(), @@ -389,7 +391,7 @@ export const definition = { workflowId: z.string().nullable(), meta: z.any().nullable(), id: z.string(), - }) + }), ), 401: z.undefined(), 404: z.undefined(), @@ -418,13 +420,13 @@ export const definition = { totalInputTokens: z.number(), totalOutputTokens: z.number(), totalModelInvocations: z.number(), - }) + }), ), agentRuns: z.array( z.object({ date: z.string(), totalAgentRuns: z.number(), - }) + }), ), }), }, @@ -481,23 +483,23 @@ export const definition = { resultSchema: anyObject .optional() .describe( - "A JSON schema definition which the result object should conform to. By default the result will be a JSON object which does not conform to any schema" + "A JSON schema definition which the result object should conform to. By default the result will be a JSON object which does not conform to any schema", ), attachedFunctions: z .array(functionReference) .optional() .describe( - "An array of functions to make available to the run. By default all functions in the cluster will be available" + "An array of functions to make available to the run. By default all functions in the cluster will be available", ), onStatusChange: z .object({ function: functionReference.describe( - "A function to call when the run status changes" + "A function to call when the run status changes", ), }) .optional() .describe( - "Mechanism for receiving notifications when the run status changes" + "Mechanism for receiving notifications when the run status changes", ), metadata: z .record(z.string()) @@ -513,28 +515,34 @@ export const definition = { .object({}) .passthrough() .describe("The mock output of the function"), - }) + }), ) .optional() .describe( - "Function mocks to be used in the run. (Keys should be function in the format _)" + "Function mocks to be used in the run. (Keys should be function in the format _)", ), }) .optional() .describe( - "When provided, the run will be marked as as a test / evaluation" + "When provided, the run will be marked as as a test / evaluation", ), + configId: z + .string() + .optional() + .describe("The run configuration ID to use"), + input: z + .object({}) + .passthrough() + .describe( + "Structured input arguments to merge with the initial prompt. The schema must match the run configuration input schema if defined", + ) + .optional(), config: z .object({ - id: z.string().describe("The run configuration ID"), - input: z - .object({}) - .passthrough() - .describe( - "The run configuration input arguments, the schema must match the run configuration input schema" - ) - .optional(), + id: z.string().describe("DEPRECATED"), + input: z.object({}).passthrough().describe("DEPRECATED").optional(), }) + .describe("DEPRECATED") .optional(), context: anyObject .optional() @@ -553,14 +561,14 @@ export const definition = { .describe("Enable reasoning traces"), callSummarization: z .boolean() - .default(true) + .default(false) .optional() .describe("Enable summarization of oversized call results"), interactive: z .boolean() .default(true) .describe( - "Allow the run to be continued with follow-up messages / message edits" + "Allow the run to be continued with follow-up messages / message edits", ), }), responses: { @@ -638,7 +646,7 @@ export const definition = { createdAt: z.date(), pending: z.boolean().default(false), displayableContext: z.record(z.string()).nullable(), - }) + }), ), 401: z.undefined(), }, @@ -676,7 +684,7 @@ export const definition = { configId: z.string().nullable(), configVersion: z.number().nullable(), feedbackScore: z.number().nullable(), - }) + }), ), 401: z.undefined(), }, @@ -756,23 +764,6 @@ export const definition = { messageId: z.string(), }), }, - storeServiceMetadata: { - method: "PUT", - path: "/clusters/:clusterId/services/:service/keys/:key", - headers: z.object({ authorization: z.string() }), - body: z.object({ - value: z.string(), - }), - pathParams: z.object({ - clusterId: z.string(), - service: z.string(), - key: z.string(), - }), - responses: { - 204: z.undefined(), - 401: z.undefined(), - }, - }, getClusterExport: { method: "GET", path: "/clusters/:clusterId/export", @@ -840,7 +831,7 @@ export const definition = { targetFn: z.string(), service: z.string(), executingMachineId: z.string().nullable(), - }) + }), ), }, }, @@ -876,7 +867,7 @@ export const definition = { createdAt: z.date(), createdBy: z.string(), revokedAt: z.date().nullable(), - }) + }), ), }, }, @@ -900,13 +891,16 @@ export const definition = { headers: z.object({ authorization: z.string(), }), + query: z.object({ + limit: z.coerce.number().min(10).max(50).default(50), + }), responses: { 200: z.array( z.object({ id: z.string(), lastPingAt: z.date(), ip: z.string(), - }) + }), ), }, pathParams: z.object({ @@ -932,10 +926,10 @@ export const definition = { description: z.string().optional(), schema: z.string().optional(), config: FunctionConfigSchema.optional(), - }) + }), ) .optional(), - }) + }), ), }, pathParams: z.object({ @@ -974,7 +968,7 @@ export const definition = { createdAt: z.date(), pending: z.boolean().default(false), displayableContext: z.record(z.string()).nullable(), - }) + }), ), activity: z.array( z.object({ @@ -985,7 +979,7 @@ export const definition = { createdAt: z.date(), jobId: z.string().nullable(), targetFn: z.string().nullable(), - }) + }), ), jobs: z.array( z.object({ @@ -997,7 +991,7 @@ export const definition = { createdAt: z.date(), approved: z.boolean().nullable(), approvalRequested: z.boolean().nullable(), - }) + }), ), run: z.object({ id: z.string(), @@ -1111,7 +1105,7 @@ export const definition = { resultSchema: anyObject.nullable(), inputSchema: anyObject.nullable(), public: z.boolean(), - }) + }), ), }), 401: z.undefined(), @@ -1216,7 +1210,7 @@ export const definition = { resultSchema: z.unknown().nullable(), createdAt: z.date(), updatedAt: z.date(), - }) + }), ), 401: z.undefined(), }, @@ -1243,7 +1237,7 @@ export const definition = { createdAt: z.date(), updatedAt: z.date(), similarity: z.number(), - }) + }), ), 401: z.undefined(), }, @@ -1263,7 +1257,7 @@ export const definition = { jobFailureCount: z.number(), timeToCompletion: z.number(), jobCount: z.number(), - }) + }), ), }, pathParams: z.object({ @@ -1284,7 +1278,7 @@ export const definition = { .array(z.string()) .transform((tags) => tags.map((tag) => tag.toLowerCase().trim())), title: z.string(), - }) + }), ), }), responses: { @@ -1312,7 +1306,7 @@ export const definition = { tags: z.array(z.string()), title: z.string(), similarity: z.number(), - }) + }), ), 401: z.undefined(), }, @@ -1363,7 +1357,7 @@ export const definition = { data: z.string(), tags: z.array(z.string()), title: z.string(), - }) + }), ), 401: z.undefined(), }, @@ -1393,7 +1387,7 @@ export const definition = { .max(20) .default(0) .describe( - "Time in seconds to keep the request open waiting for a response" + "Time in seconds to keep the request open waiting for a response", ), }), headers: z.object({ @@ -1471,7 +1465,7 @@ export const definition = { authContext: z.any().nullable(), runContext: z.any().nullable(), approved: z.boolean(), - }) + }), ), }, }, @@ -1503,7 +1497,7 @@ export const definition = { resultSchema: anyObject .optional() .describe( - "A JSON schema definition which the result object should conform to. By default the result will be a JSON object which does not conform to any schema" + "A JSON schema definition which the result object should conform to. By default the result will be a JSON object which does not conform to any schema", ), modelId: z.enum(["claude-3-5-sonnet", "claude-3-haiku"]), temperature: z diff --git a/control-plane/src/modules/contract.ts b/control-plane/src/modules/contract.ts index e75e09f0..f8d3410a 100644 --- a/control-plane/src/modules/contract.ts +++ b/control-plane/src/modules/contract.ts @@ -340,6 +340,7 @@ export const definition = { .describe( "Enable additional logging (Including prompts and results) for use by Inferable support", ), + enableCustomerAuth: z.boolean().optional(), enableRunConfigs: z.boolean().optional(), enableKnowledgebase: z.boolean().optional(), }), @@ -358,6 +359,7 @@ export const definition = { additionalContext: VersionedTextsSchema.nullable(), createdAt: z.date(), debug: z.boolean(), + enableCustomerAuth: z.boolean(), enableRunConfigs: z.boolean(), enableKnowledgebase: z.boolean(), lastPingAt: z.date().nullable(), diff --git a/control-plane/src/modules/management.ts b/control-plane/src/modules/management.ts index bed1824b..5a60fda4 100644 --- a/control-plane/src/modules/management.ts +++ b/control-plane/src/modules/management.ts @@ -79,6 +79,7 @@ export const editClusterDetails = async ({ description, additionalContext, debug, + enableCustomerAuth, enableRunConfigs, enableKnowledgebase, }: { @@ -88,6 +89,7 @@ export const editClusterDetails = async ({ description?: string; additionalContext?: VersionedTexts; debug?: boolean; + enableCustomerAuth?: boolean; enableRunConfigs?: boolean; enableKnowledgebase?: boolean; }) => { @@ -98,6 +100,7 @@ export const editClusterDetails = async ({ name, additional_context: additionalContext, debug, + enable_customer_auth: enableCustomerAuth, enable_run_configs: enableRunConfigs, enable_knowledgebase: enableKnowledgebase, }) @@ -129,6 +132,7 @@ export const getClusterDetails = async ({ lastPingAt: Date | null; additionalContext: VersionedTexts | null; debug: boolean; + enableCustomerAuth: boolean; enableRunConfigs: boolean; enableKnowledgebase: boolean; }> => { @@ -141,6 +145,7 @@ export const getClusterDetails = async ({ createdAt: data.clusters.created_at, additionalContext: data.clusters.additional_context, debug: data.clusters.debug, + enableCustomerAuth: data.clusters.enable_customer_auth, enableRunConfigs: data.clusters.enable_run_configs, enableKnowledgebase: data.clusters.enable_knowledgebase, }) @@ -178,6 +183,7 @@ export const getClusterDetails = async ({ debug: cluster.debug, additionalContext: cluster.additionalContext, lastPingAt: machines[0]?.maxLastPingAt, + enableCustomerAuth: cluster.enableCustomerAuth, enableRunConfigs: cluster.enableRunConfigs, enableKnowledgebase: cluster.enableKnowledgebase, }; diff --git a/control-plane/src/modules/router.ts b/control-plane/src/modules/router.ts index 5d661762..22164c7d 100644 --- a/control-plane/src/modules/router.ts +++ b/control-plane/src/modules/router.ts @@ -140,6 +140,7 @@ export const router = initServer().router(contract, { name, additionalContext, debug, + enableCustomerAuth, enableRunConfigs, enableKnowledgebase, } = request.body; @@ -151,6 +152,7 @@ export const router = initServer().router(contract, { description, additionalContext, debug, + enableCustomerAuth, enableRunConfigs, enableKnowledgebase, });