@agentick/core 0.0.1 → 0.1.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/.tsbuildinfo.build +1 -1
- package/package.json +8 -3
- package/dist/.tsbuildinfo +0 -1
- package/dist/agent.d.ts +0 -32
- package/dist/agent.d.ts.map +0 -1
- package/dist/agent.js +0 -26
- package/dist/agent.js.map +0 -1
- package/dist/aidk-instance.d.ts +0 -294
- package/dist/aidk-instance.d.ts.map +0 -1
- package/dist/aidk-instance.js +0 -340
- package/dist/aidk-instance.js.map +0 -1
- package/dist/compiler/content-block-registry.d.ts +0 -11
- package/dist/compiler/content-block-registry.d.ts.map +0 -1
- package/dist/compiler/content-block-registry.js +0 -312
- package/dist/compiler/content-block-registry.js.map +0 -1
- package/dist/compiler/extractors.d.ts +0 -68
- package/dist/compiler/extractors.d.ts.map +0 -1
- package/dist/compiler/extractors.js +0 -547
- package/dist/compiler/extractors.js.map +0 -1
- package/dist/compiler/fiber.d.ts +0 -61
- package/dist/compiler/fiber.d.ts.map +0 -1
- package/dist/compiler/fiber.js +0 -244
- package/dist/compiler/fiber.js.map +0 -1
- package/dist/component/tentickle-component.d.ts +0 -185
- package/dist/component/tentickle-component.d.ts.map +0 -1
- package/dist/component/tentickle-component.js +0 -182
- package/dist/component/tentickle-component.js.map +0 -1
- package/dist/core/channel-helpers.d.ts +0 -31
- package/dist/core/channel-helpers.d.ts.map +0 -1
- package/dist/core/channel-helpers.js +0 -62
- package/dist/core/channel-helpers.js.map +0 -1
- package/dist/core/channel.d.ts +0 -164
- package/dist/core/channel.d.ts.map +0 -1
- package/dist/core/channel.js +0 -199
- package/dist/core/channel.js.map +0 -1
- package/dist/core/context.d.ts +0 -412
- package/dist/core/context.d.ts.map +0 -1
- package/dist/core/context.js +0 -290
- package/dist/core/context.js.map +0 -1
- package/dist/core/event-buffer.d.ts +0 -212
- package/dist/core/event-buffer.d.ts.map +0 -1
- package/dist/core/event-buffer.js +0 -346
- package/dist/core/event-buffer.js.map +0 -1
- package/dist/core/execution-helpers.d.ts +0 -179
- package/dist/core/execution-helpers.d.ts.map +0 -1
- package/dist/core/execution-helpers.js +0 -212
- package/dist/core/execution-helpers.js.map +0 -1
- package/dist/core/execution-tracker.d.ts +0 -53
- package/dist/core/execution-tracker.d.ts.map +0 -1
- package/dist/core/execution-tracker.js +0 -309
- package/dist/core/execution-tracker.js.map +0 -1
- package/dist/core/index.d.ts +0 -58
- package/dist/core/index.d.ts.map +0 -1
- package/dist/core/index.js +0 -58
- package/dist/core/index.js.map +0 -1
- package/dist/core/logger.d.ts +0 -341
- package/dist/core/logger.d.ts.map +0 -1
- package/dist/core/logger.js +0 -346
- package/dist/core/logger.js.map +0 -1
- package/dist/core/metrics-helpers.d.ts +0 -40
- package/dist/core/metrics-helpers.d.ts.map +0 -1
- package/dist/core/metrics-helpers.js +0 -72
- package/dist/core/metrics-helpers.js.map +0 -1
- package/dist/core/otel-provider.d.ts +0 -54
- package/dist/core/otel-provider.d.ts.map +0 -1
- package/dist/core/otel-provider.js +0 -107
- package/dist/core/otel-provider.js.map +0 -1
- package/dist/core/procedure-graph.d.ts +0 -136
- package/dist/core/procedure-graph.d.ts.map +0 -1
- package/dist/core/procedure-graph.js +0 -272
- package/dist/core/procedure-graph.js.map +0 -1
- package/dist/core/procedure.d.ts +0 -755
- package/dist/core/procedure.d.ts.map +0 -1
- package/dist/core/procedure.js +0 -899
- package/dist/core/procedure.js.map +0 -1
- package/dist/core/stream.d.ts +0 -106
- package/dist/core/stream.d.ts.map +0 -1
- package/dist/core/stream.js +0 -186
- package/dist/core/stream.js.map +0 -1
- package/dist/core/telemetry.d.ts +0 -182
- package/dist/core/telemetry.d.ts.map +0 -1
- package/dist/core/telemetry.js +0 -124
- package/dist/core/telemetry.js.map +0 -1
- package/dist/engine/execution-graph.d.ts +0 -104
- package/dist/engine/execution-graph.d.ts.map +0 -1
- package/dist/engine/execution-graph.js +0 -257
- package/dist/engine/execution-graph.js.map +0 -1
- package/dist/hooks/policy-context.d.ts.map +0 -1
- package/dist/jsx/components/agent.d.ts +0 -64
- package/dist/jsx/components/agent.d.ts.map +0 -1
- package/dist/jsx/components/agent.js +0 -80
- package/dist/jsx/components/agent.js.map +0 -1
- package/dist/model/simple-adapter.d.ts +0 -176
- package/dist/model/simple-adapter.d.ts.map +0 -1
- package/dist/model/simple-adapter.js +0 -264
- package/dist/model/simple-adapter.js.map +0 -1
- package/dist/state/boundary.d.ts +0 -347
- package/dist/state/boundary.d.ts.map +0 -1
- package/dist/state/boundary.js +0 -341
- package/dist/state/boundary.js.map +0 -1
- package/dist/state/context.d.ts +0 -138
- package/dist/state/context.d.ts.map +0 -1
- package/dist/state/context.js +0 -139
- package/dist/state/context.js.map +0 -1
- package/dist/state/hooks.d.ts +0 -798
- package/dist/state/hooks.d.ts.map +0 -1
- package/dist/state/hooks.js +0 -1437
- package/dist/state/hooks.js.map +0 -1
- package/dist/state/index.d.ts +0 -72
- package/dist/state/index.d.ts.map +0 -1
- package/dist/state/index.js +0 -73
- package/dist/state/index.js.map +0 -1
- package/dist/state/signal.d.ts +0 -223
- package/dist/state/signal.d.ts.map +0 -1
- package/dist/state/signal.js +0 -699
- package/dist/state/signal.js.map +0 -1
- package/dist/state/use-state.d.ts +0 -210
- package/dist/state/use-state.d.ts.map +0 -1
- package/dist/state/use-state.js +0 -327
- package/dist/state/use-state.js.map +0 -1
- package/dist/tentickle-instance.d.ts +0 -285
- package/dist/tentickle-instance.d.ts.map +0 -1
- package/dist/tentickle-instance.js +0 -700
- package/dist/tentickle-instance.js.map +0 -1
- package/dist/testing/test-model.d.ts +0 -132
- package/dist/testing/test-model.d.ts.map +0 -1
- package/dist/testing/test-model.js +0 -260
- package/dist/testing/test-model.js.map +0 -1
- package/dist/v2/reconciler/host-config.d.ts +0 -31
- package/dist/v2/reconciler/host-config.d.ts.map +0 -1
- package/dist/v2/reconciler/host-config.js +0 -197
- package/dist/v2/reconciler/host-config.js.map +0 -1
- package/dist/v2/reconciler/index.d.ts +0 -7
- package/dist/v2/reconciler/index.d.ts.map +0 -1
- package/dist/v2/reconciler/index.js +0 -7
- package/dist/v2/reconciler/index.js.map +0 -1
- package/dist/v2/reconciler/reconciler.d.ts +0 -39
- package/dist/v2/reconciler/reconciler.d.ts.map +0 -1
- package/dist/v2/reconciler/reconciler.js +0 -54
- package/dist/v2/reconciler/reconciler.js.map +0 -1
- package/dist/v2/reconciler/types.d.ts +0 -64
- package/dist/v2/reconciler/types.d.ts.map +0 -1
- package/dist/v2/reconciler/types.js +0 -20
- package/dist/v2/reconciler/types.js.map +0 -1
- package/dist/v2/renderers/index.d.ts +0 -7
- package/dist/v2/renderers/index.d.ts.map +0 -1
- package/dist/v2/renderers/index.js +0 -7
- package/dist/v2/renderers/index.js.map +0 -1
- package/dist/v2/renderers/markdown.d.ts +0 -16
- package/dist/v2/renderers/markdown.d.ts.map +0 -1
- package/dist/v2/renderers/markdown.js +0 -65
- package/dist/v2/renderers/markdown.js.map +0 -1
- package/dist/v2/renderers/types.d.ts +0 -26
- package/dist/v2/renderers/types.d.ts.map +0 -1
- package/dist/v2/renderers/types.js +0 -6
- package/dist/v2/renderers/types.js.map +0 -1
- package/dist/v2/renderers/xml.d.ts +0 -17
- package/dist/v2/renderers/xml.d.ts.map +0 -1
- package/dist/v2/renderers/xml.js +0 -73
- package/dist/v2/renderers/xml.js.map +0 -1
package/dist/aidk-instance.js
DELETED
|
@@ -1,340 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Tentickle Configuration Instance
|
|
3
|
-
*
|
|
4
|
-
* `Tentickle` is the default global instance. Users interact with instances, never the class directly.
|
|
5
|
-
*
|
|
6
|
-
* ```typescript
|
|
7
|
-
* import { Tentickle, createApp } from 'tentickle';
|
|
8
|
-
*
|
|
9
|
-
* // Configure global instance
|
|
10
|
-
* Tentickle.use('*', loggingMiddleware);
|
|
11
|
-
* Tentickle.use('tool:*', authMiddleware);
|
|
12
|
-
*
|
|
13
|
-
* // createApp uses Tentickle by default
|
|
14
|
-
* const app = createApp(MyAgent, { model });
|
|
15
|
-
*
|
|
16
|
-
* // Create a scoped instance (inherits from Tentickle)
|
|
17
|
-
* const scoped = Tentickle.create();
|
|
18
|
-
* scoped.use('model:generate', rateLimitMiddleware);
|
|
19
|
-
* const scopedApp = scoped.createApp(MyAgent, { model });
|
|
20
|
-
*
|
|
21
|
-
* // Create isolated instance (no inheritance)
|
|
22
|
-
* const isolated = Tentickle.create({ inheritDefaults: false });
|
|
23
|
-
* ```
|
|
24
|
-
*
|
|
25
|
-
* @module tentickle/@tentickle/instance
|
|
26
|
-
*/
|
|
27
|
-
import { createProcedure } from "./core";
|
|
28
|
-
import { SessionImpl } from "./app/session";
|
|
29
|
-
/**
|
|
30
|
-
* Tentickle configuration instance.
|
|
31
|
-
*
|
|
32
|
-
* Users interact with instances, never the class directly.
|
|
33
|
-
* `Tentickle` is the default global instance.
|
|
34
|
-
*/
|
|
35
|
-
export class TentickleInstance {
|
|
36
|
-
middlewareRegistry = new Map();
|
|
37
|
-
_telemetryProvider;
|
|
38
|
-
/**
|
|
39
|
-
* One-shot execution of a JSX component.
|
|
40
|
-
*
|
|
41
|
-
* This is a procedure with handleFactory: false (pass-through).
|
|
42
|
-
* Returns SessionExecutionHandle which is both PromiseLike and AsyncIterable:
|
|
43
|
-
* - `await run(...)` → SendResult
|
|
44
|
-
* - `for await (const event of run(...))` → AppStreamEvent
|
|
45
|
-
*
|
|
46
|
-
* @example Await result
|
|
47
|
-
* ```typescript
|
|
48
|
-
* const result = await Tentickle.run(
|
|
49
|
-
* <MyAgent />,
|
|
50
|
-
* { messages: [{ role: "user", content: [...] }], model }
|
|
51
|
-
* );
|
|
52
|
-
* ```
|
|
53
|
-
*
|
|
54
|
-
* @example Stream events
|
|
55
|
-
* ```typescript
|
|
56
|
-
* for await (const event of Tentickle.run(<MyAgent />, { messages, model })) {
|
|
57
|
-
* if (event.type === 'content_delta') {
|
|
58
|
-
* process.stdout.write(event.delta);
|
|
59
|
-
* }
|
|
60
|
-
* }
|
|
61
|
-
* ```
|
|
62
|
-
*
|
|
63
|
-
* @example Add middleware to run
|
|
64
|
-
* ```typescript
|
|
65
|
-
* const loggedRun = Tentickle.run.use(loggingMiddleware);
|
|
66
|
-
* const result = await loggedRun(<MyAgent />, { messages, model });
|
|
67
|
-
* ```
|
|
68
|
-
*/
|
|
69
|
-
run;
|
|
70
|
-
/**
|
|
71
|
-
* @internal
|
|
72
|
-
*/
|
|
73
|
-
constructor(options) {
|
|
74
|
-
this._telemetryProvider = options?.telemetryProvider;
|
|
75
|
-
// Create the run procedure bound to this instance
|
|
76
|
-
const instance = this;
|
|
77
|
-
this.run = createProcedure({ name: "tentickle:run", handleFactory: false }, (element, input = {}) => {
|
|
78
|
-
const { model, props, messages = [], history = [], maxTicks, signal } = input;
|
|
79
|
-
// Extract component and element props
|
|
80
|
-
const Component = element.type;
|
|
81
|
-
const elementProps = element.props;
|
|
82
|
-
// Merge element props with input props (input props take precedence)
|
|
83
|
-
const mergedProps = { ...elementProps, ...props };
|
|
84
|
-
// Create app options
|
|
85
|
-
const appOptions = {};
|
|
86
|
-
if (model)
|
|
87
|
-
appOptions.model = model;
|
|
88
|
-
if (maxTicks !== undefined)
|
|
89
|
-
appOptions.maxTicks = maxTicks;
|
|
90
|
-
if (signal)
|
|
91
|
-
appOptions.signal = signal;
|
|
92
|
-
// Create app and run using this instance
|
|
93
|
-
const app = instance.createApp(Component, appOptions);
|
|
94
|
-
return app.run({
|
|
95
|
-
props: mergedProps,
|
|
96
|
-
messages,
|
|
97
|
-
history,
|
|
98
|
-
});
|
|
99
|
-
});
|
|
100
|
-
}
|
|
101
|
-
/**
|
|
102
|
-
* Register middleware for a procedure pattern.
|
|
103
|
-
*
|
|
104
|
-
* Keys can be:
|
|
105
|
-
* - `'*'` - all procedures
|
|
106
|
-
* - `'tool:*'` - all tool procedures (tool:run, etc.)
|
|
107
|
-
* - `'model:*'` - all model procedures (model:generate, model:stream)
|
|
108
|
-
* - `'tool:run'` - specific procedure name
|
|
109
|
-
* - `'model:generate'` - specific procedure name
|
|
110
|
-
*
|
|
111
|
-
* Middleware is executed in order: global → category → specific
|
|
112
|
-
*
|
|
113
|
-
* @param key - Procedure pattern to match
|
|
114
|
-
* @param middleware - Middleware functions to register
|
|
115
|
-
* @returns this for chaining
|
|
116
|
-
*
|
|
117
|
-
* @example
|
|
118
|
-
* ```typescript
|
|
119
|
-
* Tentickle
|
|
120
|
-
* .use('*', loggingMiddleware)
|
|
121
|
-
* .use('tool:*', authMiddleware)
|
|
122
|
-
* .use('model:generate', rateLimitMiddleware);
|
|
123
|
-
* ```
|
|
124
|
-
*/
|
|
125
|
-
use(key, ...middleware) {
|
|
126
|
-
const existing = this.middlewareRegistry.get(key) || [];
|
|
127
|
-
this.middlewareRegistry.set(key, [...existing, ...middleware]);
|
|
128
|
-
return this;
|
|
129
|
-
}
|
|
130
|
-
/**
|
|
131
|
-
* Get middleware matching a procedure name.
|
|
132
|
-
*
|
|
133
|
-
* Resolution order:
|
|
134
|
-
* 1. Global ('*')
|
|
135
|
-
* 2. Category wildcard (e.g., 'tool:*' matches 'tool:run')
|
|
136
|
-
* 3. Exact match (e.g., 'tool:run')
|
|
137
|
-
*
|
|
138
|
-
* @param procedureName - The procedure name to match (e.g., 'tool:run', 'model:generate')
|
|
139
|
-
* @returns Array of middleware functions in execution order
|
|
140
|
-
*/
|
|
141
|
-
getMiddlewareFor(procedureName) {
|
|
142
|
-
const result = [];
|
|
143
|
-
// 1. Global middleware ('*')
|
|
144
|
-
const global = this.middlewareRegistry.get("*");
|
|
145
|
-
if (global)
|
|
146
|
-
result.push(...global);
|
|
147
|
-
// 2. Category wildcard (e.g., 'tool:*' matches 'tool:run')
|
|
148
|
-
const colonIndex = procedureName.indexOf(":");
|
|
149
|
-
if (colonIndex > 0) {
|
|
150
|
-
const category = procedureName.slice(0, colonIndex);
|
|
151
|
-
const categoryWildcard = this.middlewareRegistry.get(`${category}:*`);
|
|
152
|
-
if (categoryWildcard)
|
|
153
|
-
result.push(...categoryWildcard);
|
|
154
|
-
}
|
|
155
|
-
// 3. Exact match
|
|
156
|
-
const exact = this.middlewareRegistry.get(procedureName);
|
|
157
|
-
if (exact)
|
|
158
|
-
result.push(...exact);
|
|
159
|
-
return result;
|
|
160
|
-
}
|
|
161
|
-
/**
|
|
162
|
-
* Clear all registered middleware.
|
|
163
|
-
* Useful for testing or resetting state.
|
|
164
|
-
*/
|
|
165
|
-
clear() {
|
|
166
|
-
this.middlewareRegistry.clear();
|
|
167
|
-
return this;
|
|
168
|
-
}
|
|
169
|
-
/**
|
|
170
|
-
* Get the telemetry provider.
|
|
171
|
-
*/
|
|
172
|
-
get telemetryProvider() {
|
|
173
|
-
return this._telemetryProvider;
|
|
174
|
-
}
|
|
175
|
-
/**
|
|
176
|
-
* Set the telemetry provider.
|
|
177
|
-
*/
|
|
178
|
-
set telemetryProvider(provider) {
|
|
179
|
-
this._telemetryProvider = provider;
|
|
180
|
-
}
|
|
181
|
-
/**
|
|
182
|
-
* Create a child instance.
|
|
183
|
-
*
|
|
184
|
-
* By default, the child inherits all middleware from this instance.
|
|
185
|
-
* Use `inheritDefaults: false` for a completely isolated instance.
|
|
186
|
-
*
|
|
187
|
-
* @param options - Instance options
|
|
188
|
-
* @returns A new TentickleInstance
|
|
189
|
-
*
|
|
190
|
-
* @example
|
|
191
|
-
* ```typescript
|
|
192
|
-
* // Create scoped instance that inherits global middleware
|
|
193
|
-
* const scoped = Tentickle.create();
|
|
194
|
-
* scoped.use('model:generate', rateLimitMiddleware);
|
|
195
|
-
* const app = scoped.createApp(MyAgent);
|
|
196
|
-
*
|
|
197
|
-
* // Create isolated instance (no inheritance)
|
|
198
|
-
* const isolated = Tentickle.create({ inheritDefaults: false });
|
|
199
|
-
* ```
|
|
200
|
-
*/
|
|
201
|
-
create(options = {}) {
|
|
202
|
-
const child = new TentickleInstance({
|
|
203
|
-
telemetryProvider: options.telemetryProvider ?? this._telemetryProvider,
|
|
204
|
-
});
|
|
205
|
-
// Copy middleware from parent unless inheritDefaults: false
|
|
206
|
-
if (options.inheritDefaults !== false) {
|
|
207
|
-
for (const [key, mws] of this.middlewareRegistry) {
|
|
208
|
-
child.middlewareRegistry.set(key, [...mws]);
|
|
209
|
-
}
|
|
210
|
-
}
|
|
211
|
-
return child;
|
|
212
|
-
}
|
|
213
|
-
/**
|
|
214
|
-
* Create an app from a component function.
|
|
215
|
-
*
|
|
216
|
-
* The app inherits middleware from this Tentickle instance.
|
|
217
|
-
*
|
|
218
|
-
* @param Component - The component function that defines the Model Interface
|
|
219
|
-
* @param options - App configuration options
|
|
220
|
-
* @returns An App instance with run and createSession methods
|
|
221
|
-
*
|
|
222
|
-
* @example
|
|
223
|
-
* ```typescript
|
|
224
|
-
* const MyAgent = ({ query }) => (
|
|
225
|
-
* <>
|
|
226
|
-
* <System>You are helpful.</System>
|
|
227
|
-
* <Timeline />
|
|
228
|
-
* <User>{query}</User>
|
|
229
|
-
* </>
|
|
230
|
-
* );
|
|
231
|
-
*
|
|
232
|
-
* // Use global Tentickle
|
|
233
|
-
* const app = createApp(MyAgent, { model });
|
|
234
|
-
*
|
|
235
|
-
* // Use scoped instance
|
|
236
|
-
* const scoped = Tentickle.create();
|
|
237
|
-
* scoped.use('tool:*', authMiddleware);
|
|
238
|
-
* const scopedApp = scoped.createApp(MyAgent, { model });
|
|
239
|
-
* ```
|
|
240
|
-
*/
|
|
241
|
-
createApp(Component, options = {}) {
|
|
242
|
-
const optionsWithInstance = { ...options, _tentickleInstance: this };
|
|
243
|
-
return {
|
|
244
|
-
/**
|
|
245
|
-
* Run the app with input.
|
|
246
|
-
*
|
|
247
|
-
* Returns SessionExecutionHandle which is both PromiseLike and AsyncIterable:
|
|
248
|
-
* - `await app.run(input)` → SendResult
|
|
249
|
-
* - `for await (const event of app.run(input))` → AppStreamEvent
|
|
250
|
-
*/
|
|
251
|
-
run(input) {
|
|
252
|
-
const { props = {}, messages = [], history = [], options: runOpts = {} } = input;
|
|
253
|
-
const sessionOptions = {
|
|
254
|
-
...runOpts,
|
|
255
|
-
initialTimeline: history.length > 0 ? history : undefined,
|
|
256
|
-
};
|
|
257
|
-
// Create session - it captures middleware from optionsWithInstance._tentickleInstance
|
|
258
|
-
const session = new SessionImpl(Component, optionsWithInstance, sessionOptions);
|
|
259
|
-
// Queue messages before tick
|
|
260
|
-
for (const message of messages) {
|
|
261
|
-
session.queueMessage(message);
|
|
262
|
-
}
|
|
263
|
-
// session.tick() returns SessionExecutionHandle (PromiseLike + AsyncIterable)
|
|
264
|
-
const handle = session.tick(props, sessionOptions);
|
|
265
|
-
// Cleanup on completion (success or error)
|
|
266
|
-
handle.result.finally(() => session.close()).catch(() => {
|
|
267
|
-
// Prevent unhandled rejection - errors are captured in handle
|
|
268
|
-
});
|
|
269
|
-
return handle;
|
|
270
|
-
},
|
|
271
|
-
/**
|
|
272
|
-
* Create a persistent session for multi-turn conversations.
|
|
273
|
-
*/
|
|
274
|
-
createSession(sessionOptions) {
|
|
275
|
-
// Session captures middleware from optionsWithInstance._tentickleInstance
|
|
276
|
-
return new SessionImpl(Component, optionsWithInstance, sessionOptions ?? {});
|
|
277
|
-
},
|
|
278
|
-
};
|
|
279
|
-
}
|
|
280
|
-
}
|
|
281
|
-
/**
|
|
282
|
-
* The default global Tentickle instance.
|
|
283
|
-
*
|
|
284
|
-
* All configuration and middleware registration starts here.
|
|
285
|
-
* The exported `createApp` and `run` are bound to this instance.
|
|
286
|
-
*
|
|
287
|
-
* @example
|
|
288
|
-
* ```typescript
|
|
289
|
-
* import { Tentickle, createApp, run } from 'tentickle';
|
|
290
|
-
*
|
|
291
|
-
* // Configure global middleware
|
|
292
|
-
* Tentickle.use('*', loggingMiddleware);
|
|
293
|
-
* Tentickle.telemetryProvider = myProvider;
|
|
294
|
-
*
|
|
295
|
-
* // createApp and run use Tentickle
|
|
296
|
-
* const app = createApp(MyAgent, { model });
|
|
297
|
-
* const result = await run(<MyAgent />, { messages, model });
|
|
298
|
-
*
|
|
299
|
-
* // Create scoped instance with its own middleware
|
|
300
|
-
* const scoped = Tentickle.create();
|
|
301
|
-
* scoped.use('model:generate', specialMiddleware);
|
|
302
|
-
* const scopedResult = await scoped.run(<MyAgent />, { messages, model });
|
|
303
|
-
* ```
|
|
304
|
-
*/
|
|
305
|
-
export const Tentickle = new TentickleInstance();
|
|
306
|
-
/**
|
|
307
|
-
* Create an app from a component function.
|
|
308
|
-
*
|
|
309
|
-
* This is `Tentickle.createApp` - apps inherit middleware from the global Tentickle instance.
|
|
310
|
-
*
|
|
311
|
-
* @example
|
|
312
|
-
* ```typescript
|
|
313
|
-
* import { createApp } from 'tentickle';
|
|
314
|
-
*
|
|
315
|
-
* const app = createApp(MyAgent, { model });
|
|
316
|
-
* const result = await app.run({ props: { query: "Hello!" } });
|
|
317
|
-
* ```
|
|
318
|
-
*/
|
|
319
|
-
export const createApp = Tentickle.createApp.bind(Tentickle);
|
|
320
|
-
/**
|
|
321
|
-
* One-shot execution of a JSX component.
|
|
322
|
-
*
|
|
323
|
-
* This is `Tentickle.run` - the simplest way to run an agent.
|
|
324
|
-
* Returns SessionExecutionHandle which is both PromiseLike and AsyncIterable.
|
|
325
|
-
*
|
|
326
|
-
* @example
|
|
327
|
-
* ```typescript
|
|
328
|
-
* import { run } from 'tentickle';
|
|
329
|
-
*
|
|
330
|
-
* // Await result
|
|
331
|
-
* const result = await run(<MyAgent />, { messages, model });
|
|
332
|
-
*
|
|
333
|
-
* // Stream events
|
|
334
|
-
* for await (const event of run(<MyAgent />, { messages, model })) {
|
|
335
|
-
* console.log(event);
|
|
336
|
-
* }
|
|
337
|
-
* ```
|
|
338
|
-
*/
|
|
339
|
-
export const run = Tentickle.run.bind(Tentickle);
|
|
340
|
-
//# sourceMappingURL=aidk-instance.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"aidk-instance.js","sourceRoot":"","sources":["../src/aidk-instance.ts"],"names":[],"mappings":"AAAA;;;;;;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AAG,GAAG,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC"}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { type JSX } from "../jsx/jsx-runtime";
|
|
2
|
-
import { type Formatter, type SemanticContentBlock } from "../renderers";
|
|
3
|
-
export type ContentBlockMapper = (element: JSX.Element, currentFormatter?: Formatter) => SemanticContentBlock | null;
|
|
4
|
-
/**
|
|
5
|
-
* Initialize the content block mapper registry.
|
|
6
|
-
* Maps JSX element types to their ContentBlock conversion functions.
|
|
7
|
-
*
|
|
8
|
-
* This can be called from the FiberCompiler constructor to set up the registry.
|
|
9
|
-
*/
|
|
10
|
-
export declare function initializeContentBlockMappers(register: (type: any, mapper: ContentBlockMapper, stringType?: string) => void): void;
|
|
11
|
-
//# sourceMappingURL=content-block-registry.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"content-block-registry.d.ts","sourceRoot":"","sources":["../../src/compiler/content-block-registry.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,GAAG,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,KAAK,SAAS,EAAE,KAAK,oBAAoB,EAAE,MAAM,cAAc,CAAC;AAQzE,MAAM,MAAM,kBAAkB,GAAG,CAC/B,OAAO,EAAE,GAAG,CAAC,OAAO,EACpB,gBAAgB,CAAC,EAAE,SAAS,KACzB,oBAAoB,GAAG,IAAI,CAAC;AAEjC;;;;;GAKG;AACH,wBAAgB,6BAA6B,CAC3C,QAAQ,EAAE,CAAC,IAAI,EAAE,GAAG,EAAE,MAAM,EAAE,kBAAkB,EAAE,UAAU,CAAC,EAAE,MAAM,KAAK,IAAI,GAC7E,IAAI,CA8aN"}
|
|
@@ -1,312 +0,0 @@
|
|
|
1
|
-
import {} from "@tentickle/shared";
|
|
2
|
-
import { Text, Image, Document, Audio, Video, Code, Json } from "../jsx/components/content";
|
|
3
|
-
import { H1, H2, H3, Header, Paragraph, Table, List } from "../jsx/components/semantic";
|
|
4
|
-
import { UserAction, SystemEvent, StateChange } from "../jsx/components/messages";
|
|
5
|
-
import {} from "../jsx/jsx-runtime";
|
|
6
|
-
import {} from "../renderers";
|
|
7
|
-
import { extractSemanticNodeFromElement, extractTextFromElement, extractTableStructure, extractListStructure, } from "./extractors";
|
|
8
|
-
/**
|
|
9
|
-
* Initialize the content block mapper registry.
|
|
10
|
-
* Maps JSX element types to their ContentBlock conversion functions.
|
|
11
|
-
*
|
|
12
|
-
* This can be called from the FiberCompiler constructor to set up the registry.
|
|
13
|
-
*/
|
|
14
|
-
export function initializeContentBlockMappers(register) {
|
|
15
|
-
// Text block - children win over props (React convention)
|
|
16
|
-
// Supports JSX children with inline formatting (bold, italic, code, etc.)
|
|
17
|
-
register(Text, (el, currentFormatter) => {
|
|
18
|
-
// If children exist, extract semantic node tree
|
|
19
|
-
if (el.props.children !== undefined && el.props.children !== null) {
|
|
20
|
-
const semanticNode = extractSemanticNodeFromElement(el, currentFormatter);
|
|
21
|
-
// Attach renderer to semantic node for proper formatting later
|
|
22
|
-
if (currentFormatter) {
|
|
23
|
-
semanticNode.formatter = currentFormatter;
|
|
24
|
-
}
|
|
25
|
-
return {
|
|
26
|
-
type: "text",
|
|
27
|
-
text: "", // Will be populated by renderer from semanticNode
|
|
28
|
-
semanticNode,
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
// Fallback to text prop (plain text, no semantic structure)
|
|
32
|
-
const text = el.props.text ?? "";
|
|
33
|
-
return {
|
|
34
|
-
type: "text",
|
|
35
|
-
text,
|
|
36
|
-
semanticNode: text ? { text } : undefined,
|
|
37
|
-
};
|
|
38
|
-
}, "text");
|
|
39
|
-
// Native HTML block elements (work like Text but with semantic type marker)
|
|
40
|
-
// <p> - paragraph
|
|
41
|
-
register("p", (el, currentFormatter) => {
|
|
42
|
-
const semanticNode = extractSemanticNodeFromElement(el, currentFormatter);
|
|
43
|
-
// Attach renderer to semantic node for proper formatting later
|
|
44
|
-
// This enables nested formatter boundaries (e.g., XML inside Section)
|
|
45
|
-
if (currentFormatter) {
|
|
46
|
-
semanticNode.formatter = currentFormatter;
|
|
47
|
-
}
|
|
48
|
-
return {
|
|
49
|
-
type: "text",
|
|
50
|
-
text: "",
|
|
51
|
-
semanticNode,
|
|
52
|
-
semantic: { type: "paragraph" },
|
|
53
|
-
};
|
|
54
|
-
}, "p");
|
|
55
|
-
// <blockquote> - blockquote
|
|
56
|
-
register("blockquote", (el, currentFormatter) => {
|
|
57
|
-
const semanticNode = extractSemanticNodeFromElement(el, currentFormatter);
|
|
58
|
-
// Attach renderer to semantic node for proper formatting later
|
|
59
|
-
if (currentFormatter) {
|
|
60
|
-
semanticNode.formatter = currentFormatter;
|
|
61
|
-
}
|
|
62
|
-
return {
|
|
63
|
-
type: "text",
|
|
64
|
-
text: "",
|
|
65
|
-
semanticNode,
|
|
66
|
-
semantic: { type: "blockquote" },
|
|
67
|
-
};
|
|
68
|
-
}, "blockquote");
|
|
69
|
-
// Image block
|
|
70
|
-
register(Image, (el) => ({
|
|
71
|
-
type: "image",
|
|
72
|
-
source: el.props.source,
|
|
73
|
-
mimeType: el.props.mimeType,
|
|
74
|
-
altText: el.props.altText,
|
|
75
|
-
}), "image");
|
|
76
|
-
// Document block
|
|
77
|
-
register(Document, (el) => ({
|
|
78
|
-
type: "document",
|
|
79
|
-
source: el.props.source,
|
|
80
|
-
mimeType: el.props.mimeType,
|
|
81
|
-
title: el.props.title,
|
|
82
|
-
}), "document");
|
|
83
|
-
// Audio block
|
|
84
|
-
register(Audio, (el) => ({
|
|
85
|
-
type: "audio",
|
|
86
|
-
source: el.props.source,
|
|
87
|
-
mimeType: el.props.mimeType,
|
|
88
|
-
transcript: el.props.transcript,
|
|
89
|
-
}), "audio");
|
|
90
|
-
// Video block
|
|
91
|
-
register(Video, (el) => ({
|
|
92
|
-
type: "video",
|
|
93
|
-
source: el.props.source,
|
|
94
|
-
mimeType: el.props.mimeType,
|
|
95
|
-
transcript: el.props.transcript,
|
|
96
|
-
}), "video");
|
|
97
|
-
// Code block - children win over props (React convention)
|
|
98
|
-
register(Code, (el) => {
|
|
99
|
-
const childrenText = el.props.children !== undefined
|
|
100
|
-
? typeof el.props.children === "string"
|
|
101
|
-
? el.props.children
|
|
102
|
-
: Array.isArray(el.props.children)
|
|
103
|
-
? el.props.children.join("")
|
|
104
|
-
: ""
|
|
105
|
-
: undefined;
|
|
106
|
-
const text = childrenText ?? el.props.text ?? "";
|
|
107
|
-
return {
|
|
108
|
-
type: "code",
|
|
109
|
-
language: el.props.language,
|
|
110
|
-
text,
|
|
111
|
-
};
|
|
112
|
-
}, "code");
|
|
113
|
-
// JSON block
|
|
114
|
-
register(Json, (el) => {
|
|
115
|
-
const jsonBlock = { type: "json" };
|
|
116
|
-
if (el.props.data !== undefined) {
|
|
117
|
-
jsonBlock.data = el.props.data;
|
|
118
|
-
}
|
|
119
|
-
if (el.props.text !== undefined) {
|
|
120
|
-
jsonBlock.text = el.props.text;
|
|
121
|
-
}
|
|
122
|
-
return jsonBlock;
|
|
123
|
-
}, "json");
|
|
124
|
-
// Semantic primitives - Headings
|
|
125
|
-
register(H1, (el, currentFormatter) => {
|
|
126
|
-
const semanticNode = extractSemanticNodeFromElement(el, currentFormatter);
|
|
127
|
-
if (currentFormatter) {
|
|
128
|
-
semanticNode.formatter = currentFormatter;
|
|
129
|
-
}
|
|
130
|
-
return {
|
|
131
|
-
type: "text",
|
|
132
|
-
text: "", // Will be populated by renderer from semanticNode
|
|
133
|
-
semanticNode,
|
|
134
|
-
semantic: { type: "heading", level: 1 },
|
|
135
|
-
};
|
|
136
|
-
}, "h1");
|
|
137
|
-
register(H2, (el, currentFormatter) => {
|
|
138
|
-
const semanticNode = extractSemanticNodeFromElement(el, currentFormatter);
|
|
139
|
-
if (currentFormatter) {
|
|
140
|
-
semanticNode.formatter = currentFormatter;
|
|
141
|
-
}
|
|
142
|
-
return {
|
|
143
|
-
type: "text",
|
|
144
|
-
text: "", // Will be populated by renderer from semanticNode
|
|
145
|
-
semanticNode,
|
|
146
|
-
semantic: { type: "heading", level: 2 },
|
|
147
|
-
};
|
|
148
|
-
}, "h2");
|
|
149
|
-
register(H3, (el, currentFormatter) => {
|
|
150
|
-
const semanticNode = extractSemanticNodeFromElement(el, currentFormatter);
|
|
151
|
-
if (currentFormatter) {
|
|
152
|
-
semanticNode.formatter = currentFormatter;
|
|
153
|
-
}
|
|
154
|
-
return {
|
|
155
|
-
type: "text",
|
|
156
|
-
text: "", // Will be populated by renderer from semanticNode
|
|
157
|
-
semanticNode,
|
|
158
|
-
semantic: { type: "heading", level: 3 },
|
|
159
|
-
};
|
|
160
|
-
}, "h3");
|
|
161
|
-
register(Header, (el, currentFormatter) => {
|
|
162
|
-
const level = el.props.level || 1;
|
|
163
|
-
const semanticNode = extractSemanticNodeFromElement(el, currentFormatter);
|
|
164
|
-
if (currentFormatter) {
|
|
165
|
-
semanticNode.formatter = currentFormatter;
|
|
166
|
-
}
|
|
167
|
-
return {
|
|
168
|
-
type: "text",
|
|
169
|
-
text: "", // Will be populated by renderer from semanticNode
|
|
170
|
-
semanticNode,
|
|
171
|
-
semantic: { type: "heading", level },
|
|
172
|
-
};
|
|
173
|
-
}, "header");
|
|
174
|
-
// Paragraph
|
|
175
|
-
register(Paragraph, (el, currentFormatter) => {
|
|
176
|
-
const semanticNode = extractSemanticNodeFromElement(el, currentFormatter);
|
|
177
|
-
if (currentFormatter) {
|
|
178
|
-
semanticNode.formatter = currentFormatter;
|
|
179
|
-
}
|
|
180
|
-
return {
|
|
181
|
-
type: "text",
|
|
182
|
-
text: "", // Will be populated by renderer from semanticNode
|
|
183
|
-
semanticNode,
|
|
184
|
-
semantic: { type: "paragraph" },
|
|
185
|
-
};
|
|
186
|
-
}, "paragraph");
|
|
187
|
-
// Table
|
|
188
|
-
register(Table, (el) => {
|
|
189
|
-
const tableStructure = extractTableStructure(el);
|
|
190
|
-
return {
|
|
191
|
-
type: "text",
|
|
192
|
-
text: "", // Renderer will build the text from structure
|
|
193
|
-
semantic: {
|
|
194
|
-
type: "table",
|
|
195
|
-
structure: tableStructure,
|
|
196
|
-
},
|
|
197
|
-
};
|
|
198
|
-
}, "table");
|
|
199
|
-
// List
|
|
200
|
-
register(List, (el) => {
|
|
201
|
-
const listStructure = extractListStructure(el);
|
|
202
|
-
return {
|
|
203
|
-
type: "text",
|
|
204
|
-
text: "", // Renderer will build the text from structure
|
|
205
|
-
semantic: {
|
|
206
|
-
type: "list",
|
|
207
|
-
structure: listStructure,
|
|
208
|
-
},
|
|
209
|
-
};
|
|
210
|
-
}, "list");
|
|
211
|
-
// Note: Inline formatting elements (strong, em, code, etc.) are NOT registered here.
|
|
212
|
-
// They are handled by INLINE_SEMANTIC_TYPES in extractors.ts and should only be used
|
|
213
|
-
// nested inside text content blocks like <Text>, <p>, etc.
|
|
214
|
-
// Using them at the top level (e.g., <Message><strong>text</strong></Message>) is incorrect.
|
|
215
|
-
// Block elements
|
|
216
|
-
// Note: 'p' and 'blockquote' are registered earlier with semantic tree support
|
|
217
|
-
register("ul", (el) => {
|
|
218
|
-
const listStructure = extractListStructure(el);
|
|
219
|
-
return {
|
|
220
|
-
type: "text",
|
|
221
|
-
text: "",
|
|
222
|
-
semantic: {
|
|
223
|
-
type: "list",
|
|
224
|
-
structure: listStructure,
|
|
225
|
-
},
|
|
226
|
-
};
|
|
227
|
-
}, "ul");
|
|
228
|
-
register("ol", (el) => {
|
|
229
|
-
const listStructure = extractListStructure(el);
|
|
230
|
-
return {
|
|
231
|
-
type: "text",
|
|
232
|
-
text: "",
|
|
233
|
-
semantic: {
|
|
234
|
-
type: "list",
|
|
235
|
-
structure: { ...listStructure, ordered: true },
|
|
236
|
-
},
|
|
237
|
-
};
|
|
238
|
-
}, "ol");
|
|
239
|
-
register("li", (el) => {
|
|
240
|
-
// ListItem is handled by parent List/ul/ol
|
|
241
|
-
const text = extractTextFromElement(el);
|
|
242
|
-
return {
|
|
243
|
-
type: "text",
|
|
244
|
-
text,
|
|
245
|
-
semantic: { type: "list-item" },
|
|
246
|
-
};
|
|
247
|
-
}, "li");
|
|
248
|
-
// Note: 'blockquote' is registered earlier with semantic tree support
|
|
249
|
-
register("pre", (el) => {
|
|
250
|
-
const text = extractTextFromElement(el);
|
|
251
|
-
return {
|
|
252
|
-
type: "code",
|
|
253
|
-
language: "other",
|
|
254
|
-
text,
|
|
255
|
-
};
|
|
256
|
-
}, "pre");
|
|
257
|
-
register("br", () => {
|
|
258
|
-
return {
|
|
259
|
-
type: "text",
|
|
260
|
-
text: "\n",
|
|
261
|
-
semantic: { type: "line-break" },
|
|
262
|
-
};
|
|
263
|
-
}, "br");
|
|
264
|
-
register("hr", () => {
|
|
265
|
-
return {
|
|
266
|
-
type: "text",
|
|
267
|
-
text: "---",
|
|
268
|
-
semantic: { type: "horizontal-rule" },
|
|
269
|
-
};
|
|
270
|
-
}, "hr");
|
|
271
|
-
// Event block components
|
|
272
|
-
register(UserAction, (el) => {
|
|
273
|
-
const { action, actor, target, details, children } = el.props;
|
|
274
|
-
const text = typeof children === "string" ? children : undefined;
|
|
275
|
-
return {
|
|
276
|
-
type: "user_action",
|
|
277
|
-
action,
|
|
278
|
-
actor,
|
|
279
|
-
target,
|
|
280
|
-
details,
|
|
281
|
-
text,
|
|
282
|
-
};
|
|
283
|
-
}, "user_action");
|
|
284
|
-
register(SystemEvent, (el) => {
|
|
285
|
-
const { event, source, data, children } = el.props;
|
|
286
|
-
const text = typeof children === "string" ? children : undefined;
|
|
287
|
-
return {
|
|
288
|
-
type: "system_event",
|
|
289
|
-
event,
|
|
290
|
-
source,
|
|
291
|
-
data,
|
|
292
|
-
text,
|
|
293
|
-
};
|
|
294
|
-
}, "system_event");
|
|
295
|
-
register(StateChange, (el) => {
|
|
296
|
-
const { entity, field, from, to, trigger, children } = el.props;
|
|
297
|
-
const text = typeof children === "string" ? children : undefined;
|
|
298
|
-
return {
|
|
299
|
-
type: "state_change",
|
|
300
|
-
entity,
|
|
301
|
-
field,
|
|
302
|
-
from,
|
|
303
|
-
to,
|
|
304
|
-
trigger,
|
|
305
|
-
text,
|
|
306
|
-
};
|
|
307
|
-
}, "state_change");
|
|
308
|
-
// Note: Other HTML elements (a, q, cite, kbd, var, etc.) are handled via
|
|
309
|
-
// INLINE_SEMANTIC_TYPES when nested inside text content.
|
|
310
|
-
// Custom/unknown elements are handled by the compiler's fallback mechanism.
|
|
311
|
-
}
|
|
312
|
-
//# sourceMappingURL=content-block-registry.js.map
|