@hyperdrive.bot/paseo-protocol 0.2.5

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.
Files changed (92) hide show
  1. package/README.md +12 -0
  2. package/dist/agent-attention-notification.d.ts +41 -0
  3. package/dist/agent-attention-notification.js +140 -0
  4. package/dist/agent-labels.d.ts +9 -0
  5. package/dist/agent-labels.js +23 -0
  6. package/dist/agent-lifecycle.d.ts +3 -0
  7. package/dist/agent-lifecycle.js +8 -0
  8. package/dist/agent-state-bucket.d.ts +24 -0
  9. package/dist/agent-state-bucket.js +45 -0
  10. package/dist/agent-title-limits.d.ts +2 -0
  11. package/dist/agent-title-limits.js +2 -0
  12. package/dist/agent-types.d.ts +461 -0
  13. package/dist/agent-types.js +22 -0
  14. package/dist/binary-frames/chunk-size.d.ts +2 -0
  15. package/dist/binary-frames/chunk-size.js +7 -0
  16. package/dist/binary-frames/demux.d.ts +11 -0
  17. package/dist/binary-frames/demux.js +23 -0
  18. package/dist/binary-frames/file-transfer.d.ts +50 -0
  19. package/dist/binary-frames/file-transfer.js +114 -0
  20. package/dist/binary-frames/index.d.ts +4 -0
  21. package/dist/binary-frames/index.js +4 -0
  22. package/dist/binary-frames/terminal.d.ts +31 -0
  23. package/dist/binary-frames/terminal.js +99 -0
  24. package/dist/branch-slug.d.ts +14 -0
  25. package/dist/branch-slug.js +49 -0
  26. package/dist/browser-automation/capabilities.d.ts +7 -0
  27. package/dist/browser-automation/capabilities.js +31 -0
  28. package/dist/browser-automation/rpc-schemas.d.ts +1112 -0
  29. package/dist/browser-automation/rpc-schemas.js +462 -0
  30. package/dist/chat/rpc-schemas.d.ts +158 -0
  31. package/dist/chat/rpc-schemas.js +103 -0
  32. package/dist/chat/types.d.ts +30 -0
  33. package/dist/chat/types.js +22 -0
  34. package/dist/client-capabilities.d.ts +8 -0
  35. package/dist/client-capabilities.js +16 -0
  36. package/dist/connection-offer.d.ts +36 -0
  37. package/dist/connection-offer.js +53 -0
  38. package/dist/daemon-endpoints.d.ts +47 -0
  39. package/dist/daemon-endpoints.js +201 -0
  40. package/dist/error-utils.d.ts +11 -0
  41. package/dist/error-utils.js +27 -0
  42. package/dist/generated/validation/ws-outbound.aot.d.ts +2 -0
  43. package/dist/generated/validation/ws-outbound.aot.js +46936 -0
  44. package/dist/git-remote.d.ts +16 -0
  45. package/dist/git-remote.js +72 -0
  46. package/dist/host-connection-schema.d.ts +11 -0
  47. package/dist/host-connection-schema.js +9 -0
  48. package/dist/literal-union.d.ts +2 -0
  49. package/dist/literal-union.js +2 -0
  50. package/dist/loop/rpc-schemas.d.ts +636 -0
  51. package/dist/loop/rpc-schemas.js +163 -0
  52. package/dist/messages.d.ts +36565 -0
  53. package/dist/messages.js +4703 -0
  54. package/dist/paseo-config-schema.d.ts +117 -0
  55. package/dist/paseo-config-schema.js +79 -0
  56. package/dist/path-utils.d.ts +2 -0
  57. package/dist/path-utils.js +16 -0
  58. package/dist/provider-config.d.ts +136 -0
  59. package/dist/provider-config.js +119 -0
  60. package/dist/provider-icon-names.d.ts +5 -0
  61. package/dist/provider-icon-names.js +52 -0
  62. package/dist/provider-manifest.d.ts +114 -0
  63. package/dist/provider-manifest.js +344 -0
  64. package/dist/schedule/cron-expression.d.ts +13 -0
  65. package/dist/schedule/cron-expression.js +97 -0
  66. package/dist/schedule/rpc-schemas.d.ts +574 -0
  67. package/dist/schedule/rpc-schemas.js +151 -0
  68. package/dist/schedule/types.d.ts +202 -0
  69. package/dist/schedule/types.js +75 -0
  70. package/dist/terminal-activity.d.ts +21 -0
  71. package/dist/terminal-activity.js +25 -0
  72. package/dist/terminal-input-mode.d.ts +26 -0
  73. package/dist/terminal-input-mode.js +151 -0
  74. package/dist/terminal-key-input.d.ts +13 -0
  75. package/dist/terminal-key-input.js +201 -0
  76. package/dist/terminal-profiles.d.ts +6 -0
  77. package/dist/terminal-profiles.js +28 -0
  78. package/dist/terminal-snapshot.d.ts +3 -0
  79. package/dist/terminal-snapshot.js +178 -0
  80. package/dist/terminal-stream-protocol.d.ts +2 -0
  81. package/dist/terminal-stream-protocol.js +2 -0
  82. package/dist/terminal-subscription-key.d.ts +2 -0
  83. package/dist/terminal-subscription-key.js +9 -0
  84. package/dist/tool-call-display.d.ts +11 -0
  85. package/dist/tool-call-display.js +135 -0
  86. package/dist/tool-name-normalization.d.ts +9 -0
  87. package/dist/tool-name-normalization.js +82 -0
  88. package/dist/validation/ws-outbound-schema-metadata.d.ts +6828 -0
  89. package/dist/validation/ws-outbound-schema-metadata.js +3 -0
  90. package/dist/validation/ws-outbound.d.ts +12 -0
  91. package/dist/validation/ws-outbound.js +8 -0
  92. package/package.json +42 -0
package/README.md ADDED
@@ -0,0 +1,12 @@
1
+ # @hyperdrive.bot/paseo-protocol
2
+
3
+ Shared Paseo protocol schemas, codecs, and wire types.
4
+
5
+ ## Stability
6
+
7
+ This package is public so Paseo's published packages can depend on it cleanly.
8
+ It is not a stable public API yet.
9
+
10
+ Schemas, exports, wire helpers, and types may change or disappear in any release
11
+ without advance notice. Use it outside Paseo at your own risk until the package
12
+ is explicitly documented as stable.
@@ -0,0 +1,41 @@
1
+ export type AgentAttentionReason = "finished" | "error" | "permission";
2
+ export interface AgentAttentionNotificationData {
3
+ [key: string]: unknown;
4
+ serverId: string;
5
+ agentId: string;
6
+ reason: AgentAttentionReason;
7
+ }
8
+ export interface AgentAttentionNotificationPayload {
9
+ title: string;
10
+ body: string;
11
+ data: AgentAttentionNotificationData;
12
+ }
13
+ interface BuildAgentAttentionNotificationPayloadInput {
14
+ reason: AgentAttentionReason;
15
+ serverId: string;
16
+ agentId: string;
17
+ assistantMessage?: string | null;
18
+ permissionRequest?: NotificationPermissionRequest | null;
19
+ }
20
+ export interface NotificationPermissionRequest {
21
+ id: string;
22
+ provider: string;
23
+ name: string;
24
+ kind: "tool" | "plan" | "question" | "mode" | "other";
25
+ title?: string;
26
+ description?: string;
27
+ input?: Record<string, unknown>;
28
+ metadata?: Record<string, unknown>;
29
+ }
30
+ export type AssistantTimelineItem = {
31
+ type: "assistant_message";
32
+ text: string;
33
+ } | {
34
+ type: string;
35
+ text?: string;
36
+ };
37
+ export declare function findLatestAssistantMessageFromTimeline(timeline: readonly AssistantTimelineItem[]): string | null;
38
+ export declare function findLatestPermissionRequest(pendingPermissions: ReadonlyMap<string, NotificationPermissionRequest>): NotificationPermissionRequest | null;
39
+ export declare function buildAgentAttentionNotificationPayload(input: BuildAgentAttentionNotificationPayloadInput): AgentAttentionNotificationPayload;
40
+ export {};
41
+ //# sourceMappingURL=agent-attention-notification.d.ts.map
@@ -0,0 +1,140 @@
1
+ const NOTIFICATION_PREVIEW_LIMIT = 220;
2
+ const normalizeNotificationText = (text) => text.replace(/\s+/g, " ").trim();
3
+ const truncateNotificationText = (text, limit) => {
4
+ if (text.length <= limit) {
5
+ return text;
6
+ }
7
+ const trimmed = text.slice(0, Math.max(0, limit - 3)).trimEnd();
8
+ return trimmed.length > 0 ? `${trimmed}...` : text.slice(0, limit);
9
+ };
10
+ const stripMarkdownToText = (markdown) => {
11
+ let text = markdown.replace(/\r\n/g, "\n");
12
+ // Strip fenced code markers but keep the code content itself.
13
+ text = text.replace(/^\s*```[^\n]*$/gm, "");
14
+ text = text.replace(/^\s*~~~[^\n]*$/gm, "");
15
+ // Markdown links/images.
16
+ text = text.replace(/!\[([^\]]*)\]\((?:[^()\\]|\\.)*\)/g, "$1");
17
+ text = text.replace(/\[([^\]]+)\]\((?:[^()\\]|\\.)*\)/g, "$1");
18
+ // Structural prefixes.
19
+ text = text.replace(/^\s{0,3}#{1,6}\s+/gm, "");
20
+ text = text.replace(/^\s{0,3}>+\s?/gm, "");
21
+ text = text.replace(/^\s{0,3}(?:[*+-]|\d+\.)\s+/gm, "");
22
+ text = text.replace(/^\s{0,3}(?:[-*_]\s*){3,}$/gm, "");
23
+ // Inline markdown markers.
24
+ text = text.replace(/`([^`]+)`/g, "$1");
25
+ text = text.replace(/\*\*([^*]+)\*\*/g, "$1");
26
+ text = text.replace(/__([^_]+)__/g, "$1");
27
+ text = text.replace(/\*([^*\n]+)\*/g, "$1");
28
+ text = text.replace(/_([^_\n]+)_/g, "$1");
29
+ text = text.replace(/~~([^~]+)~~/g, "$1");
30
+ // Angle-bracketed URL autolinks.
31
+ text = text.replace(/<([^>\n]+)>/g, "$1");
32
+ return text;
33
+ };
34
+ const buildNotificationPreview = (text) => {
35
+ if (!text) {
36
+ return null;
37
+ }
38
+ const normalized = normalizeNotificationText(stripMarkdownToText(text));
39
+ if (!normalized) {
40
+ return null;
41
+ }
42
+ return truncateNotificationText(normalized, NOTIFICATION_PREVIEW_LIMIT);
43
+ };
44
+ const safeStringify = (value) => {
45
+ try {
46
+ return JSON.stringify(value);
47
+ }
48
+ catch {
49
+ return null;
50
+ }
51
+ };
52
+ const buildPermissionDetails = (request) => {
53
+ if (!request) {
54
+ return null;
55
+ }
56
+ const title = request.title?.trim();
57
+ const description = request.description?.trim();
58
+ const details = [];
59
+ if (title) {
60
+ details.push(title);
61
+ }
62
+ if (description && description !== title) {
63
+ details.push(description);
64
+ }
65
+ if (details.length > 0) {
66
+ return details.join(" - ");
67
+ }
68
+ const inputPreview = request.input ? safeStringify(request.input) : null;
69
+ if (inputPreview) {
70
+ return inputPreview;
71
+ }
72
+ const metadataPreview = request.metadata ? safeStringify(request.metadata) : null;
73
+ if (metadataPreview) {
74
+ return metadataPreview;
75
+ }
76
+ return request.name?.trim() || request.kind;
77
+ };
78
+ export function findLatestAssistantMessageFromTimeline(timeline) {
79
+ // Providers may stream assistant content in consecutive chunks.
80
+ const chunks = [];
81
+ for (let i = timeline.length - 1; i >= 0; i -= 1) {
82
+ const item = timeline[i];
83
+ if (item.type !== "assistant_message" || typeof item.text !== "string") {
84
+ if (chunks.length > 0) {
85
+ break;
86
+ }
87
+ continue;
88
+ }
89
+ chunks.push(item.text);
90
+ }
91
+ if (chunks.length === 0) {
92
+ return null;
93
+ }
94
+ return chunks.toReversed().join("");
95
+ }
96
+ export function findLatestPermissionRequest(pendingPermissions) {
97
+ let latest = null;
98
+ for (const request of pendingPermissions.values()) {
99
+ latest = request;
100
+ }
101
+ return latest;
102
+ }
103
+ function resolveAgentAttentionTitle(reason) {
104
+ if (reason === "permission")
105
+ return "Agent needs permission";
106
+ if (reason === "error")
107
+ return "Agent needs attention";
108
+ return "Agent finished";
109
+ }
110
+ function resolveAgentAttentionPreview(input) {
111
+ if (input.reason === "finished") {
112
+ return buildNotificationPreview(input.assistantMessage);
113
+ }
114
+ if (input.reason === "permission") {
115
+ return buildNotificationPreview(buildPermissionDetails(input.permissionRequest));
116
+ }
117
+ return null;
118
+ }
119
+ function resolveAgentAttentionFallbackBody(reason) {
120
+ if (reason === "permission")
121
+ return "Permission requested.";
122
+ if (reason === "error")
123
+ return "Encountered an error.";
124
+ return "Finished working.";
125
+ }
126
+ export function buildAgentAttentionNotificationPayload(input) {
127
+ const title = resolveAgentAttentionTitle(input.reason);
128
+ const preview = resolveAgentAttentionPreview(input);
129
+ const body = preview ?? resolveAgentAttentionFallbackBody(input.reason);
130
+ return {
131
+ title,
132
+ body,
133
+ data: {
134
+ serverId: input.serverId,
135
+ agentId: input.agentId,
136
+ reason: input.reason,
137
+ },
138
+ };
139
+ }
140
+ //# sourceMappingURL=agent-attention-notification.js.map
@@ -0,0 +1,9 @@
1
+ export declare const PARENT_AGENT_ID_LABEL = "paseo.parent-agent-id";
2
+ export declare const WORKFLOW_ID_LABEL = "paseo.workflow-id";
3
+ export declare const WORKFLOW_TASK_ID_LABEL = "paseo.workflow-task-id";
4
+ export interface AgentLabelSource {
5
+ labels?: Record<string, unknown> | null;
6
+ }
7
+ export declare function getParentAgentIdFromLabels(labels: Record<string, unknown> | null | undefined): string | null;
8
+ export declare function isDelegatedAgent(agent: AgentLabelSource): boolean;
9
+ //# sourceMappingURL=agent-labels.d.ts.map
@@ -0,0 +1,23 @@
1
+ export const PARENT_AGENT_ID_LABEL = "paseo.parent-agent-id";
2
+ // Epic 1, Story 1.2 — links a child agent back to its owning workflow. A child may
3
+ // carry BOTH this label (workflow id) and PARENT_AGENT_ID_LABEL (parent agent id);
4
+ // the two are independent. Cascade archival keys off this label so archiving a
5
+ // workflow never orphans its spawned children.
6
+ export const WORKFLOW_ID_LABEL = "paseo.workflow-id";
7
+ // Epic 3, Story 3.1 — links a child agent to the specific task-graph node it runs.
8
+ // Carries the `TaskNode.id` from the workflow's graph. The live progress projection
9
+ // (`workflow-progress.ts`) maps each story node to its child via this label to derive
10
+ // `completedStoryCount` / phase / gate status from real child lifecycle state.
11
+ // Children must already be scoped to a single workflow (via WORKFLOW_ID_LABEL) before
12
+ // being mapped — task ids are only unique within one workflow's graph.
13
+ export const WORKFLOW_TASK_ID_LABEL = "paseo.workflow-task-id";
14
+ export function getParentAgentIdFromLabels(labels) {
15
+ const parentAgentId = labels?.[PARENT_AGENT_ID_LABEL];
16
+ return typeof parentAgentId === "string" && parentAgentId.trim().length > 0
17
+ ? parentAgentId.trim()
18
+ : null;
19
+ }
20
+ export function isDelegatedAgent(agent) {
21
+ return getParentAgentIdFromLabels(agent.labels) !== null;
22
+ }
23
+ //# sourceMappingURL=agent-labels.js.map
@@ -0,0 +1,3 @@
1
+ export declare const AGENT_LIFECYCLE_STATUSES: readonly ["initializing", "idle", "running", "error", "closed"];
2
+ export type AgentLifecycleStatus = (typeof AGENT_LIFECYCLE_STATUSES)[number];
3
+ //# sourceMappingURL=agent-lifecycle.d.ts.map
@@ -0,0 +1,8 @@
1
+ export const AGENT_LIFECYCLE_STATUSES = [
2
+ "initializing",
3
+ "idle",
4
+ "running",
5
+ "error",
6
+ "closed",
7
+ ];
8
+ //# sourceMappingURL=agent-lifecycle.js.map
@@ -0,0 +1,24 @@
1
+ import type { AgentLifecycleStatus } from "./agent-lifecycle.js";
2
+ import type { WorkspaceStateBucket } from "./messages.js";
3
+ export type { WorkspaceStateBucket };
4
+ export type AgentAttentionReason = "finished" | "error" | "permission" | null | undefined;
5
+ export interface AgentStateBucketInput {
6
+ status: AgentLifecycleStatus;
7
+ pendingPermissionCount?: number;
8
+ requiresAttention?: boolean;
9
+ attentionReason?: AgentAttentionReason;
10
+ /**
11
+ * Number of still-alive child activities owned by this agent — running
12
+ * subagents, open shell terminals, and in-flight background tasks. When > 0
13
+ * the agent is still doing work even if its own lifecycle status has settled
14
+ * to "idle", so it must keep surfacing as "running" (kanban, activity dot,
15
+ * background tray) until those children finish or are dismissed.
16
+ */
17
+ activeChildCount?: number;
18
+ }
19
+ /** True when an agent has live children (subagents / shells / background tasks). */
20
+ export declare function hasActiveChildren(input: Pick<AgentStateBucketInput, "activeChildCount">): boolean;
21
+ export declare function deriveAgentStateBucket(input: AgentStateBucketInput): WorkspaceStateBucket;
22
+ export declare function getWorkspaceStateBucketPriority(bucket: WorkspaceStateBucket): number;
23
+ export declare function getAgentStatusPriority(input: AgentStateBucketInput): number;
24
+ //# sourceMappingURL=agent-state-bucket.d.ts.map
@@ -0,0 +1,45 @@
1
+ /** True when an agent has live children (subagents / shells / background tasks). */
2
+ export function hasActiveChildren(input) {
3
+ return (input.activeChildCount ?? 0) > 0;
4
+ }
5
+ const WORKSPACE_STATE_BUCKET_PRIORITY = {
6
+ needs_input: 0,
7
+ failed: 1,
8
+ running: 2,
9
+ attention: 3,
10
+ done: 4,
11
+ };
12
+ export function deriveAgentStateBucket(input) {
13
+ if ((input.pendingPermissionCount ?? 0) > 0 || input.attentionReason === "permission") {
14
+ return "needs_input";
15
+ }
16
+ if (input.status === "error" || input.attentionReason === "error") {
17
+ return "failed";
18
+ }
19
+ if (input.status === "running" || hasActiveChildren(input)) {
20
+ return "running";
21
+ }
22
+ if (input.requiresAttention) {
23
+ return "attention";
24
+ }
25
+ return "done";
26
+ }
27
+ export function getWorkspaceStateBucketPriority(bucket) {
28
+ return WORKSPACE_STATE_BUCKET_PRIORITY[bucket];
29
+ }
30
+ export function getAgentStatusPriority(input) {
31
+ if ((input.pendingPermissionCount ?? 0) > 0 || input.attentionReason === "permission") {
32
+ return 0;
33
+ }
34
+ if (input.status === "error" || input.attentionReason === "error") {
35
+ return 1;
36
+ }
37
+ if (input.status === "running" || hasActiveChildren(input)) {
38
+ return 2;
39
+ }
40
+ if (input.status === "initializing") {
41
+ return 3;
42
+ }
43
+ return 4;
44
+ }
45
+ //# sourceMappingURL=agent-state-bucket.js.map
@@ -0,0 +1,2 @@
1
+ export declare const MAX_EXPLICIT_AGENT_TITLE_CHARS = 200;
2
+ //# sourceMappingURL=agent-title-limits.d.ts.map
@@ -0,0 +1,2 @@
1
+ export const MAX_EXPLICIT_AGENT_TITLE_CHARS = 200;
2
+ //# sourceMappingURL=agent-title-limits.js.map