- resolve the agent dir through the host getAgentDir() (registered by the composition root) instead of sniffing execPath/argv - synthesize agent_settled from the first terminal agent_end on omp - read the live model through ctx.models.current() and prefer it over the stored model on omp - adapt omp Settings (reloadFromDisk, global enabledModels) at the SDK boundary and drop scoped-model persistence on omp
This commit is contained in:
1 parent
52c9fbeaf3
commit
2aefc7ef5a
12 files changed
+232
-55
No files matched your search
+16
-2
@@ -55,15 +55,25 @@ export type CurrentModelRuntime<
|
||||
> = CurrentModelStore<TContext, TModel> &
|
||||
CurrentModelUpdateRuntime<TContext, TModel>;
|
||||
|
||||
/**
|
||||
* `preferContextModel` makes the host's live context model win over the stored
|
||||
* one. Pi pushes model changes through `model_select`, so its stored value is
|
||||
* current; omp has no such event, so its stored value would go stale after a
|
||||
* local `/model` switch.
|
||||
*/
|
||||
export function createCurrentModelStore<
|
||||
TContext,
|
||||
TModel extends MenuModel = MenuModel,
|
||||
>(
|
||||
getContextModel: (ctx: TContext) => TModel | undefined,
|
||||
preferContextModel = false,
|
||||
): CurrentModelStore<TContext, TModel> {
|
||||
let currentModel: TModel | undefined;
|
||||
return {
|
||||
get: (ctx) => currentModel ?? getContextModel(ctx),
|
||||
get: (ctx) =>
|
||||
preferContextModel
|
||||
? (getContextModel(ctx) ?? currentModel)
|
||||
: (currentModel ?? getContextModel(ctx)),
|
||||
getStored: () => currentModel,
|
||||
set: (model) => {
|
||||
currentModel = model;
|
||||
@@ -96,8 +106,12 @@ export function createCurrentModelRuntime<
|
||||
>(deps: {
|
||||
getContextModel: (ctx: TContext) => TModel | undefined;
|
||||
updateStatus: (ctx: TContext) => void;
|
||||
preferContextModel?: boolean;
|
||||
}): CurrentModelRuntime<TContext, TModel> {
|
||||
const store = createCurrentModelStore(deps.getContextModel);
|
||||
const store = createCurrentModelStore(
|
||||
deps.getContextModel,
|
||||
deps.preferContextModel,
|
||||
);
|
||||
return {
|
||||
...store,
|
||||
...createCurrentModelUpdateRuntime({
|
||||
|
||||
Reference in new issue
Block a user