@pie-lab/storage
v0.2.1
Published
Local storage interfaces for pie-lab
Readme
@pie-lab/storage
Storage package for provider accounts, settings, usage history, request details, and later chat channel state.
In 9router-derived routing language, a provider "account" is a provider credential connection such as an API key or OAuth token. It is separate from dashboard login or user signup.
Source direction:
- Usage/request logging and pricing override ideas come from
https://github.com/jikime/9router. - Chat account/channel state will be informed by
https://github.com/jikime/pi-chat. - Existing pi session/runtime persistence should be preserved where possible.
Current implemented scope:
UsageRecordshape for resolved model attemptsUsageStoreinterfaceInMemoryUsageStorefor tests and embedded useJsonlUsageStorefor local append-only usage historyqueryUsageRecords()for filtering recent usage recordssummarizeUsageRecords()for token/cost/status aggregatesProviderConnectionshape based on 9router provider connectionsProviderConnectionStoreinterfaceInMemoryProviderConnectionStorefor tests and embedded useJsonProviderConnectionStorefor local provider connection/settings stateProxyPoolshape based on 9router proxy pools- Proxy pool methods on
ProviderConnectionStore:getProxyPools()getProxyPoolById()createProxyPool()updateProxyPool()deleteProxyPool()
- 9router-style account routing settings:
fallbackStrategystickyRoundRobinLimitproviderStrategies
Current first integration:
coding-agentSDK routed stream attempts record success, error, and aborted states.- Default SDK usage history is written to
agentDir/usage.jsonl. apps/serverreads this store for/usageand/usage/summary.ModelRegistry.getApiKeyAndHeaders()can select credentials fromagentDir/provider-connections.json.- If no provider connection exists for a provider, stored
auth.jsoncredentials can be imported on demand. - Routed usage records can store the selected
connectionId. - Provider failures can persist
modelLock_${model}, error metadata, and backoff state on the selected connection. - Provider success clears the current model lock and expired locks for the selected connection.
provider-connections.jsoncan now store 9router-styleproxyPoolsbesideconnectionsandsettings.- Quota API can resolve
providerSpecificData.proxyPoolIdthrough this proxy pool store. apps/serverandapps/dashboardcan create proxy pools and assign them to provider connections.
Still pending:
- Syncing provider connection removal when credentials are removed from
auth.json - Dashboard and CLI screens for provider connection setup
- Proxy pool test endpoint
- Quota storage
- Pricing override storage
- Migration from JSONL to a richer local database if needed
