fix(agent-loop): notify type (#608)
## Description The `as AppConfig` type assertion in the constructor may introduce potential type safety risks. Removing the assertion and making `notify` an optional parameter could enhance type robustness and prevent unexpected runtime errors. close: #605
This commit is contained in:
@@ -141,7 +141,7 @@ export default function TerminalChat({
|
|||||||
additionalWritableRoots,
|
additionalWritableRoots,
|
||||||
fullStdout,
|
fullStdout,
|
||||||
}: Props): React.ReactElement {
|
}: Props): React.ReactElement {
|
||||||
const notify = config.notify;
|
const notify = Boolean(config.notify);
|
||||||
const [model, setModel] = useState<string>(config.model);
|
const [model, setModel] = useState<string>(config.model);
|
||||||
const [provider, setProvider] = useState<string>(config.provider || "openai");
|
const [provider, setProvider] = useState<string>(config.provider || "openai");
|
||||||
const [lastResponseId, setLastResponseId] = useState<string | null>(null);
|
const [lastResponseId, setLastResponseId] = useState<string | null>(null);
|
||||||
|
|||||||
@@ -272,12 +272,10 @@ export class AgentLoop {
|
|||||||
// defined object. We purposefully copy over the `model` and
|
// defined object. We purposefully copy over the `model` and
|
||||||
// `instructions` that have already been passed explicitly so that
|
// `instructions` that have already been passed explicitly so that
|
||||||
// downstream consumers (e.g. telemetry) still observe the correct values.
|
// downstream consumers (e.g. telemetry) still observe the correct values.
|
||||||
this.config =
|
this.config = config ?? {
|
||||||
config ??
|
model,
|
||||||
({
|
instructions: instructions ?? "",
|
||||||
model,
|
};
|
||||||
instructions: instructions ?? "",
|
|
||||||
} as AppConfig);
|
|
||||||
this.additionalWritableRoots = additionalWritableRoots;
|
this.additionalWritableRoots = additionalWritableRoots;
|
||||||
this.onItem = onItem;
|
this.onItem = onItem;
|
||||||
this.onLoading = onLoading;
|
this.onLoading = onLoading;
|
||||||
|
|||||||
@@ -132,7 +132,7 @@ export type AppConfig = {
|
|||||||
fullAutoErrorMode?: FullAutoErrorMode;
|
fullAutoErrorMode?: FullAutoErrorMode;
|
||||||
memory?: MemoryConfig;
|
memory?: MemoryConfig;
|
||||||
/** Whether to enable desktop notifications for responses */
|
/** Whether to enable desktop notifications for responses */
|
||||||
notify: boolean;
|
notify?: boolean;
|
||||||
|
|
||||||
/** Disable server-side response storage (send full transcript each request) */
|
/** Disable server-side response storage (send full transcript each request) */
|
||||||
disableResponseStorage?: boolean;
|
disableResponseStorage?: boolean;
|
||||||
|
|||||||
Reference in New Issue
Block a user