@homeflare/alchemy 0.27.4 → 0.29.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -0
- package/dist/caddy/admin-address.d.ts +27 -0
- package/dist/caddy/admin-address.d.ts.map +1 -0
- package/dist/caddy/admin-calls.d.ts +25 -28
- package/dist/caddy/admin-calls.d.ts.map +1 -1
- package/dist/caddy/admin.d.ts +28 -38
- package/dist/caddy/admin.d.ts.map +1 -1
- package/dist/caddy/caddy-http-client.d.ts +25 -0
- package/dist/caddy/caddy-http-client.d.ts.map +1 -0
- package/dist/caddy/config-errors.d.ts +24 -0
- package/dist/caddy/config-errors.d.ts.map +1 -0
- package/dist/caddy/config-lifecycle.d.ts +20 -49
- package/dist/caddy/config-lifecycle.d.ts.map +1 -1
- package/dist/caddy/config-reconcile.d.ts +45 -0
- package/dist/caddy/config-reconcile.d.ts.map +1 -0
- package/dist/caddy/config.d.ts +4 -3
- package/dist/caddy/config.d.ts.map +1 -1
- package/dist/caddy/fake-caddy.d.ts +10 -2
- package/dist/caddy/fake-caddy.d.ts.map +1 -1
- package/dist/caddy/index.d.ts +3 -3
- package/dist/caddy/index.d.ts.map +1 -1
- package/dist/caddy/index.js +487 -444
- package/dist/caddy/index.js.map +16 -12
- package/dist/caddy/local-admin.d.ts +20 -34
- package/dist/caddy/local-admin.d.ts.map +1 -1
- package/dist/caddy/providers.d.ts +19 -3
- package/dist/caddy/providers.d.ts.map +1 -1
- package/dist/cloudflare/mesh-node-token.d.ts +1 -1
- package/dist/cloudflare/mesh-node-token.d.ts.map +1 -1
- package/dist/forgejo/branch-protection.d.ts +4 -4
- package/dist/forgejo/org-actions-secrets.d.ts +4 -4
- package/dist/forgejo/org-label.d.ts +4 -4
- package/dist/forgejo/org-team.d.ts +4 -4
- package/dist/forgejo/repo-webhook.d.ts +4 -4
- package/dist/forgejo/repository.d.ts +4 -4
- package/dist/forgejo/team-member.d.ts +4 -4
- package/dist/github/declare-repo-baseline.d.ts +1 -1
- package/dist/github/declare-repo-baseline.d.ts.map +1 -1
- package/dist/github/index.d.ts +9 -5
- package/dist/github/index.d.ts.map +1 -1
- package/dist/github/index.js +161 -25
- package/dist/github/index.js.map +15 -13
- package/dist/github/repo-baseline-data.d.ts +10 -1
- package/dist/github/repo-baseline-data.d.ts.map +1 -1
- package/dist/github/repo-policy.d.ts +1 -1
- package/dist/github/repo-policy.d.ts.map +1 -1
- package/dist/github/repository-ruleset-errors.d.ts +37 -3
- package/dist/github/repository-ruleset-errors.d.ts.map +1 -1
- package/dist/github/repository-ruleset-form.d.ts.map +1 -1
- package/dist/github/repository-ruleset-guards.d.ts +15 -2
- package/dist/github/repository-ruleset-guards.d.ts.map +1 -1
- package/dist/github/repository-ruleset-narrowing-guards.d.ts +39 -0
- package/dist/github/repository-ruleset-narrowing-guards.d.ts.map +1 -0
- package/dist/github/repository-ruleset-octokit.d.ts +49 -0
- package/dist/github/repository-ruleset-octokit.d.ts.map +1 -1
- package/dist/github/repository-ruleset-probe.d.ts +2 -1
- package/dist/github/repository-ruleset-probe.d.ts.map +1 -1
- package/dist/github/repository-ruleset-props.d.ts +91 -0
- package/dist/github/repository-ruleset-props.d.ts.map +1 -0
- package/dist/github/repository-ruleset-providers.d.ts +42 -0
- package/dist/github/repository-ruleset-providers.d.ts.map +1 -0
- package/dist/github/repository-ruleset-reconcile.d.ts.map +1 -1
- package/dist/github/repository-ruleset.d.ts +28 -34
- package/dist/github/repository-ruleset.d.ts.map +1 -1
- package/dist/litellm/fake-litellm.d.ts +27 -16
- package/dist/litellm/fake-litellm.d.ts.map +1 -1
- package/dist/litellm/fake-stack.d.ts +9 -4
- package/dist/litellm/fake-stack.d.ts.map +1 -1
- package/dist/litellm/index.d.ts +7 -5
- package/dist/litellm/index.d.ts.map +1 -1
- package/dist/litellm/index.js +53 -123
- package/dist/litellm/index.js.map +8 -8
- package/dist/litellm/operations.d.ts +60 -0
- package/dist/litellm/operations.d.ts.map +1 -0
- package/dist/litellm/pass-through-endpoint.d.ts +10 -28
- package/dist/litellm/pass-through-endpoint.d.ts.map +1 -1
- package/dist/litellm/pass-through-errors.d.ts +37 -0
- package/dist/litellm/pass-through-errors.d.ts.map +1 -0
- package/dist/litellm/pass-through-form.d.ts +11 -4
- package/dist/litellm/pass-through-form.d.ts.map +1 -1
- package/dist/litellm/providers.d.ts +7 -5
- package/dist/litellm/providers.d.ts.map +1 -1
- package/dist/netbox/prefix.d.ts +4 -4
- package/dist/paperless/custom-field.d.ts +21 -21
- package/dist/paperless/custom-field.d.ts.map +1 -1
- package/dist/paperless/document-type.d.ts +34 -4
- package/dist/paperless/document-type.d.ts.map +1 -1
- package/dist/paperless/fake-paperless.d.ts +36 -19
- package/dist/paperless/fake-paperless.d.ts.map +1 -1
- package/dist/paperless/index.d.ts +7 -2
- package/dist/paperless/index.d.ts.map +1 -1
- package/dist/paperless/index.js +164 -228
- package/dist/paperless/index.js.map +10 -13
- package/dist/paperless/matching-locate.d.ts +42 -20
- package/dist/paperless/matching-locate.d.ts.map +1 -1
- package/dist/paperless/matching-types.d.ts +47 -18
- package/dist/paperless/matching-types.d.ts.map +1 -1
- package/dist/paperless/matching.d.ts +30 -27
- package/dist/paperless/matching.d.ts.map +1 -1
- package/dist/paperless/providers.d.ts +13 -7
- package/dist/paperless/providers.d.ts.map +1 -1
- package/dist/paperless/storage-path.d.ts +34 -4
- package/dist/paperless/storage-path.d.ts.map +1 -1
- package/dist/paperless/tag.d.ts +43 -8
- package/dist/paperless/tag.d.ts.map +1 -1
- package/dist/proxmox/acl.d.ts +30 -23
- package/dist/proxmox/acl.d.ts.map +1 -1
- package/dist/proxmox/distilled-pve.d.ts +89 -0
- package/dist/proxmox/distilled-pve.d.ts.map +1 -0
- package/dist/proxmox/index.js +663 -609
- package/dist/proxmox/index.js.map +12 -11
- package/dist/proxmox/members.d.ts +29 -10
- package/dist/proxmox/members.d.ts.map +1 -1
- package/docs/caddy-admin.md +1 -1
- package/docs/caddy.md +3 -2
- package/docs/credentials.md +16 -0
- package/docs/litellm.md +21 -13
- package/docs/paperless.md +12 -0
- package/docs/peers.md +5 -0
- package/docs/repo-policy.md +16 -1
- package/docs/repository-ruleset.md +53 -13
- package/docs/upstream-conformance.md +126 -10
- package/package.json +9 -2
- package/src/caddy/admin-address.ts +71 -0
- package/src/caddy/admin-calls.ts +48 -100
- package/src/caddy/admin.ts +37 -41
- package/src/caddy/adopt-scope.test.ts +1 -1
- package/src/caddy/caddy-http-client.ts +229 -0
- package/src/caddy/config-adopt-provider.test.ts +139 -0
- package/src/caddy/config-adopt.test.ts +60 -126
- package/src/caddy/config-errors.ts +47 -0
- package/src/caddy/config-lifecycle.test.ts +55 -42
- package/src/caddy/config-lifecycle.ts +72 -162
- package/src/caddy/config-reconcile.ts +138 -0
- package/src/caddy/config.ts +36 -42
- package/src/caddy/fake-caddy.ts +20 -2
- package/src/caddy/index.ts +3 -8
- package/src/caddy/local-admin.test.ts +35 -21
- package/src/caddy/local-admin.ts +60 -167
- package/src/caddy/providers.test.ts +14 -6
- package/src/caddy/providers.ts +20 -4
- package/src/github/declare-repo-baseline.ts +6 -6
- package/src/github/index.ts +10 -4
- package/src/github/repo-baseline-data.test.ts +13 -0
- package/src/github/repo-baseline-data.ts +11 -2
- package/src/github/repo-policy-stack.test.ts +59 -0
- package/src/github/repo-policy.ts +3 -2
- package/src/github/repository-ruleset-errors.ts +51 -4
- package/src/github/repository-ruleset-exact-adopt-k1.test.ts +109 -0
- package/src/github/repository-ruleset-exact-adopt.test.ts +184 -0
- package/src/github/repository-ruleset-form.ts +7 -3
- package/src/github/repository-ruleset-guards.ts +11 -4
- package/src/github/repository-ruleset-narrowing-guards.ts +141 -0
- package/src/github/repository-ruleset-narrowing.test.ts +210 -0
- package/src/github/repository-ruleset-octokit.test.ts +141 -0
- package/src/github/repository-ruleset-octokit.ts +121 -30
- package/src/github/repository-ruleset-probe.ts +2 -1
- package/src/github/repository-ruleset-props.ts +95 -0
- package/src/github/repository-ruleset-providers.ts +46 -0
- package/src/github/repository-ruleset-reconcile.ts +35 -0
- package/src/github/repository-ruleset-wire.test.ts +38 -27
- package/src/github/repository-ruleset-write-refusals.test.ts +6 -26
- package/src/github/repository-ruleset.ts +53 -43
- package/src/litellm/fake-litellm.ts +83 -78
- package/src/litellm/fake-stack.ts +13 -5
- package/src/litellm/index.ts +7 -21
- package/src/litellm/operations.ts +149 -0
- package/src/litellm/pass-through-endpoint-delete-swallow.test.ts +17 -20
- package/src/litellm/pass-through-endpoint-replace.test.ts +3 -4
- package/src/litellm/pass-through-endpoint.test.ts +8 -8
- package/src/litellm/pass-through-endpoint.ts +21 -31
- package/src/litellm/pass-through-errors.ts +37 -0
- package/src/litellm/pass-through-form.ts +20 -10
- package/src/litellm/providers.ts +8 -7
- package/src/paperless/custom-field.test.ts +49 -40
- package/src/paperless/custom-field.ts +57 -33
- package/src/paperless/document-type.test.ts +48 -0
- package/src/paperless/document-type.ts +51 -22
- package/src/paperless/fake-paperless.ts +63 -72
- package/src/paperless/index.ts +7 -13
- package/src/paperless/matching-locate.test.ts +102 -0
- package/src/paperless/matching-locate.ts +80 -86
- package/src/paperless/matching-types.ts +49 -16
- package/src/paperless/matching.ts +77 -90
- package/src/paperless/providers.ts +14 -10
- package/src/paperless/storage-path.test.ts +56 -0
- package/src/paperless/storage-path.ts +53 -24
- package/src/paperless/tag-identity.test.ts +127 -0
- package/src/paperless/tag.test.ts +100 -0
- package/src/paperless/tag.ts +62 -32
- package/src/proxmox/acl.test.ts +145 -0
- package/src/proxmox/acl.ts +128 -150
- package/src/proxmox/distilled-pve.test.ts +231 -0
- package/src/proxmox/distilled-pve.ts +147 -0
- package/src/proxmox/members-timeout.test.ts +161 -0
- package/src/proxmox/members.test.ts +9 -0
- package/src/proxmox/members.ts +36 -2
- package/dist/litellm/client.d.ts +0 -76
- package/dist/litellm/client.d.ts.map +0 -1
- package/dist/litellm/credentials.d.ts +0 -48
- package/dist/litellm/credentials.d.ts.map +0 -1
- package/dist/litellm/generated/pass-through.d.ts +0 -71
- package/dist/litellm/generated/pass-through.d.ts.map +0 -1
- package/dist/paperless/client.d.ts +0 -37
- package/dist/paperless/client.d.ts.map +0 -1
- package/dist/paperless/credentials.d.ts +0 -40
- package/dist/paperless/credentials.d.ts.map +0 -1
- package/dist/paperless/errors.d.ts +0 -49
- package/dist/paperless/errors.d.ts.map +0 -1
- package/src/litellm/client.ts +0 -195
- package/src/litellm/credentials.ts +0 -73
- package/src/litellm/generated/pass-through.ts +0 -73
- package/src/paperless/client.ts +0 -88
- package/src/paperless/credentials.ts +0 -69
- package/src/paperless/errors.ts +0 -62
- package/src/paperless/matching-identity.test.ts +0 -194
- package/src/paperless/matching.test.ts +0 -128
|
@@ -1,31 +1,42 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* A
|
|
3
|
-
*
|
|
2
|
+
* A fake of LiteLLM's `/config/pass_through_endpoint` routes for tests — TEST ONLY, never imported
|
|
3
|
+
* by `index.ts` (the netbox/forgejo house convention for test-only helpers). Mirrors
|
|
4
|
+
* `../netbox/fake-netbox.ts`/`../forgejo/fake-forgejo.ts`: a `fetch` function handed to Effect's
|
|
5
|
+
* real `FetchHttpClient` through its `Fetch` reference, so a test exercises distilled's REAL path
|
|
6
|
+
* assembly, JSON encode/decode and status→typed-error matching (`BadRequest`, `NotFound`, …) —
|
|
7
|
+
* nothing about that matching is re-implemented here, only the wire responses a scenario needs.
|
|
4
8
|
*
|
|
5
9
|
* ★ MODELS THE WHOLE-FIELD READ-MODIFY-WRITE ON PURPOSE. `general_settings.pass_through_endpoints`
|
|
6
|
-
* is ONE field (
|
|
7
|
-
* (so two concurrent
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
+
* is ONE field (operations.ts's header), so every mutation here reads the CURRENT row list,
|
|
11
|
+
* awaits (so two concurrent calls can interleave — no real socket needed, `fetch` is just an
|
|
12
|
+
* async function the runtime awaits), then writes back what it captured — not what is there by
|
|
13
|
+
* the time it writes. Two `create` calls that race lose one row, exactly like the vendor field
|
|
14
|
+
* would without `operations.ts`'s per-base-URL semaphore serialising them.
|
|
10
15
|
* ⚠️ WHAT THIS FAKE DOES NOT MODEL: PROXY_ADMIN vs. a lesser role for most routes (any correct
|
|
11
|
-
* bearer token is accepted)
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
16
|
+
* bearer token is accepted). `forbidDelete` is the one exception: it models the real asymmetry
|
|
17
|
+
* `operations.ts`'s header describes — `DELETE` routes through `update_config_general_settings`,
|
|
18
|
+
* which 400s `not_allowed_access` for a non-PROXY_ADMIN caller (or a disconnected DB) on a row
|
|
19
|
+
* that is genuinely still live, the SAME status a missing-id delete gets (proxy_server.py:
|
|
20
|
+
* 16389-16416 at v1.100.0).
|
|
21
|
+
* ⚠️ UPDATE-OF-A-MISSING-ID IS 404, NOT 400 — corrected by this migration. The retired hand-rolled
|
|
22
|
+
* fake 400'd it as "not measured at the tag, a documented test simplification". The distilled
|
|
23
|
+
* SDK's own `patches/misc/update_pass_through_endpoints_*.json` cites the real source
|
|
24
|
+
* (`pass_through_endpoints.py`'s `update_pass_through_endpoints` at the tag): unlike DELETE, this
|
|
25
|
+
* route raises a genuine, unambiguous `HTTPException(404)` for a missing id, distinct from the
|
|
26
|
+
* 400 `update_config_general_settings` raises for the trailing auth/DB-disconnected write. This
|
|
27
|
+
* fake now matches that measured vendor behaviour.
|
|
18
28
|
*/
|
|
19
|
-
import type { PassThroughGenericEndpoint } from '
|
|
29
|
+
import type { PassThroughGenericEndpoint } from '@distilled.cloud/litellm/misc';
|
|
30
|
+
/** RFC 2606 placeholder — never a real host. Shared across tests, like `../netbox/fake-netbox.ts`. */
|
|
31
|
+
export declare const FAKE_BASE = "https://litellm.example.com";
|
|
20
32
|
export interface FakeRequest {
|
|
21
33
|
readonly method: string;
|
|
22
34
|
readonly path: string;
|
|
23
35
|
}
|
|
24
36
|
export interface FakeLitellm {
|
|
25
|
-
readonly
|
|
37
|
+
readonly fetch: typeof globalThis.fetch;
|
|
26
38
|
readonly rows: () => readonly PassThroughGenericEndpoint[];
|
|
27
39
|
readonly requests: () => readonly FakeRequest[];
|
|
28
|
-
readonly stop: () => void;
|
|
29
40
|
}
|
|
30
41
|
export declare const startFakeLitellm: (options?: {
|
|
31
42
|
readonly masterKey?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fake-litellm.d.ts","sourceRoot":"","sources":["../../src/litellm/fake-litellm.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"fake-litellm.d.ts","sourceRoot":"","sources":["../../src/litellm/fake-litellm.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,+BAA+B,CAAC;AAEhF,sGAAsG;AACtG,eAAO,MAAM,SAAS,gCAAgC,CAAC;AAEvD,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,KAAK,EAAE,OAAO,UAAU,CAAC,KAAK,CAAC;IACxC,QAAQ,CAAC,IAAI,EAAE,MAAM,SAAS,0BAA0B,EAAE,CAAC;IAC3D,QAAQ,CAAC,QAAQ,EAAE,MAAM,SAAS,WAAW,EAAE,CAAC;CACjD;AAQD,eAAO,MAAM,gBAAgB,aAAc;IACzC,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,IAAI,CAAC,EAAE,SAAS,0BAA0B,EAAE,CAAC;IACtD,qGAAqG;IACrG,QAAQ,CAAC,YAAY,CAAC,EAAE,OAAO,CAAC;CACjC,KAAG,WAiEH,CAAC"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import * as Effect from 'effect/Effect';
|
|
2
|
-
import { type LitellmCreds } from './credentials.ts';
|
|
3
2
|
/** The planned action for each resource, deletions included, keyed by FQN. */
|
|
4
3
|
export type Planned = Readonly<Record<string, string>>;
|
|
5
4
|
/** A stack body: resource declarations, as an `alchemy.run.ts` would write them. */
|
|
@@ -15,13 +14,19 @@ export interface FakeStack {
|
|
|
15
14
|
/**
|
|
16
15
|
* ⚠️ CREDENTIALS/HTTPCLIENT ARE PROVIDED AROUND `deploy`, NOT BAKED INTO THE PROVIDER LAYER.
|
|
17
16
|
* `Provider.effect`'s own construction effect is `Effect.succeed(...)` (pass-through-endpoint.ts)
|
|
18
|
-
* — it never actually reads `
|
|
19
|
-
*
|
|
17
|
+
* — it never actually reads `Credentials`/`HttpClient`; only the HANDLERS it returns do, and
|
|
18
|
+
* those run later, whenever `Apply.ts` calls `provider.reconcile`/`read`/`delete`. Effect
|
|
20
19
|
* resolves a `yield*`'s service from whatever ambient context wraps the CALL SITE, so the layers
|
|
21
20
|
* those handlers need must wrap the whole plan+apply pipeline below, exactly where openbao's
|
|
22
21
|
* fake-stack.ts wraps `BaoEnv` around its own `deploy`.
|
|
22
|
+
* ★ `fetchFn` IS `startFakeLitellm(...).fetch` (fake-litellm.ts) — this harness never opens a real
|
|
23
|
+
* socket; `FetchHttpClient.Fetch` is the seam the SDK's protocol layer calls through, same as
|
|
24
|
+
* `../netbox/fake-netbox.ts`'s `fakeNetboxLayer`.
|
|
23
25
|
*/
|
|
24
|
-
export declare const fakeStack: (creds:
|
|
26
|
+
export declare const fakeStack: (creds: {
|
|
27
|
+
readonly apiKey: string;
|
|
28
|
+
readonly baseUrl: string;
|
|
29
|
+
}, fetchFn: typeof globalThis.fetch, name?: string) => FakeStack;
|
|
25
30
|
/** Every call that changed something, as `METHOD path`, in order. */
|
|
26
31
|
export declare const writesOf: (requests: readonly {
|
|
27
32
|
readonly method: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fake-stack.d.ts","sourceRoot":"","sources":["../../src/litellm/fake-stack.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"fake-stack.d.ts","sourceRoot":"","sources":["../../src/litellm/fake-stack.ts"],"names":[],"mappings":"AAkBA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAKxC,8EAA8E;AAC9E,MAAM,MAAM,OAAO,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;AAEvD,oFAAoF;AACpF,MAAM,MAAM,SAAS,GAAG,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;AAEjE,6FAA6F;AAC7F,MAAM,MAAM,aAAa,GAAG;IAAE,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC;AAEzD,MAAM,WAAW,SAAS;IACxB,wFAAwF;IACxF,QAAQ,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,SAAS,EAAE,OAAO,CAAC,EAAE,aAAa,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;CACjF;AAiBD;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,SAAS,UACb;IAAE,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;CAAE,WACnD,OAAO,UAAU,CAAC,KAAK,oBAE/B,SAiCF,CAAC;AAEF,qEAAqE;AACrE,eAAO,MAAM,QAAQ,aACT,SAAS;IAAE,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,EAAE,KACtE,MAAM,EACsF,CAAC"}
|
package/dist/litellm/index.d.ts
CHANGED
|
@@ -2,12 +2,14 @@
|
|
|
2
2
|
* LiteLLM providers for Alchemy.
|
|
3
3
|
*
|
|
4
4
|
* ⛔ THIS BARREL IS THE PUBLIC API, deliberately smaller than the directory — `fake-litellm.ts`
|
|
5
|
-
* and the internals `pass-through-form.ts`/`
|
|
6
|
-
* directly are not re-exported here (netbox/index.ts's own rule).
|
|
5
|
+
* and the internals `pass-through-form.ts`/`operations.ts` need but a consumer should not depend
|
|
6
|
+
* on directly are not re-exported here (netbox/index.ts's own rule).
|
|
7
|
+
* ★ CREDENTIALS AND TYPES NOW COME FROM `@distilled.cloud/litellm` ITSELF (2026-09-24, moved off a
|
|
8
|
+
* hand-rolled `client.ts`/`credentials.ts` the same way `/netbox` and `/forgejo` did) — a
|
|
9
|
+
* consumer building its own credentials layer imports `Credentials`/`CredentialsFromEnv`/
|
|
10
|
+
* `credentials` from `@distilled.cloud/litellm/Credentials` directly, not through this barrel.
|
|
7
11
|
*/
|
|
8
|
-
export
|
|
9
|
-
export { LITELLM_OPERATIONS, LitellmBadRequestError, type LitellmError, LitellmHttpError, type LitellmRequirements, LitellmTransportError, LitellmUnauthorizedError, } from './client.ts';
|
|
10
|
-
export type { PassThroughEndpointResponse, PassThroughGenericEndpoint, PassThroughGuardrailSettings, } from './generated/pass-through.ts';
|
|
12
|
+
export type { PassThroughEndpointResponse, PassThroughGenericEndpoint, PassThroughGuardrailSettings, } from '@distilled.cloud/litellm/misc';
|
|
11
13
|
export { LiteLLMPassThroughEndpoint, LiteLLMPassThroughEndpointProvider, LitellmConfigPathConflictError, LitellmLiteralSecretHeaderError, LitellmUnaddressableRowError, isLiteLLMPassThroughEndpoint, type PassThroughEndpointAttributes, type PassThroughEndpointError, type PassThroughEndpointProps, } from './pass-through-endpoint.ts';
|
|
12
14
|
export { litellmProviders } from './providers.ts';
|
|
13
15
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/litellm/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/litellm/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,YAAY,EACV,2BAA2B,EAC3B,0BAA0B,EAC1B,4BAA4B,GAC7B,MAAM,+BAA+B,CAAC;AACvC,OAAO,EACL,0BAA0B,EAC1B,kCAAkC,EAClC,8BAA8B,EAC9B,+BAA+B,EAC/B,4BAA4B,EAC5B,4BAA4B,EAC5B,KAAK,6BAA6B,EAClC,KAAK,wBAAwB,EAC7B,KAAK,wBAAwB,GAC9B,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC"}
|
package/dist/litellm/index.js
CHANGED
|
@@ -1,57 +1,19 @@
|
|
|
1
|
-
// src/litellm/
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
|
|
7
|
-
var LITELLM_PROXY_API_KEY_ENV = "LITELLM_PROXY_API_KEY";
|
|
8
|
-
|
|
9
|
-
class LitellmCredentialsError extends Data.TaggedError("LitellmCredentialsError") {
|
|
10
|
-
}
|
|
11
|
-
var missing = (name) => new LitellmCredentialsError({
|
|
12
|
-
message: `${name} is not set. Export it — the same variable LiteLLM's own \`litellm\` CLI ` + "reads — before running a stack that declares a LiteLLM.PassThroughEndpoint."
|
|
13
|
-
});
|
|
14
|
-
var resolveCreds = Effect.gen(function* () {
|
|
15
|
-
const rawUrl = process.env[LITELLM_PROXY_URL_ENV];
|
|
16
|
-
if (rawUrl === undefined || rawUrl.trim() === "")
|
|
17
|
-
return yield* Effect.fail(missing(LITELLM_PROXY_URL_ENV));
|
|
18
|
-
const rawKey = process.env[LITELLM_PROXY_API_KEY_ENV];
|
|
19
|
-
if (rawKey === undefined || rawKey.trim() === "") {
|
|
20
|
-
return yield* Effect.fail(missing(LITELLM_PROXY_API_KEY_ENV));
|
|
21
|
-
}
|
|
22
|
-
return { baseUrl: rawUrl.trim().replace(/\/$/, ""), apiKey: rawKey.trim() };
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
class LitellmCredentials extends Context.Service()("homeflare/litellm/Credentials") {
|
|
26
|
-
}
|
|
27
|
-
var litellmCredentialsLayer = Layer.succeed(LitellmCredentials, resolveCreds);
|
|
28
|
-
var litellmCredentialsLayerFor = (creds) => Layer.succeed(LitellmCredentials, Effect.succeed(creds));
|
|
29
|
-
// src/litellm/client.ts
|
|
30
|
-
import * as Data2 from "effect/Data";
|
|
1
|
+
// src/litellm/pass-through-endpoint.ts
|
|
2
|
+
import { Resource } from "alchemy";
|
|
3
|
+
import { Unowned } from "alchemy/AdoptPolicy";
|
|
4
|
+
import { isResolved } from "alchemy/Diff";
|
|
5
|
+
import { createPhysicalName } from "alchemy/PhysicalName";
|
|
6
|
+
import * as Provider from "alchemy/Provider";
|
|
31
7
|
import * as Effect2 from "effect/Effect";
|
|
32
|
-
import * as
|
|
33
|
-
import * as HttpClientRequest from "effect/unstable/http/HttpClientRequest";
|
|
34
|
-
import * as Semaphore from "effect/Semaphore";
|
|
35
|
-
var LITELLM_OPERATIONS = {
|
|
36
|
-
create: "litellm:POST /config/pass_through_endpoint",
|
|
37
|
-
delete: "litellm:DELETE /config/pass_through_endpoint",
|
|
38
|
-
list: "litellm:GET /config/pass_through_endpoint",
|
|
39
|
-
update: "litellm:POST /config/pass_through_endpoint/{endpoint_id}"
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
class LitellmUnauthorizedError extends Data2.TaggedError("LitellmUnauthorizedError") {
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
class LitellmBadRequestError extends Data2.TaggedError("LitellmBadRequestError") {
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
class LitellmHttpError extends Data2.TaggedError("LitellmHttpError") {
|
|
49
|
-
}
|
|
8
|
+
import * as Predicate from "effect/Predicate";
|
|
50
9
|
|
|
51
|
-
|
|
52
|
-
|
|
10
|
+
// src/litellm/operations.ts
|
|
11
|
+
import * as misc from "@distilled.cloud/litellm/misc";
|
|
12
|
+
import { Credentials } from "@distilled.cloud/litellm/Credentials";
|
|
13
|
+
import * as Effect from "effect/Effect";
|
|
14
|
+
import * as Semaphore from "effect/Semaphore";
|
|
53
15
|
var semaphores = new Map;
|
|
54
|
-
var semaphoreFor = (baseUrl) =>
|
|
16
|
+
var semaphoreFor = (baseUrl) => Effect.sync(() => {
|
|
55
17
|
const existing = semaphores.get(baseUrl);
|
|
56
18
|
if (existing !== undefined)
|
|
57
19
|
return existing;
|
|
@@ -59,49 +21,35 @@ var semaphoreFor = (baseUrl) => Effect2.sync(() => {
|
|
|
59
21
|
semaphores.set(baseUrl, created);
|
|
60
22
|
return created;
|
|
61
23
|
});
|
|
62
|
-
var
|
|
63
|
-
const
|
|
64
|
-
const
|
|
65
|
-
const
|
|
66
|
-
const request = HttpClientRequest.make(method)(url).pipe(HttpClientRequest.setHeaders({
|
|
67
|
-
Accept: "application/json",
|
|
68
|
-
Authorization: `Bearer ${creds.apiKey}`
|
|
69
|
-
}), body === undefined ? (self) => self : HttpClientRequest.bodyText(JSON.stringify(body), "application/json"));
|
|
70
|
-
const response = yield* client.execute(request).pipe(Effect2.mapError((cause) => new LitellmTransportError({ cause: String(cause), method, path })));
|
|
71
|
-
const text = yield* response.text.pipe(Effect2.mapError((cause) => new LitellmTransportError({ cause: String(cause), method, path })));
|
|
72
|
-
if (response.status === 401 || response.status === 403) {
|
|
73
|
-
return yield* Effect2.fail(new LitellmUnauthorizedError({ method, path, status: response.status }));
|
|
74
|
-
}
|
|
75
|
-
if (response.status === 400) {
|
|
76
|
-
return yield* Effect2.fail(new LitellmBadRequestError({ detail: text.slice(0, 300), method, path }));
|
|
77
|
-
}
|
|
78
|
-
if (response.status < 200 || response.status >= 300) {
|
|
79
|
-
return yield* Effect2.fail(new LitellmHttpError({ detail: text.slice(0, 300), method, path, status: response.status }));
|
|
80
|
-
}
|
|
81
|
-
return text === "" ? undefined : JSON.parse(text);
|
|
82
|
-
});
|
|
83
|
-
var listPassThroughEndpoints = () => call("GET", "/config/pass_through_endpoint").pipe(Effect2.map((body) => body.endpoints));
|
|
84
|
-
var mutate = (io) => Effect2.gen(function* () {
|
|
85
|
-
const creds = yield* yield* LitellmCredentials;
|
|
86
|
-
const semaphore = yield* semaphoreFor(creds.baseUrl);
|
|
24
|
+
var mutate = (io) => Effect.gen(function* () {
|
|
25
|
+
const resolve = yield* Credentials;
|
|
26
|
+
const creds = yield* resolve;
|
|
27
|
+
const semaphore = yield* semaphoreFor(creds.apiBaseUrl);
|
|
87
28
|
return yield* semaphore.withPermits(1)(io);
|
|
88
29
|
});
|
|
89
|
-
var
|
|
90
|
-
var
|
|
91
|
-
var
|
|
30
|
+
var listPassThroughEndpoints = () => misc.getPassThroughEndpointsConfigPassThroughEndpointGet({}).pipe(Effect.map((response) => response.endpoints));
|
|
31
|
+
var createPassThroughEndpoint = (body) => mutate(misc.createPassThroughEndpointsConfigPassThroughEndpointPost(body).pipe(Effect.asVoid));
|
|
32
|
+
var updatePassThroughEndpoint = (endpointId, body) => mutate(misc.updatePassThroughEndpointsConfigPassThroughEndpointEndpointIdPost({
|
|
33
|
+
...body,
|
|
34
|
+
endpoint_id: endpointId
|
|
35
|
+
}).pipe(Effect.asVoid));
|
|
36
|
+
var deletePassThroughEndpoint = (endpointId) => mutate(misc.deletePassThroughEndpointsConfigPassThroughEndpointDelete({ endpoint_id: endpointId }).pipe(Effect.asVoid, Effect.catchTag("BadRequest", (original) => Effect.gen(function* () {
|
|
92
37
|
const rows = yield* listPassThroughEndpoints();
|
|
93
38
|
if (rows.some((row) => row.id === endpointId))
|
|
94
|
-
return yield*
|
|
95
|
-
}))
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
import
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
39
|
+
return yield* Effect.fail(original);
|
|
40
|
+
}))));
|
|
41
|
+
|
|
42
|
+
// src/litellm/pass-through-errors.ts
|
|
43
|
+
import * as Data from "effect/Data";
|
|
44
|
+
|
|
45
|
+
class LitellmConfigPathConflictError extends Data.TaggedError("LitellmConfigPathConflictError") {
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
class LitellmUnaddressableRowError extends Data.TaggedError("LitellmUnaddressableRowError") {
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
class LitellmLiteralSecretHeaderError extends Data.TaggedError("LitellmLiteralSecretHeaderError") {
|
|
52
|
+
}
|
|
105
53
|
|
|
106
54
|
// src/litellm/pass-through-form.ts
|
|
107
55
|
import { deepEqual } from "alchemy/Diff";
|
|
@@ -141,14 +89,6 @@ var SECRET_HEADER_NAMES = new Set(["authorization", "x-api-key", "cf-aig-authori
|
|
|
141
89
|
var literalSecretHeaders = (headers) => Object.entries(headers ?? {}).filter(([name, value]) => SECRET_HEADER_NAMES.has(name.toLowerCase()) && !String(value).includes("os.environ/")).map(([name]) => name);
|
|
142
90
|
|
|
143
91
|
// src/litellm/pass-through-endpoint.ts
|
|
144
|
-
class LitellmConfigPathConflictError extends Data3.TaggedError("LitellmConfigPathConflictError") {
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
class LitellmUnaddressableRowError extends Data3.TaggedError("LitellmUnaddressableRowError") {
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
class LitellmLiteralSecretHeaderError extends Data3.TaggedError("LitellmLiteralSecretHeaderError") {
|
|
151
|
-
}
|
|
152
92
|
var LiteLLMPassThroughEndpoint = Resource("LiteLLM.PassThroughEndpoint");
|
|
153
93
|
var isLiteLLMPassThroughEndpoint = (value) => Predicate.hasProperty(value, "Type") && value.Type === "LiteLLM.PassThroughEndpoint";
|
|
154
94
|
var toAttributes = (row, fallbackId) => ({
|
|
@@ -162,10 +102,10 @@ var locate = (rows, objectId, path) => {
|
|
|
162
102
|
return { conflict, mine };
|
|
163
103
|
};
|
|
164
104
|
var conflictRefusal = (conflict, path) => conflict.is_from_config === true ? new LitellmConfigPathConflictError({ path }) : new LitellmUnaddressableRowError({ path });
|
|
165
|
-
var readConflict = (conflict, path) => conflict.is_from_config !== true && conflict.id !== undefined && conflict.id !== null ?
|
|
105
|
+
var readConflict = (conflict, path) => conflict.is_from_config !== true && conflict.id !== undefined && conflict.id !== null ? Effect2.succeed(Unowned(toAttributes(conflict, conflict.id))) : Effect2.fail(conflictRefusal(conflict, path));
|
|
166
106
|
var refuseLiteralSecrets = (headers) => {
|
|
167
107
|
const bad = literalSecretHeaders(headers);
|
|
168
|
-
return bad.length === 0 ?
|
|
108
|
+
return bad.length === 0 ? Effect2.void : Effect2.fail(new LitellmLiteralSecretHeaderError({ headers: bad }));
|
|
169
109
|
};
|
|
170
110
|
var passThroughHandlers = {
|
|
171
111
|
read: ({
|
|
@@ -173,7 +113,7 @@ var passThroughHandlers = {
|
|
|
173
113
|
instanceId,
|
|
174
114
|
olds,
|
|
175
115
|
output
|
|
176
|
-
}) =>
|
|
116
|
+
}) => Effect2.gen(function* () {
|
|
177
117
|
const objectId = output?.id ?? (yield* physicalIdOf(id, instanceId));
|
|
178
118
|
const rows = yield* listPassThroughEndpoints();
|
|
179
119
|
const { conflict, mine } = locate(rows, objectId, olds.path);
|
|
@@ -186,7 +126,7 @@ var passThroughHandlers = {
|
|
|
186
126
|
diff: ({
|
|
187
127
|
news,
|
|
188
128
|
output
|
|
189
|
-
}) =>
|
|
129
|
+
}) => Effect2.gen(function* () {
|
|
190
130
|
if (!isResolved(news))
|
|
191
131
|
return;
|
|
192
132
|
yield* refuseLiteralSecrets(news.headers);
|
|
@@ -201,17 +141,17 @@ var passThroughHandlers = {
|
|
|
201
141
|
instanceId,
|
|
202
142
|
news,
|
|
203
143
|
output
|
|
204
|
-
}) =>
|
|
144
|
+
}) => Effect2.gen(function* () {
|
|
205
145
|
yield* refuseLiteralSecrets(news.headers);
|
|
206
146
|
const objectId = output?.id ?? (yield* physicalIdOf(id, instanceId));
|
|
207
147
|
const rows = yield* listPassThroughEndpoints();
|
|
208
148
|
const { conflict, mine } = locate(rows, objectId, news.path);
|
|
209
149
|
if (mine === undefined) {
|
|
210
150
|
if (conflict !== undefined)
|
|
211
|
-
return yield*
|
|
151
|
+
return yield* Effect2.fail(conflictRefusal(conflict, news.path));
|
|
212
152
|
yield* createPassThroughEndpoint(createBody(news, objectId));
|
|
213
153
|
} else if (mine.is_from_config === true) {
|
|
214
|
-
return yield*
|
|
154
|
+
return yield* Effect2.fail(new LitellmConfigPathConflictError({ path: news.path }));
|
|
215
155
|
} else if (needsReplace(toAttributes(mine, objectId), news)) {
|
|
216
156
|
yield* deletePassThroughEndpoint(objectId);
|
|
217
157
|
yield* createPassThroughEndpoint(createBody(news, objectId));
|
|
@@ -222,7 +162,7 @@ var passThroughHandlers = {
|
|
|
222
162
|
}
|
|
223
163
|
const after = (yield* listPassThroughEndpoints()).find((row) => row.id === objectId);
|
|
224
164
|
if (after === undefined) {
|
|
225
|
-
return yield*
|
|
165
|
+
return yield* Effect2.die(new Error(`LiteLLM.PassThroughEndpoint ${news.path}: the write returned no error but id ` + `${objectId} is still absent from GET /config/pass_through_endpoint — read back ` + "rather than trusting the call that just returned."));
|
|
226
166
|
}
|
|
227
167
|
return toAttributes(after, objectId);
|
|
228
168
|
}),
|
|
@@ -231,7 +171,7 @@ var passThroughHandlers = {
|
|
|
231
171
|
instanceId,
|
|
232
172
|
olds,
|
|
233
173
|
output
|
|
234
|
-
}) =>
|
|
174
|
+
}) => Effect2.gen(function* () {
|
|
235
175
|
const objectId = output.id ?? (yield* physicalIdOf(id, instanceId));
|
|
236
176
|
const rows = yield* listPassThroughEndpoints();
|
|
237
177
|
const live = rows.find((row) => row.id === objectId);
|
|
@@ -239,32 +179,22 @@ var passThroughHandlers = {
|
|
|
239
179
|
return;
|
|
240
180
|
yield* deletePassThroughEndpoint(objectId);
|
|
241
181
|
}),
|
|
242
|
-
list: () =>
|
|
182
|
+
list: () => Effect2.succeed([])
|
|
243
183
|
};
|
|
244
|
-
var LiteLLMPassThroughEndpointProvider = () => Provider.effect(LiteLLMPassThroughEndpoint,
|
|
184
|
+
var LiteLLMPassThroughEndpointProvider = () => Provider.effect(LiteLLMPassThroughEndpoint, Effect2.succeed(LiteLLMPassThroughEndpoint.Provider.of(passThroughHandlers)));
|
|
245
185
|
// src/litellm/providers.ts
|
|
246
|
-
import
|
|
247
|
-
|
|
186
|
+
import { CredentialsFromEnv } from "@distilled.cloud/litellm/Credentials";
|
|
187
|
+
import * as Layer from "effect/Layer";
|
|
188
|
+
var litellmProviders = (creds = CredentialsFromEnv) => LiteLLMPassThroughEndpointProvider().pipe(Layer.provide(creds));
|
|
248
189
|
export {
|
|
249
|
-
LITELLM_OPERATIONS,
|
|
250
|
-
LITELLM_PROXY_API_KEY_ENV,
|
|
251
|
-
LITELLM_PROXY_URL_ENV,
|
|
252
190
|
LiteLLMPassThroughEndpoint,
|
|
253
191
|
LiteLLMPassThroughEndpointProvider,
|
|
254
|
-
LitellmBadRequestError,
|
|
255
192
|
LitellmConfigPathConflictError,
|
|
256
|
-
LitellmCredentials,
|
|
257
|
-
LitellmCredentialsError,
|
|
258
|
-
LitellmHttpError,
|
|
259
193
|
LitellmLiteralSecretHeaderError,
|
|
260
|
-
LitellmTransportError,
|
|
261
194
|
LitellmUnaddressableRowError,
|
|
262
|
-
LitellmUnauthorizedError,
|
|
263
195
|
isLiteLLMPassThroughEndpoint,
|
|
264
|
-
litellmCredentialsLayer,
|
|
265
|
-
litellmCredentialsLayerFor,
|
|
266
196
|
litellmProviders
|
|
267
197
|
};
|
|
268
198
|
|
|
269
|
-
//# debugId=
|
|
199
|
+
//# debugId=F883BA858F0CF3AD64756E2164756E21
|
|
270
200
|
//# sourceMappingURL=index.js.map
|