@getmateo/protocol 0.19.13 → 0.19.14

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/messages.js CHANGED
@@ -11,6 +11,8 @@ import { PluginIdSchema, PluginRequirementsSchema, PluginSourceSchema } from "./
11
11
  export { PluginIdSchema, PluginRequirementsSchema, DirectoryPluginSourceSchema, PluginSourceSchema, } from "./plugin-config.js";
12
12
  import { TerminalProfileSchema } from "./terminal-profile.js";
13
13
  export { TerminalProfileSchema } from "./terminal-profile.js";
14
+ import { NotificationPreferencesSchema } from "./notification-preferences.js";
15
+ export { DEFAULT_NOTIFICATION_PREFERENCES, NotificationEventsPreferencesSchema, NotificationPluginsPreferencesSchema, NotificationPreferencesSchema, normalizeNotificationPreferences, shouldDeliverNotification, } from "./notification-preferences.js";
14
16
  import { z } from "zod";
15
17
  import { TerminalActivitySchema } from "./terminal-activity.js";
16
18
  import { CLIENT_CAPS } from "./client-capabilities.js";
@@ -2573,6 +2575,7 @@ export const ListCommandsRequestSchema = z.object({
2573
2575
  export const RegisterPushTokenMessageSchema = z.object({
2574
2576
  type: z.literal("register_push_token"),
2575
2577
  token: z.string(),
2578
+ preferences: NotificationPreferencesSchema.optional(),
2576
2579
  });
2577
2580
  export const PushUnregisterRequestSchema = z.object({
2578
2581
  type: z.literal("push.unregister.request"),
@@ -2785,6 +2788,7 @@ export const SessionEventSubscriptionSchema = z.enum([
2785
2788
  "workspace_setup_progress",
2786
2789
  "agent.provider_subagents.update",
2787
2790
  "terminal_attention_required",
2791
+ "plugin.notification",
2788
2792
  "status.server_info",
2789
2793
  "status.daemon_config_changed",
2790
2794
  "status.plugin_catalog_changed",
@@ -3297,6 +3301,8 @@ export const ServerInfoStatusPayloadSchema = z
3297
3301
  relayConfig: z.boolean().optional(),
3298
3302
  // COMPAT(pushTokenRevocation): added in v0.3.2, remove gate after 2027-02-10.
3299
3303
  pushTokenRevocation: z.boolean().optional(),
3304
+ // COMPAT(pushNotificationPreferences): added in v0.19.14, remove gate after 2027-06-01.
3305
+ pushNotificationPreferences: z.boolean().optional(),
3300
3306
  // COMPAT(plugins): added in v0.3.0, remove gate after 2027-08-07.
3301
3307
  plugins: z.boolean().optional(),
3302
3308
  // COMPAT(pluginManagement): added in v0.4.0, remove gate after 2027-08-14.
@@ -3321,6 +3327,8 @@ export const ServerInfoStatusPayloadSchema = z
3321
3327
  pluginThemes: z.boolean().optional(),
3322
3328
  pluginSettings: z.boolean().optional(),
3323
3329
  pluginTimelineItems: z.boolean().optional(),
3330
+ // COMPAT(pluginNotifications): added in v0.19.14, remove gate after 2027-06-01.
3331
+ pluginNotifications: z.boolean().optional(),
3324
3332
  // Terminals owned by no workspace, created with GLOBAL_TERMINAL_WORKSPACE_ID.
3325
3333
  globalTerminals: z.boolean().optional(),
3326
3334
  // COMPAT(terminalBusyCount): added in v0.11.0, remove gate after 2027-04-07.
@@ -4849,6 +4857,16 @@ const CheckoutStatusCommonSchema = z.object({
4849
4857
  upstreamRef: z.string().nullable().optional(),
4850
4858
  // A missing tracking ref can mean no upstream, a pruned upstream, or a limited fetch refspec.
4851
4859
  upstreamState: z.enum(["tracked", "none", "gone", "unknown"]).optional(),
4860
+ // The remote Pull fetches currentBranch from, as git names it: the remote of the branch's
4861
+ // configured upstream, which is not necessarily origin, or "." when the upstream is a local
4862
+ // branch. Null when the branch has no upstream. Absent from daemons that predate it, which
4863
+ // pull only in checkouts that have origin (hasRemote).
4864
+ pullRemote: z.string().nullable().optional(),
4865
+ // The remote Push sends currentBranch to, resolved as the daemon's push resolves it. It is not
4866
+ // necessarily origin. Null when Push has nowhere to send the branch, as when it has no upstream
4867
+ // and origin is missing, or git is set to push it to another remote. Absent from daemons that
4868
+ // predate it, which push only in checkouts that have origin (hasRemote).
4869
+ pushRemote: z.string().nullable().optional(),
4852
4870
  // For a regular checkout's first push, null unless Git's destination agrees with Mateo's.
4853
4871
  firstPushRemote: z.string().nullable().optional(),
4854
4872
  });
@@ -6083,6 +6101,35 @@ export const TerminalAttentionRequiredSchema = z.object({
6083
6101
  shouldNotify: z.boolean(),
6084
6102
  }),
6085
6103
  });
6104
+ export const PluginNotificationOpenTargetSchema = z.discriminatedUnion("type", [
6105
+ z.object({
6106
+ type: z.literal("agent"),
6107
+ agentId: z.string(),
6108
+ }),
6109
+ z.object({
6110
+ type: z.literal("workspace"),
6111
+ workspaceId: z.string(),
6112
+ }),
6113
+ z.object({
6114
+ type: z.literal("screen"),
6115
+ screenId: z.string(),
6116
+ params: z.record(z.string(), z.string()).optional(),
6117
+ }),
6118
+ ]);
6119
+ export const PluginNotificationMessageSchema = z.object({
6120
+ type: z.literal("plugin.notification"),
6121
+ payload: z.object({
6122
+ subscriptionId: z.string().optional(),
6123
+ serverId: z.string().optional(),
6124
+ pluginId: z.string(),
6125
+ notificationId: z.string(),
6126
+ title: z.string(),
6127
+ body: z.string(),
6128
+ open: PluginNotificationOpenTargetSchema.optional(),
6129
+ data: z.record(z.string(), JsonWireValueSchema).optional(),
6130
+ shouldNotify: z.boolean(),
6131
+ }),
6132
+ });
6086
6133
  export const DaemonUpdateResponseSchema = z.object({
6087
6134
  type: z.literal("daemon.update.response"),
6088
6135
  payload: z.object({
@@ -6598,6 +6645,7 @@ export const SessionOutboundMessageSchema = z.discriminatedUnion("type", [
6598
6645
  CaptureTerminalResponseSchema,
6599
6646
  TerminalStreamExitSchema,
6600
6647
  TerminalAttentionRequiredSchema,
6648
+ PluginNotificationMessageSchema,
6601
6649
  ChatCreateResponseSchema,
6602
6650
  ChatListResponseSchema,
6603
6651
  ChatInspectResponseSchema,
@@ -0,0 +1,59 @@
1
+ import { z } from "zod";
2
+ export interface NotificationPreferences {
3
+ enabled: boolean;
4
+ events: {
5
+ agentPermission: boolean;
6
+ agentError: boolean;
7
+ agentFinished: boolean;
8
+ terminalNeedsInput: boolean;
9
+ terminalFinished: boolean;
10
+ };
11
+ plugins: {
12
+ enabled: boolean;
13
+ muted: string[];
14
+ };
15
+ }
16
+ export declare const NotificationEventsPreferencesSchema: z.ZodObject<{
17
+ agentPermission: z.ZodOptional<z.ZodBoolean>;
18
+ agentError: z.ZodOptional<z.ZodBoolean>;
19
+ agentFinished: z.ZodOptional<z.ZodBoolean>;
20
+ terminalNeedsInput: z.ZodOptional<z.ZodBoolean>;
21
+ terminalFinished: z.ZodOptional<z.ZodBoolean>;
22
+ }, z.core.$strip>;
23
+ export declare const NotificationPluginsPreferencesSchema: z.ZodObject<{
24
+ enabled: z.ZodOptional<z.ZodBoolean>;
25
+ muted: z.ZodOptional<z.ZodArray<z.ZodString>>;
26
+ }, z.core.$strip>;
27
+ export declare const NotificationPreferencesSchema: z.ZodObject<{
28
+ enabled: z.ZodOptional<z.ZodBoolean>;
29
+ events: z.ZodOptional<z.ZodObject<{
30
+ agentPermission: z.ZodOptional<z.ZodBoolean>;
31
+ agentError: z.ZodOptional<z.ZodBoolean>;
32
+ agentFinished: z.ZodOptional<z.ZodBoolean>;
33
+ terminalNeedsInput: z.ZodOptional<z.ZodBoolean>;
34
+ terminalFinished: z.ZodOptional<z.ZodBoolean>;
35
+ }, z.core.$strip>>;
36
+ plugins: z.ZodOptional<z.ZodObject<{
37
+ enabled: z.ZodOptional<z.ZodBoolean>;
38
+ muted: z.ZodOptional<z.ZodArray<z.ZodString>>;
39
+ }, z.core.$strip>>;
40
+ }, z.core.$strip>;
41
+ export type NotificationPreferencesInput = z.infer<typeof NotificationPreferencesSchema>;
42
+ /**
43
+ * Every event notifies by default. Mateo has always notified finished turns and terminals, so
44
+ * a device that never opened the settings keeps that behavior.
45
+ */
46
+ export declare const DEFAULT_NOTIFICATION_PREFERENCES: NotificationPreferences;
47
+ export type NotificationKind = {
48
+ kind: "agent";
49
+ reason: "permission" | "error" | "finished";
50
+ } | {
51
+ kind: "terminal";
52
+ reason: "needs_input" | "finished";
53
+ } | {
54
+ kind: "plugin";
55
+ pluginId: string;
56
+ };
57
+ export declare function normalizeNotificationPreferences(raw?: unknown): NotificationPreferences;
58
+ export declare function shouldDeliverNotification(prefs: NotificationPreferences, target: NotificationKind): boolean;
59
+ //# sourceMappingURL=notification-preferences.d.ts.map
@@ -0,0 +1,119 @@
1
+ import { z } from "zod";
2
+ export const NotificationEventsPreferencesSchema = z.object({
3
+ agentPermission: z.boolean().optional(),
4
+ agentError: z.boolean().optional(),
5
+ agentFinished: z.boolean().optional(),
6
+ terminalNeedsInput: z.boolean().optional(),
7
+ terminalFinished: z.boolean().optional(),
8
+ });
9
+ export const NotificationPluginsPreferencesSchema = z.object({
10
+ enabled: z.boolean().optional(),
11
+ muted: z.array(z.string()).optional(),
12
+ });
13
+ export const NotificationPreferencesSchema = z.object({
14
+ enabled: z.boolean().optional(),
15
+ events: NotificationEventsPreferencesSchema.optional(),
16
+ plugins: NotificationPluginsPreferencesSchema.optional(),
17
+ });
18
+ /**
19
+ * Every event notifies by default. Mateo has always notified finished turns and terminals, so
20
+ * a device that never opened the settings keeps that behavior.
21
+ */
22
+ export const DEFAULT_NOTIFICATION_PREFERENCES = {
23
+ enabled: true,
24
+ events: {
25
+ agentPermission: true,
26
+ agentError: true,
27
+ agentFinished: true,
28
+ terminalNeedsInput: true,
29
+ terminalFinished: true,
30
+ },
31
+ plugins: {
32
+ enabled: true,
33
+ muted: [],
34
+ },
35
+ };
36
+ export function normalizeNotificationPreferences(raw) {
37
+ if (!raw || typeof raw !== "object") {
38
+ return {
39
+ enabled: DEFAULT_NOTIFICATION_PREFERENCES.enabled,
40
+ events: { ...DEFAULT_NOTIFICATION_PREFERENCES.events },
41
+ plugins: {
42
+ enabled: DEFAULT_NOTIFICATION_PREFERENCES.plugins.enabled,
43
+ muted: [...DEFAULT_NOTIFICATION_PREFERENCES.plugins.muted],
44
+ },
45
+ };
46
+ }
47
+ const candidate = raw;
48
+ const eventsCandidate = candidate.events && typeof candidate.events === "object"
49
+ ? candidate.events
50
+ : {};
51
+ const pluginsCandidate = candidate.plugins && typeof candidate.plugins === "object"
52
+ ? candidate.plugins
53
+ : {};
54
+ const muted = Array.isArray(pluginsCandidate.muted)
55
+ ? Array.from(new Set(pluginsCandidate.muted
56
+ .filter((item) => typeof item === "string")
57
+ .map((item) => item.trim())
58
+ .filter((item) => item.length > 0))).sort()
59
+ : [...DEFAULT_NOTIFICATION_PREFERENCES.plugins.muted];
60
+ return {
61
+ enabled: typeof candidate.enabled === "boolean"
62
+ ? candidate.enabled
63
+ : DEFAULT_NOTIFICATION_PREFERENCES.enabled,
64
+ events: {
65
+ agentPermission: typeof eventsCandidate.agentPermission === "boolean"
66
+ ? eventsCandidate.agentPermission
67
+ : DEFAULT_NOTIFICATION_PREFERENCES.events.agentPermission,
68
+ agentError: typeof eventsCandidate.agentError === "boolean"
69
+ ? eventsCandidate.agentError
70
+ : DEFAULT_NOTIFICATION_PREFERENCES.events.agentError,
71
+ agentFinished: typeof eventsCandidate.agentFinished === "boolean"
72
+ ? eventsCandidate.agentFinished
73
+ : DEFAULT_NOTIFICATION_PREFERENCES.events.agentFinished,
74
+ terminalNeedsInput: typeof eventsCandidate.terminalNeedsInput === "boolean"
75
+ ? eventsCandidate.terminalNeedsInput
76
+ : DEFAULT_NOTIFICATION_PREFERENCES.events.terminalNeedsInput,
77
+ terminalFinished: typeof eventsCandidate.terminalFinished === "boolean"
78
+ ? eventsCandidate.terminalFinished
79
+ : DEFAULT_NOTIFICATION_PREFERENCES.events.terminalFinished,
80
+ },
81
+ plugins: {
82
+ enabled: typeof pluginsCandidate.enabled === "boolean"
83
+ ? pluginsCandidate.enabled
84
+ : DEFAULT_NOTIFICATION_PREFERENCES.plugins.enabled,
85
+ muted,
86
+ },
87
+ };
88
+ }
89
+ export function shouldDeliverNotification(prefs, target) {
90
+ if (!prefs.enabled) {
91
+ return false;
92
+ }
93
+ switch (target.kind) {
94
+ case "agent":
95
+ switch (target.reason) {
96
+ case "permission":
97
+ return prefs.events.agentPermission;
98
+ case "error":
99
+ return prefs.events.agentError;
100
+ case "finished":
101
+ return prefs.events.agentFinished;
102
+ }
103
+ break;
104
+ case "terminal":
105
+ switch (target.reason) {
106
+ case "needs_input":
107
+ return prefs.events.terminalNeedsInput;
108
+ case "finished":
109
+ return prefs.events.terminalFinished;
110
+ }
111
+ break;
112
+ case "plugin":
113
+ if (!prefs.plugins.enabled) {
114
+ return false;
115
+ }
116
+ return !prefs.plugins.muted.includes(target.pluginId);
117
+ }
118
+ }
119
+ //# sourceMappingURL=notification-preferences.js.map