* Extract client SDK package * Polish SDK client identity defaults * Build client before dependent CI jobs * Restore daemon client server export * Extract protocol and client SDK packages * Fix provider override schema validation * Fix app test daemon client imports * Simplify workspace build targets * Fix CLI test server build bootstrap * Run SDK package tests in CI * Fix rebase package split drift * Restore lockfile registry metadata * Update SDK config test for prompt default * Move terminal stream router test to client package * Fix rebase drift for protocol imports * Fix SDK agent capability fixture * Restore legacy server client exports * Fix server export compatibility test * Advertise custom mode icon client capability * Remove server daemon-client exports * Format rebased mode control import * Fix rebase drift for protocol imports Files added by upstream PRs (#893, #1147, #1154) referenced the pre-split shared/ paths that this branch moves into @getpaseo/protocol. Redirect those imports to the protocol package so typecheck stays green after the rebase.
61 lines
1.6 KiB
TypeScript
61 lines
1.6 KiB
TypeScript
import type { AgentFeature } from "@getpaseo/protocol/agent-types";
|
|
|
|
export function pruneFeatureValues(
|
|
featureValues: Record<string, unknown>,
|
|
features: AgentFeature[],
|
|
): Record<string, unknown> {
|
|
const allowedFeatureIds = new Set(features.map((feature) => feature.id));
|
|
let changed = false;
|
|
const next: Record<string, unknown> = {};
|
|
|
|
for (const [featureId, value] of Object.entries(featureValues)) {
|
|
if (!allowedFeatureIds.has(featureId)) {
|
|
changed = true;
|
|
continue;
|
|
}
|
|
next[featureId] = value;
|
|
}
|
|
|
|
return changed ? next : featureValues;
|
|
}
|
|
|
|
export function applyFeatureValues(
|
|
features: AgentFeature[],
|
|
featureValues: Record<string, unknown>,
|
|
): AgentFeature[] {
|
|
if (Object.keys(featureValues).length === 0) {
|
|
return features;
|
|
}
|
|
|
|
return features.map((feature) => {
|
|
if (!Object.prototype.hasOwnProperty.call(featureValues, feature.id)) {
|
|
return feature;
|
|
}
|
|
|
|
return {
|
|
...feature,
|
|
value: featureValues[feature.id],
|
|
} as AgentFeature;
|
|
});
|
|
}
|
|
|
|
export function resolveFeatureValues(args: {
|
|
features: AgentFeature[];
|
|
persistedFeatureValues: Record<string, unknown>;
|
|
localFeatureValues: Record<string, unknown>;
|
|
}): Record<string, unknown> {
|
|
const next: Record<string, unknown> = {};
|
|
|
|
for (const feature of args.features) {
|
|
if (Object.prototype.hasOwnProperty.call(args.localFeatureValues, feature.id)) {
|
|
next[feature.id] = args.localFeatureValues[feature.id];
|
|
continue;
|
|
}
|
|
if (Object.prototype.hasOwnProperty.call(args.persistedFeatureValues, feature.id)) {
|
|
next[feature.id] = args.persistedFeatureValues[feature.id];
|
|
}
|
|
}
|
|
|
|
return next;
|
|
}
|