@agimon-ai/doompi-extension-contracts 0.0.1-alpha.0

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 (127) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +34 -0
  3. package/dist/backgroundWork.cjs +2 -0
  4. package/dist/backgroundWork.cjs.map +1 -0
  5. package/dist/backgroundWork.d.cts +73 -0
  6. package/dist/backgroundWork.d.cts.map +1 -0
  7. package/dist/backgroundWork.d.mts +73 -0
  8. package/dist/backgroundWork.d.mts.map +1 -0
  9. package/dist/backgroundWork.mjs +2 -0
  10. package/dist/backgroundWork.mjs.map +1 -0
  11. package/dist/childProcess.cjs +2 -0
  12. package/dist/childProcess.cjs.map +1 -0
  13. package/dist/childProcess.d.cts +20 -0
  14. package/dist/childProcess.d.cts.map +1 -0
  15. package/dist/childProcess.d.mts +20 -0
  16. package/dist/childProcess.d.mts.map +1 -0
  17. package/dist/childProcess.mjs +2 -0
  18. package/dist/childProcess.mjs.map +1 -0
  19. package/dist/config.cjs +2 -0
  20. package/dist/config.cjs.map +1 -0
  21. package/dist/config.d.cts +517 -0
  22. package/dist/config.d.cts.map +1 -0
  23. package/dist/config.d.mts +517 -0
  24. package/dist/config.d.mts.map +1 -0
  25. package/dist/config.mjs +2 -0
  26. package/dist/config.mjs.map +1 -0
  27. package/dist/delegation.cjs +2 -0
  28. package/dist/delegation.cjs.map +1 -0
  29. package/dist/delegation.d.cts +114 -0
  30. package/dist/delegation.d.cts.map +1 -0
  31. package/dist/delegation.d.mts +114 -0
  32. package/dist/delegation.d.mts.map +1 -0
  33. package/dist/delegation.mjs +2 -0
  34. package/dist/delegation.mjs.map +1 -0
  35. package/dist/fablePlan.cjs +2 -0
  36. package/dist/fablePlan.cjs.map +1 -0
  37. package/dist/fablePlan.d.cts +143 -0
  38. package/dist/fablePlan.d.cts.map +1 -0
  39. package/dist/fablePlan.d.mts +143 -0
  40. package/dist/fablePlan.d.mts.map +1 -0
  41. package/dist/fablePlan.mjs +2 -0
  42. package/dist/fablePlan.mjs.map +1 -0
  43. package/dist/footer.cjs +2 -0
  44. package/dist/footer.cjs.map +1 -0
  45. package/dist/footer.d.cts +141 -0
  46. package/dist/footer.d.cts.map +1 -0
  47. package/dist/footer.d.mts +141 -0
  48. package/dist/footer.d.mts.map +1 -0
  49. package/dist/footer.mjs +2 -0
  50. package/dist/footer.mjs.map +1 -0
  51. package/dist/index.cjs +1 -0
  52. package/dist/index.d.cts +2 -0
  53. package/dist/index.d.mts +2 -0
  54. package/dist/index.mjs +1 -0
  55. package/dist/leader.cjs +2 -0
  56. package/dist/leader.cjs.map +1 -0
  57. package/dist/leader.d.cts +171 -0
  58. package/dist/leader.d.cts.map +1 -0
  59. package/dist/leader.d.mts +171 -0
  60. package/dist/leader.d.mts.map +1 -0
  61. package/dist/leader.mjs +2 -0
  62. package/dist/leader.mjs.map +1 -0
  63. package/dist/mcpStatus.cjs +2 -0
  64. package/dist/mcpStatus.cjs.map +1 -0
  65. package/dist/mcpStatus.d.cts +79 -0
  66. package/dist/mcpStatus.d.cts.map +1 -0
  67. package/dist/mcpStatus.d.mts +79 -0
  68. package/dist/mcpStatus.d.mts.map +1 -0
  69. package/dist/mcpStatus.mjs +2 -0
  70. package/dist/mcpStatus.mjs.map +1 -0
  71. package/dist/mode.cjs +2 -0
  72. package/dist/mode.cjs.map +1 -0
  73. package/dist/mode.d.cts +132 -0
  74. package/dist/mode.d.cts.map +1 -0
  75. package/dist/mode.d.mts +132 -0
  76. package/dist/mode.d.mts.map +1 -0
  77. package/dist/mode.mjs +2 -0
  78. package/dist/mode.mjs.map +1 -0
  79. package/dist/protocol.cjs +2 -0
  80. package/dist/protocol.cjs.map +1 -0
  81. package/dist/protocol.d.cts +83 -0
  82. package/dist/protocol.d.cts.map +1 -0
  83. package/dist/protocol.d.mts +83 -0
  84. package/dist/protocol.d.mts.map +1 -0
  85. package/dist/protocol.mjs +2 -0
  86. package/dist/protocol.mjs.map +1 -0
  87. package/dist/runnerPty.cjs +2 -0
  88. package/dist/runnerPty.cjs.map +1 -0
  89. package/dist/runnerPty.d.cts +39 -0
  90. package/dist/runnerPty.d.cts.map +1 -0
  91. package/dist/runnerPty.d.mts +39 -0
  92. package/dist/runnerPty.d.mts.map +1 -0
  93. package/dist/runnerPty.mjs +2 -0
  94. package/dist/runnerPty.mjs.map +1 -0
  95. package/dist/skills.cjs +2 -0
  96. package/dist/skills.cjs.map +1 -0
  97. package/dist/skills.d.cts +51 -0
  98. package/dist/skills.d.cts.map +1 -0
  99. package/dist/skills.d.mts +51 -0
  100. package/dist/skills.d.mts.map +1 -0
  101. package/dist/skills.mjs +2 -0
  102. package/dist/skills.mjs.map +1 -0
  103. package/dist/subagentPolicy.cjs +2 -0
  104. package/dist/subagentPolicy.cjs.map +1 -0
  105. package/dist/subagentPolicy.d.cts +47 -0
  106. package/dist/subagentPolicy.d.cts.map +1 -0
  107. package/dist/subagentPolicy.d.mts +47 -0
  108. package/dist/subagentPolicy.d.mts.map +1 -0
  109. package/dist/subagentPolicy.mjs +2 -0
  110. package/dist/subagentPolicy.mjs.map +1 -0
  111. package/dist/subagentTool.cjs +2 -0
  112. package/dist/subagentTool.cjs.map +1 -0
  113. package/dist/subagentTool.d.cts +78 -0
  114. package/dist/subagentTool.d.cts.map +1 -0
  115. package/dist/subagentTool.d.mts +78 -0
  116. package/dist/subagentTool.d.mts.map +1 -0
  117. package/dist/subagentTool.mjs +2 -0
  118. package/dist/subagentTool.mjs.map +1 -0
  119. package/dist/workflow.cjs +2 -0
  120. package/dist/workflow.cjs.map +1 -0
  121. package/dist/workflow.d.cts +15 -0
  122. package/dist/workflow.d.cts.map +1 -0
  123. package/dist/workflow.d.mts +15 -0
  124. package/dist/workflow.d.mts.map +1 -0
  125. package/dist/workflow.mjs +2 -0
  126. package/dist/workflow.mjs.map +1 -0
  127. package/package.json +121 -0
@@ -0,0 +1,171 @@
1
+ import { NotificationDefinition, RequestReplyDefinition } from "./protocol.cjs";
2
+ import { DoomExtensionContext, DoomExtensionHost } from "./config.cjs";
3
+ import { Static, Type } from "typebox";
4
+ //#region src/leader.d.ts
5
+ declare const LeaderSegmentSchema: Type.TObject<{
6
+ key: Type.TString;
7
+ label: Type.TString;
8
+ detail: Type.TOptional<Type.TString>;
9
+ order: Type.TOptional<Type.TInteger>;
10
+ }>;
11
+ type LeaderSegment = Static<typeof LeaderSegmentSchema>;
12
+ declare const LeaderCommandSchema: Type.TObject<{
13
+ name: Type.TString;
14
+ args: Type.TOptional<Type.TString>;
15
+ }>;
16
+ type LeaderCommand = Static<typeof LeaderCommandSchema>;
17
+ declare const LeaderActionSchema: Type.TObject<{
18
+ name: Type.TString;
19
+ }>;
20
+ type LeaderAction = Static<typeof LeaderActionSchema>;
21
+ declare const LeaderBindingSchema: Type.TUnion<[Type.TObject<{
22
+ command: Type.TObject<{
23
+ name: Type.TString;
24
+ args: Type.TOptional<Type.TString>;
25
+ }>;
26
+ id: Type.TString;
27
+ path: Type.TArray<Type.TObject<{
28
+ key: Type.TString;
29
+ label: Type.TString;
30
+ detail: Type.TOptional<Type.TString>;
31
+ order: Type.TOptional<Type.TInteger>;
32
+ }>>;
33
+ }>, Type.TObject<{
34
+ action: Type.TObject<{
35
+ name: Type.TString;
36
+ }>;
37
+ id: Type.TString;
38
+ path: Type.TArray<Type.TObject<{
39
+ key: Type.TString;
40
+ label: Type.TString;
41
+ detail: Type.TOptional<Type.TString>;
42
+ order: Type.TOptional<Type.TInteger>;
43
+ }>>;
44
+ }>]>;
45
+ type LeaderBinding = {
46
+ id: string;
47
+ path: readonly [LeaderSegment, ...LeaderSegment[]];
48
+ command: LeaderCommand;
49
+ } | {
50
+ id: string;
51
+ path: readonly [LeaderSegment, ...LeaderSegment[]];
52
+ action: LeaderAction;
53
+ };
54
+ declare const LeaderSourceSchema: Type.TString;
55
+ declare const LeaderContributionSchema: Type.TObject<{
56
+ source: Type.TString;
57
+ bindings: Type.TArray<Type.TUnion<[Type.TObject<{
58
+ command: Type.TObject<{
59
+ name: Type.TString;
60
+ args: Type.TOptional<Type.TString>;
61
+ }>;
62
+ id: Type.TString;
63
+ path: Type.TArray<Type.TObject<{
64
+ key: Type.TString;
65
+ label: Type.TString;
66
+ detail: Type.TOptional<Type.TString>;
67
+ order: Type.TOptional<Type.TInteger>;
68
+ }>>;
69
+ }>, Type.TObject<{
70
+ action: Type.TObject<{
71
+ name: Type.TString;
72
+ }>;
73
+ id: Type.TString;
74
+ path: Type.TArray<Type.TObject<{
75
+ key: Type.TString;
76
+ label: Type.TString;
77
+ detail: Type.TOptional<Type.TString>;
78
+ order: Type.TOptional<Type.TInteger>;
79
+ }>>;
80
+ }>]>>;
81
+ }>;
82
+ interface LeaderContribution {
83
+ source: string;
84
+ bindings: readonly LeaderBinding[];
85
+ }
86
+ declare const LeaderRegistrationSchema: Type.TObject<{
87
+ contribution: Type.TObject<{
88
+ source: Type.TString;
89
+ bindings: Type.TArray<Type.TUnion<[Type.TObject<{
90
+ command: Type.TObject<{
91
+ name: Type.TString;
92
+ args: Type.TOptional<Type.TString>;
93
+ }>;
94
+ id: Type.TString;
95
+ path: Type.TArray<Type.TObject<{
96
+ key: Type.TString;
97
+ label: Type.TString;
98
+ detail: Type.TOptional<Type.TString>;
99
+ order: Type.TOptional<Type.TInteger>;
100
+ }>>;
101
+ }>, Type.TObject<{
102
+ action: Type.TObject<{
103
+ name: Type.TString;
104
+ }>;
105
+ id: Type.TString;
106
+ path: Type.TArray<Type.TObject<{
107
+ key: Type.TString;
108
+ label: Type.TString;
109
+ detail: Type.TOptional<Type.TString>;
110
+ order: Type.TOptional<Type.TInteger>;
111
+ }>>;
112
+ }>]>>;
113
+ }>;
114
+ generation: Type.TString;
115
+ }>;
116
+ declare const LeaderActionInvoked: NotificationDefinition<Type.TObject<{
117
+ source: Type.TString;
118
+ action: Type.TString;
119
+ }>>;
120
+ declare const LeaderRegistrationProtocol: RequestReplyDefinition<Type.TObject<{
121
+ contribution: Type.TObject<{
122
+ source: Type.TString;
123
+ bindings: Type.TArray<Type.TUnion<[Type.TObject<{
124
+ command: Type.TObject<{
125
+ name: Type.TString;
126
+ args: Type.TOptional<Type.TString>;
127
+ }>;
128
+ id: Type.TString;
129
+ path: Type.TArray<Type.TObject<{
130
+ key: Type.TString;
131
+ label: Type.TString;
132
+ detail: Type.TOptional<Type.TString>;
133
+ order: Type.TOptional<Type.TInteger>;
134
+ }>>;
135
+ }>, Type.TObject<{
136
+ action: Type.TObject<{
137
+ name: Type.TString;
138
+ }>;
139
+ id: Type.TString;
140
+ path: Type.TArray<Type.TObject<{
141
+ key: Type.TString;
142
+ label: Type.TString;
143
+ detail: Type.TOptional<Type.TString>;
144
+ order: Type.TOptional<Type.TInteger>;
145
+ }>>;
146
+ }>]>>;
147
+ }>;
148
+ generation: Type.TString;
149
+ }>, Type.TObject<{
150
+ handleId: Type.TString;
151
+ }>>;
152
+ declare const LeaderUnregistrationProtocol: RequestReplyDefinition<Type.TObject<{
153
+ handleId: Type.TString;
154
+ }>, Type.TObject<{
155
+ removed: Type.TBoolean;
156
+ }>>;
157
+ interface DoomLeaderContributionHandle {
158
+ update(bindings: readonly LeaderBinding[]): void;
159
+ dispose(): void;
160
+ }
161
+ declare function createDoomLeaderContribution(pi: DoomExtensionHost, contribution: LeaderContribution): DoomLeaderContributionHandle;
162
+ declare function registerDoomLeaderContribution(pi: DoomExtensionHost, contribution: LeaderContribution): () => void;
163
+ interface DoomLeaderActionHandlerOptions {
164
+ source: string;
165
+ handlers: Readonly<Record<string, (ctx: DoomExtensionContext) => void | Promise<void>>>;
166
+ onError: (error: unknown, actionName: string, ctx: DoomExtensionContext) => void;
167
+ }
168
+ declare function registerDoomLeaderActionHandlers(pi: DoomExtensionHost, options: DoomLeaderActionHandlerOptions): () => void;
169
+ //#endregion
170
+ export { DoomLeaderActionHandlerOptions, DoomLeaderContributionHandle, LeaderAction, LeaderActionInvoked, LeaderActionSchema, LeaderBinding, LeaderBindingSchema, LeaderCommand, LeaderCommandSchema, LeaderContribution, LeaderContributionSchema, LeaderRegistrationProtocol, LeaderRegistrationSchema, LeaderSegment, LeaderSegmentSchema, LeaderSourceSchema, LeaderUnregistrationProtocol, createDoomLeaderContribution, registerDoomLeaderActionHandlers, registerDoomLeaderContribution };
171
+ //# sourceMappingURL=leader.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"leader.d.cts","names":[],"sources":["../src/leader.ts"],"mappings":";;;;cAWa,qBAAmB,KAAA;;;;;;KASpB,gBAAgB,cAAc;cAE7B,qBAAmB,KAAA;;;;KAIpB,gBAAgB,cAAc;cAE7B,oBAAkB,KAAA;QAAlB,KAAA;;KAUD,eAAe,cAAc;cAO5B,qBAAmB,KAAA,QAAA,KAAA;;;;;;;;;;;;;;;;;;;;;;;;KAIpB;EAEN;EACA,gBAAgB,kBAAkB;EAClC,SAAS;;EAGT;EACA,gBAAgB,kBAAkB;EAClC,QAAQ;;cAGD,oBAAkB,KAAA;cAMlB,0BAAwB,KAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;UAOpB;EACf;EACA,mBAAmB;;cAGR,0BAAwB,KAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAKxB,qBAAmB,uBAAA,KAAA;;;;cASnB,mDAA0B,KAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAW1B,qDAA4B,KAAA;;;;;UAqBxB;EACf,OAAO,mBAAmB;EAC1B;;iBAWc,6BACd,IAAI,mBACJ,cAAc,qBACb;iBAsFa,+BAA+B,IAAI,mBAAmB,cAAc;UAKnE;EACf;EACA,UAAU,SAAS,gBAAgB,KAAK,gCAAgC;EACxE,UAAU,gBAAgB,oBAAoB,KAAK;;iBAGrC,iCACd,IAAI,mBACJ,SAAS"}
@@ -0,0 +1,171 @@
1
+ import { NotificationDefinition, RequestReplyDefinition } from "./protocol.mjs";
2
+ import { DoomExtensionContext, DoomExtensionHost } from "./config.mjs";
3
+ import { Static, Type } from "typebox";
4
+ //#region src/leader.d.ts
5
+ declare const LeaderSegmentSchema: Type.TObject<{
6
+ key: Type.TString;
7
+ label: Type.TString;
8
+ detail: Type.TOptional<Type.TString>;
9
+ order: Type.TOptional<Type.TInteger>;
10
+ }>;
11
+ type LeaderSegment = Static<typeof LeaderSegmentSchema>;
12
+ declare const LeaderCommandSchema: Type.TObject<{
13
+ name: Type.TString;
14
+ args: Type.TOptional<Type.TString>;
15
+ }>;
16
+ type LeaderCommand = Static<typeof LeaderCommandSchema>;
17
+ declare const LeaderActionSchema: Type.TObject<{
18
+ name: Type.TString;
19
+ }>;
20
+ type LeaderAction = Static<typeof LeaderActionSchema>;
21
+ declare const LeaderBindingSchema: Type.TUnion<[Type.TObject<{
22
+ command: Type.TObject<{
23
+ name: Type.TString;
24
+ args: Type.TOptional<Type.TString>;
25
+ }>;
26
+ id: Type.TString;
27
+ path: Type.TArray<Type.TObject<{
28
+ key: Type.TString;
29
+ label: Type.TString;
30
+ detail: Type.TOptional<Type.TString>;
31
+ order: Type.TOptional<Type.TInteger>;
32
+ }>>;
33
+ }>, Type.TObject<{
34
+ action: Type.TObject<{
35
+ name: Type.TString;
36
+ }>;
37
+ id: Type.TString;
38
+ path: Type.TArray<Type.TObject<{
39
+ key: Type.TString;
40
+ label: Type.TString;
41
+ detail: Type.TOptional<Type.TString>;
42
+ order: Type.TOptional<Type.TInteger>;
43
+ }>>;
44
+ }>]>;
45
+ type LeaderBinding = {
46
+ id: string;
47
+ path: readonly [LeaderSegment, ...LeaderSegment[]];
48
+ command: LeaderCommand;
49
+ } | {
50
+ id: string;
51
+ path: readonly [LeaderSegment, ...LeaderSegment[]];
52
+ action: LeaderAction;
53
+ };
54
+ declare const LeaderSourceSchema: Type.TString;
55
+ declare const LeaderContributionSchema: Type.TObject<{
56
+ source: Type.TString;
57
+ bindings: Type.TArray<Type.TUnion<[Type.TObject<{
58
+ command: Type.TObject<{
59
+ name: Type.TString;
60
+ args: Type.TOptional<Type.TString>;
61
+ }>;
62
+ id: Type.TString;
63
+ path: Type.TArray<Type.TObject<{
64
+ key: Type.TString;
65
+ label: Type.TString;
66
+ detail: Type.TOptional<Type.TString>;
67
+ order: Type.TOptional<Type.TInteger>;
68
+ }>>;
69
+ }>, Type.TObject<{
70
+ action: Type.TObject<{
71
+ name: Type.TString;
72
+ }>;
73
+ id: Type.TString;
74
+ path: Type.TArray<Type.TObject<{
75
+ key: Type.TString;
76
+ label: Type.TString;
77
+ detail: Type.TOptional<Type.TString>;
78
+ order: Type.TOptional<Type.TInteger>;
79
+ }>>;
80
+ }>]>>;
81
+ }>;
82
+ interface LeaderContribution {
83
+ source: string;
84
+ bindings: readonly LeaderBinding[];
85
+ }
86
+ declare const LeaderRegistrationSchema: Type.TObject<{
87
+ contribution: Type.TObject<{
88
+ source: Type.TString;
89
+ bindings: Type.TArray<Type.TUnion<[Type.TObject<{
90
+ command: Type.TObject<{
91
+ name: Type.TString;
92
+ args: Type.TOptional<Type.TString>;
93
+ }>;
94
+ id: Type.TString;
95
+ path: Type.TArray<Type.TObject<{
96
+ key: Type.TString;
97
+ label: Type.TString;
98
+ detail: Type.TOptional<Type.TString>;
99
+ order: Type.TOptional<Type.TInteger>;
100
+ }>>;
101
+ }>, Type.TObject<{
102
+ action: Type.TObject<{
103
+ name: Type.TString;
104
+ }>;
105
+ id: Type.TString;
106
+ path: Type.TArray<Type.TObject<{
107
+ key: Type.TString;
108
+ label: Type.TString;
109
+ detail: Type.TOptional<Type.TString>;
110
+ order: Type.TOptional<Type.TInteger>;
111
+ }>>;
112
+ }>]>>;
113
+ }>;
114
+ generation: Type.TString;
115
+ }>;
116
+ declare const LeaderActionInvoked: NotificationDefinition<Type.TObject<{
117
+ source: Type.TString;
118
+ action: Type.TString;
119
+ }>>;
120
+ declare const LeaderRegistrationProtocol: RequestReplyDefinition<Type.TObject<{
121
+ contribution: Type.TObject<{
122
+ source: Type.TString;
123
+ bindings: Type.TArray<Type.TUnion<[Type.TObject<{
124
+ command: Type.TObject<{
125
+ name: Type.TString;
126
+ args: Type.TOptional<Type.TString>;
127
+ }>;
128
+ id: Type.TString;
129
+ path: Type.TArray<Type.TObject<{
130
+ key: Type.TString;
131
+ label: Type.TString;
132
+ detail: Type.TOptional<Type.TString>;
133
+ order: Type.TOptional<Type.TInteger>;
134
+ }>>;
135
+ }>, Type.TObject<{
136
+ action: Type.TObject<{
137
+ name: Type.TString;
138
+ }>;
139
+ id: Type.TString;
140
+ path: Type.TArray<Type.TObject<{
141
+ key: Type.TString;
142
+ label: Type.TString;
143
+ detail: Type.TOptional<Type.TString>;
144
+ order: Type.TOptional<Type.TInteger>;
145
+ }>>;
146
+ }>]>>;
147
+ }>;
148
+ generation: Type.TString;
149
+ }>, Type.TObject<{
150
+ handleId: Type.TString;
151
+ }>>;
152
+ declare const LeaderUnregistrationProtocol: RequestReplyDefinition<Type.TObject<{
153
+ handleId: Type.TString;
154
+ }>, Type.TObject<{
155
+ removed: Type.TBoolean;
156
+ }>>;
157
+ interface DoomLeaderContributionHandle {
158
+ update(bindings: readonly LeaderBinding[]): void;
159
+ dispose(): void;
160
+ }
161
+ declare function createDoomLeaderContribution(pi: DoomExtensionHost, contribution: LeaderContribution): DoomLeaderContributionHandle;
162
+ declare function registerDoomLeaderContribution(pi: DoomExtensionHost, contribution: LeaderContribution): () => void;
163
+ interface DoomLeaderActionHandlerOptions {
164
+ source: string;
165
+ handlers: Readonly<Record<string, (ctx: DoomExtensionContext) => void | Promise<void>>>;
166
+ onError: (error: unknown, actionName: string, ctx: DoomExtensionContext) => void;
167
+ }
168
+ declare function registerDoomLeaderActionHandlers(pi: DoomExtensionHost, options: DoomLeaderActionHandlerOptions): () => void;
169
+ //#endregion
170
+ export { DoomLeaderActionHandlerOptions, DoomLeaderContributionHandle, LeaderAction, LeaderActionInvoked, LeaderActionSchema, LeaderBinding, LeaderBindingSchema, LeaderCommand, LeaderCommandSchema, LeaderContribution, LeaderContributionSchema, LeaderRegistrationProtocol, LeaderRegistrationSchema, LeaderSegment, LeaderSegmentSchema, LeaderSourceSchema, LeaderUnregistrationProtocol, createDoomLeaderContribution, registerDoomLeaderActionHandlers, registerDoomLeaderContribution };
171
+ //# sourceMappingURL=leader.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"leader.d.mts","names":[],"sources":["../src/leader.ts"],"mappings":";;;;cAWa,qBAAmB,KAAA;;;;;;KASpB,gBAAgB,cAAc;cAE7B,qBAAmB,KAAA;;;;KAIpB,gBAAgB,cAAc;cAE7B,oBAAkB,KAAA;QAAlB,KAAA;;KAUD,eAAe,cAAc;cAO5B,qBAAmB,KAAA,QAAA,KAAA;;;;;;;;;;;;;;;;;;;;;;;;KAIpB;EAEN;EACA,gBAAgB,kBAAkB;EAClC,SAAS;;EAGT;EACA,gBAAgB,kBAAkB;EAClC,QAAQ;;cAGD,oBAAkB,KAAA;cAMlB,0BAAwB,KAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;UAOpB;EACf;EACA,mBAAmB;;cAGR,0BAAwB,KAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAKxB,qBAAmB,uBAAA,KAAA;;;;cASnB,mDAA0B,KAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAW1B,qDAA4B,KAAA;;;;;UAqBxB;EACf,OAAO,mBAAmB;EAC1B;;iBAWc,6BACd,IAAI,mBACJ,cAAc,qBACb;iBAsFa,+BAA+B,IAAI,mBAAmB,cAAc;UAKnE;EACf;EACA,UAAU,SAAS,gBAAgB,KAAK,gCAAgC;EACxE,UAAU,gBAAgB,oBAAoB,KAAK;;iBAGrC,iCACd,IAAI,mBACJ,SAAS"}
@@ -0,0 +1,2 @@
1
+ import{DOOM_PROTOCOL_ERROR_CODE as e,DoomProtocolError as t,createProtocolRuntime as n,defineNotification as r,defineRequestReply as i}from"./protocol.mjs";import{Type as a}from"typebox";const o=a.Object({key:a.String({minLength:1,maxLength:1}),label:a.String({minLength:1}),detail:a.Optional(a.String()),order:a.Optional(a.Integer())},{additionalProperties:!1}),s=a.Object({name:a.String({minLength:1}),args:a.Optional(a.String())},{additionalProperties:!1}),c=a.Object({name:a.String({minLength:1,maxLength:128,pattern:`^[a-z0-9][a-z0-9._:-]*$`})},{additionalProperties:!1}),l={id:a.String({minLength:1}),path:a.Array(o,{minItems:1})},u=a.Union([a.Object({...l,command:s},{additionalProperties:!1}),a.Object({...l,action:c},{additionalProperties:!1})]),d=a.String({minLength:1,maxLength:128,pattern:`^[A-Za-z0-9@][A-Za-z0-9@/._:-]*$`}),f=a.Object({source:d,bindings:a.Array(u)},{additionalProperties:!1}),p=a.Object({contribution:f,generation:a.String({minLength:1})},{additionalProperties:!1}),m=r({channel:`doom:ui:leader:v1:action-invoked`,kind:`leader.action-invoked`,payload:a.Object({source:d,action:c.properties.name},{additionalProperties:!1})}),h=i({channels:{request:`doom:ui:leader:v1:register`,response:`doom:ui:leader:v1:registered`,error:`doom:ui:leader:v1:error`},kinds:{request:`leader.register`,response:`leader.registered`},request:p,response:a.Object({handleId:a.String({minLength:1})},{additionalProperties:!1})}),g=i({channels:{request:`doom:ui:leader:v1:unregister`,response:`doom:ui:leader:v1:unregistered`,error:`doom:ui:leader:v1:unregister-error`},kinds:{request:`leader.unregister`,response:`leader.unregistered`},request:a.Object({handleId:a.String({minLength:1})},{additionalProperties:!1}),response:a.Object({removed:a.Boolean()},{additionalProperties:!1})});function _(n){n instanceof t&&n.code===e.timeout||queueMicrotask(()=>{throw n instanceof Error?n:Error(String(n))})}function v(e){return e.map(e=>({id:e.id,path:e.path.map(e=>({...e})),...`command`in e?{command:{...e.command}}:{action:{...e.action}}}))}function y(e,t){let r,i,a=0,o=!1,s=v(t.bindings),c=JSON.stringify(s),l=Promise.resolve(),u=(e,t)=>e.request(g,{handleId:t},{timeoutMs:250}).then(()=>void 0).catch(_),d=()=>{let e=r,t=i;i=void 0,!(!e||!t)&&(l=l.then(()=>u(e,t)))},f=()=>{let e=r;if(!e)return;let n=a,c=s;l=l.then(async()=>{let s=i;i=void 0,s&&await u(e,s);let l=await e.request(h,{contribution:{source:t.source,bindings:c},generation:String(n)},{timeoutMs:250});if(o||a!==n||r!==e){await u(e,l.handleId);return}i=l.handleId}).catch(_)};return e.on(`session_start`,(i,s)=>{o||(d(),a+=1,r=n({bus:e.events,source:t.source,sessionId:s.sessionManager.getSessionId()}),f())}),e.on(`session_shutdown`,()=>{a+=1,d(),r=void 0}),{update(e){if(o)return;let t=v(e),n=JSON.stringify(t);n!==c&&(c=n,s=t,f())},dispose(){o=!0,a+=1,d(),r=void 0}}}function b(e,t){let n=y(e,t);return()=>n.dispose()}function x(e,t){let r,i=0,a=!1;return e.on(`session_start`,(o,s)=>{if(a)return;r?.();let c=++i;r=n({bus:e.events,source:t.source,sessionId:s.sessionManager.getSessionId()}).onNotification(m,async({source:e,action:n},r)=>{if(a||i!==c||r.source!==`@agimon-ai/doompi-ui`||e!==t.source)return;let o=t.handlers[n];if(o)try{await o(s)}catch(e){t.onError(e,n,s)}})}),e.on(`session_shutdown`,()=>{++i,r?.(),r=void 0}),()=>{a=!0,++i,r?.(),r=void 0}}export{m as LeaderActionInvoked,c as LeaderActionSchema,u as LeaderBindingSchema,s as LeaderCommandSchema,f as LeaderContributionSchema,h as LeaderRegistrationProtocol,p as LeaderRegistrationSchema,o as LeaderSegmentSchema,d as LeaderSourceSchema,g as LeaderUnregistrationProtocol,y as createDoomLeaderContribution,x as registerDoomLeaderActionHandlers,b as registerDoomLeaderContribution};
2
+ //# sourceMappingURL=leader.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"leader.mjs","names":[],"sources":["../src/leader.ts"],"sourcesContent":["import { type Static, Type } from 'typebox';\nimport type { DoomExtensionContext, DoomExtensionHost } from './config.ts';\nimport {\n createProtocolRuntime,\n defineNotification,\n defineRequestReply,\n DOOM_PROTOCOL_ERROR_CODE,\n DoomProtocolError,\n type ProtocolRuntime,\n} from './protocol.ts';\n\nexport const LeaderSegmentSchema = Type.Object(\n {\n key: Type.String({ minLength: 1, maxLength: 1 }),\n label: Type.String({ minLength: 1 }),\n detail: Type.Optional(Type.String()),\n order: Type.Optional(Type.Integer()),\n },\n { additionalProperties: false },\n);\nexport type LeaderSegment = Static<typeof LeaderSegmentSchema>;\n\nexport const LeaderCommandSchema = Type.Object(\n { name: Type.String({ minLength: 1 }), args: Type.Optional(Type.String()) },\n { additionalProperties: false },\n);\nexport type LeaderCommand = Static<typeof LeaderCommandSchema>;\n\nexport const LeaderActionSchema = Type.Object(\n {\n name: Type.String({\n minLength: 1,\n maxLength: 128,\n pattern: '^[a-z0-9][a-z0-9._:-]*$',\n }),\n },\n { additionalProperties: false },\n);\nexport type LeaderAction = Static<typeof LeaderActionSchema>;\n\nconst LeaderBindingBase = {\n id: Type.String({ minLength: 1 }),\n path: Type.Array(LeaderSegmentSchema, { minItems: 1 }),\n};\n\nexport const LeaderBindingSchema = Type.Union([\n Type.Object({ ...LeaderBindingBase, command: LeaderCommandSchema }, { additionalProperties: false }),\n Type.Object({ ...LeaderBindingBase, action: LeaderActionSchema }, { additionalProperties: false }),\n]);\nexport type LeaderBinding =\n | {\n id: string;\n path: readonly [LeaderSegment, ...LeaderSegment[]];\n command: LeaderCommand;\n }\n | {\n id: string;\n path: readonly [LeaderSegment, ...LeaderSegment[]];\n action: LeaderAction;\n };\n\nexport const LeaderSourceSchema = Type.String({\n minLength: 1,\n maxLength: 128,\n pattern: '^[A-Za-z0-9@][A-Za-z0-9@/._:-]*$',\n});\n\nexport const LeaderContributionSchema = Type.Object(\n {\n source: LeaderSourceSchema,\n bindings: Type.Array(LeaderBindingSchema),\n },\n { additionalProperties: false },\n);\nexport interface LeaderContribution {\n source: string;\n bindings: readonly LeaderBinding[];\n}\n\nexport const LeaderRegistrationSchema = Type.Object(\n { contribution: LeaderContributionSchema, generation: Type.String({ minLength: 1 }) },\n { additionalProperties: false },\n);\n\nexport const LeaderActionInvoked = defineNotification({\n channel: 'doom:ui:leader:v1:action-invoked',\n kind: 'leader.action-invoked',\n payload: Type.Object(\n { source: LeaderSourceSchema, action: LeaderActionSchema.properties.name },\n { additionalProperties: false },\n ),\n});\n\nexport const LeaderRegistrationProtocol = defineRequestReply({\n channels: {\n request: 'doom:ui:leader:v1:register',\n response: 'doom:ui:leader:v1:registered',\n error: 'doom:ui:leader:v1:error',\n },\n kinds: { request: 'leader.register', response: 'leader.registered' },\n request: LeaderRegistrationSchema,\n response: Type.Object({ handleId: Type.String({ minLength: 1 }) }, { additionalProperties: false }),\n});\n\nexport const LeaderUnregistrationProtocol = defineRequestReply({\n channels: {\n request: 'doom:ui:leader:v1:unregister',\n response: 'doom:ui:leader:v1:unregistered',\n error: 'doom:ui:leader:v1:unregister-error',\n },\n kinds: { request: 'leader.unregister', response: 'leader.unregistered' },\n request: Type.Object({ handleId: Type.String({ minLength: 1 }) }, { additionalProperties: false }),\n response: Type.Object({ removed: Type.Boolean() }, { additionalProperties: false }),\n});\n\nconst LEADER_PROVIDER_TIMEOUT_MS = 250;\nconst DOOM_UI_SOURCE = '@agimon-ai/doompi-ui';\n\nfunction handleOptionalLeaderFailure(error: unknown): void {\n if (error instanceof DoomProtocolError && error.code === DOOM_PROTOCOL_ERROR_CODE.timeout) return;\n queueMicrotask(() => {\n throw error instanceof Error ? error : new Error(String(error));\n });\n}\n\nexport interface DoomLeaderContributionHandle {\n update(bindings: readonly LeaderBinding[]): void;\n dispose(): void;\n}\n\nfunction copyBindings(bindings: readonly LeaderBinding[]) {\n return bindings.map((binding) => ({\n id: binding.id,\n path: binding.path.map((segment) => ({ ...segment })),\n ...('command' in binding ? { command: { ...binding.command } } : { action: { ...binding.action } }),\n }));\n}\n\nexport function createDoomLeaderContribution(\n pi: DoomExtensionHost,\n contribution: LeaderContribution,\n): DoomLeaderContributionHandle {\n let runtime: ProtocolRuntime | undefined;\n let handleId: string | undefined;\n let generation = 0;\n let stopped = false;\n let bindings = copyBindings(contribution.bindings);\n let fingerprint = JSON.stringify(bindings);\n let queue: Promise<void> = Promise.resolve();\n\n const drop = (activeRuntime: ProtocolRuntime, activeHandle: string): Promise<void> =>\n activeRuntime\n .request(LeaderUnregistrationProtocol, { handleId: activeHandle }, { timeoutMs: LEADER_PROVIDER_TIMEOUT_MS })\n .then(() => undefined)\n .catch(handleOptionalLeaderFailure);\n\n const unregister = (): void => {\n const activeRuntime = runtime;\n const activeHandle = handleId;\n handleId = undefined;\n if (!activeRuntime || !activeHandle) return;\n queue = queue.then(() => drop(activeRuntime, activeHandle));\n };\n\n const publish = (): void => {\n const activeRuntime = runtime;\n if (!activeRuntime) return;\n const activeGeneration = generation;\n const activeBindings = bindings;\n queue = queue\n .then(async () => {\n const previous = handleId;\n handleId = undefined;\n if (previous) await drop(activeRuntime, previous);\n const registration = await activeRuntime.request(\n LeaderRegistrationProtocol,\n {\n contribution: { source: contribution.source, bindings: activeBindings },\n generation: String(activeGeneration),\n },\n { timeoutMs: LEADER_PROVIDER_TIMEOUT_MS },\n );\n if (stopped || generation !== activeGeneration || runtime !== activeRuntime) {\n await drop(activeRuntime, registration.handleId);\n return;\n }\n handleId = registration.handleId;\n })\n .catch(handleOptionalLeaderFailure);\n };\n\n pi.on('session_start', (_event, ctx) => {\n if (stopped) return;\n unregister();\n generation += 1;\n runtime = createProtocolRuntime({\n bus: pi.events,\n source: contribution.source,\n sessionId: ctx.sessionManager.getSessionId(),\n });\n publish();\n });\n pi.on('session_shutdown', () => {\n generation += 1;\n unregister();\n runtime = undefined;\n });\n\n return {\n update(nextBindings) {\n if (stopped) return;\n const next = copyBindings(nextBindings);\n const nextFingerprint = JSON.stringify(next);\n if (nextFingerprint === fingerprint) return;\n fingerprint = nextFingerprint;\n bindings = next;\n publish();\n },\n dispose() {\n stopped = true;\n generation += 1;\n unregister();\n runtime = undefined;\n },\n };\n}\n\nexport function registerDoomLeaderContribution(pi: DoomExtensionHost, contribution: LeaderContribution): () => void {\n const handle = createDoomLeaderContribution(pi, contribution);\n return () => handle.dispose();\n}\n\nexport interface DoomLeaderActionHandlerOptions {\n source: string;\n handlers: Readonly<Record<string, (ctx: DoomExtensionContext) => void | Promise<void>>>;\n onError: (error: unknown, actionName: string, ctx: DoomExtensionContext) => void;\n}\n\nexport function registerDoomLeaderActionHandlers(\n pi: DoomExtensionHost,\n options: DoomLeaderActionHandlerOptions,\n): () => void {\n let disposeNotification: (() => void) | undefined;\n let generation = 0;\n let stopped = false;\n\n pi.on('session_start', (_event, ctx) => {\n if (stopped) return;\n disposeNotification?.();\n const activeGeneration = ++generation;\n const runtime = createProtocolRuntime({\n bus: pi.events,\n source: options.source,\n sessionId: ctx.sessionManager.getSessionId(),\n });\n disposeNotification = runtime.onNotification(LeaderActionInvoked, async ({ source, action }, identity) => {\n if (stopped || generation !== activeGeneration) return;\n if (identity.source !== DOOM_UI_SOURCE || source !== options.source) return;\n const handler = options.handlers[action];\n if (!handler) return;\n try {\n await handler(ctx);\n } catch (error) {\n options.onError(error, action, ctx);\n }\n });\n });\n pi.on('session_shutdown', () => {\n ++generation;\n disposeNotification?.();\n disposeNotification = undefined;\n });\n return () => {\n stopped = true;\n ++generation;\n disposeNotification?.();\n disposeNotification = undefined;\n };\n}\n"],"mappings":"2LAWA,MAAa,EAAsB,EAAK,OACtC,CACE,IAAK,EAAK,OAAO,CAAE,UAAW,EAAG,UAAW,CAAE,CAAC,EAC/C,MAAO,EAAK,OAAO,CAAE,UAAW,CAAE,CAAC,EACnC,OAAQ,EAAK,SAAS,EAAK,OAAO,CAAC,EACnC,MAAO,EAAK,SAAS,EAAK,QAAQ,CAAC,CACrC,EACA,CAAE,qBAAsB,EAAM,CAChC,EAGa,EAAsB,EAAK,OACtC,CAAE,KAAM,EAAK,OAAO,CAAE,UAAW,CAAE,CAAC,EAAG,KAAM,EAAK,SAAS,EAAK,OAAO,CAAC,CAAE,EAC1E,CAAE,qBAAsB,EAAM,CAChC,EAGa,EAAqB,EAAK,OACrC,CACE,KAAM,EAAK,OAAO,CAChB,UAAW,EACX,UAAW,IACX,QAAS,yBACX,CAAC,CACH,EACA,CAAE,qBAAsB,EAAM,CAChC,EAGM,EAAoB,C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I,GAAW,IAAe,GAC1B,EAAS,SAAW,wBAAkB,IAAW,EAAQ,OAAQ,OACrE,IAAM,EAAU,EAAQ,SAAS,GAC5B,KACL,GAAI,CACF,MAAM,EAAQ,CAAG,CACnB,OAAS,EAAO,CACd,EAAQ,QAAQ,EAAO,EAAQ,CAAG,CACpC,CACF,CAAC,CACH,CAAC,EACD,EAAG,GAAG,uBAA0B,CAC9B,EAAE,EACF,IAAsB,EACtB,EAAsB,IAAA,EACxB,CAAC,MACY,CACX,EAAU,GACV,EAAE,EACF,IAAsB,EACtB,EAAsB,IAAA,EACxB,CACF"}
@@ -0,0 +1,2 @@
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./protocol.cjs");let t=require("typebox");const n=t.Type.Union([t.Type.Literal(`not-connected`),t.Type.Literal(`connecting`),t.Type.Literal(`connected`),t.Type.Literal(`degraded`),t.Type.Literal(`needs-auth`),t.Type.Literal(`failed`),t.Type.Literal(`closed`),t.Type.Literal(`disabled`)]),r=t.Type.Object({name:t.Type.String({minLength:1,maxLength:128}),state:n,tools:t.Type.Array(t.Type.String({minLength:1})),resourceCount:t.Type.Integer({minimum:0}),error:t.Type.Optional(t.Type.String({maxLength:512}))},{additionalProperties:!1}),i=t.Type.Object({servers:t.Type.Array(r)},{additionalProperties:!1}),a=e.defineRequestReply({channels:{request:`doom:pi:mcp:v1:status-query`,response:`doom:pi:mcp:v1:status`,error:`doom:pi:mcp:v1:status-error`},kinds:{request:`mcp.status.query`,response:`mcp.status`},request:t.Type.Object({},{additionalProperties:!1}),response:i});exports.McpServerSnapshotSchema=r,exports.McpServerStateSchema=n,exports.McpStatusQueryProtocol=a,exports.McpStatusSnapshotSchema=i;
2
+ //# sourceMappingURL=mcpStatus.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mcpStatus.cjs","names":["Type","defineRequestReply"],"sources":["../src/mcpStatus.ts"],"sourcesContent":["import { type Static, Type } from 'typebox';\nimport { defineRequestReply } from './protocol.ts';\n\n/**\n * Connection state of one downstream MCP server.\n *\n * `not-connected` is the startup state: tools restored from the previous run's\n * catalog exist before any socket opens, and their server has not reported yet.\n * `disabled` comes from configuration rather than the connection stream, since a\n * disabled server is never dialled at all.\n */\nexport const McpServerStateSchema = Type.Union([\n Type.Literal('not-connected'),\n Type.Literal('connecting'),\n Type.Literal('connected'),\n Type.Literal('degraded'),\n Type.Literal('needs-auth'),\n Type.Literal('failed'),\n Type.Literal('closed'),\n Type.Literal('disabled'),\n]);\nexport type McpServerState = Static<typeof McpServerStateSchema>;\n\nexport const McpServerSnapshotSchema = Type.Object(\n {\n name: Type.String({ minLength: 1, maxLength: 128 }),\n state: McpServerStateSchema,\n /**\n * Pi tool names registered for this server, exactly as registered.\n *\n * Published rather than derived: a consumer that reverse-engineers the link from\n * tool-name prefixes cannot attribute anything under an unprefixed naming scheme,\n * and guesses wrong whenever two servers share a prefix.\n */\n tools: Type.Array(Type.String({ minLength: 1 })),\n resourceCount: Type.Integer({ minimum: 0 }),\n /** Why the server is in `failed` or `needs-auth`; absent otherwise. */\n error: Type.Optional(Type.String({ maxLength: 512 })),\n },\n { additionalProperties: false },\n);\nexport type McpServerSnapshot = Static<typeof McpServerSnapshotSchema>;\n\nexport const McpStatusSnapshotSchema = Type.Object(\n { servers: Type.Array(McpServerSnapshotSchema) },\n { additionalProperties: false },\n);\nexport type McpStatusSnapshot = Static<typeof McpStatusSnapshotSchema>;\n\n/**\n * The current MCP picture, on request.\n *\n * Pulled rather than pushed. Servers connect long after install and a notification\n * only reaches subscribers that were already listening, so a surface would have to\n * win a race against the provider's own startup to see the first snapshot. Asking\n * when the answer is needed removes the ordering question, and every consumer so\n * far reads this when a panel opens rather than continuously.\n *\n * No provider means MCP is not loaded for this session (`--no-mcp`), which times\n * out and is not an error.\n */\nexport const McpStatusQueryProtocol = defineRequestReply({\n channels: {\n request: 'doom:pi:mcp:v1:status-query',\n response: 'doom:pi:mcp:v1:status',\n error: 'doom:pi:mcp:v1:status-error',\n },\n kinds: { request: 'mcp.status.query', response: 'mcp.status' },\n request: Type.Object({}, { additionalProperties: false }),\n response: McpStatusSnapshotSchema,\n});\n"],"mappings":"8HAWA,MAAa,EAAuBA,EAAAA,KAAK,MAAM,CAC7CA,EAAAA,KAAK,QAAQ,eAAe,EAC5BA,EAAAA,KAAK,QAAQ,YAAY,EACzBA,EAAAA,KAAK,QAAQ,WAAW,EACxBA,EAAAA,KAAK,QAAQ,UAAU,EACvBA,EAAAA,KAAK,QAAQ,YAAY,EACzBA,EAAAA,KAAK,QAAQ,QAAQ,EACrBA,EAAAA,KAAK,QAAQ,QAAQ,EACrBA,EAAAA,KAAK,QAAQ,UAAU,CACzB,CAAC,EAGY,EAA0BA,EAAAA,KAAK,OAC1C,CACE,KAAMA,EAAAA,KAAK,OAAO,CAAE,UAAW,EAAG,UAAW,GAAI,CAAC,EAClD,MAAO,EAQP,MAAOA,EAAAA,KAAK,MAAMA,EAAAA,KAAK,OAAO,CAAE,UAAW,CAAE,CAAC,CAAC,EAC/C,cAAeA,EAAAA,KAAK,QAAQ,CAAE,QAAS,CAAE,CAAC,EAE1C,MAAOA,EAAAA,KAAK,SAASA,EAAAA,KAAK,OAAO,CAAE,UAAW,GAAI,CAAC,CAAC,CACtD,EACA,CAAE,qBAAsB,EAAM,CAChC,EAGa,EAA0BA,EAAAA,KAAK,OAC1C,CAAE,QAASA,EAAAA,KAAK,MAAM,CAAuB,CAAE,EAC/C,CAAE,qBAAsB,EAAM,CAChC,EAea,EAAyBC,EAAAA,mBAAmB,CACvD,SAAU,CACR,QAAS,8BACT,SAAU,wBACV,MAAO,6BACT,EACA,MAAO,CAAE,QAAS,mBAAoB,SAAU,YAAa,EAC7D,QAASD,EAAAA,KAAK,OAAO,CAAC,EAAG,CAAE,qBAAsB,EAAM,CAAC,EACxD,SAAU,CACZ,CAAC"}
@@ -0,0 +1,79 @@
1
+ import { RequestReplyDefinition } from "./protocol.cjs";
2
+ import { Static, Type } from "typebox";
3
+ //#region src/mcpStatus.d.ts
4
+ /**
5
+ * Connection state of one downstream MCP server.
6
+ *
7
+ * `not-connected` is the startup state: tools restored from the previous run's
8
+ * catalog exist before any socket opens, and their server has not reported yet.
9
+ * `disabled` comes from configuration rather than the connection stream, since a
10
+ * disabled server is never dialled at all.
11
+ */
12
+ declare const McpServerStateSchema: Type.TUnion<[Type.TLiteral<"not-connected">, Type.TLiteral<"connecting">, Type.TLiteral<"connected">, Type.TLiteral<"degraded">, Type.TLiteral<"needs-auth">, Type.TLiteral<"failed">, Type.TLiteral<"closed">, Type.TLiteral<"disabled">]>;
13
+ type McpServerState = Static<typeof McpServerStateSchema>;
14
+ declare const McpServerSnapshotSchema: Type.TObject<{
15
+ name: Type.TString;
16
+ state: Type.TUnion<[Type.TLiteral<"not-connected">, Type.TLiteral<"connecting">, Type.TLiteral<"connected">, Type.TLiteral<"degraded">, Type.TLiteral<"needs-auth">, Type.TLiteral<"failed">, Type.TLiteral<"closed">, Type.TLiteral<"disabled">]>;
17
+ /**
18
+ * Pi tool names registered for this server, exactly as registered.
19
+ *
20
+ * Published rather than derived: a consumer that reverse-engineers the link from
21
+ * tool-name prefixes cannot attribute anything under an unprefixed naming scheme,
22
+ * and guesses wrong whenever two servers share a prefix.
23
+ */
24
+ tools: Type.TArray<Type.TString>;
25
+ resourceCount: Type.TInteger;
26
+ /** Why the server is in `failed` or `needs-auth`; absent otherwise. */
27
+ error: Type.TOptional<Type.TString>;
28
+ }>;
29
+ type McpServerSnapshot = Static<typeof McpServerSnapshotSchema>;
30
+ declare const McpStatusSnapshotSchema: Type.TObject<{
31
+ servers: Type.TArray<Type.TObject<{
32
+ name: Type.TString;
33
+ state: Type.TUnion<[Type.TLiteral<"not-connected">, Type.TLiteral<"connecting">, Type.TLiteral<"connected">, Type.TLiteral<"degraded">, Type.TLiteral<"needs-auth">, Type.TLiteral<"failed">, Type.TLiteral<"closed">, Type.TLiteral<"disabled">]>;
34
+ /**
35
+ * Pi tool names registered for this server, exactly as registered.
36
+ *
37
+ * Published rather than derived: a consumer that reverse-engineers the link from
38
+ * tool-name prefixes cannot attribute anything under an unprefixed naming scheme,
39
+ * and guesses wrong whenever two servers share a prefix.
40
+ */
41
+ tools: Type.TArray<Type.TString>;
42
+ resourceCount: Type.TInteger;
43
+ /** Why the server is in `failed` or `needs-auth`; absent otherwise. */
44
+ error: Type.TOptional<Type.TString>;
45
+ }>>;
46
+ }>;
47
+ type McpStatusSnapshot = Static<typeof McpStatusSnapshotSchema>;
48
+ /**
49
+ * The current MCP picture, on request.
50
+ *
51
+ * Pulled rather than pushed. Servers connect long after install and a notification
52
+ * only reaches subscribers that were already listening, so a surface would have to
53
+ * win a race against the provider's own startup to see the first snapshot. Asking
54
+ * when the answer is needed removes the ordering question, and every consumer so
55
+ * far reads this when a panel opens rather than continuously.
56
+ *
57
+ * No provider means MCP is not loaded for this session (`--no-mcp`), which times
58
+ * out and is not an error.
59
+ */
60
+ declare const McpStatusQueryProtocol: RequestReplyDefinition<Type.TObject<{}>, Type.TObject<{
61
+ servers: Type.TArray<Type.TObject<{
62
+ name: Type.TString;
63
+ state: Type.TUnion<[Type.TLiteral<"not-connected">, Type.TLiteral<"connecting">, Type.TLiteral<"connected">, Type.TLiteral<"degraded">, Type.TLiteral<"needs-auth">, Type.TLiteral<"failed">, Type.TLiteral<"closed">, Type.TLiteral<"disabled">]>;
64
+ /**
65
+ * Pi tool names registered for this server, exactly as registered.
66
+ *
67
+ * Published rather than derived: a consumer that reverse-engineers the link from
68
+ * tool-name prefixes cannot attribute anything under an unprefixed naming scheme,
69
+ * and guesses wrong whenever two servers share a prefix.
70
+ */
71
+ tools: Type.TArray<Type.TString>;
72
+ resourceCount: Type.TInteger;
73
+ /** Why the server is in `failed` or `needs-auth`; absent otherwise. */
74
+ error: Type.TOptional<Type.TString>;
75
+ }>>;
76
+ }>>;
77
+ //#endregion
78
+ export { McpServerSnapshot, McpServerSnapshotSchema, McpServerState, McpServerStateSchema, McpStatusQueryProtocol, McpStatusSnapshot, McpStatusSnapshotSchema };
79
+ //# sourceMappingURL=mcpStatus.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mcpStatus.d.cts","names":[],"sources":["../src/mcpStatus.ts"],"mappings":";;;;;;;;;;;cAWa,sBAAoB,KAAA,QAAA,KAAA,2BAAA,KAAA,wBAAA,KAAA,uBAAA,KAAA,sBAAA,KAAA,wBAAA,KAAA,oBAAA,KAAA,oBAAA,KAAA;KAUrB,iBAAiB,cAAc;cAE9B,yBAAuB,KAAA;;;;;;;;;;;;;;;KAkBxB,oBAAoB,cAAc;cAEjC,yBAAuB,KAAA;;;;;;;;;;;;;;;;;KAIxB,oBAAoB,cAAc;;;;;;;;;;;;;cAcjC,wBAAsB,uBAAA,KAAA,aAAA,KAAA"}
@@ -0,0 +1,79 @@
1
+ import { RequestReplyDefinition } from "./protocol.mjs";
2
+ import { Static, Type } from "typebox";
3
+ //#region src/mcpStatus.d.ts
4
+ /**
5
+ * Connection state of one downstream MCP server.
6
+ *
7
+ * `not-connected` is the startup state: tools restored from the previous run's
8
+ * catalog exist before any socket opens, and their server has not reported yet.
9
+ * `disabled` comes from configuration rather than the connection stream, since a
10
+ * disabled server is never dialled at all.
11
+ */
12
+ declare const McpServerStateSchema: Type.TUnion<[Type.TLiteral<"not-connected">, Type.TLiteral<"connecting">, Type.TLiteral<"connected">, Type.TLiteral<"degraded">, Type.TLiteral<"needs-auth">, Type.TLiteral<"failed">, Type.TLiteral<"closed">, Type.TLiteral<"disabled">]>;
13
+ type McpServerState = Static<typeof McpServerStateSchema>;
14
+ declare const McpServerSnapshotSchema: Type.TObject<{
15
+ name: Type.TString;
16
+ state: Type.TUnion<[Type.TLiteral<"not-connected">, Type.TLiteral<"connecting">, Type.TLiteral<"connected">, Type.TLiteral<"degraded">, Type.TLiteral<"needs-auth">, Type.TLiteral<"failed">, Type.TLiteral<"closed">, Type.TLiteral<"disabled">]>;
17
+ /**
18
+ * Pi tool names registered for this server, exactly as registered.
19
+ *
20
+ * Published rather than derived: a consumer that reverse-engineers the link from
21
+ * tool-name prefixes cannot attribute anything under an unprefixed naming scheme,
22
+ * and guesses wrong whenever two servers share a prefix.
23
+ */
24
+ tools: Type.TArray<Type.TString>;
25
+ resourceCount: Type.TInteger;
26
+ /** Why the server is in `failed` or `needs-auth`; absent otherwise. */
27
+ error: Type.TOptional<Type.TString>;
28
+ }>;
29
+ type McpServerSnapshot = Static<typeof McpServerSnapshotSchema>;
30
+ declare const McpStatusSnapshotSchema: Type.TObject<{
31
+ servers: Type.TArray<Type.TObject<{
32
+ name: Type.TString;
33
+ state: Type.TUnion<[Type.TLiteral<"not-connected">, Type.TLiteral<"connecting">, Type.TLiteral<"connected">, Type.TLiteral<"degraded">, Type.TLiteral<"needs-auth">, Type.TLiteral<"failed">, Type.TLiteral<"closed">, Type.TLiteral<"disabled">]>;
34
+ /**
35
+ * Pi tool names registered for this server, exactly as registered.
36
+ *
37
+ * Published rather than derived: a consumer that reverse-engineers the link from
38
+ * tool-name prefixes cannot attribute anything under an unprefixed naming scheme,
39
+ * and guesses wrong whenever two servers share a prefix.
40
+ */
41
+ tools: Type.TArray<Type.TString>;
42
+ resourceCount: Type.TInteger;
43
+ /** Why the server is in `failed` or `needs-auth`; absent otherwise. */
44
+ error: Type.TOptional<Type.TString>;
45
+ }>>;
46
+ }>;
47
+ type McpStatusSnapshot = Static<typeof McpStatusSnapshotSchema>;
48
+ /**
49
+ * The current MCP picture, on request.
50
+ *
51
+ * Pulled rather than pushed. Servers connect long after install and a notification
52
+ * only reaches subscribers that were already listening, so a surface would have to
53
+ * win a race against the provider's own startup to see the first snapshot. Asking
54
+ * when the answer is needed removes the ordering question, and every consumer so
55
+ * far reads this when a panel opens rather than continuously.
56
+ *
57
+ * No provider means MCP is not loaded for this session (`--no-mcp`), which times
58
+ * out and is not an error.
59
+ */
60
+ declare const McpStatusQueryProtocol: RequestReplyDefinition<Type.TObject<{}>, Type.TObject<{
61
+ servers: Type.TArray<Type.TObject<{
62
+ name: Type.TString;
63
+ state: Type.TUnion<[Type.TLiteral<"not-connected">, Type.TLiteral<"connecting">, Type.TLiteral<"connected">, Type.TLiteral<"degraded">, Type.TLiteral<"needs-auth">, Type.TLiteral<"failed">, Type.TLiteral<"closed">, Type.TLiteral<"disabled">]>;
64
+ /**
65
+ * Pi tool names registered for this server, exactly as registered.
66
+ *
67
+ * Published rather than derived: a consumer that reverse-engineers the link from
68
+ * tool-name prefixes cannot attribute anything under an unprefixed naming scheme,
69
+ * and guesses wrong whenever two servers share a prefix.
70
+ */
71
+ tools: Type.TArray<Type.TString>;
72
+ resourceCount: Type.TInteger;
73
+ /** Why the server is in `failed` or `needs-auth`; absent otherwise. */
74
+ error: Type.TOptional<Type.TString>;
75
+ }>>;
76
+ }>>;
77
+ //#endregion
78
+ export { McpServerSnapshot, McpServerSnapshotSchema, McpServerState, McpServerStateSchema, McpStatusQueryProtocol, McpStatusSnapshot, McpStatusSnapshotSchema };
79
+ //# sourceMappingURL=mcpStatus.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mcpStatus.d.mts","names":[],"sources":["../src/mcpStatus.ts"],"mappings":";;;;;;;;;;;cAWa,sBAAoB,KAAA,QAAA,KAAA,2BAAA,KAAA,wBAAA,KAAA,uBAAA,KAAA,sBAAA,KAAA,wBAAA,KAAA,oBAAA,KAAA,oBAAA,KAAA;KAUrB,iBAAiB,cAAc;cAE9B,yBAAuB,KAAA;;;;;;;;;;;;;;;KAkBxB,oBAAoB,cAAc;cAEjC,yBAAuB,KAAA;;;;;;;;;;;;;;;;;KAIxB,oBAAoB,cAAc;;;;;;;;;;;;;cAcjC,wBAAsB,uBAAA,KAAA,aAAA,KAAA"}
@@ -0,0 +1,2 @@
1
+ import{defineRequestReply as e}from"./protocol.mjs";import{Type as t}from"typebox";const n=t.Union([t.Literal(`not-connected`),t.Literal(`connecting`),t.Literal(`connected`),t.Literal(`degraded`),t.Literal(`needs-auth`),t.Literal(`failed`),t.Literal(`closed`),t.Literal(`disabled`)]),r=t.Object({name:t.String({minLength:1,maxLength:128}),state:n,tools:t.Array(t.String({minLength:1})),resourceCount:t.Integer({minimum:0}),error:t.Optional(t.String({maxLength:512}))},{additionalProperties:!1}),i=t.Object({servers:t.Array(r)},{additionalProperties:!1}),a=e({channels:{request:`doom:pi:mcp:v1:status-query`,response:`doom:pi:mcp:v1:status`,error:`doom:pi:mcp:v1:status-error`},kinds:{request:`mcp.status.query`,response:`mcp.status`},request:t.Object({},{additionalProperties:!1}),response:i});export{r as McpServerSnapshotSchema,n as McpServerStateSchema,a as McpStatusQueryProtocol,i as McpStatusSnapshotSchema};
2
+ //# sourceMappingURL=mcpStatus.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mcpStatus.mjs","names":[],"sources":["../src/mcpStatus.ts"],"sourcesContent":["import { type Static, Type } from 'typebox';\nimport { defineRequestReply } from './protocol.ts';\n\n/**\n * Connection state of one downstream MCP server.\n *\n * `not-connected` is the startup state: tools restored from the previous run's\n * catalog exist before any socket opens, and their server has not reported yet.\n * `disabled` comes from configuration rather than the connection stream, since a\n * disabled server is never dialled at all.\n */\nexport const McpServerStateSchema = Type.Union([\n Type.Literal('not-connected'),\n Type.Literal('connecting'),\n Type.Literal('connected'),\n Type.Literal('degraded'),\n Type.Literal('needs-auth'),\n Type.Literal('failed'),\n Type.Literal('closed'),\n Type.Literal('disabled'),\n]);\nexport type McpServerState = Static<typeof McpServerStateSchema>;\n\nexport const McpServerSnapshotSchema = Type.Object(\n {\n name: Type.String({ minLength: 1, maxLength: 128 }),\n state: McpServerStateSchema,\n /**\n * Pi tool names registered for this server, exactly as registered.\n *\n * Published rather than derived: a consumer that reverse-engineers the link from\n * tool-name prefixes cannot attribute anything under an unprefixed naming scheme,\n * and guesses wrong whenever two servers share a prefix.\n */\n tools: Type.Array(Type.String({ minLength: 1 })),\n resourceCount: Type.Integer({ minimum: 0 }),\n /** Why the server is in `failed` or `needs-auth`; absent otherwise. */\n error: Type.Optional(Type.String({ maxLength: 512 })),\n },\n { additionalProperties: false },\n);\nexport type McpServerSnapshot = Static<typeof McpServerSnapshotSchema>;\n\nexport const McpStatusSnapshotSchema = Type.Object(\n { servers: Type.Array(McpServerSnapshotSchema) },\n { additionalProperties: false },\n);\nexport type McpStatusSnapshot = Static<typeof McpStatusSnapshotSchema>;\n\n/**\n * The current MCP picture, on request.\n *\n * Pulled rather than pushed. Servers connect long after install and a notification\n * only reaches subscribers that were already listening, so a surface would have to\n * win a race against the provider's own startup to see the first snapshot. Asking\n * when the answer is needed removes the ordering question, and every consumer so\n * far reads this when a panel opens rather than continuously.\n *\n * No provider means MCP is not loaded for this session (`--no-mcp`), which times\n * out and is not an error.\n */\nexport const McpStatusQueryProtocol = defineRequestReply({\n channels: {\n request: 'doom:pi:mcp:v1:status-query',\n response: 'doom:pi:mcp:v1:status',\n error: 'doom:pi:mcp:v1:status-error',\n },\n kinds: { request: 'mcp.status.query', response: 'mcp.status' },\n request: Type.Object({}, { additionalProperties: false }),\n response: McpStatusSnapshotSchema,\n});\n"],"mappings":"mFAWA,MAAa,EAAuB,EAAK,MAAM,CAC7C,EAAK,QAAQ,eAAe,EAC5B,EAAK,QAAQ,YAAY,EACzB,EAAK,QAAQ,WAAW,EACxB,EAAK,QAAQ,UAAU,EACvB,EAAK,QAAQ,YAAY,EACzB,EAAK,QAAQ,QAAQ,EACrB,EAAK,QAAQ,QAAQ,EACrB,EAAK,QAAQ,UAAU,CACzB,CAAC,EAGY,EAA0B,EAAK,OAC1C,CACE,KAAM,EAAK,OAAO,CAAE,UAAW,EAAG,UAAW,GAAI,CAAC,EAClD,MAAO,EAQP,MAAO,EAAK,MAAM,EAAK,OAAO,CAAE,UAAW,CAAE,CAAC,CAAC,EAC/C,cAAe,EAAK,QAAQ,CAAE,QAAS,CAAE,CAAC,EAE1C,MAAO,EAAK,SAAS,EAAK,OAAO,CAAE,UAAW,GAAI,CAAC,CAAC,CACtD,EACA,CAAE,qBAAsB,EAAM,CAChC,EAGa,EAA0B,EAAK,OAC1C,CAAE,QAAS,EAAK,MAAM,CAAuB,CAAE,EAC/C,CAAE,qBAAsB,EAAM,CAChC,EAea,EAAyB,EAAmB,CACvD,SAAU,CACR,QAAS,8BACT,SAAU,wBACV,MAAO,6BACT,EACA,MAAO,CAAE,QAAS,mBAAoB,SAAU,YAAa,EAC7D,QAAS,EAAK,OAAO,CAAC,EAAG,CAAE,qBAAsB,EAAM,CAAC,EACxD,SAAU,CACZ,CAAC"}
package/dist/mode.cjs ADDED
@@ -0,0 +1,2 @@
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./protocol.cjs");let t=require("typebox");const n=t.Type.Union([t.Type.Literal(`accent`),t.Type.Literal(`warning`),t.Type.Literal(`mdHeading`),t.Type.Literal(`muted`),t.Type.Literal(`dim`)]),r=t.Type.Object({id:t.Type.String({minLength:1,maxLength:128}),label:t.Type.String({minLength:1,maxLength:24}),detail:t.Type.Optional(t.Type.String({minLength:1,maxLength:48})),color:t.Type.Optional(n),order:t.Type.Integer({minimum:0,maximum:1e3})},{additionalProperties:!1}),i=t.Type.Object({source:t.Type.String({minLength:1,maxLength:128}),generation:t.Type.String({minLength:1})},{additionalProperties:!1}),a=t.Type.Object({...i.properties,items:t.Type.Array(r)},{additionalProperties:!1}),o=e.defineNotification({channel:`doom:ui:mode:v1:discover`,kind:`mode-status.discover`,payload:t.Type.Object({},{additionalProperties:!1})}),s=e.defineNotification({channel:`doom:ui:mode:v1:register`,kind:`mode-status.register`,payload:a}),c=e.defineNotification({channel:`doom:ui:mode:v1:changed`,kind:`mode-status.changed`,payload:a}),l=e.defineNotification({channel:`doom:ui:mode:v1:unregister`,kind:`mode-status.unregister`,payload:i});function u(e,t){let n=`${t.source}:${crypto.randomUUID()}`,r=!1,i=()=>({source:t.source,generation:n,items:t.listStatuses().map(e=>({...e}))}),a=()=>{r||e.notify(s,i())},u=e.onNotification(o,a);return a(),{update(){r||e.notify(c,i())},dispose(){r||(r=!0,u(),e.notify(l,{source:t.source,generation:n}))}}}var d=class{sources=new Map;listeners=new Set;bind(e){let t=[e.onNotification(s,e=>this.register(e)),e.onNotification(c,e=>this.update(e)),e.onNotification(l,e=>this.unregister(e))];e.notify(o,{});let n=!1;return()=>{if(!n){n=!0;for(let e of t)e()}}}getStatuses(){return[...this.sources.entries()].flatMap(([e,t])=>t.items.map(t=>({source:e,...t}))).toSorted((e,t)=>e.order-t.order||e.source.localeCompare(t.source)||e.id.localeCompare(t.id))}subscribe(e){return this.listeners.add(e),()=>this.listeners.delete(e)}reset(){this.sources.size!==0&&(this.sources.clear(),this.notify())}register(e){this.sources.set(e.source,{generation:e.generation,items:e.items.map(e=>({...e}))}),this.notify()}update(e){this.sources.get(e.source)?.generation===e.generation&&(this.sources.set(e.source,{generation:e.generation,items:e.items.map(e=>({...e}))}),this.notify())}unregister(e){this.sources.get(e.source)?.generation===e.generation&&(this.sources.delete(e.source),this.notify())}notify(){for(let e of this.listeners)e()}};function f(t,n){let r,i,a=!1,o=()=>{i?.dispose(),i=void 0};return t.on(`session_start`,(s,c)=>{a||(o(),i=u(e.createProtocolRuntime({bus:t.events,source:n.source,sessionId:c.sessionManager.getSessionId()}),{source:n.source,listStatuses:()=>r?[{id:n.id,label:r.label,...r.detail?{detail:r.detail}:{},...r.color?{color:r.color}:{},order:n.order}]:[]}))}),t.on(`session_shutdown`,o),{update(e){a||(r=e?{...e}:void 0,i?.update())},dispose(){a||(a=!0,r=void 0,o())}}}exports.DoomModeStatusRegistry=d,exports.ModeStatusChanged=c,exports.ModeStatusDiscovery=o,exports.ModeStatusItemSchema=r,exports.ModeStatusRegistration=s,exports.ModeStatusUnregistration=l,exports.ModeTextColorSchema=n,exports.registerDoomModeContribution=f,exports.registerModeStatusProvider=u;
2
+ //# sourceMappingURL=mode.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mode.cjs","names":["Type","defineNotification","createProtocolRuntime"],"sources":["../src/mode.ts"],"sourcesContent":["/**\n * Mode banners, contributed by every extension that owns one.\n *\n * Each mode used to paint its own below-editor widget under its own key, which\n * Pi renders on a row of its own: three modes on meant three stacked rows,\n * growing with every mode added. Publishing a label instead lets one renderer\n * put them all on a single wrapped line.\n *\n * Deliberately the same shape as the footer contract next door, since the\n * problem is the same one: several extensions sharing one strip of screen.\n */\n\nimport { type Static, Type } from 'typebox';\nimport type { DoomExtensionHost } from './config.ts';\nimport { createProtocolRuntime, defineNotification, type ProtocolRuntime } from './protocol.ts';\n\nexport const ModeTextColorSchema = Type.Union([\n Type.Literal('accent'),\n Type.Literal('warning'),\n Type.Literal('mdHeading'),\n Type.Literal('muted'),\n Type.Literal('dim'),\n]);\nexport type ModeTextColor = Static<typeof ModeTextColorSchema>;\n\nexport const ModeStatusItemSchema = Type.Object(\n {\n id: Type.String({ minLength: 1, maxLength: 128 }),\n /**\n * The mode's name, and nothing else.\n *\n * Short because the line holds every enabled mode at once: `WORKFLOW`, not\n * `WORKFLOW MODE · ON`. That a label is present at all is what says the mode\n * is on, so an `ON` suffix spends a word restating the line's premise.\n */\n label: Type.String({ minLength: 1, maxLength: 24 }),\n /** Sub-state worth reading, parenthesised by the renderer: `normal - read only`. */\n detail: Type.Optional(Type.String({ minLength: 1, maxLength: 48 })),\n color: Type.Optional(ModeTextColorSchema),\n order: Type.Integer({ minimum: 0, maximum: 1000 }),\n },\n { additionalProperties: false },\n);\nexport type ModeStatusItem = Static<typeof ModeStatusItemSchema>;\n\nconst ModeStatusSourceSchema = Type.Object(\n {\n source: Type.String({ minLength: 1, maxLength: 128 }),\n generation: Type.String({ minLength: 1 }),\n },\n { additionalProperties: false },\n);\n\nconst ModeStatusSnapshotSchema = Type.Object(\n {\n ...ModeStatusSourceSchema.properties,\n items: Type.Array(ModeStatusItemSchema),\n },\n { additionalProperties: false },\n);\nexport type ModeStatusSnapshot = Static<typeof ModeStatusSnapshotSchema>;\nexport type ModeStatusSource = Static<typeof ModeStatusSourceSchema>;\n\nexport const ModeStatusDiscovery = defineNotification({\n channel: 'doom:ui:mode:v1:discover',\n kind: 'mode-status.discover',\n payload: Type.Object({}, { additionalProperties: false }),\n});\n\nexport const ModeStatusRegistration = defineNotification({\n channel: 'doom:ui:mode:v1:register',\n kind: 'mode-status.register',\n payload: ModeStatusSnapshotSchema,\n});\n\nexport const ModeStatusChanged = defineNotification({\n channel: 'doom:ui:mode:v1:changed',\n kind: 'mode-status.changed',\n payload: ModeStatusSnapshotSchema,\n});\n\nexport const ModeStatusUnregistration = defineNotification({\n channel: 'doom:ui:mode:v1:unregister',\n kind: 'mode-status.unregister',\n payload: ModeStatusSourceSchema,\n});\n\nexport interface ModeStatusProvider {\n source: string;\n listStatuses(): readonly ModeStatusItem[];\n}\n\nexport interface ModeStatusProviderHandle {\n update(): void;\n dispose(): void;\n}\n\nexport function registerModeStatusProvider(\n runtime: ProtocolRuntime,\n provider: ModeStatusProvider,\n): ModeStatusProviderHandle {\n const generation = `${provider.source}:${crypto.randomUUID()}`;\n let disposed = false;\n const snapshot = (): ModeStatusSnapshot => ({\n source: provider.source,\n generation,\n items: provider.listStatuses().map((item) => ({ ...item })),\n });\n // A renderer that loads after a provider would otherwise never learn about it,\n // and neither side controls the order extensions load in.\n const announce = (): void => {\n if (!disposed) runtime.notify(ModeStatusRegistration, snapshot());\n };\n const disposeDiscovery = runtime.onNotification(ModeStatusDiscovery, announce);\n announce();\n\n return {\n update() {\n if (!disposed) runtime.notify(ModeStatusChanged, snapshot());\n },\n dispose() {\n if (disposed) return;\n disposed = true;\n disposeDiscovery();\n runtime.notify(ModeStatusUnregistration, { source: provider.source, generation });\n },\n };\n}\n\nconst SESSION_START_EVENT = 'session_start';\nconst SESSION_SHUTDOWN_EVENT = 'session_shutdown';\n\nexport interface DoomModeContributionDefinition {\n source: string;\n id: string;\n order: number;\n}\n\nexport interface DoomModeContributionValue {\n label: string;\n detail?: string;\n color?: ModeTextColor;\n}\n\nexport interface DoomModeContributionHandle {\n update(value: DoomModeContributionValue | undefined): void;\n dispose(): void;\n}\n\nexport interface DoomModeStatus extends ModeStatusItem {\n source: string;\n}\n\ninterface ActiveModeSource {\n generation: string;\n items: ModeStatusItem[];\n}\n\nexport class DoomModeStatusRegistry {\n private readonly sources = new Map<string, ActiveModeSource>();\n private readonly listeners = new Set<() => void>();\n\n bind(runtime: ProtocolRuntime): () => void {\n const disposers = [\n runtime.onNotification(ModeStatusRegistration, (snapshot) => this.register(snapshot)),\n runtime.onNotification(ModeStatusChanged, (snapshot) => this.update(snapshot)),\n runtime.onNotification(ModeStatusUnregistration, (source) => this.unregister(source)),\n ];\n runtime.notify(ModeStatusDiscovery, {});\n let disposed = false;\n return () => {\n if (disposed) return;\n disposed = true;\n for (const dispose of disposers) dispose();\n };\n }\n\n getStatuses(): DoomModeStatus[] {\n return [...this.sources.entries()]\n .flatMap(([source, snapshot]) => snapshot.items.map((item) => ({ source, ...item })))\n .toSorted(\n (left, right) =>\n left.order - right.order || left.source.localeCompare(right.source) || left.id.localeCompare(right.id),\n );\n }\n\n subscribe(listener: () => void): () => void {\n this.listeners.add(listener);\n return () => this.listeners.delete(listener);\n }\n\n reset(): void {\n if (this.sources.size === 0) return;\n this.sources.clear();\n this.notify();\n }\n\n private register(snapshot: ModeStatusSnapshot): void {\n this.sources.set(snapshot.source, {\n generation: snapshot.generation,\n items: snapshot.items.map((item) => ({ ...item })),\n });\n this.notify();\n }\n\n private update(snapshot: ModeStatusSnapshot): void {\n if (this.sources.get(snapshot.source)?.generation !== snapshot.generation) return;\n this.sources.set(snapshot.source, {\n generation: snapshot.generation,\n items: snapshot.items.map((item) => ({ ...item })),\n });\n this.notify();\n }\n\n private unregister(source: ModeStatusSource): void {\n if (this.sources.get(source.source)?.generation !== source.generation) return;\n this.sources.delete(source.source);\n this.notify();\n }\n\n private notify(): void {\n for (const listener of this.listeners) listener();\n }\n}\n\nexport function registerDoomModeContribution(\n pi: DoomExtensionHost,\n definition: DoomModeContributionDefinition,\n): DoomModeContributionHandle {\n let value: DoomModeContributionValue | undefined;\n let provider: ModeStatusProviderHandle | undefined;\n let stopped = false;\n\n const disposeProvider = (): void => {\n provider?.dispose();\n provider = undefined;\n };\n\n pi.on(SESSION_START_EVENT, (_event, ctx) => {\n if (stopped) return;\n disposeProvider();\n const runtime = createProtocolRuntime({\n bus: pi.events,\n source: definition.source,\n sessionId: ctx.sessionManager.getSessionId(),\n });\n provider = registerModeStatusProvider(runtime, {\n source: definition.source,\n listStatuses: () =>\n value\n ? [\n {\n id: definition.id,\n label: value.label,\n ...(value.detail ? { detail: value.detail } : {}),\n ...(value.color ? { color: value.color } : {}),\n order: definition.order,\n },\n ]\n : [],\n });\n });\n\n pi.on(SESSION_SHUTDOWN_EVENT, disposeProvider);\n\n return {\n update(nextValue) {\n if (stopped) return;\n value = nextValue ? { ...nextValue } : undefined;\n provider?.update();\n },\n dispose() {\n if (stopped) return;\n stopped = true;\n value = undefined;\n disposeProvider();\n },\n };\n}\n"],"mappings":"8HAgBA,MAAa,EAAsBA,EAAAA,KAAK,MAAM,CAC5CA,EAAAA,KAAK,QAAQ,QAAQ,EACrBA,EAAAA,KAAK,QAAQ,SAAS,EACtBA,EAAAA,KAAK,QAAQ,WAAW,EACxBA,EAAAA,KAAK,QAAQ,OAAO,EACpBA,EAAAA,KAAK,QAAQ,KAAK,CACpB,CAAC,EAGY,EAAuBA,EAAAA,KAAK,OACvC,CACE,GAAIA,EAAAA,KAAK,OAAO,CAAE,UAAW,EAAG,UAAW,GAAI,CAAC,EAQhD,MAAOA,EAAAA,KAAK,OAAO,CAAE,UAAW,EAAG,UAAW,EAAG,CAAC,EAElD,OAAQA,EAAAA,KAAK,SAASA,EAAAA,KAAK,OAAO,CAAE,UAAW,EAAG,UAAW,EAAG,CAAC,CAAC,EAClE,MAAOA,EAAAA,KAAK,SAAS,CAAmB,EACxC,MAAOA,EAAAA,KAAK,QAAQ,CAAE,QAAS,EAAG,QAAS,GAAK,CAAC,CACnD,EACA,CAAE,qBAAsB,EAAM,CAChC,EAGM,EAAyBA,EAAAA,KAAK,OAClC,C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