@lunnoa/client 2.1.0 → 2.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -2
- package/dist/cli.js +201 -3
- package/dist/index.cjs +93 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +206 -5
- package/dist/index.d.ts +206 -5
- package/dist/index.js +90 -2
- package/dist/index.js.map +1 -1
- package/dist/react.cjs +67 -2
- package/dist/react.cjs.map +1 -1
- package/dist/react.d.cts +164 -4
- package/dist/react.d.ts +164 -4
- package/dist/react.js +67 -2
- package/dist/react.js.map +1 -1
- package/package.json +1 -1
- package/skills/lunnoa-client/SKILL.md +61 -7
- package/skills/lunnoa-solution-design/SKILL.md +26 -8
package/README.md
CHANGED
|
@@ -264,7 +264,7 @@ npx @lunnoa/client agents deploy ./agents/triage.ts \
|
|
|
264
264
|
--url https://lunnoa.example --api-key lna_...
|
|
265
265
|
```
|
|
266
266
|
|
|
267
|
-
`defineAction` binds catalogue actions only; toolkit `createAction` is for in-platform apps. See Lunnoa Docs under `guides/develop/client/define`, `runs`, and `cli-deploy`.
|
|
267
|
+
`defineAction` binds catalogue actions only; toolkit `createAction` is for in-platform apps. `defineWorkflow` takes an optional `defineTrigger`. Omit it for Manually Run with no input fields. `runs.start` ignores the trigger and runs the steps only. See Lunnoa Docs under `guides/develop/client/define`, `runs`, and `cli-deploy`.
|
|
268
268
|
|
|
269
269
|
### CLI discovery
|
|
270
270
|
|
|
@@ -277,13 +277,14 @@ npx @lunnoa/client tools get http_action_send-request --json
|
|
|
277
277
|
npx @lunnoa/client apps list --json
|
|
278
278
|
npx @lunnoa/client apps get http --json
|
|
279
279
|
npx @lunnoa/client connections list --app gmail --json
|
|
280
|
+
npx @lunnoa/client ai-connections list --json
|
|
280
281
|
npx @lunnoa/client agents list --json
|
|
281
282
|
npx @lunnoa/client workflows list --json
|
|
282
283
|
npx @lunnoa/client entity-types list --json
|
|
283
284
|
npx @lunnoa/client features --json
|
|
284
285
|
```
|
|
285
286
|
|
|
286
|
-
`tools list` is compact (`appId`, `actionId`, name, flags). `tools get` prints `inputConfig` and a `defineAction({ id, appId, input })` sketch. Auth flags and `LUNNOA_URL` / `LUNNOA_API_KEY` / `lunnoa.config` work the same as deploy. The CLI also reads `./.env` (real environment variables win).
|
|
287
|
+
`tools list` is compact (`appId`, `actionId`, name, flags). `tools get` prints `inputConfig` and a `defineAction({ id, appId, input })` sketch. `apps get --json` includes each trigger and a `defineTrigger` sketch. Use `triggers[].triggerId`. Do not invent trigger ids. `ai-connections list --json` prints the model ids each AI connection accepts; use `models[].id` as `defineAgent({ model })`. Auth flags and `LUNNOA_URL` / `LUNNOA_API_KEY` / `lunnoa.config` work the same as deploy. The CLI also reads `./.env` (real environment variables win).
|
|
287
288
|
|
|
288
289
|
## Regenerating the API types
|
|
289
290
|
|
package/dist/cli.js
CHANGED
|
@@ -472,7 +472,7 @@ var AgentChatClient = class {
|
|
|
472
472
|
function messageTaskBody(message, options = {}) {
|
|
473
473
|
return {
|
|
474
474
|
messages: [message],
|
|
475
|
-
|
|
475
|
+
chatMode: options.chatMode ?? "preview",
|
|
476
476
|
...options.data ? { data: options.data } : {},
|
|
477
477
|
...options.piiResolution ? { piiResolution: options.piiResolution } : {}
|
|
478
478
|
};
|
|
@@ -541,6 +541,7 @@ var DEFINE_KINDS = {
|
|
|
541
541
|
connection: "connection",
|
|
542
542
|
aiConnection: "aiConnection",
|
|
543
543
|
action: "action",
|
|
544
|
+
trigger: "trigger",
|
|
544
545
|
workflow: "workflow",
|
|
545
546
|
agent: "agent",
|
|
546
547
|
entityType: "entityType"
|
|
@@ -563,6 +564,40 @@ function resolveActionAppId(action) {
|
|
|
563
564
|
`Cannot infer appId for action "${id}". Pass appId explicitly.`
|
|
564
565
|
);
|
|
565
566
|
}
|
|
567
|
+
function resolveTriggerAppId(trigger) {
|
|
568
|
+
if (trigger.appId?.trim()) {
|
|
569
|
+
return trigger.appId.trim();
|
|
570
|
+
}
|
|
571
|
+
const id = trigger.id.trim();
|
|
572
|
+
const marker = "_trigger_";
|
|
573
|
+
const markerIndex = id.indexOf(marker);
|
|
574
|
+
if (markerIndex > 0) {
|
|
575
|
+
return id.slice(0, markerIndex);
|
|
576
|
+
}
|
|
577
|
+
const dot = id.indexOf(".");
|
|
578
|
+
if (dot > 0) {
|
|
579
|
+
return id.slice(0, dot);
|
|
580
|
+
}
|
|
581
|
+
throw new Error(
|
|
582
|
+
`Cannot infer appId for trigger "${id}". Pass appId explicitly.`
|
|
583
|
+
);
|
|
584
|
+
}
|
|
585
|
+
function resolveTriggerId(trigger) {
|
|
586
|
+
const id = trigger.id.trim();
|
|
587
|
+
const appId = trigger.appId?.trim();
|
|
588
|
+
if (appId && id.startsWith(`${appId}.`)) {
|
|
589
|
+
return id.slice(appId.length + 1);
|
|
590
|
+
}
|
|
591
|
+
const marker = "_trigger_";
|
|
592
|
+
if (id.includes(marker)) {
|
|
593
|
+
return id;
|
|
594
|
+
}
|
|
595
|
+
const dot = id.indexOf(".");
|
|
596
|
+
if (dot > 0) {
|
|
597
|
+
return id.slice(dot + 1);
|
|
598
|
+
}
|
|
599
|
+
return id;
|
|
600
|
+
}
|
|
566
601
|
function resolveActionId(action) {
|
|
567
602
|
const id = action.id.trim();
|
|
568
603
|
const appId = action.appId?.trim();
|
|
@@ -852,6 +887,22 @@ var SsoAuthResource = class {
|
|
|
852
887
|
}
|
|
853
888
|
};
|
|
854
889
|
|
|
890
|
+
// src/resources/ai-connections.ts
|
|
891
|
+
var AiConnectionsResource = class {
|
|
892
|
+
constructor(http) {
|
|
893
|
+
this.http = http;
|
|
894
|
+
}
|
|
895
|
+
http;
|
|
896
|
+
/**
|
|
897
|
+
* Lists AI connections the caller can assign to an agent, with the model
|
|
898
|
+
* ids each connection accepts. Credentials are never included.
|
|
899
|
+
* Requires `agents:create` (the same permission as agent deploy).
|
|
900
|
+
*/
|
|
901
|
+
list() {
|
|
902
|
+
return this.http.get("/api/ai-connections");
|
|
903
|
+
}
|
|
904
|
+
};
|
|
905
|
+
|
|
855
906
|
// src/resources/connections.ts
|
|
856
907
|
var ConnectionsResource = class {
|
|
857
908
|
constructor(http) {
|
|
@@ -1961,6 +2012,17 @@ var WorkflowAppsResource = class {
|
|
|
1961
2012
|
};
|
|
1962
2013
|
|
|
1963
2014
|
// src/resources/workflows.ts
|
|
2015
|
+
function triggerToUpsertInput(trigger) {
|
|
2016
|
+
return {
|
|
2017
|
+
triggerId: resolveTriggerId(trigger),
|
|
2018
|
+
appId: resolveTriggerAppId(trigger),
|
|
2019
|
+
...trigger.connection?.id ? { connectionId: trigger.connection.id } : {},
|
|
2020
|
+
...trigger.input ? { input: trigger.input } : {},
|
|
2021
|
+
...trigger.inputs?.length ? { inputs: trigger.inputs } : {},
|
|
2022
|
+
...trigger.name ? { name: trigger.name } : {},
|
|
2023
|
+
...trigger.description ? { description: trigger.description } : {}
|
|
2024
|
+
};
|
|
2025
|
+
}
|
|
1964
2026
|
function stepToUpsertInput(step) {
|
|
1965
2027
|
const use = step.use;
|
|
1966
2028
|
return {
|
|
@@ -1981,6 +2043,7 @@ function workflowDefinitionToUpsert(def) {
|
|
|
1981
2043
|
name: def.name,
|
|
1982
2044
|
description: def.description,
|
|
1983
2045
|
isActive: def.isActive,
|
|
2046
|
+
...def.trigger ? { trigger: triggerToUpsertInput(def.trigger) } : {},
|
|
1984
2047
|
managedByCode: true,
|
|
1985
2048
|
steps: def.steps.map(stepToUpsertInput)
|
|
1986
2049
|
};
|
|
@@ -2077,6 +2140,8 @@ var LunnoaClient = class {
|
|
|
2077
2140
|
variables;
|
|
2078
2141
|
scorecards;
|
|
2079
2142
|
connections;
|
|
2143
|
+
/** AI provider connections and the model ids each one accepts. */
|
|
2144
|
+
aiConnections;
|
|
2080
2145
|
workflowApps;
|
|
2081
2146
|
discovery;
|
|
2082
2147
|
constructor(options) {
|
|
@@ -2100,6 +2165,7 @@ var LunnoaClient = class {
|
|
|
2100
2165
|
this.variables = new VariablesResource(this.http);
|
|
2101
2166
|
this.scorecards = new ScorecardsResource(this.http);
|
|
2102
2167
|
this.connections = new ConnectionsResource(this.http);
|
|
2168
|
+
this.aiConnections = new AiConnectionsResource(this.http);
|
|
2103
2169
|
this.discovery = new DiscoveryResource(this.http);
|
|
2104
2170
|
}
|
|
2105
2171
|
};
|
|
@@ -2113,6 +2179,7 @@ var GROUPS_WITH_SUBCOMMAND = /* @__PURE__ */ new Set([
|
|
|
2113
2179
|
"tools",
|
|
2114
2180
|
"apps",
|
|
2115
2181
|
"connections",
|
|
2182
|
+
"ai-connections",
|
|
2116
2183
|
"skills"
|
|
2117
2184
|
]);
|
|
2118
2185
|
var VALUE_FLAGS = /* @__PURE__ */ new Set([
|
|
@@ -2210,6 +2277,7 @@ var USAGE = `Usage:
|
|
|
2210
2277
|
npx @lunnoa/client apps get <appId> [--json]
|
|
2211
2278
|
npx @lunnoa/client connections list [--app <appId>] [--json]
|
|
2212
2279
|
npx @lunnoa/client connections get <connectionId> [--json]
|
|
2280
|
+
npx @lunnoa/client ai-connections list [--json]
|
|
2213
2281
|
npx @lunnoa/client agents list [--json]
|
|
2214
2282
|
npx @lunnoa/client workflows list [--json]
|
|
2215
2283
|
npx @lunnoa/client entity-types list [--json]
|
|
@@ -2239,8 +2307,12 @@ Options:
|
|
|
2239
2307
|
Environment: LUNNOA_URL, LUNNOA_API_KEY (also read from ./.env)
|
|
2240
2308
|
Optional config file: lunnoa.config.ts | .mjs | .js | .json
|
|
2241
2309
|
|
|
2310
|
+
ai-connections list prints the model ids each AI connection accepts. Use
|
|
2311
|
+
models[].id as defineAgent({ model }). connections list is app connections
|
|
2312
|
+
(Gmail, HTTP), not model providers.
|
|
2242
2313
|
tools get prints inputConfig and a defineAction() sketch. tools list is compact;
|
|
2243
|
-
run tools get for the schema.
|
|
2314
|
+
run tools get for the schema. apps get --json includes triggers and a
|
|
2315
|
+
defineTrigger() sketch. Do not invent trigger ids. An entity-type slug is unique on the deployment
|
|
2244
2316
|
and grants the API key's workspace when the slug is new.
|
|
2245
2317
|
A slug already granted to other workspaces is not rewritten. Unknown instance attributes are rejected unless
|
|
2246
2318
|
allowUnknownAttributes is true; use extensions.
|
|
@@ -2253,6 +2325,32 @@ function asRecord(value) {
|
|
|
2253
2325
|
}
|
|
2254
2326
|
return void 0;
|
|
2255
2327
|
}
|
|
2328
|
+
function flattenTriggers(apps) {
|
|
2329
|
+
const out = [];
|
|
2330
|
+
for (const app of apps) {
|
|
2331
|
+
const appId = typeof app.id === "string" ? app.id : "";
|
|
2332
|
+
if (!appId) {
|
|
2333
|
+
continue;
|
|
2334
|
+
}
|
|
2335
|
+
const triggers = Array.isArray(app.triggers) ? app.triggers : [];
|
|
2336
|
+
for (const raw of triggers) {
|
|
2337
|
+
const trigger = asRecord(raw);
|
|
2338
|
+
if (!trigger || typeof trigger.id !== "string" || !trigger.id) {
|
|
2339
|
+
continue;
|
|
2340
|
+
}
|
|
2341
|
+
out.push({
|
|
2342
|
+
appId,
|
|
2343
|
+
appName: typeof app.name === "string" ? app.name : appId,
|
|
2344
|
+
triggerId: trigger.id,
|
|
2345
|
+
name: typeof trigger.name === "string" ? trigger.name : trigger.id,
|
|
2346
|
+
description: typeof trigger.description === "string" ? trigger.description : "",
|
|
2347
|
+
needsConnection: typeof trigger.needsConnection === "boolean" ? trigger.needsConnection : Boolean(app.needsConnection),
|
|
2348
|
+
inputConfig: trigger.inputConfig
|
|
2349
|
+
});
|
|
2350
|
+
}
|
|
2351
|
+
}
|
|
2352
|
+
return out;
|
|
2353
|
+
}
|
|
2256
2354
|
function flattenActions(apps) {
|
|
2257
2355
|
const out = [];
|
|
2258
2356
|
for (const app of apps) {
|
|
@@ -2414,6 +2512,49 @@ function formatDefineActionSnippet(action) {
|
|
|
2414
2512
|
"})"
|
|
2415
2513
|
].join("\n");
|
|
2416
2514
|
}
|
|
2515
|
+
function formatDefineTriggerSnippet(trigger) {
|
|
2516
|
+
if (trigger.triggerId === "flow-control_trigger_manual") {
|
|
2517
|
+
return [
|
|
2518
|
+
"defineTrigger({",
|
|
2519
|
+
` id: '${trigger.triggerId}',`,
|
|
2520
|
+
" // inputs become the Manually Run form (customInputConfig)",
|
|
2521
|
+
" inputs: [",
|
|
2522
|
+
" // { id, label, inputType, required }",
|
|
2523
|
+
" ],",
|
|
2524
|
+
"})"
|
|
2525
|
+
].join("\n");
|
|
2526
|
+
}
|
|
2527
|
+
const fields = extractInputFields(trigger.inputConfig);
|
|
2528
|
+
const inputBlock = fields.length === 0 ? " // no inputConfig fields advertised" : fields.map((field) => {
|
|
2529
|
+
const notes = [
|
|
2530
|
+
field.label && field.label !== field.id ? field.label : void 0,
|
|
2531
|
+
field.type,
|
|
2532
|
+
field.required ? "required" : void 0
|
|
2533
|
+
].filter(Boolean).join(", ");
|
|
2534
|
+
return notes ? ` // ${field.id} \u2014 ${notes}` : ` // ${field.id}`;
|
|
2535
|
+
}).join("\n");
|
|
2536
|
+
return [
|
|
2537
|
+
"defineTrigger({",
|
|
2538
|
+
` id: '${trigger.triggerId}',`,
|
|
2539
|
+
` appId: '${trigger.appId}',`,
|
|
2540
|
+
" input: {",
|
|
2541
|
+
inputBlock,
|
|
2542
|
+
" },",
|
|
2543
|
+
"})"
|
|
2544
|
+
].join("\n");
|
|
2545
|
+
}
|
|
2546
|
+
function triggerDetail(trigger) {
|
|
2547
|
+
return {
|
|
2548
|
+
appId: trigger.appId,
|
|
2549
|
+
triggerId: trigger.triggerId,
|
|
2550
|
+
name: trigger.name,
|
|
2551
|
+
description: trigger.description,
|
|
2552
|
+
needsConnection: trigger.needsConnection,
|
|
2553
|
+
inputFields: extractInputFields(trigger.inputConfig),
|
|
2554
|
+
inputConfig: trigger.inputConfig ?? null,
|
|
2555
|
+
defineTrigger: formatDefineTriggerSnippet(trigger)
|
|
2556
|
+
};
|
|
2557
|
+
}
|
|
2417
2558
|
function actionDetail(action) {
|
|
2418
2559
|
return {
|
|
2419
2560
|
...summarizeAction(action),
|
|
@@ -2573,6 +2714,7 @@ async function runAppsGet(client, args) {
|
|
|
2573
2714
|
throw new Error(`Unknown app "${appId}". Try: apps list`);
|
|
2574
2715
|
}
|
|
2575
2716
|
const actions = flattenActions([app]).map(summarizeAction);
|
|
2717
|
+
const triggers = flattenTriggers([app]).map(triggerDetail);
|
|
2576
2718
|
const payload = {
|
|
2577
2719
|
id: app.id,
|
|
2578
2720
|
name: app.name,
|
|
@@ -2581,6 +2723,7 @@ async function runAppsGet(client, args) {
|
|
|
2581
2723
|
needsConnection: Boolean(app.needsConnection),
|
|
2582
2724
|
isPublished: Boolean(app.isPublished),
|
|
2583
2725
|
actions,
|
|
2726
|
+
triggers,
|
|
2584
2727
|
connectionTypes: Array.isArray(app.connections) ? app.connections : []
|
|
2585
2728
|
};
|
|
2586
2729
|
if (args.json) {
|
|
@@ -2601,6 +2744,56 @@ async function runAppsGet(client, args) {
|
|
|
2601
2744
|
{ key: "availableForAgent", header: "FOR_AGENT" },
|
|
2602
2745
|
{ key: "needsConnection", header: "NEEDS_CONN" }
|
|
2603
2746
|
]);
|
|
2747
|
+
if (triggers.length) {
|
|
2748
|
+
console.log("");
|
|
2749
|
+
console.log("triggers:");
|
|
2750
|
+
printTable(
|
|
2751
|
+
triggers.map((trigger) => ({
|
|
2752
|
+
triggerId: trigger.triggerId,
|
|
2753
|
+
name: trigger.name,
|
|
2754
|
+
needsConnection: trigger.needsConnection
|
|
2755
|
+
})),
|
|
2756
|
+
[
|
|
2757
|
+
{ key: "triggerId", header: "TRIGGER" },
|
|
2758
|
+
{ key: "name", header: "NAME" },
|
|
2759
|
+
{ key: "needsConnection", header: "NEEDS_CONN" }
|
|
2760
|
+
]
|
|
2761
|
+
);
|
|
2762
|
+
}
|
|
2763
|
+
}
|
|
2764
|
+
async function runAiConnectionsList(client, args) {
|
|
2765
|
+
const connections = await client.aiConnections.list();
|
|
2766
|
+
if (args.json) {
|
|
2767
|
+
printJson(connections);
|
|
2768
|
+
return;
|
|
2769
|
+
}
|
|
2770
|
+
const rows = connections.flatMap((connection) => {
|
|
2771
|
+
if (connection.models.length === 0) {
|
|
2772
|
+
return [
|
|
2773
|
+
{
|
|
2774
|
+
name: connection.name,
|
|
2775
|
+
provider: connection.provider,
|
|
2776
|
+
model: "",
|
|
2777
|
+
isDefault: connection.isDefault,
|
|
2778
|
+
id: connection.id
|
|
2779
|
+
}
|
|
2780
|
+
];
|
|
2781
|
+
}
|
|
2782
|
+
return connection.models.map((model) => ({
|
|
2783
|
+
name: connection.name,
|
|
2784
|
+
provider: connection.provider,
|
|
2785
|
+
model: model.id,
|
|
2786
|
+
isDefault: connection.isDefault && model.isDefault,
|
|
2787
|
+
id: connection.id
|
|
2788
|
+
}));
|
|
2789
|
+
});
|
|
2790
|
+
printTable(rows, [
|
|
2791
|
+
{ key: "name", header: "CONNECTION" },
|
|
2792
|
+
{ key: "provider", header: "PROVIDER" },
|
|
2793
|
+
{ key: "model", header: "MODEL" },
|
|
2794
|
+
{ key: "isDefault", header: "DEFAULT" },
|
|
2795
|
+
{ key: "id", header: "ID" }
|
|
2796
|
+
]);
|
|
2604
2797
|
}
|
|
2605
2798
|
async function runConnectionsList(client, args) {
|
|
2606
2799
|
const connections = await client.connections.list({
|
|
@@ -3490,6 +3683,7 @@ var DISCOVERY_SUBCOMMANDS = {
|
|
|
3490
3683
|
tools: ["list", "get", "search"],
|
|
3491
3684
|
apps: ["list", "get"],
|
|
3492
3685
|
connections: ["list", "get"],
|
|
3686
|
+
"ai-connections": ["list"],
|
|
3493
3687
|
tables: ["list", "get"],
|
|
3494
3688
|
features: void 0
|
|
3495
3689
|
};
|
|
@@ -3523,7 +3717,7 @@ ${USAGE}`
|
|
|
3523
3717
|
}
|
|
3524
3718
|
async function runDiscovery(args) {
|
|
3525
3719
|
const { command, subcommand } = args;
|
|
3526
|
-
if (command === "tools" || command === "apps" || command === "connections" || command === "tables") {
|
|
3720
|
+
if (command === "tools" || command === "apps" || command === "connections" || command === "ai-connections" || command === "tables") {
|
|
3527
3721
|
assertKnownDiscoveryShape(args);
|
|
3528
3722
|
}
|
|
3529
3723
|
if (!isDiscoveryCommand(args)) {
|
|
@@ -3558,6 +3752,10 @@ async function runDiscovery(args) {
|
|
|
3558
3752
|
await runConnectionsGet(client, args);
|
|
3559
3753
|
return true;
|
|
3560
3754
|
}
|
|
3755
|
+
if (command === "ai-connections" && subcommand === "list") {
|
|
3756
|
+
await runAiConnectionsList(client, args);
|
|
3757
|
+
return true;
|
|
3758
|
+
}
|
|
3561
3759
|
if (command === "agents" && subcommand === "list") {
|
|
3562
3760
|
await runAgentsList(client, args);
|
|
3563
3761
|
return true;
|
package/dist/index.cjs
CHANGED
|
@@ -468,7 +468,7 @@ var AgentChatClient = class {
|
|
|
468
468
|
function messageTaskBody(message, options = {}) {
|
|
469
469
|
return {
|
|
470
470
|
messages: [message],
|
|
471
|
-
|
|
471
|
+
chatMode: options.chatMode ?? "preview",
|
|
472
472
|
...options.data ? { data: options.data } : {},
|
|
473
473
|
...options.piiResolution ? { piiResolution: options.piiResolution } : {}
|
|
474
474
|
};
|
|
@@ -537,6 +537,7 @@ var DEFINE_KINDS = {
|
|
|
537
537
|
connection: "connection",
|
|
538
538
|
aiConnection: "aiConnection",
|
|
539
539
|
action: "action",
|
|
540
|
+
trigger: "trigger",
|
|
540
541
|
workflow: "workflow",
|
|
541
542
|
agent: "agent",
|
|
542
543
|
entityType: "entityType"
|
|
@@ -553,6 +554,25 @@ function defineAction(config) {
|
|
|
553
554
|
}
|
|
554
555
|
return { kind: DEFINE_KINDS.action, ...config };
|
|
555
556
|
}
|
|
557
|
+
function assertTriggerConfig(config) {
|
|
558
|
+
if (!config.id?.trim()) {
|
|
559
|
+
throw new Error("defineTrigger requires id (catalogue trigger id)");
|
|
560
|
+
}
|
|
561
|
+
for (const field of config.inputs ?? []) {
|
|
562
|
+
if (!field?.id?.trim()) {
|
|
563
|
+
throw new Error("defineTrigger inputs require id");
|
|
564
|
+
}
|
|
565
|
+
}
|
|
566
|
+
if (config.inputs?.length && config.id.trim() !== "flow-control_trigger_manual") {
|
|
567
|
+
throw new Error(
|
|
568
|
+
"defineTrigger inputs are only valid on flow-control_trigger_manual"
|
|
569
|
+
);
|
|
570
|
+
}
|
|
571
|
+
}
|
|
572
|
+
function defineTrigger(config) {
|
|
573
|
+
assertTriggerConfig(config);
|
|
574
|
+
return { kind: DEFINE_KINDS.trigger, ...config };
|
|
575
|
+
}
|
|
556
576
|
function defineWorkflow(config) {
|
|
557
577
|
if (!config.slug?.trim()) {
|
|
558
578
|
throw new Error("defineWorkflow requires slug");
|
|
@@ -560,6 +580,9 @@ function defineWorkflow(config) {
|
|
|
560
580
|
if (!config.steps?.length) {
|
|
561
581
|
throw new Error("defineWorkflow requires at least one step");
|
|
562
582
|
}
|
|
583
|
+
if (config.trigger) {
|
|
584
|
+
assertTriggerConfig(config.trigger);
|
|
585
|
+
}
|
|
563
586
|
return { kind: DEFINE_KINDS.workflow, ...config };
|
|
564
587
|
}
|
|
565
588
|
function defineAgent(config) {
|
|
@@ -605,6 +628,40 @@ function resolveActionAppId(action) {
|
|
|
605
628
|
`Cannot infer appId for action "${id}". Pass appId explicitly.`
|
|
606
629
|
);
|
|
607
630
|
}
|
|
631
|
+
function resolveTriggerAppId(trigger) {
|
|
632
|
+
if (trigger.appId?.trim()) {
|
|
633
|
+
return trigger.appId.trim();
|
|
634
|
+
}
|
|
635
|
+
const id = trigger.id.trim();
|
|
636
|
+
const marker = "_trigger_";
|
|
637
|
+
const markerIndex = id.indexOf(marker);
|
|
638
|
+
if (markerIndex > 0) {
|
|
639
|
+
return id.slice(0, markerIndex);
|
|
640
|
+
}
|
|
641
|
+
const dot = id.indexOf(".");
|
|
642
|
+
if (dot > 0) {
|
|
643
|
+
return id.slice(0, dot);
|
|
644
|
+
}
|
|
645
|
+
throw new Error(
|
|
646
|
+
`Cannot infer appId for trigger "${id}". Pass appId explicitly.`
|
|
647
|
+
);
|
|
648
|
+
}
|
|
649
|
+
function resolveTriggerId(trigger) {
|
|
650
|
+
const id = trigger.id.trim();
|
|
651
|
+
const appId = trigger.appId?.trim();
|
|
652
|
+
if (appId && id.startsWith(`${appId}.`)) {
|
|
653
|
+
return id.slice(appId.length + 1);
|
|
654
|
+
}
|
|
655
|
+
const marker = "_trigger_";
|
|
656
|
+
if (id.includes(marker)) {
|
|
657
|
+
return id;
|
|
658
|
+
}
|
|
659
|
+
const dot = id.indexOf(".");
|
|
660
|
+
if (dot > 0) {
|
|
661
|
+
return id.slice(dot + 1);
|
|
662
|
+
}
|
|
663
|
+
return id;
|
|
664
|
+
}
|
|
608
665
|
function resolveActionId(action) {
|
|
609
666
|
const id = action.id.trim();
|
|
610
667
|
const appId = action.appId?.trim();
|
|
@@ -894,6 +951,22 @@ var SsoAuthResource = class {
|
|
|
894
951
|
}
|
|
895
952
|
};
|
|
896
953
|
|
|
954
|
+
// src/resources/ai-connections.ts
|
|
955
|
+
var AiConnectionsResource = class {
|
|
956
|
+
constructor(http) {
|
|
957
|
+
this.http = http;
|
|
958
|
+
}
|
|
959
|
+
http;
|
|
960
|
+
/**
|
|
961
|
+
* Lists AI connections the caller can assign to an agent, with the model
|
|
962
|
+
* ids each connection accepts. Credentials are never included.
|
|
963
|
+
* Requires `agents:create` (the same permission as agent deploy).
|
|
964
|
+
*/
|
|
965
|
+
list() {
|
|
966
|
+
return this.http.get("/api/ai-connections");
|
|
967
|
+
}
|
|
968
|
+
};
|
|
969
|
+
|
|
897
970
|
// src/resources/connections.ts
|
|
898
971
|
var ConnectionsResource = class {
|
|
899
972
|
constructor(http) {
|
|
@@ -2003,6 +2076,17 @@ var WorkflowAppsResource = class {
|
|
|
2003
2076
|
};
|
|
2004
2077
|
|
|
2005
2078
|
// src/resources/workflows.ts
|
|
2079
|
+
function triggerToUpsertInput(trigger) {
|
|
2080
|
+
return {
|
|
2081
|
+
triggerId: resolveTriggerId(trigger),
|
|
2082
|
+
appId: resolveTriggerAppId(trigger),
|
|
2083
|
+
...trigger.connection?.id ? { connectionId: trigger.connection.id } : {},
|
|
2084
|
+
...trigger.input ? { input: trigger.input } : {},
|
|
2085
|
+
...trigger.inputs?.length ? { inputs: trigger.inputs } : {},
|
|
2086
|
+
...trigger.name ? { name: trigger.name } : {},
|
|
2087
|
+
...trigger.description ? { description: trigger.description } : {}
|
|
2088
|
+
};
|
|
2089
|
+
}
|
|
2006
2090
|
function stepToUpsertInput(step) {
|
|
2007
2091
|
const use = step.use;
|
|
2008
2092
|
return {
|
|
@@ -2023,6 +2107,7 @@ function workflowDefinitionToUpsert(def) {
|
|
|
2023
2107
|
name: def.name,
|
|
2024
2108
|
description: def.description,
|
|
2025
2109
|
isActive: def.isActive,
|
|
2110
|
+
...def.trigger ? { trigger: triggerToUpsertInput(def.trigger) } : {},
|
|
2026
2111
|
managedByCode: true,
|
|
2027
2112
|
steps: def.steps.map(stepToUpsertInput)
|
|
2028
2113
|
};
|
|
@@ -2119,6 +2204,8 @@ var LunnoaClient = class {
|
|
|
2119
2204
|
variables;
|
|
2120
2205
|
scorecards;
|
|
2121
2206
|
connections;
|
|
2207
|
+
/** AI provider connections and the model ids each one accepts. */
|
|
2208
|
+
aiConnections;
|
|
2122
2209
|
workflowApps;
|
|
2123
2210
|
discovery;
|
|
2124
2211
|
constructor(options) {
|
|
@@ -2142,6 +2229,7 @@ var LunnoaClient = class {
|
|
|
2142
2229
|
this.variables = new VariablesResource(this.http);
|
|
2143
2230
|
this.scorecards = new ScorecardsResource(this.http);
|
|
2144
2231
|
this.connections = new ConnectionsResource(this.http);
|
|
2232
|
+
this.aiConnections = new AiConnectionsResource(this.http);
|
|
2145
2233
|
this.discovery = new DiscoveryResource(this.http);
|
|
2146
2234
|
}
|
|
2147
2235
|
};
|
|
@@ -2223,6 +2311,7 @@ exports.ActionsResource = ActionsResource;
|
|
|
2223
2311
|
exports.AgentChatClient = AgentChatClient;
|
|
2224
2312
|
exports.AgentChatStream = AgentChatStream;
|
|
2225
2313
|
exports.AgentsResource = AgentsResource;
|
|
2314
|
+
exports.AiConnectionsResource = AiConnectionsResource;
|
|
2226
2315
|
exports.ApprovalsResource = ApprovalsResource;
|
|
2227
2316
|
exports.AuthResource = AuthResource;
|
|
2228
2317
|
exports.ConnectionsResource = ConnectionsResource;
|
|
@@ -2257,6 +2346,7 @@ exports.defineAgent = defineAgent;
|
|
|
2257
2346
|
exports.defineAiConnection = defineAiConnection;
|
|
2258
2347
|
exports.defineConnection = defineConnection;
|
|
2259
2348
|
exports.defineEntityType = defineEntityType;
|
|
2349
|
+
exports.defineTrigger = defineTrigger;
|
|
2260
2350
|
exports.defineWorkflow = defineWorkflow;
|
|
2261
2351
|
exports.entityTypeDefinitionToUpsert = entityTypeDefinitionToUpsert;
|
|
2262
2352
|
exports.isBrowserEnvironment = isBrowserEnvironment;
|
|
@@ -2267,5 +2357,7 @@ exports.parseSseEvents = parseSseEvents;
|
|
|
2267
2357
|
exports.parseSseStream = parseSseStream;
|
|
2268
2358
|
exports.resolveActionAppId = resolveActionAppId;
|
|
2269
2359
|
exports.resolveActionId = resolveActionId;
|
|
2360
|
+
exports.resolveTriggerAppId = resolveTriggerAppId;
|
|
2361
|
+
exports.resolveTriggerId = resolveTriggerId;
|
|
2270
2362
|
//# sourceMappingURL=index.cjs.map
|
|
2271
2363
|
//# sourceMappingURL=index.cjs.map
|