Compare commits
37
Commits
next
..
6a1fda8133
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6a1fda8133 | ||
|
|
9ce1c1aa17 | ||
|
|
536819e8ef | ||
|
|
7b3a486fd8 | ||
|
|
fa32dcb72e | ||
|
|
c1fcaea8ca | ||
|
|
e7c2a6a58a | ||
|
|
59594d46bc | ||
|
|
9a4ab4af96 | ||
|
|
df5a09ddfe | ||
|
|
4f8e5e1adb | ||
|
|
5603a42be0 | ||
|
|
c89aeb9c29 | ||
|
|
97cc9b8d5e | ||
|
|
87a6f219d1 | ||
|
|
c6ad02d0a7 | ||
|
|
10907a6276 | ||
|
|
6c4e0045ec | ||
|
|
80ca6feced | ||
|
|
576011e224 | ||
|
|
eb6671580f | ||
|
|
05866d146a | ||
|
|
4f8a8e12b0 | ||
|
|
2668a7fd15 | ||
|
|
918eff9612 | ||
|
|
4b233f2755 | ||
|
|
ca44fb5ef9 | ||
|
|
b662784087 | ||
|
|
850c94dcd6 | ||
|
|
a77797ed12 | ||
|
|
c5501c1019 | ||
|
|
c2e51d09f6 | ||
|
|
12148db477 | ||
|
|
2e116b9965 | ||
|
|
415af8bdf7 | ||
|
|
fa38277468 | ||
|
|
37c01787f7 |
No files matched your search
@@ -3,15 +3,20 @@ name: Build
|
||||
on:
|
||||
workflow_dispatch:
|
||||
pull_request:
|
||||
paths-ignore: ['*.md']
|
||||
types: [opened, synchronize, reopened, ready_for_review]
|
||||
branches: ['main']
|
||||
paths-ignore: ['*.md']
|
||||
|
||||
permissions: {}
|
||||
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.head_ref || github.ref }}
|
||||
group: package-build-${{ github.event.pull_request.number || github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
build:
|
||||
if: github.event.pull_request.draft == false
|
||||
if: github.event_name != 'pull_request' || github.event.pull_request.draft == false
|
||||
permissions:
|
||||
contents: read
|
||||
uses: Start9Labs/start-technologies/.github/workflows/build.yml@master
|
||||
# No DEV_KEY — a PR build doesn't publish, so it doesn't need the signing key.
|
||||
@@ -0,0 +1,18 @@
|
||||
name: Retarget Build
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
types: [edited]
|
||||
|
||||
permissions: {}
|
||||
|
||||
concurrency:
|
||||
group: package-build-${{ github.event.changes.base && github.event.pull_request.number || format('metadata-{0}', github.event.pull_request.number) }}
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
build:
|
||||
if: github.event.changes.base && github.event.pull_request.draft == false
|
||||
permissions:
|
||||
contents: read
|
||||
uses: Start9Labs/start-technologies/.github/workflows/build.yml@master
|
||||
@@ -3,6 +3,14 @@ name: Sync next
|
||||
# Carries every change that lands on the base branch onto the paired `next`
|
||||
# iteration branch, so `next` never drifts behind what has already shipped.
|
||||
# `next` is created on the first run if the repo does not have one yet.
|
||||
#
|
||||
# List every base branch this package maintains. Most packages have one; the
|
||||
# multi-branch packages list each major line or flavor (e.g. 28.x, 29.x). A
|
||||
# package whose default branch is `main` must say `main` here — a workflow
|
||||
# pointed at a branch the repo does not use never runs.
|
||||
#
|
||||
# No paths-ignore: a docs-only commit on the base still has to reach `next`,
|
||||
# or the next merge back re-introduces the stale copy.
|
||||
on:
|
||||
push:
|
||||
branches: ['main']
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
"@start9labs/start-sdk/prettier.config.json"
|
||||
@@ -18,17 +18,29 @@ Freshly scaffolded? Work the
|
||||
guide page, not a file in this repo — read it, don't copy it in.
|
||||
|
||||
Keep `README.md` (technical reference for an AI support or administering agent) and
|
||||
`instructions.md` (end-user docs) in sync with your changes.
|
||||
`instructions.md` (end-user docs) in sync with your changes. This file restates neither:
|
||||
whoever changes the package has both, so it carries only what they don't — repo mechanics,
|
||||
a change that looks right and is not, where the next thing gets added, a naming trap, a
|
||||
build or test invocation particular to this repo.
|
||||
|
||||
**Fix a defect you spot rather than reporting it** — you have the package open and the
|
||||
context to be sure. File **a GitHub issue on this repo** only when the call isn't yours to
|
||||
make: you can't pin the cause down, two defensible fixes exist, or it's too large to ride on
|
||||
the work in hand. An open issue is a report, not a queue — implement one when you're asked
|
||||
to or when it's labelled `Approved`, then close it with `Closes #<n>`.
|
||||
|
||||
**Bugs and feature requests are GitHub issues on this repo** — file them as you find them.
|
||||
Don't record work in the repo instead: no `TODO.md`, no `NOTES.md`, no `PLAN.md`. What you
|
||||
verified, tried, and decided belongs in the commit message and the PR body.
|
||||
|
||||
## This repo
|
||||
|
||||
- **`config.json`'s shape must stay exactly upstream's.** The proxy rewrites the whole file when a key is saved on the Status Page, so anything the package adds there is destroyed. Package-owned settings go in `store.json` at the volume root — **outside** the `proxy/` subpath that is mounted — where the container cannot see or clobber them.
|
||||
- **Don't set `PPQ_API_KEY`.** Leaving it unset makes the proxy's own key store the single owner, so the action and the Status Page write the same key rather than competing.
|
||||
- **The task is `important`, not `critical`, on purpose.** A `critical` task suspends the ordinary controls, which would stop the user starting the service — and the Status Page is the other place a key can be saved. Blocking startup would block half the ways to complete the task.
|
||||
- **This is a fork, and upstream is a moving target.** `packageRepo` points at `sondreolav/ppq-private-mode-startos`; upstream is `Start9-Community/ppq-private-mode-startos`. Take upstream changes with `git merge upstream/main` — never by hand-copying files. A hand-copy leaves upstream's commits outside our history, so GitHub keeps reporting the fork as *N commits behind*, and the gap grows with every upstream release.
|
||||
- **The package version tracks the vendored proxy, not upstream's wrapper version.** `version` in `startos/versions/current.ts` follows `ppq-private-mode-proxy/package.json` (currently `0.6.0`), while upstream's wrapper sits on its own `0.4.x` line. That makes `current.ts` a conflict on every upstream merge: keep our version, bump the revision (`0.6.0:5`), and write our own release notes.
|
||||
- **Don't merge `upstream/next`.** `main` is the released line — upstream's `v0.4.1_1` tag sits on it. Our own tags use the same shape: `v0.6.0_5`, with an underscore because git refs cannot contain `:`.
|
||||
- **`PPQ_ALLOWED_HOSTS` is derived from the binding's own addresses.** Never hardcode hostnames; `main.ts` resolves them reactively, so an address added later is picked up on the next restart.
|
||||
- **Put package-owned settings in `store.json`, never in `config.json`** — the proxy rewrites `config.json` whole when a key is saved on the Status Page.
|
||||
- **Don't set `PPQ_API_KEY`** — the proxy's own key store must stay the key's only owner, so the action and the Status Page write the same key.
|
||||
- **A blank key field keeps the saved key; don't "fix" it to clear on empty** — it is how the action toggles logging without re-entering the key.
|
||||
- **The key pattern is validated in the action** because upstream only validates on the Status Page — a malformed key written straight to `config.json` surfaces later as a 401 on the first request.
|
||||
- **A blank key field preserves the existing key**, so the action doubles as the way to toggle logging. Don't "fix" it to clear on empty.
|
||||
- **Default branch is `main`, not `master`.** Its CI workflows reference `main`; leave them.
|
||||
- **The task is `important`, not `critical`, on purpose.** A `critical` task suspends the ordinary controls, which would stop the user starting the service — and the Status Page is the other place a key can be saved.
|
||||
- **Default branch is `main`, not `master`.** Keep `main` in every workflow when resyncing them from the template.
|
||||
@@ -11,11 +11,27 @@
|
||||
|
||||
[PPQ Private Mode](https://github.com/PayPerQ/ppq-private-mode-proxy) is a local proxy that encrypts AI requests on your server and only lets them be decrypted inside an attested hardware enclave, so neither PPQ.AI nor the model host can read them. This package runs that proxy and points any OpenAI- or Anthropic-compatible client at it.
|
||||
|
||||
- **Upstream repo:** <https://github.com/PayPerQ/ppq-private-mode-proxy>
|
||||
- **Wrapper repo:** <https://github.com/Start9-Community/ppq-private-mode-startos>
|
||||
- **Upstream proxy repo:** <https://github.com/PayPerQ/ppq-private-mode-proxy>
|
||||
- **Upstream wrapper (this is a fork of it):** <https://github.com/Start9-Community/ppq-private-mode-startos>
|
||||
|
||||
---
|
||||
|
||||
## Changes in this fork
|
||||
|
||||
Forked from [Start9-Community/ppq-private-mode-startos](https://github.com/Start9-Community/ppq-private-mode-startos). Tracks upstream `ppq-private-mode-proxy` v0.6.0:
|
||||
|
||||
- **Upstream v0.6.0 updates:** Updated model catalog (`private/glm-5-3`, `private/glm-5-3-flash`, `private/deepseek-v4-flash`), host and origin security hardening against browser CSRF/DNS rebinding.
|
||||
- **DNS-rebinding hardening (default on).** StartOS now sets `PPQ_ALLOWED_HOSTS` automatically to the exact hostnames the API interface is served on (LAN IP, `.local`, private/public domains, the bridge address and loopback). A hostile web page can no longer reach the proxy as "same-origin" or overwrite the stored API key via `/setup/api-key`. The list is resolved reactively, so adding a domain later is picked up on the next restart.
|
||||
- **New action — Service-to-Service URL.** Resolves the internal LXC-bridge address and prints the `http://<bridge-ip>:<port>/v1` base URL that Open WebUI (or any service container on this same StartOS server) should dial — plain HTTP, no TLS or cert handling. This is what an on-box client must use instead of the LAN `https://` address, which fails certificate validation inside another container's runtime.
|
||||
- **Key validation matches upstream.** `configureApiKey` uses the exact same API-key shape check as upstream v0.6.0 (`^sk-[A-Za-z0-9]{16,64}$`), so a key accepted in StartOS is never rejected later by the proxy itself.
|
||||
- **No double restart on configure.** The action only writes settings that actually changed (both `debug` and the API key are compared against the stored value first), so toggling logging or replacing the key restarts the service once — and only when something really changed.
|
||||
- **Stable consumer contract.** `startos/utils.ts` exports `apiHostId` (`'main'`) and `apiPort` (`8787`) for dependents to import, mirroring the pattern Open WebUI already uses for its other AI backends.
|
||||
- **Docs.** `README.md` and `instructions.md` document the same-server / Open WebUI connection flow and updated models.
|
||||
- **Toolchain rebased onto upstream's SDK migration.** This fork builds with start-sdk 3.1.0: file models use `z.looseObject`, the manifest and init take an `sdk.Dependencies.of()` builder, and the toolchain scripts and devDependencies come from the SDK rather than `package.json`. The container is rebuilt on Node.js 22.23.4 for its October 2026 security release.
|
||||
|
||||
Version: `0.6.0:6`, built with SDK 3.1.0.
|
||||
---
|
||||
|
||||
## Table of Contents
|
||||
|
||||
- [Image and Container Runtime](#image-and-container-runtime)
|
||||
@@ -78,7 +94,6 @@ Two models, and keeping them apart is the point.
|
||||
**The proxy's config file is co-owned, and its shape must stay exactly upstream's.** The proxy rewrites the whole file when a key is saved on its status page, so anything else stored there would be destroyed — which is why the verbose-logging setting lives in a separate file the container cannot see.
|
||||
|
||||
**The API key is not passed as an environment variable**, though upstream supports that. Leaving it out means the proxy's own key store is the single owner of the key, so a key set through the status page and a key set through the action are the same key rather than two competing sources.
|
||||
|
||||
The config file is read reactively, which is what makes a key saved by the action take effect: the write restarts the daemon, and the proxy reloads the file at start.
|
||||
|
||||
## Dependencies
|
||||
@@ -100,6 +115,10 @@ Both are exported from the **same binding**, because they are the same server: o
|
||||
|
||||
**Neither is authenticated by StartOS**, and the status page is where the API key can be saved — so anyone who can reach the address can read the attestation state, use your key for inference, and replace it. Treat the address as a credential.
|
||||
|
||||
Since 0.6.0:4 the package sets **`PPQ_ALLOWED_HOSTS`** automatically to the hostnames StartOS serves this binding on (LAN IP, `.local`, private/public domains, plus the bridge IP and loopback). This thwarts DNS-rebinding: a request whose `Host` is not one of those names is refused by the proxy before any request handling, so a hostile web page cannot act as "same-origin" against it.
|
||||
|
||||
**Same-server consumption (service-to-service).** A client running in *another service's container on this same server* — Open WebUI, a custom agent — must not use the LAN `https://` address: the calling runtime does not trust this server's self-signed Root CA, so the dial fails certificate verification. What it *should* use is the LXC-bridge address, which is plain HTTP — no TLS, no cert handling. Run the **Service-to-Service URL** action and paste the returned `http://<bridge-ip>:<port>/v1` URL into the client. The LAN `https://` address (e.g. `https://192.168.0.158:56849`) remains correct for off-box clients — a browser with the server's Root CA trusted, or `curl -k`.
|
||||
|
||||
## Installation and First-Run Flow
|
||||
|
||||
Install seeds nothing and raises an `important` task asking for the PPQ.AI API key.
|
||||
@@ -112,7 +131,7 @@ So the proxy starts without a key. It serves its status page, performs attestati
|
||||
|
||||
## Actions
|
||||
|
||||
One action.
|
||||
Two actions, both available whether or not the service is running.
|
||||
|
||||
### Configure PPQ API Key
|
||||
|
||||
@@ -122,10 +141,21 @@ Sets the API key and the verbose-logging switch.
|
||||
- **Cost:** the service restarts, since the proxy reads its config at start.
|
||||
- **Repeat safety:** idempotent. **Leaving the key blank keeps the existing one** rather than clearing it, so the action can be used to toggle logging without re-entering the key.
|
||||
- **The key is never echoed back into the form.** The logging toggle is pre-filled; the key is not.
|
||||
- **The key's shape is checked before it is written.** Upstream's status page rejects a malformed key outright, but a bad key written straight into the config file would only surface later as a failed request — so the same check is applied here.
|
||||
- **Verbose logging** adds model information for accepted chat requests and logs OpenAI stream errors. Error messages may include sensitive content, even when verbose logging is off.
|
||||
- **The key's shape is checked before it is written**, with the exact same pattern upstream v0.6.0 uses (`^sk-[A-Za-z0-9]{16,64}$`) — so a key accepted here is never rejected later by the proxy's own status-page endpoint.
|
||||
- **Only changed settings are written.** Each value (`debug`, `apiKey`) is compared against the stored value first; nothing is written when it did not change, so no spurious restarts.
|
||||
|
||||
**Requests are billed to whichever key is set.**
|
||||
|
||||
### Service-to-Service URL
|
||||
|
||||
Resolves the internal LXC-bridge address another service on this same server (Open WebUI) dials to reach the proxy.
|
||||
|
||||
- **What it returns:** the copyable base URL `http://<bridge-ip>:<assigned-port>/v1`.
|
||||
- **Why it exists:** the LAN `https://` address fails from another container, because that container's runtime does not trust this server's Root CA; the bridge address is plain HTTP and needs no trust setup.
|
||||
- **Usage:** in Open WebUI, Admin Panel → Connections → OpenAI API, paste the URL, Save, and add the `private/` model IDs shown on the Status Page.
|
||||
- **Cost:** none; the service does not restart.
|
||||
|
||||
## Tasks
|
||||
|
||||
One, and it is advisory.
|
||||
@@ -165,6 +195,10 @@ A restored instance comes back with the same key and works immediately, since no
|
||||
5. **The API key cannot be cleared from the action** — leaving the field blank preserves it.
|
||||
6. **The package cannot add settings to the proxy's config file**, which upstream rewrites wholesale.
|
||||
7. **The only package-level setting is verbose logging.** Everything else is upstream's.
|
||||
8. **Same-server clients must use the bridge address, not the LAN `https://` URL** — see [Network Access and Interfaces](#network-access-and-interfaces).
|
||||
9. **Known SDK listener warning (accepted).** `main` reads the files reactively with `.const()` — necessary so a key saved on the Status Page clears the setup task. That hits the known Start9 SDK pattern around `FileHelper.produce` that can emit a cosmetic `MaxListenersExceededWarning` (start9labs/start-technologies#3182). It is library-side and cosmetic; the reactive reads are required, so we deliberately do not "fix" it.
|
||||
10. **Upstream request bodies are unbounded (accepted, documented).** Upstream v0.6.0 does not cap HTTP request-body size, so a client that can reach the API could spend memory with very large POSTs (a potential DoS). This is upstream code — this wrapper cannot fix it without forking the proxy — so the mitigation is to keep the API interface private (LAN/VPN/Tor) and never expose it on the public internet. The interface is unauthenticated anyway (see #3), so it should never be publicly reachable.
|
||||
11. **Upstream logs error messages unsanitized.** A `JSON.parse` failure quotes an excerpt of the request body, and caught errors are logged regardless of the Verbose Logging switch — so logs can contain prompt content. Review logs before sharing them.
|
||||
|
||||
---
|
||||
|
||||
@@ -189,6 +223,7 @@ startos_managed_env_vars:
|
||||
- HOST
|
||||
- PORT
|
||||
- DEBUG
|
||||
- PPQ_ALLOWED_HOSTS # set automatically from the binding's addresses (v0.6.0:4+)
|
||||
# PPQ_API_KEY is deliberately NOT set — the proxy's key store owns the key
|
||||
dependencies: [] # but requires internet and a funded PPQ.AI account
|
||||
interfaces:
|
||||
@@ -196,8 +231,11 @@ interfaces:
|
||||
api: { type: api, port: 8787 } # same binding, exported as a second interface
|
||||
actions:
|
||||
- configure-api-key # blank key field preserves the existing key
|
||||
- show-service-to-service-url # prints http://<bridge-ip>:<port>/v1 for same-server clients (Open WebUI)
|
||||
tasks:
|
||||
- { action: configure-api-key, severity: important } # not critical, by design
|
||||
health_checks:
|
||||
- proxy # the port opens only after enclave attestation succeeds
|
||||
```
|
||||
|
||||
**Stable contract for dependents:** `startos/utils.ts` exports `apiHostId` (`'main'`) and `apiPort` (`8787`) — the values a package like Open WebUI imports rather than hardcoding (`sdk.host.getBridgeAddress(effects, { packageId: 'ppq-private-mode', hostId: apiHostId, internalPort: apiPort, ssl: false })`).
|
||||
+21
-3
@@ -48,7 +48,7 @@ Point any OpenAI-compatible client at the API address:
|
||||
|
||||
```
|
||||
POST <api-address>/v1/chat/completions
|
||||
{"model": "private/glm-5-2", "messages": [{"role": "user", "content": "Hello"}]}
|
||||
{"model": "private/glm-5-3", "messages": [{"role": "user", "content": "Hello"}]}
|
||||
```
|
||||
|
||||
Anthropic-SDK clients (including Claude Code) can use the native endpoint at
|
||||
@@ -56,7 +56,7 @@ Anthropic-SDK clients (including Claude Code) can use the native endpoint at
|
||||
|
||||
```
|
||||
export ANTHROPIC_BASE_URL="<api-address>"
|
||||
export ANTHROPIC_MODEL="private/glm-5-2"
|
||||
export ANTHROPIC_MODEL="private/glm-5-3"
|
||||
```
|
||||
|
||||
`GET <api-address>/v1/models` lists the available private models, and the Status
|
||||
@@ -65,12 +65,30 @@ Page shows the same list.
|
||||
Requests are billed to your saved API key by default. To bill a different
|
||||
PPQ.AI key per request, pass it as an `Authorization: Bearer` header.
|
||||
|
||||
### Open WebUI (or any service on this same server)
|
||||
|
||||
Open WebUI and this proxy are separate StartOS services. From one container to
|
||||
another, the LAN `https://` address fails certificate validation — the calling
|
||||
container does not trust this server's self-signed Root CA. Use the internal
|
||||
LXC-bridge address instead, which is plain HTTP (no TLS involved):
|
||||
|
||||
1. On this service, run the **Service-to-Service URL** action (Actions tab).
|
||||
2. Copy the URL it prints — `http://<bridge-ip>:<port>/v1`.
|
||||
3. In Open WebUI: **Admin Panel → Connections → OpenAI API**, paste the URL in
|
||||
the URL field, click **Save**, and add the `private/` model IDs shown on the
|
||||
Status Page (for example `private/glm-5-3`).
|
||||
|
||||
Any other service container on the same server can use the same URL. It is not
|
||||
reachable from your browser — that is what the LAN `https://` address is for.
|
||||
|
||||
### Replacing the key
|
||||
|
||||
Either surface works, and both write the same place: **Replace key** on the
|
||||
Status Page, or the **Configure PPQ API Key** action. The action is also where
|
||||
you turn Verbose Logging on and off; leaving its key field blank keeps the key
|
||||
you already saved.
|
||||
you already saved. Verbose Logging adds model information for accepted chat
|
||||
requests and logs OpenAI stream errors. Error messages may include sensitive
|
||||
content, even when Verbose Logging is off; review logs before sharing them.
|
||||
|
||||
## Limitations
|
||||
|
||||
|
||||
Generated
+1109
-911
File diff suppressed because it is too large.
Load diff
+1
-18
@@ -1,26 +1,9 @@
|
||||
{
|
||||
"name": "ppq-private-mode-startos",
|
||||
"scripts": {
|
||||
"build": "rm -rf ./javascript && ncc build startos/index.ts -o ./javascript",
|
||||
"prettier": "prettier --write startos",
|
||||
"check": "tsc --noEmit"
|
||||
},
|
||||
"dependencies": {
|
||||
"@start9labs/start-sdk": "2.0.9"
|
||||
"@start9labs/start-sdk": "3.1.0"
|
||||
},
|
||||
"overrides": {
|
||||
"@start9labs/start-sdk": "$@start9labs/start-sdk"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "^22.19.0",
|
||||
"@vercel/ncc": "^0.38.4",
|
||||
"prettier": "^3.6.2",
|
||||
"typescript": "^6.0.3"
|
||||
},
|
||||
"prettier": {
|
||||
"trailingComma": "all",
|
||||
"tabWidth": 2,
|
||||
"semi": false,
|
||||
"singleQuote": true
|
||||
}
|
||||
}
|
||||
+1
-1
Submodule ppq-private-mode-proxy updated: 3ba4ac9431...214656ded6.
@@ -15,9 +15,8 @@ const inputSpec = InputSpec.of({
|
||||
default: null,
|
||||
masked: true,
|
||||
placeholder: 'sk-...',
|
||||
// Upstream's own shape check, applied here too — the Status Page rejects a
|
||||
// malformed key outright, but a key written straight to config.json would
|
||||
// only surface as a 401 on the first request.
|
||||
// Same exact shape check as upstream v0.6.0, so a key accepted here is
|
||||
// never later rejected by the proxy's own status-page endpoint.
|
||||
patterns: [
|
||||
{
|
||||
regex: '^sk-[A-Za-z0-9]{16,64}$',
|
||||
@@ -28,7 +27,7 @@ const inputSpec = InputSpec.of({
|
||||
debug: Value.toggle({
|
||||
name: i18n('Verbose Logging'),
|
||||
description: i18n(
|
||||
'Log every request the proxy handles. Useful for troubleshooting.',
|
||||
'Logs the model for accepted chat requests and OpenAI stream errors. Error messages may include sensitive content, even when Verbose Logging is off.',
|
||||
),
|
||||
default: false,
|
||||
}),
|
||||
@@ -56,9 +55,20 @@ export const configureApiKey = sdk.Action.withInput(
|
||||
}),
|
||||
|
||||
async ({ effects, input }) => {
|
||||
// Write each setting only when it actually changed. main.ts re-runs — and
|
||||
// the daemon restarts — on every file change, so writing values
|
||||
// unconditionally would restart the service (possibly twice) for nothing.
|
||||
const currentDebug = (await storeJson.read((s) => s.debug).once()) ?? false
|
||||
if (input.debug !== currentDebug) {
|
||||
await storeJson.merge(effects, { debug: input.debug })
|
||||
}
|
||||
|
||||
const apiKey = (input.apiKey ?? '').trim()
|
||||
if (apiKey) await configJson.merge(effects, { apiKey })
|
||||
if (apiKey) {
|
||||
const currentKey = (await configJson.read((c) => c.apiKey).once()) ?? ''
|
||||
if (apiKey !== currentKey) {
|
||||
await configJson.merge(effects, { apiKey })
|
||||
}
|
||||
}
|
||||
},
|
||||
)
|
||||
@@ -1,4 +1,7 @@
|
||||
import { sdk } from '../sdk'
|
||||
import { configureApiKey } from './configureApiKey'
|
||||
import { showServiceUrl } from './showServiceUrl'
|
||||
|
||||
export const actions = sdk.Actions.of().addAction(configureApiKey)
|
||||
export const actions = sdk.Actions.of()
|
||||
.addAction(configureApiKey)
|
||||
.addAction(showServiceUrl)
|
||||
@@ -0,0 +1,66 @@
|
||||
import { sdk } from '../sdk'
|
||||
import { apiHostId, apiPort } from '../utils'
|
||||
import { i18n } from '../i18n'
|
||||
|
||||
/**
|
||||
* Surfaces the internal (service-to-service) base URL another StartOS service
|
||||
* on this same server — e.g. Open WebUI — should be pointed at.
|
||||
*
|
||||
* The LAN `https://` address fails from another container on the box, because
|
||||
* the calling runtime does not trust this server's self-signed Root CA. The
|
||||
* LXC bridge address is plain HTTP, so no TLS/cert handling is involved. We
|
||||
* resolve it from our own binding rather than assuming anything about the
|
||||
* bridge IP or the assigned external port.
|
||||
*/
|
||||
export const showServiceUrl = sdk.Action.withoutInput(
|
||||
'show-service-to-service-url',
|
||||
|
||||
async ({ effects }) => ({
|
||||
name: i18n('Service-to-Service URL'),
|
||||
description: i18n(
|
||||
'Resolve the internal URL that services on this same StartOS server (e.g. Open WebUI) can use to reach this proxy over the LXC bridge, without TLS.',
|
||||
),
|
||||
warning: null,
|
||||
allowedStatuses: 'any',
|
||||
group: null,
|
||||
visibility: 'enabled',
|
||||
}),
|
||||
|
||||
async ({ effects }) => {
|
||||
const bridge = await sdk.host
|
||||
.getBridgeAddress(effects, {
|
||||
// Explicit self-reference: `packageId` may be omitted (it then defaults
|
||||
// to this package), but naming it keeps the call in lockstep with the
|
||||
// documented service-to-service contract in README.md.
|
||||
packageId: 'ppq-private-mode',
|
||||
hostId: apiHostId,
|
||||
internalPort: apiPort,
|
||||
ssl: false,
|
||||
})
|
||||
.once()
|
||||
|
||||
if (!bridge) {
|
||||
throw new Error(
|
||||
i18n(
|
||||
'Could not resolve the service-to-service address for this package.',
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
return {
|
||||
version: '1',
|
||||
title: i18n('Service-to-Service Base URL'),
|
||||
message: i18n(
|
||||
'Paste this URL into Open WebUI (Admin → Connections → OpenAI API, URL field), Save, then add the private/ model IDs shown on the Status Page. This address only works from services on this same server — it is not reachable from your browser.',
|
||||
),
|
||||
result: {
|
||||
type: 'single',
|
||||
value: `http://${bridge}/v1`,
|
||||
copyable: true,
|
||||
qr: false,
|
||||
masked: false,
|
||||
launchable: false,
|
||||
},
|
||||
}
|
||||
},
|
||||
)
|
||||
@@ -1,5 +1,3 @@
|
||||
import { sdk } from './sdk'
|
||||
|
||||
export const setDependencies = sdk.setupDependencies(
|
||||
async ({ effects }) => ({}),
|
||||
)
|
||||
export const dependencies = sdk.Dependencies.of()
|
||||
@@ -5,7 +5,7 @@ import { sdk } from '../sdk'
|
||||
// loads the key from here at startup and rewrites the whole file when one is
|
||||
// saved from the status page, so this shape must stay exactly upstream's and
|
||||
// nothing else may live in it — see fileModels/store.json.ts.
|
||||
const shape = z.object({
|
||||
const shape = z.looseObject({
|
||||
apiKey: z.string().optional().catch(undefined),
|
||||
})
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ import { sdk } from '../sdk'
|
||||
|
||||
// Package-owned settings, kept outside the mounted PPQ_DATA_DIR subtree so the
|
||||
// proxy neither sees them nor overwrites them.
|
||||
const shape = z.object({
|
||||
const shape = z.looseObject({
|
||||
debug: z.boolean().catch(false),
|
||||
})
|
||||
|
||||
|
||||
@@ -16,11 +16,17 @@ const dict = {
|
||||
'Your API key from ppq.ai (Settings → API Keys). Leave blank to keep the key already saved, or to set one later from the Status Page.': 9,
|
||||
'A PPQ.AI key starts with "sk-".': 10,
|
||||
'Verbose Logging': 11,
|
||||
'Log every request the proxy handles. Useful for troubleshooting.': 12,
|
||||
'Logs the model for accepted chat requests and OpenAI stream errors. Error messages may include sensitive content, even when Verbose Logging is off.': 12,
|
||||
'Configure PPQ API Key': 13,
|
||||
'Set the PPQ.AI API key the proxy uses to authenticate. Requests are billed to this key.': 14,
|
||||
// init/taskConfigureApiKey.ts
|
||||
'Add your PPQ.AI API key here, or start the service and save one on the Status Page': 15,
|
||||
// actions/showServiceUrl.ts
|
||||
'Service-to-Service URL': 16,
|
||||
'Resolve the internal URL that services on this same StartOS server (e.g. Open WebUI) can use to reach this proxy over the LXC bridge, without TLS.': 17,
|
||||
'Service-to-Service Base URL': 18,
|
||||
'Paste this URL into Open WebUI (Admin → Connections → OpenAI API, URL field), Save, then add the private/ model IDs shown on the Status Page. This address only works from services on this same server — it is not reachable from your browser.': 19,
|
||||
'Could not resolve the service-to-service address for this package.': 20,
|
||||
} as const
|
||||
|
||||
/**
|
||||
|
||||
@@ -14,10 +14,15 @@ export default {
|
||||
9: 'Tu clave API de ppq.ai (Ajustes → Claves API). Déjalo en blanco para conservar la clave ya guardada, o para configurar una más tarde desde la Página de estado.',
|
||||
10: 'Una clave de PPQ.AI empieza por «sk-».',
|
||||
11: 'Registro detallado',
|
||||
12: 'Registra cada solicitud que maneja el proxy. Útil para diagnosticar problemas.',
|
||||
12: 'Registra el modelo de las solicitudes de chat aceptadas y los errores de streaming de OpenAI. Los mensajes de error pueden incluir contenido sensible, incluso cuando el Registro detallado está desactivado.',
|
||||
13: 'Configurar clave API de PPQ',
|
||||
14: 'Establece la clave API de PPQ.AI que el proxy usa para autenticarse. Las solicitudes se facturan a esta clave.',
|
||||
15: 'Añade aquí tu clave API de PPQ.AI, o inicia el servicio y guárdala en la Página de estado',
|
||||
16: 'URL de servicio a servicio',
|
||||
17: 'Resuelve la URL interna que los servicios de este mismo servidor StartOS (p. ej. Open WebUI) pueden usar para llegar a este proxy a través del puente LXC, sin TLS.',
|
||||
18: 'URL base de servicio a servicio',
|
||||
19: 'Pega esta URL en Open WebUI (Admin → Connections → OpenAI API, campo URL), guarda y añade los IDs de modelo private/ que muestra la Página de estado. Esta dirección solo funciona desde servicios del mismo servidor — no es accesible desde tu navegador.',
|
||||
20: 'No se pudo resolver la dirección de servicio a servicio de este paquete.',
|
||||
},
|
||||
de_DE: {
|
||||
0: 'Starte PPQ Private Mode!',
|
||||
@@ -32,10 +37,15 @@ export default {
|
||||
9: 'Dein API-Schlüssel von ppq.ai (Einstellungen → API-Schlüssel). Leer lassen, um den bereits gespeicherten Schlüssel zu behalten oder später auf der Statusseite einen festzulegen.',
|
||||
10: 'Ein PPQ.AI-Schlüssel beginnt mit „sk-“.',
|
||||
11: 'Ausführliche Protokollierung',
|
||||
12: 'Protokolliert jede Anfrage, die der Proxy verarbeitet. Nützlich zur Fehlersuche.',
|
||||
12: 'Protokolliert das Modell akzeptierter Chat-Anfragen und OpenAI-Streamingfehler. Fehlermeldungen können sensible Inhalte enthalten, auch wenn die Ausführliche Protokollierung deaktiviert ist.',
|
||||
13: 'PPQ-API-Schlüssel konfigurieren',
|
||||
14: 'Lege den PPQ.AI-API-Schlüssel fest, mit dem sich der Proxy authentifiziert. Anfragen werden diesem Schlüssel in Rechnung gestellt.',
|
||||
15: 'Füge deinen PPQ.AI-API-Schlüssel hier hinzu, oder starte den Dienst und speichere ihn auf der Statusseite',
|
||||
16: 'Service-to-Service-URL',
|
||||
17: 'Ermittelt die interne URL, über die Dienste auf diesem StartOS-Server (z. B. Open WebUI) den Proxy über die LXC-Brücke ohne TLS erreichen können.',
|
||||
18: 'Service-to-Service-Basis-URL',
|
||||
19: 'Füge diese URL in Open WebUI ein (Admin → Connections → OpenAI API, URL-Feld), speichere und füge dann die private/ Modell-IDs von der Statusseite hinzu. Diese Adresse funktioniert nur für Dienste auf demselben Server — aus deinem Browser ist sie nicht erreichbar.',
|
||||
20: 'Die Service-to-Service-Adresse für dieses Paket konnte nicht ermittelt werden.',
|
||||
},
|
||||
pl_PL: {
|
||||
0: 'Uruchamianie PPQ Private Mode!',
|
||||
@@ -50,10 +60,15 @@ export default {
|
||||
9: 'Twój klucz API z ppq.ai (Ustawienia → Klucze API). Pozostaw puste, aby zachować już zapisany klucz lub ustawić go później na Stronie stanu.',
|
||||
10: 'Klucz PPQ.AI zaczyna się od „sk-”.',
|
||||
11: 'Szczegółowe logowanie',
|
||||
12: 'Rejestruje każde żądanie obsługiwane przez proxy. Przydatne przy rozwiązywaniu problemów.',
|
||||
12: 'Rejestruje model zaakceptowanych żądań czatu i błędy strumieniowania OpenAI. Komunikaty błędów mogą zawierać poufne treści, nawet gdy Szczegółowe logowanie jest wyłączone.',
|
||||
13: 'Skonfiguruj klucz API PPQ',
|
||||
14: 'Ustaw klucz API PPQ.AI, którym proxy się uwierzytelnia. Żądania są rozliczane na ten klucz.',
|
||||
15: 'Dodaj tutaj swój klucz API PPQ.AI albo uruchom usługę i zapisz go na Stronie stanu',
|
||||
16: 'Adres URL między usługami',
|
||||
17: 'Ustala wewnętrzny adres URL, pod którym usługi na tym samym serwerze StartOS (np. Open WebUI) mogą dotrzeć do proxy przez most LXC, bez TLS.',
|
||||
18: 'Podstawowy adres URL między usługami',
|
||||
19: 'Wklej ten adres URL w Open WebUI (Admin → Connections → OpenAI API, pole URL), zapisz, a następnie dodaj identyfikatory modeli private/ widoczne na Stronie stanu. Adres działa tylko z usług na tym samym serwerze — nie jest dostępny z przeglądarki.',
|
||||
20: 'Nie udało się ustalić adresu między usługami dla tego pakietu.',
|
||||
},
|
||||
fr_FR: {
|
||||
0: 'Démarrage de PPQ Private Mode !',
|
||||
@@ -68,9 +83,14 @@ export default {
|
||||
9: "Votre clé API de ppq.ai (Paramètres → Clés API). Laissez vide pour conserver la clé déjà enregistrée, ou pour en définir une plus tard depuis la Page d'état.",
|
||||
10: 'Une clé PPQ.AI commence par « sk- ».',
|
||||
11: 'Journalisation détaillée',
|
||||
12: 'Journalise chaque requête traitée par le proxy. Utile pour le dépannage.',
|
||||
12: "Journalise le modèle des requêtes de chat acceptées et les erreurs de streaming OpenAI. Les messages d'erreur peuvent inclure du contenu sensible, même lorsque la Journalisation détaillée est désactivée.",
|
||||
13: 'Configurer la clé API PPQ',
|
||||
14: "Définissez la clé API PPQ.AI avec laquelle le proxy s'authentifie. Les requêtes sont facturées sur cette clé.",
|
||||
15: "Ajoutez ici votre clé API PPQ.AI, ou démarrez le service et enregistrez-la sur la Page d'état",
|
||||
16: 'URL de service à service',
|
||||
17: "Résout l'URL interne que les services de ce même serveur StartOS (p. ex. Open WebUI) peuvent utiliser pour joindre ce proxy via le pont LXC, sans TLS.",
|
||||
18: 'URL de base de service à service',
|
||||
19: "Collez cette URL dans Open WebUI (Admin → Connections → OpenAI API, champ URL), enregistrez, puis ajoutez les identifiants de modèles private/ affichés sur la Page d'état. Cette adresse ne fonctionne que depuis des services sur ce même serveur — elle n'est pas accessible depuis votre navigateur.",
|
||||
20: "Impossible de résoudre l'adresse de service à service de ce package.",
|
||||
},
|
||||
} satisfies Record<string, LangDict>
|
||||
+2
-1
@@ -8,4 +8,5 @@ export { actions } from './actions'
|
||||
import { buildManifest } from '@start9labs/start-sdk'
|
||||
import { manifest as sdkManifest } from './manifest'
|
||||
import { versionGraph } from './versions'
|
||||
export const manifest = buildManifest(versionGraph, sdkManifest)
|
||||
import { dependencies } from './dependencies'
|
||||
export const manifest = buildManifest(versionGraph, sdkManifest, dependencies)
|
||||
@@ -1,5 +1,5 @@
|
||||
import { sdk } from '../sdk'
|
||||
import { setDependencies } from '../dependencies'
|
||||
import { dependencies } from '../dependencies'
|
||||
import { setInterfaces } from '../interfaces'
|
||||
import { versionGraph } from '../versions'
|
||||
import { actions } from '../actions'
|
||||
@@ -10,8 +10,8 @@ export const init = sdk.setupInit(
|
||||
restoreInit,
|
||||
versionGraph,
|
||||
setInterfaces,
|
||||
setDependencies,
|
||||
actions,
|
||||
dependencies,
|
||||
taskConfigureApiKey,
|
||||
)
|
||||
|
||||
|
||||
+42
-2
@@ -1,7 +1,8 @@
|
||||
import { utils } from '@start9labs/start-sdk'
|
||||
import { i18n } from './i18n'
|
||||
import { sdk } from './sdk'
|
||||
import { manifest } from './manifest'
|
||||
import { apiPort, dataDir } from './utils'
|
||||
import { apiHostId, apiPort, dataDir } from './utils'
|
||||
import { configureApiKey } from './actions/configureApiKey'
|
||||
import { configJson } from './fileModels/config.json'
|
||||
import { storeJson } from './fileModels/store.json'
|
||||
@@ -23,6 +24,37 @@ export const main = sdk.setupMain(async ({ effects }) => {
|
||||
await sdk.action.clearTask(effects, `${manifest.id}:${configureApiKey.id}`)
|
||||
}
|
||||
|
||||
// DNS-rebinding hardening. Upstream's proxy is bound to 0.0.0.0, and without
|
||||
// PPQ_ALLOWED_HOSTS it accepts any Host header — a hostile web page could
|
||||
// reach it as "same-origin" and even overwrite the stored API key via
|
||||
// /setup/api-key. Pin the accepted Hosts to exactly the addresses StartOS
|
||||
// serves this binding on, plus loopback and the bridge (what Open WebUI
|
||||
// dials). Resolved reactively so an address added later is picked up on the
|
||||
// next restart.
|
||||
const servedHosts = await sdk.host
|
||||
.getOwn(effects, apiHostId, (host) =>
|
||||
host
|
||||
? utils
|
||||
.filledAddress(host, {
|
||||
hostId: apiHostId,
|
||||
internalPort: apiPort,
|
||||
username: null,
|
||||
scheme: null,
|
||||
sslScheme: null,
|
||||
suffix: '',
|
||||
})
|
||||
.matchesAny([{ visibility: 'private' }, { visibility: 'public' }])
|
||||
.filter({ exclude: { kind: ['localhost', 'link-local'] } })
|
||||
.hostnames.map((h) => h.hostname)
|
||||
: [],
|
||||
)
|
||||
.const()
|
||||
|
||||
const osIp = await sdk.getOsIp(effects)
|
||||
const allowedHosts = Array.from(
|
||||
new Set(['localhost', '127.0.0.1', osIp, ...servedHosts].filter(Boolean)),
|
||||
).join(',')
|
||||
|
||||
const subcontainer = sdk.SubContainer.of(
|
||||
effects,
|
||||
{ imageId: 'proxy' },
|
||||
@@ -48,7 +80,15 @@ export const main = sdk.setupMain(async ({ effects }) => {
|
||||
subcontainer,
|
||||
exec: {
|
||||
command: ['node', '/app/dist/bin/server.js'],
|
||||
env: {
|
||||
env: allowedHosts
|
||||
? {
|
||||
PPQ_DATA_DIR: dataDir,
|
||||
HOST: '0.0.0.0',
|
||||
PORT: apiPort.toString(),
|
||||
DEBUG: debug ? 'true' : 'false',
|
||||
PPQ_ALLOWED_HOSTS: allowedHosts,
|
||||
}
|
||||
: {
|
||||
PPQ_DATA_DIR: dataDir,
|
||||
HOST: '0.0.0.0',
|
||||
PORT: apiPort.toString(),
|
||||
|
||||
@@ -5,7 +5,7 @@ export const manifest = setupManifest({
|
||||
id: 'ppq-private-mode',
|
||||
title: 'PPQ Private Mode',
|
||||
license: 'MIT',
|
||||
packageRepo: 'https://github.com/Start9-Community/ppq-private-mode-startos',
|
||||
packageRepo: 'https://github.com/sondreolav/ppq-private-mode-startos',
|
||||
upstreamRepo: 'https://github.com/PayPerQ/ppq-private-mode-proxy',
|
||||
marketingUrl: 'https://ppq.ai',
|
||||
donationUrl: null,
|
||||
@@ -22,5 +22,4 @@ export const manifest = setupManifest({
|
||||
arch: ['x86_64', 'aarch64'],
|
||||
},
|
||||
},
|
||||
dependencies: {},
|
||||
})
|
||||
@@ -3,6 +3,11 @@
|
||||
// Port the proxy listens on inside the container (upstream default).
|
||||
export const apiPort = 8787
|
||||
|
||||
// Host id of the binding the proxy's API and Status Page are served from.
|
||||
// Dependents import this along with apiPort (the stable contract) rather than
|
||||
// hardcoding either — mirroring the open-webui KNOWN_BACKENDS pattern.
|
||||
export const apiHostId = 'main'
|
||||
|
||||
// Upstream's PPQ_DATA_DIR inside the container: where it persists the API key
|
||||
// saved from the status page.
|
||||
export const dataDir = '/data'
|
||||
@@ -2,13 +2,18 @@ import { IMPOSSIBLE, VersionInfo } from '@start9labs/start-sdk'
|
||||
|
||||
export const current = VersionInfo.of({
|
||||
// Tracks upstream ppq-private-mode-proxy (package.json version).
|
||||
version: '0.4.1:0',
|
||||
version: '0.6.0:6',
|
||||
releaseNotes: {
|
||||
en_US: 'Initial release for StartOS',
|
||||
es_ES: 'Lanzamiento inicial para StartOS',
|
||||
de_DE: 'Erstveröffentlichung für StartOS',
|
||||
pl_PL: 'Pierwsze wydanie dla StartOS',
|
||||
fr_FR: 'Version initiale pour StartOS',
|
||||
en_US:
|
||||
'Updates Node.js to 22.23.4 with security fixes and moves to start-sdk 3.1.0.',
|
||||
es_ES:
|
||||
'Actualiza Node.js a 22.23.4 con correcciones de seguridad y pasa a start-sdk 3.1.0.',
|
||||
de_DE:
|
||||
'Aktualisiert Node.js auf 22.23.4 mit Sicherheitskorrekturen und wechselt zu start-sdk 3.1.0.',
|
||||
pl_PL:
|
||||
'Aktualizuje Node.js do wersji 22.23.4 z poprawkami bezpieczeństwa i przechodzi na start-sdk 3.1.0.',
|
||||
fr_FR:
|
||||
'Met à jour Node.js vers 22.23.4 avec des correctifs de sécurité et passe à start-sdk 3.1.0.',
|
||||
},
|
||||
migrations: {
|
||||
up: async ({ effects }) => {},
|
||||
|
||||
Reference in new issue
Block a user