@stigmer/ink 0.0.88

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 (85) hide show
  1. package/LICENSE +190 -0
  2. package/app/SessionApp.d.ts +42 -0
  3. package/app/SessionApp.d.ts.map +1 -0
  4. package/app/SessionApp.js +38 -0
  5. package/app/SessionApp.js.map +1 -0
  6. package/app/SessionView.d.ts +32 -0
  7. package/app/SessionView.d.ts.map +1 -0
  8. package/app/SessionView.js +58 -0
  9. package/app/SessionView.js.map +1 -0
  10. package/cli/stigmer-ink.d.ts +3 -0
  11. package/cli/stigmer-ink.d.ts.map +1 -0
  12. package/cli/stigmer-ink.js +117 -0
  13. package/cli/stigmer-ink.js.map +1 -0
  14. package/components/ApprovalPrompt.d.ts +21 -0
  15. package/components/ApprovalPrompt.d.ts.map +1 -0
  16. package/components/ApprovalPrompt.js +60 -0
  17. package/components/ApprovalPrompt.js.map +1 -0
  18. package/components/ExecutionProgress.d.ts +16 -0
  19. package/components/ExecutionProgress.d.ts.map +1 -0
  20. package/components/ExecutionProgress.js +47 -0
  21. package/components/ExecutionProgress.js.map +1 -0
  22. package/components/FollowUpInput.d.ts +19 -0
  23. package/components/FollowUpInput.d.ts.map +1 -0
  24. package/components/FollowUpInput.js +27 -0
  25. package/components/FollowUpInput.js.map +1 -0
  26. package/components/MessageEntry.d.ts +18 -0
  27. package/components/MessageEntry.d.ts.map +1 -0
  28. package/components/MessageEntry.js +42 -0
  29. package/components/MessageEntry.js.map +1 -0
  30. package/components/MessageThread.d.ts +31 -0
  31. package/components/MessageThread.d.ts.map +1 -0
  32. package/components/MessageThread.js +146 -0
  33. package/components/MessageThread.js.map +1 -0
  34. package/components/SubAgentBlock.d.ts +19 -0
  35. package/components/SubAgentBlock.d.ts.map +1 -0
  36. package/components/SubAgentBlock.js +73 -0
  37. package/components/SubAgentBlock.js.map +1 -0
  38. package/components/TodoList.d.ts +17 -0
  39. package/components/TodoList.d.ts.map +1 -0
  40. package/components/TodoList.js +43 -0
  41. package/components/TodoList.js.map +1 -0
  42. package/components/ToolCallGroup.d.ts +20 -0
  43. package/components/ToolCallGroup.d.ts.map +1 -0
  44. package/components/ToolCallGroup.js +51 -0
  45. package/components/ToolCallGroup.js.map +1 -0
  46. package/components/ToolCallItem.d.ts +14 -0
  47. package/components/ToolCallItem.d.ts.map +1 -0
  48. package/components/ToolCallItem.js +33 -0
  49. package/components/ToolCallItem.js.map +1 -0
  50. package/components/UsageWidget.d.ts +16 -0
  51. package/components/UsageWidget.d.ts.map +1 -0
  52. package/components/UsageWidget.js +18 -0
  53. package/components/UsageWidget.js.map +1 -0
  54. package/index.d.ts +16 -0
  55. package/index.d.ts.map +1 -0
  56. package/index.js +21 -0
  57. package/index.js.map +1 -0
  58. package/markdown.d.ts +21 -0
  59. package/markdown.d.ts.map +1 -0
  60. package/markdown.js +44 -0
  61. package/markdown.js.map +1 -0
  62. package/package.json +48 -0
  63. package/provider.d.ts +46 -0
  64. package/provider.d.ts.map +1 -0
  65. package/provider.js +33 -0
  66. package/provider.js.map +1 -0
  67. package/src/__tests__/components.test.tsx +162 -0
  68. package/src/__tests__/markdown.test.ts +46 -0
  69. package/src/app/SessionApp.tsx +74 -0
  70. package/src/app/SessionView.tsx +164 -0
  71. package/src/cli/stigmer-ink.tsx +148 -0
  72. package/src/components/ApprovalPrompt.tsx +139 -0
  73. package/src/components/ExecutionProgress.tsx +75 -0
  74. package/src/components/FollowUpInput.tsx +70 -0
  75. package/src/components/MessageEntry.tsx +80 -0
  76. package/src/components/MessageThread.tsx +264 -0
  77. package/src/components/SubAgentBlock.tsx +146 -0
  78. package/src/components/TodoList.tsx +75 -0
  79. package/src/components/ToolCallGroup.tsx +92 -0
  80. package/src/components/ToolCallItem.tsx +74 -0
  81. package/src/components/UsageWidget.tsx +35 -0
  82. package/src/index.ts +28 -0
  83. package/src/markdown.ts +48 -0
  84. package/src/provider.tsx +62 -0
  85. package/src/types/marked-terminal.d.ts +19 -0
package/LICENSE ADDED
@@ -0,0 +1,190 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ Copyright 2026 Stigmer Contributors
179
+
180
+ Licensed under the Apache License, Version 2.0 (the "License");
181
+ you may not use this file except in compliance with the License.
182
+ You may obtain a copy of the License at
183
+
184
+ http://www.apache.org/licenses/LICENSE-2.0
185
+
186
+ Unless required by applicable law or agreed to in writing, software
187
+ distributed under the License is distributed on an "AS IS" BASIS,
188
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
189
+ See the License for the specific language governing permissions and
190
+ limitations under the License.
@@ -0,0 +1,42 @@
1
+ import type { TokenProvider } from "@stigmer/sdk";
2
+ /** Props for {@link SessionApp}. */
3
+ export interface SessionAppProps {
4
+ /** Session ID to display and converse in. */
5
+ readonly sessionId: string;
6
+ /** Organization slug for creating follow-up executions. */
7
+ readonly org: string;
8
+ /** Stigmer API server URL. */
9
+ readonly baseUrl: string;
10
+ /** Static API key for authentication. */
11
+ readonly apiKey?: string;
12
+ /** Dynamic token provider for authentication. */
13
+ readonly getAccessToken?: TokenProvider;
14
+ }
15
+ /**
16
+ * Self-contained top-level Ink application for viewing and
17
+ * interacting with a Stigmer agent session in the terminal.
18
+ *
19
+ * Creates a Node.js-compatible Stigmer client, wraps in
20
+ * `InkStigmerProvider`, and renders a {@link SessionView}.
21
+ *
22
+ * This is the highest-level component — platform builders who
23
+ * need more control should compose {@link InkStigmerProvider},
24
+ * {@link SessionView}, or the individual components directly.
25
+ *
26
+ * @example
27
+ * ```tsx
28
+ * import { render } from "ink";
29
+ * import { SessionApp } from "@stigmer/ink";
30
+ *
31
+ * render(
32
+ * <SessionApp
33
+ * sessionId="ses-abc123"
34
+ * org="my-org"
35
+ * baseUrl="https://api.stigmer.ai"
36
+ * apiKey={process.env.STIGMER_API_KEY}
37
+ * />
38
+ * );
39
+ * ```
40
+ */
41
+ export declare function SessionApp({ sessionId, org, baseUrl, apiKey, getAccessToken, }: SessionAppProps): import("react/jsx-runtime").JSX.Element;
42
+ //# sourceMappingURL=SessionApp.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SessionApp.d.ts","sourceRoot":"","sources":["../../src/app/SessionApp.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAKlD,oCAAoC;AACpC,MAAM,WAAW,eAAe;IAC9B,6CAA6C;IAC7C,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,2DAA2D;IAC3D,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,8BAA8B;IAC9B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,yCAAyC;IACzC,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB,iDAAiD;IACjD,QAAQ,CAAC,cAAc,CAAC,EAAE,aAAa,CAAC;CACzC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAgB,UAAU,CAAC,EACzB,SAAS,EACT,GAAG,EACH,OAAO,EACP,MAAM,EACN,cAAc,GACf,EAAE,eAAe,2CAoBjB"}
@@ -0,0 +1,38 @@
1
+ import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
2
+ import React from "react";
3
+ import { Box, Text } from "ink";
4
+ import { InkStigmerProvider } from "../provider.js";
5
+ import { createNodeClient } from "@stigmer/sdk/node";
6
+ import { SessionView } from "./SessionView.js";
7
+ /**
8
+ * Self-contained top-level Ink application for viewing and
9
+ * interacting with a Stigmer agent session in the terminal.
10
+ *
11
+ * Creates a Node.js-compatible Stigmer client, wraps in
12
+ * `InkStigmerProvider`, and renders a {@link SessionView}.
13
+ *
14
+ * This is the highest-level component — platform builders who
15
+ * need more control should compose {@link InkStigmerProvider},
16
+ * {@link SessionView}, or the individual components directly.
17
+ *
18
+ * @example
19
+ * ```tsx
20
+ * import { render } from "ink";
21
+ * import { SessionApp } from "@stigmer/ink";
22
+ *
23
+ * render(
24
+ * <SessionApp
25
+ * sessionId="ses-abc123"
26
+ * org="my-org"
27
+ * baseUrl="https://api.stigmer.ai"
28
+ * apiKey={process.env.STIGMER_API_KEY}
29
+ * />
30
+ * );
31
+ * ```
32
+ */
33
+ export function SessionApp({ sessionId, org, baseUrl, apiKey, getAccessToken, }) {
34
+ const clientConfig = { baseUrl, apiKey, getAccessToken };
35
+ const client = React.useMemo(() => createNodeClient(clientConfig), [baseUrl, apiKey, getAccessToken]);
36
+ return (_jsx(InkStigmerProvider, { client: client, children: _jsxs(Box, { flexDirection: "column", children: [_jsx(Box, { paddingLeft: 1, paddingBottom: 1, children: _jsxs(Text, { dimColor: true, children: ["Session ", sessionId, " \u00B7 ", org] }) }), _jsx(SessionView, { sessionId: sessionId, org: org })] }) }));
37
+ }
38
+ //# sourceMappingURL=SessionApp.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SessionApp.js","sourceRoot":"","sources":["../../src/app/SessionApp.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC;AAEhC,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,EAAE,gBAAgB,EAAyB,MAAM,mBAAmB,CAAC;AAC5E,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAgB/C;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,MAAM,UAAU,UAAU,CAAC,EACzB,SAAS,EACT,GAAG,EACH,OAAO,EACP,MAAM,EACN,cAAc,GACE;IAChB,MAAM,YAAY,GAAqB,EAAE,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,CAAC;IAE3E,MAAM,MAAM,GAAG,KAAK,CAAC,OAAO,CAC1B,GAAG,EAAE,CAAC,gBAAgB,CAAC,YAAY,CAAC,EACpC,CAAC,OAAO,EAAE,MAAM,EAAE,cAAc,CAAC,CAClC,CAAC;IAEF,OAAO,CACL,KAAC,kBAAkB,IAAC,MAAM,EAAE,MAAM,YAChC,MAAC,GAAG,IAAC,aAAa,EAAC,QAAQ,aACzB,KAAC,GAAG,IAAC,WAAW,EAAE,CAAC,EAAE,aAAa,EAAE,CAAC,YACnC,MAAC,IAAI,IAAC,QAAQ,+BACH,SAAS,cAAK,GAAG,IACrB,GACH,EACN,KAAC,WAAW,IAAC,SAAS,EAAE,SAAS,EAAE,GAAG,EAAE,GAAG,GAAI,IAC3C,GACa,CACtB,CAAC;AACJ,CAAC"}
@@ -0,0 +1,32 @@
1
+ /** Props for {@link SessionView}. */
2
+ export interface SessionViewProps {
3
+ /** Session ID to display and converse in. */
4
+ readonly sessionId: string;
5
+ /** Organization slug for creating follow-up executions. */
6
+ readonly org: string;
7
+ }
8
+ /**
9
+ * Full-featured session conversation view for the terminal.
10
+ *
11
+ * Uses the headless {@link useSessionConversation} hook from
12
+ * `@stigmer/react` to manage the complete conversation lifecycle,
13
+ * then renders the thread and input using Ink terminal components.
14
+ *
15
+ * This is the main composition component that platform builders
16
+ * drop into their Ink apps for a complete agent conversation UI.
17
+ *
18
+ * @example
19
+ * ```tsx
20
+ * import { InkStigmerProvider, createNodeClient, SessionView } from "@stigmer/ink";
21
+ *
22
+ * const client = createNodeClient({ baseUrl: "...", apiKey: "..." });
23
+ *
24
+ * render(
25
+ * <InkStigmerProvider client={client}>
26
+ * <SessionView sessionId="ses-xxx" org="my-org" />
27
+ * </InkStigmerProvider>
28
+ * );
29
+ * ```
30
+ */
31
+ export declare function SessionView({ sessionId, org }: SessionViewProps): import("react/jsx-runtime").JSX.Element;
32
+ //# sourceMappingURL=SessionView.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SessionView.d.ts","sourceRoot":"","sources":["../../src/app/SessionView.tsx"],"names":[],"mappings":"AAUA,qCAAqC;AACrC,MAAM,WAAW,gBAAgB;IAC/B,6CAA6C;IAC7C,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,2DAA2D;IAC3D,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;CACtB;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,WAAW,CAAC,EAAE,SAAS,EAAE,GAAG,EAAE,EAAE,gBAAgB,2CA0H/D"}
@@ -0,0 +1,58 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useState } from "react";
3
+ import { Box, Text, useInput } from "ink";
4
+ import Spinner from "ink-spinner";
5
+ import { useSessionConversation, resolvedSubject, PENDING_SUBJECT } from "@stigmer/react";
6
+ import { MessageThread } from "../components/MessageThread.js";
7
+ import { TodoList } from "../components/TodoList.js";
8
+ import { FollowUpInput } from "../components/FollowUpInput.js";
9
+ import { UsageWidget } from "../components/UsageWidget.js";
10
+ import { ExecutionProgress } from "../components/ExecutionProgress.js";
11
+ /**
12
+ * Full-featured session conversation view for the terminal.
13
+ *
14
+ * Uses the headless {@link useSessionConversation} hook from
15
+ * `@stigmer/react` to manage the complete conversation lifecycle,
16
+ * then renders the thread and input using Ink terminal components.
17
+ *
18
+ * This is the main composition component that platform builders
19
+ * drop into their Ink apps for a complete agent conversation UI.
20
+ *
21
+ * @example
22
+ * ```tsx
23
+ * import { InkStigmerProvider, createNodeClient, SessionView } from "@stigmer/ink";
24
+ *
25
+ * const client = createNodeClient({ baseUrl: "...", apiKey: "..." });
26
+ *
27
+ * render(
28
+ * <InkStigmerProvider client={client}>
29
+ * <SessionView sessionId="ses-xxx" org="my-org" />
30
+ * </InkStigmerProvider>
31
+ * );
32
+ * ```
33
+ */
34
+ export function SessionView({ sessionId, org }) {
35
+ const conv = useSessionConversation(sessionId, org);
36
+ const [expandTools, setExpandTools] = useState(false);
37
+ useInput((input, key) => {
38
+ if (key.ctrl && input === "o") {
39
+ setExpandTools((e) => !e);
40
+ }
41
+ });
42
+ if (conv.isLoading) {
43
+ return (_jsxs(Box, { gap: 1, paddingLeft: 1, children: [_jsx(Text, { color: "cyan", children: _jsx(Spinner, { type: "dots" }) }), _jsx(Text, { children: "Loading session..." })] }));
44
+ }
45
+ if (conv.loadError) {
46
+ return (_jsxs(Box, { flexDirection: "column", paddingLeft: 1, children: [_jsx(Text, { color: "red", bold: true, children: "Failed to load session" }), _jsx(Text, { color: "red", children: conv.loadError.message })] }));
47
+ }
48
+ const allExecutions = [
49
+ ...conv.completedExecutions,
50
+ ...(conv.activeStreamExecution ? [conv.activeStreamExecution] : []),
51
+ ];
52
+ const activeTodos = conv.activeStreamExecution?.status?.todos;
53
+ const contextInfo = conv.activeStreamExecution?.status?.contextInfo;
54
+ const summarizationCount = contextInfo?.summarizationEvents?.length ?? 0;
55
+ const subject = resolvedSubject(conv.session?.spec?.subject);
56
+ return (_jsxs(Box, { flexDirection: "column", children: [subject && subject !== PENDING_SUBJECT && (_jsx(Box, { paddingLeft: 1, marginBottom: 1, children: _jsx(Text, { dimColor: true, bold: true, children: subject }) })), conv.isConnecting && (_jsxs(Box, { gap: 1, paddingLeft: 1, children: [_jsx(Text, { color: "cyan", children: _jsx(Spinner, { type: "dots" }) }), _jsx(Text, { dimColor: true, children: "Connecting to stream..." })] })), conv.streamError && (_jsxs(Box, { flexDirection: "column", paddingLeft: 1, marginBottom: 1, children: [_jsxs(Box, { gap: 1, children: [_jsx(Text, { color: "yellow", bold: true, children: "Stream disconnected" }), _jsx(Text, { dimColor: true, children: "\u2014 reconnecting..." })] }), _jsx(Text, { color: "red", dimColor: true, children: conv.streamError.message })] })), conv.activePhase != null && conv.activePhase !== 0 && (_jsx(ExecutionProgress, { phase: conv.activePhase })), _jsx(MessageThread, { executions: conv.completedExecutions, activeStreamExecution: conv.activeStreamExecution, pendingUserMessage: conv.pendingUserMessage, onApprovalSubmit: conv.submitApproval, submittingApprovalIds: conv.submittingApprovalIds, expandToolCalls: expandTools }), summarizationCount > 0 && (_jsx(Box, { paddingLeft: 1, marginTop: 1, children: _jsxs(Text, { dimColor: true, children: ["Context compacted (", summarizationCount, " ", summarizationCount === 1 ? "event" : "events", ", ", Math.round(contextInfo.utilizationPercent), "% utilization)"] }) })), activeTodos && Object.keys(activeTodos).length > 0 && (_jsx(Box, { marginTop: 1, paddingLeft: 1, children: _jsx(TodoList, { todos: activeTodos }) })), conv.approvalError && (_jsx(Box, { paddingLeft: 1, children: _jsxs(Text, { color: "red", children: ["Approval error: ", conv.approvalError.message] }) })), conv.sendError && (_jsx(Box, { paddingLeft: 1, children: _jsxs(Text, { color: "red", children: ["Send error: ", conv.sendError.message] }) })), _jsx(UsageWidget, { executions: allExecutions }), _jsx(FollowUpInput, { onSubmit: (message) => conv.sendFollowUp(message), isSubmitting: conv.isSending, disabled: !conv.canSendFollowUp })] }));
57
+ }
58
+ //# sourceMappingURL=SessionView.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SessionView.js","sourceRoot":"","sources":["../../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AAM,GAAG,CAAC,IAAI,CACrD,KAAC,GAAG,IAAC,SAAS,EAAE,CAAC,EAAE,WAAW,EAAE,CAAC,YAC/B,KAAC,QAAQ,IAAC,KAAK,EAAE,WAAW,GAAI,GAC5B,CACP,EAEA,IAAI,CAAC,aAAa,IAAI,CACrB,KAAC,GAAG,IAAC,WAAW,EAAE,CAAC,YACjB,MAAC,IAAI,IAAC,KAAK,EAAC,KAAK,iCACE,IAAI,CAAC,aAAa,CAAC,OAAO,IACtC,GACH,CACP,EAEA,IAAI,CAAC,SAAS,IAAI,CACjB,KAAC,GAAG,IAAC,WAAW,EAAE,CAAC,YACjB,MAAC,IAAI,IAAC,KAAK,EAAC,KAAK,6BACF,IAAI,CAAC,SAAS,CAAC,OAAO,IAC9B,GACH,CACP,EAED,KAAC,WAAW,IAAC,UAAU,EAAE,aAAa,GAAI,EAE1C,KAAC,aAAa,IACZ,QAAQ,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,EACjD,YAAY,EAAE,IAAI,CAAC,SAAS,EAC5B,QAAQ,EAAE,CAAC,IAAI,CAAC,eAAe,GAC/B,IACE,CACP,CAAC;AACJ,CAAC"}
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env tsx
2
+ export {};
3
+ //# sourceMappingURL=stigmer-ink.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stigmer-ink.d.ts","sourceRoot":"","sources":["../../src/cli/stigmer-ink.tsx"],"names":[],"mappings":""}
@@ -0,0 +1,117 @@
1
+ #!/usr/bin/env tsx
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ import { Readable } from "node:stream";
4
+ import { render } from "ink";
5
+ import { SessionApp } from "../app/SessionApp.js";
6
+ function parseArgs(argv) {
7
+ const args = argv.slice(2);
8
+ const config = {};
9
+ for (let i = 0; i < args.length; i++) {
10
+ switch (args[i]) {
11
+ case "--session":
12
+ case "-s":
13
+ config.sessionId = args[++i];
14
+ break;
15
+ case "--org":
16
+ case "-o":
17
+ config.org = args[++i];
18
+ break;
19
+ case "--base-url":
20
+ case "-u":
21
+ config.baseUrl = args[++i];
22
+ break;
23
+ case "--api-key":
24
+ case "-k":
25
+ config.apiKey = args[++i];
26
+ break;
27
+ case "--help":
28
+ case "-h":
29
+ printUsage();
30
+ process.exit(0);
31
+ default:
32
+ if (args[i].startsWith("-")) {
33
+ console.error(`Unknown option: ${args[i]}`);
34
+ printUsage();
35
+ process.exit(1);
36
+ }
37
+ }
38
+ }
39
+ config.baseUrl ??= process.env.STIGMER_BASE_URL;
40
+ config.apiKey ??= process.env.STIGMER_API_KEY;
41
+ if (!config.sessionId || !config.org || !config.baseUrl) {
42
+ return null;
43
+ }
44
+ return config;
45
+ }
46
+ async function readStdinJson() {
47
+ if (process.stdin.isTTY)
48
+ return null;
49
+ return new Promise((resolve) => {
50
+ let data = "";
51
+ process.stdin.setEncoding("utf8");
52
+ process.stdin.on("data", (chunk) => (data += chunk));
53
+ process.stdin.on("end", () => {
54
+ try {
55
+ const parsed = JSON.parse(data);
56
+ if (parsed.sessionId && parsed.org && parsed.baseUrl) {
57
+ resolve(parsed);
58
+ }
59
+ else {
60
+ resolve(null);
61
+ }
62
+ }
63
+ catch {
64
+ resolve(null);
65
+ }
66
+ });
67
+ setTimeout(() => resolve(null), 1000);
68
+ });
69
+ }
70
+ function printUsage() {
71
+ console.log(`
72
+ stigmer-ink — Terminal session viewer for the Stigmer platform
73
+
74
+ Usage:
75
+ stigmer-ink --session <id> --org <slug> [options]
76
+ echo '{"sessionId":"...","org":"...","baseUrl":"..."}' | stigmer-ink
77
+
78
+ Options:
79
+ -s, --session <id> Session ID (required)
80
+ -o, --org <slug> Organization slug (required)
81
+ -u, --base-url <url> Stigmer API URL (or STIGMER_BASE_URL env)
82
+ -k, --api-key <key> API key (or STIGMER_API_KEY env)
83
+ -h, --help Show this help message
84
+
85
+ Environment:
86
+ STIGMER_BASE_URL Default API server URL
87
+ STIGMER_API_KEY Default API key
88
+ `);
89
+ }
90
+ async function main() {
91
+ let config = parseArgs(process.argv);
92
+ if (!config) {
93
+ config = await readStdinJson();
94
+ }
95
+ if (!config) {
96
+ console.error("Error: --session, --org, and --base-url are required.\n" +
97
+ "Run with --help for usage information.");
98
+ process.exit(1);
99
+ }
100
+ const isTTY = Boolean(process.stdin.isTTY);
101
+ const stdin = isTTY
102
+ ? process.stdin
103
+ : new Readable({ read() { } });
104
+ const instance = render(_jsx(SessionApp, { sessionId: config.sessionId, org: config.org, baseUrl: config.baseUrl, apiKey: config.apiKey }), { stdin, exitOnCtrlC: isTTY, debug: !isTTY });
105
+ const cleanup = () => {
106
+ instance.unmount();
107
+ process.exit(0);
108
+ };
109
+ process.on("SIGINT", cleanup);
110
+ process.on("SIGTERM", cleanup);
111
+ await instance.waitUntilExit();
112
+ }
113
+ main().catch((err) => {
114
+ console.error("Fatal error:", err);
115
+ process.exit(1);
116
+ });
117
+ //# sourceMappingURL=stigmer-ink.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stigmer-ink.js","sourceRoot":"","sources":["../../src/cli/stigmer-ink.tsx"],"names":[],"mappings":";;AAGA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,MAAM,EAAE,MAAM,KAAK,CAAC;AAC7B,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AASlD,SAAS,SAAS,CAAC,IAAc;IAC/B,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IAC3B,MAAM,MAAM,GAAuB,EAAE,CAAC;IAEtC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACrC,QAAQ,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC;YAChB,KAAK,WAAW,CAAC;YACjB,KAAK,IAAI;gBACP,MAAM,CAAC,SAAS,GAAG,IAAI,CAA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AC,CAAC;IAClB,CAAC;IAED,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IAC3C,MAAM,KAAK,GAAG,KAAK;QACjB,CAAC,CAAC,OAAO,CAAC,KAAK;QACf,CAAC,CAAC,IAAI,QAAQ,CAAC,EAAE,IAAI,KAAI,CAAC,EAAE,CAAiC,CAAC;IAEhE,MAAM,QAAQ,GAAG,MAAM,CACrB,KAAC,UAAU,IACT,SAAS,EAAE,MAAM,CAAC,SAAS,EAC3B,GAAG,EAAE,MAAM,CAAC,GAAG,EACf,OAAO,EAAE,MAAM,CAAC,OAAO,EACvB,MAAM,EAAE,MAAM,CAAC,MAAM,GACrB,EACF,EAAE,KAAK,EAAE,WAAW,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,KAAK,EAAE,CAC7C,CAAC;IAEF,MAAM,OAAO,GAAG,GAAG,EAAE;QACnB,QAAQ,CAAC,OAAO,EAAE,CAAC;QACnB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC,CAAC;IAEF,OAAO,CAAC,EAAE,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;IAC9B,OAAO,CAAC,EAAE,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;IAE/B,MAAM,QAAQ,CAAC,aAAa,EAAE,CAAC;AACjC,CAAC;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;IACnB,OAAO,CAAC,KAAK,CAAC,cAAc,EAAE,GAAG,CAAC,CAAC;IACnC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
@@ -0,0 +1,21 @@
1
+ import type { PendingApproval } from "@stigmer/protos/ai/stigmer/agentic/agentexecution/v1/approval_pb";
2
+ import { ApprovalAction } from "@stigmer/protos/ai/stigmer/agentic/agentexecution/v1/enum_pb";
3
+ /** Props for {@link ApprovalPrompt}. */
4
+ export interface ApprovalPromptProps {
5
+ /** The pending approval request to render. */
6
+ readonly pendingApproval: PendingApproval;
7
+ /** Called when the user selects an action. */
8
+ readonly onSubmit: (action: ApprovalAction) => void;
9
+ /** Disables input while an approval submission is in flight. */
10
+ readonly isSubmitting?: boolean;
11
+ }
12
+ /**
13
+ * HITL approval prompt for tool call authorization.
14
+ *
15
+ * Displays the tool name and args preview, then presents
16
+ * Approve/Reject/Skip options navigable via arrow keys or
17
+ * shortcut keys (y/n/s). Press Enter to confirm the highlighted
18
+ * selection.
19
+ */
20
+ export declare function ApprovalPrompt({ pendingApproval, onSubmit, isSubmitting, }: ApprovalPromptProps): import("react/jsx-runtime").JSX.Element;
21
+ //# sourceMappingURL=ApprovalPrompt.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ApprovalPrompt.d.ts","sourceRoot":"","sources":["../../src/components/ApprovalPrompt.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kEAAkE,CAAC;AACxG,OAAO,EAAE,cAAc,EAAE,MAAM,8DAA8D,CAAC;AAE9F,wCAAwC;AACxC,MAAM,WAAW,mBAAmB;IAClC,8CAA8C;IAC9C,QAAQ,CAAC,eAAe,EAAE,eAAe,CAAC;IAC1C,8CAA8C;IAC9C,QAAQ,CAAC,QAAQ,EAAE,CAAC,MAAM,EAAE,cAAc,KAAK,IAAI,CAAC;IACpD,gEAAgE;IAChE,QAAQ,CAAC,YAAY,CAAC,EAAE,OAAO,CAAC;CACjC;AA8BD;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAAC,EAC7B,eAAe,EACf,QAAQ,EACR,YAAoB,GACrB,EAAE,mBAAmB,2CAmFrB"}
@@ -0,0 +1,60 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useState } from "react";
3
+ import { Box, Text, useInput } from "ink";
4
+ import { ApprovalAction } from "@stigmer/protos/ai/stigmer/agentic/agentexecution/v1/enum_pb";
5
+ const OPTIONS = [
6
+ {
7
+ label: "Approve",
8
+ action: ApprovalAction.APPROVE,
9
+ color: "green",
10
+ shortcut: "y",
11
+ },
12
+ {
13
+ label: "Reject",
14
+ action: ApprovalAction.REJECT,
15
+ color: "red",
16
+ shortcut: "n",
17
+ },
18
+ {
19
+ label: "Skip",
20
+ action: ApprovalAction.SKIP,
21
+ color: "yellow",
22
+ shortcut: "s",
23
+ },
24
+ ];
25
+ /**
26
+ * HITL approval prompt for tool call authorization.
27
+ *
28
+ * Displays the tool name and args preview, then presents
29
+ * Approve/Reject/Skip options navigable via arrow keys or
30
+ * shortcut keys (y/n/s). Press Enter to confirm the highlighted
31
+ * selection.
32
+ */
33
+ export function ApprovalPrompt({ pendingApproval, onSubmit, isSubmitting = false, }) {
34
+ const [selectedIndex, setSelectedIndex] = useState(0);
35
+ useInput((input, key) => {
36
+ if (isSubmitting)
37
+ return;
38
+ if (key.upArrow || key.leftArrow) {
39
+ setSelectedIndex((i) => (i > 0 ? i - 1 : OPTIONS.length - 1));
40
+ }
41
+ else if (key.downArrow || key.rightArrow) {
42
+ setSelectedIndex((i) => (i < OPTIONS.length - 1 ? i + 1 : 0));
43
+ }
44
+ else if (key.return) {
45
+ onSubmit(OPTIONS[selectedIndex].action);
46
+ }
47
+ else {
48
+ const shortcutMatch = OPTIONS.findIndex((o) => o.shortcut === input.toLowerCase());
49
+ if (shortcutMatch >= 0) {
50
+ onSubmit(OPTIONS[shortcutMatch].action);
51
+ }
52
+ }
53
+ });
54
+ const serverSlug = pendingApproval.mcpServerSlug;
55
+ const toolLabel = serverSlug
56
+ ? `${serverSlug}/${pendingApproval.toolName}`
57
+ : pendingApproval.toolName;
58
+ return (_jsxs(Box, { flexDirection: "column", paddingLeft: 2, paddingTop: 1, paddingBottom: 1, borderStyle: "round", borderColor: "yellow", children: [_jsxs(Box, { gap: 1, children: [_jsx(Text, { color: "yellow", bold: true, children: "\u26A0 Approval required" }), pendingApproval.fromSubAgent && (_jsxs(Text, { dimColor: true, children: ["via ", pendingApproval.subAgentSubject || pendingApproval.subAgentName] }))] }), _jsxs(Box, { paddingLeft: 2, marginTop: 1, flexDirection: "column", children: [_jsxs(Box, { gap: 1, children: [_jsx(Text, { dimColor: true, children: "Tool:" }), _jsx(Text, { bold: true, children: toolLabel })] }), pendingApproval.argsPreview && (_jsxs(Box, { gap: 1, children: [_jsx(Text, { dimColor: true, children: "Args:" }), _jsx(Text, { wrap: "truncate-end", children: pendingApproval.argsPreview })] }))] }), _jsx(Box, { gap: 2, marginTop: 1, paddingLeft: 2, children: OPTIONS.map((opt, idx) => (_jsxs(Text, { color: idx === selectedIndex ? opt.color : undefined, dimColor: idx !== selectedIndex, bold: idx === selectedIndex, children: [idx === selectedIndex ? "▸ " : " ", "[", opt.shortcut, "] ", opt.label] }, opt.shortcut))) }), isSubmitting && (_jsx(Box, { paddingLeft: 2, marginTop: 1, children: _jsx(Text, { dimColor: true, children: "Submitting..." }) }))] }));
59
+ }
60
+ //# sourceMappingURL=ApprovalPrompt.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ApprovalPrompt.js","sourceRoot":"","sources":["../../src/components/ApprovalPrompt.tsx"],"names":[],"mappings":";AAAA,OAAc,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACxC,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,KAAK,CAAC;AAE1C,OAAO,EAAE,cAAc,EAAE,MAAM,8DAA8D,CAAC;AAmB9F,MAAM,OAAO,GAA4B;IACvC;QACE,KAAK,EAAE,SAAS;QAChB,MAAM,EAAE,cAAc,CAAC,OAAO;QAC9B,KAAK,EAAE,OAAO;QACd,QAAQ,EAAE,GAAG;KACd;IACD;QACE,KAAK,EAAE,QAAQ;QACf,MAAM,EAAE,cAAc,CAAC,MAAM;QAC7B,KAAK,EAAE,KAAK;QACZ,QAAQ,EAAE,GAAG;KACd;IACD;QACE,KAAK,EAAE,MAAM;QACb,MAAM,EAAE,cAAc,CAAC,IAA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,MAAC,IAAI,IAEH,KAAK,EAAE,GAAG,KAAK,aAAa,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,EACpD,QAAQ,EAAE,GAAG,KAAK,aAAa,EAC/B,IAAI,EAAE,GAAG,KAAK,aAAa,aAE1B,GAAG,KAAK,aAAa,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,OAClC,GAAG,CAAC,QAAQ,QAAI,GAAG,CAAC,KAAK,KANtB,GAAG,CAAC,QAAQ,CAOZ,CACR,CAAC,GACE,EAEL,YAAY,IAAI,CACf,KAAC,GAAG,IAAC,WAAW,EAAE,CAAC,EAAE,SAAS,EAAE,CAAC,YAC/B,KAAC,IAAI,IAAC,QAAQ,oCAAqB,GAC/B,CACP,IACG,CACP,CAAC;AACJ,CAAC"}
@@ -0,0 +1,16 @@
1
+ import { ExecutionPhase } from "@stigmer/protos/ai/stigmer/agentic/agentexecution/v1/enum_pb";
2
+ /** Props for {@link ExecutionProgress}. */
3
+ export interface ExecutionProgressProps {
4
+ /** Current execution phase. */
5
+ readonly phase: ExecutionPhase;
6
+ }
7
+ /**
8
+ * Displays the current execution phase as a compact terminal badge.
9
+ *
10
+ * Shows a spinner for active phases (pending, in-progress) and
11
+ * static indicators for terminal phases.
12
+ *
13
+ * Renders nothing for unspecified phases.
14
+ */
15
+ export declare function ExecutionProgress({ phase }: ExecutionProgressProps): import("react/jsx-runtime").JSX.Element | null;
16
+ //# sourceMappingURL=ExecutionProgress.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ExecutionProgress.d.ts","sourceRoot":"","sources":["../../src/components/ExecutionProgress.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,cAAc,EAAE,MAAM,8DAA8D,CAAC;AAE9F,2CAA2C;AAC3C,MAAM,WAAW,sBAAsB;IACrC,+BAA+B;IAC/B,QAAQ,CAAC,KAAK,EAAE,cAAc,CAAC;CAChC;AAqCD;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAAC,EAAE,KAAK,EAAE,EAAE,sBAAsB,kDAoBlE"}