@noetic-tools/core 0.0.1
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 +201 -0
- package/README.md +38 -0
- package/dist/adapters/in-memory-fs-adapter.d.ts +3 -0
- package/dist/adapters/in-memory-fs-adapter.js +245 -0
- package/dist/adapters/in-memory-shell-adapter.d.ts +9 -0
- package/dist/adapters/in-memory-shell-adapter.js +20 -0
- package/dist/adapters/in-memory-subprocess-adapter.d.ts +5 -0
- package/dist/adapters/in-memory-subprocess-adapter.js +126 -0
- package/dist/adapters/local-fs-adapter.d.ts +3 -0
- package/dist/adapters/local-fs-adapter.js +43 -0
- package/dist/adapters/local-shell-adapter.d.ts +51 -0
- package/dist/adapters/local-shell-adapter.js +167 -0
- package/dist/adapters/local-subprocess-adapter.d.ts +16 -0
- package/dist/adapters/local-subprocess-adapter.js +187 -0
- package/dist/adapters/openrouter.d.ts +57 -0
- package/dist/adapters/openrouter.js +248 -0
- package/dist/builders/channel-builder.d.ts +36 -0
- package/dist/builders/channel-builder.js +15 -0
- package/dist/builders/control-flow-builders.d.ts +79 -0
- package/dist/builders/control-flow-builders.js +53 -0
- package/dist/builders/every.d.ts +45 -0
- package/dist/builders/every.js +60 -0
- package/dist/builders/layer-provides-builders.d.ts +32 -0
- package/dist/builders/layer-provides-builders.js +33 -0
- package/dist/builders/loop-builder.d.ts +23 -0
- package/dist/builders/loop-builder.js +46 -0
- package/dist/builders/memory-builder.d.ts +11 -0
- package/dist/builders/memory-builder.js +15 -0
- package/dist/builders/provide-builder.d.ts +20 -0
- package/dist/builders/provide-builder.js +34 -0
- package/dist/builders/spawn-builder.d.ts +20 -0
- package/dist/builders/spawn-builder.js +33 -0
- package/dist/builders/step-builders.d.ts +62 -0
- package/dist/builders/step-builders.js +99 -0
- package/dist/builders/tool-builder.d.ts +52 -0
- package/dist/builders/tool-builder.js +59 -0
- package/dist/conditions/conditions.d.ts +114 -0
- package/dist/conditions/conditions.js +271 -0
- package/dist/conditions/cosine-similarity.d.ts +11 -0
- package/dist/conditions/cosine-similarity.js +28 -0
- package/dist/conditions/index.d.ts +3 -0
- package/dist/conditions/index.js +2 -0
- package/dist/errors/noetic-config-error.d.ts +41 -0
- package/dist/errors/noetic-config-error.js +44 -0
- package/dist/errors/noetic-error.d.ts +18 -0
- package/dist/errors/noetic-error.js +52 -0
- package/dist/index.d.ts +152 -0
- package/dist/index.js +112 -0
- package/dist/internal-test.d.ts +11 -0
- package/dist/internal-test.js +11 -0
- package/dist/interpreter/clone-guard.d.ts +4 -0
- package/dist/interpreter/clone-guard.js +18 -0
- package/dist/interpreter/collect-tools.d.ts +12 -0
- package/dist/interpreter/collect-tools.js +70 -0
- package/dist/interpreter/execute-branch.d.ts +3 -0
- package/dist/interpreter/execute-branch.js +10 -0
- package/dist/interpreter/execute-every.d.ts +15 -0
- package/dist/interpreter/execute-every.js +143 -0
- package/dist/interpreter/execute-fork.d.ts +3 -0
- package/dist/interpreter/execute-fork.js +215 -0
- package/dist/interpreter/execute-llm.d.ts +4 -0
- package/dist/interpreter/execute-llm.js +217 -0
- package/dist/interpreter/execute-loop.d.ts +3 -0
- package/dist/interpreter/execute-loop.js +171 -0
- package/dist/interpreter/execute-provide.d.ts +10 -0
- package/dist/interpreter/execute-provide.js +64 -0
- package/dist/interpreter/execute-run.d.ts +3 -0
- package/dist/interpreter/execute-run.js +39 -0
- package/dist/interpreter/execute-spawn.d.ts +11 -0
- package/dist/interpreter/execute-spawn.js +113 -0
- package/dist/interpreter/execute-tool.d.ts +5 -0
- package/dist/interpreter/execute-tool.js +81 -0
- package/dist/interpreter/execute.d.ts +14 -0
- package/dist/interpreter/execute.js +119 -0
- package/dist/interpreter/framework-cast.d.ts +10 -0
- package/dist/interpreter/framework-cast.js +16 -0
- package/dist/interpreter/message-helpers.d.ts +9 -0
- package/dist/interpreter/message-helpers.js +42 -0
- package/dist/interpreter/typeguards.d.ts +25 -0
- package/dist/interpreter/typeguards.js +50 -0
- package/dist/memory/budget.d.ts +23 -0
- package/dist/memory/budget.js +117 -0
- package/dist/memory/function-call-utils.d.ts +6 -0
- package/dist/memory/function-call-utils.js +25 -0
- package/dist/memory/layer-api.d.ts +14 -0
- package/dist/memory/layer-api.js +91 -0
- package/dist/memory/layer-lifecycle.d.ts +160 -0
- package/dist/memory/layer-lifecycle.js +552 -0
- package/dist/memory/layer-usage.d.ts +15 -0
- package/dist/memory/layer-usage.js +48 -0
- package/dist/memory/layers/durable-task-state.d.ts +79 -0
- package/dist/memory/layers/durable-task-state.js +118 -0
- package/dist/memory/layers/file-reference.d.ts +55 -0
- package/dist/memory/layers/file-reference.js +538 -0
- package/dist/memory/layers/history-window.d.ts +29 -0
- package/dist/memory/layers/history-window.js +114 -0
- package/dist/memory/layers/observational-memory.d.ts +53 -0
- package/dist/memory/layers/observational-memory.js +110 -0
- package/dist/memory/layers/plan.d.ts +55 -0
- package/dist/memory/layers/plan.js +369 -0
- package/dist/memory/layers/static-content.d.ts +27 -0
- package/dist/memory/layers/static-content.js +35 -0
- package/dist/memory/layers/steering.d.ts +51 -0
- package/dist/memory/layers/steering.js +258 -0
- package/dist/memory/layers/tool-memory-layer.d.ts +16 -0
- package/dist/memory/layers/tool-memory-layer.js +43 -0
- package/dist/memory/layers/working-memory.d.ts +44 -0
- package/dist/memory/layers/working-memory.js +92 -0
- package/dist/memory/projector.d.ts +10 -0
- package/dist/memory/projector.js +19 -0
- package/dist/memory/scope.d.ts +3 -0
- package/dist/memory/scope.js +31 -0
- package/dist/memory/strip-unresolved.d.ts +13 -0
- package/dist/memory/strip-unresolved.js +35 -0
- package/dist/observability/genai-attributes.d.ts +11 -0
- package/dist/observability/genai-attributes.js +12 -0
- package/dist/observability/span-impl.d.ts +20 -0
- package/dist/observability/span-impl.js +33 -0
- package/dist/observability/trace-exporter.d.ts +15 -0
- package/dist/observability/trace-exporter.js +26 -0
- package/dist/patterns/flow.d.ts +52 -0
- package/dist/patterns/flow.js +103 -0
- package/dist/patterns/interview.d.ts +53 -0
- package/dist/patterns/interview.js +113 -0
- package/dist/patterns/plans.d.ts +45 -0
- package/dist/patterns/plans.js +125 -0
- package/dist/patterns/ralph-wiggum.d.ts +20 -0
- package/dist/patterns/ralph-wiggum.js +37 -0
- package/dist/patterns/react.d.ts +18 -0
- package/dist/patterns/react.js +39 -0
- package/dist/portable.d.ts +26 -0
- package/dist/portable.js +34 -0
- package/dist/runtime/agent-harness.d.ts +206 -0
- package/dist/runtime/agent-harness.js +1170 -0
- package/dist/runtime/broadcaster-utils.d.ts +30 -0
- package/dist/runtime/broadcaster-utils.js +53 -0
- package/dist/runtime/channel-store.d.ts +18 -0
- package/dist/runtime/channel-store.js +187 -0
- package/dist/runtime/context-impl.d.ts +80 -0
- package/dist/runtime/context-impl.js +140 -0
- package/dist/runtime/cwd-helpers.d.ts +42 -0
- package/dist/runtime/cwd-helpers.js +68 -0
- package/dist/runtime/detached-handle.d.ts +14 -0
- package/dist/runtime/detached-handle.js +56 -0
- package/dist/runtime/event-broadcaster.d.ts +61 -0
- package/dist/runtime/event-broadcaster.js +187 -0
- package/dist/runtime/exec-context-factory.d.ts +25 -0
- package/dist/runtime/exec-context-factory.js +30 -0
- package/dist/runtime/in-memory-storage.d.ts +9 -0
- package/dist/runtime/in-memory-storage.js +33 -0
- package/dist/runtime/item-log-impl.d.ts +11 -0
- package/dist/runtime/item-log-impl.js +25 -0
- package/dist/runtime/message-queue.d.ts +30 -0
- package/dist/runtime/message-queue.js +46 -0
- package/dist/runtime/session-runner.d.ts +77 -0
- package/dist/runtime/session-runner.js +253 -0
- package/dist/runtime/session-streams.d.ts +11 -0
- package/dist/runtime/session-streams.js +204 -0
- package/dist/runtime/tool-memory.d.ts +6 -0
- package/dist/runtime/tool-memory.js +22 -0
- package/dist/schemas/item.d.ts +35 -0
- package/dist/schemas/item.js +155 -0
- package/dist/types/channel.d.ts +29 -0
- package/dist/types/channel.js +1 -0
- package/dist/types/common.d.ts +111 -0
- package/dist/types/common.js +1 -0
- package/dist/types/context.d.ts +93 -0
- package/dist/types/context.js +1 -0
- package/dist/types/detached.d.ts +17 -0
- package/dist/types/detached.js +7 -0
- package/dist/types/embed.d.ts +5 -0
- package/dist/types/embed.js +1 -0
- package/dist/types/error.d.ts +51 -0
- package/dist/types/error.js +1 -0
- package/dist/types/fs-adapter.d.ts +51 -0
- package/dist/types/fs-adapter.js +3 -0
- package/dist/types/harness-result.d.ts +43 -0
- package/dist/types/harness-result.js +2 -0
- package/dist/types/items.d.ts +115 -0
- package/dist/types/items.js +2 -0
- package/dist/types/memory.d.ts +336 -0
- package/dist/types/memory.js +13 -0
- package/dist/types/mutable-context.d.ts +13 -0
- package/dist/types/mutable-context.js +1 -0
- package/dist/types/observability.d.ts +30 -0
- package/dist/types/observability.js +1 -0
- package/dist/types/runtime.d.ts +255 -0
- package/dist/types/runtime.js +1 -0
- package/dist/types/shell-adapter.d.ts +34 -0
- package/dist/types/shell-adapter.js +10 -0
- package/dist/types/steering.d.ts +89 -0
- package/dist/types/steering.js +14 -0
- package/dist/types/step.d.ts +206 -0
- package/dist/types/step.js +1 -0
- package/dist/types/subprocess-adapter.d.ts +41 -0
- package/dist/types/subprocess-adapter.js +1 -0
- package/dist/types/tool-context.d.ts +34 -0
- package/dist/types/tool-context.js +1 -0
- package/dist/unstable.d.ts +28 -0
- package/dist/unstable.js +24 -0
- package/dist/until/combinators.d.ts +17 -0
- package/dist/until/combinators.js +49 -0
- package/dist/until/never.d.ts +9 -0
- package/dist/until/never.js +12 -0
- package/dist/until/predicates.d.ts +43 -0
- package/dist/until/predicates.js +126 -0
- package/package.json +81 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
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 describing the origin of the Work and
|
|
141
|
+
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 Support. While redistributing the Work or
|
|
166
|
+
Derivative Works thereof, You may choose to offer, and charge a
|
|
167
|
+
fee for, acceptance of support, warranty, indemnity, or other
|
|
168
|
+
liability obligations and/or rights consistent with this License.
|
|
169
|
+
However, in accepting such obligations, You may act only on Your
|
|
170
|
+
own behalf and on Your sole responsibility, not on behalf of any
|
|
171
|
+
other Contributor, and only if You agree to indemnify, defend,
|
|
172
|
+
and hold each Contributor harmless for any liability incurred by,
|
|
173
|
+
or claims asserted against, such Contributor by reason of your
|
|
174
|
+
accepting any such warranty or support.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright 2026 Matt Apperson
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
200
|
+
implied. See the License for the specific language governing
|
|
201
|
+
permissions and limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# @noetic-tools/core
|
|
2
|
+
|
|
3
|
+
Core primitives for the [Noetic](https://github.com/mattapperson/noetic) agent framework: step types, the interpreter, the runtime, the memory layer contract, and built-in patterns.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @noetic-tools/core @openrouter/agent zod
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
`@openrouter/agent` is an optional peer dependency — required only if you use the OpenRouter adapter. `zod` is required.
|
|
12
|
+
|
|
13
|
+
## Quick start
|
|
14
|
+
|
|
15
|
+
```ts
|
|
16
|
+
import { AgentHarness, step } from '@noetic-tools/core';
|
|
17
|
+
|
|
18
|
+
const harness = new AgentHarness({
|
|
19
|
+
model: 'anthropic/claude-sonnet-4',
|
|
20
|
+
llm: { apiKey: process.env.OPENROUTER_API_KEY },
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
const greet = step.llm({
|
|
24
|
+
id: 'greet',
|
|
25
|
+
prompt: ({ input }) => `Say hi to ${input}.`,
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
const result = await harness.run(greet, 'Sam');
|
|
29
|
+
console.log(result.output);
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Documentation
|
|
33
|
+
|
|
34
|
+
Full docs, specs, and examples live in the [main repo](https://github.com/mattapperson/noetic).
|
|
35
|
+
|
|
36
|
+
## License
|
|
37
|
+
|
|
38
|
+
Apache-2.0
|
|
@@ -0,0 +1,245 @@
|
|
|
1
|
+
import { frameworkCast } from '../interpreter/framework-cast';
|
|
2
|
+
function normalizePath(path) {
|
|
3
|
+
const raw = path.trim();
|
|
4
|
+
if (raw.length === 0) {
|
|
5
|
+
return '/';
|
|
6
|
+
}
|
|
7
|
+
const absolute = raw.startsWith('/') ? raw : `/${raw}`;
|
|
8
|
+
const parts = [];
|
|
9
|
+
for (const part of absolute.split('/')) {
|
|
10
|
+
if (part.length === 0 || part === '.') {
|
|
11
|
+
continue;
|
|
12
|
+
}
|
|
13
|
+
if (part === '..') {
|
|
14
|
+
parts.pop();
|
|
15
|
+
continue;
|
|
16
|
+
}
|
|
17
|
+
parts.push(part);
|
|
18
|
+
}
|
|
19
|
+
return `/${parts.join('/')}`;
|
|
20
|
+
}
|
|
21
|
+
function parentPath(path) {
|
|
22
|
+
const normalized = normalizePath(path);
|
|
23
|
+
if (normalized === '/') {
|
|
24
|
+
return '/';
|
|
25
|
+
}
|
|
26
|
+
const idx = normalized.lastIndexOf('/');
|
|
27
|
+
return idx <= 0 ? '/' : normalized.slice(0, idx);
|
|
28
|
+
}
|
|
29
|
+
function basename(path) {
|
|
30
|
+
const normalized = normalizePath(path);
|
|
31
|
+
if (normalized === '/') {
|
|
32
|
+
return '';
|
|
33
|
+
}
|
|
34
|
+
const idx = normalized.lastIndexOf('/');
|
|
35
|
+
return normalized.slice(idx + 1);
|
|
36
|
+
}
|
|
37
|
+
function statsFor(entry) {
|
|
38
|
+
return {
|
|
39
|
+
size: entry.kind === 'file' ? entry.bytes.byteLength : 0,
|
|
40
|
+
isDirectory: () => entry.kind === 'dir',
|
|
41
|
+
isSymbolicLink: () => false,
|
|
42
|
+
isFile: () => entry.kind === 'file',
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
function cloneBytes(bytes) {
|
|
46
|
+
return bytes.slice();
|
|
47
|
+
}
|
|
48
|
+
function toUint8Array(content) {
|
|
49
|
+
if (typeof content === 'string') {
|
|
50
|
+
return new TextEncoder().encode(content);
|
|
51
|
+
}
|
|
52
|
+
if (content instanceof ArrayBuffer) {
|
|
53
|
+
return new Uint8Array(content);
|
|
54
|
+
}
|
|
55
|
+
return new Uint8Array(content.buffer, content.byteOffset, content.byteLength);
|
|
56
|
+
}
|
|
57
|
+
function asBuffer(bytes) {
|
|
58
|
+
const maybeBuffer = frameworkCast(globalThis);
|
|
59
|
+
if (maybeBuffer.Buffer) {
|
|
60
|
+
return maybeBuffer.Buffer.from(bytes);
|
|
61
|
+
}
|
|
62
|
+
return frameworkCast(cloneBytes(bytes));
|
|
63
|
+
}
|
|
64
|
+
function ensureDirSync(entries, path) {
|
|
65
|
+
const normalized = normalizePath(path);
|
|
66
|
+
if (entries.has(normalized)) {
|
|
67
|
+
const existing = entries.get(normalized);
|
|
68
|
+
if (existing.kind !== 'dir') {
|
|
69
|
+
throw new Error(`ENOTDIR: not a directory, mkdir '${normalized}'`);
|
|
70
|
+
}
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
if (normalized !== '/') {
|
|
74
|
+
ensureDirSync(entries, parentPath(normalized));
|
|
75
|
+
}
|
|
76
|
+
entries.set(normalized, {
|
|
77
|
+
kind: 'dir',
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
//#endregion
|
|
81
|
+
//#region Public API
|
|
82
|
+
/** @public Create a process-local, POSIX-like in-memory filesystem adapter. */
|
|
83
|
+
export function createInMemoryFsAdapter(seed) {
|
|
84
|
+
const entries = new Map([
|
|
85
|
+
[
|
|
86
|
+
'/',
|
|
87
|
+
{
|
|
88
|
+
kind: 'dir',
|
|
89
|
+
},
|
|
90
|
+
],
|
|
91
|
+
]);
|
|
92
|
+
async function ensureDir(path) {
|
|
93
|
+
ensureDirSync(entries, path);
|
|
94
|
+
}
|
|
95
|
+
function requireEntry(path) {
|
|
96
|
+
const normalized = normalizePath(path);
|
|
97
|
+
const entry = entries.get(normalized);
|
|
98
|
+
if (!entry) {
|
|
99
|
+
throw new Error(`ENOENT: no such file or directory, '${normalized}'`);
|
|
100
|
+
}
|
|
101
|
+
return entry;
|
|
102
|
+
}
|
|
103
|
+
async function writeBytes(path, bytes) {
|
|
104
|
+
const normalized = normalizePath(path);
|
|
105
|
+
await ensureDir(parentPath(normalized));
|
|
106
|
+
entries.set(normalized, {
|
|
107
|
+
kind: 'file',
|
|
108
|
+
bytes: cloneBytes(bytes),
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
const adapter = {
|
|
112
|
+
async readFile(path) {
|
|
113
|
+
const entry = requireEntry(path);
|
|
114
|
+
if (entry.kind !== 'file') {
|
|
115
|
+
throw new Error(`EISDIR: illegal operation on a directory, read '${normalizePath(path)}'`);
|
|
116
|
+
}
|
|
117
|
+
return asBuffer(entry.bytes);
|
|
118
|
+
},
|
|
119
|
+
async readFileText(path) {
|
|
120
|
+
const entry = requireEntry(path);
|
|
121
|
+
if (entry.kind !== 'file') {
|
|
122
|
+
throw new Error(`EISDIR: illegal operation on a directory, read '${normalizePath(path)}'`);
|
|
123
|
+
}
|
|
124
|
+
return new TextDecoder().decode(entry.bytes);
|
|
125
|
+
},
|
|
126
|
+
async writeFile(path, content) {
|
|
127
|
+
await writeBytes(path, new TextEncoder().encode(content));
|
|
128
|
+
},
|
|
129
|
+
async writeFileBytes(path, content) {
|
|
130
|
+
await writeBytes(path, toUint8Array(content));
|
|
131
|
+
},
|
|
132
|
+
async appendFile(path, content) {
|
|
133
|
+
const normalized = normalizePath(path);
|
|
134
|
+
const next = new TextEncoder().encode(content);
|
|
135
|
+
const current = entries.get(normalized);
|
|
136
|
+
if (!current) {
|
|
137
|
+
await writeBytes(normalized, next);
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
if (current.kind !== 'file') {
|
|
141
|
+
throw new Error(`EISDIR: illegal operation on a directory, append '${normalized}'`);
|
|
142
|
+
}
|
|
143
|
+
const combined = new Uint8Array(current.bytes.byteLength + next.byteLength);
|
|
144
|
+
combined.set(current.bytes);
|
|
145
|
+
combined.set(next, current.bytes.byteLength);
|
|
146
|
+
entries.set(normalized, {
|
|
147
|
+
kind: 'file',
|
|
148
|
+
bytes: combined,
|
|
149
|
+
});
|
|
150
|
+
},
|
|
151
|
+
mkdir: ensureDir,
|
|
152
|
+
async rename(oldPath, newPath) {
|
|
153
|
+
const oldNormalized = normalizePath(oldPath);
|
|
154
|
+
const newNormalized = normalizePath(newPath);
|
|
155
|
+
const entry = requireEntry(oldNormalized);
|
|
156
|
+
await ensureDir(parentPath(newNormalized));
|
|
157
|
+
entries.set(newNormalized, entry.kind === 'file'
|
|
158
|
+
? {
|
|
159
|
+
...entry,
|
|
160
|
+
bytes: cloneBytes(entry.bytes),
|
|
161
|
+
}
|
|
162
|
+
: entry);
|
|
163
|
+
entries.delete(oldNormalized);
|
|
164
|
+
if (entry.kind === 'dir') {
|
|
165
|
+
for (const [path, child] of [
|
|
166
|
+
...entries,
|
|
167
|
+
]) {
|
|
168
|
+
if (path.startsWith(`${oldNormalized}/`)) {
|
|
169
|
+
const moved = `${newNormalized}${path.slice(oldNormalized.length)}`;
|
|
170
|
+
entries.set(moved, child.kind === 'file'
|
|
171
|
+
? {
|
|
172
|
+
...child,
|
|
173
|
+
bytes: cloneBytes(child.bytes),
|
|
174
|
+
}
|
|
175
|
+
: child);
|
|
176
|
+
entries.delete(path);
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
},
|
|
181
|
+
async rm(path, options) {
|
|
182
|
+
const normalized = normalizePath(path);
|
|
183
|
+
const entry = entries.get(normalized);
|
|
184
|
+
if (!entry) {
|
|
185
|
+
if (options?.force) {
|
|
186
|
+
return;
|
|
187
|
+
}
|
|
188
|
+
throw new Error(`ENOENT: no such file or directory, rm '${normalized}'`);
|
|
189
|
+
}
|
|
190
|
+
if (entry.kind === 'dir') {
|
|
191
|
+
const children = [
|
|
192
|
+
...entries.keys(),
|
|
193
|
+
].filter((p) => p.startsWith(`${normalized}/`));
|
|
194
|
+
if (children.length > 0 && !options?.recursive) {
|
|
195
|
+
throw new Error(`ENOTEMPTY: directory not empty, rm '${normalized}'`);
|
|
196
|
+
}
|
|
197
|
+
for (const child of children) {
|
|
198
|
+
entries.delete(child);
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
if (normalized !== '/') {
|
|
202
|
+
entries.delete(normalized);
|
|
203
|
+
}
|
|
204
|
+
},
|
|
205
|
+
async access(path) {
|
|
206
|
+
requireEntry(path);
|
|
207
|
+
},
|
|
208
|
+
async stat(path) {
|
|
209
|
+
return statsFor(requireEntry(path));
|
|
210
|
+
},
|
|
211
|
+
async lstat(path) {
|
|
212
|
+
return statsFor(requireEntry(path));
|
|
213
|
+
},
|
|
214
|
+
async readdir(path) {
|
|
215
|
+
const normalized = normalizePath(path);
|
|
216
|
+
const entry = requireEntry(normalized);
|
|
217
|
+
if (entry.kind !== 'dir') {
|
|
218
|
+
throw new Error(`ENOTDIR: not a directory, scandir '${normalized}'`);
|
|
219
|
+
}
|
|
220
|
+
const prefix = normalized === '/' ? '/' : `${normalized}/`;
|
|
221
|
+
const names = new Set();
|
|
222
|
+
for (const key of entries.keys()) {
|
|
223
|
+
if (key === normalized || !key.startsWith(prefix)) {
|
|
224
|
+
continue;
|
|
225
|
+
}
|
|
226
|
+
const rest = key.slice(prefix.length);
|
|
227
|
+
if (rest.length > 0 && !rest.includes('/')) {
|
|
228
|
+
names.add(basename(key));
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
return [
|
|
232
|
+
...names,
|
|
233
|
+
].sort();
|
|
234
|
+
},
|
|
235
|
+
};
|
|
236
|
+
for (const [path, content] of Object.entries(seed ?? {})) {
|
|
237
|
+
ensureDirSync(entries, parentPath(path));
|
|
238
|
+
entries.set(normalizePath(path), {
|
|
239
|
+
kind: 'file',
|
|
240
|
+
bytes: toUint8Array(content),
|
|
241
|
+
});
|
|
242
|
+
}
|
|
243
|
+
return adapter;
|
|
244
|
+
}
|
|
245
|
+
//#endregion
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ShellAdapter } from '../types/shell-adapter';
|
|
2
|
+
/**
|
|
3
|
+
* @public Create a portable shell adapter that does not execute host processes.
|
|
4
|
+
*
|
|
5
|
+
* This is the runtime default for portable harnesses. Hosts that want real
|
|
6
|
+
* process execution should pass an explicit local, Worker, container, or
|
|
7
|
+
* just-bash-backed adapter.
|
|
8
|
+
*/
|
|
9
|
+
export declare function createInMemoryShellAdapter(): ShellAdapter;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
//#region Public API
|
|
2
|
+
/**
|
|
3
|
+
* @public Create a portable shell adapter that does not execute host processes.
|
|
4
|
+
*
|
|
5
|
+
* This is the runtime default for portable harnesses. Hosts that want real
|
|
6
|
+
* process execution should pass an explicit local, Worker, container, or
|
|
7
|
+
* just-bash-backed adapter.
|
|
8
|
+
*/
|
|
9
|
+
export function createInMemoryShellAdapter() {
|
|
10
|
+
return {
|
|
11
|
+
async exec(command, _options) {
|
|
12
|
+
return {
|
|
13
|
+
stdout: '',
|
|
14
|
+
stderr: `Shell execution is not available in the default in-memory adapter: ${command}`,
|
|
15
|
+
exitCode: 127,
|
|
16
|
+
};
|
|
17
|
+
},
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
//#endregion
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { SubprocessAdapter, SubprocessHandle, SubprocessRequest } from '../types/subprocess-adapter';
|
|
2
|
+
export interface CreateInMemorySubprocessAdapterOptions {
|
|
3
|
+
run?: (request: SubprocessRequest, handle: SubprocessHandle) => Promise<void>;
|
|
4
|
+
}
|
|
5
|
+
export declare function createInMemorySubprocessAdapter(options?: CreateInMemorySubprocessAdapterOptions): SubprocessAdapter;
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
function nowIso() {
|
|
2
|
+
return new Date().toISOString();
|
|
3
|
+
}
|
|
4
|
+
async function completeInMemoryRun({ request, handle, run, handles, active, save, }) {
|
|
5
|
+
try {
|
|
6
|
+
await run?.(request, handle);
|
|
7
|
+
const latest = handles.get(handle.id);
|
|
8
|
+
if (!latest || latest.status !== 'running') {
|
|
9
|
+
return;
|
|
10
|
+
}
|
|
11
|
+
active.delete(handle.id);
|
|
12
|
+
await save({
|
|
13
|
+
...latest,
|
|
14
|
+
status: 'completed',
|
|
15
|
+
updatedAt: nowIso(),
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
catch (err) {
|
|
19
|
+
active.delete(handle.id);
|
|
20
|
+
const latest = handles.get(handle.id) ?? handle;
|
|
21
|
+
await save({
|
|
22
|
+
...latest,
|
|
23
|
+
status: 'failed',
|
|
24
|
+
updatedAt: nowIso(),
|
|
25
|
+
metadata: {
|
|
26
|
+
...(latest.metadata ?? {}),
|
|
27
|
+
error: err instanceof Error ? err.message : String(err),
|
|
28
|
+
},
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
export function createInMemorySubprocessAdapter(options = {}) {
|
|
33
|
+
const handles = new Map();
|
|
34
|
+
const active = new Set();
|
|
35
|
+
async function save(handle) {
|
|
36
|
+
handles.set(handle.id, handle);
|
|
37
|
+
return handle;
|
|
38
|
+
}
|
|
39
|
+
return {
|
|
40
|
+
async spawn(request) {
|
|
41
|
+
const now = nowIso();
|
|
42
|
+
const handle = {
|
|
43
|
+
id: `subprocess-${crypto.randomUUID()}`,
|
|
44
|
+
status: 'running',
|
|
45
|
+
startedAt: now,
|
|
46
|
+
updatedAt: now,
|
|
47
|
+
metadata: {
|
|
48
|
+
...(request.metadata ?? {}),
|
|
49
|
+
runtime: 'in-memory',
|
|
50
|
+
command: request.command,
|
|
51
|
+
args: request.args ?? [],
|
|
52
|
+
cwd: request.cwd,
|
|
53
|
+
},
|
|
54
|
+
};
|
|
55
|
+
active.add(handle.id);
|
|
56
|
+
await save(handle);
|
|
57
|
+
void completeInMemoryRun({
|
|
58
|
+
request,
|
|
59
|
+
handle,
|
|
60
|
+
run: options.run,
|
|
61
|
+
handles,
|
|
62
|
+
active,
|
|
63
|
+
save,
|
|
64
|
+
});
|
|
65
|
+
return handle;
|
|
66
|
+
},
|
|
67
|
+
async get(handleId) {
|
|
68
|
+
return handles.get(handleId) ?? null;
|
|
69
|
+
},
|
|
70
|
+
async stop(handleId, reason) {
|
|
71
|
+
const handle = handles.get(handleId);
|
|
72
|
+
if (!handle) {
|
|
73
|
+
return {
|
|
74
|
+
kind: 'not_found',
|
|
75
|
+
handleId,
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
active.delete(handleId);
|
|
79
|
+
const next = await save({
|
|
80
|
+
...handle,
|
|
81
|
+
status: 'stopped',
|
|
82
|
+
updatedAt: nowIso(),
|
|
83
|
+
metadata: {
|
|
84
|
+
...(handle.metadata ?? {}),
|
|
85
|
+
stopReason: reason,
|
|
86
|
+
},
|
|
87
|
+
});
|
|
88
|
+
return {
|
|
89
|
+
kind: 'stopped',
|
|
90
|
+
handleId,
|
|
91
|
+
handle: next,
|
|
92
|
+
};
|
|
93
|
+
},
|
|
94
|
+
async pause(handleId) {
|
|
95
|
+
const handle = handles.get(handleId);
|
|
96
|
+
if (!handle) {
|
|
97
|
+
return {
|
|
98
|
+
kind: 'not_found',
|
|
99
|
+
handleId,
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
return {
|
|
103
|
+
kind: 'unsupported',
|
|
104
|
+
handle,
|
|
105
|
+
message: 'In-memory subprocess adapter does not support pause.',
|
|
106
|
+
};
|
|
107
|
+
},
|
|
108
|
+
async resume(handleId) {
|
|
109
|
+
const handle = handles.get(handleId);
|
|
110
|
+
if (!handle) {
|
|
111
|
+
return {
|
|
112
|
+
kind: 'not_found',
|
|
113
|
+
handleId,
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
return {
|
|
117
|
+
kind: 'unsupported',
|
|
118
|
+
handle,
|
|
119
|
+
message: 'In-memory subprocess adapter does not support resume.',
|
|
120
|
+
};
|
|
121
|
+
},
|
|
122
|
+
async isAlive(handle) {
|
|
123
|
+
return active.has(handle.id);
|
|
124
|
+
},
|
|
125
|
+
};
|
|
126
|
+
}
|