@homeflare/alchemy 0.52.0 → 0.53.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/dist/grafana/folder-permission.d.ts +76 -0
- package/dist/grafana/folder-permission.d.ts.map +1 -0
- package/dist/grafana/index.d.ts +3 -1
- package/dist/grafana/index.d.ts.map +1 -1
- package/dist/grafana/index.js +133 -46
- package/dist/grafana/index.js.map +7 -5
- package/dist/grafana/providers.d.ts +1 -1
- package/dist/grafana/providers.d.ts.map +1 -1
- package/dist/grafana/provisioned.d.ts +1 -1
- package/dist/grafana/provisioned.d.ts.map +1 -1
- package/dist/grafana/team.d.ts +64 -0
- package/dist/grafana/team.d.ts.map +1 -0
- package/dist/litellm/fake-marketplace-litellm.d.ts +33 -0
- package/dist/litellm/fake-marketplace-litellm.d.ts.map +1 -0
- package/dist/litellm/index.d.ts +1 -0
- package/dist/litellm/index.d.ts.map +1 -1
- package/dist/litellm/index.js +530 -329
- package/dist/litellm/index.js.map +7 -4
- package/dist/litellm/marketplace-form.d.ts +21 -0
- package/dist/litellm/marketplace-form.d.ts.map +1 -0
- package/dist/litellm/marketplace-operations.d.ts +27 -0
- package/dist/litellm/marketplace-operations.d.ts.map +1 -0
- package/dist/litellm/marketplace-plugin.d.ts +57 -0
- package/dist/litellm/marketplace-plugin.d.ts.map +1 -0
- package/dist/litellm/marketplace-types.d.ts +55 -0
- package/dist/litellm/marketplace-types.d.ts.map +1 -0
- package/dist/litellm/providers.d.ts +1 -1
- package/dist/litellm/providers.d.ts.map +1 -1
- package/docs/litellm-marketplace.md +59 -0
- package/docs/litellm.md +1 -0
- package/package.json +1 -1
- package/src/grafana/folder-permission.test.ts +107 -0
- package/src/grafana/folder-permission.ts +128 -0
- package/src/grafana/index.ts +10 -1
- package/src/grafana/providers.ts +4 -0
- package/src/grafana/provisioned.ts +1 -1
- package/src/grafana/team.test.ts +108 -0
- package/src/grafana/team.ts +105 -0
- package/src/litellm/fake-marketplace-litellm.test.ts +51 -0
- package/src/litellm/fake-marketplace-litellm.ts +134 -0
- package/src/litellm/index.ts +8 -0
- package/src/litellm/marketplace-form.ts +160 -0
- package/src/litellm/marketplace-operations.ts +76 -0
- package/src/litellm/marketplace-plugin-replace.test.ts +68 -0
- package/src/litellm/marketplace-plugin.test.ts +181 -0
- package/src/litellm/marketplace-plugin.ts +156 -0
- package/src/litellm/marketplace-types.ts +53 -0
- package/src/litellm/providers.ts +2 -0
- package/src/litellm/registry-exports.test.ts +6 -0
package/dist/litellm/index.js
CHANGED
|
@@ -1557,7 +1557,7 @@ var accessGroupHandlers = {
|
|
|
1557
1557
|
list: () => Effect20.succeed([])
|
|
1558
1558
|
};
|
|
1559
1559
|
var LiteLLMAccessGroupProvider = () => Provider5.effect(LiteLLMAccessGroup, Effect20.succeed(LiteLLMAccessGroup.Provider.of(accessGroupHandlers)));
|
|
1560
|
-
// src/litellm/
|
|
1560
|
+
// src/litellm/marketplace-plugin.ts
|
|
1561
1561
|
import { Resource as Resource6 } from "alchemy";
|
|
1562
1562
|
import { Unowned as Unowned7 } from "alchemy/AdoptPolicy";
|
|
1563
1563
|
import { isResolved as isResolved6 } from "alchemy/Diff";
|
|
@@ -1565,9 +1565,207 @@ import * as Provider6 from "alchemy/Provider";
|
|
|
1565
1565
|
import * as Effect22 from "effect/Effect";
|
|
1566
1566
|
import * as Predicate7 from "effect/Predicate";
|
|
1567
1567
|
|
|
1568
|
+
// src/litellm/marketplace-form.ts
|
|
1569
|
+
var TEXT = ["description", "version", "domain", "namespace", "category", "homepage"];
|
|
1570
|
+
var SOURCE_KINDS = new Set(["github", "url", "git-subdir", "archive"]);
|
|
1571
|
+
var firstProblem4 = (props) => {
|
|
1572
|
+
if (!/^[a-z0-9]+(-[a-z0-9]+)*$/.test(String(props.pluginName))) {
|
|
1573
|
+
return "`pluginName` must be kebab-case (lowercase letters, digits and single hyphens)";
|
|
1574
|
+
}
|
|
1575
|
+
const source = props.source;
|
|
1576
|
+
if (source === undefined || isBlank3(source["source"])) {
|
|
1577
|
+
return "`source` needs a `source` kind (github, url, git-subdir or archive)";
|
|
1578
|
+
}
|
|
1579
|
+
if (!SOURCE_KINDS.has(String(source["source"]))) {
|
|
1580
|
+
return `\`source.source\` must be github, url, git-subdir or archive`;
|
|
1581
|
+
}
|
|
1582
|
+
for (const [key, value5] of Object.entries(source)) {
|
|
1583
|
+
if (isBlank3(key) || isBlank3(value5))
|
|
1584
|
+
return `\`source.${key}\` is blank`;
|
|
1585
|
+
}
|
|
1586
|
+
for (const field of TEXT) {
|
|
1587
|
+
if (props[field] !== undefined && isBlank3(props[field])) {
|
|
1588
|
+
return `\`${field}\` is blank; leave it out to keep the live text`;
|
|
1589
|
+
}
|
|
1590
|
+
}
|
|
1591
|
+
if (props.author !== undefined && isBlank3(props.author.name))
|
|
1592
|
+
return "`author.name` is blank";
|
|
1593
|
+
const bad = firstBadEntry(props.keywords ?? []);
|
|
1594
|
+
if (bad !== undefined)
|
|
1595
|
+
return `\`keywords\` has a blank or padded entry (${JSON.stringify(bad)})`;
|
|
1596
|
+
const twice = firstDuplicate(props.keywords ?? []);
|
|
1597
|
+
if (twice !== undefined)
|
|
1598
|
+
return `\`keywords\` lists ${JSON.stringify(twice)} twice`;
|
|
1599
|
+
return;
|
|
1600
|
+
};
|
|
1601
|
+
var sourceOf = (value5) => Object.fromEntries(Object.entries(asRow(value5) ?? {}).filter((entry) => typeof entry[1] === "string"));
|
|
1602
|
+
var toAttributes6 = (value5) => {
|
|
1603
|
+
const row = asRow(value5);
|
|
1604
|
+
if (row === undefined)
|
|
1605
|
+
return;
|
|
1606
|
+
const pluginId = row["id"];
|
|
1607
|
+
const pluginName = row["name"];
|
|
1608
|
+
if (typeof pluginId !== "string" || typeof pluginName !== "string")
|
|
1609
|
+
return;
|
|
1610
|
+
const author = asRow(row["author"]);
|
|
1611
|
+
return {
|
|
1612
|
+
author: author !== undefined && typeof author["name"] === "string" ? { email: stringOrNull(author["email"]), name: author["name"] } : null,
|
|
1613
|
+
category: stringOrNull(row["category"]),
|
|
1614
|
+
description: stringOrNull(row["description"]),
|
|
1615
|
+
domain: stringOrNull(row["domain"]),
|
|
1616
|
+
enabled: row["enabled"] === true,
|
|
1617
|
+
homepage: stringOrNull(row["homepage"]),
|
|
1618
|
+
keywords: canonical2(stringsOf(row["keywords"])),
|
|
1619
|
+
namespace: stringOrNull(row["namespace"]),
|
|
1620
|
+
pluginId,
|
|
1621
|
+
pluginName,
|
|
1622
|
+
source: sourceOf(row["source"]),
|
|
1623
|
+
version: stringOrNull(row["version"])
|
|
1624
|
+
};
|
|
1625
|
+
};
|
|
1626
|
+
var sameSource = (left, right) => {
|
|
1627
|
+
const a = Object.entries(left).sort(([x], [y]) => x.localeCompare(y));
|
|
1628
|
+
const b = Object.entries(right).sort(([x], [y]) => x.localeCompare(y));
|
|
1629
|
+
return a.length === b.length && a.every(([k, v], i) => k === b[i]?.[0] && v === b[i]?.[1]);
|
|
1630
|
+
};
|
|
1631
|
+
var differing5 = (live, props) => {
|
|
1632
|
+
const fields = [];
|
|
1633
|
+
if (!sameSource(live.source, props.source))
|
|
1634
|
+
fields.push("source");
|
|
1635
|
+
for (const field of TEXT) {
|
|
1636
|
+
if (props[field] !== undefined && live[field] !== props[field])
|
|
1637
|
+
fields.push(field);
|
|
1638
|
+
}
|
|
1639
|
+
if (props.keywords !== undefined && !sameSet2(live.keywords, props.keywords)) {
|
|
1640
|
+
fields.push("keywords");
|
|
1641
|
+
}
|
|
1642
|
+
if (props.author !== undefined) {
|
|
1643
|
+
const same = live.author?.name === props.author.name && (props.author.email === undefined || live.author.email === props.author.email);
|
|
1644
|
+
if (!same)
|
|
1645
|
+
fields.push("author");
|
|
1646
|
+
}
|
|
1647
|
+
if (live.enabled !== (props.enabled ?? true))
|
|
1648
|
+
fields.push("enabled");
|
|
1649
|
+
return fields;
|
|
1650
|
+
};
|
|
1651
|
+
var metadata = (props, live) => {
|
|
1652
|
+
const author = props.author ? { name: props.author.name } : live?.author ? { name: live.author.name } : undefined;
|
|
1653
|
+
if (author !== undefined) {
|
|
1654
|
+
const keep = props.author?.email ?? live?.author?.email;
|
|
1655
|
+
if (keep !== undefined && keep !== null) {
|
|
1656
|
+
author.email = keep;
|
|
1657
|
+
}
|
|
1658
|
+
}
|
|
1659
|
+
const keywords = props.keywords ?? (live?.keywords.length ? live.keywords : undefined);
|
|
1660
|
+
return {
|
|
1661
|
+
...author === undefined ? {} : { author },
|
|
1662
|
+
...Object.fromEntries(TEXT.flatMap((field) => {
|
|
1663
|
+
const value5 = props[field] ?? live?.[field] ?? undefined;
|
|
1664
|
+
return value5 === undefined ? [] : [[field, value5]];
|
|
1665
|
+
})),
|
|
1666
|
+
...keywords === undefined ? {} : { keywords: [...keywords] },
|
|
1667
|
+
source: { ...props.source }
|
|
1668
|
+
};
|
|
1669
|
+
};
|
|
1670
|
+
var registerBody = (props) => ({
|
|
1671
|
+
...metadata(props),
|
|
1672
|
+
name: props.pluginName
|
|
1673
|
+
});
|
|
1674
|
+
var updateBody5 = (props, live) => metadata(props, live);
|
|
1675
|
+
|
|
1676
|
+
// src/litellm/marketplace-operations.ts
|
|
1677
|
+
import * as cc from "@distilled.cloud/litellm/claude_code_marketplace";
|
|
1678
|
+
import * as Effect21 from "effect/Effect";
|
|
1679
|
+
var RESOURCE3 = "LiteLLM.ClaudeCodeMarketplacePlugin";
|
|
1680
|
+
var listPlugins = () => throughFetch(cc.listPluginsClaudeCodePluginsGet({})).pipe(Effect21.flatMap((response) => {
|
|
1681
|
+
const items = asRow(bodyOf(response))?.["plugins"];
|
|
1682
|
+
const parsed = Array.isArray(items) ? items.map(toAttributes6) : undefined;
|
|
1683
|
+
return parsed !== undefined && parsed.every((row) => row !== undefined) ? Effect21.succeed(parsed) : Effect21.fail(new LitellmRegistryUnreadableError({
|
|
1684
|
+
reason: "no plugins array of rows with an id and a name",
|
|
1685
|
+
resource: RESOURCE3
|
|
1686
|
+
}));
|
|
1687
|
+
}));
|
|
1688
|
+
var registerPlugin = (body) => throughFetch(cc.registerPluginClaudeCodePluginsPost(body)).pipe(Effect21.asVoid);
|
|
1689
|
+
var updatePlugin = (name, body) => throughFetch(cc.updatePluginClaudeCodePluginsPluginNamePut({ ...body, plugin_name: name })).pipe(Effect21.asVoid);
|
|
1690
|
+
var setEnabled = (name, enabled) => throughFetch(enabled ? cc.enablePluginClaudeCodePluginsPluginNameEnablePost({ plugin_name: name }) : cc.disablePluginClaudeCodePluginsPluginNameDisablePost({ plugin_name: name })).pipe(Effect21.asVoid);
|
|
1691
|
+
var deletePlugin = (name) => throughFetch(cc.deletePluginClaudeCodePluginsPluginNameDelete({ plugin_name: name })).pipe(Effect21.asVoid, Effect21.catch((original) => listPlugins().pipe(Effect21.catch(() => Effect21.fail(original)), Effect21.flatMap((rows) => rows.some((row) => row.pluginName === name) ? Effect21.fail(original) : Effect21.void))));
|
|
1692
|
+
|
|
1693
|
+
// src/litellm/marketplace-plugin.ts
|
|
1694
|
+
var RESOURCE4 = "LiteLLM.ClaudeCodeMarketplacePlugin";
|
|
1695
|
+
var LiteLLMClaudeCodeMarketplacePlugin = Resource6("LiteLLM.ClaudeCodeMarketplacePlugin", { defaultRemovalPolicy: "retain" });
|
|
1696
|
+
var isLiteLLMClaudeCodeMarketplacePlugin = (value5) => Predicate7.hasProperty(value5, "Type") && value5.Type === "LiteLLM.ClaudeCodeMarketplacePlugin";
|
|
1697
|
+
var locate4 = (rows, props, output) => rows.find((row) => row.pluginName === (output?.pluginName ?? props.pluginName));
|
|
1698
|
+
var findNamed = (name) => listPlugins().pipe(Effect22.map((rows) => rows.find((row) => row.pluginName === name)));
|
|
1699
|
+
var marketplacePluginHandlers = {
|
|
1700
|
+
read: ({
|
|
1701
|
+
olds,
|
|
1702
|
+
output
|
|
1703
|
+
}) => Effect22.gen(function* () {
|
|
1704
|
+
if (output === undefined) {
|
|
1705
|
+
yield* dieIfInvalid(RESOURCE4, String(olds.pluginName), firstProblem4(olds));
|
|
1706
|
+
}
|
|
1707
|
+
const live = locate4(yield* listPlugins(), olds, output);
|
|
1708
|
+
if (live === undefined)
|
|
1709
|
+
return;
|
|
1710
|
+
return output === undefined ? Unowned7(live) : live;
|
|
1711
|
+
}),
|
|
1712
|
+
diff: ({
|
|
1713
|
+
news,
|
|
1714
|
+
output
|
|
1715
|
+
}) => Effect22.gen(function* () {
|
|
1716
|
+
if (!isResolved6(news))
|
|
1717
|
+
return;
|
|
1718
|
+
yield* failIfInvalid(RESOURCE4, String(news.pluginName), firstProblem4(news));
|
|
1719
|
+
if (output === undefined)
|
|
1720
|
+
return;
|
|
1721
|
+
if (output.pluginName !== news.pluginName)
|
|
1722
|
+
return { action: "replace" };
|
|
1723
|
+
return differing5(output, news).length === 0 ? { action: "noop" } : { action: "update" };
|
|
1724
|
+
}),
|
|
1725
|
+
reconcile: ({
|
|
1726
|
+
news,
|
|
1727
|
+
output
|
|
1728
|
+
}) => Effect22.gen(function* () {
|
|
1729
|
+
yield* failIfInvalid(RESOURCE4, String(news.pluginName), firstProblem4(news));
|
|
1730
|
+
const before = locate4(yield* listPlugins(), news, output);
|
|
1731
|
+
if (before === undefined)
|
|
1732
|
+
yield* registerPlugin(registerBody(news));
|
|
1733
|
+
else if (differing5(before, news).some((field) => field !== "enabled")) {
|
|
1734
|
+
yield* updatePlugin(news.pluginName, updateBody5(news, before));
|
|
1735
|
+
}
|
|
1736
|
+
const written = yield* findNamed(news.pluginName);
|
|
1737
|
+
if (written !== undefined && written.enabled !== (news.enabled ?? true)) {
|
|
1738
|
+
yield* setEnabled(news.pluginName, news.enabled ?? true);
|
|
1739
|
+
}
|
|
1740
|
+
const after = yield* findNamed(news.pluginName);
|
|
1741
|
+
if (after === undefined) {
|
|
1742
|
+
return yield* Effect22.fail(new LitellmRegistryAbsentAfterWriteError({ name: news.pluginName, resource: RESOURCE4 }));
|
|
1743
|
+
}
|
|
1744
|
+
const left = differing5(after, news);
|
|
1745
|
+
if (left.length > 0) {
|
|
1746
|
+
return yield* Effect22.fail(new LitellmRegistryNotConvergedError({
|
|
1747
|
+
fields: left,
|
|
1748
|
+
name: news.pluginName,
|
|
1749
|
+
resource: RESOURCE4
|
|
1750
|
+
}));
|
|
1751
|
+
}
|
|
1752
|
+
return after;
|
|
1753
|
+
}),
|
|
1754
|
+
delete: ({ output }) => deletePlugin(output.pluginName),
|
|
1755
|
+
list: () => Effect22.succeed([])
|
|
1756
|
+
};
|
|
1757
|
+
var LiteLLMClaudeCodeMarketplacePluginProvider = () => Provider6.effect(LiteLLMClaudeCodeMarketplacePlugin, Effect22.succeed(LiteLLMClaudeCodeMarketplacePlugin.Provider.of(marketplacePluginHandlers)));
|
|
1758
|
+
// src/litellm/policy-attachment.ts
|
|
1759
|
+
import { Resource as Resource7 } from "alchemy";
|
|
1760
|
+
import { Unowned as Unowned8 } from "alchemy/AdoptPolicy";
|
|
1761
|
+
import { isResolved as isResolved7 } from "alchemy/Diff";
|
|
1762
|
+
import * as Provider7 from "alchemy/Provider";
|
|
1763
|
+
import * as Effect24 from "effect/Effect";
|
|
1764
|
+
import * as Predicate8 from "effect/Predicate";
|
|
1765
|
+
|
|
1568
1766
|
// src/litellm/policy-attachment-form.ts
|
|
1569
1767
|
var SELECTORS = ["teams", "keys", "models", "tags"];
|
|
1570
|
-
var
|
|
1768
|
+
var firstProblem5 = (props) => {
|
|
1571
1769
|
if (isBlank3(props.policyName) || props.policyName !== props.policyName.trim()) {
|
|
1572
1770
|
return "`policyName` must be a non-blank name with no leading or trailing space";
|
|
1573
1771
|
}
|
|
@@ -1590,7 +1788,7 @@ var firstProblem4 = (props) => {
|
|
|
1590
1788
|
}
|
|
1591
1789
|
return;
|
|
1592
1790
|
};
|
|
1593
|
-
var
|
|
1791
|
+
var toAttributes7 = (value5) => {
|
|
1594
1792
|
const row = asRow(value5);
|
|
1595
1793
|
if (row === undefined)
|
|
1596
1794
|
return;
|
|
@@ -1610,7 +1808,7 @@ var toAttributes6 = (value5) => {
|
|
|
1610
1808
|
};
|
|
1611
1809
|
};
|
|
1612
1810
|
var isConfigRow = (value5) => asRow(value5)?.["definition_location"] === "config";
|
|
1613
|
-
var
|
|
1811
|
+
var differing6 = (live, props) => {
|
|
1614
1812
|
const fields = [];
|
|
1615
1813
|
if (live.policyName !== props.policyName)
|
|
1616
1814
|
fields.push("policy_name");
|
|
@@ -1635,105 +1833,105 @@ var createBody6 = (props) => ({
|
|
|
1635
1833
|
|
|
1636
1834
|
// src/litellm/policy-attachment-operations.ts
|
|
1637
1835
|
import * as policies from "@distilled.cloud/litellm/policy_engine";
|
|
1638
|
-
import * as
|
|
1639
|
-
var
|
|
1640
|
-
var unreadable = (reason) => new LitellmRegistryUnreadableError({ reason, resource:
|
|
1641
|
-
var listAttachments = () => throughFetch(policies.listPolicyAttachmentsPoliciesAttachmentsListGet({})).pipe(
|
|
1836
|
+
import * as Effect23 from "effect/Effect";
|
|
1837
|
+
var RESOURCE5 = "LiteLLM.PolicyAttachment";
|
|
1838
|
+
var unreadable = (reason) => new LitellmRegistryUnreadableError({ reason, resource: RESOURCE5 });
|
|
1839
|
+
var listAttachments = () => throughFetch(policies.listPolicyAttachmentsPoliciesAttachmentsListGet({})).pipe(Effect23.flatMap((response) => {
|
|
1642
1840
|
const rows = asRow(bodyOf(response))?.["attachments"];
|
|
1643
1841
|
if (rows === undefined)
|
|
1644
|
-
return
|
|
1842
|
+
return Effect23.succeed([]);
|
|
1645
1843
|
if (!Array.isArray(rows))
|
|
1646
|
-
return
|
|
1647
|
-
const parsed = rows.filter((row) => !isConfigRow(row)).map(
|
|
1648
|
-
return parsed.every((each) => each !== undefined) ?
|
|
1844
|
+
return Effect23.fail(unreadable("attachments is not an array"));
|
|
1845
|
+
const parsed = rows.filter((row) => !isConfigRow(row)).map(toAttributes7);
|
|
1846
|
+
return parsed.every((each) => each !== undefined) ? Effect23.succeed(parsed) : Effect23.fail(unreadable("an attachment has no id or policy name"));
|
|
1649
1847
|
}));
|
|
1650
|
-
var createAttachment = (body) => throughFetch(policies.createPolicyAttachmentPoliciesAttachmentsPost(body)).pipe(
|
|
1848
|
+
var createAttachment = (body) => throughFetch(policies.createPolicyAttachmentPoliciesAttachmentsPost(body)).pipe(Effect23.map((response) => toAttributes7(bodyOf(response))));
|
|
1651
1849
|
var deleteAttachment = (attachmentId) => throughFetch(policies.deletePolicyAttachmentPoliciesAttachmentsAttachmentIdDelete({
|
|
1652
1850
|
attachment_id: attachmentId
|
|
1653
|
-
})).pipe(
|
|
1851
|
+
})).pipe(Effect23.asVoid, Effect23.catch((original) => listAttachments().pipe(Effect23.catch(() => Effect23.fail(original)), Effect23.flatMap((rows) => rows.some((row) => row.attachmentId === attachmentId) ? Effect23.fail(original) : Effect23.void))));
|
|
1654
1852
|
|
|
1655
1853
|
// src/litellm/policy-attachment.ts
|
|
1656
|
-
var
|
|
1657
|
-
var LiteLLMPolicyAttachment =
|
|
1658
|
-
var isLiteLLMPolicyAttachment = (value5) =>
|
|
1659
|
-
var
|
|
1854
|
+
var RESOURCE6 = "LiteLLM.PolicyAttachment";
|
|
1855
|
+
var LiteLLMPolicyAttachment = Resource7("LiteLLM.PolicyAttachment");
|
|
1856
|
+
var isLiteLLMPolicyAttachment = (value5) => Predicate8.hasProperty(value5, "Type") && value5.Type === "LiteLLM.PolicyAttachment";
|
|
1857
|
+
var locate5 = (rows, props, output) => {
|
|
1660
1858
|
if (output !== undefined) {
|
|
1661
|
-
return
|
|
1859
|
+
return Effect24.succeed(rows.find((row) => row.attachmentId === output.attachmentId));
|
|
1662
1860
|
}
|
|
1663
|
-
const equal = rows.filter((row) =>
|
|
1664
|
-
return equal.length > 1 ?
|
|
1861
|
+
const equal = rows.filter((row) => differing6(row, props).length === 0);
|
|
1862
|
+
return equal.length > 1 ? Effect24.fail(new LitellmRegistryAmbiguousError({
|
|
1665
1863
|
ids: equal.map((row) => row.attachmentId),
|
|
1666
1864
|
name: props.policyName,
|
|
1667
|
-
resource:
|
|
1668
|
-
})) :
|
|
1865
|
+
resource: RESOURCE6
|
|
1866
|
+
})) : Effect24.succeed(equal[0]);
|
|
1669
1867
|
};
|
|
1670
1868
|
var policyAttachmentHandlers = {
|
|
1671
1869
|
read: ({
|
|
1672
1870
|
olds,
|
|
1673
1871
|
output
|
|
1674
|
-
}) =>
|
|
1872
|
+
}) => Effect24.gen(function* () {
|
|
1675
1873
|
if (output === undefined) {
|
|
1676
|
-
yield* dieIfInvalid(
|
|
1874
|
+
yield* dieIfInvalid(RESOURCE6, String(olds.policyName), firstProblem5(olds));
|
|
1677
1875
|
}
|
|
1678
|
-
const live = yield*
|
|
1876
|
+
const live = yield* locate5(yield* listAttachments(), olds, output);
|
|
1679
1877
|
if (live === undefined)
|
|
1680
1878
|
return;
|
|
1681
|
-
return output === undefined ?
|
|
1879
|
+
return output === undefined ? Unowned8(live) : live;
|
|
1682
1880
|
}),
|
|
1683
1881
|
diff: ({
|
|
1684
1882
|
news,
|
|
1685
1883
|
output
|
|
1686
|
-
}) =>
|
|
1687
|
-
if (!
|
|
1884
|
+
}) => Effect24.gen(function* () {
|
|
1885
|
+
if (!isResolved7(news))
|
|
1688
1886
|
return;
|
|
1689
|
-
yield* failIfInvalid(
|
|
1887
|
+
yield* failIfInvalid(RESOURCE6, String(news.policyName), firstProblem5(news));
|
|
1690
1888
|
if (output === undefined)
|
|
1691
1889
|
return;
|
|
1692
|
-
return
|
|
1890
|
+
return differing6(output, news).length === 0 ? { action: "noop" } : { action: "replace", deleteFirst: false };
|
|
1693
1891
|
}),
|
|
1694
1892
|
reconcile: ({
|
|
1695
1893
|
news,
|
|
1696
1894
|
output
|
|
1697
|
-
}) =>
|
|
1698
|
-
yield* failIfInvalid(
|
|
1699
|
-
const before = yield*
|
|
1700
|
-
if (before !== undefined &&
|
|
1895
|
+
}) => Effect24.gen(function* () {
|
|
1896
|
+
yield* failIfInvalid(RESOURCE6, String(news.policyName), firstProblem5(news));
|
|
1897
|
+
const before = yield* locate5(yield* listAttachments(), news, output);
|
|
1898
|
+
if (before !== undefined && differing6(before, news).length === 0)
|
|
1701
1899
|
return before;
|
|
1702
1900
|
const created = yield* createAttachment(createBody6(news));
|
|
1703
1901
|
if (created === undefined) {
|
|
1704
|
-
return yield*
|
|
1902
|
+
return yield* Effect24.fail(new LitellmRegistryUnreadableError({
|
|
1705
1903
|
reason: "the create answered something that is not an attachment",
|
|
1706
|
-
resource:
|
|
1904
|
+
resource: RESOURCE6
|
|
1707
1905
|
}));
|
|
1708
1906
|
}
|
|
1709
1907
|
const after = (yield* listAttachments()).find((row) => row.attachmentId === created.attachmentId);
|
|
1710
1908
|
if (after === undefined) {
|
|
1711
|
-
return yield*
|
|
1909
|
+
return yield* Effect24.fail(new LitellmRegistryAbsentAfterWriteError({ name: news.policyName, resource: RESOURCE6 }));
|
|
1712
1910
|
}
|
|
1713
|
-
const left =
|
|
1911
|
+
const left = differing6(after, news);
|
|
1714
1912
|
if (left.length > 0) {
|
|
1715
|
-
return yield*
|
|
1913
|
+
return yield* Effect24.fail(new LitellmRegistryNotConvergedError({
|
|
1716
1914
|
fields: left,
|
|
1717
1915
|
name: news.policyName,
|
|
1718
|
-
resource:
|
|
1916
|
+
resource: RESOURCE6
|
|
1719
1917
|
}));
|
|
1720
1918
|
}
|
|
1721
1919
|
return after;
|
|
1722
1920
|
}),
|
|
1723
1921
|
delete: ({ output }) => deleteAttachment(output.attachmentId),
|
|
1724
|
-
list: () =>
|
|
1922
|
+
list: () => Effect24.succeed([])
|
|
1725
1923
|
};
|
|
1726
|
-
var LiteLLMPolicyAttachmentProvider = () =>
|
|
1924
|
+
var LiteLLMPolicyAttachmentProvider = () => Provider7.effect(LiteLLMPolicyAttachment, Effect24.succeed(LiteLLMPolicyAttachment.Provider.of(policyAttachmentHandlers)));
|
|
1727
1925
|
// src/litellm/policy.ts
|
|
1728
|
-
import { Resource as
|
|
1729
|
-
import { Unowned as
|
|
1730
|
-
import { isResolved as
|
|
1731
|
-
import * as
|
|
1732
|
-
import * as
|
|
1733
|
-
import * as
|
|
1926
|
+
import { Resource as Resource8 } from "alchemy";
|
|
1927
|
+
import { Unowned as Unowned9 } from "alchemy/AdoptPolicy";
|
|
1928
|
+
import { isResolved as isResolved8 } from "alchemy/Diff";
|
|
1929
|
+
import * as Provider8 from "alchemy/Provider";
|
|
1930
|
+
import * as Effect26 from "effect/Effect";
|
|
1931
|
+
import * as Predicate9 from "effect/Predicate";
|
|
1734
1932
|
|
|
1735
1933
|
// src/litellm/policy-form.ts
|
|
1736
|
-
var
|
|
1934
|
+
var firstProblem6 = (props) => {
|
|
1737
1935
|
if (isBlank3(props.policyName) || props.policyName !== props.policyName.trim()) {
|
|
1738
1936
|
return "`policyName` must be a non-blank name with no leading or trailing space";
|
|
1739
1937
|
}
|
|
@@ -1785,11 +1983,11 @@ var toVersion = (value5) => {
|
|
|
1785
1983
|
versionStatus: typeof row["version_status"] === "string" ? row["version_status"] : "production"
|
|
1786
1984
|
};
|
|
1787
1985
|
};
|
|
1788
|
-
var
|
|
1986
|
+
var toAttributes8 = (version) => {
|
|
1789
1987
|
const { versionStatus: _status, ...attributes } = version;
|
|
1790
1988
|
return attributes;
|
|
1791
1989
|
};
|
|
1792
|
-
var
|
|
1990
|
+
var differing7 = (live, props) => {
|
|
1793
1991
|
const fields = [];
|
|
1794
1992
|
if (props.description !== undefined && live.description !== props.description) {
|
|
1795
1993
|
fields.push("description");
|
|
@@ -1813,8 +2011,8 @@ var createBody7 = (props) => ({
|
|
|
1813
2011
|
...props.inherit === undefined ? {} : { inherit: props.inherit },
|
|
1814
2012
|
...props.conditionModel === undefined ? {} : { condition: { model: props.conditionModel } }
|
|
1815
2013
|
});
|
|
1816
|
-
var
|
|
1817
|
-
const changed = new Set(
|
|
2014
|
+
var updateBody6 = (props, live) => {
|
|
2015
|
+
const changed = new Set(differing7(live, props));
|
|
1818
2016
|
return {
|
|
1819
2017
|
...changed.has("description") ? { description: props.description ?? null } : {},
|
|
1820
2018
|
...changed.has("inherit") ? { inherit: props.inherit ?? null } : {},
|
|
@@ -1826,72 +2024,72 @@ var updateBody5 = (props, live) => {
|
|
|
1826
2024
|
|
|
1827
2025
|
// src/litellm/policy-operations.ts
|
|
1828
2026
|
import * as policies2 from "@distilled.cloud/litellm/policy_engine";
|
|
1829
|
-
import * as
|
|
1830
|
-
var
|
|
1831
|
-
var unreadable2 = (reason) => new LitellmRegistryUnreadableError({ reason, resource:
|
|
1832
|
-
var listPolicyVersions = (policyName) => throughFetch(policies2.listPolicyVersionsPoliciesNamePolicyNameVersionsGet({ policy_name: policyName })).pipe(
|
|
2027
|
+
import * as Effect25 from "effect/Effect";
|
|
2028
|
+
var RESOURCE7 = "LiteLLM.Policy";
|
|
2029
|
+
var unreadable2 = (reason) => new LitellmRegistryUnreadableError({ reason, resource: RESOURCE7 });
|
|
2030
|
+
var listPolicyVersions = (policyName) => throughFetch(policies2.listPolicyVersionsPoliciesNamePolicyNameVersionsGet({ policy_name: policyName })).pipe(Effect25.flatMap((response) => {
|
|
1833
2031
|
const versions = asRow(bodyOf(response))?.["versions"];
|
|
1834
2032
|
if (versions === undefined)
|
|
1835
|
-
return
|
|
2033
|
+
return Effect25.succeed([]);
|
|
1836
2034
|
if (!Array.isArray(versions))
|
|
1837
|
-
return
|
|
2035
|
+
return Effect25.fail(unreadable2("versions is not an array"));
|
|
1838
2036
|
const parsed = versions.map(toVersion);
|
|
1839
|
-
return parsed.every((each) => each !== undefined) ?
|
|
2037
|
+
return parsed.every((each) => each !== undefined) ? Effect25.succeed(parsed) : Effect25.fail(unreadable2("a version has no id or name"));
|
|
1840
2038
|
}));
|
|
1841
|
-
var configPolicyNames = () => throughFetch(policies2.listPoliciesPoliciesListGet({ version_status: "production" })).pipe(
|
|
2039
|
+
var configPolicyNames = () => throughFetch(policies2.listPoliciesPoliciesListGet({ version_status: "production" })).pipe(Effect25.flatMap((response) => {
|
|
1842
2040
|
const rows = asRow(bodyOf(response))?.["policies"];
|
|
1843
2041
|
if (!Array.isArray(rows))
|
|
1844
|
-
return
|
|
1845
|
-
return
|
|
2042
|
+
return Effect25.fail(unreadable2("policies is not an array"));
|
|
2043
|
+
return Effect25.succeed(rows.flatMap((row) => {
|
|
1846
2044
|
const each = asRow(row);
|
|
1847
2045
|
return each?.["definition_location"] === "config" && typeof each["policy_name"] === "string" ? [each["policy_name"]] : [];
|
|
1848
2046
|
}));
|
|
1849
2047
|
}));
|
|
1850
|
-
var createPolicy = (body) => throughFetch(policies2.createPolicyPoliciesPost(body)).pipe(
|
|
1851
|
-
var createDraft = (policyName) => throughFetch(policies2.createPolicyVersionPoliciesNamePolicyNameVersionsPost({ policy_name: policyName })).pipe(
|
|
2048
|
+
var createPolicy = (body) => throughFetch(policies2.createPolicyPoliciesPost(body)).pipe(Effect25.asVoid);
|
|
2049
|
+
var createDraft = (policyName) => throughFetch(policies2.createPolicyVersionPoliciesNamePolicyNameVersionsPost({ policy_name: policyName })).pipe(Effect25.flatMap((response) => {
|
|
1852
2050
|
const draft = toVersion(bodyOf(response));
|
|
1853
|
-
return draft === undefined ?
|
|
2051
|
+
return draft === undefined ? Effect25.fail(unreadable2("the new draft is not a policy")) : Effect25.succeed(draft);
|
|
1854
2052
|
}));
|
|
1855
|
-
var editDraft = (policyId, body) => throughFetch(policies2.updatePolicyPoliciesPolicyIdPut({ ...body, policy_id: policyId })).pipe(
|
|
2053
|
+
var editDraft = (policyId, body) => throughFetch(policies2.updatePolicyPoliciesPolicyIdPut({ ...body, policy_id: policyId })).pipe(Effect25.asVoid);
|
|
1856
2054
|
var setVersionStatus = (policyId, status) => throughFetch(policies2.updatePolicyVersionStatusPoliciesPolicyIdStatusPut({
|
|
1857
2055
|
policy_id: policyId,
|
|
1858
2056
|
version_status: status
|
|
1859
|
-
})).pipe(
|
|
2057
|
+
})).pipe(Effect25.asVoid);
|
|
1860
2058
|
var deleteAllVersions = (policyName) => throughFetch(policies2.deleteAllPolicyVersionsPoliciesNamePolicyNameAllVersionsDelete({
|
|
1861
2059
|
policy_name: policyName
|
|
1862
|
-
})).pipe(
|
|
2060
|
+
})).pipe(Effect25.asVoid);
|
|
1863
2061
|
|
|
1864
2062
|
// src/litellm/policy.ts
|
|
1865
|
-
var
|
|
1866
|
-
var LiteLLMPolicy =
|
|
2063
|
+
var RESOURCE8 = "LiteLLM.Policy";
|
|
2064
|
+
var LiteLLMPolicy = Resource8("LiteLLM.Policy", {
|
|
1867
2065
|
defaultRemovalPolicy: "retain"
|
|
1868
2066
|
});
|
|
1869
|
-
var isLiteLLMPolicy = (value5) =>
|
|
2067
|
+
var isLiteLLMPolicy = (value5) => Predicate9.hasProperty(value5, "Type") && value5.Type === "LiteLLM.Policy";
|
|
1870
2068
|
var production = (versions) => versions.find((version) => version.versionStatus === "production");
|
|
1871
|
-
var invalid = (name, problem) =>
|
|
2069
|
+
var invalid = (name, problem) => Effect26.fail(new LitellmRegistryInvalidError({ name, problem, resource: RESOURCE8 }));
|
|
1872
2070
|
var policyHandlers = {
|
|
1873
|
-
read: ({ olds, output }) =>
|
|
2071
|
+
read: ({ olds, output }) => Effect26.gen(function* () {
|
|
1874
2072
|
if (output === undefined) {
|
|
1875
|
-
yield* dieIfInvalid(
|
|
2073
|
+
yield* dieIfInvalid(RESOURCE8, String(olds.policyName), firstProblem6(olds));
|
|
1876
2074
|
}
|
|
1877
2075
|
const live = production(yield* listPolicyVersions(output?.policyName ?? olds.policyName));
|
|
1878
2076
|
if (live === undefined)
|
|
1879
2077
|
return;
|
|
1880
|
-
return output === undefined ?
|
|
2078
|
+
return output === undefined ? Unowned9(toAttributes8(live)) : toAttributes8(live);
|
|
1881
2079
|
}),
|
|
1882
|
-
diff: ({ news, output }) =>
|
|
1883
|
-
if (!
|
|
2080
|
+
diff: ({ news, output }) => Effect26.gen(function* () {
|
|
2081
|
+
if (!isResolved8(news))
|
|
1884
2082
|
return;
|
|
1885
|
-
yield* failIfInvalid(
|
|
2083
|
+
yield* failIfInvalid(RESOURCE8, String(news.policyName), firstProblem6(news));
|
|
1886
2084
|
if (output === undefined)
|
|
1887
2085
|
return;
|
|
1888
2086
|
if (news.policyName !== output.policyName) {
|
|
1889
2087
|
return { action: "replace", deleteFirst: false };
|
|
1890
2088
|
}
|
|
1891
|
-
return
|
|
2089
|
+
return differing7(output, news).length === 0 ? { action: "noop" } : { action: "update" };
|
|
1892
2090
|
}),
|
|
1893
|
-
reconcile: ({ news }) =>
|
|
1894
|
-
yield* failIfInvalid(
|
|
2091
|
+
reconcile: ({ news }) => Effect26.gen(function* () {
|
|
2092
|
+
yield* failIfInvalid(RESOURCE8, String(news.policyName), firstProblem6(news));
|
|
1895
2093
|
const versions = yield* listPolicyVersions(news.policyName);
|
|
1896
2094
|
const live = production(versions);
|
|
1897
2095
|
if (versions.length === 0) {
|
|
@@ -1901,38 +2099,38 @@ var policyHandlers = {
|
|
|
1901
2099
|
yield* createPolicy(createBody7(news));
|
|
1902
2100
|
} else if (live === undefined) {
|
|
1903
2101
|
return yield* invalid(news.policyName, `${versions.length} version(s) exist and none is production, so the policy is inactive; promote one in LiteLLM (or delete its versions) instead of letting this guess`);
|
|
1904
|
-
} else if (
|
|
2102
|
+
} else if (differing7(live, news).length > 0) {
|
|
1905
2103
|
const draft = yield* createDraft(news.policyName);
|
|
1906
|
-
yield* editDraft(draft.policyId,
|
|
2104
|
+
yield* editDraft(draft.policyId, updateBody6(news, live));
|
|
1907
2105
|
yield* setVersionStatus(draft.policyId, "published");
|
|
1908
2106
|
yield* setVersionStatus(draft.policyId, "production");
|
|
1909
2107
|
}
|
|
1910
2108
|
const after = production(yield* listPolicyVersions(news.policyName));
|
|
1911
2109
|
if (after === undefined) {
|
|
1912
|
-
return yield*
|
|
2110
|
+
return yield* Effect26.fail(new LitellmRegistryAbsentAfterWriteError({ name: news.policyName, resource: RESOURCE8 }));
|
|
1913
2111
|
}
|
|
1914
|
-
const left =
|
|
2112
|
+
const left = differing7(after, news);
|
|
1915
2113
|
if (left.length > 0) {
|
|
1916
|
-
return yield*
|
|
2114
|
+
return yield* Effect26.fail(new LitellmRegistryNotConvergedError({
|
|
1917
2115
|
fields: left,
|
|
1918
2116
|
name: news.policyName,
|
|
1919
|
-
resource:
|
|
2117
|
+
resource: RESOURCE8
|
|
1920
2118
|
}));
|
|
1921
2119
|
}
|
|
1922
|
-
return
|
|
2120
|
+
return toAttributes8(after);
|
|
1923
2121
|
}),
|
|
1924
2122
|
delete: ({ output }) => deleteAllVersions(output.policyName),
|
|
1925
|
-
list: () =>
|
|
2123
|
+
list: () => Effect26.succeed([])
|
|
1926
2124
|
};
|
|
1927
|
-
var LiteLLMPolicyProvider = () =>
|
|
2125
|
+
var LiteLLMPolicyProvider = () => Provider8.effect(LiteLLMPolicy, Effect26.succeed(LiteLLMPolicy.Provider.of(policyHandlers)));
|
|
1928
2126
|
// src/litellm/team.ts
|
|
1929
|
-
import { Resource as
|
|
1930
|
-
import { Unowned as
|
|
1931
|
-
import { isResolved as
|
|
2127
|
+
import { Resource as Resource9 } from "alchemy";
|
|
2128
|
+
import { Unowned as Unowned10 } from "alchemy/AdoptPolicy";
|
|
2129
|
+
import { isResolved as isResolved9 } from "alchemy/Diff";
|
|
1932
2130
|
import { createPhysicalName as createPhysicalName4 } from "alchemy/PhysicalName";
|
|
1933
|
-
import * as
|
|
1934
|
-
import * as
|
|
1935
|
-
import * as
|
|
2131
|
+
import * as Provider9 from "alchemy/Provider";
|
|
2132
|
+
import * as Effect28 from "effect/Effect";
|
|
2133
|
+
import * as Predicate10 from "effect/Predicate";
|
|
1936
2134
|
|
|
1937
2135
|
// src/litellm/team-members.ts
|
|
1938
2136
|
var toMemberAttributes = (value5) => {
|
|
@@ -2047,7 +2245,7 @@ var permissionProblem = (declared) => {
|
|
|
2047
2245
|
};
|
|
2048
2246
|
|
|
2049
2247
|
// src/litellm/team-form.ts
|
|
2050
|
-
var
|
|
2248
|
+
var firstProblem7 = (props) => {
|
|
2051
2249
|
if (isBlank3(props.teamAlias) || props.teamAlias !== props.teamAlias.trim()) {
|
|
2052
2250
|
return "`teamAlias` must be a non-blank name with no leading or trailing space";
|
|
2053
2251
|
}
|
|
@@ -2079,7 +2277,7 @@ var firstProblem6 = (props) => {
|
|
|
2079
2277
|
}
|
|
2080
2278
|
return permissionProblem(props.objectPermission);
|
|
2081
2279
|
};
|
|
2082
|
-
var
|
|
2280
|
+
var toAttributes9 = (value5) => {
|
|
2083
2281
|
const row = asRow(asRow(value5)?.["team_info"]);
|
|
2084
2282
|
if (row === undefined)
|
|
2085
2283
|
return;
|
|
@@ -2112,7 +2310,7 @@ var teamFieldsDiffering = (live, props) => {
|
|
|
2112
2310
|
}
|
|
2113
2311
|
return fields;
|
|
2114
2312
|
};
|
|
2115
|
-
var
|
|
2313
|
+
var differing8 = (live, props) => [
|
|
2116
2314
|
...teamFieldsDiffering(live, props),
|
|
2117
2315
|
...rosterPending(live.members, props.members) ? ["members"] : []
|
|
2118
2316
|
];
|
|
@@ -2124,7 +2322,7 @@ var createBody8 = (props, teamId) => ({
|
|
|
2124
2322
|
...props.accessGroupIds === undefined ? {} : { access_group_ids: [...props.accessGroupIds] },
|
|
2125
2323
|
...props.objectPermission === undefined ? {} : { object_permission: permissionBody(props.objectPermission) }
|
|
2126
2324
|
});
|
|
2127
|
-
var
|
|
2325
|
+
var updateBody7 = (props, live) => {
|
|
2128
2326
|
const changed = new Set(teamFieldsDiffering(live, props));
|
|
2129
2327
|
if (changed.size === 0)
|
|
2130
2328
|
return;
|
|
@@ -2141,74 +2339,74 @@ var updateBody6 = (props, live) => {
|
|
|
2141
2339
|
|
|
2142
2340
|
// src/litellm/team-operations.ts
|
|
2143
2341
|
import * as team from "@distilled.cloud/litellm/team_management";
|
|
2144
|
-
import * as
|
|
2145
|
-
var readTeam = (teamId) => throughFetch(team.getTeamInfoTeamInfo({ team_id: teamId })).pipe(
|
|
2146
|
-
const row =
|
|
2342
|
+
import * as Effect27 from "effect/Effect";
|
|
2343
|
+
var readTeam = (teamId) => throughFetch(team.getTeamInfoTeamInfo({ team_id: teamId })).pipe(Effect27.map((response) => {
|
|
2344
|
+
const row = toAttributes9(bodyOf(response));
|
|
2147
2345
|
return row?.teamId === teamId ? row : undefined;
|
|
2148
|
-
}),
|
|
2149
|
-
var createTeam = (body) => throughFetch(team.postNewTeamTeamNew(body)).pipe(
|
|
2150
|
-
var updateTeam = (body) => throughFetch(team.updateTeamTeamUpdatePost(body)).pipe(
|
|
2346
|
+
}), Effect27.catch((error) => isNotFound(error) ? Effect27.succeed(undefined) : Effect27.fail(error)));
|
|
2347
|
+
var createTeam = (body) => throughFetch(team.postNewTeamTeamNew(body)).pipe(Effect27.asVoid);
|
|
2348
|
+
var updateTeam = (body) => throughFetch(team.updateTeamTeamUpdatePost(body)).pipe(Effect27.asVoid);
|
|
2151
2349
|
var addMembers = (teamId, members) => throughFetch(team.teamMemberAddTeamMemberAddPost({
|
|
2152
2350
|
member: members.map((member) => ({ role: member.role ?? "user", user_id: member.userId })),
|
|
2153
2351
|
team_id: teamId
|
|
2154
|
-
})).pipe(
|
|
2352
|
+
})).pipe(Effect27.asVoid);
|
|
2155
2353
|
var setMemberRole = (teamId, member) => throughFetch(team.teamMemberUpdateTeamMemberUpdatePost({
|
|
2156
2354
|
role: member.role ?? "user",
|
|
2157
2355
|
team_id: teamId,
|
|
2158
2356
|
user_id: member.userId
|
|
2159
|
-
})).pipe(
|
|
2160
|
-
var listTeamIds = () => throughFetch(team.listTeamTeamListGet({})).pipe(
|
|
2357
|
+
})).pipe(Effect27.asVoid);
|
|
2358
|
+
var listTeamIds = () => throughFetch(team.listTeamTeamListGet({})).pipe(Effect27.map((response) => {
|
|
2161
2359
|
const rows = bodyOf(response);
|
|
2162
2360
|
return Array.isArray(rows) ? rows.flatMap((row) => {
|
|
2163
2361
|
const id = asRow(row)?.["team_id"];
|
|
2164
2362
|
return typeof id === "string" ? [id] : [];
|
|
2165
2363
|
}) : [];
|
|
2166
2364
|
}));
|
|
2167
|
-
var deleteTeam = (teamId) => throughFetch(team.deleteTeamTeamDeletePost({ team_ids: [teamId] })).pipe(
|
|
2365
|
+
var deleteTeam = (teamId) => throughFetch(team.deleteTeamTeamDeletePost({ team_ids: [teamId] })).pipe(Effect27.asVoid, Effect27.catchTag("NotFound", (original) => listTeamIds().pipe(Effect27.flatMap((ids) => ids.includes(teamId) ? Effect27.fail(original) : Effect27.void))));
|
|
2168
2366
|
|
|
2169
2367
|
// src/litellm/team.ts
|
|
2170
|
-
var
|
|
2171
|
-
var LiteLLMTeam =
|
|
2368
|
+
var RESOURCE9 = "LiteLLM.Team";
|
|
2369
|
+
var LiteLLMTeam = Resource9("LiteLLM.Team", {
|
|
2172
2370
|
defaultRemovalPolicy: "retain"
|
|
2173
2371
|
});
|
|
2174
|
-
var isLiteLLMTeam = (value5) =>
|
|
2175
|
-
var idOf3 = (id, instanceId, props, output) => output?.teamId !== undefined ?
|
|
2372
|
+
var isLiteLLMTeam = (value5) => Predicate10.hasProperty(value5, "Type") && value5.Type === "LiteLLM.Team";
|
|
2373
|
+
var idOf3 = (id, instanceId, props, output) => output?.teamId !== undefined ? Effect28.succeed(output.teamId) : props.teamId !== undefined ? Effect28.succeed(props.teamId) : createPhysicalName4({ id, instanceId, lowercase: true, maxLength: 64 });
|
|
2176
2374
|
var teamHandlers = {
|
|
2177
|
-
read: ({ id, instanceId, olds, output }) =>
|
|
2375
|
+
read: ({ id, instanceId, olds, output }) => Effect28.gen(function* () {
|
|
2178
2376
|
if (output === undefined) {
|
|
2179
|
-
yield* dieIfInvalid(
|
|
2377
|
+
yield* dieIfInvalid(RESOURCE9, String(olds.teamAlias), firstProblem7(olds));
|
|
2180
2378
|
}
|
|
2181
2379
|
const live = yield* readTeam(yield* idOf3(id, instanceId, olds, output));
|
|
2182
2380
|
if (live === undefined)
|
|
2183
2381
|
return;
|
|
2184
|
-
return output === undefined ?
|
|
2382
|
+
return output === undefined ? Unowned10(live) : live;
|
|
2185
2383
|
}),
|
|
2186
|
-
diff: ({ news, output }) =>
|
|
2187
|
-
if (!
|
|
2384
|
+
diff: ({ news, output }) => Effect28.gen(function* () {
|
|
2385
|
+
if (!isResolved9(news))
|
|
2188
2386
|
return;
|
|
2189
|
-
yield* failIfInvalid(
|
|
2387
|
+
yield* failIfInvalid(RESOURCE9, String(news.teamAlias), firstProblem7(news));
|
|
2190
2388
|
if (output === undefined)
|
|
2191
2389
|
return;
|
|
2192
2390
|
if (news.teamId !== undefined && news.teamId !== output.teamId) {
|
|
2193
2391
|
return { action: "replace", deleteFirst: false };
|
|
2194
2392
|
}
|
|
2195
|
-
return
|
|
2393
|
+
return differing8(output, news).length === 0 ? { action: "noop" } : { action: "update" };
|
|
2196
2394
|
}),
|
|
2197
|
-
reconcile: ({ id, instanceId, news, output }) =>
|
|
2198
|
-
yield* failIfInvalid(
|
|
2395
|
+
reconcile: ({ id, instanceId, news, output }) => Effect28.gen(function* () {
|
|
2396
|
+
yield* failIfInvalid(RESOURCE9, String(news.teamAlias), firstProblem7(news));
|
|
2199
2397
|
const teamId = yield* idOf3(id, instanceId, news, output);
|
|
2200
2398
|
const before = yield* readTeam(teamId);
|
|
2201
2399
|
if (before === undefined)
|
|
2202
2400
|
yield* createTeam(createBody8(news, teamId));
|
|
2203
2401
|
else {
|
|
2204
|
-
const body =
|
|
2402
|
+
const body = updateBody7(news, before);
|
|
2205
2403
|
if (body !== undefined)
|
|
2206
2404
|
yield* updateTeam(body);
|
|
2207
2405
|
}
|
|
2208
2406
|
if (news.members !== undefined) {
|
|
2209
2407
|
const live = yield* readTeam(teamId);
|
|
2210
2408
|
if (live === undefined) {
|
|
2211
|
-
return yield*
|
|
2409
|
+
return yield* Effect28.fail(new LitellmRegistryAbsentAfterWriteError({ name: news.teamAlias, resource: RESOURCE9 }));
|
|
2212
2410
|
}
|
|
2213
2411
|
const missing = membersToAdd(live.members, news.members);
|
|
2214
2412
|
if (missing.length > 0)
|
|
@@ -2219,29 +2417,29 @@ var teamHandlers = {
|
|
|
2219
2417
|
}
|
|
2220
2418
|
const after = yield* readTeam(teamId);
|
|
2221
2419
|
if (after === undefined) {
|
|
2222
|
-
return yield*
|
|
2420
|
+
return yield* Effect28.fail(new LitellmRegistryAbsentAfterWriteError({ name: news.teamAlias, resource: RESOURCE9 }));
|
|
2223
2421
|
}
|
|
2224
|
-
const left =
|
|
2422
|
+
const left = differing8(after, news);
|
|
2225
2423
|
if (left.length > 0) {
|
|
2226
|
-
return yield*
|
|
2424
|
+
return yield* Effect28.fail(new LitellmRegistryNotConvergedError({
|
|
2227
2425
|
fields: left,
|
|
2228
2426
|
name: news.teamAlias,
|
|
2229
|
-
resource:
|
|
2427
|
+
resource: RESOURCE9
|
|
2230
2428
|
}));
|
|
2231
2429
|
}
|
|
2232
2430
|
return after;
|
|
2233
2431
|
}),
|
|
2234
2432
|
delete: ({ output }) => deleteTeam(output.teamId),
|
|
2235
|
-
list: () =>
|
|
2433
|
+
list: () => Effect28.succeed([])
|
|
2236
2434
|
};
|
|
2237
|
-
var LiteLLMTeamProvider = () =>
|
|
2435
|
+
var LiteLLMTeamProvider = () => Provider9.effect(LiteLLMTeam, Effect28.succeed(LiteLLMTeam.Provider.of(teamHandlers)));
|
|
2238
2436
|
// src/litellm/tool-policy.ts
|
|
2239
|
-
import { Resource as
|
|
2240
|
-
import { Unowned as
|
|
2241
|
-
import { isResolved as
|
|
2242
|
-
import * as
|
|
2243
|
-
import * as
|
|
2244
|
-
import * as
|
|
2437
|
+
import { Resource as Resource10 } from "alchemy";
|
|
2438
|
+
import { Unowned as Unowned11 } from "alchemy/AdoptPolicy";
|
|
2439
|
+
import { isResolved as isResolved10 } from "alchemy/Diff";
|
|
2440
|
+
import * as Provider10 from "alchemy/Provider";
|
|
2441
|
+
import * as Effect30 from "effect/Effect";
|
|
2442
|
+
import * as Predicate11 from "effect/Predicate";
|
|
2245
2443
|
|
|
2246
2444
|
// src/litellm/tool-policy-types.ts
|
|
2247
2445
|
var DEFAULT_TOOL_POLICY = "untrusted";
|
|
@@ -2250,7 +2448,7 @@ var OUTPUT_POLICIES = ["untrusted", "trusted"];
|
|
|
2250
2448
|
|
|
2251
2449
|
// src/litellm/tool-policy-form.ts
|
|
2252
2450
|
var shadowed = (name) => name === "list" || name === "spend" || name === "policy/options" || ["/detail", "/logs"].some((suffix) => name.endsWith(suffix));
|
|
2253
|
-
var
|
|
2451
|
+
var firstProblem8 = (props) => {
|
|
2254
2452
|
if (isBlank3(props.toolName) || props.toolName !== props.toolName.trim()) {
|
|
2255
2453
|
return "`toolName` must be a non-blank name with no leading or trailing space";
|
|
2256
2454
|
}
|
|
@@ -2268,7 +2466,7 @@ var firstProblem7 = (props) => {
|
|
|
2268
2466
|
}
|
|
2269
2467
|
return;
|
|
2270
2468
|
};
|
|
2271
|
-
var
|
|
2469
|
+
var toAttributes10 = (value5) => {
|
|
2272
2470
|
const row = asRow(value5);
|
|
2273
2471
|
if (row === undefined)
|
|
2274
2472
|
return;
|
|
@@ -2284,7 +2482,7 @@ var toAttributes9 = (value5) => {
|
|
|
2284
2482
|
toolName
|
|
2285
2483
|
};
|
|
2286
2484
|
};
|
|
2287
|
-
var
|
|
2485
|
+
var differing9 = (live, props) => {
|
|
2288
2486
|
const fields = [];
|
|
2289
2487
|
if (props.inputPolicy !== undefined && live.inputPolicy !== props.inputPolicy) {
|
|
2290
2488
|
fields.push("input_policy");
|
|
@@ -2294,8 +2492,8 @@ var differing8 = (live, props) => {
|
|
|
2294
2492
|
}
|
|
2295
2493
|
return fields;
|
|
2296
2494
|
};
|
|
2297
|
-
var
|
|
2298
|
-
const changed = live === undefined ? undefined : new Set(
|
|
2495
|
+
var updateBody8 = (props, live) => {
|
|
2496
|
+
const changed = live === undefined ? undefined : new Set(differing9(live, props));
|
|
2299
2497
|
return {
|
|
2300
2498
|
tool_name: props.toolName,
|
|
2301
2499
|
...props.inputPolicy !== undefined && (changed === undefined || changed.has("input_policy")) ? { input_policy: props.inputPolicy } : {},
|
|
@@ -2305,19 +2503,19 @@ var updateBody7 = (props, live) => {
|
|
|
2305
2503
|
|
|
2306
2504
|
// src/litellm/tool-policy-operations.ts
|
|
2307
2505
|
import * as tools from "@distilled.cloud/litellm/tools";
|
|
2308
|
-
import * as
|
|
2309
|
-
var readTool = (toolName) => throughFetch(tools.getToolV1ToolToolNameGet({ tool_name: toolName })).pipe(
|
|
2310
|
-
const row =
|
|
2506
|
+
import * as Effect29 from "effect/Effect";
|
|
2507
|
+
var readTool = (toolName) => throughFetch(tools.getToolV1ToolToolNameGet({ tool_name: toolName })).pipe(Effect29.map((response) => {
|
|
2508
|
+
const row = toAttributes10(bodyOf(response));
|
|
2311
2509
|
return row?.toolName === toolName ? row : undefined;
|
|
2312
|
-
}),
|
|
2313
|
-
var writeToolPolicy = (body) => throughFetch(tools.updateToolPolicyV1ToolPolicyPost(body)).pipe(
|
|
2314
|
-
var resetToolPolicy = (props) => readTool(props.toolName).pipe(
|
|
2510
|
+
}), Effect29.catch((error) => isNotFound(error) ? Effect29.succeed(undefined) : Effect29.fail(error)));
|
|
2511
|
+
var writeToolPolicy = (body) => throughFetch(tools.updateToolPolicyV1ToolPolicyPost(body)).pipe(Effect29.asVoid);
|
|
2512
|
+
var resetToolPolicy = (props) => readTool(props.toolName).pipe(Effect29.flatMap((live) => {
|
|
2315
2513
|
if (live === undefined)
|
|
2316
|
-
return
|
|
2514
|
+
return Effect29.void;
|
|
2317
2515
|
const inputStale = props.inputPolicy !== undefined && live.inputPolicy !== DEFAULT_TOOL_POLICY;
|
|
2318
2516
|
const outputStale = props.outputPolicy !== undefined && live.outputPolicy !== DEFAULT_TOOL_POLICY;
|
|
2319
2517
|
if (!inputStale && !outputStale)
|
|
2320
|
-
return
|
|
2518
|
+
return Effect29.void;
|
|
2321
2519
|
return writeToolPolicy({
|
|
2322
2520
|
tool_name: props.toolName,
|
|
2323
2521
|
...inputStale ? { input_policy: DEFAULT_TOOL_POLICY } : {},
|
|
@@ -2326,66 +2524,66 @@ var resetToolPolicy = (props) => readTool(props.toolName).pipe(Effect27.flatMap(
|
|
|
2326
2524
|
}));
|
|
2327
2525
|
|
|
2328
2526
|
// src/litellm/tool-policy.ts
|
|
2329
|
-
var
|
|
2330
|
-
var LiteLLMToolPolicy =
|
|
2527
|
+
var RESOURCE10 = "LiteLLM.ToolPolicy";
|
|
2528
|
+
var LiteLLMToolPolicy = Resource10("LiteLLM.ToolPolicy", {
|
|
2331
2529
|
defaultRemovalPolicy: "retain"
|
|
2332
2530
|
});
|
|
2333
|
-
var isLiteLLMToolPolicy = (value5) =>
|
|
2531
|
+
var isLiteLLMToolPolicy = (value5) => Predicate11.hasProperty(value5, "Type") && value5.Type === "LiteLLM.ToolPolicy";
|
|
2334
2532
|
var toolPolicyHandlers = {
|
|
2335
|
-
read: ({ olds, output }) =>
|
|
2533
|
+
read: ({ olds, output }) => Effect30.gen(function* () {
|
|
2336
2534
|
if (output === undefined) {
|
|
2337
|
-
yield* dieIfInvalid(
|
|
2535
|
+
yield* dieIfInvalid(RESOURCE10, String(olds.toolName), firstProblem8(olds));
|
|
2338
2536
|
}
|
|
2339
2537
|
const live = yield* readTool(output?.toolName ?? olds.toolName);
|
|
2340
2538
|
if (live === undefined)
|
|
2341
2539
|
return;
|
|
2342
|
-
return output === undefined ?
|
|
2540
|
+
return output === undefined ? Unowned11(live) : live;
|
|
2343
2541
|
}),
|
|
2344
2542
|
diff: ({
|
|
2345
2543
|
news,
|
|
2346
2544
|
output
|
|
2347
|
-
}) =>
|
|
2348
|
-
if (!
|
|
2545
|
+
}) => Effect30.gen(function* () {
|
|
2546
|
+
if (!isResolved10(news))
|
|
2349
2547
|
return;
|
|
2350
|
-
yield* failIfInvalid(
|
|
2548
|
+
yield* failIfInvalid(RESOURCE10, String(news.toolName), firstProblem8(news));
|
|
2351
2549
|
if (output === undefined)
|
|
2352
2550
|
return;
|
|
2353
2551
|
if (news.toolName !== output.toolName) {
|
|
2354
2552
|
return { action: "replace", deleteFirst: false };
|
|
2355
2553
|
}
|
|
2356
|
-
return
|
|
2554
|
+
return differing9(output, news).length === 0 ? { action: "noop" } : { action: "update" };
|
|
2357
2555
|
}),
|
|
2358
|
-
reconcile: ({ news }) =>
|
|
2359
|
-
yield* failIfInvalid(
|
|
2556
|
+
reconcile: ({ news }) => Effect30.gen(function* () {
|
|
2557
|
+
yield* failIfInvalid(RESOURCE10, String(news.toolName), firstProblem8(news));
|
|
2360
2558
|
const before = yield* readTool(news.toolName);
|
|
2361
|
-
if (before === undefined ||
|
|
2362
|
-
yield* writeToolPolicy(
|
|
2559
|
+
if (before === undefined || differing9(before, news).length > 0) {
|
|
2560
|
+
yield* writeToolPolicy(updateBody8(news, before));
|
|
2363
2561
|
}
|
|
2364
2562
|
const after = yield* readTool(news.toolName);
|
|
2365
2563
|
if (after === undefined) {
|
|
2366
|
-
return yield*
|
|
2564
|
+
return yield* Effect30.fail(new LitellmRegistryAbsentAfterWriteError({ name: news.toolName, resource: RESOURCE10 }));
|
|
2367
2565
|
}
|
|
2368
|
-
const left =
|
|
2566
|
+
const left = differing9(after, news);
|
|
2369
2567
|
if (left.length > 0) {
|
|
2370
|
-
return yield*
|
|
2568
|
+
return yield* Effect30.fail(new LitellmRegistryNotConvergedError({
|
|
2371
2569
|
fields: left,
|
|
2372
2570
|
name: news.toolName,
|
|
2373
|
-
resource:
|
|
2571
|
+
resource: RESOURCE10
|
|
2374
2572
|
}));
|
|
2375
2573
|
}
|
|
2376
2574
|
return after;
|
|
2377
2575
|
}),
|
|
2378
2576
|
delete: ({ olds }) => resetToolPolicy(olds),
|
|
2379
|
-
list: () =>
|
|
2577
|
+
list: () => Effect30.succeed([])
|
|
2380
2578
|
};
|
|
2381
|
-
var LiteLLMToolPolicyProvider = () =>
|
|
2579
|
+
var LiteLLMToolPolicyProvider = () => Provider10.effect(LiteLLMToolPolicy, Effect30.succeed(LiteLLMToolPolicy.Provider.of(toolPolicyHandlers)));
|
|
2382
2580
|
// src/litellm/toolset.ts
|
|
2383
|
-
import { Resource as
|
|
2384
|
-
import { Unowned as
|
|
2385
|
-
import { isResolved as
|
|
2386
|
-
import * as
|
|
2387
|
-
import * as
|
|
2388
|
-
import * as
|
|
2581
|
+
import { Resource as Resource11 } from "alchemy";
|
|
2582
|
+
import { Unowned as Unowned12 } from "alchemy/AdoptPolicy";
|
|
2583
|
+
import { isResolved as isResolved11 } from "alchemy/Diff";
|
|
2584
|
+
import * as Provider11 from "alchemy/Provider";
|
|
2585
|
+
import * as Effect32 from "effect/Effect";
|
|
2586
|
+
import * as Predicate12 from "effect/Predicate";
|
|
2389
2587
|
|
|
2390
2588
|
// src/litellm/toolset-form.ts
|
|
2391
2589
|
var pairKey = (tool) => JSON.stringify([tool.serverId, tool.toolName]);
|
|
@@ -2395,7 +2593,7 @@ var sameTools = (left, right) => {
|
|
|
2395
2593
|
const b = canonicalTools(right).map(pairKey);
|
|
2396
2594
|
return a.length === b.length && a.every((each, index) => each === b[index]);
|
|
2397
2595
|
};
|
|
2398
|
-
var
|
|
2596
|
+
var firstProblem9 = (props) => {
|
|
2399
2597
|
if (isBlank3(props.toolsetName) || props.toolsetName !== props.toolsetName.trim()) {
|
|
2400
2598
|
return "`toolsetName` must be a non-blank name with no leading or trailing space";
|
|
2401
2599
|
}
|
|
@@ -2416,7 +2614,7 @@ var firstProblem8 = (props) => {
|
|
|
2416
2614
|
return `\`tools\` lists ${twice} twice`;
|
|
2417
2615
|
return;
|
|
2418
2616
|
};
|
|
2419
|
-
var
|
|
2617
|
+
var toAttributes11 = (value5) => {
|
|
2420
2618
|
const row = asRow(value5);
|
|
2421
2619
|
if (row === undefined)
|
|
2422
2620
|
return;
|
|
@@ -2438,7 +2636,7 @@ var toAttributes10 = (value5) => {
|
|
|
2438
2636
|
tools: canonicalTools(tools2)
|
|
2439
2637
|
};
|
|
2440
2638
|
};
|
|
2441
|
-
var
|
|
2639
|
+
var differing10 = (live, props) => {
|
|
2442
2640
|
const fields = [];
|
|
2443
2641
|
if (live.toolsetName !== props.toolsetName)
|
|
2444
2642
|
fields.push("toolset_name");
|
|
@@ -2455,8 +2653,8 @@ var createBody9 = (props) => ({
|
|
|
2455
2653
|
tools: wireTools(props.tools),
|
|
2456
2654
|
...props.description === undefined ? {} : { description: props.description }
|
|
2457
2655
|
});
|
|
2458
|
-
var
|
|
2459
|
-
const changed = new Set(
|
|
2656
|
+
var updateBody9 = (props, live) => {
|
|
2657
|
+
const changed = new Set(differing10(live, props));
|
|
2460
2658
|
return {
|
|
2461
2659
|
toolset_id: live.toolsetId,
|
|
2462
2660
|
...changed.has("toolset_name") ? { toolset_name: props.toolsetName } : {},
|
|
@@ -2467,108 +2665,108 @@ var updateBody8 = (props, live) => {
|
|
|
2467
2665
|
|
|
2468
2666
|
// src/litellm/toolset-operations.ts
|
|
2469
2667
|
import * as mcp2 from "@distilled.cloud/litellm/mcp_management";
|
|
2470
|
-
import * as
|
|
2471
|
-
var
|
|
2472
|
-
var listToolsets = () => throughFetch(mcp2.fetchMcpToolsetsV1McpToolsetGet({})).pipe(
|
|
2668
|
+
import * as Effect31 from "effect/Effect";
|
|
2669
|
+
var RESOURCE11 = "LiteLLM.Toolset";
|
|
2670
|
+
var listToolsets = () => throughFetch(mcp2.fetchMcpToolsetsV1McpToolsetGet({})).pipe(Effect31.flatMap((response) => {
|
|
2473
2671
|
const rows = bodyOf(response);
|
|
2474
2672
|
if (!Array.isArray(rows)) {
|
|
2475
|
-
return
|
|
2673
|
+
return Effect31.fail(new LitellmRegistryUnreadableError({ reason: "not an array", resource: RESOURCE11 }));
|
|
2476
2674
|
}
|
|
2477
|
-
const parsed = rows.map(
|
|
2478
|
-
return parsed.every((row) => row !== undefined) ?
|
|
2675
|
+
const parsed = rows.map(toAttributes11);
|
|
2676
|
+
return parsed.every((row) => row !== undefined) ? Effect31.succeed(parsed) : Effect31.fail(new LitellmRegistryUnreadableError({
|
|
2479
2677
|
reason: "a row has no id or name",
|
|
2480
|
-
resource:
|
|
2678
|
+
resource: RESOURCE11
|
|
2481
2679
|
}));
|
|
2482
2680
|
}));
|
|
2483
|
-
var readToolset = (toolsetId) => throughFetch(mcp2.fetchMcpToolsetV1McpToolsetToolsetIdGet({ toolset_id: toolsetId })).pipe(
|
|
2484
|
-
const row =
|
|
2681
|
+
var readToolset = (toolsetId) => throughFetch(mcp2.fetchMcpToolsetV1McpToolsetToolsetIdGet({ toolset_id: toolsetId })).pipe(Effect31.map((response) => {
|
|
2682
|
+
const row = toAttributes11(bodyOf(response));
|
|
2485
2683
|
return row?.toolsetId === toolsetId ? row : undefined;
|
|
2486
|
-
}),
|
|
2487
|
-
var createToolset = (body) => throughFetch(mcp2.addMcpToolsetV1McpToolsetPost(body)).pipe(
|
|
2488
|
-
var updateToolset = (body) => throughFetch(mcp2.editMcpToolsetV1McpToolsetPut(body)).pipe(
|
|
2489
|
-
var deleteToolset = (toolsetId) => throughFetch(mcp2.removeMcpToolsetV1McpToolsetToolsetIdDelete({ toolset_id: toolsetId })).pipe(
|
|
2684
|
+
}), Effect31.catch((error) => isNotFound(error) ? Effect31.succeed(undefined) : Effect31.fail(error)));
|
|
2685
|
+
var createToolset = (body) => throughFetch(mcp2.addMcpToolsetV1McpToolsetPost(body)).pipe(Effect31.map((response) => toAttributes11(bodyOf(response))));
|
|
2686
|
+
var updateToolset = (body) => throughFetch(mcp2.editMcpToolsetV1McpToolsetPut(body)).pipe(Effect31.asVoid);
|
|
2687
|
+
var deleteToolset = (toolsetId) => throughFetch(mcp2.removeMcpToolsetV1McpToolsetToolsetIdDelete({ toolset_id: toolsetId })).pipe(Effect31.asVoid, Effect31.catch((original) => readToolset(toolsetId).pipe(Effect31.catch(() => Effect31.fail(original)), Effect31.flatMap((row) => row === undefined ? Effect31.void : Effect31.fail(original)))));
|
|
2490
2688
|
|
|
2491
2689
|
// src/litellm/toolset.ts
|
|
2492
|
-
var
|
|
2493
|
-
var LiteLLMToolset =
|
|
2690
|
+
var RESOURCE12 = "LiteLLM.Toolset";
|
|
2691
|
+
var LiteLLMToolset = Resource11("LiteLLM.Toolset", {
|
|
2494
2692
|
defaultRemovalPolicy: "retain"
|
|
2495
2693
|
});
|
|
2496
|
-
var isLiteLLMToolset = (value5) =>
|
|
2497
|
-
var
|
|
2694
|
+
var isLiteLLMToolset = (value5) => Predicate12.hasProperty(value5, "Type") && value5.Type === "LiteLLM.Toolset";
|
|
2695
|
+
var locate6 = (props, output) => Effect32.gen(function* () {
|
|
2498
2696
|
if (output !== undefined)
|
|
2499
2697
|
return yield* readToolset(output.toolsetId);
|
|
2500
2698
|
const named = (yield* listToolsets()).filter((row) => row.toolsetName === props.toolsetName);
|
|
2501
2699
|
if (named.length > 1) {
|
|
2502
|
-
return yield*
|
|
2700
|
+
return yield* Effect32.fail(new LitellmRegistryAmbiguousError({
|
|
2503
2701
|
ids: named.map((row) => row.toolsetId),
|
|
2504
2702
|
name: props.toolsetName,
|
|
2505
|
-
resource:
|
|
2703
|
+
resource: RESOURCE12
|
|
2506
2704
|
}));
|
|
2507
2705
|
}
|
|
2508
2706
|
return named[0];
|
|
2509
2707
|
});
|
|
2510
2708
|
var toolsetHandlers = {
|
|
2511
|
-
read: ({ olds, output }) =>
|
|
2709
|
+
read: ({ olds, output }) => Effect32.gen(function* () {
|
|
2512
2710
|
if (output === undefined) {
|
|
2513
|
-
yield* dieIfInvalid(
|
|
2711
|
+
yield* dieIfInvalid(RESOURCE12, String(olds.toolsetName), firstProblem9(olds));
|
|
2514
2712
|
}
|
|
2515
|
-
const live = yield*
|
|
2713
|
+
const live = yield* locate6(olds, output);
|
|
2516
2714
|
if (live === undefined)
|
|
2517
2715
|
return;
|
|
2518
|
-
return output === undefined ?
|
|
2716
|
+
return output === undefined ? Unowned12(live) : live;
|
|
2519
2717
|
}),
|
|
2520
|
-
diff: ({ news, output }) =>
|
|
2521
|
-
if (!
|
|
2718
|
+
diff: ({ news, output }) => Effect32.gen(function* () {
|
|
2719
|
+
if (!isResolved11(news))
|
|
2522
2720
|
return;
|
|
2523
|
-
yield* failIfInvalid(
|
|
2721
|
+
yield* failIfInvalid(RESOURCE12, String(news.toolsetName), firstProblem9(news));
|
|
2524
2722
|
if (output === undefined)
|
|
2525
2723
|
return;
|
|
2526
|
-
return
|
|
2724
|
+
return differing10(output, news).length === 0 ? { action: "noop" } : { action: "update" };
|
|
2527
2725
|
}),
|
|
2528
|
-
reconcile: ({ news, output }) =>
|
|
2529
|
-
yield* failIfInvalid(
|
|
2530
|
-
const before = yield*
|
|
2726
|
+
reconcile: ({ news, output }) => Effect32.gen(function* () {
|
|
2727
|
+
yield* failIfInvalid(RESOURCE12, String(news.toolsetName), firstProblem9(news));
|
|
2728
|
+
const before = yield* locate6(news, output);
|
|
2531
2729
|
let toolsetId;
|
|
2532
2730
|
if (before === undefined) {
|
|
2533
2731
|
const created = yield* createToolset(createBody9(news));
|
|
2534
2732
|
if (created === undefined) {
|
|
2535
|
-
return yield*
|
|
2733
|
+
return yield* Effect32.fail(new LitellmRegistryUnreadableError({
|
|
2536
2734
|
reason: "the create answered something that is not a toolset",
|
|
2537
|
-
resource:
|
|
2735
|
+
resource: RESOURCE12
|
|
2538
2736
|
}));
|
|
2539
2737
|
}
|
|
2540
2738
|
toolsetId = created.toolsetId;
|
|
2541
2739
|
} else {
|
|
2542
2740
|
toolsetId = before.toolsetId;
|
|
2543
|
-
if (
|
|
2544
|
-
yield* updateToolset(
|
|
2741
|
+
if (differing10(before, news).length > 0)
|
|
2742
|
+
yield* updateToolset(updateBody9(news, before));
|
|
2545
2743
|
}
|
|
2546
2744
|
const after = yield* readToolset(toolsetId);
|
|
2547
2745
|
if (after === undefined) {
|
|
2548
|
-
return yield*
|
|
2746
|
+
return yield* Effect32.fail(new LitellmRegistryAbsentAfterWriteError({ name: news.toolsetName, resource: RESOURCE12 }));
|
|
2549
2747
|
}
|
|
2550
|
-
const left =
|
|
2748
|
+
const left = differing10(after, news);
|
|
2551
2749
|
if (left.length > 0) {
|
|
2552
|
-
return yield*
|
|
2750
|
+
return yield* Effect32.fail(new LitellmRegistryNotConvergedError({
|
|
2553
2751
|
fields: left,
|
|
2554
2752
|
name: news.toolsetName,
|
|
2555
|
-
resource:
|
|
2753
|
+
resource: RESOURCE12
|
|
2556
2754
|
}));
|
|
2557
2755
|
}
|
|
2558
2756
|
return after;
|
|
2559
2757
|
}),
|
|
2560
2758
|
delete: ({ output }) => deleteToolset(output.toolsetId),
|
|
2561
|
-
list: () =>
|
|
2759
|
+
list: () => Effect32.succeed([])
|
|
2562
2760
|
};
|
|
2563
|
-
var LiteLLMToolsetProvider = () =>
|
|
2761
|
+
var LiteLLMToolsetProvider = () => Provider11.effect(LiteLLMToolset, Effect32.succeed(LiteLLMToolset.Provider.of(toolsetHandlers)));
|
|
2564
2762
|
// src/litellm/model.ts
|
|
2565
|
-
import { Resource as
|
|
2566
|
-
import { Unowned as
|
|
2567
|
-
import { isResolved as
|
|
2763
|
+
import { Resource as Resource12 } from "alchemy";
|
|
2764
|
+
import { Unowned as Unowned14 } from "alchemy/AdoptPolicy";
|
|
2765
|
+
import { isResolved as isResolved12 } from "alchemy/Diff";
|
|
2568
2766
|
import { createPhysicalName as createPhysicalName6 } from "alchemy/PhysicalName";
|
|
2569
|
-
import * as
|
|
2570
|
-
import * as
|
|
2571
|
-
import * as
|
|
2767
|
+
import * as Provider12 from "alchemy/Provider";
|
|
2768
|
+
import * as Effect38 from "effect/Effect";
|
|
2769
|
+
import * as Predicate13 from "effect/Predicate";
|
|
2572
2770
|
|
|
2573
2771
|
// src/litellm/model-errors.ts
|
|
2574
2772
|
import * as Data6 from "effect/Data";
|
|
@@ -2623,14 +2821,14 @@ class LitellmModelConfigFileRowError extends Data6.TaggedError("LitellmModelConf
|
|
|
2623
2821
|
}
|
|
2624
2822
|
|
|
2625
2823
|
// src/litellm/model-claim.ts
|
|
2626
|
-
import * as
|
|
2824
|
+
import * as Effect35 from "effect/Effect";
|
|
2627
2825
|
|
|
2628
2826
|
// src/ownership/adopting.ts
|
|
2629
|
-
import * as
|
|
2827
|
+
import * as Effect34 from "effect/Effect";
|
|
2630
2828
|
|
|
2631
2829
|
// src/ownership/probe.ts
|
|
2632
|
-
import { Unowned as
|
|
2633
|
-
import * as
|
|
2830
|
+
import { Unowned as Unowned13 } from "alchemy/AdoptPolicy";
|
|
2831
|
+
import * as Effect33 from "effect/Effect";
|
|
2634
2832
|
import * as Option5 from "effect/Option";
|
|
2635
2833
|
var inApplyResource = (span) => {
|
|
2636
2834
|
let at = span;
|
|
@@ -2645,32 +2843,32 @@ var isCreatesRead = (span) => {
|
|
|
2645
2843
|
const current = Option5.getOrUndefined(span);
|
|
2646
2844
|
return current?.name === "provider.read" && inApplyResource(current);
|
|
2647
2845
|
};
|
|
2648
|
-
var readsAtApply =
|
|
2649
|
-
var provenOurs = (ask, settled2) =>
|
|
2846
|
+
var readsAtApply = Effect33.map(Effect33.option(Effect33.currentSpan), isCreatesRead);
|
|
2847
|
+
var provenOurs = (ask, settled2) => Effect33.gen(function* () {
|
|
2650
2848
|
if (yield* readsAtApply)
|
|
2651
2849
|
return yield* resumes(ask.instanceId);
|
|
2652
2850
|
const recorded = yield* recordedInstance(ask.fqn, ask.instanceId);
|
|
2653
2851
|
if (recorded === "absent")
|
|
2654
2852
|
return false;
|
|
2655
2853
|
if (recorded === "partial") {
|
|
2656
|
-
yield*
|
|
2854
|
+
yield* Effect33.logWarning(`${ask.fqn}: the interrupted create's state row lacks part of the declaration (a prop ` + "was still an Output when it was written), so the live object is not proven ours");
|
|
2657
2855
|
return false;
|
|
2658
2856
|
}
|
|
2659
|
-
const unproven = (reason) =>
|
|
2660
|
-
return yield* settled2.pipe(
|
|
2857
|
+
const unproven = (reason) => Effect33.as(Effect33.logWarning(`${ask.fqn}: the interrupted create's object could not be compared with its props ` + `(${reason instanceof Error ? reason.message : String(reason)}), so it is not treated as ours`), false);
|
|
2858
|
+
return yield* settled2.pipe(Effect33.catch(unproven), Effect33.catchDefect(unproven));
|
|
2661
2859
|
});
|
|
2662
|
-
var ownedRead = (ask, found, settled2) =>
|
|
2860
|
+
var ownedRead = (ask, found, settled2) => Effect33.gen(function* () {
|
|
2663
2861
|
if (found === undefined || ask.output !== undefined)
|
|
2664
2862
|
return found;
|
|
2665
2863
|
if (yield* provenOurs(ask, settled2))
|
|
2666
2864
|
return found;
|
|
2667
2865
|
if (yield* readsAtApply)
|
|
2668
2866
|
yield* forgetRefusedCreate(ask.fqn, ask.instanceId);
|
|
2669
|
-
return
|
|
2867
|
+
return Unowned13(found);
|
|
2670
2868
|
});
|
|
2671
2869
|
|
|
2672
2870
|
// src/ownership/adopting.ts
|
|
2673
|
-
var adopting = (owner, settled2) =>
|
|
2871
|
+
var adopting = (owner, settled2) => Effect34.gen(function* () {
|
|
2674
2872
|
if (owner.output === undefined)
|
|
2675
2873
|
return false;
|
|
2676
2874
|
const generation = yield* recordedGeneration(owner.fqn, owner.instanceId);
|
|
@@ -2682,10 +2880,10 @@ var adopting = (owner, settled2) => Effect32.gen(function* () {
|
|
|
2682
2880
|
});
|
|
2683
2881
|
|
|
2684
2882
|
// src/litellm/model-claim.ts
|
|
2685
|
-
var claimStatelessRow = (args) =>
|
|
2883
|
+
var claimStatelessRow = (args) => Effect35.gen(function* () {
|
|
2686
2884
|
const older = yield* olderGenerationIds(args.fqn, args.instanceId);
|
|
2687
2885
|
if (older.includes(args.beforeId)) {
|
|
2688
|
-
return yield*
|
|
2886
|
+
return yield* Effect35.fail(new LitellmModelPriorGenerationError({
|
|
2689
2887
|
fqn: args.fqn,
|
|
2690
2888
|
id: args.beforeId,
|
|
2691
2889
|
modelName: args.news.modelName
|
|
@@ -2694,12 +2892,12 @@ var claimStatelessRow = (args) => Effect33.gen(function* () {
|
|
|
2694
2892
|
const unpinned = args.news.id === undefined;
|
|
2695
2893
|
const ours = unpinned && args.beforeId === args.wanted;
|
|
2696
2894
|
const owner = { fqn: args.fqn, instanceId: args.instanceId, output: args.output };
|
|
2697
|
-
const isAdoption = yield* adopting(owner, () =>
|
|
2895
|
+
const isAdoption = yield* adopting(owner, () => Effect35.succeed(false));
|
|
2698
2896
|
const creating = yield* isCreate(args.fqn, args.instanceId);
|
|
2699
2897
|
const mayAdopt = unpinned ? creating && (yield* adoptEnabled(args.fqn)) : yield* adoptsAtApply(owner);
|
|
2700
2898
|
if (!ours && !isAdoption && !mayAdopt) {
|
|
2701
2899
|
const replace = unpinned ? !creating : !creating && !(yield* unfinished(args.instanceId));
|
|
2702
|
-
return yield*
|
|
2900
|
+
return yield* Effect35.fail(new LitellmModelForeignRowError({
|
|
2703
2901
|
id: args.beforeId,
|
|
2704
2902
|
modelName: args.news.modelName,
|
|
2705
2903
|
replace
|
|
@@ -2724,7 +2922,7 @@ var sealFromValues = (values) => seal(values);
|
|
|
2724
2922
|
var sealState = (props, sealed) => sealMatches(sealed, declaredValues(props)) ? "match" : "stale";
|
|
2725
2923
|
|
|
2726
2924
|
// src/litellm/model-form.ts
|
|
2727
|
-
var
|
|
2925
|
+
var firstProblem10 = (props) => {
|
|
2728
2926
|
if (isBlank4(props.modelName) || props.modelName !== props.modelName.trim()) {
|
|
2729
2927
|
return "`modelName` must be a non-empty string without leading or trailing whitespace";
|
|
2730
2928
|
}
|
|
@@ -2754,7 +2952,7 @@ var firstProblem9 = (props) => {
|
|
|
2754
2952
|
};
|
|
2755
2953
|
var declaredDigest = (props) => sealFromValues(declaredValues(props));
|
|
2756
2954
|
var sameSet3 = (live, declared) => new Set(live).size === new Set(declared).size && declared.every((entry) => live.includes(entry));
|
|
2757
|
-
var
|
|
2955
|
+
var differing11 = (live, props) => {
|
|
2758
2956
|
const out = [];
|
|
2759
2957
|
if (live.modelName !== props.modelName)
|
|
2760
2958
|
out.push("model_name");
|
|
@@ -2769,7 +2967,7 @@ var differing10 = (live, props) => {
|
|
|
2769
2967
|
out.push("access_groups");
|
|
2770
2968
|
return out;
|
|
2771
2969
|
};
|
|
2772
|
-
var
|
|
2970
|
+
var toAttributes12 = (row) => {
|
|
2773
2971
|
const info = row["model_info"] ?? {};
|
|
2774
2972
|
const params = row["litellm_params"];
|
|
2775
2973
|
const carriedModel = typeof params === "object" && params !== null ? params["model"] : undefined;
|
|
@@ -2830,11 +3028,11 @@ var patchBody2 = (props, live) => {
|
|
|
2830
3028
|
|
|
2831
3029
|
// src/litellm/model-locate.ts
|
|
2832
3030
|
import { createPhysicalName as createPhysicalName5 } from "alchemy/PhysicalName";
|
|
2833
|
-
import * as
|
|
3031
|
+
import * as Effect37 from "effect/Effect";
|
|
2834
3032
|
|
|
2835
3033
|
// src/litellm/model-operations.ts
|
|
2836
3034
|
import * as models from "@distilled.cloud/litellm/model_management";
|
|
2837
|
-
import * as
|
|
3035
|
+
import * as Effect36 from "effect/Effect";
|
|
2838
3036
|
var hasRowId = (row) => {
|
|
2839
3037
|
if (typeof row !== "object" || row === null)
|
|
2840
3038
|
return false;
|
|
@@ -2844,49 +3042,49 @@ var hasRowId = (row) => {
|
|
|
2844
3042
|
};
|
|
2845
3043
|
var rowsOf = (response) => {
|
|
2846
3044
|
const rows = Array.isArray(response) ? response : Array.isArray(response?.data) ? response.data : response?.body;
|
|
2847
|
-
return Array.isArray(rows) && rows.every(hasRowId) ?
|
|
3045
|
+
return Array.isArray(rows) && rows.every(hasRowId) ? Effect36.succeed(rows.map(toAttributes12)) : Effect36.fail(new LitellmModelUnreadableError({
|
|
2848
3046
|
reason: Array.isArray(rows) ? "a row has no model id" : "not a list of deployments"
|
|
2849
3047
|
}));
|
|
2850
3048
|
};
|
|
2851
|
-
var listModels = () => throughFetch(models.getModelInfoV1ModelInfo({})).pipe(
|
|
2852
|
-
var readModelRow = (modelId) => throughFetch(models.getModelInfoV1ModelInfo({ litellm_model_id: modelId })).pipe(
|
|
2853
|
-
var createModel = (body) => throughFetch(models.addNewModelModelNewPost(body)).pipe(
|
|
2854
|
-
var patchModel = (body) => throughFetch(models.patchModelModelModelIdUpdatePatch(body)).pipe(
|
|
2855
|
-
var deleteModel = (modelId) => throughFetch(models.deleteModelModelDeletePost({ id: modelId })).pipe(
|
|
3049
|
+
var listModels = () => throughFetch(models.getModelInfoV1ModelInfo({})).pipe(Effect36.flatMap(rowsOf));
|
|
3050
|
+
var readModelRow = (modelId) => throughFetch(models.getModelInfoV1ModelInfo({ litellm_model_id: modelId })).pipe(Effect36.mapError((error) => error), Effect36.catchTag("NotFound", () => Effect36.succeed(undefined)), Effect36.catchTag("BadRequest", (error) => listModels().pipe(Effect36.flatMap((rows) => rows.some((row) => row.id === modelId) ? Effect36.fail(error) : Effect36.succeed(undefined)))), Effect36.flatMap((response) => response === undefined ? Effect36.succeed(undefined) : rowsOf(response).pipe(Effect36.map((rows) => rows.find((row) => row.id === modelId)))));
|
|
3051
|
+
var createModel = (body) => throughFetch(models.addNewModelModelNewPost(body)).pipe(Effect36.asVoid);
|
|
3052
|
+
var patchModel = (body) => throughFetch(models.patchModelModelModelIdUpdatePatch(body)).pipe(Effect36.asVoid);
|
|
3053
|
+
var deleteModel = (modelId) => throughFetch(models.deleteModelModelDeletePost({ id: modelId })).pipe(Effect36.asVoid, Effect36.catchTag("BadRequest", (original) => listModels().pipe(Effect36.flatMap((rows) => rows.some((row) => row.id === modelId) ? Effect36.fail(original) : Effect36.void))));
|
|
2856
3054
|
|
|
2857
3055
|
// src/litellm/model-locate.ts
|
|
2858
|
-
var
|
|
3056
|
+
var locate7 = (rows, props, output) => {
|
|
2859
3057
|
const pinned = output?.id ?? props.id;
|
|
2860
3058
|
if (pinned !== undefined)
|
|
2861
|
-
return
|
|
3059
|
+
return Effect37.succeed(rows.find((row) => row.id === pinned));
|
|
2862
3060
|
const named = rows.filter((row) => row.modelName === props.modelName);
|
|
2863
|
-
return named.length > 1 ?
|
|
3061
|
+
return named.length > 1 ? Effect37.fail(new LitellmModelAmbiguousNameError({
|
|
2864
3062
|
ids: named.map((row) => row.id),
|
|
2865
3063
|
modelName: props.modelName
|
|
2866
|
-
})) :
|
|
3064
|
+
})) : Effect37.succeed(named[0]);
|
|
2867
3065
|
};
|
|
2868
|
-
var wantedId2 = (id, instanceId, props, output) => output?.id !== undefined ?
|
|
2869
|
-
var findLive2 = (id, instanceId, props, output) =>
|
|
2870
|
-
const listed = yield*
|
|
3066
|
+
var wantedId2 = (id, instanceId, props, output) => output?.id !== undefined ? Effect37.succeed(output.id) : props.id !== undefined ? Effect37.succeed(props.id) : createPhysicalName5({ id, instanceId, lowercase: true, maxLength: 64 });
|
|
3067
|
+
var findLive2 = (id, instanceId, props, output) => Effect37.gen(function* () {
|
|
3068
|
+
const listed = yield* locate7(yield* listModels(), props, output);
|
|
2871
3069
|
if (listed !== undefined)
|
|
2872
3070
|
return listed;
|
|
2873
3071
|
return yield* readModelRow(yield* wantedId2(id, instanceId, props, output));
|
|
2874
3072
|
});
|
|
2875
3073
|
|
|
2876
3074
|
// src/litellm/model.ts
|
|
2877
|
-
var LiteLLMModel =
|
|
3075
|
+
var LiteLLMModel = Resource12("LiteLLM.Model", {
|
|
2878
3076
|
defaultRemovalPolicy: "retain"
|
|
2879
3077
|
});
|
|
2880
|
-
var isLiteLLMModel = (value5) =>
|
|
3078
|
+
var isLiteLLMModel = (value5) => Predicate13.hasProperty(value5, "Type") && value5.Type === "LiteLLM.Model";
|
|
2881
3079
|
var refuse3 = (props) => {
|
|
2882
|
-
const problem =
|
|
2883
|
-
return problem === undefined ?
|
|
3080
|
+
const problem = firstProblem10(props);
|
|
3081
|
+
return problem === undefined ? Effect38.void : Effect38.fail(new LitellmModelInvalidError({ problem, modelName: String(props.modelName) }));
|
|
2884
3082
|
};
|
|
2885
3083
|
var modelHandlers = {
|
|
2886
|
-
read: ({ id, instanceId, olds, output }) =>
|
|
2887
|
-
const problem = output === undefined ?
|
|
3084
|
+
read: ({ id, instanceId, olds, output }) => Effect38.gen(function* () {
|
|
3085
|
+
const problem = output === undefined ? firstProblem10(olds) : undefined;
|
|
2888
3086
|
if (problem !== undefined) {
|
|
2889
|
-
return yield*
|
|
3087
|
+
return yield* Effect38.die(new LitellmModelInvalidError({ problem, modelName: String(olds.modelName) }));
|
|
2890
3088
|
}
|
|
2891
3089
|
const found = yield* findLive2(id, instanceId, olds, output);
|
|
2892
3090
|
if (found === undefined)
|
|
@@ -2901,14 +3099,14 @@ var modelHandlers = {
|
|
|
2901
3099
|
if (found.id === physical)
|
|
2902
3100
|
return found;
|
|
2903
3101
|
}
|
|
2904
|
-
return output === undefined ?
|
|
3102
|
+
return output === undefined ? Unowned14(found) : { ...found, paramsSeal: output.paramsSeal };
|
|
2905
3103
|
}),
|
|
2906
3104
|
diff: ({
|
|
2907
3105
|
instanceId,
|
|
2908
3106
|
news,
|
|
2909
3107
|
output
|
|
2910
|
-
}) =>
|
|
2911
|
-
if (!
|
|
3108
|
+
}) => Effect38.gen(function* () {
|
|
3109
|
+
if (!isResolved12(news))
|
|
2912
3110
|
return;
|
|
2913
3111
|
yield* refuse3(news);
|
|
2914
3112
|
if (output === undefined)
|
|
@@ -2919,9 +3117,9 @@ var modelHandlers = {
|
|
|
2919
3117
|
if (news.modelName !== output.modelName && news.id === undefined) {
|
|
2920
3118
|
return { action: "replace", deleteFirst: false };
|
|
2921
3119
|
}
|
|
2922
|
-
return
|
|
3120
|
+
return differing11(output, news).length === 0 && sealState(news, output.paramsSeal) === "match" ? { action: "noop" } : { action: "update" };
|
|
2923
3121
|
}),
|
|
2924
|
-
reconcile: ({ fqn, id, instanceId, news, output }) =>
|
|
3122
|
+
reconcile: ({ fqn, id, instanceId, news, output }) => Effect38.gen(function* () {
|
|
2925
3123
|
yield* refuse3(news);
|
|
2926
3124
|
const before = yield* findLive2(id, instanceId, news, output);
|
|
2927
3125
|
let sealed = output?.paramsSeal ?? "";
|
|
@@ -2933,7 +3131,7 @@ var modelHandlers = {
|
|
|
2933
3131
|
sealed = declaredDigest(news);
|
|
2934
3132
|
} else {
|
|
2935
3133
|
if (before.dbModel === false) {
|
|
2936
|
-
return yield*
|
|
3134
|
+
return yield* Effect38.fail(new LitellmModelConfigFileRowError({ id: before.id, modelName: news.modelName }));
|
|
2937
3135
|
}
|
|
2938
3136
|
const stateless = output === undefined || output.paramsSeal === "";
|
|
2939
3137
|
if (stateless) {
|
|
@@ -2947,7 +3145,7 @@ var modelHandlers = {
|
|
|
2947
3145
|
});
|
|
2948
3146
|
}
|
|
2949
3147
|
modelId = before.id;
|
|
2950
|
-
const drifted =
|
|
3148
|
+
const drifted = differing11(before, news);
|
|
2951
3149
|
const sealStale = sealState(news, sealed) === "stale";
|
|
2952
3150
|
const sealNeedsStamp = sealStale && (sealed !== "" || news.apiKey !== undefined || news.apiBase !== undefined);
|
|
2953
3151
|
if (drifted.length > 0 || sealNeedsStamp) {
|
|
@@ -2958,11 +3156,11 @@ var modelHandlers = {
|
|
|
2958
3156
|
}
|
|
2959
3157
|
const after = (yield* listModels()).find((row) => row.id === modelId) ?? (yield* readModelRow(modelId));
|
|
2960
3158
|
if (after === undefined) {
|
|
2961
|
-
return yield*
|
|
3159
|
+
return yield* Effect38.fail(new LitellmModelAbsentAfterWriteError({ id: modelId, modelName: news.modelName }));
|
|
2962
3160
|
}
|
|
2963
|
-
const left =
|
|
3161
|
+
const left = differing11(after, news);
|
|
2964
3162
|
if (left.length > 0) {
|
|
2965
|
-
return yield*
|
|
3163
|
+
return yield* Effect38.fail(new LitellmModelNotConvergedError({
|
|
2966
3164
|
fields: left,
|
|
2967
3165
|
id: modelId,
|
|
2968
3166
|
modelName: news.modelName
|
|
@@ -2971,16 +3169,16 @@ var modelHandlers = {
|
|
|
2971
3169
|
return { ...after, paramsSeal: sealed };
|
|
2972
3170
|
}),
|
|
2973
3171
|
delete: ({ output }) => deleteModel(output.id),
|
|
2974
|
-
list: () =>
|
|
3172
|
+
list: () => Effect38.succeed([])
|
|
2975
3173
|
};
|
|
2976
|
-
var LiteLLMModelProvider = () =>
|
|
3174
|
+
var LiteLLMModelProvider = () => Provider12.effect(LiteLLMModel, Effect38.succeed(LiteLLMModel.Provider.of(modelHandlers)));
|
|
2977
3175
|
// src/litellm/key.ts
|
|
2978
|
-
import { Resource as
|
|
2979
|
-
import { Unowned as
|
|
2980
|
-
import { isResolved as
|
|
2981
|
-
import * as
|
|
2982
|
-
import * as
|
|
2983
|
-
import * as
|
|
3176
|
+
import { Resource as Resource13 } from "alchemy";
|
|
3177
|
+
import { Unowned as Unowned15 } from "alchemy/AdoptPolicy";
|
|
3178
|
+
import { isResolved as isResolved13 } from "alchemy/Diff";
|
|
3179
|
+
import * as Provider13 from "alchemy/Provider";
|
|
3180
|
+
import * as Effect41 from "effect/Effect";
|
|
3181
|
+
import * as Predicate15 from "effect/Predicate";
|
|
2984
3182
|
|
|
2985
3183
|
// src/litellm/key-errors.ts
|
|
2986
3184
|
import * as Data7 from "effect/Data";
|
|
@@ -3071,7 +3269,7 @@ import * as Redacted5 from "effect/Redacted";
|
|
|
3071
3269
|
import { deepEqual as deepEqual2 } from "alchemy/Diff";
|
|
3072
3270
|
var CALLBACK_SLOTS = ["callback_settings", "logging", "secret_manager_settings"];
|
|
3073
3271
|
var isObject = (value5) => typeof value5 === "object" && value5 !== null && !Array.isArray(value5);
|
|
3074
|
-
var callbackSlotsIn = (
|
|
3272
|
+
var callbackSlotsIn = (metadata2) => metadata2 === undefined ? [] : CALLBACK_SLOTS.filter((slot) => Object.hasOwn(metadata2, slot));
|
|
3075
3273
|
var splitMetadata = (raw) => {
|
|
3076
3274
|
if (!isObject(raw))
|
|
3077
3275
|
return { metadata: {}, withheld: [] };
|
|
@@ -3094,7 +3292,7 @@ var sameSet4 = (a, b) => {
|
|
|
3094
3292
|
return left.length === right.length && left.every((value6, i) => value6 === right[i]);
|
|
3095
3293
|
};
|
|
3096
3294
|
var expiryDiffers = (live, wanted) => live.duration !== wanted || wanted === null !== (live.expires === null);
|
|
3097
|
-
var
|
|
3295
|
+
var differing12 = (live, props) => {
|
|
3098
3296
|
const out = [];
|
|
3099
3297
|
if (props.budgetId !== undefined && live.budgetId !== props.budgetId)
|
|
3100
3298
|
out.push("budget_id");
|
|
@@ -3130,9 +3328,9 @@ var createBody11 = (props, secret) => {
|
|
|
3130
3328
|
body.duration = props.duration;
|
|
3131
3329
|
return body;
|
|
3132
3330
|
};
|
|
3133
|
-
var
|
|
3331
|
+
var updateBody10 = (props, live) => {
|
|
3134
3332
|
const body = { key_alias: live.keyAlias };
|
|
3135
|
-
for (const field of
|
|
3333
|
+
for (const field of differing12(live, props)) {
|
|
3136
3334
|
if (field === "budget_id")
|
|
3137
3335
|
body.budget_id = props.budgetId ?? null;
|
|
3138
3336
|
if (field === "models")
|
|
@@ -3150,15 +3348,15 @@ var updateBody9 = (props, live) => {
|
|
|
3150
3348
|
};
|
|
3151
3349
|
var strings = (value6) => Array.isArray(value6) ? value6.filter((item) => typeof item === "string") : [];
|
|
3152
3350
|
var stringOrNull2 = (value6) => typeof value6 === "string" ? value6 : null;
|
|
3153
|
-
var
|
|
3154
|
-
const { metadata, withheld } = splitMetadata(row["metadata"]);
|
|
3351
|
+
var toAttributes13 = (row) => {
|
|
3352
|
+
const { metadata: metadata2, withheld } = splitMetadata(row["metadata"]);
|
|
3155
3353
|
return {
|
|
3156
3354
|
allowedRoutes: strings(row["allowed_routes"]),
|
|
3157
3355
|
budgetId: stringOrNull2(row["budget_id"]),
|
|
3158
3356
|
duration: null,
|
|
3159
3357
|
expires: stringOrNull2(row["expires"]),
|
|
3160
3358
|
keyAlias: String(row["key_alias"]),
|
|
3161
|
-
metadata,
|
|
3359
|
+
metadata: metadata2,
|
|
3162
3360
|
models: strings(row["models"]),
|
|
3163
3361
|
teamId: stringOrNull2(row["team_id"]),
|
|
3164
3362
|
withheld
|
|
@@ -3182,12 +3380,12 @@ class LitellmKeyCallbackMetadataLiveError extends Data8.TaggedError("LitellmKeyC
|
|
|
3182
3380
|
|
|
3183
3381
|
// src/litellm/key-operations.ts
|
|
3184
3382
|
import * as keys from "@distilled.cloud/litellm/key_management";
|
|
3185
|
-
import * as
|
|
3186
|
-
import * as
|
|
3383
|
+
import * as Effect39 from "effect/Effect";
|
|
3384
|
+
import * as Predicate14 from "effect/Predicate";
|
|
3187
3385
|
import { isHttpClientError as isHttpClientError2 } from "effect/http/HttpClientError";
|
|
3188
|
-
var findKey = (keyAlias) => keyAlias.trim() === "" ?
|
|
3189
|
-
var findKeyByAlias = (keyAlias) => findKeyRowByAlias(keyAlias).pipe(
|
|
3190
|
-
var findKeyRowByAlias = (keyAlias) => throughFetch(keys.listKeysKeyListGet({ key_alias: keyAlias, return_full_object: true })).pipe(
|
|
3386
|
+
var findKey = (keyAlias) => keyAlias.trim() === "" ? Effect39.fail(new LitellmKeyAliasEmptyError) : findKeyByAlias(keyAlias);
|
|
3387
|
+
var findKeyByAlias = (keyAlias) => findKeyRowByAlias(keyAlias).pipe(Effect39.map((row) => row === undefined ? undefined : toAttributes13(row)));
|
|
3388
|
+
var findKeyRowByAlias = (keyAlias) => throughFetch(keys.listKeysKeyListGet({ key_alias: keyAlias, return_full_object: true })).pipe(Effect39.flatMap((response) => Effect39.gen(function* () {
|
|
3191
3389
|
const rows = response.keys ?? [];
|
|
3192
3390
|
if (rows.some((row) => typeof row !== "object" || row === null)) {
|
|
3193
3391
|
return yield* new LitellmKeyUnreadableError({ keyAlias });
|
|
@@ -3198,26 +3396,26 @@ var findKeyRowByAlias = (keyAlias) => throughFetch(keys.listKeysKeyListGet({ key
|
|
|
3198
3396
|
}
|
|
3199
3397
|
return mine[0];
|
|
3200
3398
|
})));
|
|
3201
|
-
var readKeyToken = (keyAlias) => keyAlias.trim() === "" ?
|
|
3202
|
-
var carriesRequest2 = (value6) => isHttpClientError2(value6) ||
|
|
3399
|
+
var readKeyToken = (keyAlias) => keyAlias.trim() === "" ? Effect39.fail(new LitellmKeyAliasEmptyError) : findKeyRowByAlias(keyAlias).pipe(Effect39.map((row) => row === undefined ? undefined : typeof row["token"] === "string" ? row["token"] : null));
|
|
3400
|
+
var carriesRequest2 = (value6) => isHttpClientError2(value6) || Predicate14.hasProperty(value6, "request");
|
|
3203
3401
|
var generateKey = (body) => {
|
|
3204
3402
|
const keyAlias = body.key_alias ?? "";
|
|
3205
|
-
return throughFetch(keys.generateKeyFnKeyGeneratePost(body)).pipe(
|
|
3403
|
+
return throughFetch(keys.generateKeyFnKeyGeneratePost(body)).pipe(Effect39.catchTag("HttpClientError", (error) => Effect39.fail(new LitellmKeyTransportError({ keyAlias, reason: error.reason._tag }))), Effect39.catchDefect((defect) => carriesRequest2(defect) ? Effect39.fail(new LitellmKeyTransportError({
|
|
3206
3404
|
keyAlias,
|
|
3207
3405
|
reason: isHttpClientError2(defect) ? defect.reason._tag : "Defect"
|
|
3208
|
-
})) :
|
|
3406
|
+
})) : Effect39.die(defect)));
|
|
3209
3407
|
};
|
|
3210
|
-
var updateKey = (body) => throughFetch(keys.updateKeyFnKeyUpdatePost(body)).pipe(
|
|
3211
|
-
var deleteKey = (keyAlias) => findKey(keyAlias).pipe(
|
|
3408
|
+
var updateKey = (body) => throughFetch(keys.updateKeyFnKeyUpdatePost(body)).pipe(Effect39.asVoid);
|
|
3409
|
+
var deleteKey = (keyAlias) => findKey(keyAlias).pipe(Effect39.flatMap((live) => live === undefined ? Effect39.void : throughFetch(keys.deleteKeyFnKeyDeletePost({ key_aliases: [keyAlias] })).pipe(Effect39.asVoid, Effect39.catchTag("KeyNotFound", (original) => findKey(keyAlias).pipe(Effect39.flatMap((still) => still === undefined ? Effect39.void : Effect39.fail(original)))))));
|
|
3212
3410
|
|
|
3213
3411
|
// src/litellm/key-secret.ts
|
|
3214
3412
|
import { createHash } from "node:crypto";
|
|
3215
|
-
import * as
|
|
3413
|
+
import * as Effect40 from "effect/Effect";
|
|
3216
3414
|
import * as Redacted6 from "effect/Redacted";
|
|
3217
3415
|
var PREFIX2 = "sk-";
|
|
3218
3416
|
var MIN_LENGTH = 16;
|
|
3219
3417
|
var RULE = `a user-defined key must start with '${PREFIX2}', be at least ${MIN_LENGTH} characters and contain no whitespace`;
|
|
3220
|
-
var resolveKeyValue = (keyAlias, ref) =>
|
|
3418
|
+
var resolveKeyValue = (keyAlias, ref) => Effect40.gen(function* () {
|
|
3221
3419
|
if (ref === undefined)
|
|
3222
3420
|
return yield* new LitellmKeyValueRequiredError({ keyAlias });
|
|
3223
3421
|
const variable = ref.fromEnv;
|
|
@@ -3231,7 +3429,7 @@ var resolveKeyValue = (keyAlias, ref) => Effect38.gen(function* () {
|
|
|
3231
3429
|
});
|
|
3232
3430
|
var echoes = (returned, sent) => (Redacted6.isRedacted(returned) ? Redacted6.value(returned) : returned) === Redacted6.value(sent);
|
|
3233
3431
|
var sha256 = (value7) => createHash("sha256").update(value7).digest("hex");
|
|
3234
|
-
var verifyKeyValue = (keyAlias, ref, token) =>
|
|
3432
|
+
var verifyKeyValue = (keyAlias, ref, token) => Effect40.gen(function* () {
|
|
3235
3433
|
if (ref === undefined)
|
|
3236
3434
|
return;
|
|
3237
3435
|
const variable = ref.fromEnv;
|
|
@@ -3242,18 +3440,18 @@ var verifyKeyValue = (keyAlias, ref, token) => Effect38.gen(function* () {
|
|
|
3242
3440
|
return yield* new LitellmKeyValueMismatchError({ keyAlias, variable });
|
|
3243
3441
|
}
|
|
3244
3442
|
});
|
|
3245
|
-
var refuseDebugLogging2 = (keyAlias) => (globalThis.process?.env?.["DISTILLED_DEBUG_HTTP"] ?? "") !== "" ?
|
|
3443
|
+
var refuseDebugLogging2 = (keyAlias) => (globalThis.process?.env?.["DISTILLED_DEBUG_HTTP"] ?? "") !== "" ? Effect40.fail(new LitellmKeyDebugLoggingError({ keyAlias })) : Effect40.void;
|
|
3246
3444
|
var hasKeyValue = (ref) => ref !== undefined && resolveAll({ key: ref }).values["key"] !== undefined;
|
|
3247
3445
|
|
|
3248
3446
|
// src/litellm/key.ts
|
|
3249
|
-
var LiteLLMKey =
|
|
3250
|
-
var isLiteLLMKey = (value7) =>
|
|
3447
|
+
var LiteLLMKey = Resource13("LiteLLM.Key", { defaultRemovalPolicy: "retain" });
|
|
3448
|
+
var isLiteLLMKey = (value7) => Predicate15.hasProperty(value7, "Type") && value7.Type === "LiteLLM.Key";
|
|
3251
3449
|
var remembering = (live, output) => ({
|
|
3252
3450
|
...live,
|
|
3253
3451
|
duration: output?.duration ?? null
|
|
3254
3452
|
});
|
|
3255
3453
|
var remembered = (news, before) => news.duration !== undefined ? news.duration : before?.duration ?? null;
|
|
3256
|
-
var refuseMetadata = (news, live) =>
|
|
3454
|
+
var refuseMetadata = (news, live) => Effect41.gen(function* () {
|
|
3257
3455
|
const declared = callbackSlotsIn(news.metadata);
|
|
3258
3456
|
if (declared.length > 0) {
|
|
3259
3457
|
return yield* new LitellmKeyCallbackMetadataDeclaredError({
|
|
@@ -3261,31 +3459,31 @@ var refuseMetadata = (news, live) => Effect39.gen(function* () {
|
|
|
3261
3459
|
slots: declared
|
|
3262
3460
|
});
|
|
3263
3461
|
}
|
|
3264
|
-
if (live !== undefined && live.withheld.length > 0 &&
|
|
3462
|
+
if (live !== undefined && live.withheld.length > 0 && differing12(live, news).includes("metadata")) {
|
|
3265
3463
|
return yield* new LitellmKeyCallbackMetadataLiveError({
|
|
3266
3464
|
keyAlias: news.keyAlias,
|
|
3267
3465
|
slots: live.withheld
|
|
3268
3466
|
});
|
|
3269
3467
|
}
|
|
3270
3468
|
});
|
|
3271
|
-
var createKey = (news) =>
|
|
3469
|
+
var createKey = (news) => Effect41.gen(function* () {
|
|
3272
3470
|
yield* refuseDebugLogging2(news.keyAlias);
|
|
3273
3471
|
const secret = yield* resolveKeyValue(news.keyAlias, news.key);
|
|
3274
3472
|
const created = yield* generateKey(createBody11(news, secret));
|
|
3275
3473
|
if (echoes(created.key, secret))
|
|
3276
3474
|
return;
|
|
3277
|
-
const removed = yield* deleteKey(news.keyAlias).pipe(
|
|
3475
|
+
const removed = yield* deleteKey(news.keyAlias).pipe(Effect41.as(true), Effect41.orElseSucceed(() => false));
|
|
3278
3476
|
return yield* new LitellmKeyValueNotHonouredError({ keyAlias: news.keyAlias, removed });
|
|
3279
3477
|
});
|
|
3280
3478
|
var keyHandlers = {
|
|
3281
|
-
read: ({ olds, output }) =>
|
|
3479
|
+
read: ({ olds, output }) => Effect41.gen(function* () {
|
|
3282
3480
|
const live = yield* findKey(output?.keyAlias ?? olds.keyAlias);
|
|
3283
3481
|
if (live === undefined)
|
|
3284
3482
|
return;
|
|
3285
|
-
return output === undefined ?
|
|
3483
|
+
return output === undefined ? Unowned15(live) : remembering(live, output);
|
|
3286
3484
|
}),
|
|
3287
|
-
diff: ({ news, output }) =>
|
|
3288
|
-
if (!
|
|
3485
|
+
diff: ({ news, output }) => Effect41.gen(function* () {
|
|
3486
|
+
if (!isResolved13(news))
|
|
3289
3487
|
return;
|
|
3290
3488
|
yield* refuseMetadata(news, output);
|
|
3291
3489
|
if (output === undefined)
|
|
@@ -3299,14 +3497,14 @@ var keyHandlers = {
|
|
|
3299
3497
|
return { action: "update" };
|
|
3300
3498
|
yield* verifyKeyValue(news.keyAlias, news.key, token);
|
|
3301
3499
|
}
|
|
3302
|
-
return
|
|
3500
|
+
return differing12(output, news).length === 0 ? { action: "noop" } : { action: "update" };
|
|
3303
3501
|
}),
|
|
3304
3502
|
reconcile: ({
|
|
3305
3503
|
fqn,
|
|
3306
3504
|
instanceId,
|
|
3307
3505
|
news,
|
|
3308
3506
|
output
|
|
3309
|
-
}) =>
|
|
3507
|
+
}) => Effect41.gen(function* () {
|
|
3310
3508
|
const alias = news.keyAlias;
|
|
3311
3509
|
yield* refuseMetadata(news, undefined);
|
|
3312
3510
|
const found = yield* findKey(alias);
|
|
@@ -3319,32 +3517,34 @@ var keyHandlers = {
|
|
|
3319
3517
|
yield* verifyKeyValue(alias, news.key, (yield* readKeyToken(alias)) ?? null);
|
|
3320
3518
|
}
|
|
3321
3519
|
yield* refuseMetadata(news, before);
|
|
3322
|
-
if (
|
|
3323
|
-
yield* updateKey(
|
|
3520
|
+
if (differing12(before, news).length > 0)
|
|
3521
|
+
yield* updateKey(updateBody10(news, before));
|
|
3324
3522
|
}
|
|
3325
3523
|
const after = yield* findKey(alias);
|
|
3326
3524
|
if (after === undefined)
|
|
3327
3525
|
return yield* new LitellmKeyAbsentAfterWriteError({ keyAlias: alias });
|
|
3328
3526
|
const settled2 = { ...after, duration: remembered(news, before) };
|
|
3329
|
-
const left =
|
|
3527
|
+
const left = differing12(settled2, news);
|
|
3330
3528
|
if (left.length > 0) {
|
|
3331
3529
|
return yield* new LitellmKeyFieldNotAppliedError({ fields: left, keyAlias: alias });
|
|
3332
3530
|
}
|
|
3333
3531
|
return settled2;
|
|
3334
3532
|
}),
|
|
3335
3533
|
delete: ({ output }) => deleteKey(output.keyAlias),
|
|
3336
|
-
list: () =>
|
|
3534
|
+
list: () => Effect41.succeed([])
|
|
3337
3535
|
};
|
|
3338
|
-
var LiteLLMKeyProvider = () =>
|
|
3536
|
+
var LiteLLMKeyProvider = () => Provider13.effect(LiteLLMKey, Effect41.succeed(LiteLLMKey.Provider.of(keyHandlers)));
|
|
3339
3537
|
// src/litellm/providers.ts
|
|
3340
3538
|
import { CredentialsFromEnv } from "@distilled.cloud/litellm/Credentials";
|
|
3341
3539
|
import * as Layer from "effect/Layer";
|
|
3342
|
-
var litellmProviders = (creds = CredentialsFromEnv) => Layer.mergeAll(LiteLLMPassThroughEndpointProvider(), LiteLLMBudgetProvider(), LiteLLMCredentialProvider(), LiteLLMMCPServerProvider(), LiteLLMAccessGroupProvider(), LiteLLMToolsetProvider(), LiteLLMToolPolicyProvider(), LiteLLMPolicyProvider(), LiteLLMPolicyAttachmentProvider(), LiteLLMTeamProvider(), LiteLLMKeyProvider(), LiteLLMModelProvider()).pipe(Layer.provideMerge(creds));
|
|
3540
|
+
var litellmProviders = (creds = CredentialsFromEnv) => Layer.mergeAll(LiteLLMPassThroughEndpointProvider(), LiteLLMBudgetProvider(), LiteLLMCredentialProvider(), LiteLLMMCPServerProvider(), LiteLLMAccessGroupProvider(), LiteLLMClaudeCodeMarketplacePluginProvider(), LiteLLMToolsetProvider(), LiteLLMToolPolicyProvider(), LiteLLMPolicyProvider(), LiteLLMPolicyAttachmentProvider(), LiteLLMTeamProvider(), LiteLLMKeyProvider(), LiteLLMModelProvider()).pipe(Layer.provideMerge(creds));
|
|
3343
3541
|
export {
|
|
3344
3542
|
LiteLLMAccessGroup,
|
|
3345
3543
|
LiteLLMAccessGroupProvider,
|
|
3346
3544
|
LiteLLMBudget,
|
|
3347
3545
|
LiteLLMBudgetProvider,
|
|
3546
|
+
LiteLLMClaudeCodeMarketplacePlugin,
|
|
3547
|
+
LiteLLMClaudeCodeMarketplacePluginProvider,
|
|
3348
3548
|
LiteLLMCredential,
|
|
3349
3549
|
LiteLLMCredentialProvider,
|
|
3350
3550
|
LiteLLMKey,
|
|
@@ -3412,6 +3612,7 @@ export {
|
|
|
3412
3612
|
LitellmUnaddressableRowError,
|
|
3413
3613
|
isLiteLLMAccessGroup,
|
|
3414
3614
|
isLiteLLMBudget,
|
|
3615
|
+
isLiteLLMClaudeCodeMarketplacePlugin,
|
|
3415
3616
|
isLiteLLMCredential,
|
|
3416
3617
|
isLiteLLMKey,
|
|
3417
3618
|
isLiteLLMMCPServer,
|
|
@@ -3425,5 +3626,5 @@ export {
|
|
|
3425
3626
|
litellmProviders
|
|
3426
3627
|
};
|
|
3427
3628
|
|
|
3428
|
-
//# debugId=
|
|
3629
|
+
//# debugId=7E0878290952A6B164756E2164756E21
|
|
3429
3630
|
//# sourceMappingURL=index.js.map
|