@parlor/client 0.3.0 → 0.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- import { ActionError, type ActionInput, type ActionMap, type ActionOutput, type Tag } from "@parlor/core";
1
+ import { ActionError, type ActionInput, type ActionMap, type ActionOutput, type ReadRequest, type RefreshedRead, type Tag } from "@parlor/core";
2
2
  export declare function generateClientId(): string;
3
3
  export type HeadersProvider = HeadersInit | (() => HeadersInit | Promise<HeadersInit>);
4
4
  export interface ActionClientOptions {
@@ -10,12 +10,18 @@ export interface ActionClientOptions {
10
10
  }
11
11
  export interface CallOptions {
12
12
  readonly signal?: AbortSignal | undefined;
13
+ /** For a write: the reads the page shows, to answer with fresh the ones it changed. */
14
+ readonly refresh?: readonly ReadRequest[] | undefined;
13
15
  }
14
16
  export interface ActionEnvelope<T> {
15
17
  readonly data: T;
16
18
  readonly tags: readonly Tag[];
17
19
  /** The sync cursor a read's data reflects, when the server tracks it. */
18
20
  readonly cursor?: string | undefined;
21
+ /** For a call with `refresh`, when the server knows it: what the write changed. */
22
+ readonly writes?: readonly Tag[] | undefined;
23
+ /** For a call with `refresh`, when the server knows it: each read named, in order. */
24
+ readonly refreshed?: readonly RefreshedRead[] | undefined;
19
25
  }
20
26
  export interface ActionClient<T extends ActionMap> {
21
27
  readonly clientId: string;
@@ -1 +1 @@
1
- {"version":3,"file":"action-client.d.ts","sourceRoot":"","sources":["../src/action-client.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EACX,KAAK,WAAW,EAChB,KAAK,SAAS,EACd,KAAK,YAAY,EAEjB,KAAK,GAAG,EACT,MAAM,cAAc,CAAC;AAWtB,wBAAgB,gBAAgB,IAAI,MAAM,CAEzC;AAED,MAAM,MAAM,eAAe,GAAG,WAAW,GAAG,CAAC,MAAM,WAAW,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC;AAEvF,MAAM,WAAW,mBAAmB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AAS,GAAE,MAA8B,EACzC,QAAQ,GAAE,MAA4B,GACrC,MAAM,CASR;AAED,wBAAgB,kBAAkB,CAAC,CAAC,SAAS,SAAS,EACpD,OAAO,GAAE,mBAAwB,GAChC,YAAY,CAAC,CAAC,CAAC,CAmCjB"}
@@ -1,4 +1,4 @@
1
- import { ActionError, SHELL_ORIGINS, } from "@parlor/core";
1
+ import { ActionError, encodeReadRequests, REFRESH_HEADER, SHELL_ORIGINS, } from "@parlor/core";
2
2
  const DEFAULT_BASE_PATH = "/_parlor";
3
3
  const SOURCE_HEADER = "x-parlor-source";
4
4
  const CLIENT_HEADER = "x-parlor-client";
@@ -26,7 +26,12 @@ export async function toActionError(response, options = {}) {
26
26
  export async function invokeAt(request, path, input, options = {}) {
27
27
  const response = await request(path, {
28
28
  method: "POST",
29
- headers: { "content-type": "application/json" },
29
+ headers: {
30
+ "content-type": "application/json",
31
+ ...(options.refresh?.length
32
+ ? { [REFRESH_HEADER]: encodeReadRequests(options.refresh) }
33
+ : {}),
34
+ },
30
35
  body: JSON.stringify(input ?? {}),
31
36
  signal: options.signal ?? null,
32
37
  });
@@ -38,6 +43,9 @@ export async function invokeAt(request, path, input, options = {}) {
38
43
  data: body.data,
39
44
  tags: body.tags ?? [],
40
45
  ...(typeof body.cursor === "string" ? { cursor: body.cursor } : {}),
46
+ ...(Array.isArray(body.writes) && Array.isArray(body.refreshed)
47
+ ? { writes: body.writes, refreshed: body.refreshed }
48
+ : {}),
41
49
  };
42
50
  }
43
51
  export function resolveServerOrigin() {
@@ -1 +1 @@
1
- {"version":3,"file":"action-client.js","sourceRoot":"","sources":["../src/action-client.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EAIX,aAAa,GAEd,MAAM,cAAc,CAAC;AAEtB,MAAM,iBAAiB,GAAG,UAAU,CAAC;AACrC,MAAM,aAAa,GAAG,iBAAiB,CAAC;AACxC,MAAM,aAAa,GAAG,iBAAiB,CAAC;AAExC,SAAS,iBAAiB;IACxB,MA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AC,CAAC;IAEL,MAAM,MAAM,GAAG,KAAK,EAClB,IAAO,EACP,KAAwB,EACxB,WAAW,GAAgB,EAAE,EACgB,EAAE;QAC/C,OAAO,QAAQ,CAAO,OAAO,EAAE,GAAG,QAAQ,YAAY,IAAI,EAAE,EAAE,KAAK,EAAE,WAAW,CAAC,CAAC;IACpF,CAAC,CAAC;IAEF,OAAO;QACL,IAAI,QAAQ;YACV,OAAO,KAAK,EAAE,CAAC;QACjB,CAAC;QACD,QAAQ;QACR,OAAO;QACP,MAAM;QACN,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,WAAW,EAAE,EAAE,CACvC,CAAC,MAAM,MAAM,CAAC,IAAI,EAAE,KAAK,EAAE,WAAW,CAAC,CAAC,CAAC,IAAI;KAChD,CAAC;AACJ,CAAC","sourcesContent":["import {\n ActionError,\n type ActionInput,\n type ActionMap,\n type ActionOutput,\n SHELL_ORIGINS,\n type Tag,\n} from \"@parlor/core\";\n\nconst DEFAULT_BASE_PATH = \"/_parlor\";\nconst SOURCE_HEADER = \"x-parlor-source\";\nconst CLIENT_HEADER = \"x-parlor-client\";\n\nfunction injectedServerUrl(): string {\n const env = (import.meta as { env?: { PARLOR_SERVER_URL?: string } }).env;\n return env?.PARLOR_SERVER_URL ?? \"\";\n}\n\nexport function generateClientId(): string {\n return globalThis.crypto?.randomUUID?.() ?? Math.random().toString(36).slice(2);\n}\n\nexport type HeadersProvider = HeadersInit | (() => HeadersInit | Promise<HeadersInit>);\n\nexport interface ActionClientOptions {\n readonly baseUrl?: string | undefined;\n readonly basePath?: string | undefined;\n readonly fetch?: typeof fetch | undefined;\n readonly headers?: HeadersProvider | undefined;\n readonly clientId?: string | undefined;\n}\n\nexport interface CallOptions {\n readonly signal?: AbortSignal | undefined;\n}\n\nexport interface ActionEnvelope<T> {\n readonly data: T;\n readonly tags: readonly Tag[];\n /** The sync cursor a read's data reflects, when the server tracks it. */\n readonly cursor?: string | undefined;\n}\n\nexport interface ActionClient<T extends ActionMap> {\n readonly clientId: string;\n readonly basePath: string;\n call<K extends keyof T & string>(\n name: K,\n input: ActionInput<T[K]>,\n options?: CallOptions,\n ): Promise<ActionOutput<T[K]>>;\n invoke<K extends keyof T & string>(\n name: K,\n input: ActionInput<T[K]>,\n options?: CallOptions,\n ): Promise<ActionEnvelope<ActionOutput<T[K]>>>;\n request(path: string, init?: RequestInit): Promise<Response>;\n}\n\nasync function resolveHeaders(\n provider: HeadersProvider | undefined,\n clientId: string,\n extra?: HeadersInit,\n): Promise<Headers> {\n const headers = new Headers(\n typeof provider === \"function\" ? await provider() : provider,\n );\n new Headers(extra).forEach((value, key) => headers.set(key, value));\n headers.set(SOURCE_HEADER, \"ui\");\n headers.set(CLIENT_HEADER, clientId);\n return headers;\n}\n\nexport async function toActionError(\n response: Response,\n options: { readonly missingIsNotFound?: boolean } = {},\n): Promise<ActionError> {\n const body: unknown = await response.json().catch(() => undefined);\n if (ActionError.isBody(body)) return ActionError.fromBody(body);\n const code =\n options.missingIsNotFound && response.status === 404 ? \"not_found\" : \"internal\";\n return new ActionError(code, `Action request failed with HTTP ${response.status}`);\n}\n\nexport async function invokeAt<T extends ActionMap, K extends keyof T & string>(\n request: ActionClient<ActionMap>[\"request\"],\n path: string,\n input: ActionInput<T[K]>,\n options: CallOptions & { readonly missingIsNotFound?: boolean } = {},\n): Promise<ActionEnvelope<ActionOutput<T[K]>>> {\n const response = await request(path, {\n method: \"POST\",\n headers: { \"content-type\": \"application/json\" },\n body: JSON.stringify(input ?? {}),\n signal: options.signal ?? null,\n });\n if (!response.ok) {\n throw await toActionError(\n response,\n options.missingIsNotFound ? { missingIsNotFound: true } : {},\n );\n }\n const body = (await response.json()) as {\n data: ActionOutput<T[K]>;\n tags?: Tag[];\n cursor?: string;\n };\n return {\n data: body.data,\n tags: body.tags ?? [],\n ...(typeof body.cursor === \"string\" ? { cursor: body.cursor } : {}),\n };\n}\n\nexport function resolveServerOrigin(): string {\n return injectedServerUrl() || globalThis.location?.origin || \"\";\n}\n\nfunction injectedAppOrigin(): string {\n const env = (import.meta as { env?: { PARLOR_APP_ORIGIN?: string } }).env;\n return env?.PARLOR_APP_ORIGIN ?? \"\";\n}\n\n/**\n * The one name of this app's backend on every surface: the page's own origin when it is\n * served over http(s) and is not a shell's webview origin, else the shell's `server.url`.\n * `parlor dev` running several targets names the web target's origin for all of them.\n * Statements are signed for it and the host is paired with it.\n */\nexport function appOrigin(\n serverUrl: string = resolveServerOrigin(),\n injected: string = injectedAppOrigin(),\n): string {\n if (injected) return new URL(injected).origin;\n const page = globalThis.location?.origin ?? \"\";\n if (/^https?:\\/\\//.test(page) && !SHELL_ORIGINS.includes(page)) return page;\n try {\n return new URL(serverUrl).origin;\n } catch {\n return serverUrl;\n }\n}\n\nexport function createActionClient<T extends ActionMap>(\n options: ActionClientOptions = {},\n): ActionClient<T> {\n const {\n baseUrl = injectedServerUrl(),\n basePath = DEFAULT_BASE_PATH,\n headers,\n } = options;\n // Drawn on first use: workerd allows no random values while a module loads.\n let clientId = options.clientId;\n const ownId = () => (clientId ??= generateClientId());\n const fetchImpl = options.fetch ?? globalThis.fetch;\n\n const request = async (path: string, init: RequestInit = {}) =>\n fetchImpl(`${baseUrl}${path}`, {\n ...init,\n headers: await resolveHeaders(headers, ownId(), init.headers),\n });\n\n const invoke = async <K extends keyof T & string>(\n name: K,\n input: ActionInput<T[K]>,\n callOptions: CallOptions = {},\n ): Promise<ActionEnvelope<ActionOutput<T[K]>>> => {\n return invokeAt<T, K>(request, `${basePath}/actions/${name}`, input, callOptions);\n };\n\n return {\n get clientId() {\n return ownId();\n },\n basePath,\n request,\n invoke,\n call: async (name, input, callOptions) =>\n (await invoke(name, input, callOptions)).data,\n };\n}\n"]}
1
+ {"version":3,"file":"action-client.js","sourceRoot":"","sources":["../src/action-client.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EAIX,kBAAkB,EAElB,cAAc,EAEd,aAAa,GAEd,MAAM,cAAc,CAAC;AAEtB,M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B,EAAE,EAC7B,QAAQ,GAAG,iBAAiB,EAC5B,OAAO,GACR,GAAG,OAAO,CAAC;IACZ,4EAA4E;IAC5E,IAAI,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC;IAChC,MAAM,KAAK,GAAG,GAAG,EAAE,CAAC,CAAC,QAAQ,KAAK,gBAAgB,EAAE,CAAC,CAAC;IACtD,MAAM,SAAS,GAAG,OAAO,CAAC,KAAK,IAAI,UAAU,CAAC,KAAK,CAAC;IAEpD,MAAM,OAAO,GAAG,KAAK,EAAE,IAAY,EAAE,IAAI,GAAgB,EAAE,EAAE,EAAE,CAC7D,SAAS,CAAC,GAAG,OAAO,GAAG,IAAI,EAAE,EAAE;QAC7B,GAAG,IAAI;QACP,OAAO,EAAE,MAAM,cAAc,CAAC,OAAO,EAAE,KAAK,EAAE,EAAE,IAAI,CAAC,OAAO,CAAC;KAC9D,CAAC,CAAC;IAEL,MAAM,MAAM,GAAG,KAAK,EAClB,IAAO,EACP,KAAwB,EACxB,WAAW,GAAgB,EAAE,EACgB,EAAE;QAC/C,OAAO,QAAQ,CAAO,OAAO,EAAE,GAAG,QAAQ,YAAY,IAAI,EAAE,EAAE,KAAK,EAAE,WAAW,CAAC,CAAC;IACpF,CAAC,CAAC;IAEF,OAAO;QACL,IAAI,QAAQ;YACV,OAAO,KAAK,EAAE,CAAC;QACjB,CAAC;QACD,QAAQ;QACR,OAAO;QACP,MAAM;QACN,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,WAAW,EAAE,EAAE,CACvC,CAAC,MAAM,MAAM,CAAC,IAAI,EAAE,KAAK,EAAE,WAAW,CAAC,CAAC,CAAC,IAAI;KAChD,CAAC;AACJ,CAAC","sourcesContent":["import {\n ActionError,\n type ActionInput,\n type ActionMap,\n type ActionOutput,\n encodeReadRequests,\n type ReadRequest,\n REFRESH_HEADER,\n type RefreshedRead,\n SHELL_ORIGINS,\n type Tag,\n} from \"@parlor/core\";\n\nconst DEFAULT_BASE_PATH = \"/_parlor\";\nconst SOURCE_HEADER = \"x-parlor-source\";\nconst CLIENT_HEADER = \"x-parlor-client\";\n\nfunction injectedServerUrl(): string {\n const env = (import.meta as { env?: { PARLOR_SERVER_URL?: string } }).env;\n return env?.PARLOR_SERVER_URL ?? \"\";\n}\n\nexport function generateClientId(): string {\n return globalThis.crypto?.randomUUID?.() ?? Math.random().toString(36).slice(2);\n}\n\nexport type HeadersProvider = HeadersInit | (() => HeadersInit | Promise<HeadersInit>);\n\nexport interface ActionClientOptions {\n readonly baseUrl?: string | undefined;\n readonly basePath?: string | undefined;\n readonly fetch?: typeof fetch | undefined;\n readonly headers?: HeadersProvider | undefined;\n readonly clientId?: string | undefined;\n}\n\nexport interface CallOptions {\n readonly signal?: AbortSignal | undefined;\n /** For a write: the reads the page shows, to answer with fresh the ones it changed. */\n readonly refresh?: readonly ReadRequest[] | undefined;\n}\n\nexport interface ActionEnvelope<T> {\n readonly data: T;\n readonly tags: readonly Tag[];\n /** The sync cursor a read's data reflects, when the server tracks it. */\n readonly cursor?: string | undefined;\n /** For a call with `refresh`, when the server knows it: what the write changed. */\n readonly writes?: readonly Tag[] | undefined;\n /** For a call with `refresh`, when the server knows it: each read named, in order. */\n readonly refreshed?: readonly RefreshedRead[] | undefined;\n}\n\nexport interface ActionClient<T extends ActionMap> {\n readonly clientId: string;\n readonly basePath: string;\n call<K extends keyof T & string>(\n name: K,\n input: ActionInput<T[K]>,\n options?: CallOptions,\n ): Promise<ActionOutput<T[K]>>;\n invoke<K extends keyof T & string>(\n name: K,\n input: ActionInput<T[K]>,\n options?: CallOptions,\n ): Promise<ActionEnvelope<ActionOutput<T[K]>>>;\n request(path: string, init?: RequestInit): Promise<Response>;\n}\n\nasync function resolveHeaders(\n provider: HeadersProvider | undefined,\n clientId: string,\n extra?: HeadersInit,\n): Promise<Headers> {\n const headers = new Headers(\n typeof provider === \"function\" ? await provider() : provider,\n );\n new Headers(extra).forEach((value, key) => headers.set(key, value));\n headers.set(SOURCE_HEADER, \"ui\");\n headers.set(CLIENT_HEADER, clientId);\n return headers;\n}\n\nexport async function toActionError(\n response: Response,\n options: { readonly missingIsNotFound?: boolean } = {},\n): Promise<ActionError> {\n const body: unknown = await response.json().catch(() => undefined);\n if (ActionError.isBody(body)) return ActionError.fromBody(body);\n const code =\n options.missingIsNotFound && response.status === 404 ? \"not_found\" : \"internal\";\n return new ActionError(code, `Action request failed with HTTP ${response.status}`);\n}\n\nexport async function invokeAt<T extends ActionMap, K extends keyof T & string>(\n request: ActionClient<ActionMap>[\"request\"],\n path: string,\n input: ActionInput<T[K]>,\n options: CallOptions & { readonly missingIsNotFound?: boolean } = {},\n): Promise<ActionEnvelope<ActionOutput<T[K]>>> {\n const response = await request(path, {\n method: \"POST\",\n headers: {\n \"content-type\": \"application/json\",\n ...(options.refresh?.length\n ? { [REFRESH_HEADER]: encodeReadRequests(options.refresh) }\n : {}),\n },\n body: JSON.stringify(input ?? {}),\n signal: options.signal ?? null,\n });\n if (!response.ok) {\n throw await toActionError(\n response,\n options.missingIsNotFound ? { missingIsNotFound: true } : {},\n );\n }\n const body = (await response.json()) as {\n data: ActionOutput<T[K]>;\n tags?: Tag[];\n cursor?: string;\n writes?: Tag[];\n refreshed?: RefreshedRead[];\n };\n return {\n data: body.data,\n tags: body.tags ?? [],\n ...(typeof body.cursor === \"string\" ? { cursor: body.cursor } : {}),\n ...(Array.isArray(body.writes) && Array.isArray(body.refreshed)\n ? { writes: body.writes, refreshed: body.refreshed }\n : {}),\n };\n}\n\nexport function resolveServerOrigin(): string {\n return injectedServerUrl() || globalThis.location?.origin || \"\";\n}\n\nfunction injectedAppOrigin(): string {\n const env = (import.meta as { env?: { PARLOR_APP_ORIGIN?: string } }).env;\n return env?.PARLOR_APP_ORIGIN ?? \"\";\n}\n\n/**\n * The one name of this app's backend on every surface: the page's own origin when it is\n * served over http(s) and is not a shell's webview origin, else the shell's `server.url`.\n * `parlor dev` running several targets names the web target's origin for all of them.\n * Statements are signed for it and the host is paired with it.\n */\nexport function appOrigin(\n serverUrl: string = resolveServerOrigin(),\n injected: string = injectedAppOrigin(),\n): string {\n if (injected) return new URL(injected).origin;\n const page = globalThis.location?.origin ?? \"\";\n if (/^https?:\\/\\//.test(page) && !SHELL_ORIGINS.includes(page)) return page;\n try {\n return new URL(serverUrl).origin;\n } catch {\n return serverUrl;\n }\n}\n\nexport function createActionClient<T extends ActionMap>(\n options: ActionClientOptions = {},\n): ActionClient<T> {\n const {\n baseUrl = injectedServerUrl(),\n basePath = DEFAULT_BASE_PATH,\n headers,\n } = options;\n // Drawn on first use: workerd allows no random values while a module loads.\n let clientId = options.clientId;\n const ownId = () => (clientId ??= generateClientId());\n const fetchImpl = options.fetch ?? globalThis.fetch;\n\n const request = async (path: string, init: RequestInit = {}) =>\n fetchImpl(`${baseUrl}${path}`, {\n ...init,\n headers: await resolveHeaders(headers, ownId(), init.headers),\n });\n\n const invoke = async <K extends keyof T & string>(\n name: K,\n input: ActionInput<T[K]>,\n callOptions: CallOptions = {},\n ): Promise<ActionEnvelope<ActionOutput<T[K]>>> => {\n return invokeAt<T, K>(request, `${basePath}/actions/${name}`, input, callOptions);\n };\n\n return {\n get clientId() {\n return ownId();\n },\n basePath,\n request,\n invoke,\n call: async (name, input, callOptions) =>\n (await invoke(name, input, callOptions)).data,\n };\n}\n"]}
@@ -21,6 +21,15 @@ export interface AgentChoice {
21
21
  /** The name this agent knows the app by outside the sidebar, when the user let it use the app there. */
22
22
  readonly outsideName: string | undefined;
23
23
  }
24
+ /** What `checkAgents` learned: the agents that appeared, and whether every computer answered. */
25
+ export interface AgentsCheck {
26
+ /** The agents found that the sidebar did not offer before, as "Claude Code on Alice's Mac". */
27
+ readonly found: readonly AgentChoice[];
28
+ /** Every online computer looked again in time; false when one did not answer within 8 s. */
29
+ readonly answered: boolean;
30
+ /** A computer, or this app, is too old to look again when asked. */
31
+ readonly outdated: boolean;
32
+ }
24
33
  export interface AgentChoiceOption extends AgentOption {
25
34
  /** The value the next prompt runs with: this device's choice, or the agent's own. */
26
35
  readonly selected: string;
@@ -100,6 +109,8 @@ export interface ChatState {
100
109
  /** Set while `loadOlder` or `loadMoreThreads` reads. */
101
110
  readonly loadingOlder: boolean;
102
111
  readonly hosts: readonly HostSummary[];
112
+ /** Set while `checkAgents` waits for the computers to answer. */
113
+ readonly checkingAgents: boolean;
103
114
  readonly agents: readonly AgentChoice[];
104
115
  readonly agent: AgentChoice | undefined;
105
116
  readonly connect: ConnectOption;
@@ -140,6 +151,12 @@ export interface ChatCommands {
140
151
  startLink(options?: {
141
152
  readonly presence?: boolean;
142
153
  }): Promise<void>;
154
+ /**
155
+ * Asks the user's computers to look again for the agents installed on them, and waits
156
+ * until each online one has answered: one installed since its computer started joins
157
+ * `agents`, and gets the app outside the sidebar when the user let its agents use it.
158
+ */
159
+ checkAgents(): Promise<AgentsCheck>;
143
160
  }
144
161
  export interface DeviceSetupCommands {
145
162
  /** Sets this device up, with a passkey or without one, then runs what waited for it. */
@@ -1 +1 @@
1
- {"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../../../src/react/chat/runtime.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAChF,OAAO,KAAK,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAC7E,OAAO,EACL,KAAK,WAAW,EAChB,KAAK,UAAU,EAKf,KAAK,QAAQ,EAEb,KAAK,WAAW,EAQhB,KAAK,aAAa,EAEnB,MAAM,cAAc,CAAC;AACtB,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAC7D,OAAO,EAIL,KAAK,GAAG,EAIT,MAAM,cAAc,CAAC;AACtB,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAGlD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,KAAK,EACV,oBAAoB,EACpB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AAM,IAAI,CAAC;IAC9E,QAAQ,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE,MAAM,IAAI,KAAK,MAAM,IAAI,CAAC;IACxD,qEAAqE;IACrE,QAAQ,CAAC,SAAS,EAAE,MAAM,KAAK,GAAG,MAAM,GAAG,SAAS,CAAC;IACrD,QAAQ,CAAC,YAAY,EAAE,CAAC,QAAQ,EAAE,CAAC,SAAS,EAAE,KAAK,GAAG,MAAM,KAAK,IAAI,KAAK,MAAM,IAAI,CAAC;IACrF,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC,MAAM,OAAO,CAAC,GAAG,SAAS,CAAC;IAChD,QAAQ,CAAC,IAAI,EACT,OAAO,CAAC,YAAY,GAAG,cAAc,GAAG,YAAY,GAAG,oBAAoB,CAAC,GAC5E,SAAS,CAAC;IACd,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC,gBAAgB,CAAC,cAAc,CAAC,CAAC,CAAC;IAC9D,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAC;CACvC;AAED,eAAO,MAAM,eAAe,sBAAsB,CAAC;AACnD,eAAO,MAAM,WAAW,wBAAwB,CAAC;AAyEjD,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,eAAe,GAAG,WAAW,CA4jCpE"}
@@ -9,6 +9,10 @@ const CHECKING = { status: "checking" };
9
9
  const READ_RETRY_BASE_MS = 1_000;
10
10
  const READ_RETRY_MAX_MS = 30_000;
11
11
  const ACTIVITY_PING_MS = 60_000;
12
+ /** How long `checkAgents` waits for the computers to answer. */
13
+ const AGENTS_CHECK_MS = 8_000;
14
+ /** The least time between the looks a sidebar without agents asks for on its own. */
15
+ const AUTO_CHECK_MS = 10_000;
12
16
  const UNFIXABLE_BY_RETRY = new Set([
13
17
  "not_found",
14
18
  "unauthenticated",
@@ -67,6 +71,8 @@ export function createChatRuntime(deps) {
67
71
  let optionChoices = readOptionChoices();
68
72
  let sending = false;
69
73
  let pendingSend;
74
+ /** The prompt in flight, shown in its thread until the server's copy arrives. */
75
+ let shownSend;
70
76
  let startedNew = false;
71
77
  let connect = {
72
78
  kind: "command",
@@ -124,6 +130,67 @@ export function createChatRuntime(deps) {
124
130
  };
125
131
  /** This device's choices for `agentKey` that its agent still offers. */
126
132
  const chosenOptions = (agentKey, options) => Object.fromEntries(Object.entries(optionChoices[agentKey] ?? {}).filter(([id, value]) => options.some((option) => option.id === id && option.values.some((candidate) => candidate.id === value))));
133
+ let checkingAgents;
134
+ let lastAutoCheck = 0;
135
+ /** Resolves once `done` holds after an update, or after `ms`. */
136
+ const until = (done, ms) => new Promise((resolve) => {
137
+ const finish = () => {
138
+ clearTimeout(timer);
139
+ listeners.delete(check);
140
+ resolve();
141
+ };
142
+ const check = () => {
143
+ if (done())
144
+ finish();
145
+ };
146
+ const timer = setTimeout(finish, ms);
147
+ listeners.add(check);
148
+ });
149
+ const checkAgents = () => {
150
+ if (checkingAgents)
151
+ return checkingAgents;
152
+ const before = new Set(choices().map((choice) => choice.key));
153
+ checkingAgents = (async () => {
154
+ try {
155
+ let askedAt;
156
+ try {
157
+ ({ askedAt } = await calls.call("checkAgents", {}));
158
+ }
159
+ catch (error) {
160
+ if (error instanceof ActionError && error.code === "not_found") {
161
+ return { found: [], answered: false, outdated: true };
162
+ }
163
+ throw error;
164
+ }
165
+ const online = () => hosts.filter((host) => host.online);
166
+ const answered = () => online().every((host) => (host.agentsCheckedAt ?? 0) >= askedAt);
167
+ if (!answered())
168
+ await until(answered, AGENTS_CHECK_MS);
169
+ return {
170
+ found: choices().filter((choice) => !before.has(choice.key)),
171
+ answered: answered(),
172
+ outdated: online().some((host) => host.agentsCheckedAt === undefined),
173
+ };
174
+ }
175
+ finally {
176
+ checkingAgents = undefined;
177
+ emit();
178
+ }
179
+ })();
180
+ emit();
181
+ return checkingAgents;
182
+ };
183
+ /** A sidebar with computers but no agent asks them to look again when it comes into view. */
184
+ const checkAgentsOnSight = () => {
185
+ if (!running || loaded !== "yes" || deps.isHidden?.() === true)
186
+ return;
187
+ if (!hosts.some((host) => host.online) || choices().length > 0)
188
+ return;
189
+ if (Date.now() - lastAutoCheck < AUTO_CHECK_MS)
190
+ return;
191
+ lastAutoCheck = Date.now();
192
+ void checkAgents().catch(() => undefined);
193
+ };
127
194
  const choices = () => hosts.flatMap((host) => host.agents.map((agent) => {
128
195
  const key = `${host.id}/${agent.id}`;
129
196
  const offered = agent.options ?? [];
@@ -185,6 +252,27 @@ export function createChatRuntime(deps) {
185
252
  hosts.some((host) => host.id === turn.agent.hostId && !host.online));
186
253
  return offline && waitOn("offline", offline.agent.hostId);
187
254
  };
255
+ const withShownSend = (folded) => {
256
+ if (shownSend && items.has(shownSend.itemId))
257
+ shownSend = undefined;
258
+ const shown = shownSend;
259
+ if (!shown || (threadId !== shown.openedIn && threadId !== shown.threadId)) {
260
+ return folded;
261
+ }
262
+ const [hostId, agentId] = shown.agent.split("/");
263
+ const row = {
264
+ kind: "prompt",
265
+ id: shown.itemId,
266
+ turnId: shown.turnId,
267
+ text: shown.text,
268
+ agent: { hostId: asId("host", hostId), agentId },
269
+ state: "queued",
270
+ failure: undefined,
271
+ mine: true,
272
+ sending: true,
273
+ };
274
+ return [...folded, row];
275
+ };
188
276
  const compute = () => {
189
277
  const agents = choices();
190
278
  const wanted = chosen ??
@@ -217,18 +305,21 @@ export function createChatRuntime(deps) {
217
305
  moreThreads,
218
306
  hasOlder,
219
307
  loadingOlder,
220
- items: foldThread({
308
+ items: withShownSend(foldThread({
221
309
  items: [...items.values()].sort(bySeq),
222
310
  open: [...open.turns.values()],
223
311
  turns,
224
- confirmations: agentUi.confirmations.get().filter((c) => c.threadId === threadId),
312
+ confirmations: agentUi.confirmations
313
+ .get()
314
+ .filter((c) => c.threadId === threadId),
225
315
  deviceId: device?.id,
226
- }),
316
+ })),
227
317
  hosts,
228
318
  agents,
229
319
  agent,
230
320
  connect,
231
321
  draft,
322
+ checkingAgents: checkingAgents !== undefined,
232
323
  error: failure,
233
324
  setup,
234
325
  link: linkOf(),
@@ -541,6 +632,7 @@ export function createChatRuntime(deps) {
541
632
  open = NO_OPEN_TURNS;
542
633
  beforeLoad = [];
543
634
  pendingSend = undefined;
635
+ shownSend = undefined;
544
636
  stopIds.clear();
545
637
  answerIds.clear();
546
638
  dirty = false;
@@ -586,12 +678,28 @@ export function createChatRuntime(deps) {
586
678
  turnId: mint("turn"),
587
679
  itemId: mint("item"),
588
680
  });
589
- await whenSetUp(() => submit(attempt, target.key, () => {
590
- pendingSend = undefined;
681
+ await whenSetUp(async () => {
682
+ let delivered = false;
683
+ shownSend = attempt;
591
684
  if (draft.trim() === prompt)
592
685
  draft = "";
593
- }));
686
+ emit();
687
+ try {
688
+ await submit(attempt, target.key, () => {
689
+ delivered = true;
690
+ pendingSend = undefined;
691
+ });
692
+ }
693
+ finally {
694
+ if (!delivered && shownSend === attempt) {
695
+ shownSend = undefined;
696
+ draft = draft.trim() === "" ? attempt.text : `${attempt.text}\n\n${draft}`;
697
+ emit();
698
+ }
699
+ }
700
+ });
594
701
  },
702
+ checkAgents,
595
703
  async loadOlder() {
596
704
  const target = threadId;
597
705
  const before = oldestSeq();
@@ -879,6 +987,19 @@ export function createChatRuntime(deps) {
879
987
  announceActivity();
880
988
  });
881
989
  const offConfirmations = agentUi.confirmations.subscribe(emit);
990
+ // Back from installing an agent in a terminal, the window regains focus without the tab ever hiding.
991
+ const onSight = () => {
992
+ if (typeof document === "undefined" || document.visibilityState === "visible")
993
+ checkAgentsOnSight();
994
+ };
995
+ const watchesSight = typeof window !== "undefined" &&
996
+ typeof window.addEventListener === "function" &&
997
+ typeof document !== "undefined" &&
998
+ typeof document.addEventListener === "function";
999
+ if (watchesSight) {
1000
+ window.addEventListener("focus", onSight);
1001
+ document.addEventListener("visibilitychange", onSight);
1002
+ }
882
1003
  const offLink = deps.auth?.subscribeLink?.(() => void refreshLink());
883
1004
  emit();
884
1005
  announceActivity();
@@ -897,6 +1018,10 @@ export function createChatRuntime(deps) {
897
1018
  offResume();
898
1019
  offNegotiated();
899
1020
  offConfirmations();
1021
+ if (watchesSight) {
1022
+ window.removeEventListener("focus", onSight);
1023
+ document.removeEventListener("visibilitychange", onSight);
1024
+ }
900
1025
  offLink?.();
901
1026
  stopWatching?.();
902
1027
  stopWatching = undefined;
@@ -977,6 +1102,7 @@ export function createChatRuntime(deps) {
977
1102
  await loadFirst();
978
1103
  announceActivity();
979
1104
  emit();
1105
+ checkAgentsOnSight();
980
1106
  }
981
1107
  return runtime;
982
1108
  }