@desplega.ai/agent-swarm 1.129.0 → 1.131.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 +2 -2
- package/dist/{actions-kfv2dawe.js → actions-w53mbns9.js} +11 -11
- package/dist/{anthropic-messages-3xgme8my.js → anthropic-messages-rjmd2e7n.js} +5 -5
- package/dist/{app-q8vjk6e8.js → app-m9gwqsqv.js} +8 -8
- package/dist/{artifact-hg4t1nx7.js → artifact-jysj3wrg.js} +2 -2
- package/dist/{assistant-g037r345.js → assistant-bp65m6f3.js} +13 -13
- package/dist/{azure-openai-responses-xa4sh9f6.js → azure-openai-responses-c0yjmbfd.js} +8 -5
- package/dist/{boot-reembed-18pzsrxa.js → boot-reembed-62p0at2k.js} +6 -6
- package/dist/{boot-reembed-wpks2cj8.js → boot-reembed-xmfp6wdh.js} +7 -7
- package/dist/{boot-scrub-logs-n7szd57r.js → boot-scrub-logs-rr8q2dms.js} +5 -5
- package/dist/{claude-adapter-qz4r0ajt.js → claude-adapter-2y47mrkd.js} +9 -9
- package/dist/{cli-mhjnbgb6.js → cli-0rcyq6d9.js} +450 -186
- package/dist/{cli-ttkmehy0.js → cli-2q72qz2s.js} +274 -25
- package/dist/{cli-gztgc3hz.js → cli-2wadx7p2.js} +2 -2
- package/dist/cli-3fj60etf.js +153 -0
- package/dist/{cli-7ecgm5v0.js → cli-3kf51j15.js} +1 -1
- package/dist/{cli-vgexpfsr.js → cli-57khth04.js} +6 -3
- package/dist/{cli-2mbe7vk0.js → cli-5dsbcjjw.js} +1 -1
- package/dist/{cli-etr62zy6.js → cli-5kx36evn.js} +2 -2
- package/dist/{cli-v2tr6amf.js → cli-5n6e5yfn.js} +30 -8
- package/dist/{cli-hx02s9zq.js → cli-5v4rw6yd.js} +2 -2
- package/dist/{cli-v37yr6mf.js → cli-5ze9rv97.js} +4 -4
- package/dist/{cli-ch7t5v7n.js → cli-6map995v.js} +9 -4
- package/dist/{cli-h0457a67.js → cli-70xqj0z3.js} +3 -3
- package/dist/{cli-kk4f9r17.js → cli-72q8m8gk.js} +8 -6
- package/dist/{cli-7padk69a.js → cli-78xwvkhj.js} +2 -2
- package/dist/{cli-dxtxacy7.js → cli-9dr5qzc0.js} +45 -8
- package/dist/{cli-17zxdgsq.js → cli-a40rnf71.js} +6 -6
- package/dist/{cli-t53vnnxz.js → cli-a4jzdpa3.js} +2514 -1055
- package/dist/{cli-w10fkrf1.js → cli-akdvwc9v.js} +354 -115
- package/dist/{cli-1qkk5er0.js → cli-bmze986d.js} +1 -1
- package/dist/{cli-ga12dc1d.js → cli-bqw0mt1n.js} +3 -3
- package/dist/{cli-0sf92efp.js → cli-cdeg08wx.js} +1 -1
- package/dist/{cli-a8ynhkyj.js → cli-cvgjwnh1.js} +17 -15
- package/dist/{cli-9fxg3v5m.js → cli-d2tfkcga.js} +4 -4
- package/dist/{cli-nhcd7x43.js → cli-d3x3x1c9.js} +2 -2
- package/dist/{cli-6nh2qxvh.js → cli-darcwax3.js} +1 -1
- package/dist/{cli-yjbgmysx.js → cli-e7ckcg4v.js} +12 -12
- package/dist/{cli-4n2gcjpd.js → cli-efxfnq6q.js} +4 -3
- package/dist/{cli-z9xqqhfk.js → cli-er3a4bb0.js} +1 -1
- package/dist/{cli-xg2eezyv.js → cli-f1am9szv.js} +1 -1
- package/dist/{cli-xy4cwsm9.js → cli-fywms69x.js} +1 -1
- package/dist/{cli-33jj76y8.js → cli-g6b8x1h8.js} +1 -1
- package/dist/{cli-epsvdckx.js → cli-gm9cbhbq.js} +20 -10
- package/dist/{cli-rkndnn90.js → cli-k9qkf1hw.js} +6 -4
- package/dist/{cli-zejvt395.js → cli-kh3ba2zf.js} +1 -1
- package/dist/{cli-gb25p1h2.js → cli-nm5gtp1x.js} +2 -2
- package/dist/{cli-akxnpx17.js → cli-pm6xbh84.js} +1829 -1629
- package/dist/{cli-2k0ztbfp.js → cli-psh3c4va.js} +1 -1
- package/dist/{cli-39vgrsep.js → cli-qv61hp37.js} +2 -2
- package/dist/{cli-hv2fndhm.js → cli-r6kqqbj0.js} +6 -4
- package/dist/{cli-1y1cm570.js → cli-rzbpmxdr.js} +1 -1
- package/dist/{cli-mmrk00vp.js → cli-t1xze5qh.js} +1 -1
- package/dist/{cli-g252a9ky.js → cli-t55yw3a1.js} +2 -2
- package/dist/{cli-7bz8dzqa.js → cli-t76vw5db.js} +1184 -1522
- package/dist/{cli-4n4mdv21.js → cli-xpxde7rm.js} +7 -3
- package/dist/{cli-fpaa5k2q.js → cli-yw8vghx2.js} +54 -18
- package/dist/cli-zsspvvm2.js +490 -0
- package/dist/cli.js +27 -25
- package/dist/{codex-adapter-7v6t7ff6.js → codex-adapter-d24q75wk.js} +7 -7
- package/dist/{codex-hook-amndawyb.js → codex-hook-hq54t9ft.js} +2 -2
- package/dist/{codex-session-runner-e7j4khe2.js → codex-session-runner-g50vcsex.js} +7 -7
- package/dist/{commands-ex0k5tbf.js → commands-c3nrc5hg.js} +5 -5
- package/dist/{db-df7jatfc.js → db-nt7fg3tw.js} +5 -5
- package/dist/{google-generative-ai-y42hnw9p.js → google-generative-ai-hysrd8qx.js} +7 -5
- package/dist/{google-vertex-4sg66gb6.js → google-vertex-p5arrga0.js} +7 -5
- package/dist/{handlers-1j2cfqt2.js → handlers-fkr6swat.js} +13 -13
- package/dist/{hook-nx9a0mj3.js → hook-77wpvnjc.js} +7 -7
- package/dist/{hook-w6yaf6sy.js → hook-g019yehy.js} +8 -8
- package/dist/{http-4tz5h8wg.js → http-jewj0syk.js} +2993 -716
- package/dist/{index-0bpkzb09.js → index-070v4eyb.js} +3 -3
- package/dist/{index-0s67qv7h.js → index-6gm5he8h.js} +11 -11
- package/dist/{index-35gtv6gj.js → index-7n2xpbd4.js} +310 -40
- package/dist/{index-ker3gccb.js → index-9znhar3x.js} +4 -4
- package/dist/{index-5n2c8yay.js → index-hase6zbe.js} +2 -2
- package/dist/{index-kcf3tm9h.js → index-hfvggd0z.js} +12 -12
- package/dist/{index-7c0jqna0.js → index-hp1kdbjj.js} +13 -13
- package/dist/{keepalive-3j4a9168.js → keepalive-j0fjvqfd.js} +7 -7
- package/dist/{lead-6kpevymb.js → lead-1n8x30xe.js} +33 -33
- package/dist/{maintenance-m1k82ean.js → maintenance-gvev11sa.js} +7 -7
- package/dist/{mistral-conversations-bjkdfb6z.js → mistral-conversations-81fwav0j.js} +6 -6
- package/dist/{oauth-refresh-sweep-881k8e4q.js → oauth-refresh-sweep-s9ecsvh0.js} +6 -6
- package/dist/{onboard-c0ykffjn.js → onboard-pvm5b38w.js} +2 -2
- package/dist/{openai-codex-responses-xetseqvt.js → openai-codex-responses-5g27pd6f.js} +43 -23
- package/dist/{openai-completions-5r2g5axa.js → openai-completions-3vkmfz2a.js} +55 -11
- package/dist/{openai-responses-ce67hd23.js → openai-responses-dg4t7j7a.js} +8 -5
- package/dist/{openrouter-images-pzfp22jb.js → openrouter-images-g3gm8931.js} +1 -1
- package/dist/{otel-impl-sqagjerv.js → otel-impl-p6jvgd9c.js} +6 -4
- package/dist/{otel-3mp81ppd.js → otel-nqa12wf3.js} +2 -2
- package/dist/{pi-mono-adapter-k584k16g.js → pi-mono-adapter-t091s27g.js} +17117 -7517
- package/dist/{pricing-refresh-y82whbf9.js → pricing-refresh-k49rcyed.js} +7 -7
- package/dist/{rbac-roles-nvkqmzyd.js → rbac-roles-30pspvy7.js} +7 -7
- package/dist/{rbac-roles-4ht8gegc.js → rbac-roles-cr80g96t.js} +6 -6
- package/dist/{render-v2-wvqdgvvp.js → render-v2-xm457ng1.js} +8 -8
- package/dist/{seed-pricing-fy3rxhde.js → seed-pricing-yhpv35fr.js} +6 -6
- package/dist/{setup-ak5cnc6f.js → setup-nytnmwwr.js} +2 -2
- package/dist/{worker-d8769q8a.js → worker-msytr2cw.js} +33 -33
- package/openapi.json +34039 -11036
- package/package.json +8 -6
- package/src/apps/definition.ts +368 -26
- package/src/apps/row-store.ts +66 -10
- package/src/apps/schema-migrate.ts +95 -1
- package/src/apps/store.ts +13 -4
- package/src/apps/sync-run-as.ts +18 -0
- package/src/apps/sync.ts +934 -0
- package/src/apps/version.ts +16 -2
- package/src/assets/key.ts +8 -1
- package/src/be/asset-key-audit.ts +3 -1
- package/src/be/db-queries/mcp-oauth.ts +297 -24
- package/src/be/db.ts +42 -1
- package/src/be/migrations/129_asset_keys_apps_scripts.sql +161 -0
- package/src/be/scripts/db.ts +5 -2
- package/src/be/scripts/typecheck.ts +1 -0
- package/src/be/seed-scripts/catalog/app-sync-run.ts +32 -0
- package/src/be/seed-scripts/catalog/github-issues-pull.ts +102 -0
- package/src/be/seed-scripts/index.ts +18 -0
- package/src/be/seed-skills/index.ts +7 -0
- package/src/http/active-sessions.ts +26 -18
- package/src/http/agents.ts +94 -27
- package/src/http/api-keys.ts +91 -17
- package/src/http/approval-requests.ts +87 -10
- package/src/http/apps.ts +361 -53
- package/src/http/assets.ts +165 -31
- package/src/http/budgets.ts +7 -5
- package/src/http/codex-oauth-keep-warm.ts +21 -3
- package/src/http/config.ts +46 -16
- package/src/http/context.ts +33 -6
- package/src/http/ecosystem.ts +20 -6
- package/src/http/events.ts +24 -9
- package/src/http/favorites.ts +20 -6
- package/src/http/fs.ts +60 -17
- package/src/http/heartbeat.ts +18 -4
- package/src/http/inbox-state.ts +12 -6
- package/src/http/integrations.ts +25 -5
- package/src/http/kv.ts +36 -15
- package/src/http/mcp-bridge.ts +5 -1
- package/src/http/mcp-oauth.ts +332 -17
- package/src/http/mcp-servers.ts +56 -18
- package/src/http/memory.ts +282 -29
- package/src/http/metrics.ts +80 -17
- package/src/http/oauth-callback.ts +10 -4
- package/src/http/oauth-generic.ts +5 -1
- package/src/http/oauth-locks.ts +6 -3
- package/src/http/openapi.ts +57 -9
- package/src/http/page-proxy.ts +25 -5
- package/src/http/pages-public.ts +37 -20
- package/src/http/pages.ts +93 -28
- package/src/http/poll.ts +89 -5
- package/src/http/pricing.ts +9 -6
- package/src/http/prompt-templates.ts +85 -21
- package/src/http/route-def.ts +67 -4
- package/src/http/schedules.ts +63 -14
- package/src/http/script-connection-proxy.ts +30 -4
- package/src/http/script-connections.ts +393 -43
- package/src/http/script-runs.ts +73 -19
- package/src/http/scripts.ts +257 -39
- package/src/http/session-data.ts +87 -14
- package/src/http/sessions.ts +80 -5
- package/src/http/skills.ts +115 -35
- package/src/http/stats.ts +94 -13
- package/src/http/task-templates.ts +6 -4
- package/src/http/tasks.ts +230 -61
- package/src/http/trackers/jira.ts +90 -30
- package/src/http/trackers/linear.ts +46 -12
- package/src/http/users.ts +162 -25
- package/src/http/utils.ts +12 -2
- package/src/http/webhooks.ts +30 -16
- package/src/http/workflow-events.ts +18 -5
- package/src/http/workflows.ts +128 -39
- package/src/http/x.ts +37 -6
- package/src/oauth/ensure-mcp-token.ts +16 -1
- package/src/oauth/mcp-wrapper.ts +281 -26
- package/src/providers/pi-mono-adapter.ts +1 -1
- package/src/scripts-runtime/credential-broker/README.md +1 -1
- package/src/scripts-runtime/credential-broker/fetch-patch.ts +12 -2
- package/src/scripts-runtime/sdk-allowlist.ts +1 -0
- package/src/scripts-runtime/stdlib/fetch.ts +6 -0
- package/src/scripts-runtime/types/stdlib.d.ts +1 -0
- package/src/scripts-runtime/types/swarm-sdk.d.ts +1 -0
- package/src/server.ts +2 -0
- package/src/tests/apps-rbac.test.ts +110 -0
- package/src/tests/apps-spike2.test.ts +4 -1
- package/src/tests/apps-sync-engine.test.ts +2540 -0
- package/src/tests/apps-sync.test.ts +1627 -0
- package/src/tests/asset-key-api.test.ts +48 -2
- package/src/tests/asset-key-invariants.test.ts +92 -0
- package/src/tests/asset-key-migration.test.ts +174 -8
- package/src/tests/asset-key-normalization.test.ts +2 -0
- package/src/tests/credential-broker.test.ts +27 -2
- package/src/tests/mcp-oauth-dcr-reuse.test.ts +743 -0
- package/src/tests/mcp-oauth-ensure-token.test.ts +45 -0
- package/src/tests/mcp-oauth-manual-client.test.ts +135 -2
- package/src/tests/mcp-oauth-queries.test.ts +153 -0
- package/src/tests/mcp-oauth-wrapper.test.ts +432 -0
- package/src/tests/memory-http-recall-gating.test.ts +2 -0
- package/src/tests/openapi-response-contract.test.ts +138 -0
- package/src/tests/rbac-admission-e2e.test.ts +68 -0
- package/src/tests/script-connections.test.ts +3 -0
- package/src/tests/scripts-runtime-fetch.test.ts +121 -0
- package/src/tests/scripts-runtime-secret-egress.test.ts +4 -2
- package/src/tests/seed-scripts.test.ts +2 -2
- package/src/tests/swarm-tool-result-gate.test.ts +32 -0
- package/src/tests/task-working-dir.test.ts +8 -4
- package/src/tests/whoami-route.test.ts +127 -0
- package/src/tests/workflow-engine-v2.test.ts +80 -7
- package/src/tests/workflow-swarm-script.test.ts +104 -0
- package/src/tools/app-get.ts +10 -2
- package/src/tools/app-rollback.ts +1 -0
- package/src/tools/app-sync.ts +112 -0
- package/src/tools/script-common.ts +20 -0
- package/src/tools/tool-config.ts +2 -1
- package/src/tools/utils.ts +11 -0
- package/src/tools/workflows/create-workflow.ts +4 -1
- package/src/types.ts +1394 -1206
- package/src/utils/template.ts +8 -1
- package/src/utils/zod-openapi.ts +11 -0
- package/src/workflows/engine.ts +27 -4
- package/src/workflows/executors/swarm-script.ts +28 -0
- package/src/workflows/retry-poller.ts +19 -2
- package/templates/skills/apps/content.md +94 -5
- package/templates/skills/asset-namespaces/content.md +2 -2
- package/templates/skills/scheduled-task-resilience/SKILL.md +102 -0
- package/templates/skills/scheduled-task-resilience/config.json +14 -0
- package/templates/skills/scheduled-task-resilience/content.md +97 -0
- package/dist/cli-7wmybrt5.js +0 -115
- package/dist/cli-d91pvmq1.js +0 -14
|
@@ -3,15 +3,19 @@ import {
|
|
|
3
3
|
getScriptApiConnectionDescriptors,
|
|
4
4
|
getScriptById,
|
|
5
5
|
getScriptMcpConnectionDescriptors,
|
|
6
|
+
listScriptConnections,
|
|
6
7
|
runScript
|
|
7
|
-
} from "./cli-
|
|
8
|
+
} from "./cli-pm6xbh84.js";
|
|
8
9
|
import {
|
|
10
|
+
defaultAssetKey,
|
|
9
11
|
getDb,
|
|
10
|
-
|
|
11
|
-
|
|
12
|
+
getLeadAgent,
|
|
13
|
+
init_db,
|
|
14
|
+
init_key
|
|
15
|
+
} from "./cli-a4jzdpa3.js";
|
|
12
16
|
import {
|
|
13
17
|
init_zod
|
|
14
|
-
} from "./cli-
|
|
18
|
+
} from "./cli-zsspvvm2.js";
|
|
15
19
|
import {
|
|
16
20
|
_enum,
|
|
17
21
|
array,
|
|
@@ -25,7 +29,7 @@ import {
|
|
|
25
29
|
string,
|
|
26
30
|
union,
|
|
27
31
|
unknown
|
|
28
|
-
} from "./cli-
|
|
32
|
+
} from "./cli-5dsbcjjw.js";
|
|
29
33
|
|
|
30
34
|
// src/be/scripts/run-saved.ts
|
|
31
35
|
function getSavedScriptOwnerAgentId(script) {
|
|
@@ -2148,6 +2152,12 @@ function validatePage(definition, catalog, target) {
|
|
|
2148
2152
|
return dedupeIssues(issues);
|
|
2149
2153
|
}
|
|
2150
2154
|
|
|
2155
|
+
// src/apps/sync-run-as.ts
|
|
2156
|
+
init_db();
|
|
2157
|
+
function resolveSyncRunAs(script) {
|
|
2158
|
+
return getSavedScriptOwnerAgentId(script) ?? getLeadAgent()?.id ?? "app-sync";
|
|
2159
|
+
}
|
|
2160
|
+
|
|
2151
2161
|
// src/apps/definition.ts
|
|
2152
2162
|
var AppNameSchema = string().regex(/^[a-z][a-zA-Z0-9_]{0,39}$/, {
|
|
2153
2163
|
message: "must start with a lowercase letter and contain only letters, numbers, or underscores"
|
|
@@ -2157,13 +2167,27 @@ var ISO_8601_PREFIX = /^\d{4}-\d{2}-\d{2}(?:T.*)?$/;
|
|
|
2157
2167
|
function isIso8601Date(value) {
|
|
2158
2168
|
return ISO_8601_PREFIX.test(value) && !Number.isNaN(Date.parse(value));
|
|
2159
2169
|
}
|
|
2170
|
+
var SourceTransformSchema = _enum(["slug", "lower", "upper", "cents", "date-parse"]);
|
|
2171
|
+
var TRANSFORM_COLUMN_KIND = {
|
|
2172
|
+
slug: "string",
|
|
2173
|
+
lower: "string",
|
|
2174
|
+
upper: "string",
|
|
2175
|
+
cents: "number",
|
|
2176
|
+
"date-parse": "date"
|
|
2177
|
+
};
|
|
2178
|
+
var ColumnSourceBindingSchema = object({
|
|
2179
|
+
of: AppNameSchema,
|
|
2180
|
+
field: string().min(1),
|
|
2181
|
+
transform: SourceTransformSchema.optional()
|
|
2182
|
+
}).strict();
|
|
2160
2183
|
var ColumnDefSchema = object({
|
|
2161
2184
|
kind: ColumnKindSchema,
|
|
2162
2185
|
required: boolean().optional(),
|
|
2163
2186
|
enum: array(string()).optional(),
|
|
2164
2187
|
index: boolean().optional(),
|
|
2165
2188
|
default: union([string(), number(), boolean()]).optional(),
|
|
2166
|
-
hidden: boolean().optional()
|
|
2189
|
+
hidden: boolean().optional(),
|
|
2190
|
+
source: ColumnSourceBindingSchema.optional()
|
|
2167
2191
|
}).superRefine((column, ctx) => {
|
|
2168
2192
|
if (column.kind === "enum") {
|
|
2169
2193
|
if (!column.enum || column.enum.length === 0) {
|
|
@@ -2225,8 +2249,23 @@ var UserConfigFieldSchema = object({
|
|
|
2225
2249
|
}
|
|
2226
2250
|
});
|
|
2227
2251
|
var UserConfigSchema = record(AppNameSchema, UserConfigFieldSchema);
|
|
2252
|
+
var SourceDefSchema = discriminatedUnion("connector", [
|
|
2253
|
+
object({
|
|
2254
|
+
connector: literal("script"),
|
|
2255
|
+
scriptId: string().uuid(),
|
|
2256
|
+
joinKey: AppNameSchema,
|
|
2257
|
+
args: record(string(), unknown()).optional(),
|
|
2258
|
+
connection: string().min(1).optional()
|
|
2259
|
+
}).strict(),
|
|
2260
|
+
object({
|
|
2261
|
+
connector: literal("swarm-tasks"),
|
|
2262
|
+
joinKey: AppNameSchema,
|
|
2263
|
+
config: record(string(), union([string(), number(), boolean()])).optional()
|
|
2264
|
+
}).strict()
|
|
2265
|
+
]);
|
|
2228
2266
|
var ModelDefSchema = object({
|
|
2229
|
-
columns: record(AppNameSchema, ColumnDefSchema)
|
|
2267
|
+
columns: record(AppNameSchema, ColumnDefSchema),
|
|
2268
|
+
sources: record(AppNameSchema, SourceDefSchema).optional()
|
|
2230
2269
|
}).superRefine((model, ctx) => {
|
|
2231
2270
|
const count = Object.keys(model.columns).length;
|
|
2232
2271
|
if (count < 1 || count > 40) {
|
|
@@ -2241,6 +2280,9 @@ var ModelDefSchema = object({
|
|
|
2241
2280
|
});
|
|
2242
2281
|
}
|
|
2243
2282
|
}
|
|
2283
|
+
if (Object.keys(model.sources ?? {}).length > 4) {
|
|
2284
|
+
ctx.addIssue({ code: "custom", path: ["sources"], message: "must define at most 4 sources" });
|
|
2285
|
+
}
|
|
2244
2286
|
});
|
|
2245
2287
|
var AppQueryParamRefSchema = object({
|
|
2246
2288
|
$param: AppNameSchema
|
|
@@ -2250,8 +2292,12 @@ var SYSTEM_COLUMN_KINDS = {
|
|
|
2250
2292
|
createdAt: "date",
|
|
2251
2293
|
updatedAt: "date",
|
|
2252
2294
|
createdBy: "string",
|
|
2253
|
-
updatedBy: "string"
|
|
2295
|
+
updatedBy: "string",
|
|
2296
|
+
source: "string",
|
|
2297
|
+
syncedAt: "date",
|
|
2298
|
+
stale: "boolean"
|
|
2254
2299
|
};
|
|
2300
|
+
var SORTABLE_SYSTEM_DATE_COLUMNS = new Set(["createdAt", "updatedAt", "syncedAt"]);
|
|
2255
2301
|
var AppQueryDefSchema = object({
|
|
2256
2302
|
model: AppNameSchema,
|
|
2257
2303
|
filter: record(string(), union([string(), number(), boolean(), AppQueryParamRefSchema])).optional(),
|
|
@@ -2271,6 +2317,11 @@ var AppActionDefSchema = discriminatedUnion("kind", [
|
|
|
2271
2317
|
kind: literal("task"),
|
|
2272
2318
|
prompt: string().min(1),
|
|
2273
2319
|
agentId: string().min(1).optional()
|
|
2320
|
+
}),
|
|
2321
|
+
object({
|
|
2322
|
+
kind: literal("sync"),
|
|
2323
|
+
model: AppNameSchema.optional(),
|
|
2324
|
+
source: AppNameSchema.optional()
|
|
2274
2325
|
})
|
|
2275
2326
|
]);
|
|
2276
2327
|
var AppPageParamSchema = object({
|
|
@@ -2419,7 +2470,7 @@ var AppDefinitionSchema = object({
|
|
|
2419
2470
|
}
|
|
2420
2471
|
}
|
|
2421
2472
|
const sortColumn = query.sort?.column;
|
|
2422
|
-
if (sortColumn && sortColumn
|
|
2473
|
+
if (sortColumn && !SORTABLE_SYSTEM_DATE_COLUMNS.has(sortColumn) && (!Object.hasOwn(model.columns, sortColumn) || model.columns[sortColumn].hidden === true)) {
|
|
2423
2474
|
ctx.addIssue({
|
|
2424
2475
|
code: "custom",
|
|
2425
2476
|
path: ["queries", queryName, "sort", "column"],
|
|
@@ -2456,19 +2507,209 @@ function flattenIssue(issue2, prefix = []) {
|
|
|
2456
2507
|
function appDefinitionIssues(error) {
|
|
2457
2508
|
return error.issues.flatMap((issue2) => flattenIssue(issue2));
|
|
2458
2509
|
}
|
|
2459
|
-
function
|
|
2460
|
-
const
|
|
2510
|
+
function collectScriptReferences(definition) {
|
|
2511
|
+
const references = new Map;
|
|
2512
|
+
const add = (scriptId, path) => {
|
|
2513
|
+
if (typeof scriptId !== "string" || scriptId.length === 0)
|
|
2514
|
+
return;
|
|
2515
|
+
const paths = references.get(scriptId);
|
|
2516
|
+
if (paths)
|
|
2517
|
+
paths.push(path);
|
|
2518
|
+
else
|
|
2519
|
+
references.set(scriptId, [path]);
|
|
2520
|
+
};
|
|
2461
2521
|
if (!isMergePatchObject(definition))
|
|
2462
|
-
return
|
|
2522
|
+
return references;
|
|
2463
2523
|
const actions = definition.actions;
|
|
2464
|
-
if (
|
|
2465
|
-
|
|
2466
|
-
|
|
2467
|
-
|
|
2468
|
-
|
|
2524
|
+
if (isMergePatchObject(actions)) {
|
|
2525
|
+
for (const [actionName, action] of Object.entries(actions)) {
|
|
2526
|
+
if (isMergePatchObject(action))
|
|
2527
|
+
add(action.scriptId, `actions.${actionName}`);
|
|
2528
|
+
}
|
|
2529
|
+
}
|
|
2530
|
+
const models = definition.models;
|
|
2531
|
+
if (isMergePatchObject(models)) {
|
|
2532
|
+
for (const [modelName, model] of Object.entries(models)) {
|
|
2533
|
+
if (!isMergePatchObject(model) || !isMergePatchObject(model.sources))
|
|
2534
|
+
continue;
|
|
2535
|
+
for (const [sourceName, source] of Object.entries(model.sources)) {
|
|
2536
|
+
if (isMergePatchObject(source)) {
|
|
2537
|
+
add(source.scriptId, `models.${modelName}.sources.${sourceName}`);
|
|
2538
|
+
}
|
|
2539
|
+
}
|
|
2469
2540
|
}
|
|
2470
2541
|
}
|
|
2471
|
-
return
|
|
2542
|
+
return references;
|
|
2543
|
+
}
|
|
2544
|
+
function foreignScriptForWriter(context, script) {
|
|
2545
|
+
if (script.scope !== "agent")
|
|
2546
|
+
return false;
|
|
2547
|
+
if (context.writerIsUser === true)
|
|
2548
|
+
return true;
|
|
2549
|
+
if (!context.writerAgentId)
|
|
2550
|
+
return false;
|
|
2551
|
+
return getSavedScriptOwnerAgentId(script) !== context.writerAgentId;
|
|
2552
|
+
}
|
|
2553
|
+
function scriptRefKey(scriptId, args, connection) {
|
|
2554
|
+
if (typeof scriptId !== "string" || scriptId.length === 0)
|
|
2555
|
+
return null;
|
|
2556
|
+
return JSON.stringify({ scriptId, args: args ?? null, connection: connection ?? null });
|
|
2557
|
+
}
|
|
2558
|
+
function collectScriptReferencePathMap(definition) {
|
|
2559
|
+
const byPath = new Map;
|
|
2560
|
+
if (!isMergePatchObject(definition))
|
|
2561
|
+
return byPath;
|
|
2562
|
+
const actions = definition.actions;
|
|
2563
|
+
if (isMergePatchObject(actions)) {
|
|
2564
|
+
for (const [actionName, action] of Object.entries(actions)) {
|
|
2565
|
+
if (!isMergePatchObject(action))
|
|
2566
|
+
continue;
|
|
2567
|
+
const key = scriptRefKey(action.scriptId, action.args, undefined);
|
|
2568
|
+
if (key)
|
|
2569
|
+
byPath.set(`actions.${actionName}`, key);
|
|
2570
|
+
}
|
|
2571
|
+
}
|
|
2572
|
+
const models = definition.models;
|
|
2573
|
+
if (isMergePatchObject(models)) {
|
|
2574
|
+
for (const [modelName, model] of Object.entries(models)) {
|
|
2575
|
+
if (!isMergePatchObject(model) || !isMergePatchObject(model.sources))
|
|
2576
|
+
continue;
|
|
2577
|
+
for (const [sourceName, source] of Object.entries(model.sources)) {
|
|
2578
|
+
if (!isMergePatchObject(source))
|
|
2579
|
+
continue;
|
|
2580
|
+
const key = scriptRefKey(source.scriptId, source.args, source.connection);
|
|
2581
|
+
if (key)
|
|
2582
|
+
byPath.set(`models.${modelName}.sources.${sourceName}`, key);
|
|
2583
|
+
}
|
|
2584
|
+
}
|
|
2585
|
+
}
|
|
2586
|
+
return byPath;
|
|
2587
|
+
}
|
|
2588
|
+
function modelSourceIssues(modelName, model, context, grandfatheredScriptRefs) {
|
|
2589
|
+
const issues = [];
|
|
2590
|
+
const sources = model.sources ?? {};
|
|
2591
|
+
const sourceNames = new Set(Object.keys(sources));
|
|
2592
|
+
for (const [sourceName, source] of Object.entries(sources)) {
|
|
2593
|
+
const path = `models.${modelName}.sources.${sourceName}`;
|
|
2594
|
+
const joinColumn = Object.hasOwn(model.columns, source.joinKey) ? model.columns[source.joinKey] : undefined;
|
|
2595
|
+
if (!joinColumn || joinColumn.hidden === true) {
|
|
2596
|
+
issues.push({
|
|
2597
|
+
path: `${path}.joinKey`,
|
|
2598
|
+
message: `unknown or hidden column "${source.joinKey}"`
|
|
2599
|
+
});
|
|
2600
|
+
} else if (joinColumn.kind !== "string") {
|
|
2601
|
+
issues.push({
|
|
2602
|
+
path: `${path}.joinKey`,
|
|
2603
|
+
message: `join key column "${source.joinKey}" must be a string column`
|
|
2604
|
+
});
|
|
2605
|
+
} else {
|
|
2606
|
+
if (joinColumn.source) {
|
|
2607
|
+
issues.push({
|
|
2608
|
+
path: `${path}.joinKey`,
|
|
2609
|
+
message: `join key column "${source.joinKey}" must not be bound to a source`
|
|
2610
|
+
});
|
|
2611
|
+
}
|
|
2612
|
+
if (joinColumn.required === true) {
|
|
2613
|
+
issues.push({
|
|
2614
|
+
path: `${path}.joinKey`,
|
|
2615
|
+
message: `join key column "${source.joinKey}" must not be required`
|
|
2616
|
+
});
|
|
2617
|
+
}
|
|
2618
|
+
if (joinColumn.default !== undefined) {
|
|
2619
|
+
issues.push({
|
|
2620
|
+
path: `${path}.joinKey`,
|
|
2621
|
+
message: `join key column "${source.joinKey}" must not declare a default`
|
|
2622
|
+
});
|
|
2623
|
+
}
|
|
2624
|
+
}
|
|
2625
|
+
if (source.connector !== "script")
|
|
2626
|
+
continue;
|
|
2627
|
+
const script = getScriptById(source.scriptId);
|
|
2628
|
+
if (!script) {
|
|
2629
|
+
issues.push({ path: `${path}.scriptId`, message: `script "${source.scriptId}" not found` });
|
|
2630
|
+
continue;
|
|
2631
|
+
}
|
|
2632
|
+
const runAs = resolveSyncRunAs(script);
|
|
2633
|
+
const grandfatheredRef = grandfatheredScriptRefs.get(path) === scriptRefKey(source.scriptId, source.args, source.connection);
|
|
2634
|
+
if (foreignScriptForWriter(context, script) && !grandfatheredRef) {
|
|
2635
|
+
issues.push({
|
|
2636
|
+
path: `${path}.scriptId`,
|
|
2637
|
+
message: `script "${source.scriptId}" is agent-scoped to another agent — reference a script you own or a global script`
|
|
2638
|
+
});
|
|
2639
|
+
} else if (script.scope !== "agent" && (context.writerIsUser === true || typeof context.writerAgentId === "string") && context.writerAgentId !== runAs && !grandfatheredRef) {
|
|
2640
|
+
issues.push({
|
|
2641
|
+
path: `${path}.scriptId`,
|
|
2642
|
+
message: `script "${source.scriptId}" syncs with agent "${runAs}"'s credentials — only that agent or the operator may wire or alter this source`
|
|
2643
|
+
});
|
|
2644
|
+
}
|
|
2645
|
+
if (source.connection !== undefined) {
|
|
2646
|
+
const reachable = listScriptConnections({ agentId: runAs });
|
|
2647
|
+
if (!reachable.some((connection) => connection.slug === source.connection)) {
|
|
2648
|
+
issues.push({
|
|
2649
|
+
path: `${path}.connection`,
|
|
2650
|
+
message: `connection "${source.connection}" not found or disabled for the sync run-as identity`
|
|
2651
|
+
});
|
|
2652
|
+
}
|
|
2653
|
+
}
|
|
2654
|
+
}
|
|
2655
|
+
for (const [columnName, column] of Object.entries(model.columns)) {
|
|
2656
|
+
const path = `models.${modelName}.columns.${columnName}`;
|
|
2657
|
+
if (!column.source) {
|
|
2658
|
+
if (sourceNames.size > 0 && column.required === true && column.hidden !== true && column.default === undefined) {
|
|
2659
|
+
issues.push({
|
|
2660
|
+
path,
|
|
2661
|
+
message: "required column on a model with sources must declare a default — sync-created rows cannot supply it"
|
|
2662
|
+
});
|
|
2663
|
+
}
|
|
2664
|
+
continue;
|
|
2665
|
+
}
|
|
2666
|
+
if (!sourceNames.has(column.source.of)) {
|
|
2667
|
+
issues.push({ path: `${path}.source.of`, message: `unknown source "${column.source.of}"` });
|
|
2668
|
+
}
|
|
2669
|
+
const transform = column.source.transform;
|
|
2670
|
+
if (transform && TRANSFORM_COLUMN_KIND[transform] !== column.kind) {
|
|
2671
|
+
issues.push({
|
|
2672
|
+
path: `${path}.source.transform`,
|
|
2673
|
+
message: `transform "${transform}" requires a ${TRANSFORM_COLUMN_KIND[transform]} column`
|
|
2674
|
+
});
|
|
2675
|
+
}
|
|
2676
|
+
if (column.required === true) {
|
|
2677
|
+
issues.push({
|
|
2678
|
+
path: `${path}.required`,
|
|
2679
|
+
message: "source-bound column must not be required"
|
|
2680
|
+
});
|
|
2681
|
+
}
|
|
2682
|
+
if (column.default !== undefined) {
|
|
2683
|
+
issues.push({
|
|
2684
|
+
path: `${path}.default`,
|
|
2685
|
+
message: "source-bound column must not declare a default"
|
|
2686
|
+
});
|
|
2687
|
+
}
|
|
2688
|
+
}
|
|
2689
|
+
return issues;
|
|
2690
|
+
}
|
|
2691
|
+
function syncActionIssues(name, action, models) {
|
|
2692
|
+
if (action.model !== undefined && !Object.hasOwn(models, action.model)) {
|
|
2693
|
+
return [{ path: `actions.${name}.model`, message: `unknown model "${action.model}"` }];
|
|
2694
|
+
}
|
|
2695
|
+
const candidates = action.model !== undefined ? [action.model] : Object.keys(models);
|
|
2696
|
+
const pairs = candidates.flatMap((modelName) => Object.keys(models[modelName]?.sources ?? {}).filter((sourceName) => action.source === undefined || sourceName === action.source));
|
|
2697
|
+
if (pairs.length > 0)
|
|
2698
|
+
return [];
|
|
2699
|
+
if (action.source !== undefined) {
|
|
2700
|
+
return [
|
|
2701
|
+
{
|
|
2702
|
+
path: `actions.${name}.source`,
|
|
2703
|
+
message: action.model !== undefined ? `unknown source "${action.source}" on model "${action.model}"` : `unknown source "${action.source}" — no model declares it`
|
|
2704
|
+
}
|
|
2705
|
+
];
|
|
2706
|
+
}
|
|
2707
|
+
if (action.model !== undefined) {
|
|
2708
|
+
return [
|
|
2709
|
+
{ path: `actions.${name}.model`, message: `model "${action.model}" declares no sources` }
|
|
2710
|
+
];
|
|
2711
|
+
}
|
|
2712
|
+
return [{ path: `actions.${name}`, message: "no model declares a source to sync" }];
|
|
2472
2713
|
}
|
|
2473
2714
|
function parseAppDefinition(input, elementContext = {}) {
|
|
2474
2715
|
if (isMergePatchObject(input) && Object.hasOwn(input, "page")) {
|
|
@@ -2505,8 +2746,15 @@ function parseAppDefinition(input, elementContext = {}) {
|
|
|
2505
2746
|
...crossPageDefinitionIssues(parsed.data, catalog_generated_default),
|
|
2506
2747
|
...elementDefinitionIssues(parsed.data, catalog_generated_default, elementContext)
|
|
2507
2748
|
];
|
|
2508
|
-
const
|
|
2749
|
+
const grandfatheredScriptRefs = collectScriptReferencePathMap(elementContext.existingDefinition);
|
|
2750
|
+
for (const [modelName, model] of Object.entries(parsed.data.models)) {
|
|
2751
|
+
issues.push(...modelSourceIssues(modelName, model, elementContext, grandfatheredScriptRefs));
|
|
2752
|
+
}
|
|
2509
2753
|
for (const [name, action] of Object.entries(parsed.data.actions ?? {})) {
|
|
2754
|
+
if (action.kind === "sync") {
|
|
2755
|
+
issues.push(...syncActionIssues(name, action, parsed.data.models));
|
|
2756
|
+
continue;
|
|
2757
|
+
}
|
|
2510
2758
|
if (action.kind !== "script")
|
|
2511
2759
|
continue;
|
|
2512
2760
|
const script = getScriptById(action.scriptId);
|
|
@@ -2517,7 +2765,7 @@ function parseAppDefinition(input, elementContext = {}) {
|
|
|
2517
2765
|
});
|
|
2518
2766
|
continue;
|
|
2519
2767
|
}
|
|
2520
|
-
if (elementContext
|
|
2768
|
+
if (foreignScriptForWriter(elementContext, script) && grandfatheredScriptRefs.get(`actions.${name}`) !== scriptRefKey(action.scriptId, action.args, undefined)) {
|
|
2521
2769
|
issues.push({
|
|
2522
2770
|
path: `actions.${name}.scriptId`,
|
|
2523
2771
|
message: `script "${action.scriptId}" is agent-scoped to another agent — reference a script you own or a global script`
|
|
@@ -2606,7 +2854,7 @@ function applyMergePatch(target, patch, path) {
|
|
|
2606
2854
|
if (!isMergePatchObject(patch))
|
|
2607
2855
|
return patch;
|
|
2608
2856
|
const result = isMergePatchObject(target) ? { ...target } : {};
|
|
2609
|
-
const entriesAreAtomic = path.length === 1 && path[0] === "actions" || path.length === 1 && path[0] === "elements" || path.length === 1 && path[0] === "userConfig" || path.length === 3 && path[0] === "models" && path[2] === "columns" || path.length === 3 && path[0] === "elements" && path[2] === "elements" || path.length === 3 && path[0] === "pages" && (path[2] === "elements" || path[2] === "params");
|
|
2857
|
+
const entriesAreAtomic = path.length === 1 && path[0] === "actions" || path.length === 1 && path[0] === "elements" || path.length === 1 && path[0] === "userConfig" || path.length === 3 && path[0] === "models" && path[2] === "columns" || path.length === 3 && path[0] === "models" && path[2] === "sources" || path.length === 3 && path[0] === "elements" && path[2] === "elements" || path.length === 3 && path[0] === "pages" && (path[2] === "elements" || path[2] === "params");
|
|
2610
2858
|
for (const [key, value] of Object.entries(patch)) {
|
|
2611
2859
|
if (value === null) {
|
|
2612
2860
|
delete result[key];
|
|
@@ -2626,6 +2874,7 @@ function applyAppDefinitionPatch(stored, patch) {
|
|
|
2626
2874
|
}
|
|
2627
2875
|
|
|
2628
2876
|
// src/apps/store.ts
|
|
2877
|
+
init_key();
|
|
2629
2878
|
init_db();
|
|
2630
2879
|
|
|
2631
2880
|
// src/apps/format-upgrades.ts
|
|
@@ -2749,9 +2998,9 @@ function nextTimestamp(previous) {
|
|
|
2749
2998
|
function createApp(input) {
|
|
2750
2999
|
const id = input.id ?? crypto.randomUUID();
|
|
2751
3000
|
const now = nextTimestamp();
|
|
2752
|
-
const row = getDb().prepare(`INSERT INTO apps (id, name, description, definition, created_at, updated_at)
|
|
2753
|
-
VALUES (?, ?, ?, ?, ?, ?)
|
|
2754
|
-
RETURNING id, name, description, definition, created_at, updated_at`).get(id, input.name, input.description ?? null, encodeDefinition(input.definition), now, now);
|
|
3001
|
+
const row = getDb().prepare(`INSERT INTO apps (id, name, description, definition, created_at, updated_at, "key")
|
|
3002
|
+
VALUES (?, ?, ?, ?, ?, ?, ?)
|
|
3003
|
+
RETURNING id, name, description, definition, created_at, updated_at`).get(id, input.name, input.description ?? null, encodeDefinition(input.definition), now, now, defaultAssetKey("app", id));
|
|
2755
3004
|
if (!row)
|
|
2756
3005
|
throw new Error("Failed to create app");
|
|
2757
3006
|
return decodeApp(row);
|
|
@@ -2789,4 +3038,4 @@ function deleteApp(id) {
|
|
|
2789
3038
|
return getDb().prepare("DELETE FROM apps WHERE id = ?").run(id).changes > 0;
|
|
2790
3039
|
}
|
|
2791
3040
|
|
|
2792
|
-
export { getSavedScriptOwnerAgentId, runSavedScriptAsAgent, AppNameSchema, isIso8601Date, SYSTEM_COLUMN_KINDS, AppElementsSchema, AppDefinitionSchema, parseAppDefinition, applyAppDefinitionPatch, upgradeAppDefinition, decodeAppDefinition, appDefinitionNeedsRepair, createApp, getApp, listApps, listAppRecords, updateApp, deleteApp };
|
|
3041
|
+
export { getSavedScriptOwnerAgentId, runSavedScriptAsAgent, resolveSyncRunAs, AppNameSchema, ColumnKindSchema, isIso8601Date, SYSTEM_COLUMN_KINDS, SORTABLE_SYSTEM_DATE_COLUMNS, AppElementsSchema, AppDefinitionSchema, collectScriptReferences, parseAppDefinition, applyAppDefinitionPatch, upgradeAppDefinition, decodeAppDefinition, appDefinitionNeedsRepair, createApp, getApp, listApps, listAppRecords, updateApp, deleteApp };
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import {
|
|
2
|
+
__esm,
|
|
3
|
+
__export
|
|
4
|
+
} from "./cli-p9swy5t3.js";
|
|
5
|
+
|
|
6
|
+
// node_modules/supports-color/index.js
|
|
7
|
+
var exports_supports_color = {};
|
|
8
|
+
__export(exports_supports_color, {
|
|
9
|
+
default: () => supports_color_default,
|
|
10
|
+
createSupportsColor: () => createSupportsColor
|
|
11
|
+
});
|
|
12
|
+
import process from "node:process";
|
|
13
|
+
import os from "node:os";
|
|
14
|
+
import tty from "node:tty";
|
|
15
|
+
function hasFlag(flag, argv = globalThis.Deno ? globalThis.Deno.args : process.argv) {
|
|
16
|
+
const prefix = flag.startsWith("-") ? "" : flag.length === 1 ? "-" : "--";
|
|
17
|
+
const position = argv.indexOf(prefix + flag);
|
|
18
|
+
const terminatorPosition = argv.indexOf("--");
|
|
19
|
+
return position !== -1 && (terminatorPosition === -1 || position < terminatorPosition);
|
|
20
|
+
}
|
|
21
|
+
function envForceColor() {
|
|
22
|
+
if (!("FORCE_COLOR" in env)) {
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
if (env.FORCE_COLOR === "true") {
|
|
26
|
+
return 1;
|
|
27
|
+
}
|
|
28
|
+
if (env.FORCE_COLOR === "false") {
|
|
29
|
+
return 0;
|
|
30
|
+
}
|
|
31
|
+
if (env.FORCE_COLOR.length === 0) {
|
|
32
|
+
return 1;
|
|
33
|
+
}
|
|
34
|
+
const level = Math.min(Number.parseInt(env.FORCE_COLOR, 10), 3);
|
|
35
|
+
if (![0, 1, 2, 3].includes(level)) {
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
return level;
|
|
39
|
+
}
|
|
40
|
+
function translateLevel(level) {
|
|
41
|
+
if (level === 0) {
|
|
42
|
+
return false;
|
|
43
|
+
}
|
|
44
|
+
return {
|
|
45
|
+
level,
|
|
46
|
+
hasBasic: true,
|
|
47
|
+
has256: level >= 2,
|
|
48
|
+
has16m: level >= 3
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
function _supportsColor(haveStream, { streamIsTTY, sniffFlags = true } = {}) {
|
|
52
|
+
const noFlagForceColor = envForceColor();
|
|
53
|
+
if (noFlagForceColor !== undefined) {
|
|
54
|
+
flagForceColor = noFlagForceColor;
|
|
55
|
+
}
|
|
56
|
+
const forceColor = sniffFlags ? flagForceColor : noFlagForceColor;
|
|
57
|
+
if (forceColor === 0) {
|
|
58
|
+
return 0;
|
|
59
|
+
}
|
|
60
|
+
if (sniffFlags) {
|
|
61
|
+
if (hasFlag("color=16m") || hasFlag("color=full") || hasFlag("color=truecolor")) {
|
|
62
|
+
return 3;
|
|
63
|
+
}
|
|
64
|
+
if (hasFlag("color=256")) {
|
|
65
|
+
return 2;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
if ("TF_BUILD" in env && "AGENT_NAME" in env) {
|
|
69
|
+
return 1;
|
|
70
|
+
}
|
|
71
|
+
if (haveStream && !streamIsTTY && forceColor === undefined) {
|
|
72
|
+
return 0;
|
|
73
|
+
}
|
|
74
|
+
const min = forceColor || 0;
|
|
75
|
+
if (env.TERM === "dumb") {
|
|
76
|
+
return min;
|
|
77
|
+
}
|
|
78
|
+
if (process.platform === "win32") {
|
|
79
|
+
const osRelease = os.release().split(".");
|
|
80
|
+
if (Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) {
|
|
81
|
+
return Number(osRelease[2]) >= 14931 ? 3 : 2;
|
|
82
|
+
}
|
|
83
|
+
return 1;
|
|
84
|
+
}
|
|
85
|
+
if ("CI" in env) {
|
|
86
|
+
if (["GITHUB_ACTIONS", "GITEA_ACTIONS", "CIRCLECI"].some((key) => (key in env))) {
|
|
87
|
+
return 3;
|
|
88
|
+
}
|
|
89
|
+
if (["TRAVIS", "APPVEYOR", "GITLAB_CI", "BUILDKITE", "DRONE"].some((sign) => (sign in env)) || env.CI_NAME === "codeship") {
|
|
90
|
+
return 1;
|
|
91
|
+
}
|
|
92
|
+
return min;
|
|
93
|
+
}
|
|
94
|
+
if ("TEAMCITY_VERSION" in env) {
|
|
95
|
+
return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env.TEAMCITY_VERSION) ? 1 : 0;
|
|
96
|
+
}
|
|
97
|
+
if (env.COLORTERM === "truecolor") {
|
|
98
|
+
return 3;
|
|
99
|
+
}
|
|
100
|
+
if (env.TERM === "xterm-kitty") {
|
|
101
|
+
return 3;
|
|
102
|
+
}
|
|
103
|
+
if (env.TERM === "xterm-ghostty") {
|
|
104
|
+
return 3;
|
|
105
|
+
}
|
|
106
|
+
if (env.TERM === "wezterm") {
|
|
107
|
+
return 3;
|
|
108
|
+
}
|
|
109
|
+
if ("TERM_PROGRAM" in env) {
|
|
110
|
+
const version = Number.parseInt((env.TERM_PROGRAM_VERSION || "").split(".")[0], 10);
|
|
111
|
+
switch (env.TERM_PROGRAM) {
|
|
112
|
+
case "iTerm.app": {
|
|
113
|
+
return version >= 3 ? 3 : 2;
|
|
114
|
+
}
|
|
115
|
+
case "Apple_Terminal": {
|
|
116
|
+
return 2;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
if (/-256(color)?$/i.test(env.TERM)) {
|
|
121
|
+
return 2;
|
|
122
|
+
}
|
|
123
|
+
if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env.TERM)) {
|
|
124
|
+
return 1;
|
|
125
|
+
}
|
|
126
|
+
if ("COLORTERM" in env) {
|
|
127
|
+
return 1;
|
|
128
|
+
}
|
|
129
|
+
return min;
|
|
130
|
+
}
|
|
131
|
+
function createSupportsColor(stream, options = {}) {
|
|
132
|
+
const level = _supportsColor(stream, {
|
|
133
|
+
streamIsTTY: stream && stream.isTTY,
|
|
134
|
+
...options
|
|
135
|
+
});
|
|
136
|
+
return translateLevel(level);
|
|
137
|
+
}
|
|
138
|
+
var env, flagForceColor, supportsColor, supports_color_default;
|
|
139
|
+
var init_supports_color = __esm(() => {
|
|
140
|
+
({ env } = process);
|
|
141
|
+
if (hasFlag("no-color") || hasFlag("no-colors") || hasFlag("color=false") || hasFlag("color=never")) {
|
|
142
|
+
flagForceColor = 0;
|
|
143
|
+
} else if (hasFlag("color") || hasFlag("colors") || hasFlag("color=true") || hasFlag("color=always")) {
|
|
144
|
+
flagForceColor = 1;
|
|
145
|
+
}
|
|
146
|
+
supportsColor = {
|
|
147
|
+
stdout: createSupportsColor({ isTTY: tty.isatty(1) }),
|
|
148
|
+
stderr: createSupportsColor({ isTTY: tty.isatty(2) })
|
|
149
|
+
};
|
|
150
|
+
supports_color_default = supportsColor;
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
export { exports_supports_color, init_supports_color };
|
|
@@ -214,10 +214,13 @@ function clampMaxTokensToContext(model, context, maxTokens) {
|
|
|
214
214
|
return Math.min(maxTokens, Math.max(MIN_MAX_TOKENS, available));
|
|
215
215
|
}
|
|
216
216
|
function buildBaseOptions(model, context, options, apiKey) {
|
|
217
|
+
const samplingParams = model.samplingParams || options?.samplingParams ? { ...model.samplingParams, ...options?.samplingParams } : undefined;
|
|
217
218
|
return {
|
|
218
219
|
temperature: options?.temperature,
|
|
220
|
+
samplingParams,
|
|
219
221
|
maxTokens: clampMaxTokensToContext(model, context, options?.maxTokens ?? model.maxTokens),
|
|
220
222
|
signal: options?.signal,
|
|
223
|
+
telemetryContext: options?.telemetryContext,
|
|
221
224
|
apiKey: apiKey || options?.apiKey,
|
|
222
225
|
fetch: options?.fetch,
|
|
223
226
|
transport: options?.transport,
|
|
@@ -234,6 +237,7 @@ function buildBaseOptions(model, context, options, apiKey) {
|
|
|
234
237
|
env: options?.env
|
|
235
238
|
};
|
|
236
239
|
}
|
|
240
|
+
var MIN_ANSWER_TOKENS = 1024;
|
|
237
241
|
function clampReasoning(effort) {
|
|
238
242
|
return effort === "xhigh" || effort === "max" ? "high" : effort;
|
|
239
243
|
}
|
|
@@ -245,12 +249,11 @@ function adjustMaxTokensForThinking(baseMaxTokens, modelMaxTokens, reasoningLeve
|
|
|
245
249
|
high: 16384
|
|
246
250
|
};
|
|
247
251
|
const budgets = { ...defaultBudgets, ...customBudgets };
|
|
248
|
-
const minOutputTokens = 1024;
|
|
249
252
|
const level = clampReasoning(reasoningLevel);
|
|
250
253
|
let thinkingBudget = budgets[level];
|
|
251
254
|
const maxTokens = baseMaxTokens === undefined ? modelMaxTokens : Math.min(baseMaxTokens + thinkingBudget, modelMaxTokens);
|
|
252
255
|
if (maxTokens <= thinkingBudget) {
|
|
253
|
-
thinkingBudget = Math.max(0, maxTokens -
|
|
256
|
+
thinkingBudget = Math.max(0, maxTokens - MIN_ANSWER_TOKENS);
|
|
254
257
|
}
|
|
255
258
|
return { maxTokens, thinkingBudget };
|
|
256
259
|
}
|
|
@@ -410,4 +413,4 @@ function transformMessages(messages, model, normalizeToolCallId) {
|
|
|
410
413
|
return result;
|
|
411
414
|
}
|
|
412
415
|
|
|
413
|
-
export { getGrammarToolInput, appendGrammarToolInputJsonDelta, resolveJsonSchemaStrictSampling, resolveGrammarConstrainedSampling, createGrammarToolInputProperties, clampMaxTokensToContext, buildBaseOptions, clampReasoning, adjustMaxTokensForThinking, transformMessages };
|
|
416
|
+
export { getGrammarToolInput, appendGrammarToolInputJsonDelta, resolveJsonSchemaStrictSampling, resolveGrammarConstrainedSampling, createGrammarToolInputProperties, clampMaxTokensToContext, buildBaseOptions, MIN_ANSWER_TOKENS, clampReasoning, adjustMaxTokensForThinking, transformMessages };
|
|
@@ -13727,4 +13727,4 @@ var init_external = __esm(() => {
|
|
|
13727
13727
|
config(en_default());
|
|
13728
13728
|
});
|
|
13729
13729
|
|
|
13730
|
-
export { NEVER, $constructor, clone, exports_util, $ZodError, prettifyError, parse, parseAsync, safeParse, safeParseAsync, $ZodType, $ZodObject, init_locales, toJSONSchema, init_json_schema_processors, init_core2 as init_core, exports_iso, safeParseAsync2 as safeParseAsync1, string2 as string, uuid2 as uuid, number2 as number, int, boolean2 as boolean, _null3 as _null, any, unknown, never, _void2 as _void, date3 as date, array, object, looseObject, union, discriminatedUnion, intersection, record, _enum2 as _enum, literal, ZodOptional, optional, nullable, lazy, custom, preprocess, ZodIssueCode, exports_coerce, exports_external, init_external };
|
|
13730
|
+
export { NEVER, $constructor, $brand, config, clone, exports_util, $ZodError, flattenError, formatError, treeifyError, prettifyError, parse, parseAsync, safeParse, safeParseAsync, exports_regexes, $ZodType, $ZodObject, exports_locales, init_locales, $output, $input, registry, globalRegistry, TimePrecision, _lt, _lte, _gt, _gte, _positive, _negative, _nonpositive, _nonnegative, _multipleOf, _maxSize, _minSize, _size, _maxLength, _minLength, _length, _regex, _lowercase, _uppercase, _includes, _startsWith, _endsWith, _property, _mime, _overwrite, _normalize, _trim, _toLowerCase, _toUpperCase, _slugify, toJSONSchema, init_json_schema_processors, exports_core2 as exports_core, init_core2 as init_core, ZodISODateTime, ZodISODate, ZodISOTime, ZodISODuration, exports_iso, ZodError, ZodRealError, parse3 as parse1, parseAsync2 as parseAsync1, safeParse2 as safeParse1, safeParseAsync2 as safeParseAsync1, encode2 as encode, decode2 as decode, encodeAsync2 as encodeAsync, decodeAsync2 as decodeAsync, safeEncode2 as safeEncode, safeDecode2 as safeDecode, safeEncodeAsync2 as safeEncodeAsync, safeDecodeAsync2 as safeDecodeAsync, ZodType, _ZodString, ZodString, string2 as string, ZodStringFormat, ZodEmail, email2 as email, ZodGUID, guid2 as guid, ZodUUID, uuid2 as uuid, uuidv4, uuidv6, uuidv7, ZodURL, url, httpUrl, ZodEmoji, emoji2 as emoji, ZodNanoID, nanoid2 as nanoid, ZodCUID, cuid3 as cuid, ZodCUID2, cuid22 as cuid2, ZodULID, ulid2 as ulid, ZodXID, xid2 as xid, ZodKSUID, ksuid2 as ksuid, ZodIPv4, ipv42 as ipv4, ZodMAC, mac2 as mac, ZodIPv6, ipv62 as ipv6, ZodCIDRv4, cidrv42 as cidrv4, ZodCIDRv6, cidrv62 as cidrv6, ZodBase64, base642 as base64, ZodBase64URL, base64url2 as base64url, ZodE164, e1642 as e164, ZodJWT, jwt, ZodCustomStringFormat, stringFormat, hostname2 as hostname, hex2 as hex, hash, ZodNumber, number2 as number, ZodNumberFormat, int, float32, float64, int32, uint32, ZodBoolean, boolean2 as boolean, ZodBigInt, bigint2 as bigint, ZodBigIntFormat, int64, uint64, ZodSymbol, symbol, ZodUndefined, _undefined3 as _undefined, ZodNull, _null3 as _null, ZodAny, any, ZodUnknown, unknown, ZodNever, never, ZodVoid, _void2 as _void, ZodDate, date3 as date, ZodArray, array, keyof, ZodObject, object, strictObject, looseObject, ZodUnion, union, ZodXor, xor, ZodDiscriminatedUnion, discriminatedUnion, ZodIntersection, intersection, ZodTuple, tuple, ZodRecord, record, partialRecord, looseRecord, ZodMap, map, ZodSet, set, ZodEnum, _enum2 as _enum, nativeEnum, ZodLiteral, literal, ZodFile, file, ZodTransform, transform, ZodOptional, optional, ZodNullable, nullable, nullish2 as nullish, ZodDefault, _default2 as _default, ZodPrefault, prefault, ZodNonOptional, nonoptional, ZodSuccess, success, ZodCatch, _catch2 as _catch, ZodNaN, nan, ZodPipe, pipe, ZodCodec, codec, ZodReadonly, readonly, ZodTemplateLiteral, templateLiteral, ZodLazy, lazy, ZodPromise, promise, ZodFunction, _function, ZodCustom, check, custom, refine, superRefine, describe2 as describe, meta2 as meta, _instanceof, stringbool, json, preprocess, ZodIssueCode, setErrorMap, getErrorMap, ZodFirstPartyTypeKind, fromJSONSchema, exports_coerce, exports_external, init_external };
|
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
} from "./cli-psrqtw2m.js";
|
|
14
14
|
import {
|
|
15
15
|
summarizeSession
|
|
16
|
-
} from "./cli-
|
|
16
|
+
} from "./cli-0rcyq6d9.js";
|
|
17
17
|
import {
|
|
18
18
|
CTX_MODE_NUDGE_EVERY
|
|
19
19
|
} from "./cli-zm7njwzd.js";
|
|
@@ -26,7 +26,7 @@ import {
|
|
|
26
26
|
buildRatingsFromLlm,
|
|
27
27
|
fetchRetrievalsForTask,
|
|
28
28
|
postRatings
|
|
29
|
-
} from "./cli-
|
|
29
|
+
} from "./cli-2wadx7p2.js";
|
|
30
30
|
import {
|
|
31
31
|
CodexOAuthRefreshError,
|
|
32
32
|
credentialsToAuthJson,
|