@otto-code/protocol 0.7.4 → 0.7.6

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.
@@ -2,6 +2,7 @@ export type AgentAttentionReason = "finished" | "error" | "permission";
2
2
  export interface AgentAttentionNotificationData {
3
3
  [key: string]: unknown;
4
4
  serverId: string;
5
+ workspaceId?: string;
5
6
  agentId: string;
6
7
  reason: AgentAttentionReason;
7
8
  }
@@ -13,6 +14,7 @@ export interface AgentAttentionNotificationPayload {
13
14
  interface BuildAgentAttentionNotificationPayloadInput {
14
15
  reason: AgentAttentionReason;
15
16
  serverId: string;
17
+ workspaceId: string;
16
18
  agentId: string;
17
19
  assistantMessage?: string | null;
18
20
  permissionRequest?: NotificationPermissionRequest | null;
@@ -180,6 +180,7 @@ export function buildAgentAttentionNotificationPayload(input) {
180
180
  body,
181
181
  data: {
182
182
  serverId: input.serverId,
183
+ workspaceId: input.workspaceId,
183
184
  agentId: input.agentId,
184
185
  reason: input.reason,
185
186
  },
@@ -0,0 +1,8 @@
1
+ export interface AgentDeepLinkTarget {
2
+ serverId: string;
3
+ agentId: string;
4
+ }
5
+ export declare function buildAgentDeepLinkRoute(target: AgentDeepLinkTarget): `/h/${string}/agent/${string}`;
6
+ export declare function buildAgentDeepLink(target: AgentDeepLinkTarget): string;
7
+ export declare function parseAgentDeepLink(input: string): AgentDeepLinkTarget | null;
8
+ //# sourceMappingURL=agent-deep-link.d.ts.map
@@ -0,0 +1,49 @@
1
+ function normalizeSegment(value) {
2
+ return value.trim();
3
+ }
4
+ function normalizeAgentDeepLinkTarget(target) {
5
+ const serverId = normalizeSegment(target.serverId);
6
+ const agentId = normalizeSegment(target.agentId);
7
+ if (!serverId || !agentId) {
8
+ throw new Error("Agent deep links require a server ID and agent ID.");
9
+ }
10
+ return { serverId, agentId };
11
+ }
12
+ export function buildAgentDeepLinkRoute(target) {
13
+ const { serverId, agentId } = normalizeAgentDeepLinkTarget(target);
14
+ return `/h/${encodeURIComponent(serverId)}/agent/${encodeURIComponent(agentId)}`;
15
+ }
16
+ export function buildAgentDeepLink(target) {
17
+ return `otto:/${buildAgentDeepLinkRoute(target)}`;
18
+ }
19
+ export function parseAgentDeepLink(input) {
20
+ let url;
21
+ try {
22
+ url = new URL(input);
23
+ }
24
+ catch {
25
+ return null;
26
+ }
27
+ if (url.protocol !== "otto:" ||
28
+ url.hostname !== "h" ||
29
+ url.username ||
30
+ url.password ||
31
+ url.port ||
32
+ url.search ||
33
+ url.hash) {
34
+ return null;
35
+ }
36
+ const segments = url.pathname.split("/").filter(Boolean);
37
+ if (segments.length !== 3 || segments[1] !== "agent") {
38
+ return null;
39
+ }
40
+ try {
41
+ const serverId = normalizeSegment(decodeURIComponent(segments[0] ?? ""));
42
+ const agentId = normalizeSegment(decodeURIComponent(segments[2] ?? ""));
43
+ return serverId && agentId ? { serverId, agentId } : null;
44
+ }
45
+ catch {
46
+ return null;
47
+ }
48
+ }
49
+ //# sourceMappingURL=agent-deep-link.js.map
@@ -110,6 +110,7 @@ export interface ProviderSnapshotEntry {
110
110
  provider: AgentProvider;
111
111
  status: ProviderStatus;
112
112
  enabled: boolean;
113
+ source?: "builtin" | "custom";
113
114
  error?: string;
114
115
  models?: AgentModelDefinition[];
115
116
  modes?: AgentMode[];
@@ -373,6 +374,7 @@ export type AgentTimelineItem = {
373
374
  type: "user_message";
374
375
  text: string;
375
376
  messageId?: string;
377
+ clientMessageId?: string;
376
378
  } | {
377
379
  type: "assistant_message";
378
380
  text: string;
@@ -489,6 +491,18 @@ export interface ObservedSubagentUpdate {
489
491
  status: "initializing" | "running" | "idle" | "error" | "closed";
490
492
  requiresAttention?: boolean;
491
493
  usage?: AgentUsage;
494
+ /**
495
+ * True once this run is known to outlive an interrupt of the parent's turn —
496
+ * the provider backgrounded it, so the parent's teardown does not take it
497
+ * down. Sticky: the daemon keeps it set for the row's whole life, and
498
+ * propagates it to nested rows (a child of a backgrounded run survives too).
499
+ * Absent ⇒ foreground, i.e. the run dies with the turn that spawned it.
500
+ *
501
+ * Claude sets it for Workflow orchestration runs (always backgrounded) and
502
+ * for a Task/Agent whose tool_result turned out to be a launch ack rather
503
+ * than a final report. See docs/chat-lifecycle.md.
504
+ */
505
+ backgrounded?: boolean;
492
506
  /**
493
507
  * Tool invocations this subagent has made so far (cumulative). Neutral field
494
508
  * any provider can set; kept monotonic by the daemon so a status-only final
@@ -13,6 +13,7 @@ export declare const FileBeginMetadataSchema: z.ZodObject<{
13
13
  "utf-8": "utf-8";
14
14
  }>;
15
15
  modifiedAt: z.ZodString;
16
+ revision: z.ZodOptional<z.ZodString>;
16
17
  fileName: z.ZodOptional<z.ZodString>;
17
18
  }, z.core.$strip>;
18
19
  export interface FileBegin {
@@ -10,6 +10,7 @@ export const FileBeginMetadataSchema = z.object({
10
10
  size: z.number().int().nonnegative(),
11
11
  encoding: z.enum(["utf-8", "binary"]),
12
12
  modifiedAt: z.string(),
13
+ revision: z.string().optional(),
13
14
  fileName: z.string().optional(),
14
15
  });
15
16
  export function encodeFileTransferFrame(input) {
@@ -489,6 +489,11 @@ export declare const BrowserAutomationTabInfoSchema: z.ZodObject<{
489
489
  isLoading: z.ZodDefault<z.ZodBoolean>;
490
490
  canGoBack: z.ZodOptional<z.ZodBoolean>;
491
491
  canGoForward: z.ZodOptional<z.ZodBoolean>;
492
+ status: z.ZodOptional<z.ZodEnum<{
493
+ ready: "ready";
494
+ starting: "starting";
495
+ detached: "detached";
496
+ }>>;
492
497
  }, z.core.$strip>;
493
498
  export declare const BrowserAutomationListTabsResultSchema: z.ZodObject<{
494
499
  command: z.ZodLiteral<"list_tabs">;
@@ -501,6 +506,11 @@ export declare const BrowserAutomationListTabsResultSchema: z.ZodObject<{
501
506
  isLoading: z.ZodDefault<z.ZodBoolean>;
502
507
  canGoBack: z.ZodOptional<z.ZodBoolean>;
503
508
  canGoForward: z.ZodOptional<z.ZodBoolean>;
509
+ status: z.ZodOptional<z.ZodEnum<{
510
+ ready: "ready";
511
+ starting: "starting";
512
+ detached: "detached";
513
+ }>>;
504
514
  }, z.core.$strip>>;
505
515
  }, z.core.$strip>;
506
516
  export declare const BrowserAutomationNewTabResultSchema: z.ZodObject<{
@@ -783,6 +793,11 @@ export declare const BrowserAutomationResultSchema: z.ZodDiscriminatedUnion<[z.Z
783
793
  isLoading: z.ZodDefault<z.ZodBoolean>;
784
794
  canGoBack: z.ZodOptional<z.ZodBoolean>;
785
795
  canGoForward: z.ZodOptional<z.ZodBoolean>;
796
+ status: z.ZodOptional<z.ZodEnum<{
797
+ ready: "ready";
798
+ starting: "starting";
799
+ detached: "detached";
800
+ }>>;
786
801
  }, z.core.$strip>>;
787
802
  }, z.core.$strip>, z.ZodObject<{
788
803
  command: z.ZodLiteral<"new_tab">;
@@ -1250,6 +1265,11 @@ export declare const BrowserAutomationExecuteResponseSchema: z.ZodObject<{
1250
1265
  isLoading: z.ZodDefault<z.ZodBoolean>;
1251
1266
  canGoBack: z.ZodOptional<z.ZodBoolean>;
1252
1267
  canGoForward: z.ZodOptional<z.ZodBoolean>;
1268
+ status: z.ZodOptional<z.ZodEnum<{
1269
+ ready: "ready";
1270
+ starting: "starting";
1271
+ detached: "detached";
1272
+ }>>;
1253
1273
  }, z.core.$strip>>;
1254
1274
  }, z.core.$strip>, z.ZodObject<{
1255
1275
  command: z.ZodLiteral<"new_tab">;
@@ -1518,6 +1538,7 @@ export type BrowserAutomationColorScheme = z.infer<typeof BrowserAutomationColor
1518
1538
  export type BrowserAutomationCommandName = z.infer<typeof BrowserAutomationCommandNameSchema>;
1519
1539
  export type BrowserAutomationCommand = z.infer<typeof BrowserAutomationCommandSchema>;
1520
1540
  export type BrowserAutomationResult = z.infer<typeof BrowserAutomationResultSchema>;
1541
+ export type BrowserAutomationTabInfo = z.infer<typeof BrowserAutomationTabInfoSchema>;
1521
1542
  export type BrowserAutomationConsoleLogEntry = z.infer<typeof BrowserAutomationConsoleLogEntrySchema>;
1522
1543
  export type BrowserAutomationNetworkLogEntry = z.infer<typeof BrowserAutomationNetworkLogEntrySchema>;
1523
1544
  export type BrowserAutomationNetworkRequestEntry = z.infer<typeof BrowserAutomationNetworkRequestEntrySchema>;
@@ -306,6 +306,16 @@ export const BrowserAutomationTabInfoSchema = z.object({
306
306
  isLoading: z.boolean().default(false),
307
307
  canGoBack: z.boolean().optional(),
308
308
  canGoForward: z.boolean().optional(),
309
+ // Whether the tab's webview is attached and drivable. Reported explicitly so
310
+ // that "not drivable" is never expressed by leaving the tab OUT of the list:
311
+ // a tab the user can see on screen must always appear, or callers conclude it
312
+ // was closed and open a replacement. `starting` = registered, webview not
313
+ // attached yet; `detached` = it was attached and its contents are gone (a
314
+ // pane that stopped compositing looks like this). `url`/`title` are empty for
315
+ // both, because only the live webview knows them.
316
+ // COMPAT(browserTabStatus): added in v0.7.5; absent ⇒ "ready", which is how
317
+ // every pre-0.7.5 host behaved. Drop the gate when floor >= v0.7.5.
318
+ status: z.enum(["starting", "ready", "detached"]).optional(),
309
319
  });
310
320
  export const BrowserAutomationListTabsResultSchema = z.object({
311
321
  command: z.literal("list_tabs"),
@@ -1,7 +1,10 @@
1
1
  export declare const CLIENT_CAPS: {
2
+ readonly selectiveAgentTimeline: "selective_agent_timeline";
2
3
  readonly reasoningMergeEnum: "reasoning_merge_enum";
3
4
  readonly customModeIcons: "custom_mode_icons";
4
5
  readonly terminalReflowableSnapshot: "terminal_reflowable_snapshot";
6
+ readonly providerSubagents: "provider_subagents";
7
+ readonly projectUpdates: "project_updates";
5
8
  readonly browserHost: "browser_host";
6
9
  };
7
10
  export type ClientCapability = (typeof CLIENT_CAPS)[keyof typeof CLIENT_CAPS];
@@ -1,4 +1,8 @@
1
1
  export const CLIENT_CAPS = {
2
+ // COMPAT(selectiveAgentTimeline): added in v0.1.106. Capable clients receive
3
+ // agent streams only for their explicit viewed set. Remove after 2027-01-12
4
+ // once the supported client floor is >= v0.1.106.
5
+ selectiveAgentTimeline: "selective_agent_timeline",
2
6
  reasoningMergeEnum: "reasoning_merge_enum",
3
7
  // COMPAT(customModeIcons): added in v0.1.84. Old clients pin AgentModeIcon to
4
8
  // a closed enum and crash rendering unknown values; daemon downgrades icons
@@ -11,6 +15,11 @@ export const CLIENT_CAPS = {
11
15
  // Old clients use a strict TerminalState schema and would reject the extra fields.
12
16
  // Drop the gate (always send the flags) when floor >= v0.1.88.
13
17
  terminalReflowableSnapshot: "terminal_reflowable_snapshot",
18
+ // COMPAT(providerSubagents): added in v0.1.107. The daemon emits provider-owned
19
+ // child descriptors and timelines only to clients that understand the new messages.
20
+ providerSubagents: "provider_subagents",
21
+ // COMPAT(projectUpdates): added in v0.1.109, remove gate after 2027-01-15.
22
+ projectUpdates: "project_updates",
14
23
  browserHost: "browser_host",
15
24
  };
16
25
  //# sourceMappingURL=client-capabilities.js.map
@@ -0,0 +1,66 @@
1
+ /**
2
+ * Declarative manifest of the git forges Otto knows how to present, mirroring
3
+ * provider-manifest.ts. Pure build-time data shared by BOTH the client (icon,
4
+ * brand label, PR↔MR relabel) and the server (registry host-matching, prompt
5
+ * branding). It is NEVER serialized over the wire, so adding a forge here is not
6
+ * a protocol change.
7
+ *
8
+ * Keep this a pure leaf: no imports, no zod, no functions with runtime deps.
9
+ * Behavioural concerns (CLI invocation, host probing, REST adapters) live in the
10
+ * server adapter keyed by {@link ForgeDefinition.id}; this file is only the
11
+ * declarative half.
12
+ */
13
+ /**
14
+ * Declarative sign-in recipe for a forge. The client renders install/sign-in
15
+ * hints from this data alone — no per-CLI switch — so a new forge wires its auth
16
+ * UX entirely from the manifest. Behavioural auth (the actual host probe) stays
17
+ * in the server adapter; this is only what the user is told to run.
18
+ */
19
+ export interface ForgeSignInCommand {
20
+ /** Binary the user installs, e.g. "gh" — shown in the install-CLI hint. */
21
+ cli: string;
22
+ /** Full sign-in command, e.g. "gh auth login". */
23
+ command: string;
24
+ /**
25
+ * Flag that targets a self-hosted host, e.g. "--hostname". When present and a
26
+ * host is known, the client appends `${command} ${hostnameFlag} ${host}`.
27
+ * Omit when the command already targets the right host on its own.
28
+ */
29
+ hostnameFlag?: string;
30
+ }
31
+ export interface ForgeDefinition {
32
+ /** Registry id, matches the server adapter and the wire `forge` value. */
33
+ id: string;
34
+ /** Human brand name, e.g. for "Open on GitLab". */
35
+ displayName: string;
36
+ /** Short change-request noun: "PR" for GitHub, "MR" for GitLab. */
37
+ changeRequestAbbrev: string;
38
+ /** Full change-request noun: "pull request" vs "merge request". */
39
+ changeRequestNoun: string;
40
+ /** Prefix before a change-request number: "#" vs "!". */
41
+ changeRequestNumberPrefix: string;
42
+ /** Prefix before an issue number ("#" on every forge so far). */
43
+ issueNumberPrefix: string;
44
+ /** Icon key; the client falls back to a generic git icon for unknown values. */
45
+ iconKind: string;
46
+ /** Sign-in recipe, or null when the forge has no Otto-driven sign-in. */
47
+ signIn: ForgeSignInCommand | null;
48
+ /**
49
+ * Public cloud hosts this forge owns exactly. A BOUNDED list, never an
50
+ * allowlist for self-hosted detection — self-hosted/Enterprise instances are
51
+ * recognized at runtime by the adapter's host probe, not by this field.
52
+ */
53
+ cloudHosts?: string[];
54
+ }
55
+ export declare const FORGE_DEFINITIONS: ForgeDefinition[];
56
+ /** Forge definitions only present in dev builds (none today; mirrors providers). */
57
+ export declare const DEV_FORGE_DEFINITIONS: ForgeDefinition[];
58
+ export declare const FORGE_IDS: string[];
59
+ export declare function getForgeDefinition(id: string, definitions?: ForgeDefinition[]): ForgeDefinition | null;
60
+ /**
61
+ * Resolve a forge definition, synthesizing a neutral one for a forge id the
62
+ * client has never heard of (e.g. a self-hosted forge a newer daemon reports to
63
+ * an older client). The neutral shape renders generic, never GitHub-branded.
64
+ */
65
+ export declare function getForgeDefinitionOrNeutral(id: string): ForgeDefinition;
66
+ //# sourceMappingURL=forge-manifest.d.ts.map
@@ -0,0 +1,92 @@
1
+ /**
2
+ * Declarative manifest of the git forges Otto knows how to present, mirroring
3
+ * provider-manifest.ts. Pure build-time data shared by BOTH the client (icon,
4
+ * brand label, PR↔MR relabel) and the server (registry host-matching, prompt
5
+ * branding). It is NEVER serialized over the wire, so adding a forge here is not
6
+ * a protocol change.
7
+ *
8
+ * Keep this a pure leaf: no imports, no zod, no functions with runtime deps.
9
+ * Behavioural concerns (CLI invocation, host probing, REST adapters) live in the
10
+ * server adapter keyed by {@link ForgeDefinition.id}; this file is only the
11
+ * declarative half.
12
+ */
13
+ export const FORGE_DEFINITIONS = [
14
+ {
15
+ id: "github",
16
+ displayName: "GitHub",
17
+ changeRequestAbbrev: "PR",
18
+ changeRequestNoun: "pull request",
19
+ changeRequestNumberPrefix: "#",
20
+ issueNumberPrefix: "#",
21
+ iconKind: "github",
22
+ signIn: { cli: "gh", command: "gh auth login" },
23
+ cloudHosts: ["github.com", "ssh.github.com"],
24
+ },
25
+ {
26
+ id: "gitlab",
27
+ displayName: "GitLab",
28
+ changeRequestAbbrev: "MR",
29
+ changeRequestNoun: "merge request",
30
+ changeRequestNumberPrefix: "!",
31
+ issueNumberPrefix: "#",
32
+ iconKind: "gitlab",
33
+ signIn: { cli: "glab", command: "glab auth login", hostnameFlag: "--hostname" },
34
+ cloudHosts: ["gitlab.com"],
35
+ },
36
+ {
37
+ id: "gitea",
38
+ displayName: "Gitea",
39
+ changeRequestAbbrev: "PR",
40
+ changeRequestNoun: "pull request",
41
+ changeRequestNumberPrefix: "#",
42
+ issueNumberPrefix: "#",
43
+ iconKind: "gitea",
44
+ signIn: { cli: "tea", command: "tea login add" },
45
+ cloudHosts: ["gitea.com"],
46
+ },
47
+ {
48
+ id: "forgejo",
49
+ displayName: "Forgejo",
50
+ changeRequestAbbrev: "PR",
51
+ changeRequestNoun: "pull request",
52
+ changeRequestNumberPrefix: "#",
53
+ issueNumberPrefix: "#",
54
+ iconKind: "forgejo",
55
+ signIn: { cli: "tea", command: "tea login add" },
56
+ },
57
+ {
58
+ id: "codeberg",
59
+ displayName: "Codeberg",
60
+ changeRequestAbbrev: "PR",
61
+ changeRequestNoun: "pull request",
62
+ changeRequestNumberPrefix: "#",
63
+ issueNumberPrefix: "#",
64
+ iconKind: "codeberg",
65
+ signIn: { cli: "tea", command: "tea login add" },
66
+ cloudHosts: ["codeberg.org"],
67
+ },
68
+ ];
69
+ /** Forge definitions only present in dev builds (none today; mirrors providers). */
70
+ export const DEV_FORGE_DEFINITIONS = [];
71
+ export const FORGE_IDS = FORGE_DEFINITIONS.map((definition) => definition.id);
72
+ export function getForgeDefinition(id, definitions = [...FORGE_DEFINITIONS, ...DEV_FORGE_DEFINITIONS]) {
73
+ return definitions.find((definition) => definition.id === id) ?? null;
74
+ }
75
+ /**
76
+ * Resolve a forge definition, synthesizing a neutral one for a forge id the
77
+ * client has never heard of (e.g. a self-hosted forge a newer daemon reports to
78
+ * an older client). The neutral shape renders generic, never GitHub-branded.
79
+ */
80
+ export function getForgeDefinitionOrNeutral(id) {
81
+ return (getForgeDefinition(id) ?? {
82
+ id,
83
+ displayName: id,
84
+ changeRequestAbbrev: "PR",
85
+ changeRequestNoun: "pull request",
86
+ changeRequestNumberPrefix: "#",
87
+ issueNumberPrefix: "#",
88
+ iconKind: "git",
89
+ signIn: null,
90
+ });
91
+ }
92
+ //# sourceMappingURL=forge-manifest.js.map