@salsita-ai/contracts 0.50.0-develop.eb204e0da4 → 0.50.0-develop.f03b563886
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/assistant/browser-details-tool.js +1 -1
- package/dist/assistant/deployment-assistant.d.ts +18 -6
- package/dist/assistant/deployment-assistant.js +1 -1
- package/dist/assistant/graphql-tools.js +1 -1
- package/dist/assistant/index.d.ts +2 -0
- package/dist/assistant/index.js +1 -1
- package/dist/assistant/message-metadata.d.ts +7 -7
- package/dist/assistant/message-metadata.js +1 -1
- package/dist/assistant/tool-error.d.ts +30 -0
- package/dist/assistant/tool-error.js +1 -0
- package/dist/domain/deployments/api-token-domain.d.ts +5 -0
- package/dist/domain/deployments/api-token-domain.js +1 -1
- package/dist/domain/deployments/deployment-domain.d.ts +2 -0
- package/dist/domain/deployments/index.d.ts +1 -1
- package/dist/domain/deployments/index.js +1 -1
- package/dist/domain/feedback/feedback-domain.d.ts +4 -3
- package/dist/domain/feedback/feedback-domain.js +1 -1
- package/dist/webhook/implementation/index.d.ts +1 -1
- package/dist/webhook/implementation/index.js +1 -1
- package/dist/webhook/implementation/webhook-api-types.d.ts +106 -0
- package/dist/webhook/implementation/webhook-api-types.js +1 -1
- package/dist/webhook/implementation/webhook-client.d.ts +2 -1
- package/dist/webhook/implementation/webhook-client.js +1 -1
- package/dist/webhook/implementation/webhook-routing.d.ts +3 -1
- package/dist/webhook/implementation/webhook-routing.js +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -19,7 +19,7 @@ There is no package-root export. Import from the path that owns the boundary; th
|
|
|
19
19
|
| `clerk` | Clerk backend client and services and the shared user, invitation, role, and token schemas. |
|
|
20
20
|
| `domain` | Branded deployment, customer, project, environment, configuration, and revision data: types, schemas, constructors, and the state values clients compare against. |
|
|
21
21
|
| `chat` | Chat completion and stream chunks, tool definitions, validation, speech, and embeddings. |
|
|
22
|
-
| `assistant` | Experimental assistant: shared client-tool definitions
|
|
22
|
+
| `assistant` | Experimental assistant: shared client-tool definitions, user-message metadata, server-recorded tool errors and the deployment webhook setup shape. |
|
|
23
23
|
| `webhook` | Webhook clients and building blocks, finalization tasks and resources, spreadsheet adapters. |
|
|
24
24
|
|
|
25
25
|
Runtime schemas and TypeScript types are kept aligned, so a value that passes the schema has the declared type.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{toolDefinition as e}from"@tanstack/ai";export const browserDetailsTool=e({name:"getBrowserDetails",description:"
|
|
1
|
+
import{toolDefinition as e}from"@tanstack/ai";export const browserDetailsTool=e({name:"getBrowserDetails",description:"Call when the user asks about their browser, screen or device. Returns their browser details as an image.",inputSchema:{type:"object",properties:{},required:[]}});
|
|
@@ -13,32 +13,39 @@ export type AssistantModelTier = (typeof ASSISTANT_MODEL_TIERS)[number];
|
|
|
13
13
|
export type AssistantReasoningLevel = (typeof ASSISTANT_REASONING_LEVELS)[number];
|
|
14
14
|
/**
|
|
15
15
|
* The `ai` block of the assistant manifest: which provider, model tier and reasoning level the
|
|
16
|
-
* deployment's assistant runs with. Authored in the application spec
|
|
17
|
-
*
|
|
16
|
+
* deployment's assistant runs with. Authored in the application spec and resolved through its deployment webhook;
|
|
17
|
+
* the server has no defaults for any of the three.
|
|
18
18
|
*/
|
|
19
19
|
export interface AssistantAiSettings {
|
|
20
20
|
readonly provider: AssistantAiProvider;
|
|
21
21
|
readonly model: AssistantModelTier;
|
|
22
22
|
readonly reasoning: AssistantReasoningLevel;
|
|
23
|
+
/**
|
|
24
|
+
* How many input tokens a model call of a thread may reach before the thread is compacted on the
|
|
25
|
+
* user's next message. Defaults to the server's limit; the server also caps it.
|
|
26
|
+
*/
|
|
27
|
+
readonly maxThreadSize?: number | undefined;
|
|
23
28
|
}
|
|
24
29
|
export declare const AssistantAiSettings: z.ZodObject<{
|
|
25
30
|
provider: z.ZodEnum<["openai"]>;
|
|
26
31
|
model: z.ZodEnum<["frontier", "advanced", "balanced", "fast"]>;
|
|
27
32
|
reasoning: z.ZodEnum<["low", "medium", "high"]>;
|
|
33
|
+
maxThreadSize: z.ZodOptional<z.ZodNumber>;
|
|
28
34
|
}, "strict", z.ZodTypeAny, {
|
|
29
35
|
provider: "openai";
|
|
30
36
|
model: "advanced" | "balanced" | "fast" | "frontier";
|
|
31
37
|
reasoning: "high" | "low" | "medium";
|
|
38
|
+
maxThreadSize?: number | undefined;
|
|
32
39
|
}, {
|
|
33
40
|
provider: "openai";
|
|
34
41
|
model: "advanced" | "balanced" | "fast" | "frontier";
|
|
35
42
|
reasoning: "high" | "low" | "medium";
|
|
43
|
+
maxThreadSize?: number | undefined;
|
|
36
44
|
}>;
|
|
37
45
|
/**
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
* deployment that registers none has no assistant.
|
|
46
|
+
* The setup returned by a deployment webhook: GraphQL SDL, SDK-generated prompt, integrator
|
|
47
|
+
* instructions and AI settings. The server caches validated answers and builds run prompts from
|
|
48
|
+
* them; a null setup means the assistant is unavailable for that session.
|
|
42
49
|
*/
|
|
43
50
|
export interface DeploymentAssistant {
|
|
44
51
|
readonly sdl: string;
|
|
@@ -54,14 +61,17 @@ export declare const DeploymentAssistant: z.ZodObject<{
|
|
|
54
61
|
provider: z.ZodEnum<["openai"]>;
|
|
55
62
|
model: z.ZodEnum<["frontier", "advanced", "balanced", "fast"]>;
|
|
56
63
|
reasoning: z.ZodEnum<["low", "medium", "high"]>;
|
|
64
|
+
maxThreadSize: z.ZodOptional<z.ZodNumber>;
|
|
57
65
|
}, "strict", z.ZodTypeAny, {
|
|
58
66
|
provider: "openai";
|
|
59
67
|
model: "advanced" | "balanced" | "fast" | "frontier";
|
|
60
68
|
reasoning: "high" | "low" | "medium";
|
|
69
|
+
maxThreadSize?: number | undefined;
|
|
61
70
|
}, {
|
|
62
71
|
provider: "openai";
|
|
63
72
|
model: "advanced" | "balanced" | "fast" | "frontier";
|
|
64
73
|
reasoning: "high" | "low" | "medium";
|
|
74
|
+
maxThreadSize?: number | undefined;
|
|
65
75
|
}>;
|
|
66
76
|
}, "strict", z.ZodTypeAny, {
|
|
67
77
|
sdl: string;
|
|
@@ -71,6 +81,7 @@ export declare const DeploymentAssistant: z.ZodObject<{
|
|
|
71
81
|
provider: "openai";
|
|
72
82
|
model: "advanced" | "balanced" | "fast" | "frontier";
|
|
73
83
|
reasoning: "high" | "low" | "medium";
|
|
84
|
+
maxThreadSize?: number | undefined;
|
|
74
85
|
};
|
|
75
86
|
}, {
|
|
76
87
|
sdl: string;
|
|
@@ -80,5 +91,6 @@ export declare const DeploymentAssistant: z.ZodObject<{
|
|
|
80
91
|
provider: "openai";
|
|
81
92
|
model: "advanced" | "balanced" | "fast" | "frontier";
|
|
82
93
|
reasoning: "high" | "low" | "medium";
|
|
94
|
+
maxThreadSize?: number | undefined;
|
|
83
95
|
};
|
|
84
96
|
}>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{z as t}from"zod";export const ASSISTANT_AI_PROVIDERS=["openai"];export const ASSISTANT_MODEL_TIERS=["frontier","advanced","balanced","fast"];export const ASSISTANT_REASONING_LEVELS=["low","medium","high"];export const AssistantAiSettings=t.object({provider:t.enum(ASSISTANT_AI_PROVIDERS),model:t.enum(ASSISTANT_MODEL_TIERS),reasoning:t.enum(ASSISTANT_REASONING_LEVELS)}).strict();export const DeploymentAssistant=t.object({sdl:t.string().min(1),prompt:t.string().min(1),instructions:t.string().min(1).optional(),ai:AssistantAiSettings}).strict();
|
|
1
|
+
import{z as t}from"zod";export const ASSISTANT_AI_PROVIDERS=["openai"];export const ASSISTANT_MODEL_TIERS=["frontier","advanced","balanced","fast"];export const ASSISTANT_REASONING_LEVELS=["low","medium","high"];export const AssistantAiSettings=t.object({provider:t.enum(ASSISTANT_AI_PROVIDERS),model:t.enum(ASSISTANT_MODEL_TIERS),reasoning:t.enum(ASSISTANT_REASONING_LEVELS),maxThreadSize:t.number().int().positive().optional()}).strict();export const DeploymentAssistant=t.object({sdl:t.string().min(1),prompt:t.string().min(1),instructions:t.string().min(1).optional(),ai:AssistantAiSettings}).strict();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{toolDefinition as e}from"@tanstack/ai";import{z as t}from"zod";export const AssistantGraphQLToolInput=t.object({operations:t.array(t.object({query:t.string(),variables:t.record(t.unknown()).nullish(),operationName:t.string().nullish()})).min(1)});let o={type:"object",properties:{operations:{type:"array",minItems:1,description:"The operations to run, in order. Each one sees the changes of the ones before it.",items:{type:"object",properties:{query:{type:"string",description:"A GraphQL document with exactly one operation, a query or a mutation."},variables:{type:"object",description:"Values of the variables the document declares. Prefer literals written into the document."},operationName:{type:"string",description:"The name of the operation, when the document names it."}},required:["query"]}}},required:["operations"]};export const queryTool=e({name:"query",description:"
|
|
1
|
+
import{toolDefinition as e}from"@tanstack/ai";import{z as t}from"zod";export const AssistantGraphQLToolInput=t.object({operations:t.array(t.object({query:t.string(),variables:t.record(t.unknown()).nullish(),operationName:t.string().nullish()})).min(1)});let o={type:"object",properties:{operations:{type:"array",minItems:1,description:"The operations to run, in order. Each one sees the changes of the ones before it.",items:{type:"object",properties:{query:{type:"string",description:"A GraphQL document with exactly one operation, a query or a mutation."},variables:{type:"object",description:"Values of the variables the document declares. Prefer literals written into the document."},operationName:{type:"string",description:"The name of the operation, when the document names it."}},required:["query"]}}},required:["operations"]};export const queryTool=e({name:"query",description:"Reads the open configuration: runs GraphQL operations and returns their results. Changes nothing; mutations run on a copy discarded after the call.",inputSchema:o});export const applyTool=e({name:"apply",description:"Changes the open configuration: runs GraphQL operations and keeps their changes as one undo step. All or nothing: when any operation fails, nothing changes. `committed` says whether the changes were kept.",inputSchema:o});
|
|
@@ -4,3 +4,5 @@ export { AssistantGraphQLToolInput, applyTool, queryTool } from './graphql-tools
|
|
|
4
4
|
export type { AssistantGraphQLOperation } from './graphql-tools.js';
|
|
5
5
|
export type { AssistantAiProvider, AssistantModelTier, AssistantReasoningLevel } from './deployment-assistant.js';
|
|
6
6
|
export { AssistantMessageMetadata } from './message-metadata.js';
|
|
7
|
+
export { ASSISTANT_TOOL_ERROR_CODES, AssistantToolError } from './tool-error.js';
|
|
8
|
+
export type { AssistantToolErrorCode } from './tool-error.js';
|
package/dist/assistant/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export{browserDetailsTool}from"./browser-details-tool.js";export{ASSISTANT_AI_PROVIDERS,ASSISTANT_MODEL_TIERS,ASSISTANT_REASONING_LEVELS,AssistantAiSettings,DeploymentAssistant}from"./deployment-assistant.js";export{AssistantGraphQLToolInput,applyTool,queryTool}from"./graphql-tools.js";export{AssistantMessageMetadata}from"./message-metadata.js";
|
|
1
|
+
export{browserDetailsTool}from"./browser-details-tool.js";export{ASSISTANT_AI_PROVIDERS,ASSISTANT_MODEL_TIERS,ASSISTANT_REASONING_LEVELS,AssistantAiSettings,DeploymentAssistant}from"./deployment-assistant.js";export{AssistantGraphQLToolInput,applyTool,queryTool}from"./graphql-tools.js";export{AssistantMessageMetadata}from"./message-metadata.js";export{ASSISTANT_TOOL_ERROR_CODES,AssistantToolError}from"./tool-error.js";
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
/**
|
|
3
3
|
* Metadata the assistant chat client attaches to each user message (AG-UI message `metadata`). It is
|
|
4
|
-
* persisted with the message, and the server shows `
|
|
5
|
-
* model knows
|
|
4
|
+
* persisted with the message, and the server shows `changes` to the model in front of the message, so
|
|
5
|
+
* the model knows what the user did in the configurator since it last acted.
|
|
6
6
|
*/
|
|
7
7
|
export interface AssistantMessageMetadata {
|
|
8
|
-
/**
|
|
9
|
-
readonly
|
|
8
|
+
/** The change record since the agent's previous action: a marker or a diff, as the assistant prompt describes it. */
|
|
9
|
+
readonly changes: string;
|
|
10
10
|
}
|
|
11
11
|
export declare const AssistantMessageMetadata: z.ZodObject<{
|
|
12
|
-
|
|
12
|
+
changes: z.ZodString;
|
|
13
13
|
}, "strip", z.ZodTypeAny, {
|
|
14
|
-
|
|
14
|
+
changes: string;
|
|
15
15
|
}, {
|
|
16
|
-
|
|
16
|
+
changes: string;
|
|
17
17
|
}>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{z as t}from"zod";export const AssistantMessageMetadata=t.object({
|
|
1
|
+
import{z as t}from"zod";export const AssistantMessageMetadata=t.object({changes:t.string()});
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
/**
|
|
3
|
+
* Why the server recorded an error in place of the result of an assistant tool call:
|
|
4
|
+
* - `cancelled`: the user stopped the reply while the call was waiting for its result
|
|
5
|
+
* - `no_result`: the thread stopped waiting for the call when the user wrote a new message
|
|
6
|
+
* - `tool_budget`: the reply had used its tool calls for one user message, so the call was not run
|
|
7
|
+
*/
|
|
8
|
+
export declare const ASSISTANT_TOOL_ERROR_CODES: readonly ['cancelled', 'no_result', 'tool_budget'];
|
|
9
|
+
export type AssistantToolErrorCode = (typeof ASSISTANT_TOOL_ERROR_CODES)[number];
|
|
10
|
+
/**
|
|
11
|
+
* An error in place of the result of an assistant tool call. `error` is text for the model, in the
|
|
12
|
+
* `{ error }` form TanStack AI itself records for a tool that threw or was cancelled. `code` is set
|
|
13
|
+
* on the errors the server records and tells the assistant panel what to say to the user; it is
|
|
14
|
+
* read as any string, so a panel older than the server shows a code it does not know as a general
|
|
15
|
+
* failure.
|
|
16
|
+
*/
|
|
17
|
+
export interface AssistantToolError {
|
|
18
|
+
readonly error: string;
|
|
19
|
+
readonly code?: string | undefined;
|
|
20
|
+
}
|
|
21
|
+
export declare const AssistantToolError: z.ZodObject<{
|
|
22
|
+
error: z.ZodString;
|
|
23
|
+
code: z.ZodOptional<z.ZodString>;
|
|
24
|
+
}, "strip", z.ZodTypeAny, {
|
|
25
|
+
error: string;
|
|
26
|
+
code?: string | undefined;
|
|
27
|
+
}, {
|
|
28
|
+
error: string;
|
|
29
|
+
code?: string | undefined;
|
|
30
|
+
}>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{z as o}from"zod";export const ASSISTANT_TOOL_ERROR_CODES=["cancelled","no_result","tool_budget"];export const AssistantToolError=o.object({error:o.string(),code:o.string().optional()});
|
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
import { Branded } from '@salsita-ai/common/utils';
|
|
2
|
+
/**
|
|
3
|
+
* How long the name of an API token may be. A builder gives the name when approving `phoenix login` in Studio, and
|
|
4
|
+
* the CLI sends it back with `POST /auth/token`, so Studio and both server inputs apply this one limit.
|
|
5
|
+
*/
|
|
6
|
+
export declare const API_TOKEN_NAME_MAX_LENGTH = 100;
|
|
2
7
|
/**
|
|
3
8
|
* Identifies one API token: a long-lived, revocable credential that authenticates calls to the Phoenix API on
|
|
4
9
|
* behalf of the user who approved it. The id names the token in revocation and in the request session; it is
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{validate as o}from"uuid";import{Branded as
|
|
1
|
+
import{validate as o}from"uuid";import{Branded as t}from"@salsita-ai/common/utils";export const API_TOKEN_NAME_MAX_LENGTH=100;export const ApiTokenId=r=>{if(!o(r))throw Error(`Invalid API token id: ${r}. It must be a valid UUID.`);return t(r)};
|
|
@@ -86,6 +86,7 @@ export interface Deployment {
|
|
|
86
86
|
readonly id: DeploymentId;
|
|
87
87
|
readonly environmentId: EnvironmentId;
|
|
88
88
|
readonly isActive: boolean;
|
|
89
|
+
readonly assistantEnabled: boolean;
|
|
89
90
|
readonly resourcesUrl: ResourceUrl;
|
|
90
91
|
readonly useAuthHook: boolean;
|
|
91
92
|
readonly lambdaWebhookUrl: LambdaWebhookUrl | null;
|
|
@@ -107,6 +108,7 @@ export interface NewDeployment {
|
|
|
107
108
|
readonly id: DeploymentId;
|
|
108
109
|
readonly environmentId: EnvironmentId;
|
|
109
110
|
readonly isActive: boolean;
|
|
111
|
+
readonly assistantEnabled: boolean;
|
|
110
112
|
readonly resourcesUrl: ResourceUrl;
|
|
111
113
|
readonly useAuthHook: boolean;
|
|
112
114
|
readonly lambdaWebhookUrl: LambdaWebhookUrl | null;
|
|
@@ -5,7 +5,7 @@ export { DEFAULT_PROJECT_ALIAS, ProjectId, ProjectName, ProjectSlug, ProjectCust
|
|
|
5
5
|
export { OAuthProviderId, OAuthClientId, OAuthClientSecret, OAuthBaseUrl, type OAuthProvider, OAuthProviderName, OAuthScopes, } from './oauth-provider-domain.js';
|
|
6
6
|
export { DeploymentBuild, DeploymentBuildId, DeploymentBuildMode, DeploymentBuildSourceKey, DeploymentBuildStatus, } from './deployment-build-domain.js';
|
|
7
7
|
export { SdkBuilderSetupState } from './sdk-builder-setup-domain.js';
|
|
8
|
-
export { ApiTokenId } from './api-token-domain.js';
|
|
8
|
+
export { API_TOKEN_NAME_MAX_LENGTH, ApiTokenId } from './api-token-domain.js';
|
|
9
9
|
export { CustomerId, CustomerName, type Customer, CustomerClerkPublishableKey, CustomerClerkSecretKey, CustomerClerkJwtSecret, CustomerClerkOAuthBaseUrl, CustomerClerkOAuthClientId, CustomerClerkOAuthClientSecret, type CustomerClerkSettings, CustomerSlug, CustomerType, CustomerTypeSchema, } from './customer-domain.js';
|
|
10
10
|
export { OAuthConnectionId, type OAuthConnectionProvider, OAuthRefreshToken, OAuthGrantedScopes, SHAREPOINT_MISSING_TENANT_DOMAIN, SharePointTenantDomainInvalidError, SharePointTenantDomainSchema, type NewOAuthConnection, type OAuthConnection, type SharePointProjectSite, OAUTH_STALE_CONNECTION_CODE, parseRequiredSharePointTenantDomain, parseSharePointTenantDomain, } from './oauth-connection-domain.js';
|
|
11
11
|
export { type Embeddings } from './embedding-domain.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export{EnvironmentId,EnvironmentName,EnvironmentSlug,EnvironmentType,FrontendUrl,DevelopmentKey,DEFAULT_SESSION_LIMIT,PRODUCTION_ENVIRONMENT_SLUG,SessionLimit,ServerKey,BaseDomain,ServiceName,FrontendBucketName,LambdaFunctionName,TfStateKeyPrefix,DdServiceName}from"./environment-domain.js";export{ConfigurationSchemaId,ConfigurationSchemaJsonSchema,ConfigurationSchemaVersion}from"./configuration-schema-domain.js";export{ApplicationType,AllowedOrigin,ChatConfiguration,DeploymentId,ResourceUrl,LambdaWebhookUrl,PrivateS3Bucket,PrivateDeploymentResourcesPath,PublicS3Bucket,PublicDeploymentResourcesPath,DeploymentApplicationId,OAuthProviderRegistration}from"./deployment-domain.js";export{DEFAULT_PROJECT_ALIAS,ProjectId,ProjectName,ProjectSlug,ProjectCustomDomain,ParamStorePath}from"./project-domain.js";export{OAuthProviderId,OAuthClientId,OAuthClientSecret,OAuthBaseUrl,OAuthProviderName,OAuthScopes}from"./oauth-provider-domain.js";export{DeploymentBuild,DeploymentBuildId,DeploymentBuildMode,DeploymentBuildSourceKey,DeploymentBuildStatus}from"./deployment-build-domain.js";export{SdkBuilderSetupState}from"./sdk-builder-setup-domain.js";export{ApiTokenId}from"./api-token-domain.js";export{CustomerId,CustomerName,CustomerClerkPublishableKey,CustomerClerkSecretKey,CustomerClerkJwtSecret,CustomerClerkOAuthBaseUrl,CustomerClerkOAuthClientId,CustomerClerkOAuthClientSecret,CustomerSlug,CustomerType,CustomerTypeSchema}from"./customer-domain.js";export{OAuthConnectionId,OAuthRefreshToken,OAuthGrantedScopes,SHAREPOINT_MISSING_TENANT_DOMAIN,SharePointTenantDomainInvalidError,SharePointTenantDomainSchema,OAUTH_STALE_CONNECTION_CODE,parseRequiredSharePointTenantDomain,parseSharePointTenantDomain}from"./oauth-connection-domain.js";export{BucketTimestamp,SessionCount}from"./session-domain.js";export{AiImageCount}from"./ai-image-domain.js";export{ImageRenderCount,ImageRenderLimit,DEFAULT_IMAGE_RENDER_LIMIT}from"./image-render-domain.js";
|
|
1
|
+
export{EnvironmentId,EnvironmentName,EnvironmentSlug,EnvironmentType,FrontendUrl,DevelopmentKey,DEFAULT_SESSION_LIMIT,PRODUCTION_ENVIRONMENT_SLUG,SessionLimit,ServerKey,BaseDomain,ServiceName,FrontendBucketName,LambdaFunctionName,TfStateKeyPrefix,DdServiceName}from"./environment-domain.js";export{ConfigurationSchemaId,ConfigurationSchemaJsonSchema,ConfigurationSchemaVersion}from"./configuration-schema-domain.js";export{ApplicationType,AllowedOrigin,ChatConfiguration,DeploymentId,ResourceUrl,LambdaWebhookUrl,PrivateS3Bucket,PrivateDeploymentResourcesPath,PublicS3Bucket,PublicDeploymentResourcesPath,DeploymentApplicationId,OAuthProviderRegistration}from"./deployment-domain.js";export{DEFAULT_PROJECT_ALIAS,ProjectId,ProjectName,ProjectSlug,ProjectCustomDomain,ParamStorePath}from"./project-domain.js";export{OAuthProviderId,OAuthClientId,OAuthClientSecret,OAuthBaseUrl,OAuthProviderName,OAuthScopes}from"./oauth-provider-domain.js";export{DeploymentBuild,DeploymentBuildId,DeploymentBuildMode,DeploymentBuildSourceKey,DeploymentBuildStatus}from"./deployment-build-domain.js";export{SdkBuilderSetupState}from"./sdk-builder-setup-domain.js";export{API_TOKEN_NAME_MAX_LENGTH,ApiTokenId}from"./api-token-domain.js";export{CustomerId,CustomerName,CustomerClerkPublishableKey,CustomerClerkSecretKey,CustomerClerkJwtSecret,CustomerClerkOAuthBaseUrl,CustomerClerkOAuthClientId,CustomerClerkOAuthClientSecret,CustomerSlug,CustomerType,CustomerTypeSchema}from"./customer-domain.js";export{OAuthConnectionId,OAuthRefreshToken,OAuthGrantedScopes,SHAREPOINT_MISSING_TENANT_DOMAIN,SharePointTenantDomainInvalidError,SharePointTenantDomainSchema,OAUTH_STALE_CONNECTION_CODE,parseRequiredSharePointTenantDomain,parseSharePointTenantDomain}from"./oauth-connection-domain.js";export{BucketTimestamp,SessionCount}from"./session-domain.js";export{AiImageCount}from"./ai-image-domain.js";export{ImageRenderCount,ImageRenderLimit,DEFAULT_IMAGE_RENDER_LIMIT}from"./image-render-domain.js";
|
|
@@ -44,10 +44,11 @@ export declare const FeedbackSource: ((value: string) => FeedbackSource) & {
|
|
|
44
44
|
readonly Cli: 'cli';
|
|
45
45
|
};
|
|
46
46
|
/**
|
|
47
|
-
* Longest feedback message the server stores.
|
|
48
|
-
* the
|
|
47
|
+
* Longest feedback message the server stores. It leaves room for a full report: the error output and a condensed
|
|
48
|
+
* conversation log of the coding agent that wrote it. Studio and the CLI check it before sending, so a sender learns
|
|
49
|
+
* about the limit without a round trip.
|
|
49
50
|
*/
|
|
50
|
-
export declare const FEEDBACK_MESSAGE_MAX_LENGTH =
|
|
51
|
+
export declare const FEEDBACK_MESSAGE_MAX_LENGTH = 100000;
|
|
51
52
|
/**
|
|
52
53
|
* Longest contact detail a sender may leave with CLI feedback when they want a reply.
|
|
53
54
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{validate as e}from"uuid";import{z as t}from"zod";import{Branded as o}from"@salsita-ai/common/utils";export const FeedbackId=t=>{if(!e(t))throw Error(`Invalid feedback id: ${t}. It must be a valid UUID.`);return o(t)};let r={Bug:"bug",Idea:"idea",Other:"other"};export const FeedbackTypeSchema=t.nativeEnum(r);export const FeedbackType=Object.assign(e=>{let t=FeedbackTypeSchema.safeParse(e);if(!t.success)throw Error(`Invalid feedback type: ${e}. It must be one of ${Object.values(r).join(", ")}.`);return t.data},r);let a={Studio:"studio",Cli:"cli"};export const FeedbackSourceSchema=t.nativeEnum(a);export const FeedbackSource=Object.assign(e=>{let t=FeedbackSourceSchema.safeParse(e);if(!t.success)throw Error(`Invalid feedback source: ${e}. It must be one of ${Object.values(a).join(", ")}.`);return t.data},a);export const FEEDBACK_MESSAGE_MAX_LENGTH=
|
|
1
|
+
import{validate as e}from"uuid";import{z as t}from"zod";import{Branded as o}from"@salsita-ai/common/utils";export const FeedbackId=t=>{if(!e(t))throw Error(`Invalid feedback id: ${t}. It must be a valid UUID.`);return o(t)};let r={Bug:"bug",Idea:"idea",Other:"other"};export const FeedbackTypeSchema=t.nativeEnum(r);export const FeedbackType=Object.assign(e=>{let t=FeedbackTypeSchema.safeParse(e);if(!t.success)throw Error(`Invalid feedback type: ${e}. It must be one of ${Object.values(r).join(", ")}.`);return t.data},r);let a={Studio:"studio",Cli:"cli"};export const FeedbackSourceSchema=t.nativeEnum(a);export const FeedbackSource=Object.assign(e=>{let t=FeedbackSourceSchema.safeParse(e);if(!t.success)throw Error(`Invalid feedback source: ${e}. It must be one of ${Object.values(a).join(", ")}.`);return t.data},a);export const FEEDBACK_MESSAGE_MAX_LENGTH=1e5;export const FEEDBACK_CONTACT_MAX_LENGTH=200;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export { routeWebhookRequests } from './webhook-routing.js';
|
|
2
2
|
export { TunneledWebhookRequest, TunneledWebhookResponse, WebhookTunnelPollRequest, WebhookTunnelPollResponse, WebhookTunnelRespondRequest, } from './webhook-tunnel-types.js';
|
|
3
3
|
export { WebhookClient, createUrlWebhookHttpClient, fetchWebhookHttpClient, type WebhookHttpClient, } from './webhook-client.js';
|
|
4
|
-
export { AuthHandlerResponse, AuthUserIdSource, RefreshPayload, CodePayload, AuthPayload, AnonymousPayload, FinalizeWebhookPayload, CallbackPayload, CallbackResponse, FetchBackendDataPayload, FetchBackendDataHandlerResponse, } from './webhook-api-types.js';
|
|
4
|
+
export { AssistantSetupPayload, AssistantSetupResponse, AuthHandlerResponse, AuthUserIdSource, RefreshPayload, CodePayload, AuthPayload, AnonymousPayload, FinalizeWebhookPayload, CallbackPayload, CallbackResponse, FetchBackendDataPayload, FetchBackendDataHandlerResponse, } from './webhook-api-types.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export{routeWebhookRequests}from"./webhook-routing.js";export{TunneledWebhookRequest,TunneledWebhookResponse,WebhookTunnelPollRequest,WebhookTunnelPollResponse,WebhookTunnelRespondRequest}from"./webhook-tunnel-types.js";export{WebhookClient,createUrlWebhookHttpClient,fetchWebhookHttpClient}from"./webhook-client.js";export{AuthHandlerResponse,AuthUserIdSource,RefreshPayload,CodePayload,AuthPayload,AnonymousPayload,FinalizeWebhookPayload,CallbackPayload,CallbackResponse,FetchBackendDataPayload,FetchBackendDataHandlerResponse}from"./webhook-api-types.js";
|
|
1
|
+
export{routeWebhookRequests}from"./webhook-routing.js";export{TunneledWebhookRequest,TunneledWebhookResponse,WebhookTunnelPollRequest,WebhookTunnelPollResponse,WebhookTunnelRespondRequest}from"./webhook-tunnel-types.js";export{WebhookClient,createUrlWebhookHttpClient,fetchWebhookHttpClient}from"./webhook-client.js";export{AssistantSetupPayload,AssistantSetupResponse,AuthHandlerResponse,AuthUserIdSource,RefreshPayload,CodePayload,AuthPayload,AnonymousPayload,FinalizeWebhookPayload,CallbackPayload,CallbackResponse,FetchBackendDataPayload,FetchBackendDataHandlerResponse}from"./webhook-api-types.js";
|
|
@@ -300,3 +300,109 @@ export declare const FetchBackendDataHandlerResponse: z.ZodObject<{
|
|
|
300
300
|
}, {
|
|
301
301
|
backendData: Record<string, unknown>;
|
|
302
302
|
}>;
|
|
303
|
+
/** Session inputs used by the lambda to resolve the assistant setup. */
|
|
304
|
+
export declare const AssistantSetupPayload: z.ZodObject<{
|
|
305
|
+
deploymentId: z.ZodEffects<z.ZodString, DeploymentId, string>;
|
|
306
|
+
sessionRole: z.ZodNativeEnum<{
|
|
307
|
+
readonly Anonymous: 'anonymous';
|
|
308
|
+
readonly User: 'user';
|
|
309
|
+
readonly Admin: 'admin';
|
|
310
|
+
readonly SuperAdmin: 'superadmin';
|
|
311
|
+
}>;
|
|
312
|
+
sessionPayload: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
313
|
+
sub: z.ZodOptional<z.ZodString>;
|
|
314
|
+
access: z.ZodNativeEnum<{
|
|
315
|
+
readonly Owner: 'o';
|
|
316
|
+
readonly ReadRevision: 'rr';
|
|
317
|
+
readonly Read: 'r';
|
|
318
|
+
}>;
|
|
319
|
+
}, "strip", z.ZodTypeAny, {
|
|
320
|
+
deploymentId: string & import("@salsita-ai/common/utils").Brand<"DeploymentId">;
|
|
321
|
+
sessionRole: "admin" | "anonymous" | "superadmin" | "user";
|
|
322
|
+
sessionPayload: Record<string, unknown>;
|
|
323
|
+
sub?: string | undefined;
|
|
324
|
+
access: "o" | "r" | "rr";
|
|
325
|
+
}, {
|
|
326
|
+
deploymentId: string;
|
|
327
|
+
sessionRole: "admin" | "anonymous" | "superadmin" | "user";
|
|
328
|
+
sessionPayload: Record<string, unknown>;
|
|
329
|
+
sub?: string | undefined;
|
|
330
|
+
access: "o" | "r" | "rr";
|
|
331
|
+
}>;
|
|
332
|
+
export type AssistantSetupPayload = z.infer<typeof AssistantSetupPayload>;
|
|
333
|
+
/**
|
|
334
|
+
* A deployment's assistant setup, or a session for which no assistant is available. `threadLock`
|
|
335
|
+
* is outside the setup a thread is bound to: `'strict'` asks a development environment to lock a
|
|
336
|
+
* thread when the setup changes, as every other environment always does.
|
|
337
|
+
*/
|
|
338
|
+
export declare const AssistantSetupResponse: z.ZodObject<{
|
|
339
|
+
setup: z.ZodNullable<z.ZodObject<{
|
|
340
|
+
sdl: z.ZodString;
|
|
341
|
+
prompt: z.ZodString;
|
|
342
|
+
instructions: z.ZodOptional<z.ZodString>;
|
|
343
|
+
ai: z.ZodObject<{
|
|
344
|
+
provider: z.ZodEnum<["openai"]>;
|
|
345
|
+
model: z.ZodEnum<["frontier", "advanced", "balanced", "fast"]>;
|
|
346
|
+
reasoning: z.ZodEnum<["low", "medium", "high"]>;
|
|
347
|
+
maxThreadSize: z.ZodOptional<z.ZodNumber>;
|
|
348
|
+
}, "strict", z.ZodTypeAny, {
|
|
349
|
+
provider: "openai";
|
|
350
|
+
model: "advanced" | "balanced" | "fast" | "frontier";
|
|
351
|
+
reasoning: "high" | "low" | "medium";
|
|
352
|
+
maxThreadSize?: number | undefined;
|
|
353
|
+
}, {
|
|
354
|
+
provider: "openai";
|
|
355
|
+
model: "advanced" | "balanced" | "fast" | "frontier";
|
|
356
|
+
reasoning: "high" | "low" | "medium";
|
|
357
|
+
maxThreadSize?: number | undefined;
|
|
358
|
+
}>;
|
|
359
|
+
}, "strict", z.ZodTypeAny, {
|
|
360
|
+
sdl: string;
|
|
361
|
+
prompt: string;
|
|
362
|
+
instructions?: string | undefined;
|
|
363
|
+
ai: {
|
|
364
|
+
provider: "openai";
|
|
365
|
+
model: "advanced" | "balanced" | "fast" | "frontier";
|
|
366
|
+
reasoning: "high" | "low" | "medium";
|
|
367
|
+
maxThreadSize?: number | undefined;
|
|
368
|
+
};
|
|
369
|
+
}, {
|
|
370
|
+
sdl: string;
|
|
371
|
+
prompt: string;
|
|
372
|
+
instructions?: string | undefined;
|
|
373
|
+
ai: {
|
|
374
|
+
provider: "openai";
|
|
375
|
+
model: "advanced" | "balanced" | "fast" | "frontier";
|
|
376
|
+
reasoning: "high" | "low" | "medium";
|
|
377
|
+
maxThreadSize?: number | undefined;
|
|
378
|
+
};
|
|
379
|
+
}>>;
|
|
380
|
+
threadLock: z.ZodOptional<z.ZodLiteral<"strict">>;
|
|
381
|
+
}, "strict", z.ZodTypeAny, {
|
|
382
|
+
setup: {
|
|
383
|
+
sdl: string;
|
|
384
|
+
prompt: string;
|
|
385
|
+
instructions?: string | undefined;
|
|
386
|
+
ai: {
|
|
387
|
+
provider: "openai";
|
|
388
|
+
model: "advanced" | "balanced" | "fast" | "frontier";
|
|
389
|
+
reasoning: "high" | "low" | "medium";
|
|
390
|
+
maxThreadSize?: number | undefined;
|
|
391
|
+
};
|
|
392
|
+
} | null;
|
|
393
|
+
threadLock?: "strict" | undefined;
|
|
394
|
+
}, {
|
|
395
|
+
setup: {
|
|
396
|
+
sdl: string;
|
|
397
|
+
prompt: string;
|
|
398
|
+
instructions?: string | undefined;
|
|
399
|
+
ai: {
|
|
400
|
+
provider: "openai";
|
|
401
|
+
model: "advanced" | "balanced" | "fast" | "frontier";
|
|
402
|
+
reasoning: "high" | "low" | "medium";
|
|
403
|
+
maxThreadSize?: number | undefined;
|
|
404
|
+
};
|
|
405
|
+
} | null;
|
|
406
|
+
threadLock?: "strict" | undefined;
|
|
407
|
+
}>;
|
|
408
|
+
export type AssistantSetupResponse = z.infer<typeof AssistantSetupResponse>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{z as o}from"zod";import{usingType as n}from"@salsita-ai/common/utils";import{SessionRole as
|
|
1
|
+
import{z as o}from"zod";import{usingType as n}from"@salsita-ai/common/utils";import{AccessLevel as e,SessionRole as t}from"../../api/index.js";import{DeploymentAssistant as r}from"../../assistant/index.js";import{ConfigurationId as s,DeploymentId as a,FrontendUrl as i,RevisionId as l}from"../../domain/index.js";import{CallLambdaBackResourceType as c}from"../tasks/index.js";export const CallbackPayload=o.object({replayData:o.record(o.unknown()),resources:o.record(o.object({type:o.literal(c.Link),link:o.string()}))});export const CallbackResponse=o.object({result:o.record(o.unknown()).optional()});export const AuthUserIdSource=o.enum(["clerk","custom"]);export const AuthHandlerResponse=o.discriminatedUnion("success",[o.object({success:o.literal(!0),data:o.record(o.unknown()),role:o.nativeEnum(t),refreshToken:o.string().optional(),expirationTime:o.number().optional(),scopes:o.array(o.string()).optional(),userId:o.string().optional(),userIdSource:AuthUserIdSource.optional()}),o.object({success:o.literal(!1)})]);export const RefreshPayload=o.object({type:o.literal("refresh"),refreshToken:o.string()});export const CodePayload=o.object({type:o.literal("code"),accessToken:o.string(),refreshToken:o.string().optional(),idToken:o.string().optional()});export const AnonymousPayload=o.object({type:o.literal("anonymous")});export const AuthPayload=o.union([RefreshPayload,CodePayload,AnonymousPayload]);export const FinalizeWebhookPayload=o.object({configurationId:o.string().transform(n(s)),revisionId:o.string().transform(n(l)),deploymentId:o.string().transform(n(a)),frontendUrl:o.string().transform(n(i)),rootEntityType:o.string(),entities:o.array(o.object({type:o.string(),id:o.string()}).and(o.record(o.unknown()))),modelVersion:o.number().positive(),data:o.record(o.unknown()),frontendData:o.record(o.unknown()).optional(),locale:o.string(),sessionRole:o.nativeEnum(t),sessionPayload:o.record(o.unknown()),publishedAdminRevisionPath:o.string().optional(),publishedChunkUrls:o.record(o.string()).optional(),chunksUploadUrl:o.string().optional(),connectedProviderAccessTokens:o.record(o.string()).optional()});export const FetchBackendDataPayload=o.object({deploymentId:o.string().transform(n(a)),frontendUrl:o.string().transform(n(i)),frontendData:o.record(o.unknown()).optional(),sessionRole:o.nativeEnum(t),sessionPayload:o.record(o.unknown()),publishedAdminRevisionPath:o.string().optional(),publishedChunkUrls:o.record(o.string()).optional()});export const FetchBackendDataHandlerResponse=o.object({backendData:o.record(o.unknown())});export const AssistantSetupPayload=o.object({deploymentId:o.string().transform(n(a)),sessionRole:o.nativeEnum(t),sessionPayload:o.record(o.unknown()),sub:o.string().optional(),access:o.nativeEnum(e)});export const AssistantSetupResponse=o.object({setup:r.nullable(),threadLock:o.literal("strict").optional()}).strict();
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ApplicationType } from '../../domain/index.js';
|
|
2
|
-
import { type CallbackPayload, CallbackResponse, type FetchBackendDataPayload, type FinalizeWebhookPayload } from './webhook-api-types.js';
|
|
2
|
+
import { type AssistantSetupPayload, AssistantSetupResponse, type CallbackPayload, CallbackResponse, type FetchBackendDataPayload, type FinalizeWebhookPayload } from './webhook-api-types.js';
|
|
3
3
|
export type WebhookHttpClient = (url: string, init: RequestInit) => Promise<Response>;
|
|
4
4
|
export declare const fetchWebhookHttpClient: WebhookHttpClient;
|
|
5
5
|
export declare const createUrlWebhookHttpClient: (baseUrl: string, httpClient?: WebhookHttpClient) => WebhookHttpClient;
|
|
@@ -79,6 +79,7 @@ export declare class WebhookClient {
|
|
|
79
79
|
resources: import("../index.js").FinalizeTaskResource<string>[];
|
|
80
80
|
}>;
|
|
81
81
|
callback: (payload: CallbackPayload<Record<string, unknown>, string>) => Promise<CallbackResponse<Record<string, unknown>>>;
|
|
82
|
+
assistantSetup: (payload: AssistantSetupPayload) => Promise<AssistantSetupResponse>;
|
|
82
83
|
fetchBackendData: (payload: FetchBackendDataPayload<Record<string, unknown>, Record<string, unknown>>) => Promise<{
|
|
83
84
|
backendData: Record<string, unknown>;
|
|
84
85
|
}>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{WebhookFinalizeTaskConfiguration as t}from"../tasks/index.js";import{
|
|
1
|
+
import{WebhookFinalizeTaskConfiguration as t}from"../tasks/index.js";import{AssistantSetupResponse as e,AuthHandlerResponse as a,CallbackResponse as o,FetchBackendDataHandlerResponse as i}from"./webhook-api-types.js";import{getAssistantSetupRoute as n,getAuthRoute as r,getCallbackRoute as s,getFetchBackendDataRoute as l,getFinalizeRoute as h}from"./webhook-routing.js";export const fetchWebhookHttpClient=(t,e)=>fetch(t,e);export const createUrlWebhookHttpClient=(t,e=fetchWebhookHttpClient)=>(a,o)=>e(`${t}${a}`,o);export class WebhookClient{_httpClient;constructor(t,e=fetchWebhookHttpClient){this._httpClient="string"==typeof t?createUrlWebhookHttpClient(t,e):t}handleRefreshFlow=async t=>{let e=await this._httpClient(r(),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({type:"refresh",refreshToken:t})});if(!e.ok)throw Error(`Refresh webhook call failed: ${await e.text()}`);return a.parse(await e.json())};handleCodeFlow=async(t,e,o)=>{let i=await this._httpClient(r(),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({type:"code",accessToken:t,refreshToken:e,idToken:o})});if(!i.ok)throw Error(`Refresh webhook call failed: ${await i.text()}`);return a.parse(await i.json())};handleAnonymousFlow=async()=>{let t=await this._httpClient(r(),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({type:"anonymous"})});if(!t.ok)throw Error(`Refresh webhook call failed: ${await t.text()}`);return a.parse(await t.json())};finalize=async(e,a)=>{let o=await this._httpClient(h(a),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!o.ok)throw Error("Lambda call failed: "+await o.text());let i=await o.json();return t.parse(i)};callback=async t=>{let e=await this._httpClient(s(),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!e.ok)throw Error("Lambda call failed: "+await e.text());let a=await e.json();return o.parse(a)};assistantSetup=async t=>{let a=await this._httpClient(n(),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!a.ok)throw Error(`Assistant setup lambda call failed: ${await a.text()}`);return e.parse(await a.json())};fetchBackendData=async t=>{let e=await this._httpClient(l(),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!e.ok)throw Error("Lambda call failed: "+await e.text());return i.parse(await e.json())}}
|
|
@@ -3,7 +3,8 @@ import type { Logger } from '@salsita-ai/common/utils';
|
|
|
3
3
|
import { ApplicationType } from '../../domain/index.js';
|
|
4
4
|
import { type WebhookFinalizeTaskConfiguration } from '../tasks/index.js';
|
|
5
5
|
import type { AuthHandlerResponse, CallbackResponse, FetchBackendDataHandlerResponse } from './webhook-api-types.js';
|
|
6
|
-
import { AuthPayload, CallbackPayload, FetchBackendDataPayload, FinalizeWebhookPayload } from './webhook-api-types.js';
|
|
6
|
+
import { AssistantSetupPayload, AssistantSetupResponse, AuthPayload, CallbackPayload, FetchBackendDataPayload, FinalizeWebhookPayload } from './webhook-api-types.js';
|
|
7
|
+
export declare const getAssistantSetupRoute: () => string;
|
|
7
8
|
export declare const getAuthRoute: () => string;
|
|
8
9
|
export declare const getFinalizeRoute: (applicationType: ApplicationType) => string;
|
|
9
10
|
export declare const getCallbackRoute: () => string;
|
|
@@ -18,6 +19,7 @@ type AuthHandler = (body: AuthPayload, e: APIGatewayProxyEventV2) => Promise<Aut
|
|
|
18
19
|
type FetchBackendDataHandler = (body: FetchBackendDataPayload<Record<string, unknown>, Record<string, unknown>>, e: APIGatewayProxyEventV2) => Promise<FetchBackendDataHandlerResponse>;
|
|
19
20
|
export declare const routeWebhookRequests: (handlers: {
|
|
20
21
|
configurator?: {
|
|
22
|
+
onAssistantSetup?: (body: AssistantSetupPayload, e: APIGatewayProxyEventV2) => Promise<AssistantSetupResponse>;
|
|
21
23
|
onFetchBackendData?: FetchBackendDataHandler;
|
|
22
24
|
onCallback?: CallbackHandler;
|
|
23
25
|
onFinalize?: FinalizeHandler;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{P as o,match as t}from"ts-pattern";import{ApplicationType as r}from"../../domain/index.js";import{validateTaskConfiguration as n}from"../tasks/index.js";import{
|
|
1
|
+
import{P as o,match as t}from"ts-pattern";import{ApplicationType as r}from"../../domain/index.js";import{validateTaskConfiguration as n}from"../tasks/index.js";import{AssistantSetupPayload as e,AssistantSetupResponse as i,AuthPayload as a,CallbackPayload as s,FetchBackendDataPayload as f,FinalizeWebhookPayload as u}from"./webhook-api-types.js";let c="assistantSetup",h="auth",d="finalize",p="callback",l="fetchBackendData";export const getAssistantSetupRoute=()=>`?o=${c}`;export const getAuthRoute=()=>`?o=${h}`;export const getFinalizeRoute=o=>`?o=${d}&t=${o}`;export const getCallbackRoute=()=>`?o=${p}`;export const getFetchBackendDataRoute=()=>`?o=${l}`;export const handleWebhookSafely=(o,t)=>async r=>{try{return await o(r)}catch(n){let o=`Webhook failed: ${n instanceof Error?n.message:"Unknown error"}`,r="object"==typeof n&&n instanceof Error?n:Error(o);return t.error(o,{},r),{statusCode:500,body:JSON.stringify({message:o})}}};export const routeWebhookRequests=(g,w)=>handleWebhookSafely(async y=>{if(!y.body)throw Error("No body found in the webhook event!");let b=JSON.parse(y.isBase64Encoded?Buffer.from(y.body,"base64").toString():y.body);return t(y.queryStringParameters?.o).with(c,async()=>{if(!g.configurator?.onAssistantSetup)throw Error("Assistant setup operation is not configured for this webhook!");let o=await g.configurator.onAssistantSetup(e.parse(b),y);return{statusCode:200,body:JSON.stringify(i.parse(o))}}).with(h,async()=>{if(w.info("Handling auth operation."),!g.onAuth)throw Error("Auth operation is not configured for this webhook!");let o=a.parse(b);return{statusCode:200,body:JSON.stringify(await g.onAuth(o,y))}}).with(p,async()=>{if(w.info("Handling configurator callback operation."),!g.configurator?.onCallback)throw Error("Auth operation is not configured for this webhook!");let o=s.parse(b);return{statusCode:200,body:JSON.stringify(await g.configurator.onCallback(o,y))}}).with(o.union(void 0,d),()=>t(y.queryStringParameters?.t).with(r.Admin,async()=>{if(w.info("Handling admin finalize operation."),!g.admin?.onFinalize)throw Error("Admin finalize operation is not configured for this webhook!");let o=u.parse(b),t=await g.admin.onFinalize(o,y);return n(t),{statusCode:200,body:JSON.stringify(t)}}).with(o.union(void 0,r.Configurator),async()=>{if(w.info("Handling configurator finalize operation."),!g.configurator?.onFinalize)throw Error("Configurator finalize operation is not configured for this webhook!");let o=u.parse(b),t=await g.configurator.onFinalize(o,y);return n(t),{statusCode:200,body:JSON.stringify(t)}}).otherwise(o=>{throw Error(`Can not parse application type - unknown type: ${o}!`)})).with(l,async()=>{if(w.info("Handling fetch backend data operation."),!g.configurator?.onFetchBackendData)throw Error("Fetch backend data operation is not configured for this webhook!");let o=f.parse(b);return{statusCode:200,body:JSON.stringify(await g.configurator.onFetchBackendData(o,y))}}).otherwise(o=>{throw Error(`Can not parse webhook operation - unknown operation: ${o}!`)})},w);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@salsita-ai/contracts",
|
|
3
|
-
"version": "0.50.0-develop.
|
|
3
|
+
"version": "0.50.0-develop.f03b563886",
|
|
4
4
|
"description": "Shared API, authentication, domain, chat, and webhook contracts for Phoenix.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"salsita",
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
"uuid": "14.0.0",
|
|
57
57
|
"valid-url": "1.0.9",
|
|
58
58
|
"zod": "3.25.76",
|
|
59
|
-
"@salsita-ai/common": "0.50.0-develop.
|
|
59
|
+
"@salsita-ai/common": "0.50.0-develop.f03b563886"
|
|
60
60
|
},
|
|
61
61
|
"devDependencies": {
|
|
62
62
|
"@lingui/core": "5.9.5",
|