adopt 0.4's persistent key store and browser setup form
The earlier bump took 0.4.1 for its model catalog and status page but
left PPQ_DATA_DIR unset, which disabled the key form the release exists
to add. Enable it, and let the proxy own the key outright.
PPQ_API_KEY is no longer passed. The volume's `proxy/` subpath mounts at
/data as PPQ_DATA_DIR, so upstream's key store is the single source of
truth: the Status Page and the Configure PPQ API Key action write the
same config.json, and there is no StartOS-side copy to revert what the
browser saved. A chown oneshot hands /data to the image's `node` user so
the page can write there.
Verbose Logging moves to store.json outside the mount, because upstream
rewrites config.json wholesale when a key is saved and would drop it.
main.ts watches config.json — upstream loads it once at startup, so the
watch is what makes the action take effect: the write restarts the
daemon, which reloads the file. A key saved on the page applies
immediately and converges through the same restart.
The task drops from critical to important. A critical task suspends
every other control, so it would have left the user unable to start the
service and reach the page's own form — and with PPQ_DATA_DIR set the
proxy no longer exits keyless; it attests, serves the page, and answers
401 until a key exists. main.ts clears the task when a key appears,
since saving on the page never touches the action that would clear it.
The action's key field is now validated against upstream's own
^sk-[A-Za-z0-9]{16,64}$ shape and no longer refuses a blank submission,
a key having become optional.
This commit is contained in:
10 files changed
+213
-140
No files matched your search
@@ -1,5 +1,6 @@
|
||||
import { sdk } from '../sdk'
|
||||
import { configJson } from '../fileModels/config.json'
|
||||
import { storeJson } from '../fileModels/store.json'
|
||||
import { i18n } from '../i18n'
|
||||
|
||||
const { InputSpec, Value } = sdk
|
||||
@@ -8,12 +9,21 @@ const inputSpec = InputSpec.of({
|
||||
apiKey: Value.text({
|
||||
name: i18n('PPQ.AI API Key'),
|
||||
description: i18n(
|
||||
'Your API key from ppq.ai (Settings → API Keys). Leave blank to keep the key already saved.',
|
||||
'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.',
|
||||
),
|
||||
required: false,
|
||||
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.
|
||||
patterns: [
|
||||
{
|
||||
regex: '^sk-[A-Za-z0-9]{16,64}$',
|
||||
description: i18n('A PPQ.AI key starts with "sk-".'),
|
||||
},
|
||||
],
|
||||
}),
|
||||
debug: Value.toggle({
|
||||
name: i18n('Verbose Logging'),
|
||||
@@ -42,21 +52,13 @@ export const configureApiKey = sdk.Action.withInput(
|
||||
|
||||
// Prefill: the API key is never echoed back into the form.
|
||||
async ({ effects }) => ({
|
||||
debug: (await configJson.read((c) => c.debug).once()) ?? false,
|
||||
debug: (await storeJson.read((s) => s.debug).once()) ?? false,
|
||||
}),
|
||||
|
||||
async ({ effects, input }) => {
|
||||
const apiKey =
|
||||
(input.apiKey ?? '').trim() ||
|
||||
(await configJson.read((c) => c.apiKey).once())
|
||||
if (!apiKey) {
|
||||
throw new Error(
|
||||
i18n(
|
||||
'An API key is required. Create one at ppq.ai under Settings → API Keys.',
|
||||
),
|
||||
)
|
||||
}
|
||||
await storeJson.merge(effects, { debug: input.debug })
|
||||
|
||||
await configJson.merge(effects, { apiKey, debug: input.debug })
|
||||
const apiKey = (input.apiKey ?? '').trim()
|
||||
if (apiKey) await configJson.merge(effects, { apiKey })
|
||||
},
|
||||
)
|
||||
Reference in new issue
Block a user