@parlor/chat 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.
package/dist/index.d.ts CHANGED
@@ -3,7 +3,7 @@ export type { Author, AuthorOf, ChatItemBody, ChatItemKind, HostItemDraft, HostI
3
3
  export { type AppliedFrame, applyFrame } from "./open-turns.js";
4
4
  export { isPromptTooLong, MAX_PROMPT_CHARS, PROMPT_LIMIT_MESSAGE } from "./limits.js";
5
5
  export type { AgentInfo, AgentOption, AgentOptionValue, AgentRef, AgentUsage, AgentUsageWindow, AnswerToSign, ChatOwner, ChatSnapshot, ClaimedDevice, ClaimedTurn, HostSummary, OpenItem, OpenTurn, PromptToSign, ThreadHistory, ThreadList, ThreadPage, ThreadSummary, TurnFailure, TurnOutcome, TurnSignals, TurnState, TurnStatus, } from "./model.js";
6
- export { CHAT_CHANNEL, CHAT_PLUGIN, type ChatFrame, HOST_PROTOCOL, type HostFrame, type HostHello, type HostStreamBatch, type HostWelcome, parseChatFrame, type ProtocolRange, type StreamingKind, } from "./protocol.js";
7
- export { CHAT_ACTIVITY_TAG, CHAT_TAG, HOSTS_TAG } from "./tags.js";
6
+ export { CHAT_CHANNEL, CHAT_PLUGIN, type ChatFrame, HOST_PROTOCOL, type HostFrame, type HostHello, type HostStreamBatch, type HostWelcome, parseChatFrame, PUSHED_TURNS_PROTOCOL, type PushedTurn, type ProtocolRange, type StreamingKind, } from "./protocol.js";
7
+ export { CHAT_ACTIVITY_TAG, CHAT_AGENTS_CHECK_TAG, CHAT_TAG, HOSTS_TAG } from "./tags.js";
8
8
  export { type AskState, type ChatItem, type FoldedKind, type FoldInput, foldThread, type ItemFolders, type ThreadConfirmation, } from "./view.js";
9
9
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,KAAK,SAAS,E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,YAAY,EACZ,aAAa,EACb,YAAY,EACZ,aAAa,EACb,UAAU,EACV,YAAY,GACb,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,KAAK,YAAY,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAChE,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AACtF,YAAY,EACV,SAAS,EACT,WAAW,EACX,gBAAgB,EAChB,QAAQ,EACR,UAAU,EACV,gBAAgB,EAChB,YAAY,EACZ,SAAS,EACT,YAAY,EACZ,aAAa,EACb,WAAW,EACX,WAAW,EACX,QAAQ,EACR,QAAQ,EACR,YAAY,EACZ,aAAa,EACb,UAAU,EACV,UAAU,EACV,aAAa,EACb,WAAW,EACX,WAAW,EACX,WAAW,EACX,SAAS,EACT,UAAU,GACX,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,YAAY,EACZ,WAAW,EACX,KAAK,SAAS,EACd,aAAa,EACb,KAAK,SAAS,EACd,KAAK,SAAS,EACd,KAAK,eAAe,EACpB,KAAK,WAAW,EAChB,cAAc,EACd,qBAAqB,EACrB,KAAK,UAAU,EACf,KAAK,aAAa,EAClB,KAAK,aAAa,GACnB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,iBAAiB,EAAE,qBAAqB,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAC1F,OAAO,EACL,KAAK,QAAQ,EACb,KAAK,QAAQ,EACb,KAAK,UAAU,EACf,KAAK,SAAS,EACd,UAAU,EACV,KAAK,WAAW,EAChB,KAAK,kBAAkB,GACxB,MAAM,WAAW,CAAC"}
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  export { CHAT_EVENTS } from "./events.js";
2
2
  export { applyFrame } from "./open-turns.js";
3
3
  export { isPromptTooLong, MAX_PROMPT_CHARS, PROMPT_LIMIT_MESSAGE } from "./limits.js";
4
- export { CHAT_CHANNEL, CHAT_PLUGIN, HOST_PROTOCOL, parseChatFrame, } from "./protocol.js";
5
- export { CHAT_ACTIVITY_TAG, CHAT_TAG, HOSTS_TAG } from "./tags.js";
4
+ export { CHAT_CHANNEL, CHAT_PLUGIN, HOST_PROTOCOL, parseChatFrame, PUSHED_TURNS_PROTOCOL, } from "./protocol.js";
5
+ export { CHAT_ACTIVITY_TAG, CHAT_AGENTS_CHECK_TAG, CHAT_TAG, HOSTS_TAG } from "./tags.js";
6
6
  export { foldThread, } from "./view.js";
7
7
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAkB,MAAM,aAAa,CAAC;AAY1D,OAAO,EAAqB,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAChE,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AA2BtF,OAAO,EACL,YAAY,EACZ,WAAW,EAEX,aAAa,EAKb,cAAc,GAGf,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,iBAAiB,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACnE,OAAO,EAKL,UAAU,GAGX,MAAM,WAAW,CAAC","sourcesContent":["export { CHAT_EVENTS, type ChatEvent } from \"./events.js\";\nexport type {\n Author,\n AuthorOf,\n ChatItemBody,\n ChatItemKind,\n HostItemDraft,\n HostItemKind,\n ItemSignature,\n LoggedItem,\n UserItemKind,\n} from \"./items.js\";\nexport { type AppliedFrame, applyFrame } from \"./open-turns.js\";\nexport { isPromptTooLong, MAX_PROMPT_CHARS, PROMPT_LIMIT_MESSAGE } from \"./limits.js\";\nexport type {\n AgentInfo,\n AgentOption,\n AgentOptionValue,\n AgentRef,\n AgentUsage,\n AgentUsageWindow,\n AnswerToSign,\n ChatOwner,\n ChatSnapshot,\n ClaimedDevice,\n ClaimedTurn,\n HostSummary,\n OpenItem,\n OpenTurn,\n PromptToSign,\n ThreadHistory,\n ThreadList,\n ThreadPage,\n ThreadSummary,\n TurnFailure,\n TurnOutcome,\n TurnSignals,\n TurnState,\n TurnStatus,\n} from \"./model.js\";\nexport {\n CHAT_CHANNEL,\n CHAT_PLUGIN,\n type ChatFrame,\n HOST_PROTOCOL,\n type HostFrame,\n type HostHello,\n type HostStreamBatch,\n type HostWelcome,\n parseChatFrame,\n type ProtocolRange,\n type StreamingKind,\n} from \"./protocol.js\";\nexport { CHAT_ACTIVITY_TAG, CHAT_TAG, HOSTS_TAG } from \"./tags.js\";\nexport {\n type AskState,\n type ChatItem,\n type FoldedKind,\n type FoldInput,\n foldThread,\n type ItemFolders,\n type ThreadConfirmation,\n} from \"./view.js\";\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAkB,MAAM,aAAa,CAAC;AAY1D,OAAO,EAAqB,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAChE,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AA2BtF,OAAO,EACL,YAAY,EACZ,WAAW,EAEX,aAAa,EAKb,cAAc,EACd,qBAAqB,GAItB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,iBAAiB,EAAE,qBAAqB,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAC1F,OAAO,EAKL,UAAU,GAGX,MAAM,WAAW,CAAC","sourcesContent":["export { CHAT_EVENTS, type ChatEvent } from \"./events.js\";\nexport type {\n Author,\n AuthorOf,\n ChatItemBody,\n ChatItemKind,\n HostItemDraft,\n HostItemKind,\n ItemSignature,\n LoggedItem,\n UserItemKind,\n} from \"./items.js\";\nexport { type AppliedFrame, applyFrame } from \"./open-turns.js\";\nexport { isPromptTooLong, MAX_PROMPT_CHARS, PROMPT_LIMIT_MESSAGE } from \"./limits.js\";\nexport type {\n AgentInfo,\n AgentOption,\n AgentOptionValue,\n AgentRef,\n AgentUsage,\n AgentUsageWindow,\n AnswerToSign,\n ChatOwner,\n ChatSnapshot,\n ClaimedDevice,\n ClaimedTurn,\n HostSummary,\n OpenItem,\n OpenTurn,\n PromptToSign,\n ThreadHistory,\n ThreadList,\n ThreadPage,\n ThreadSummary,\n TurnFailure,\n TurnOutcome,\n TurnSignals,\n TurnState,\n TurnStatus,\n} from \"./model.js\";\nexport {\n CHAT_CHANNEL,\n CHAT_PLUGIN,\n type ChatFrame,\n HOST_PROTOCOL,\n type HostFrame,\n type HostHello,\n type HostStreamBatch,\n type HostWelcome,\n parseChatFrame,\n PUSHED_TURNS_PROTOCOL,\n type PushedTurn,\n type ProtocolRange,\n type StreamingKind,\n} from \"./protocol.js\";\nexport { CHAT_ACTIVITY_TAG, CHAT_AGENTS_CHECK_TAG, CHAT_TAG, HOSTS_TAG } from \"./tags.js\";\nexport {\n type AskState,\n type ChatItem,\n type FoldedKind,\n type FoldInput,\n foldThread,\n type ItemFolders,\n type ThreadConfirmation,\n} from \"./view.js\";\n"]}
package/dist/model.d.ts CHANGED
@@ -27,6 +27,11 @@ export interface HostSummary {
27
27
  * (epoch ms); a device it never asks is missing.
28
28
  */
29
29
  readonly presenceDue?: Readonly<Record<string, number>> | undefined;
30
+ /**
31
+ * When this computer last looked for the agents installed on it, by the server's clock;
32
+ * absent on a computer too old to look again when asked.
33
+ */
34
+ readonly agentsCheckedAt?: number | undefined;
30
35
  }
31
36
  export interface AgentInfo {
32
37
  readonly id: string;
@@ -1 +1 @@
1
- {"version":3,"file":"model.d.ts","sourceRoot":"","sources":["../src/model.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAC7E,OAAO,KAAK,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAE7D,OAAO,KAAK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QAAQ,EAAE,QAAQ,CAAC;IAC5B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,KAAK,EAAE,QAAQ,CAAC;IACzB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC;IAC5B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,MAAM,CAAC,EAAE,YAAY,CAAC,QAAQ,CAAC,CAAC,QAAQ,CAAC,CAAC;CACpD"}
package/dist/model.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"model.js","sourceRoot":"","sources":["../src/model.ts"],"names":[],"mappings":"","sourcesContent":["import type { HostId, ItemId, ThreadId, TurnId, UserId } from \"@parlor/core\";\nimport type { Delegation, DeviceKeys } from \"@parlor/server\";\n\nimport type { ChatItemBody, LoggedItem, UserItemKind } from \"./items.js\";\n\nexport interface AgentRef {\n readonly hostId: HostId;\n /** A profile id on that host (`claude`, `codex`), not an entity. */\n readonly agentId: string;\n}\n\n/**\n * Whose chat a row is. Every thread, turn and host row carries both and every chat query\n * filters by both, so members of one organization scope never see each other's chats.\n */\nexport interface ChatOwner {\n readonly scope: string;\n readonly userId: UserId;\n}\n\nexport interface HostSummary {\n readonly id: HostId;\n readonly name: string;\n readonly platform: string;\n readonly online: boolean;\n readonly agents: readonly AgentInfo[];\n /** The devices this computer runs prompts from; absent when it is too old to say. */\n readonly devices?: readonly string[] | undefined;\n /**\n * When each of those devices must sign its next prompt with Face ID or Touch ID again\n * (epoch ms); a device it never asks is missing.\n */\n readonly presenceDue?: Readonly<Record<string, number>> | undefined;\n}\n\nexport interface AgentInfo {\n readonly id: string;\n readonly name: string;\n readonly version?: string | undefined;\n readonly ready: boolean;\n /** Why a not-ready agent cannot run yet (\"run `claude` to log in\"). */\n readonly problem?: string | undefined;\n /** What a prompt may choose for its turn, as the agent last offered it; absent until it has. */\n readonly options?: readonly AgentOption[] | undefined;\n /** The account's allowance, as the agent last reported it; absent until it has. */\n readonly usage?: AgentUsage | undefined;\n /**\n * The name this agent knows the app by outside the sidebar, when the user let it use the\n * app there: \"use coursekit to ...\" in Claude Code.\n */\n readonly outsideName?: string | undefined;\n}\n\n/**\n * One setting a prompt may choose, such as the model or how hard it thinks. Never the\n * permission mode: that is the computer's to set.\n */\nexport interface AgentOption {\n readonly id: string;\n readonly name: string;\n /** `model` and `thought_level` as the agent tags them; any other the agent names. */\n readonly category?: string | undefined;\n /** The agent's own default, the value a prompt that chooses nothing runs with. */\n readonly current: string;\n readonly values: readonly AgentOptionValue[];\n}\n\nexport interface AgentOptionValue {\n readonly id: string;\n readonly name: string;\n readonly description?: string | undefined;\n}\n\nexport interface AgentUsage {\n /** Account-wide windows first, each set shortest first. */\n readonly windows: readonly AgentUsageWindow[];\n /** When the agent reported it (epoch ms). */\n readonly at: number;\n}\n\nexport interface AgentUsageWindow {\n /** The vendor's name for it: `five_hour`, `seven_day`, `seven_day_opus`. */\n readonly id: string;\n readonly minutes: number;\n /** Share of the window used, 0 to 1. */\n readonly used: number;\n /** When the window rolls over (epoch ms). */\n readonly resetsAt?: number | undefined;\n}\n\nexport interface ThreadSummary {\n readonly id: ThreadId;\n readonly title: string;\n readonly agent: AgentRef | undefined;\n readonly updatedAt: number;\n readonly lastSeq: number;\n}\n\nexport type TurnState = \"queued\" | \"running\" | \"done\" | \"failed\" | \"cancelled\";\n\nexport type TurnFailure =\n | \"agent_exited\"\n | \"agent_unavailable\"\n | \"device_rejected\"\n | \"signature_invalid\"\n | \"prompt_expired\"\n | \"host_lost\";\n\nexport type TurnOutcome =\n | { readonly state: \"done\"; readonly stopReason: string }\n | { readonly state: \"cancelled\" }\n | { readonly state: \"failed\"; readonly reason: TurnFailure };\n\n/** Still being produced: only in memory, on the instance the host posts to. */\nexport type OpenItem =\n | { readonly id: ItemId; readonly kind: \"reply\" | \"reasoning\"; readonly text: string }\n | {\n readonly id: ItemId;\n readonly kind: \"tool\";\n readonly title: string;\n readonly status: \"pending\" | \"running\";\n }\n | {\n readonly id: ItemId;\n readonly kind: \"plan\";\n readonly entries: ChatItemBody<\"plan\">[\"entries\"];\n };\n\nexport interface OpenTurn {\n readonly turnId: TurnId;\n readonly threadId: ThreadId;\n readonly items: readonly OpenItem[];\n}\n\nexport interface TurnStatus {\n readonly turnId: TurnId;\n readonly state: TurnState;\n readonly agent: AgentRef;\n readonly failure?: TurnFailure | undefined;\n}\n\nexport interface ThreadPage {\n readonly thread: ThreadSummary | undefined;\n readonly items: readonly LoggedItem[];\n readonly open: readonly OpenTurn[];\n readonly turns: readonly TurnStatus[];\n readonly hasMore: boolean;\n}\n\nexport interface ChatSnapshot {\n readonly threads: readonly ThreadSummary[];\n /** `threads` was cut at its limit; `threadsBefore` reads on from its last one. */\n readonly moreThreads?: boolean | undefined;\n readonly hosts: readonly HostSummary[];\n readonly page: ThreadPage;\n}\n\n/** What `history` returns: earlier items of a thread, oldest first, with their turns. */\nexport interface ThreadHistory {\n readonly items: readonly LoggedItem[];\n readonly turns: readonly TurnStatus[];\n readonly hasMore: boolean;\n}\n\n/** What `threadsBefore` returns: the next older threads, newest first. */\nexport interface ThreadList {\n readonly threads: readonly ThreadSummary[];\n readonly hasMore: boolean;\n}\n\n/** The device's keys as the account has them; the host compares them with its own pins. */\nexport type ClaimedDevice = DeviceKeys;\n\nexport interface ClaimedTurn {\n /** The thread id; every chat write returns it as `id`, which becomes its sync tag. */\n readonly id: ThreadId;\n readonly turnId: TurnId;\n readonly agent: AgentRef;\n /** The client the prompt came from; the turn token binds `ui_*` to it. */\n readonly clientId: string;\n readonly prompt: LoggedItem<\"prompt\">;\n readonly device: ClaimedDevice | undefined;\n /** The `<parlor-context>` block for a fresh agent session. */\n readonly context: string;\n readonly token: Delegation;\n readonly leaseUntil: number;\n}\n\nexport interface TurnSignals {\n readonly turnId: TurnId;\n readonly items: readonly LoggedItem<Exclude<UserItemKind, \"prompt\">>[];\n /** The keys of each device that answered, as the account lists them; revoked ones are left out. */\n readonly devices?: readonly DeviceKeys[];\n}\n\n/** What a device signs for a prompt; the host rebuilds the same statement from the item. */\nexport interface PromptToSign {\n readonly threadId: ThreadId;\n readonly turnId: TurnId;\n readonly agent: AgentRef;\n readonly text: string;\n}\n\nexport interface AnswerToSign {\n readonly threadId: ThreadId;\n readonly askId: ItemId;\n readonly choice: string;\n readonly values?: ChatItemBody<\"answer\">[\"values\"];\n}\n"]}
1
+ {"version":3,"file":"model.js","sourceRoot":"","sources":["../src/model.ts"],"names":[],"mappings":"","sourcesContent":["import type { HostId, ItemId, ThreadId, TurnId, UserId } from \"@parlor/core\";\nimport type { Delegation, DeviceKeys } from \"@parlor/server\";\n\nimport type { ChatItemBody, LoggedItem, UserItemKind } from \"./items.js\";\n\nexport interface AgentRef {\n readonly hostId: HostId;\n /** A profile id on that host (`claude`, `codex`), not an entity. */\n readonly agentId: string;\n}\n\n/**\n * Whose chat a row is. Every thread, turn and host row carries both and every chat query\n * filters by both, so members of one organization scope never see each other's chats.\n */\nexport interface ChatOwner {\n readonly scope: string;\n readonly userId: UserId;\n}\n\nexport interface HostSummary {\n readonly id: HostId;\n readonly name: string;\n readonly platform: string;\n readonly online: boolean;\n readonly agents: readonly AgentInfo[];\n /** The devices this computer runs prompts from; absent when it is too old to say. */\n readonly devices?: readonly string[] | undefined;\n /**\n * When each of those devices must sign its next prompt with Face ID or Touch ID again\n * (epoch ms); a device it never asks is missing.\n */\n readonly presenceDue?: Readonly<Record<string, number>> | undefined;\n /**\n * When this computer last looked for the agents installed on it, by the server's clock;\n * absent on a computer too old to look again when asked.\n */\n readonly agentsCheckedAt?: number | undefined;\n}\n\nexport interface AgentInfo {\n readonly id: string;\n readonly name: string;\n readonly version?: string | undefined;\n readonly ready: boolean;\n /** Why a not-ready agent cannot run yet (\"run `claude` to log in\"). */\n readonly problem?: string | undefined;\n /** What a prompt may choose for its turn, as the agent last offered it; absent until it has. */\n readonly options?: readonly AgentOption[] | undefined;\n /** The account's allowance, as the agent last reported it; absent until it has. */\n readonly usage?: AgentUsage | undefined;\n /**\n * The name this agent knows the app by outside the sidebar, when the user let it use the\n * app there: \"use coursekit to ...\" in Claude Code.\n */\n readonly outsideName?: string | undefined;\n}\n\n/**\n * One setting a prompt may choose, such as the model or how hard it thinks. Never the\n * permission mode: that is the computer's to set.\n */\nexport interface AgentOption {\n readonly id: string;\n readonly name: string;\n /** `model` and `thought_level` as the agent tags them; any other the agent names. */\n readonly category?: string | undefined;\n /** The agent's own default, the value a prompt that chooses nothing runs with. */\n readonly current: string;\n readonly values: readonly AgentOptionValue[];\n}\n\nexport interface AgentOptionValue {\n readonly id: string;\n readonly name: string;\n readonly description?: string | undefined;\n}\n\nexport interface AgentUsage {\n /** Account-wide windows first, each set shortest first. */\n readonly windows: readonly AgentUsageWindow[];\n /** When the agent reported it (epoch ms). */\n readonly at: number;\n}\n\nexport interface AgentUsageWindow {\n /** The vendor's name for it: `five_hour`, `seven_day`, `seven_day_opus`. */\n readonly id: string;\n readonly minutes: number;\n /** Share of the window used, 0 to 1. */\n readonly used: number;\n /** When the window rolls over (epoch ms). */\n readonly resetsAt?: number | undefined;\n}\n\nexport interface ThreadSummary {\n readonly id: ThreadId;\n readonly title: string;\n readonly agent: AgentRef | undefined;\n readonly updatedAt: number;\n readonly lastSeq: number;\n}\n\nexport type TurnState = \"queued\" | \"running\" | \"done\" | \"failed\" | \"cancelled\";\n\nexport type TurnFailure =\n | \"agent_exited\"\n | \"agent_unavailable\"\n | \"device_rejected\"\n | \"signature_invalid\"\n | \"prompt_expired\"\n | \"host_lost\";\n\nexport type TurnOutcome =\n | { readonly state: \"done\"; readonly stopReason: string }\n | { readonly state: \"cancelled\" }\n | { readonly state: \"failed\"; readonly reason: TurnFailure };\n\n/** Still being produced: only in memory, on the instance the host posts to. */\nexport type OpenItem =\n | { readonly id: ItemId; readonly kind: \"reply\" | \"reasoning\"; readonly text: string }\n | {\n readonly id: ItemId;\n readonly kind: \"tool\";\n readonly title: string;\n readonly status: \"pending\" | \"running\";\n }\n | {\n readonly id: ItemId;\n readonly kind: \"plan\";\n readonly entries: ChatItemBody<\"plan\">[\"entries\"];\n };\n\nexport interface OpenTurn {\n readonly turnId: TurnId;\n readonly threadId: ThreadId;\n readonly items: readonly OpenItem[];\n}\n\nexport interface TurnStatus {\n readonly turnId: TurnId;\n readonly state: TurnState;\n readonly agent: AgentRef;\n readonly failure?: TurnFailure | undefined;\n}\n\nexport interface ThreadPage {\n readonly thread: ThreadSummary | undefined;\n readonly items: readonly LoggedItem[];\n readonly open: readonly OpenTurn[];\n readonly turns: readonly TurnStatus[];\n readonly hasMore: boolean;\n}\n\nexport interface ChatSnapshot {\n readonly threads: readonly ThreadSummary[];\n /** `threads` was cut at its limit; `threadsBefore` reads on from its last one. */\n readonly moreThreads?: boolean | undefined;\n readonly hosts: readonly HostSummary[];\n readonly page: ThreadPage;\n}\n\n/** What `history` returns: earlier items of a thread, oldest first, with their turns. */\nexport interface ThreadHistory {\n readonly items: readonly LoggedItem[];\n readonly turns: readonly TurnStatus[];\n readonly hasMore: boolean;\n}\n\n/** What `threadsBefore` returns: the next older threads, newest first. */\nexport interface ThreadList {\n readonly threads: readonly ThreadSummary[];\n readonly hasMore: boolean;\n}\n\n/** The device's keys as the account has them; the host compares them with its own pins. */\nexport type ClaimedDevice = DeviceKeys;\n\nexport interface ClaimedTurn {\n /** The thread id; every chat write returns it as `id`, which becomes its sync tag. */\n readonly id: ThreadId;\n readonly turnId: TurnId;\n readonly agent: AgentRef;\n /** The client the prompt came from; the turn token binds `ui_*` to it. */\n readonly clientId: string;\n readonly prompt: LoggedItem<\"prompt\">;\n readonly device: ClaimedDevice | undefined;\n /** The `<parlor-context>` block for a fresh agent session. */\n readonly context: string;\n readonly token: Delegation;\n readonly leaseUntil: number;\n}\n\nexport interface TurnSignals {\n readonly turnId: TurnId;\n readonly items: readonly LoggedItem<Exclude<UserItemKind, \"prompt\">>[];\n /** The keys of each device that answered, as the account lists them; revoked ones are left out. */\n readonly devices?: readonly DeviceKeys[];\n}\n\n/** What a device signs for a prompt; the host rebuilds the same statement from the item. */\nexport interface PromptToSign {\n readonly threadId: ThreadId;\n readonly turnId: TurnId;\n readonly agent: AgentRef;\n readonly text: string;\n}\n\nexport interface AnswerToSign {\n readonly threadId: ThreadId;\n readonly askId: ItemId;\n readonly choice: string;\n readonly values?: ChatItemBody<\"answer\">[\"values\"];\n}\n"]}
@@ -1,5 +1,5 @@
1
1
  import { type ItemId, type ThreadId, type TurnId } from "@parlor/core";
2
- import type { AgentInfo, OpenItem } from "./model.js";
2
+ import type { AgentInfo, ClaimedTurn, OpenItem } from "./model.js";
3
3
  export declare const CHAT_CHANNEL = "chat";
4
4
  /** The plugin name, so its routes live under `/_parlor/chat/`. */
5
5
  export declare const CHAT_PLUGIN = "chat";
@@ -41,8 +41,20 @@ export interface HostStreamBatch {
41
41
  /**
42
42
  * The versioned contract between an app's backend and Parlor Host: host actions, item
43
43
  * kinds, frames and cursor rules. Bumped on any change an older peer could misread.
44
+ * 3: the server may claim a turn for the computer and push it on the `chat` channel.
44
45
  */
45
- export declare const HOST_PROTOCOL = 2;
46
+ export declare const HOST_PROTOCOL = 3;
47
+ /** The first protocol whose computers take a turn pushed to them. */
48
+ export declare const PUSHED_TURNS_PROTOCOL = 3;
49
+ /**
50
+ * Server to one computer, on the `chat` channel: a turn claimed for it, as `hostClaim` would
51
+ * answer. The computer confirms it by calling about the turn; one it never confirms goes
52
+ * back to the queue, for `hostClaim`.
53
+ */
54
+ export interface PushedTurn {
55
+ readonly type: "claimed";
56
+ readonly turn: ClaimedTurn;
57
+ }
46
58
  export interface ProtocolRange {
47
59
  readonly min: number;
48
60
  readonly max: number;
@@ -1 +1 @@
1
- {"version":3,"file":"protocol.d.ts","sourceRoot":"","sources":["../src/protocol.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,KAAK,MAAM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gB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,GAAG,SAAS,CA8BlE"}
package/dist/protocol.js CHANGED
@@ -5,8 +5,11 @@ export const CHAT_PLUGIN = "chat";
5
5
  /**
6
6
  * The versioned contract between an app's backend and Parlor Host: host actions, item
7
7
  * kinds, frames and cursor rules. Bumped on any change an older peer could misread.
8
+ * 3: the server may claim a turn for the computer and push it on the `chat` channel.
8
9
  */
9
- export const HOST_PROTOCOL = 2;
10
+ export const HOST_PROTOCOL = 3;
11
+ /** The first protocol whose computers take a turn pushed to them. */
12
+ export const PUSHED_TURNS_PROTOCOL = 3;
10
13
  function isFields(value) {
11
14
  return typeof value === "object" && value !== null && !Array.isArray(value);
12
15
  }
@@ -1 +1 @@
1
- {"version":3,"file":"protocol.js","sourceRoot":"","sources":["../src/protocol.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,IAAI,GAML,MAAM,cAAc,CAAC;AAKtB,MAAM,CAAC,MAAM,YAAY,GAAG,MAAM,CAAC;AACnC,kEAAkE;AAClE,MAAM,CAAC,MAAM,WAAW,GAAG,MAAM,CAAC;AAwClC;;;GAGG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,CAAC;AA+B/B,SAAS,QAAQ,CAAC,KAAc;IAC9B,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAC9E,CAAC;AAED,SAAS,KAAK,CAAmB,MAAoB,EAAE,KAAc;IACnE,OAAO,MAAM,CAAC,IAAI,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,SAAS,KAAK,KAAK,CAAC,CAAC;AACzD,CAAC;AAED,SAAS,IAAI,CAAmB,IAAO,EAAE,KAAc;IACrD,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,CAA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EAAE,IAAI,EAAE,GAAG,KAAK,CAAC;YAC/B,IAAI,CAAC,MAAM,IAAI,CAAC,IAAI,IAAI,OAAO,IAAI,KAAK,QAAQ;gBAAE,OAAO,SAAS,CAAC;YACnE,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI,MAAM,GAAG,CAAC;gBACvE,OAAO,SAAS,CAAC;YACnB,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;QACzE,CAAC;QACD;YACE,OAAO,SAAS,CAAC;IACrB,CAAC;AACH,CAAC","sourcesContent":["import {\n asId,\n type Id,\n type IdKind,\n type ItemId,\n type ThreadId,\n type TurnId,\n} from \"@parlor/core\";\n\nimport type { ChatItemBody } from \"./items.js\";\nimport type { AgentInfo, OpenItem } from \"./model.js\";\n\nexport const CHAT_CHANNEL = \"chat\";\n/** The plugin name, so its routes live under `/_parlor/chat/`. */\nexport const CHAT_PLUGIN = \"chat\";\n\nexport type StreamingKind = \"reply\" | \"reasoning\";\n\n/**\n * Server to browser on the `chat` channel; never persisted. `offset` makes a duplicate\n * delta skippable and a gap detectable, after which the client waits for the durable\n * item. `settled` drops a turn's open items: durable now, or gone.\n */\nexport type ChatFrame =\n | {\n readonly type: \"delta\";\n readonly threadId: ThreadId;\n readonly turnId: TurnId;\n readonly itemId: ItemId;\n readonly kind: StreamingKind;\n readonly offset: number;\n readonly text: string;\n }\n | {\n readonly type: \"item\";\n readonly threadId: ThreadId;\n readonly turnId: TurnId;\n readonly item: Extract<OpenItem, { kind: \"tool\" | \"plan\" }>;\n }\n | { readonly type: \"settled\"; readonly threadId: ThreadId; readonly turnId: TurnId };\n\n/** Host to server: the same frames minus what the batch's turn implies. Only the server settles. */\nexport type HostFrame = ChatFrame extends infer F\n ? F extends { readonly type: \"delta\" | \"item\" }\n ? Omit<F, \"threadId\" | \"turnId\">\n : never\n : never;\n\n/** `POST /_parlor/chat/stream` */\nexport interface HostStreamBatch {\n readonly turnId: TurnId;\n readonly frames: readonly HostFrame[];\n}\n\n/**\n * The versioned contract between an app's backend and Parlor Host: host actions, item\n * kinds, frames and cursor rules. Bumped on any change an older peer could misread.\n */\nexport const HOST_PROTOCOL = 2;\n\nexport interface ProtocolRange {\n readonly min: number;\n readonly max: number;\n}\n\nexport interface HostHello {\n readonly protocols: ProtocolRange;\n readonly hostVersion: string;\n readonly name: string;\n readonly platform: string;\n readonly agents: readonly AgentInfo[];\n}\n\nexport type HostWelcome =\n | {\n readonly accepted: true;\n readonly protocol: number;\n readonly leaseMs: number;\n readonly heartbeatMs: number;\n readonly userActivity?: true;\n }\n | {\n readonly accepted: false;\n readonly reason: \"host_too_old\" | \"app_too_old\";\n readonly protocols: ProtocolRange;\n };\n\ntype Fields = Readonly<Record<string, unknown>>;\n\nfunction isFields(value: unknown): value is Fields {\n return typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\nfunction oneOf<T extends string>(values: readonly T[], value: unknown): T | undefined {\n return values.find((candidate) => candidate === value);\n}\n\nfunction idOf<K extends IdKind>(kind: K, value: unknown): Id<K> | undefined {\n return typeof value === \"string\" && value.length > 0 ? asId(kind, value) : undefined;\n}\n\nfunction openItemOf(\n value: unknown,\n): Extract<OpenItem, { kind: \"tool\" | \"plan\" }> | undefined {\n if (!isFields(value)) return undefined;\n const id = idOf(\"item\", value.id);\n if (!id) return undefined;\n if (value.kind === \"tool\") {\n const status = oneOf([\"pending\", \"running\"], value.status);\n if (typeof value.title !== \"string\" || !status) return undefined;\n return { id, kind: \"tool\", title: value.title, status };\n }\n if (value.kind === \"plan\" && Array.isArray(value.entries)) {\n const entries: ChatItemBody<\"plan\">[\"entries\"][number][] = [];\n for (const entry of value.entries as unknown[]) {\n if (!isFields(entry) || typeof entry.content !== \"string\") return undefined;\n const status = oneOf([\"pending\", \"in_progress\", \"completed\"], entry.status);\n if (!status) return undefined;\n entries.push({ content: entry.content, status });\n }\n return { id, kind: \"plan\", entries };\n }\n return undefined;\n}\n\nexport function parseChatFrame(data: string): ChatFrame | undefined {\n let value: unknown;\n try {\n value = JSON.parse(data);\n } catch {\n return undefined;\n }\n if (!isFields(value)) return undefined;\n const threadId = idOf(\"thread\", value.threadId);\n const turnId = idOf(\"turn\", value.turnId);\n if (!threadId || !turnId) return undefined;\n switch (value.type) {\n case \"settled\":\n return { type: \"settled\", threadId, turnId };\n case \"item\": {\n const item = openItemOf(value.item);\n return item ? { type: \"item\", threadId, turnId, item } : undefined;\n }\n case \"delta\": {\n const itemId = idOf(\"item\", value.itemId);\n const kind = oneOf([\"reply\", \"reasoning\"], value.kind);\n const { offset, text } = value;\n if (!itemId || !kind || typeof text !== \"string\") return undefined;\n if (typeof offset !== \"number\" || !Number.isInteger(offset) || offset < 0)\n return undefined;\n return { type: \"delta\", threadId, turnId, itemId, kind, offset, text };\n }\n default:\n return undefined;\n }\n}\n"]}
1
+ {"version":3,"file":"protocol.js","sourceRoot":"","sources":["../src/protocol.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,IAAI,GAML,MAAM,cAAc,CAAC;AAKtB,MAAM,CAAC,MAAM,YAAY,GAAG,MAAM,CAAC;AACnC,kEAAkE;AAClE,MAAM,CAAC,MAAM,WAAW,GAAG,MAAM,CAAC;AAwClC;;;;GAIG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,CAAC;AAE/B,qEAAqE;AACrE,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,CAAC;AAyCvC,SAAS,QAAQ,CAAC,KAAc;IAC9B,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAC9E,CAAC;AAED,SAAS,KAAK,CAAmB,MAAoB,EAAE,KAAc;IACnE,OAAO,MAAM,CAAC,IAAI,CAAC,CAAC,SAAS,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AAK,OAAO,EAAE,CAAC;YACb,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;YAC1C,MAAM,IAAI,GAAG,KAAK,CAAC,CAAC,OAAO,EAAE,WAAW,CAAC,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC;YACvD,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,KAAK,CAAC;YAC/B,IAAI,CAAC,MAAM,IAAI,CAAC,IAAI,IAAI,OAAO,IAAI,KAAK,QAAQ;gBAAE,OAAO,SAAS,CAAC;YACnE,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI,MAAM,GAAG,CAAC;gBACvE,OAAO,SAAS,CAAC;YACnB,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;QACzE,CAAC;QACD;YACE,OAAO,SAAS,CAAC;IACrB,CAAC;AACH,CAAC","sourcesContent":["import {\n asId,\n type Id,\n type IdKind,\n type ItemId,\n type ThreadId,\n type TurnId,\n} from \"@parlor/core\";\n\nimport type { ChatItemBody } from \"./items.js\";\nimport type { AgentInfo, ClaimedTurn, OpenItem } from \"./model.js\";\n\nexport const CHAT_CHANNEL = \"chat\";\n/** The plugin name, so its routes live under `/_parlor/chat/`. */\nexport const CHAT_PLUGIN = \"chat\";\n\nexport type StreamingKind = \"reply\" | \"reasoning\";\n\n/**\n * Server to browser on the `chat` channel; never persisted. `offset` makes a duplicate\n * delta skippable and a gap detectable, after which the client waits for the durable\n * item. `settled` drops a turn's open items: durable now, or gone.\n */\nexport type ChatFrame =\n | {\n readonly type: \"delta\";\n readonly threadId: ThreadId;\n readonly turnId: TurnId;\n readonly itemId: ItemId;\n readonly kind: StreamingKind;\n readonly offset: number;\n readonly text: string;\n }\n | {\n readonly type: \"item\";\n readonly threadId: ThreadId;\n readonly turnId: TurnId;\n readonly item: Extract<OpenItem, { kind: \"tool\" | \"plan\" }>;\n }\n | { readonly type: \"settled\"; readonly threadId: ThreadId; readonly turnId: TurnId };\n\n/** Host to server: the same frames minus what the batch's turn implies. Only the server settles. */\nexport type HostFrame = ChatFrame extends infer F\n ? F extends { readonly type: \"delta\" | \"item\" }\n ? Omit<F, \"threadId\" | \"turnId\">\n : never\n : never;\n\n/** `POST /_parlor/chat/stream` */\nexport interface HostStreamBatch {\n readonly turnId: TurnId;\n readonly frames: readonly HostFrame[];\n}\n\n/**\n * The versioned contract between an app's backend and Parlor Host: host actions, item\n * kinds, frames and cursor rules. Bumped on any change an older peer could misread.\n * 3: the server may claim a turn for the computer and push it on the `chat` channel.\n */\nexport const HOST_PROTOCOL = 3;\n\n/** The first protocol whose computers take a turn pushed to them. */\nexport const PUSHED_TURNS_PROTOCOL = 3;\n\n/**\n * Server to one computer, on the `chat` channel: a turn claimed for it, as `hostClaim` would\n * answer. The computer confirms it by calling about the turn; one it never confirms goes\n * back to the queue, for `hostClaim`.\n */\nexport interface PushedTurn {\n readonly type: \"claimed\";\n readonly turn: ClaimedTurn;\n}\n\nexport interface ProtocolRange {\n readonly min: number;\n readonly max: number;\n}\n\nexport interface HostHello {\n readonly protocols: ProtocolRange;\n readonly hostVersion: string;\n readonly name: string;\n readonly platform: string;\n readonly agents: readonly AgentInfo[];\n}\n\nexport type HostWelcome =\n | {\n readonly accepted: true;\n readonly protocol: number;\n readonly leaseMs: number;\n readonly heartbeatMs: number;\n readonly userActivity?: true;\n }\n | {\n readonly accepted: false;\n readonly reason: \"host_too_old\" | \"app_too_old\";\n readonly protocols: ProtocolRange;\n };\n\ntype Fields = Readonly<Record<string, unknown>>;\n\nfunction isFields(value: unknown): value is Fields {\n return typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\nfunction oneOf<T extends string>(values: readonly T[], value: unknown): T | undefined {\n return values.find((candidate) => candidate === value);\n}\n\nfunction idOf<K extends IdKind>(kind: K, value: unknown): Id<K> | undefined {\n return typeof value === \"string\" && value.length > 0 ? asId(kind, value) : undefined;\n}\n\nfunction openItemOf(\n value: unknown,\n): Extract<OpenItem, { kind: \"tool\" | \"plan\" }> | undefined {\n if (!isFields(value)) return undefined;\n const id = idOf(\"item\", value.id);\n if (!id) return undefined;\n if (value.kind === \"tool\") {\n const status = oneOf([\"pending\", \"running\"], value.status);\n if (typeof value.title !== \"string\" || !status) return undefined;\n return { id, kind: \"tool\", title: value.title, status };\n }\n if (value.kind === \"plan\" && Array.isArray(value.entries)) {\n const entries: ChatItemBody<\"plan\">[\"entries\"][number][] = [];\n for (const entry of value.entries as unknown[]) {\n if (!isFields(entry) || typeof entry.content !== \"string\") return undefined;\n const status = oneOf([\"pending\", \"in_progress\", \"completed\"], entry.status);\n if (!status) return undefined;\n entries.push({ content: entry.content, status });\n }\n return { id, kind: \"plan\", entries };\n }\n return undefined;\n}\n\nexport function parseChatFrame(data: string): ChatFrame | undefined {\n let value: unknown;\n try {\n value = JSON.parse(data);\n } catch {\n return undefined;\n }\n if (!isFields(value)) return undefined;\n const threadId = idOf(\"thread\", value.threadId);\n const turnId = idOf(\"turn\", value.turnId);\n if (!threadId || !turnId) return undefined;\n switch (value.type) {\n case \"settled\":\n return { type: \"settled\", threadId, turnId };\n case \"item\": {\n const item = openItemOf(value.item);\n return item ? { type: \"item\", threadId, turnId, item } : undefined;\n }\n case \"delta\": {\n const itemId = idOf(\"item\", value.itemId);\n const kind = oneOf([\"reply\", \"reasoning\"], value.kind);\n const { offset, text } = value;\n if (!itemId || !kind || typeof text !== \"string\") return undefined;\n if (typeof offset !== \"number\" || !Number.isInteger(offset) || offset < 0)\n return undefined;\n return { type: \"delta\", threadId, turnId, itemId, kind, offset, text };\n }\n default:\n return undefined;\n }\n}\n"]}
@@ -1,14 +1,16 @@
1
- import { type ActionContext, type HostId, type ThreadId } from "@parlor/core";
1
+ import { type HostId, type ThreadId, type TurnId } from "@parlor/core";
2
2
  import { type ActionsOf } from "@parlor/core/registry";
3
3
  import { type AuthProvider, type Delegation, HOST_GRANTS_TAG } from "@parlor/server";
4
4
  import { z } from "zod";
5
5
  import { idSchema } from "../id-schemas.js";
6
6
  import { type LoggedItem } from "../items.js";
7
- import type { ChatOwner, ChatSnapshot, ThreadHistory, ThreadList, ClaimedTurn, HostSummary, TurnSignals } from "../model.js";
7
+ import type { AgentInfo, ChatOwner, ChatSnapshot, ThreadHistory, ThreadList, ClaimedTurn, HostSummary, TurnSignals } from "../model.js";
8
8
  import { type HostWelcome } from "../protocol.js";
9
9
  import { CHAT_ACTIVITY_TAG, CHAT_TAG, HOSTS_TAG } from "../tags.js";
10
10
  import type { LiveRelay } from "./live.js";
11
- import { type ChatDb, type ChatStore } from "./store.js";
11
+ import { type ChatHost } from "./party.js";
12
+ import type { TurnPush } from "./push.js";
13
+ import { type ChatDb, type ChatStore, type StoredHost } from "./store.js";
12
14
  export { CHAT_ACTIVITY_TAG, CHAT_TAG, HOSTS_TAG, HOST_GRANTS_TAG };
13
15
  export interface Written<T> {
14
16
  readonly result: T;
@@ -35,7 +37,9 @@ export interface ChatActionDeps {
35
37
  readonly maxQueued: number;
36
38
  readonly instructions: string | undefined;
37
39
  readonly appName: string;
38
- readonly appOrigin: (ctx: ActionContext) => string;
40
+ readonly appOrigin: () => string;
41
+ /** Hands a queued turn straight to its computer; without it computers only claim. */
42
+ readonly pushed?: TurnPush | undefined;
39
43
  }
40
44
  export declare function userChatActions(deps: ChatActionDeps): {
41
45
  open: import("@parlor/core").ActionDefinition<z.ZodObject<{
@@ -136,9 +140,32 @@ export declare function userChatActions(deps: ChatActionDeps): {
136
140
  userActive: import("@parlor/core").ActionDefinition<z.ZodObject<{}, z.core.$strip>, {
137
141
  readonly ok: true;
138
142
  }>;
143
+ checkAgents: import("@parlor/core").ActionDefinition<z.ZodObject<{}, z.core.$strip>, {
144
+ readonly askedAt: number;
145
+ }>;
139
146
  };
147
+ /**
148
+ * What the server keeps about the computers it serves: which said hello, their agents'
149
+ * names, and how a turn is claimed for one, by `hostClaim` or pushed to it.
150
+ */
151
+ export declare function hostSession(deps: ChatActionDeps): {
152
+ welcome: (host: ChatHost, db: ChatDb) => Promise<StoredHost>;
153
+ requireWelcome: (host: ChatHost, db: ChatDb) => Promise<void>;
154
+ learnAgents: (hostId: HostId, agents: readonly AgentInfo[]) => void;
155
+ agentNameOf: (host: ChatHost, db: ChatDb, agentId: string) => Promise<string>;
156
+ mint: (host: ChatHost, db: ChatDb, turn: {
157
+ threadId: ThreadId;
158
+ turnId: TurnId;
159
+ clientId: string;
160
+ agentId: string;
161
+ }) => Promise<Delegation>;
162
+ claim: (host: ChatHost, db: ChatDb) => Promise<ClaimedTurn | undefined>;
163
+ release: (host: ChatHost, thread: ThreadId, turn: TurnId) => Promise<boolean>;
164
+ welcomed: Set<HostId>;
165
+ };
166
+ export type HostSession = ReturnType<typeof hostSession>;
140
167
  /** What the user's computers call; `hostHello` first on every link. */
141
- export declare function hostChatActions(deps: ChatActionDeps): {
168
+ export declare function hostChatActions(deps: ChatActionDeps, session?: HostSession): {
142
169
  hostHello: import("@parlor/core").ActionDefinition<z.ZodObject<{
143
170
  protocols: z.ZodObject<{
144
171
  min: z.ZodNumber;
@@ -212,6 +239,7 @@ export declare function hostChatActions(deps: ChatActionDeps): {
212
239
  }, z.core.$strip>>;
213
240
  devices: z.ZodOptional<z.ZodArray<z.ZodString>>;
214
241
  presenceDue: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodNumber>>;
242
+ agentsChecked: z.ZodOptional<z.ZodLiteral<true>>;
215
243
  }, z.core.$strip>, {
216
244
  readonly id: string;
217
245
  readonly onlineUntil: number;
@@ -346,7 +374,7 @@ export declare function hostChatActions(deps: ChatActionDeps): {
346
374
  * The chat's actions at `/_parlor/chat/actions/<name>`: plugin actions, so never on MCP
347
375
  * and never callable by an agent. Writes return the thread or host id as `id`.
348
376
  */
349
- export declare function chatActions(deps: ChatActionDeps): import("@parlor/core/registry").ActionRegistry<{
377
+ export declare function chatActions(deps: ChatActionDeps, session?: HostSession): import("@parlor/core/registry").ActionRegistry<{
350
378
  open: import("@parlor/core").ActionDefinition<z.ZodObject<{
351
379
  threadId: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<import("@parlor/core").Id<"thread">, string>>>;
352
380
  limit: z.ZodDefault<z.ZodNumber>;
@@ -445,6 +473,9 @@ export declare function chatActions(deps: ChatActionDeps): import("@parlor/core/
445
473
  userActive: import("@parlor/core").ActionDefinition<z.ZodObject<{}, z.core.$strip>, {
446
474
  readonly ok: true;
447
475
  }>;
476
+ checkAgents: import("@parlor/core").ActionDefinition<z.ZodObject<{}, z.core.$strip>, {
477
+ readonly askedAt: number;
478
+ }>;
448
479
  hostHello: import("@parlor/core").ActionDefinition<z.ZodObject<{
449
480
  protocols: z.ZodObject<{
450
481
  min: z.ZodNumber;
@@ -518,6 +549,7 @@ export declare function chatActions(deps: ChatActionDeps): import("@parlor/core/
518
549
  }, z.core.$strip>>;
519
550
  devices: z.ZodOptional<z.ZodArray<z.ZodString>>;
520
551
  presenceDue: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodNumber>>;
552
+ agentsChecked: z.ZodOptional<z.ZodLiteral<true>>;
521
553
  }, z.core.$strip>, {
522
554
  readonly id: string;
523
555
  readonly onlineUntil: number;
@@ -1 +1 @@
1
- {"version":3,"file":"actions.d.ts","sourceRoot":"","sources":["../../src/server/actions.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,aAAa,EAElB,KAAK,MAAM,EACX,KAAK,QAAQ,EAEd,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,KAAK,SAAS,EAAkB,MAAM,uBAAuB,CAAC;AACvE,OAAO,EAAE,KAAK,YAAY,EAAE,KAAK,UAAU,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACrF,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,QAAQ,EAAE,MAAM,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AAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qBAgDhD,MAAM;8BAAwB,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qBAiF/C,MAAM;6BACE,MAAM;wBACX,WAAW,CAAC,OAAO,CAAC;;;;;;;;;;;;;;;;;;;;;qBAgCgB,MAAM;;GA6BjE;AAED,MAAM,MAAM,kBAAkB,GAAG,UAAU,CAAC,OAAO,WAAW,CAAC,CAAC;AAChE,MAAM,MAAM,aAAa,GAAG,SAAS,CAAC,kBAAkB,CAAC,CAAC;AAC1D,MAAM,MAAM,iBAAiB,GAAG,UAAU,CAAC,OAAO,eAAe,CAAC,CAAC;AACnE,MAAM,MAAM,iBAAiB,GAAG,UAAU,CAAC,OAAO,eAAe,CAAC,CAAC"}
@@ -4,8 +4,8 @@ import { HOST_GRANTS_TAG } from "@parlor/server";
4
4
  import { z } from "zod";
5
5
  import { idSchema } from "../id-schemas.js";
6
6
  import { chatItemBodies, hostItemDraft } from "../items.js";
7
- import { HOST_PROTOCOL } from "../protocol.js";
8
- import { CHAT_ACTIVITY_TAG, CHAT_TAG, HOSTS_TAG } from "../tags.js";
7
+ import { HOST_PROTOCOL, PUSHED_TURNS_PROTOCOL } from "../protocol.js";
8
+ import { CHAT_ACTIVITY_TAG, CHAT_AGENTS_CHECK_TAG, CHAT_TAG, HOSTS_TAG, } from "../tags.js";
9
9
  import { turnContext } from "./context.js";
10
10
  import { chatAction } from "./party.js";
11
11
  import { agentInfoSchema, TURN_FAILURES } from "./rows.js";
@@ -130,7 +130,7 @@ export function userChatActions(deps) {
130
130
  const host = hosts.find((candidate) => candidate.id === input.prompt.agent.hostId);
131
131
  if (!host)
132
132
  throw new ActionError("not_found", "Computer not found");
133
- return deps.transact(user, async (tx) => {
133
+ const sent = await deps.transact(user, async (tx) => {
134
134
  await deps.store.appendUserItems(tx, user, {
135
135
  threadId: input.threadId,
136
136
  turnId: input.turnId,
@@ -148,6 +148,9 @@ export function userChatActions(deps) {
148
148
  threadId: input.threadId,
149
149
  };
150
150
  });
151
+ if (host.protocol >= PUSHED_TURNS_PROTOCOL)
152
+ deps.pushed?.offer(user, host.id);
153
+ return sent;
151
154
  },
152
155
  }),
153
156
  answer: chatAction("user", enforcing, {
@@ -190,11 +193,19 @@ export function userChatActions(deps) {
190
193
  writes: [CHAT_ACTIVITY_TAG],
191
194
  run: () => ({ ok: true }),
192
195
  }),
196
+ checkAgents: chatAction("user", enforcing, {
197
+ description: "Ask the user's computers to look again for the coding agents installed on them; each reports what it found, stamped `agentsCheckedAt`. Answers when it asked, by the same clock.",
198
+ input: z.object({}),
199
+ writes: [CHAT_AGENTS_CHECK_TAG],
200
+ run: () => ({ askedAt: Date.now() }),
201
+ }),
193
202
  };
194
203
  }
195
- /** What the user's computers call; `hostHello` first on every link. */
196
- export function hostChatActions(deps) {
197
- const { enforcing } = deps;
204
+ /**
205
+ * What the server keeps about the computers it serves: which said hello, their agents'
206
+ * names, and how a turn is claimed for one, by `hostClaim` or pushed to it.
207
+ */
208
+ export function hostSession(deps) {
198
209
  const welcomed = new Set();
199
210
  const welcome = async (host, db) => {
200
211
  const hosts = await deps.store.listHosts(db, host);
@@ -236,6 +247,64 @@ export function hostChatActions(deps) {
236
247
  ttlMs: deps.leaseMs,
237
248
  });
238
249
  };
250
+ /** The next turn waiting for `host`, claimed for it with its token and context; undefined when none waits. */
251
+ const claim = async (host, db) => {
252
+ await requireWelcome(host, db);
253
+ await deps.reconcile(host);
254
+ const claimed = await deps.transact(host, async (tx) => {
255
+ const taken = await deps.store.claimTurn(tx, host, host.host, deps.leaseMs);
256
+ return { result: taken, threadId: taken?.id };
257
+ });
258
+ if (!claimed)
259
+ return undefined;
260
+ try {
261
+ const deviceId = claimed.prompt.body.signed?.deviceId;
262
+ const [token, device, account, page] = await Promise.all([
263
+ mint(host, db, {
264
+ threadId: claimed.id,
265
+ turnId: claimed.turnId,
266
+ clientId: claimed.clientId,
267
+ agentId: claimed.agent.agentId,
268
+ }),
269
+ deviceId ? deps.auth.device?.(host.userId, deviceId) : undefined,
270
+ deps.auth.account?.(host.userId),
271
+ deps.store.readPage(db, host, claimed.id, CONTEXT_HISTORY_ITEMS),
272
+ ]);
273
+ const context = turnContext({
274
+ appName: deps.appName,
275
+ appOrigin: deps.appOrigin(),
276
+ account,
277
+ device,
278
+ instructions: deps.instructions,
279
+ history: page.items.filter((item) => item.seq < claimed.prompt.seq),
280
+ });
281
+ return { ...claimed, device, context, token };
282
+ }
283
+ catch (error) {
284
+ await release(host, claimed.id, claimed.turnId).catch(() => false);
285
+ throw error;
286
+ }
287
+ };
288
+ /** Puts a claimed turn back in the queue, waking the computer to claim it again. */
289
+ const release = (host, thread, turn) => deps.transact(host, async (tx) => {
290
+ const released = await deps.store.releaseClaim(tx, host, host.host, turn);
291
+ return { result: released, threadId: thread };
292
+ });
293
+ return {
294
+ welcome,
295
+ requireWelcome,
296
+ learnAgents,
297
+ agentNameOf,
298
+ mint,
299
+ claim,
300
+ release,
301
+ welcomed,
302
+ };
303
+ }
304
+ /** What the user's computers call; `hostHello` first on every link. */
305
+ export function hostChatActions(deps, session = hostSession(deps)) {
306
+ const { enforcing } = deps;
307
+ const { welcome, requireWelcome, learnAgents, mint, welcomed } = session;
239
308
  return {
240
309
  hostHello: chatAction("host", enforcing, {
241
310
  description: "A link's first call: agree on the host protocol and report this computer online with its agents.",
@@ -288,12 +357,13 @@ export function hostChatActions(deps) {
288
357
  },
289
358
  }),
290
359
  hostReport: chatAction("host", enforcing, {
291
- description: "This computer went offline or changed its agents.",
360
+ description: "This computer went offline, changed its agents, or looked for them again (`agentsChecked`).",
292
361
  input: z.object({
293
362
  online: z.boolean(),
294
363
  agents: z.array(agentInfoSchema).max(32),
295
364
  devices: z.array(z.string().min(1).max(64)).max(256).optional(),
296
365
  presenceDue: presenceDueSchema.optional(),
366
+ agentsChecked: z.literal(true).optional(),
297
367
  }),
298
368
  writes: [HOSTS_TAG],
299
369
  run: async (input, host, ctx) => {
@@ -306,6 +376,7 @@ export function hostChatActions(deps) {
306
376
  agents: input.agents,
307
377
  devices: input.devices,
308
378
  presenceDue: input.presenceDue,
379
+ agentsCheckedAt: input.agentsChecked ? Date.now() : undefined,
309
380
  online: input.online,
310
381
  ttlMs: 2 * deps.heartbeatMs,
311
382
  });
@@ -328,53 +399,18 @@ export function hostChatActions(deps) {
328
399
  description: "Take the next turn addressed to this computer with its turn token; not_found when none waits.",
329
400
  input: z.object({}),
330
401
  run: async (_input, host, ctx) => {
331
- const db = dbOf(ctx);
332
- await requireWelcome(host, db);
333
- await deps.reconcile(host);
334
- const claimed = await deps.transact(host, async (tx) => {
335
- const taken = await deps.store.claimTurn(tx, host, host.host, deps.leaseMs);
336
- if (!taken)
337
- throw new ActionError("not_found", "No turn is waiting.");
338
- return { result: taken, threadId: taken.id };
339
- });
340
- try {
341
- const token = await mint(host, db, {
342
- threadId: claimed.id,
343
- turnId: claimed.turnId,
344
- clientId: claimed.clientId,
345
- agentId: claimed.agent.agentId,
346
- });
347
- const deviceId = claimed.prompt.body.signed?.deviceId;
348
- const [device, account, page] = await Promise.all([
349
- deviceId ? deps.auth.device?.(host.userId, deviceId) : undefined,
350
- deps.auth.account?.(host.userId),
351
- deps.store.readPage(db, host, claimed.id, CONTEXT_HISTORY_ITEMS),
352
- ]);
353
- const context = turnContext({
354
- appName: deps.appName,
355
- appOrigin: deps.appOrigin(ctx),
356
- account,
357
- device,
358
- instructions: deps.instructions,
359
- history: page.items.filter((item) => item.seq < claimed.prompt.seq),
360
- });
361
- return { ...claimed, device, context, token };
362
- }
363
- catch (error) {
364
- await deps
365
- .transact(host, async (tx) => {
366
- const released = await deps.store.releaseClaim(tx, host, host.host, claimed.turnId);
367
- return { result: released, threadId: claimed.id };
368
- })
369
- .catch(() => false);
370
- throw error;
371
- }
402
+ const claimed = await session.claim(host, dbOf(ctx));
403
+ if (!claimed)
404
+ throw new ActionError("not_found", "No turn is waiting.");
405
+ return claimed;
372
406
  },
373
407
  }),
374
408
  hostSignals: chatAction("host", enforcing, {
375
409
  description: "Answers and stop requests for the turns this computer runs.",
376
410
  input: z.object({ turns: z.array(z.object({ turnId, afterSeq })).max(16) }),
377
411
  run: async (input, host, ctx) => {
412
+ for (const turn of input.turns)
413
+ deps.pushed?.confirm(turn.turnId);
378
414
  const db = dbOf(ctx);
379
415
  await requireWelcome(host, db);
380
416
  const signals = await deps.store.readSignals(db, host, host.host, input.turns);
@@ -391,6 +427,7 @@ export function hostChatActions(deps) {
391
427
  description: "Append finished items of a running turn and extend its lease; no items only renews it.",
392
428
  input: z.object({ turnId, items: z.array(hostItemDraft).max(64) }),
393
429
  run: async (input, host, ctx) => {
430
+ deps.pushed?.confirm(input.turnId);
394
431
  await requireWelcome(host, dbOf(ctx));
395
432
  const appended = await deps.transact(host, async (tx) => {
396
433
  const result = await deps.store.appendHostItems(tx, host, host.host, input.turnId, input.items, deps.leaseMs);
@@ -414,6 +451,7 @@ export function hostChatActions(deps) {
414
451
  ]),
415
452
  }),
416
453
  run: async (input, host, ctx) => {
454
+ deps.pushed?.confirm(input.turnId);
417
455
  await requireWelcome(host, dbOf(ctx));
418
456
  const finished = await deps.transact(host, async (tx) => {
419
457
  const result = await deps.store.finishTurn(tx, host, host.host, input.turnId, input.outcome);
@@ -429,7 +467,7 @@ export function hostChatActions(deps) {
429
467
  * The chat's actions at `/_parlor/chat/actions/<name>`: plugin actions, so never on MCP
430
468
  * and never callable by an agent. Writes return the thread or host id as `id`.
431
469
  */
432
- export function chatActions(deps) {
433
- return createRegistry({ ...userChatActions(deps), ...hostChatActions(deps) });
470
+ export function chatActions(deps, session = hostSession(deps)) {
471
+ return createRegistry({ ...userChatActions(deps), ...hostChatActions(deps, session) });
434
472
  }
435
473
  //# sourceMappingURL=actions.js.map