@introspection-ai/recipes 0.13.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.
- package/LICENSE +191 -0
- package/README.md +184 -0
- package/dist/agent-tool.d.ts +42 -0
- package/dist/agent-tool.d.ts.map +1 -0
- package/dist/agent-tool.js +159 -0
- package/dist/agent-tool.js.map +1 -0
- package/dist/child-agent-completions.d.ts +61 -0
- package/dist/child-agent-completions.d.ts.map +1 -0
- package/dist/child-agent-completions.js +135 -0
- package/dist/child-agent-completions.js.map +1 -0
- package/dist/child-agent-store.d.ts +48 -0
- package/dist/child-agent-store.d.ts.map +1 -0
- package/dist/child-agent-store.js +98 -0
- package/dist/child-agent-store.js.map +1 -0
- package/dist/child-agent.d.ts +43 -0
- package/dist/child-agent.d.ts.map +1 -0
- package/dist/child-agent.js +268 -0
- package/dist/child-agent.js.map +1 -0
- package/dist/direct-cli.d.ts +9 -0
- package/dist/direct-cli.d.ts.map +1 -0
- package/dist/direct-cli.js +22 -0
- package/dist/direct-cli.js.map +1 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +14 -0
- package/dist/index.js.map +1 -0
- package/dist/inspect.d.ts +26 -0
- package/dist/inspect.d.ts.map +1 -0
- package/dist/inspect.js +70 -0
- package/dist/inspect.js.map +1 -0
- package/dist/interactions.d.ts +204 -0
- package/dist/interactions.d.ts.map +1 -0
- package/dist/interactions.js +358 -0
- package/dist/interactions.js.map +1 -0
- package/dist/mcp-catalog.d.ts +8 -0
- package/dist/mcp-catalog.d.ts.map +1 -0
- package/dist/mcp-catalog.js +60 -0
- package/dist/mcp-catalog.js.map +1 -0
- package/dist/mcp-cli-core.d.ts +79 -0
- package/dist/mcp-cli-core.d.ts.map +1 -0
- package/dist/mcp-cli-core.js +1717 -0
- package/dist/mcp-cli-core.js.map +1 -0
- package/dist/mcp-cli-help.d.ts +2 -0
- package/dist/mcp-cli-help.d.ts.map +1 -0
- package/dist/mcp-cli-help.js +36 -0
- package/dist/mcp-cli-help.js.map +1 -0
- package/dist/mcp-cli-policy.d.ts +17 -0
- package/dist/mcp-cli-policy.d.ts.map +1 -0
- package/dist/mcp-cli-policy.js +230 -0
- package/dist/mcp-cli-policy.js.map +1 -0
- package/dist/mcp-cli.d.ts +3 -0
- package/dist/mcp-cli.d.ts.map +1 -0
- package/dist/mcp-cli.js +33 -0
- package/dist/mcp-cli.js.map +1 -0
- package/dist/mcp-client.d.ts +3 -0
- package/dist/mcp-client.d.ts.map +1 -0
- package/dist/mcp-client.js +86 -0
- package/dist/mcp-client.js.map +1 -0
- package/dist/mcp-command-context.d.ts +13 -0
- package/dist/mcp-command-context.d.ts.map +1 -0
- package/dist/mcp-command-context.js +29 -0
- package/dist/mcp-command-context.js.map +1 -0
- package/dist/mcp-contract.d.ts +16 -0
- package/dist/mcp-contract.d.ts.map +1 -0
- package/dist/mcp-contract.js +306 -0
- package/dist/mcp-contract.js.map +1 -0
- package/dist/mcp-daemon-client.d.ts +10 -0
- package/dist/mcp-daemon-client.d.ts.map +1 -0
- package/dist/mcp-daemon-client.js +119 -0
- package/dist/mcp-daemon-client.js.map +1 -0
- package/dist/mcp-daemon-protocol.d.ts +64 -0
- package/dist/mcp-daemon-protocol.d.ts.map +1 -0
- package/dist/mcp-daemon-protocol.js +6 -0
- package/dist/mcp-daemon-protocol.js.map +1 -0
- package/dist/mcp-daemon.d.ts +3 -0
- package/dist/mcp-daemon.d.ts.map +1 -0
- package/dist/mcp-daemon.js +76880 -0
- package/dist/mcp-daemon.js.map +1 -0
- package/dist/mcp-run-worker.d.ts +2 -0
- package/dist/mcp-run-worker.d.ts.map +1 -0
- package/dist/mcp-run-worker.js +76579 -0
- package/dist/mcp-run-worker.js.map +1 -0
- package/dist/mcp.d.ts +168 -0
- package/dist/mcp.d.ts.map +1 -0
- package/dist/mcp.js +558 -0
- package/dist/mcp.js.map +1 -0
- package/dist/pi-extension.d.ts +30 -0
- package/dist/pi-extension.d.ts.map +1 -0
- package/dist/pi-extension.js +880 -0
- package/dist/pi-extension.js.map +1 -0
- package/dist/provider-env.d.ts +2 -0
- package/dist/provider-env.d.ts.map +1 -0
- package/dist/provider-env.js +21 -0
- package/dist/provider-env.js.map +1 -0
- package/dist/recipe/resolve.d.ts +30 -0
- package/dist/recipe/resolve.d.ts.map +1 -0
- package/dist/recipe/resolve.js +131 -0
- package/dist/recipe/resolve.js.map +1 -0
- package/dist/recipe-agent.d.ts +71 -0
- package/dist/recipe-agent.d.ts.map +1 -0
- package/dist/recipe-agent.js +555 -0
- package/dist/recipe-agent.js.map +1 -0
- package/dist/recipe-extensions.d.ts +9 -0
- package/dist/recipe-extensions.d.ts.map +1 -0
- package/dist/recipe-extensions.js +81 -0
- package/dist/recipe-extensions.js.map +1 -0
- package/dist/recipe-mcp-config.d.ts +15 -0
- package/dist/recipe-mcp-config.d.ts.map +1 -0
- package/dist/recipe-mcp-config.js +82 -0
- package/dist/recipe-mcp-config.js.map +1 -0
- package/dist/recipe-model.d.ts +49 -0
- package/dist/recipe-model.d.ts.map +1 -0
- package/dist/recipe-model.js +299 -0
- package/dist/recipe-model.js.map +1 -0
- package/dist/recipe-package.d.ts +79 -0
- package/dist/recipe-package.d.ts.map +1 -0
- package/dist/recipe-package.js +479 -0
- package/dist/recipe-package.js.map +1 -0
- package/dist/recipe-skills.d.ts +7 -0
- package/dist/recipe-skills.d.ts.map +1 -0
- package/dist/recipe-skills.js +46 -0
- package/dist/recipe-skills.js.map +1 -0
- package/dist/run-controller.d.ts +32 -0
- package/dist/run-controller.d.ts.map +1 -0
- package/dist/run-controller.js +259 -0
- package/dist/run-controller.js.map +1 -0
- package/dist/run.d.ts +28 -0
- package/dist/run.d.ts.map +1 -0
- package/dist/run.js +84 -0
- package/dist/run.js.map +1 -0
- package/dist/session.d.ts +140 -0
- package/dist/session.d.ts.map +1 -0
- package/dist/session.js +363 -0
- package/dist/session.js.map +1 -0
- package/dist/test-utils.d.ts +32 -0
- package/dist/test-utils.d.ts.map +1 -0
- package/dist/test-utils.js +259 -0
- package/dist/test-utils.js.map +1 -0
- package/dist/testing.d.ts +25 -0
- package/dist/testing.d.ts.map +1 -0
- package/dist/testing.js +96 -0
- package/dist/testing.js.map +1 -0
- package/docs/agent-composition.md +196 -0
- package/docs/deployment-configuration.md +65 -0
- package/docs/index.md +49 -0
- package/docs/interactions.md +210 -0
- package/docs/mcp-auth.md +80 -0
- package/docs/mcp-configuration.md +126 -0
- package/docs/migration.md +70 -0
- package/docs/pi-extension.md +97 -0
- package/docs/python-bindings-release.md +47 -0
- package/docs/recipe-evals.md +70 -0
- package/docs/recipe-flow.md +41 -0
- package/docs/recipe-format.md +186 -0
- package/docs/recipe-judges.md +152 -0
- package/docs/runtime-library.md +171 -0
- package/package.json +106 -0
- package/vendor/mcp-client/darwin-arm64/mcp-client +0 -0
- package/vendor/mcp-client/darwin-x64/mcp-client +0 -0
- package/vendor/mcp-client/linux-arm64/mcp-client +0 -0
- package/vendor/mcp-client/linux-x64/mcp-client +0 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to the Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by the Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding any notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
Copyright 2026 Introspection AI Inc.
|
|
180
|
+
|
|
181
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
182
|
+
you may not use this file except in compliance with the License.
|
|
183
|
+
You may obtain a copy of the License at
|
|
184
|
+
|
|
185
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
186
|
+
|
|
187
|
+
Unless required by applicable law or agreed to in writing, software
|
|
188
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
189
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
190
|
+
See the License for the specific language governing permissions and
|
|
191
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
<a href="https://pi.recipes">
|
|
3
|
+
<picture>
|
|
4
|
+
<source media="(prefers-color-scheme: dark)" srcset=".github/images/logo-dark.svg">
|
|
5
|
+
<source media="(prefers-color-scheme: light)" srcset=".github/images/logo-light.svg">
|
|
6
|
+
<img alt="Recipes" src=".github/images/logo-light.svg" width="165">
|
|
7
|
+
</picture>
|
|
8
|
+
</a>
|
|
9
|
+
</div>
|
|
10
|
+
|
|
11
|
+
<h4 align="center">The open package format for complete, portable Pi agents.</h4>
|
|
12
|
+
|
|
13
|
+
<div align="center">
|
|
14
|
+
<a href="https://pi.recipes"><img src="https://img.shields.io/badge/website-pi.recipes-blue" alt="Website"></a>
|
|
15
|
+
<a href="https://github.com/introspection-org/pi-recipes/actions/workflows/ci.yml"><img src="https://github.com/introspection-org/pi-recipes/actions/workflows/ci.yml/badge.svg" alt="CI"></a>
|
|
16
|
+
<a href="https://www.npmjs.com/package/@introspection-ai/recipes"><img src="https://img.shields.io/npm/v/@introspection-ai/recipes?label=npm" alt="npm version"></a>
|
|
17
|
+
<a href="https://crates.io/crates/pi-recipe-check"><img src="https://img.shields.io/crates/v/pi-recipe-check?label=crates.io" alt="crates.io version"></a>
|
|
18
|
+
<a href="https://www.apache.org/licenses/LICENSE-2.0"><img src="https://img.shields.io/badge/license-Apache%202.0-green" alt="License"></a>
|
|
19
|
+
</div>
|
|
20
|
+
|
|
21
|
+
<br>
|
|
22
|
+
|
|
23
|
+
**Everything that makes your agent yours, in one portable package.**
|
|
24
|
+
|
|
25
|
+
A Recipe keeps a complete Pi agent—its instructions, models, tools, skills,
|
|
26
|
+
extensions, subagents, capability policy, and quality definitions—together as
|
|
27
|
+
ordinary source you can inspect, fork, validate, and own.
|
|
28
|
+
|
|
29
|
+
Run the same Recipe locally, on Introspection, or in another compatible Pi
|
|
30
|
+
host. The Recipe is portable; credentials, isolation, persistence, scheduling,
|
|
31
|
+
and deployment remain the host's responsibility.
|
|
32
|
+
|
|
33
|
+
## What Recipes is
|
|
34
|
+
|
|
35
|
+
Recipes has two deliberately small surfaces:
|
|
36
|
+
|
|
37
|
+
1. **The Recipe Format** is the open, Git-native package contract.
|
|
38
|
+
2. **The Recipes runtime library** resolves that package into a live Pi session
|
|
39
|
+
without imposing a server, queue, database, or deployment platform.
|
|
40
|
+
|
|
41
|
+
[Pi](https://pi.dev/docs/latest) is the minimal agent harness. A Recipe packages
|
|
42
|
+
the complete configured agent built on that harness. It is more than a prompt
|
|
43
|
+
template or a collection of Pi resources, but it is not a hosting framework.
|
|
44
|
+
|
|
45
|
+
## Package anatomy
|
|
46
|
+
|
|
47
|
+
```text
|
|
48
|
+
my-recipe/
|
|
49
|
+
├── package.json # identity and Pi resource declarations
|
|
50
|
+
├── SYSTEM.md # optional shared instructions
|
|
51
|
+
├── agents/*.yaml # models, tools, skills, subagents, policy
|
|
52
|
+
├── skills/**/SKILL.md # reusable domain workflows
|
|
53
|
+
├── extensions/*.ts # optional Recipe-owned Pi extensions
|
|
54
|
+
├── judges/*.yaml # optional portable quality definitions
|
|
55
|
+
└── .pi/mcp.local.example.json # optional binding template
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
The normative contract is documented in [Recipe Format](docs/recipe-format.md).
|
|
59
|
+
|
|
60
|
+
## Use a Recipe
|
|
61
|
+
|
|
62
|
+
The [`introspection`](https://github.com/introspection-org/introspection-cli)
|
|
63
|
+
CLI owns the end-to-end local workflow:
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
npm install -g @introspection-ai/cli
|
|
67
|
+
introspection init
|
|
68
|
+
introspection check
|
|
69
|
+
introspection local
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
`introspection init` installs a compatible Pi and Recipes extension when they
|
|
73
|
+
are missing. `introspection local` launches the selected local Recipe directly
|
|
74
|
+
with Pi. It does not require an Introspection login or managed runtime.
|
|
75
|
+
|
|
76
|
+
To install the extension without the Introspection CLI:
|
|
77
|
+
|
|
78
|
+
```bash
|
|
79
|
+
pi install npm:@introspection-ai/recipes
|
|
80
|
+
pi --recipe ./path/to/recipe --agent agent
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
## Embed the runtime
|
|
84
|
+
|
|
85
|
+
Install the library in a Pi host:
|
|
86
|
+
|
|
87
|
+
```bash
|
|
88
|
+
npm install @introspection-ai/recipes
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
Choose the lowest useful layer:
|
|
92
|
+
|
|
93
|
+
```ts
|
|
94
|
+
import { resolveRecipe } from "@introspection-ai/recipes/recipe";
|
|
95
|
+
|
|
96
|
+
const recipe = resolveRecipe({
|
|
97
|
+
recipeDir: "./my-recipe",
|
|
98
|
+
agentName: "agent",
|
|
99
|
+
});
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
```ts
|
|
103
|
+
import { createRecipeSession } from "@introspection-ai/recipes/session";
|
|
104
|
+
|
|
105
|
+
const handle = await createRecipeSession({
|
|
106
|
+
recipeDir: "./my-recipe",
|
|
107
|
+
cwd: "./workspace",
|
|
108
|
+
agentName: "agent",
|
|
109
|
+
credentials,
|
|
110
|
+
mcpBindings,
|
|
111
|
+
sessionManager,
|
|
112
|
+
otel: { tracer, meta: { conversationId } },
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
await handle.session.prompt("Start the task");
|
|
116
|
+
await handle.dispose();
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
```ts
|
|
120
|
+
import { runRecipe } from "@introspection-ai/recipes/run";
|
|
121
|
+
|
|
122
|
+
const result = await runRecipe({
|
|
123
|
+
recipeDir: "./my-recipe",
|
|
124
|
+
cwd: "./workspace",
|
|
125
|
+
prompt: "Produce the report",
|
|
126
|
+
});
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
`createRecipeSession` is the primary host boundary. It owns Recipe semantics
|
|
130
|
+
and Pi session construction. The host still owns task lifecycle, durable state,
|
|
131
|
+
auth, networking, isolation, protocol translation, and deployment.
|
|
132
|
+
|
|
133
|
+
See [Runtime library](docs/runtime-library.md) for the complete API boundary and
|
|
134
|
+
[host conformance](docs/runtime-library.md#host-conformance) for compatibility
|
|
135
|
+
tests.
|
|
136
|
+
|
|
137
|
+
## Public exports
|
|
138
|
+
|
|
139
|
+
- `@introspection-ai/recipes` — core Recipe types and runtime helpers
|
|
140
|
+
- `@introspection-ai/recipes/recipe` — resolve a Recipe into session inputs
|
|
141
|
+
- `@introspection-ai/recipes/session` — create a live Pi Recipe session
|
|
142
|
+
- `@introspection-ai/recipes/run` — execute one Recipe turn
|
|
143
|
+
- `@introspection-ai/recipes/pi-extension` — Pi extension entrypoint
|
|
144
|
+
- `@introspection-ai/recipes/pi` — shared subagent tool and controller types
|
|
145
|
+
- `@introspection-ai/recipes/interactions` — portable user-input and approval contract
|
|
146
|
+
- `@introspection-ai/recipes/inspect` — derive host requirements
|
|
147
|
+
- `@introspection-ai/recipes/test-utils` — host conformance cases
|
|
148
|
+
|
|
149
|
+
The package intentionally has no `recipes` executable and no generic HTTP
|
|
150
|
+
server. The `introspection` CLI owns authoring and local operation. Hosting
|
|
151
|
+
adapters and deployment cookbooks belong outside this runtime package.
|
|
152
|
+
|
|
153
|
+
## Validation
|
|
154
|
+
|
|
155
|
+
The format validator is independently reusable:
|
|
156
|
+
|
|
157
|
+
- [`pi-recipe-check`](https://crates.io/crates/pi-recipe-check) — Rust crate and
|
|
158
|
+
standalone validator
|
|
159
|
+
- [`pi-recipe-check`](https://pypi.org/project/pi-recipe-check/) — Python
|
|
160
|
+
bindings for validating in-memory Recipe snapshots
|
|
161
|
+
|
|
162
|
+
The Introspection CLI embeds the same validation engine used by managed
|
|
163
|
+
deployments.
|
|
164
|
+
|
|
165
|
+
## Documentation
|
|
166
|
+
|
|
167
|
+
- [Recipe Format](docs/recipe-format.md)
|
|
168
|
+
- [Runtime library](docs/runtime-library.md)
|
|
169
|
+
- [Pi extension](docs/pi-extension.md)
|
|
170
|
+
- [Agent composition](docs/agent-composition.md)
|
|
171
|
+
- [Interactions](docs/interactions.md)
|
|
172
|
+
- [MCP configuration](docs/mcp-configuration.md)
|
|
173
|
+
- [Deployment configuration](docs/deployment-configuration.md)
|
|
174
|
+
- [Recipe judges](docs/recipe-judges.md)
|
|
175
|
+
- [Recipe eval declarations](docs/recipe-evals.md)
|
|
176
|
+
- [Migration from `@introspection-ai/pi-recipes`](docs/migration.md)
|
|
177
|
+
|
|
178
|
+
## Contributing
|
|
179
|
+
|
|
180
|
+
Contributions are welcome. See [CONTRIBUTING.md](CONTRIBUTING.md).
|
|
181
|
+
|
|
182
|
+
## License
|
|
183
|
+
|
|
184
|
+
Apache-2.0
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { type ToolDefinition } from "@earendil-works/pi-coding-agent";
|
|
2
|
+
export type AgentRunStatus = "running" | "completed" | "failed" | "interrupted" | "closed";
|
|
3
|
+
export interface AgentNestedToolSummary {
|
|
4
|
+
toolName: string;
|
|
5
|
+
verb: string;
|
|
6
|
+
detail: string;
|
|
7
|
+
toolInput?: Record<string, unknown>;
|
|
8
|
+
}
|
|
9
|
+
export interface AgentRunSummary {
|
|
10
|
+
agent_run_id: string;
|
|
11
|
+
invocation_name: string;
|
|
12
|
+
agent_name: string;
|
|
13
|
+
label: string;
|
|
14
|
+
prompt: string;
|
|
15
|
+
status: AgentRunStatus;
|
|
16
|
+
started_at: number;
|
|
17
|
+
completed_at?: number;
|
|
18
|
+
last_activity_at: number;
|
|
19
|
+
current_tool?: string;
|
|
20
|
+
nested_tools?: AgentNestedToolSummary[];
|
|
21
|
+
output_preview?: string;
|
|
22
|
+
output?: string;
|
|
23
|
+
error?: string;
|
|
24
|
+
}
|
|
25
|
+
export interface AgentRunController {
|
|
26
|
+
list(): AgentRunSummary[];
|
|
27
|
+
get(id: string): AgentRunSummary | null;
|
|
28
|
+
start(input: {
|
|
29
|
+
name: string;
|
|
30
|
+
prompt: string;
|
|
31
|
+
label?: string;
|
|
32
|
+
onUpdate?: (summary: AgentRunSummary) => void | Promise<void>;
|
|
33
|
+
}): Promise<AgentRunSummary>;
|
|
34
|
+
wait(id: string, signal?: AbortSignal): Promise<AgentRunSummary>;
|
|
35
|
+
message(id: string, message: string): Promise<AgentRunSummary>;
|
|
36
|
+
interrupt(id: string): Promise<AgentRunSummary>;
|
|
37
|
+
close(id: string): Promise<AgentRunSummary>;
|
|
38
|
+
}
|
|
39
|
+
export declare function createAgentTool(controller: AgentRunController, agents: ReadonlyMap<string, unknown>, opts?: {
|
|
40
|
+
acknowledgeCompletions?(ids: readonly string[]): void;
|
|
41
|
+
}): ToolDefinition;
|
|
42
|
+
//# sourceMappingURL=agent-tool.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-tool.d.ts","sourceRoot":"","sources":["../src/agent-tool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,KAAK,cAAc,EAAE,MAAM,iCAAiC,CA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W,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC;IACjE,OAAO,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC;IAC/D,SAAS,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC;IAChD,KAAK,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC;CAC7C;AAyED,wBAAgB,eAAe,CAC7B,UAAU,EAAE,kBAAkB,EAC9B,MAAM,EAAE,WAAW,CAAC,MAAM,EAAE,OAAO,CAAC,EACpC,IAAI,GAAE;IAAE,sBAAsB,CAAC,CAAC,GAAG,EAAE,SAAS,MAAM,EAAE,GAAG,IAAI,CAAA;CAAO,GACnE,cAAc,CAuGhB"}
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
import { defineTool } from "@earendil-works/pi-coding-agent";
|
|
2
|
+
import { Type } from "typebox";
|
|
3
|
+
const AgentToolParams = Type.Object({
|
|
4
|
+
action: Type.Optional(Type.Union([
|
|
5
|
+
Type.Literal("start"),
|
|
6
|
+
Type.Literal("status"),
|
|
7
|
+
Type.Literal("wait"),
|
|
8
|
+
Type.Literal("message"),
|
|
9
|
+
Type.Literal("interrupt"),
|
|
10
|
+
Type.Literal("close"),
|
|
11
|
+
])),
|
|
12
|
+
name: Type.Optional(Type.String()),
|
|
13
|
+
prompt: Type.Optional(Type.String()),
|
|
14
|
+
label: Type.Optional(Type.String()),
|
|
15
|
+
id: Type.Optional(Type.String()),
|
|
16
|
+
message: Type.Optional(Type.String()),
|
|
17
|
+
});
|
|
18
|
+
function terminal(run) {
|
|
19
|
+
return run.status !== "running";
|
|
20
|
+
}
|
|
21
|
+
function runLine(run) {
|
|
22
|
+
return `${run.invocation_name} (${run.agent_run_id}) — ${run.label} [${run.status}]`;
|
|
23
|
+
}
|
|
24
|
+
function statusBlock(run) {
|
|
25
|
+
if (!terminal(run))
|
|
26
|
+
return runLine(run);
|
|
27
|
+
const output = run.output?.trim() ||
|
|
28
|
+
(run.error ? `Agent failed: ${run.error}` : `Agent ${run.status}.`);
|
|
29
|
+
return `${runLine(run)}\n${output}`;
|
|
30
|
+
}
|
|
31
|
+
function subtask(run) {
|
|
32
|
+
const nestedTools = [...(run.nested_tools ?? [])];
|
|
33
|
+
if (run.current_tool && !nestedTools.some((tool) => tool.toolName === run.current_tool)) {
|
|
34
|
+
nestedTools.push({ toolName: run.current_tool, verb: run.current_tool, detail: "" });
|
|
35
|
+
}
|
|
36
|
+
return {
|
|
37
|
+
agentName: run.invocation_name,
|
|
38
|
+
label: run.label,
|
|
39
|
+
task: run.prompt,
|
|
40
|
+
nestedTools,
|
|
41
|
+
transcript: run.output_preview
|
|
42
|
+
? [{ type: "assistant", text: run.output_preview }]
|
|
43
|
+
: [],
|
|
44
|
+
status: terminal(run) ? "completed" : "running",
|
|
45
|
+
finishReason: run.status === "completed" ? "stop" : run.error ?? run.status,
|
|
46
|
+
startedAt: run.started_at,
|
|
47
|
+
completedAt: run.completed_at,
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
function result(run, text) {
|
|
51
|
+
return {
|
|
52
|
+
content: [{ type: "text", text }],
|
|
53
|
+
details: { agent: run, subtasks: [subtask(run)] },
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
function errorResult(text, controller) {
|
|
57
|
+
return {
|
|
58
|
+
content: [{ type: "text", text }],
|
|
59
|
+
details: { agents: controller.list() },
|
|
60
|
+
isError: true,
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
export function createAgentTool(controller, agents, opts = {}) {
|
|
64
|
+
const closedRunIds = new Set();
|
|
65
|
+
const acknowledge = (run) => {
|
|
66
|
+
if (terminal(run))
|
|
67
|
+
opts.acknowledgeCompletions?.([run.agent_run_id]);
|
|
68
|
+
};
|
|
69
|
+
return defineTool({
|
|
70
|
+
name: "agent",
|
|
71
|
+
label: "Agent",
|
|
72
|
+
description: [
|
|
73
|
+
"Start or manage background child agents.",
|
|
74
|
+
"Omit action to start one child with name and prompt; it returns a run id immediately.",
|
|
75
|
+
`Available agent roles: ${[...agents.keys()].join(", ")}. Pass a role as name; use label to distinguish concurrent runs.`,
|
|
76
|
+
"Use status, wait, message, interrupt, or close with that id.",
|
|
77
|
+
"Message steers a running child at the next message boundary; on a settled child it resumes the same session.",
|
|
78
|
+
].join(" "),
|
|
79
|
+
parameters: AgentToolParams,
|
|
80
|
+
async execute(_callId, rawParams, signal, onUpdate) {
|
|
81
|
+
const params = rawParams;
|
|
82
|
+
try {
|
|
83
|
+
if (!params.action || params.action === "start") {
|
|
84
|
+
if (!params.name || !params.prompt) {
|
|
85
|
+
return errorResult("Starting an agent requires name and prompt.", controller);
|
|
86
|
+
}
|
|
87
|
+
if (!agents.has(params.name)) {
|
|
88
|
+
return errorResult(`Unknown agent "${params.name}". Available: ${[...agents.keys()].join(", ")}`, controller);
|
|
89
|
+
}
|
|
90
|
+
const run = await controller.start({
|
|
91
|
+
name: params.name,
|
|
92
|
+
prompt: params.prompt,
|
|
93
|
+
label: params.label,
|
|
94
|
+
onUpdate(update) {
|
|
95
|
+
return onUpdate?.({
|
|
96
|
+
content: [{ type: "text", text: "" }],
|
|
97
|
+
details: { subtasks: [subtask(update)] },
|
|
98
|
+
});
|
|
99
|
+
},
|
|
100
|
+
});
|
|
101
|
+
return result(run, `Started ${runLine(run)}`);
|
|
102
|
+
}
|
|
103
|
+
if (params.action === "status" && !params.id) {
|
|
104
|
+
const runs = controller.list();
|
|
105
|
+
runs.forEach(acknowledge);
|
|
106
|
+
return {
|
|
107
|
+
content: [
|
|
108
|
+
{
|
|
109
|
+
type: "text",
|
|
110
|
+
text: runs.length
|
|
111
|
+
? runs.map(statusBlock).join("\n\n")
|
|
112
|
+
: "No agent runs.",
|
|
113
|
+
},
|
|
114
|
+
],
|
|
115
|
+
details: { agents: runs, subtasks: runs.map(subtask) },
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
if (!params.id)
|
|
119
|
+
return errorResult(`${params.action} requires id`, controller);
|
|
120
|
+
if (closedRunIds.has(params.id)) {
|
|
121
|
+
return errorResult(`Agent run already closed: ${params.id}`, controller);
|
|
122
|
+
}
|
|
123
|
+
if (params.action === "status") {
|
|
124
|
+
const run = controller.get(params.id);
|
|
125
|
+
if (!run)
|
|
126
|
+
return errorResult(`Unknown agent run: ${params.id}`, controller);
|
|
127
|
+
acknowledge(run);
|
|
128
|
+
return result(run, statusBlock(run));
|
|
129
|
+
}
|
|
130
|
+
if (params.action === "wait") {
|
|
131
|
+
const run = await controller.wait(params.id, signal);
|
|
132
|
+
acknowledge(run);
|
|
133
|
+
return result(run, statusBlock(run));
|
|
134
|
+
}
|
|
135
|
+
if (params.action === "message") {
|
|
136
|
+
if (!params.message)
|
|
137
|
+
return errorResult("message requires message", controller);
|
|
138
|
+
const run = await controller.message(params.id, params.message);
|
|
139
|
+
return result(run, `Sent message to ${runLine(run)}`);
|
|
140
|
+
}
|
|
141
|
+
if (params.action === "interrupt") {
|
|
142
|
+
const run = await controller.interrupt(params.id);
|
|
143
|
+
if (run.status !== "interrupted") {
|
|
144
|
+
return result(run, `No interrupt sent: ${runLine(run)} is already ${run.status}.`);
|
|
145
|
+
}
|
|
146
|
+
return result(run, `Interrupted ${runLine(run)}`);
|
|
147
|
+
}
|
|
148
|
+
const run = await controller.close(params.id);
|
|
149
|
+
closedRunIds.add(params.id);
|
|
150
|
+
opts.acknowledgeCompletions?.([params.id]);
|
|
151
|
+
return result(run, `Closed ${runLine(run)}`);
|
|
152
|
+
}
|
|
153
|
+
catch (error) {
|
|
154
|
+
return errorResult(`Agent ${params.action ?? "start"} failed: ${error instanceof Error ? error.message : String(error)}`, controller);
|
|
155
|
+
}
|
|
156
|
+
},
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
//# sourceMappingURL=agent-tool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-tool.js","sour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E,UAAU,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;YAC/C,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,OAAO,WAAW,CAChB,SAAS,MAAM,CAAC,MAAM,IAAI,OAAO,YAC/B,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CACvD,EAAE,EACF,UAAU,CACX,CAAC;YACJ,CAAC;QACH,CAAC;KACF,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Child agent-run completion queue.
|
|
3
|
+
*
|
|
4
|
+
* When a background child run settles as `completed`/`failed`, the extension
|
|
5
|
+
* enqueues an envelope here. The registered deliverer — wired up in
|
|
6
|
+
* `pi-extension.ts` — drains the queue into a parent-waking custom message
|
|
7
|
+
* (`pi.sendMessage(..., { triggerTurn: true })`) once the parent session is
|
|
8
|
+
* idle; while the parent is mid-turn the deliverer holds the queue and
|
|
9
|
+
* retries shortly after the `agent_end` boundary poke (a message queued
|
|
10
|
+
* during the turn teardown itself would be stranded on current pi releases).
|
|
11
|
+
*
|
|
12
|
+
* Successes batch briefly so N parallel children produce one notice;
|
|
13
|
+
* failures flush immediately. Runs whose terminal output the model already
|
|
14
|
+
* saw synchronously (`action:"wait"` or a terminal `status` read) are
|
|
15
|
+
* acknowledged out of the queue so nothing is delivered
|
|
16
|
+
* twice.
|
|
17
|
+
*/
|
|
18
|
+
import type { ChildRunSnapshot } from "./child-agent-store.js";
|
|
19
|
+
/** Batching window for successful completions. Failures skip it. */
|
|
20
|
+
export declare const COMPLETION_BATCH_WINDOW_MS = 2000;
|
|
21
|
+
/** Cap on inline output previews; full output stays in status.json. */
|
|
22
|
+
export declare const OUTPUT_PREVIEW_CHARS = 4000;
|
|
23
|
+
export interface ChildCompletionEnvelope {
|
|
24
|
+
id: string;
|
|
25
|
+
agent: string;
|
|
26
|
+
label?: string;
|
|
27
|
+
status: "completed" | "failed";
|
|
28
|
+
output_preview?: string;
|
|
29
|
+
error?: string;
|
|
30
|
+
duration_ms?: number;
|
|
31
|
+
}
|
|
32
|
+
export declare function envelopeFromRun(run: ChildRunSnapshot): ChildCompletionEnvelope | null;
|
|
33
|
+
/**
|
|
34
|
+
* Model-facing notice. The `<agent_run_completions>` wrapper marks it as a
|
|
35
|
+
* runtime notification rather than user input.
|
|
36
|
+
*/
|
|
37
|
+
export declare function renderCompletionNotice(batch: readonly ChildCompletionEnvelope[]): string;
|
|
38
|
+
export declare class ChildCompletionQueue {
|
|
39
|
+
private pending;
|
|
40
|
+
private deliverer;
|
|
41
|
+
private flushTimer;
|
|
42
|
+
private deliveryScheduled;
|
|
43
|
+
setDeliverer(deliverer: (() => void) | null): void;
|
|
44
|
+
enqueue(envelope: ChildCompletionEnvelope): void;
|
|
45
|
+
/**
|
|
46
|
+
* Re-attempt delivery of anything still queued (no-op when empty). Called
|
|
47
|
+
* at the `agent_end` settle boundary: a batch held mid-turn delivers here,
|
|
48
|
+
* bypassing any open batch window.
|
|
49
|
+
*/
|
|
50
|
+
poke(): void;
|
|
51
|
+
/**
|
|
52
|
+
* Drop queued envelopes whose terminal output the model just saw
|
|
53
|
+
* synchronously (wait or terminal status read).
|
|
54
|
+
*/
|
|
55
|
+
acknowledge(ids: readonly string[]): void;
|
|
56
|
+
hasPending(): boolean;
|
|
57
|
+
consumeBatch(): ChildCompletionEnvelope[];
|
|
58
|
+
clear(): void;
|
|
59
|
+
private flushNow;
|
|
60
|
+
}
|
|
61
|
+
//# sourceMappingURL=child-agent-completions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"child-agent-completions.d.ts","sourceRoot":"","sources":["../src/child-agent-completions.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAE/D,oEAAoE;AACpE,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