@code-yeongyu/senpi
Version:
Coding agent CLI with read, bash, edit, write tools and session management
132 lines • 5.81 kB
JavaScript
/**
* The user-facing copy of every effect outcome that is not a plain success: the code, what happened in
* plain words, and what the caller can do. One table so a client renders the same words the host wrote.
*/
export const EFFECT_OUTCOMES = {
inputInterruptedByReopen: {
kind: "interrupted_by_reopen",
reason: "interrupted_by_reopen",
detail: "the session was reopened while this input's turn was running, so that turn never finished",
action: "read the transcript for what the turn produced, then send the input again with a new clientMessageId",
},
inputCleared: {
kind: "cleared",
reason: "cleared",
detail: "the queue was cleared (clear_queue, or abort or unload_session with clearQueue) before this queued input was delivered",
action: "send the input again with a new clientMessageId if it is still needed",
},
queuedInputAlreadyDelivered: {
kind: "already_delivered",
reason: "already_delivered",
detail: "the queued message had already been handed to the agent, so it can no longer be removed or edited",
action: "send a follow-up message to correct it, or abort the turn",
},
queuedInputNotFound: {
kind: "not_found",
reason: "not_found",
detail: "no queued message has this queuedId in this session",
action: "read queuedId values from get_state or queue_update and retry with one that is still queued",
},
queuedInputConflict: {
kind: "conflict",
reason: "conflict",
detail: "the queued message was changed after the revision this request was based on, so nothing was changed",
action: "read the input's current text and revision from get_state or queue_update, then retry with that expectedRevision if the change still applies",
},
inputDroppedByReplace: {
kind: "dropped_by_replace",
reason: "dropped_by_replace",
detail: "the session was replaced (new_session, switch_session or fork) before this queued input was delivered",
action: "send the input again with a new clientMessageId on the current session",
},
abortInterruptedByReopen: {
kind: "interrupted_by_reopen",
reason: "interrupted_by_reopen",
detail: "the session was reopened, so the turn this abort targeted is no longer running",
},
setModelInterruptedByReopen: {
kind: "interrupted_by_reopen",
reason: "interrupted_by_reopen",
detail: "the host restarted before the model switch was applied",
action: "send set_model again with a new effectId",
},
setModelSuperseded: {
kind: "superseded",
reason: "superseded",
detail: "a newer model selection replaced this switch before it was applied",
action: "read the current model, then send set_model with a new effectId if you still want this model",
},
setModelDroppedByReplace: {
kind: "dropped_by_replace",
reason: "dropped_by_replace",
detail: "the session was replaced (new_session, switch_session or fork) before this model switch was applied",
action: "read the current model, then send set_model with a new effectId on the current session",
},
setThinkingInterruptedByReopen: {
kind: "interrupted_by_reopen",
reason: "interrupted_by_reopen",
detail: "the host restarted before the thinking level was applied",
action: "send set_thinking_level again with a new effectId",
},
dequeueInterruptedByReopen: {
kind: "interrupted_by_reopen",
reason: "interrupted_by_reopen",
detail: "the session was reopened before the queued input was removed",
action: "re-read queue_update.ordered and retry with a new effectId",
},
editQueuedInterruptedByReopen: {
kind: "interrupted_by_reopen",
reason: "interrupted_by_reopen",
detail: "the session was reopened before the queued input was edited",
action: "re-read queue_update.ordered and retry with a new effectId",
},
};
export function unknownModelOutcome(provider, modelId) {
return {
kind: "unknown_model",
reason: "unknown_model",
detail: `no available model is named ${provider}/${modelId}`,
action: "pick a model from get_available_models and send set_model again with a new effectId",
};
}
export function providerUnavailableOutcome(detail) {
return {
kind: "provider_unavailable",
reason: "provider_unavailable",
detail,
action: "sign in to the provider or pick another model, then send set_model again with a new effectId",
};
}
export function contextBudgetOutcome(detail) {
return {
kind: "context_budget",
reason: "context_budget",
detail,
action: "compact the session or pick a model with a larger context window, then send set_model with a new effectId",
};
}
export function modelSwitchErrorOutcome(detail) {
return {
kind: "error",
reason: "error",
detail,
action: "read the error, then send set_model again with a new effectId after correcting its cause",
};
}
export function unsupportedThinkingLevelOutcome(detail) {
return {
kind: "unsupported_thinking_level",
reason: "unsupported_thinking_level",
detail,
action: "pick a level from get_available_thinking_levels and send it again with a new effectId",
};
}
export function turnErrorOutcome(detail) {
return {
kind: "error",
reason: "error",
detail: detail ?? "the turn ended with a provider error",
action: "read the error in the transcript, then retry the turn",
};
}
//# sourceMappingURL=effect-outcome-copy.js.map