lua-cli 3.39.3 → 3.39.4
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/dist/api-exports.d.ts +198 -0
- package/dist/api-exports.js +174 -8
- package/dist/api-exports.js.map +1 -1
- package/dist/index.js +132 -20
- package/dist/index.js.map +1 -1
- package/dist/workflow-builder.js +76 -0
- package/dist/workflow-builder.js.map +1 -1
- package/package.json +6 -4
- package/template/package.json +1 -1
package/dist/api-exports.d.ts
CHANGED
|
@@ -1927,6 +1927,37 @@ export declare function defineTrigger<T = any>(config: LuaTriggerConfig<T>): Lua
|
|
|
1927
1927
|
*/
|
|
1928
1928
|
export declare function defineVoice(config: LuaVoiceConfig): LuaVoice;
|
|
1929
1929
|
|
|
1930
|
+
/**
|
|
1931
|
+
* Define a web app on the agent.
|
|
1932
|
+
*
|
|
1933
|
+
* @example
|
|
1934
|
+
* ```typescript
|
|
1935
|
+
* import { defineWebApp, route, json } from 'lua-cli';
|
|
1936
|
+
* import { z } from 'zod';
|
|
1937
|
+
*
|
|
1938
|
+
* export default defineWebApp({
|
|
1939
|
+
* name: 'ops-dashboard',
|
|
1940
|
+
* description: 'Open tickets per shop',
|
|
1941
|
+
* pages: { root: './web', nav: [{ path: '/', label: 'Overview' }] },
|
|
1942
|
+
* routes: {
|
|
1943
|
+
* 'GET /tickets': route({
|
|
1944
|
+
* query: z.object({ status: z.enum(['open', 'closed']).default('open') }),
|
|
1945
|
+
* handler: async ({ query }) => ({ items: (await Data.get('tickets', { filter: { status: query.status } })).data }),
|
|
1946
|
+
* }),
|
|
1947
|
+
* 'POST /tickets/:id/close': route({
|
|
1948
|
+
* params: z.object({ id: z.string() }),
|
|
1949
|
+
* body: z.object({ note: z.string().max(500) }),
|
|
1950
|
+
* handler: async ({ params, body, auth }) => {
|
|
1951
|
+
* await Data.patch('tickets', params.id, { set: { status: 'closed', closedBy: auth.userId, note: body.note } });
|
|
1952
|
+
* return json(undefined, 204);
|
|
1953
|
+
* },
|
|
1954
|
+
* }),
|
|
1955
|
+
* },
|
|
1956
|
+
* });
|
|
1957
|
+
* ```
|
|
1958
|
+
*/
|
|
1959
|
+
export declare function defineWebApp(config: LuaWebAppConfig): LuaWebApp;
|
|
1960
|
+
|
|
1930
1961
|
export declare function defineWorkflow(cfg: LuaWorkflowConfig, build: (wf: LuaWorkflowBuilder) => LuaWorkflow): LuaWorkflow;
|
|
1931
1962
|
|
|
1932
1963
|
/**
|
|
@@ -3125,6 +3156,11 @@ declare interface JobVersion {
|
|
|
3125
3156
|
metadata?: Record<string, any>;
|
|
3126
3157
|
}
|
|
3127
3158
|
|
|
3159
|
+
/**
|
|
3160
|
+
* Build a JSON `Response`. `json(undefined, 204)` answers with no body.
|
|
3161
|
+
*/
|
|
3162
|
+
export declare function json(data: unknown, status?: number, headers?: Record<string, string>): Response;
|
|
3163
|
+
|
|
3128
3164
|
export { JsonSchema }
|
|
3129
3165
|
|
|
3130
3166
|
export { KnowledgeBindingSpec }
|
|
@@ -3394,6 +3430,9 @@ export declare interface LuaAgentConfig {
|
|
|
3394
3430
|
*/
|
|
3395
3431
|
export declare type LuaAgentModel = string | ((request: LuaRequest) => string | Promise<string>);
|
|
3396
3432
|
|
|
3433
|
+
/** The signed-in person a route runs for (never an API key, never anonymous). */
|
|
3434
|
+
export declare type LuaAuth = WebRouteAuth;
|
|
3435
|
+
|
|
3397
3436
|
/**
|
|
3398
3437
|
* LuaDevice class — represents an external device that an agent can communicate with.
|
|
3399
3438
|
*
|
|
@@ -5088,6 +5127,37 @@ export declare interface LuaVoiceTurnContext {
|
|
|
5088
5127
|
}): void;
|
|
5089
5128
|
}
|
|
5090
5129
|
|
|
5130
|
+
/**
|
|
5131
|
+
* Lua Web App — the class form of `defineWebApp` (consistent with
|
|
5132
|
+
* `LuaTrigger` / `defineTrigger`). Validates the definition eagerly so a
|
|
5133
|
+
* mistake fails at `lua compile`, not at first request.
|
|
5134
|
+
*/
|
|
5135
|
+
export declare class LuaWebApp {
|
|
5136
|
+
private readonly config;
|
|
5137
|
+
constructor(config: LuaWebAppConfig);
|
|
5138
|
+
getName(): string;
|
|
5139
|
+
getDescription(): string | undefined;
|
|
5140
|
+
getPages(): WebAppPages;
|
|
5141
|
+
getBranding(): WebAppBranding | undefined;
|
|
5142
|
+
getRoutes(): Record<string, RouteDefinition<any, any, any>>;
|
|
5143
|
+
getFetch(): LuaWebAppConfig['fetch'];
|
|
5144
|
+
getConfig(): LuaWebAppConfig;
|
|
5145
|
+
}
|
|
5146
|
+
|
|
5147
|
+
export declare interface LuaWebAppConfig {
|
|
5148
|
+
/** URL-safe name: `^[a-z][a-z0-9-]*$`. The app's identifier on the agent. */
|
|
5149
|
+
name: string;
|
|
5150
|
+
description?: string;
|
|
5151
|
+
pages: WebAppPages;
|
|
5152
|
+
branding?: WebAppBranding;
|
|
5153
|
+
/** Typed route handlers keyed by `'<METHOD> /<path>'`. */
|
|
5154
|
+
routes?: Record<string, RouteDefinition<any, any, any>>;
|
|
5155
|
+
/** Escape hatch: a Web-standard `fetch` handler (Hono, itty-router, …) for
|
|
5156
|
+
* paths no route matches. Apps that use only `fetch` forgo manifest-driven
|
|
5157
|
+
* route access and the typed client. */
|
|
5158
|
+
fetch?: (request: Request) => Promise<Response> | Response;
|
|
5159
|
+
}
|
|
5160
|
+
|
|
5091
5161
|
/**
|
|
5092
5162
|
* Lua Webhook class.
|
|
5093
5163
|
* Main class for building webhooks with validated inputs.
|
|
@@ -6468,6 +6538,46 @@ declare type ResumeStepResult = {
|
|
|
6468
6538
|
* `maxBackoffSeconds` (default 3600) only meaningful with 'exponential' (`backoff-invalid` otherwise). */
|
|
6469
6539
|
export declare type RetryPolicy = WorkflowRetryPolicy;
|
|
6470
6540
|
|
|
6541
|
+
/**
|
|
6542
|
+
* Declare a route. Identity at runtime; exists so the compiler can see the
|
|
6543
|
+
* schemas and the handler, and so `RouteContext` is inferred from them.
|
|
6544
|
+
*/
|
|
6545
|
+
export declare function route<P = Record<string, string>, Q = Record<string, string | string[]>, B = unknown>(def: RouteDefinition<P, Q, B>): RouteDefinition<P, Q, B>;
|
|
6546
|
+
|
|
6547
|
+
/** What a route handler receives. `params`, `query` and `body` are already
|
|
6548
|
+
* validated by the route's schemas when those are declared. */
|
|
6549
|
+
export declare interface RouteContext<P = Record<string, string>, Q = Record<string, string | string[]>, B = unknown> {
|
|
6550
|
+
params: P;
|
|
6551
|
+
query: Q;
|
|
6552
|
+
body: B;
|
|
6553
|
+
/** Lower-cased, allow-listed request headers. */
|
|
6554
|
+
headers: Record<string, string>;
|
|
6555
|
+
method: WebRouteMethod;
|
|
6556
|
+
path: string;
|
|
6557
|
+
/** The matched route key. */
|
|
6558
|
+
route?: string;
|
|
6559
|
+
auth: LuaAuth;
|
|
6560
|
+
app: WebRouteApp;
|
|
6561
|
+
/** The Web `Request` the gateway received, for handlers that want it. */
|
|
6562
|
+
request: Request;
|
|
6563
|
+
}
|
|
6564
|
+
|
|
6565
|
+
export declare interface RouteDefinition<P = Record<string, string>, Q = Record<string, string | string[]>, B = unknown> {
|
|
6566
|
+
description?: string;
|
|
6567
|
+
/** Zod schema for path parameters; a failure answers 400 `VALIDATION`. */
|
|
6568
|
+
params?: ZodType<P>;
|
|
6569
|
+
/** Zod schema for query parameters; a failure answers 400 `VALIDATION`. */
|
|
6570
|
+
query?: ZodType<Q>;
|
|
6571
|
+
/** Zod schema for the request body; a failure answers 400 `VALIDATION`. */
|
|
6572
|
+
body?: ZodType<B>;
|
|
6573
|
+
/** Response schemas by status, for the typed client (not enforced at runtime). */
|
|
6574
|
+
responses?: Record<number, ZodType>;
|
|
6575
|
+
handler: (ctx: RouteContext<P, Q, B>) => Promise<RouteHandlerResult> | RouteHandlerResult;
|
|
6576
|
+
}
|
|
6577
|
+
|
|
6578
|
+
/** A handler returns a Web `Response`, `undefined` (→ 204) or any JSON value (→ 200). */
|
|
6579
|
+
export declare type RouteHandlerResult = Response | undefined | unknown;
|
|
6580
|
+
|
|
6471
6581
|
export declare const rows: (s: LuaWorkflowStep<any, any, any> | string, path: string, page: {
|
|
6472
6582
|
offset: number;
|
|
6473
6583
|
limit: number;
|
|
@@ -7320,6 +7430,60 @@ export declare interface WaitForSignalOptions {
|
|
|
7320
7430
|
acceptedSources?: Array<'webhook' | 'api' | 'user' | 'agent'>;
|
|
7321
7431
|
}
|
|
7322
7432
|
|
|
7433
|
+
/**
|
|
7434
|
+
* Per-app additions to the gateway's strict Content-Security-Policy
|
|
7435
|
+
* (`defineWebApp({ pages: { csp } })`, PRD 7.10.11). This camelCase shape is
|
|
7436
|
+
* what lua-cli writes, what `webAppVersion.csp` stores and what the gateway
|
|
7437
|
+
* reads; the gateway alone maps each key to its directive (`scriptSrc` →
|
|
7438
|
+
* `script-src`, …). A key outside this list is ignored by the gateway.
|
|
7439
|
+
*/
|
|
7440
|
+
declare const WEB_APP_CSP_KEYS: readonly ["scriptSrc", "styleSrc", "imgSrc", "connectSrc", "fontSrc", "frameSrc", "workerSrc"];
|
|
7441
|
+
|
|
7442
|
+
export declare const WEB_APP_NAME_PATTERN: RegExp;
|
|
7443
|
+
|
|
7444
|
+
declare const WEB_ROUTE_METHODS: readonly ["GET", "POST", "PUT", "PATCH", "DELETE"];
|
|
7445
|
+
|
|
7446
|
+
/** `defineWebApp({ branding })`, as lua-cli writes it and the version stores it. */
|
|
7447
|
+
export declare interface WebAppBranding {
|
|
7448
|
+
/** Display name in the shells; defaults to the app name. */
|
|
7449
|
+
name?: string;
|
|
7450
|
+
/** Path to a logo inside the pages project, shipped as an asset. */
|
|
7451
|
+
logo?: string;
|
|
7452
|
+
/** Accent color (any CSS color; OKLCH preferred). */
|
|
7453
|
+
accent?: string;
|
|
7454
|
+
}
|
|
7455
|
+
|
|
7456
|
+
/** Per-app additions to the gateway's strict Content-Security-Policy (PRD 7.10.11),
|
|
7457
|
+
* in the one camelCase shape lua-cli stores and the gateway reads. */
|
|
7458
|
+
export declare type WebAppCsp = WebAppCsp_2;
|
|
7459
|
+
|
|
7460
|
+
declare type WebAppCsp_2 = Partial<Record<WebAppCspKey, string[]>>;
|
|
7461
|
+
|
|
7462
|
+
declare type WebAppCspKey = (typeof WEB_APP_CSP_KEYS)[number];
|
|
7463
|
+
|
|
7464
|
+
/** One navigation entry of a web app (`defineWebApp({ pages: { nav } })`): drives the
|
|
7465
|
+
* app's nav rail and the shells' Apps tile. Written by lua-cli, stored on the version. */
|
|
7466
|
+
export declare interface WebAppNavItem {
|
|
7467
|
+
/** Client route path inside the app, e.g. `/tickets`. */
|
|
7468
|
+
path: string;
|
|
7469
|
+
label: string;
|
|
7470
|
+
/** An icon name from the design system's curated set. */
|
|
7471
|
+
icon?: string;
|
|
7472
|
+
}
|
|
7473
|
+
|
|
7474
|
+
export declare interface WebAppPages {
|
|
7475
|
+
/** The Vite project directory, relative to the app definition (usually `./web`). */
|
|
7476
|
+
root: string;
|
|
7477
|
+
/** Serve the entry HTML for every non-asset path (client-side routing). Default true. */
|
|
7478
|
+
spa?: boolean;
|
|
7479
|
+
/** Navigation the app and the shells agree on; drives the app's nav rail and the Apps hub tile. */
|
|
7480
|
+
nav?: WebAppNavItem[];
|
|
7481
|
+
csp?: WebAppCsp;
|
|
7482
|
+
}
|
|
7483
|
+
|
|
7484
|
+
/** Route keys are `'<METHOD> /<path>'`, e.g. `'POST /tickets/:id/close'`. */
|
|
7485
|
+
export declare type WebAppRouteKey = `${WebRouteMethod} /${string}`;
|
|
7486
|
+
|
|
7323
7487
|
/**
|
|
7324
7488
|
* Webhook request information from channel integrations.
|
|
7325
7489
|
* Contains the raw webhook payload from the channel provider.
|
|
@@ -7329,6 +7493,40 @@ export declare interface WebhookRequest {
|
|
|
7329
7493
|
payload: any;
|
|
7330
7494
|
}
|
|
7331
7495
|
|
|
7496
|
+
/** The app the handler belongs to, for `ctx.app` and log correlation. */
|
|
7497
|
+
declare interface WebRouteApp {
|
|
7498
|
+
id: string;
|
|
7499
|
+
name: string;
|
|
7500
|
+
version: string;
|
|
7501
|
+
/** Monotonic deployment ordinal of the app version being executed. */
|
|
7502
|
+
deployment: number;
|
|
7503
|
+
/** The app origin, e.g. `https://ops-dashboard-7f3a.apps.heylua.ai`; the
|
|
7504
|
+
* wrapper builds the Web `Request` URL against it. */
|
|
7505
|
+
origin: string;
|
|
7506
|
+
/** True for preview/sandbox deployments (reserved; always false in the MVP). */
|
|
7507
|
+
preview: boolean;
|
|
7508
|
+
}
|
|
7509
|
+
|
|
7510
|
+
/** The caller, as the gateway resolved it. Mirrors the shells' principal:
|
|
7511
|
+
* a first-party Lua session, never an API key, never anonymous. `roles` and
|
|
7512
|
+
* `scopes` are the effective ones on the app's agent target. */
|
|
7513
|
+
declare interface WebRouteAuth {
|
|
7514
|
+
userId: string;
|
|
7515
|
+
orgId: string;
|
|
7516
|
+
agentId: string;
|
|
7517
|
+
subjectType: 'user';
|
|
7518
|
+
credentialType: 'firstPartySession';
|
|
7519
|
+
sessionId?: string;
|
|
7520
|
+
roles: string[];
|
|
7521
|
+
scopes: string[];
|
|
7522
|
+
name?: string;
|
|
7523
|
+
email?: string;
|
|
7524
|
+
/** ISO timestamp the session token expires at, when known. */
|
|
7525
|
+
expiresAt?: string;
|
|
7526
|
+
}
|
|
7527
|
+
|
|
7528
|
+
declare type WebRouteMethod = (typeof WEB_ROUTE_METHODS)[number];
|
|
7529
|
+
|
|
7332
7530
|
/** Body of POST /developer/agents/:agentId/channels/whatsapp/reaction */
|
|
7333
7531
|
export declare interface WhatsAppReactionSendInput {
|
|
7334
7532
|
to: {
|
package/dist/api-exports.js
CHANGED
|
@@ -135,6 +135,9 @@ function isInteractiveTurn(turn) {
|
|
|
135
135
|
function removeNavigateBlock(input) {
|
|
136
136
|
return input.replace(/::: navigate[\s\S]*?:::/g, "").trim();
|
|
137
137
|
}
|
|
138
|
+
function removeHiddenBlocks(input) {
|
|
139
|
+
return input.replace(/::: hide\b[\s\S]*?:::/gi, "").replace(/::: hide\b[\s\S]*$/gi, "").trim();
|
|
140
|
+
}
|
|
138
141
|
function transformChatHistoryContentParts(parts) {
|
|
139
142
|
const content = [];
|
|
140
143
|
for (const rawPart of parts ?? []) {
|
|
@@ -1990,7 +1993,44 @@ function parseOnboardingFlow(value3) {
|
|
|
1990
1993
|
function parsePublishedOnboardingResponse(value3) {
|
|
1991
1994
|
return getPublishedOnboardingResponseSchema.parse(value3);
|
|
1992
1995
|
}
|
|
1993
|
-
|
|
1996
|
+
function isForwardableWebRouteRequestHeader(name) {
|
|
1997
|
+
const n2 = name.toLowerCase();
|
|
1998
|
+
return WEB_ROUTE_REQUEST_HEADER_ALLOWLIST.includes(n2) || n2.startsWith("x-lua-");
|
|
1999
|
+
}
|
|
2000
|
+
function isForwardableWebRouteResponseHeader(name) {
|
|
2001
|
+
const n2 = name.toLowerCase();
|
|
2002
|
+
if (n2 === "set-cookie") return false;
|
|
2003
|
+
return WEB_ROUTE_RESPONSE_HEADER_ALLOWLIST.includes(n2) || n2.startsWith("x-lua-");
|
|
2004
|
+
}
|
|
2005
|
+
function isWebRouteBody(value3) {
|
|
2006
|
+
if (!value3 || typeof value3 !== "object") return false;
|
|
2007
|
+
const b = value3;
|
|
2008
|
+
if (b.kind === "json") return "value" in b;
|
|
2009
|
+
if (b.kind === "text" || b.kind === "base64") return typeof b.value === "string";
|
|
2010
|
+
return false;
|
|
2011
|
+
}
|
|
2012
|
+
function isWebRouteInput(value3) {
|
|
2013
|
+
if (!value3 || typeof value3 !== "object") return false;
|
|
2014
|
+
const v = value3;
|
|
2015
|
+
if (v.v !== WEB_ROUTE_PROTOCOL_VERSION) return false;
|
|
2016
|
+
const r = v.request;
|
|
2017
|
+
if (!r || typeof r !== "object") return false;
|
|
2018
|
+
if (!WEB_ROUTE_METHODS.includes(String(r.method))) return false;
|
|
2019
|
+
if (typeof r.path !== "string" || !r.path.startsWith("/")) return false;
|
|
2020
|
+
if (!r.params || typeof r.params !== "object") return false;
|
|
2021
|
+
if (!r.query || typeof r.query !== "object") return false;
|
|
2022
|
+
if (!r.headers || typeof r.headers !== "object") return false;
|
|
2023
|
+
if (r.body !== void 0) {
|
|
2024
|
+
if (r.method === "GET") return false;
|
|
2025
|
+
if (!isWebRouteBody(r.body)) return false;
|
|
2026
|
+
}
|
|
2027
|
+
const a = v.auth;
|
|
2028
|
+
if (!a || typeof a.userId !== "string" || typeof a.orgId !== "string" || typeof a.agentId !== "string") return false;
|
|
2029
|
+
const app = v.app;
|
|
2030
|
+
if (!app || typeof app.id !== "string" || typeof app.name !== "string" || typeof app.origin !== "string") return false;
|
|
2031
|
+
return true;
|
|
2032
|
+
}
|
|
2033
|
+
var __defProp2, __name2, PLUMBING_THREAD_CHANNELS, CHANNEL_CONVERSATION_CHANNELS, HIDDEN_THREAD_CHANNELS, CHANNEL_SEND_CHANNELS, REVIEWABLE_ACTION_EXECUTE_TOOL_ALLOWLIST, REVIEWABLE_STANDING_START_TOOLS, REVIEWABLE_MCP_SEND_TOOL_SUFFIX, MCP_TOOL_READ_VERB_RE, MCP_DRAFT_CREATE_VERBS, NON_INTERACTIVE_CHANNELS, RICH_PARTS_MESSAGE_ID_PREFIX, SCREENSHOT_MESSAGE_ID_PREFIX, BROWSER_COMMANDS, BROWSER_COMMAND_NAMES, LOG_FIELDS_MAX_KEYS, LOG_FIELD_MAX_VALUE_BYTES, LOG_FIELDS_MAX_BYTES, LOG_FIELD_KEY_PATTERN, LOG_FIELD_SECRET_SHAPED_KEY_PATTERNS, LOG_FIELDS_CLAMPED_KEY, LOG_FIELD_ARRAY_COUNT_SUFFIX, LuaLogFieldsError, DESKTOP_FILE_COMMANDS, DESKTOP_FILE_COMMAND_SET, WORKFLOW_RETRY_BACKOFFS, WORKFLOW_RETRY_MIN_ATTEMPTS, WORKFLOW_RETRY_POLICY_KEYS, WORKFLOW_RETRY_MAX_ATTEMPTS, WORKFLOW_RETRY_ENGINE_KEYS, WORKFLOW_JOB_RESOURCES, WORKFLOW_SIDE_EFFECTS, WORKFLOW_MODEL_CLASSES, WORKFLOW_DEFAULT_TASK_CLASS_MAP, WORKFLOW_MODELS_MAX_CLASS_DEFAULT, WORKFLOW_AUTONOMY_NUMERIC_KEYS, WORKFLOW_AUTONOMY_ENVELOPE_KEYS, WORKFLOW_AUTONOMY_DEFAULTS, WORKFLOW_AUTONOMY_CEILINGS, WORKFLOW_AUTONOMY_MAX_RUNS_PER_HOUR_ENV, WORKFLOW_AUTONOMY_MAX_RUNS_PER_HOUR_CEILING, WORKFLOW_AUTONOMY_FORMS_DEFAULT, WORKFLOW_AUTONOMY_MIN_VALUE, WORKFLOW_JOB_RANGES, WORKFLOW_JOB_RANGE_MEMBERS, WORKFLOW_SINGLE_STEP_TYPES, WORKFLOW_HITL_ENTRY_TYPES, WORKFLOW_ARM_ENTRY_TYPES, WORKFLOW_HITL_ARM_CONTAINERS, WORKFLOW_GRAPH_ENTRY_STEP_KINDS, WORKFLOW_ARM_ENTRY_STEP_KINDS, WORKFLOW_BUDGET_MAX_DURATION_SECONDS, MODEL_ID_BYOK_PROVIDERS, MODEL_CLASS_REF_PREFIX, MODEL_SNAPSHOT_SUFFIX, REASONING_EFFORT_VALUES, IMPLICIT_MODEL_SELECTION_SOURCES, PLATFORM_FALLBACK_MODEL_SOURCE, AGENT_NAME_TOKEN, DEFAULT_PERSONA_GUIDE, PERSONAL_SPACE_STARTING_PERSONA, AGENT_LOG_SOURCES, AGENT_LOG_FIELDS_MAX_WIRE_KEYS, LOG_DRAIN_TYPES_PHASE1, LOG_DRAIN_TYPES_PHASE2, LOG_DRAIN_TYPES_IMPLEMENTED, LOG_DRAIN_SOURCES, LOG_DRAIN_MAX_PER_ORG, LOG_DRAIN_MAX_PER_ORG_ENTERPRISE, LOG_DRAIN_DATADOG_SITES, LOG_DRAIN_NEWRELIC_SITES, LOG_DRAIN_ENDPOINT_TEMPLATES, LOG_DRAIN_PRESET_SITES, LOG_DRAIN_BUCKET_NAME_PATTERN, LOG_DRAIN_BUCKET_HOST_PATTERNS, LOG_DRAIN_PRESET_HOST_SUFFIXES, DRAIN_CONTENT_ACK_ERROR_CODE, DRAIN_CONTENT_ACK_FIELD, DrainContentAckRequiredError, LOG_DRAIN_PRESET_PATHS, PRESET_SEGMENT_RE, LOG_DRAIN_QUOTAS, LOG_DRAIN_QUOTA_WARN_RATIO, LOG_DRAIN_QUOTA_DROP_DEBUG_RATIO, LOG_DRAIN_QUOTA_DROP_INFO_RATIO, LOG_DRAIN_QUOTA_PAUSE_RATIO, LOG_EXPORT_SOURCES, LOG_EXPORT_MAX_WINDOW_DAYS, LOG_EXPORT_MAX_WINDOW_MS, LOG_EXPORT_URL_TTL_SECONDS, LOG_EXPORT_FILE_RETENTION_DAYS, LOG_EXPORT_FILE_RETENTION_MS, LOG_EXPORT_PART_MAX_BYTES, LOG_DRAIN_NOTICE_RATE_LIMIT_MS, LOG_DRAIN_VERIFICATION_STALE_MS, LOG_DRAIN_DIGEST_INTERVAL_MS, LOG_DRAIN_DIGEST_MAX_ENTRIES, LOG_DRAIN_NOTICE_ERROR_MAX_CHARS, LOG_DRAIN_USAGE_LINE_ITEM, LOG_DRAIN_BYTES_PER_GIB, DEFAULT_LOG_DRAIN_PLAN_CONFIG, TIERS, LOG_CURSOR_MAX_LENGTH, LOG_CURSOR_MAX_ID_LENGTH, LOG_RELATIVE_TIME_PATTERN, LOG_ISO_TIME_PATTERN, RELATIVE_UNIT_MS, CORE_DRAINING_CODE, CORE_DRAINING_DEFAULT_RETRY_MS, CORE_DRAINING_MAX_RETRY_MS, VoiceNameSchema, PluginProviderSchema, RealtimeProviderSchema, PluginClassSchema, ModelDescriptorSchema, InferenceModelSchema, PluginModelSchema, RealtimeModelSchema, LuaVoiceModelSchema, TurnDetectionSchema, InterruptionSchema, BuiltinAudioClipSchema, AudioConfigSchema, BackgroundAudioEntrySchema, BackgroundAudioSchema, LuaVoiceConfigInnerSchema, LuaVoiceConfigSchema, LuaVoiceRefSchema, LUA_JOB_DEFAULT_TIMEOUT_SECONDS, LUA_JOB_MIN_TIMEOUT_SECONDS, LUA_JOB_MAX_TIMEOUT_SECONDS, KEYS, MAX_BODY_BYTES, MAX_ID_LENGTH, UTC_ISO, TEMPLATE_TRIGGER_URL_ENV_PREFIX, TEMPLATE_INSTALL_POLICY_PER_WORKSPACE_VALUES, SUBJECT_TYPES, SubjectTypeSchema, CREDENTIAL_TYPES, CredentialTypeSchema, DEVICE_OPERATIONS, DeviceOperationSchema, DEVICE_SCOPE_BY_OPERATION, DeviceBindingSchema, IdSchema, SESSION_AUTH_TIME_MAX_S, PrincipalDescriptorSchema, ActorDescriptorSchema, PrincipalOwnerSchema, CredentialLifecycleSchema, GeneralCredentialDescriptorSchema, DeviceCredentialDescriptorSchema, GeneralPrincipalContextSchema, DeviceCredentialPrincipalContextSchema, RawPrincipalContextSchema, PrincipalContextSchema, DeviceCredentialClaimSchema, LUA_CLIENT_HEADER, LUA_CLIENT_APPS, SEMVER_PATTERN, WEB_RELEASE_PATTERN, CLIENT_HEADER_PATTERN, LUA_SESSION_ID_CLAIM, SESSION_REVOKED_CODE, AUTHZ_PROJECTION_VERSION, ProjectedScopeSchema, DisplayRoleSchema, AuthorizationPrincipalSchema, CredentialContextSchema, ProjectionAnomalySchema, ProjectedOrgSchema, ProjectedResourceSchema, CapabilityProfilesSchema, RoleCatalogSchema, EffectiveAuthorizationSchema, ResourcePageSchema, SYSTEM_USER_PREFIX, WORKFLOW_RUN_IN_FLIGHT, WORKFLOW_RUN_IDLE, WORKFLOW_RUN_TERMINAL, WORKFLOW_RUN_STATUSES, WORKFLOW_RUN_GATE_KINDS, WORKFLOW_STEP_STATUSES, WORKFLOW_STEP_IN_FLIGHT, WORKFLOW_SIGNAL_EVENT_SITES, ARCHIVE_WINDOW_MARGIN_DAYS, WORKFLOW_ORG_PURGING_TTL_S, WORKFLOW_ORG_PURGE_FORCE_AFTER_MS, IDEMPOTENCY_HOLDING_STATUSES, WORKFLOW_SCHEDULED_RUN_ID_PREFIX, CLOUD_TASK_RUN_ID_PREFIX, WORKFLOW_SCHEDULE_KEY_MAX, WORKFLOW_SCHEDULE_IDEMPOTENCY_KEY_PREFIX, WORKFLOW_OPERATION_ID_PREFIX, WORKFLOW_CONNECTION_KEY_RE, WORKFLOW_JOB_MODEL_SOURCE_LABELS, WORKFLOW_SUSPEND_KINDS, WORKFLOW_RUN_NOTIFICATION_SUSPENDED_KINDS, WORKFLOW_SIGNAL_PAYLOAD_MAX_BYTES, WORKFLOW_RESOLVE_OUTPUT_MAX_BYTES, WORKFLOW_GOAL_JUDGE_SELF, REDACTED_PLACEHOLDER, PROVIDER_MESSAGE_MAX_CHARS, ERROR_MESSAGE_MAX_CHARS, SECRET_LITERAL_PATTERNS, SECRET_NAME, SECRET_PAIR_PATTERNS, GROUP_COUNT, WORKFLOW_SECRET_KEY_RE, WORKFLOW_RESERVED_SECRET_KEYS, SCRUB_INPUT_MAX_CHARS, SCRUB_CUT_BACKOFF_CHARS, WORKFLOW_AUDIT_EVENTS, WORKFLOW_AUDIT_METADATA_MAX_BYTES, INDENT, WRAP_WIDTH, NOUNS, GET_TOOL_NAMES, PREAMBLE, WORKFLOW_APPROVAL_OUTPUT_DECISIONS, WORKFLOW_APPROVAL_OUTPUT_SCHEMA, JSON_FENCE_RE, DEFAULT_ON_AGENT_FEATURES, SUBAGENT_PER_KEY_FLAG_ENV, PER_KEY_FLAG_VALUES, ONBOARDING_FLOW_KEY, ONBOARDING_SCHEMA_VERSION, id, copy, onboardingHeadingSchema, onboardingRichTextInlineSchema, onboardingRichTextSchema, onboardingDestinationSchema, onboardingArtworkSchema, onboardingAnswerSchema, onboardingQuestionSchema, onboardingTemplateSectionSchema, onboardingTemplateContentSchema, onboardingUnavailableOutcomeSchema, onboardingFlowSchema, onboardingActorSchema, onboardingEditorSchema, onboardingPublicationSummarySchema, onboardingValidationIssueSchema, onboardingValidationResponseSchema, onboardingAssetSchema, onboardingPublicAssetSchema, getOnboardingConfigResponseSchema, saveOnboardingDraftRequestSchema, validateOnboardingRequestSchema, publishOnboardingRequestSchema, rollbackOnboardingRequestSchema, onboardingTemplateCatalogItemSchema, getPublishedOnboardingResponseSchema, WEB_ROUTE_PROTOCOL_VERSION, WEB_ROUTE_METHODS, WEB_ROUTE_REQUEST_HEADER_ALLOWLIST, WEB_ROUTE_RESPONSE_HEADER_ALLOWLIST, WEB_ROUTE_MAX_REQUEST_BODY_BYTES, WEB_ROUTE_MAX_RESPONSE_BYTES;
|
|
1994
2034
|
var init_dist = __esm({
|
|
1995
2035
|
"../shared-types/dist/index.mjs"() {
|
|
1996
2036
|
"use strict";
|
|
@@ -2099,6 +2139,8 @@ var init_dist = __esm({
|
|
|
2099
2139
|
__name2(isInteractiveTurn, "isInteractiveTurn");
|
|
2100
2140
|
__name(removeNavigateBlock, "removeNavigateBlock");
|
|
2101
2141
|
__name2(removeNavigateBlock, "removeNavigateBlock");
|
|
2142
|
+
__name(removeHiddenBlocks, "removeHiddenBlocks");
|
|
2143
|
+
__name2(removeHiddenBlocks, "removeHiddenBlocks");
|
|
2102
2144
|
__name(transformChatHistoryContentParts, "transformChatHistoryContentParts");
|
|
2103
2145
|
__name2(transformChatHistoryContentParts, "transformChatHistoryContentParts");
|
|
2104
2146
|
RICH_PARTS_MESSAGE_ID_PREFIX = "rich-parts:";
|
|
@@ -2690,6 +2732,7 @@ This text is who you are for this person. As you learn them, their name, their w
|
|
|
2690
2732
|
"skill",
|
|
2691
2733
|
"job",
|
|
2692
2734
|
"webhook",
|
|
2735
|
+
"web-route",
|
|
2693
2736
|
"trigger",
|
|
2694
2737
|
"preprocessor",
|
|
2695
2738
|
"postprocessor",
|
|
@@ -4381,6 +4424,39 @@ listed here; never invent a target.`;
|
|
|
4381
4424
|
__name2(parseOnboardingFlow, "parseOnboardingFlow");
|
|
4382
4425
|
__name(parsePublishedOnboardingResponse, "parsePublishedOnboardingResponse");
|
|
4383
4426
|
__name2(parsePublishedOnboardingResponse, "parsePublishedOnboardingResponse");
|
|
4427
|
+
WEB_ROUTE_PROTOCOL_VERSION = 1;
|
|
4428
|
+
WEB_ROUTE_METHODS = [
|
|
4429
|
+
"GET",
|
|
4430
|
+
"POST",
|
|
4431
|
+
"PUT",
|
|
4432
|
+
"PATCH",
|
|
4433
|
+
"DELETE"
|
|
4434
|
+
];
|
|
4435
|
+
WEB_ROUTE_REQUEST_HEADER_ALLOWLIST = [
|
|
4436
|
+
"accept",
|
|
4437
|
+
"accept-language",
|
|
4438
|
+
"content-type",
|
|
4439
|
+
"if-none-match",
|
|
4440
|
+
"idempotency-key"
|
|
4441
|
+
];
|
|
4442
|
+
WEB_ROUTE_RESPONSE_HEADER_ALLOWLIST = [
|
|
4443
|
+
"content-type",
|
|
4444
|
+
"cache-control",
|
|
4445
|
+
"etag",
|
|
4446
|
+
"location",
|
|
4447
|
+
"content-disposition",
|
|
4448
|
+
"content-language"
|
|
4449
|
+
];
|
|
4450
|
+
__name(isForwardableWebRouteRequestHeader, "isForwardableWebRouteRequestHeader");
|
|
4451
|
+
__name2(isForwardableWebRouteRequestHeader, "isForwardableWebRouteRequestHeader");
|
|
4452
|
+
__name(isForwardableWebRouteResponseHeader, "isForwardableWebRouteResponseHeader");
|
|
4453
|
+
__name2(isForwardableWebRouteResponseHeader, "isForwardableWebRouteResponseHeader");
|
|
4454
|
+
WEB_ROUTE_MAX_REQUEST_BODY_BYTES = 1 * 1024 * 1024;
|
|
4455
|
+
WEB_ROUTE_MAX_RESPONSE_BYTES = 4 * 1024 * 1024;
|
|
4456
|
+
__name(isWebRouteBody, "isWebRouteBody");
|
|
4457
|
+
__name2(isWebRouteBody, "isWebRouteBody");
|
|
4458
|
+
__name(isWebRouteInput, "isWebRouteInput");
|
|
4459
|
+
__name2(isWebRouteInput, "isWebRouteInput");
|
|
4384
4460
|
}
|
|
4385
4461
|
});
|
|
4386
4462
|
|
|
@@ -9853,8 +9929,8 @@ function uidFromFirebaseIdToken(idToken) {
|
|
|
9853
9929
|
if (parsed.success) return parsed.data.sub;
|
|
9854
9930
|
throw new Error(INVALID_FIREBASE_SESSION);
|
|
9855
9931
|
}
|
|
9856
|
-
function parseFirebaseSession(
|
|
9857
|
-
const customTokenResponse = customTokenResponseSchema.safeParse(
|
|
9932
|
+
function parseFirebaseSession(json2, now = Date.now()) {
|
|
9933
|
+
const customTokenResponse = customTokenResponseSchema.safeParse(json2);
|
|
9858
9934
|
if (customTokenResponse.success) {
|
|
9859
9935
|
const { idToken: idToken2, refreshToken: refreshToken2, expiresIn: expiresIn2, localId } = customTokenResponse.data;
|
|
9860
9936
|
return {
|
|
@@ -9864,7 +9940,7 @@ function parseFirebaseSession(json, now = Date.now()) {
|
|
|
9864
9940
|
uid: localId ?? uidFromFirebaseIdToken(idToken2)
|
|
9865
9941
|
};
|
|
9866
9942
|
}
|
|
9867
|
-
const refreshResponse = refreshResponseSchema.safeParse(
|
|
9943
|
+
const refreshResponse = refreshResponseSchema.safeParse(json2);
|
|
9868
9944
|
if (!refreshResponse.success) throw new Error(INVALID_FIREBASE_SESSION);
|
|
9869
9945
|
const { id_token: idToken, refresh_token: refreshToken, expires_in: expiresIn, user_id: uid } = refreshResponse.data;
|
|
9870
9946
|
return {
|
|
@@ -11346,8 +11422,8 @@ function buildSourceArchive(files) {
|
|
|
11346
11422
|
map[entryFile] = source;
|
|
11347
11423
|
}
|
|
11348
11424
|
if (Object.keys(map).length === 0) return null;
|
|
11349
|
-
const
|
|
11350
|
-
const gz = zlib.gzipSync(Buffer.from(
|
|
11425
|
+
const json2 = JSON.stringify(map);
|
|
11426
|
+
const gz = zlib.gzipSync(Buffer.from(json2, "utf-8"));
|
|
11351
11427
|
return gz.toString("base64");
|
|
11352
11428
|
}
|
|
11353
11429
|
function getPrimitivesByKind(manifest, kind) {
|
|
@@ -16270,8 +16346,8 @@ var init_workflow_api_service = __esm({
|
|
|
16270
16346
|
}
|
|
16271
16347
|
}, "assertBoundAgent");
|
|
16272
16348
|
pathId = /* @__PURE__ */ __name((id2) => encodeURIComponent(id2), "pathId");
|
|
16273
|
-
unavailable = /* @__PURE__ */ __name((member,
|
|
16274
|
-
throw new WorkflowApiError("WORKFLOWS_API_UNAVAILABLE", `Workflows.${member} is not available in this runtime yet (${
|
|
16349
|
+
unavailable = /* @__PURE__ */ __name((member, route2) => async () => {
|
|
16350
|
+
throw new WorkflowApiError("WORKFLOWS_API_UNAVAILABLE", `Workflows.${member} is not available in this runtime yet (${route2} lands with a later wave)`, 501);
|
|
16275
16351
|
}, "unavailable");
|
|
16276
16352
|
__name(createWorkflowsRuntime, "createWorkflowsRuntime");
|
|
16277
16353
|
WorkflowApi = class extends HttpClient {
|
|
@@ -17727,6 +17803,91 @@ function defineVoice(config) {
|
|
|
17727
17803
|
}
|
|
17728
17804
|
__name(defineVoice, "defineVoice");
|
|
17729
17805
|
|
|
17806
|
+
// src/types/web-app.ts
|
|
17807
|
+
init_dist();
|
|
17808
|
+
var WEB_APP_NAME_PATTERN = /^[a-z][a-z0-9-]*$/;
|
|
17809
|
+
var ROUTE_KEY_PATTERN = new RegExp(`^(${WEB_ROUTE_METHODS.join("|")}) /\\S*$`);
|
|
17810
|
+
function route(def) {
|
|
17811
|
+
if (typeof def.handler !== "function") {
|
|
17812
|
+
throw new Error("route() requires a `handler` function.");
|
|
17813
|
+
}
|
|
17814
|
+
return def;
|
|
17815
|
+
}
|
|
17816
|
+
__name(route, "route");
|
|
17817
|
+
function json(data, status = 200, headers = {}) {
|
|
17818
|
+
const hasBody = data !== void 0 && status !== 204 && status !== 304;
|
|
17819
|
+
return new Response(hasBody ? JSON.stringify(data) : null, {
|
|
17820
|
+
status,
|
|
17821
|
+
headers: hasBody ? {
|
|
17822
|
+
"content-type": "application/json",
|
|
17823
|
+
...headers
|
|
17824
|
+
} : headers
|
|
17825
|
+
});
|
|
17826
|
+
}
|
|
17827
|
+
__name(json, "json");
|
|
17828
|
+
var LuaWebApp = class {
|
|
17829
|
+
static {
|
|
17830
|
+
__name(this, "LuaWebApp");
|
|
17831
|
+
}
|
|
17832
|
+
config;
|
|
17833
|
+
constructor(config) {
|
|
17834
|
+
if (!config || typeof config !== "object") {
|
|
17835
|
+
throw new Error("defineWebApp requires a configuration object.");
|
|
17836
|
+
}
|
|
17837
|
+
if (typeof config.name !== "string" || !WEB_APP_NAME_PATTERN.test(config.name)) {
|
|
17838
|
+
throw new Error(`defineWebApp: \`name\` must match ${WEB_APP_NAME_PATTERN} (lower-case letters, digits and dashes, starting with a letter); got ${JSON.stringify(config.name)}.`);
|
|
17839
|
+
}
|
|
17840
|
+
if (!config.pages || typeof config.pages.root !== "string" || !config.pages.root.trim()) {
|
|
17841
|
+
throw new Error(`defineWebApp(${config.name}): \`pages.root\` (the Vite project directory) is required.`);
|
|
17842
|
+
}
|
|
17843
|
+
const hasRoutes = !!config.routes && Object.keys(config.routes).length > 0;
|
|
17844
|
+
const hasFetch = typeof config.fetch === "function";
|
|
17845
|
+
if (!hasRoutes && !hasFetch) {
|
|
17846
|
+
throw new Error(`defineWebApp(${config.name}): declare at least one entry in \`routes\` or a \`fetch\` handler.`);
|
|
17847
|
+
}
|
|
17848
|
+
for (const key of Object.keys(config.routes ?? {})) {
|
|
17849
|
+
if (!ROUTE_KEY_PATTERN.test(key)) {
|
|
17850
|
+
throw new Error(`defineWebApp(${config.name}): route key ${JSON.stringify(key)} must look like 'GET /path' (${WEB_ROUTE_METHODS.join(", ")}, one space, a path starting with /).`);
|
|
17851
|
+
}
|
|
17852
|
+
const def = config.routes[key];
|
|
17853
|
+
if (!def || typeof def.handler !== "function") {
|
|
17854
|
+
throw new Error(`defineWebApp(${config.name}): route ${JSON.stringify(key)} has no \`handler\` function.`);
|
|
17855
|
+
}
|
|
17856
|
+
}
|
|
17857
|
+
for (const item of config.pages.nav ?? []) {
|
|
17858
|
+
if (typeof item?.path !== "string" || !item.path.startsWith("/") || typeof item?.label !== "string") {
|
|
17859
|
+
throw new Error(`defineWebApp(${config.name}): every \`pages.nav\` item needs a \`path\` starting with / and a \`label\`.`);
|
|
17860
|
+
}
|
|
17861
|
+
}
|
|
17862
|
+
this.config = config;
|
|
17863
|
+
}
|
|
17864
|
+
getName() {
|
|
17865
|
+
return this.config.name;
|
|
17866
|
+
}
|
|
17867
|
+
getDescription() {
|
|
17868
|
+
return this.config.description;
|
|
17869
|
+
}
|
|
17870
|
+
getPages() {
|
|
17871
|
+
return this.config.pages;
|
|
17872
|
+
}
|
|
17873
|
+
getBranding() {
|
|
17874
|
+
return this.config.branding;
|
|
17875
|
+
}
|
|
17876
|
+
getRoutes() {
|
|
17877
|
+
return this.config.routes ?? {};
|
|
17878
|
+
}
|
|
17879
|
+
getFetch() {
|
|
17880
|
+
return this.config.fetch;
|
|
17881
|
+
}
|
|
17882
|
+
getConfig() {
|
|
17883
|
+
return this.config;
|
|
17884
|
+
}
|
|
17885
|
+
};
|
|
17886
|
+
function defineWebApp(config) {
|
|
17887
|
+
return new LuaWebApp(config);
|
|
17888
|
+
}
|
|
17889
|
+
__name(defineWebApp, "defineWebApp");
|
|
17890
|
+
|
|
17730
17891
|
// src/api-exports.ts
|
|
17731
17892
|
init_workflow();
|
|
17732
17893
|
init_dist();
|
|
@@ -18500,6 +18661,7 @@ export {
|
|
|
18500
18661
|
LuaTrigger,
|
|
18501
18662
|
LuaVoice,
|
|
18502
18663
|
LuaVoiceTool,
|
|
18664
|
+
LuaWebApp,
|
|
18503
18665
|
LuaWebhook,
|
|
18504
18666
|
LuaWorkflow,
|
|
18505
18667
|
LuaWorkflowBuildError,
|
|
@@ -18516,6 +18678,7 @@ export {
|
|
|
18516
18678
|
User,
|
|
18517
18679
|
UserDataInstance,
|
|
18518
18680
|
Voice,
|
|
18681
|
+
WEB_APP_NAME_PATTERN,
|
|
18519
18682
|
Workflows,
|
|
18520
18683
|
and2 as and,
|
|
18521
18684
|
createStep,
|
|
@@ -18524,6 +18687,7 @@ export {
|
|
|
18524
18687
|
defineDeviceTrigger,
|
|
18525
18688
|
defineTrigger,
|
|
18526
18689
|
defineVoice,
|
|
18690
|
+
defineWebApp,
|
|
18527
18691
|
defineWorkflow,
|
|
18528
18692
|
env,
|
|
18529
18693
|
eq2 as eq,
|
|
@@ -18537,6 +18701,7 @@ export {
|
|
|
18537
18701
|
gte2 as gte,
|
|
18538
18702
|
inSet2 as inSet,
|
|
18539
18703
|
init2 as init,
|
|
18704
|
+
json,
|
|
18540
18705
|
lit2 as lit,
|
|
18541
18706
|
log,
|
|
18542
18707
|
lt2 as lt,
|
|
@@ -18546,6 +18711,7 @@ export {
|
|
|
18546
18711
|
notExists2 as notExists,
|
|
18547
18712
|
notIn2 as notIn,
|
|
18548
18713
|
or2 as or,
|
|
18714
|
+
route,
|
|
18549
18715
|
rows2 as rows,
|
|
18550
18716
|
state2 as state,
|
|
18551
18717
|
step2 as step,
|