wunderland 0.51.0 → 0.52.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/README.md +134 -2
- package/dist/advanced/index.d.ts +9 -1
- package/dist/advanced/index.d.ts.map +1 -1
- package/dist/advanced/index.js +9 -1
- package/dist/advanced/index.js.map +1 -1
- package/dist/api/server.d.ts +4 -0
- package/dist/api/server.d.ts.map +1 -1
- package/dist/api/server.js +39 -0
- package/dist/api/server.js.map +1 -1
- package/dist/api/types.d.ts +5 -0
- package/dist/api/types.d.ts.map +1 -1
- package/dist/cli/commands/chat.d.ts.map +1 -1
- package/dist/cli/commands/chat.js +271 -2
- package/dist/cli/commands/chat.js.map +1 -1
- package/dist/cli/commands/completions.d.ts.map +1 -1
- package/dist/cli/commands/completions.js +12 -1
- package/dist/cli/commands/completions.js.map +1 -1
- package/dist/cli/commands/connect.d.ts.map +1 -1
- package/dist/cli/commands/connect.js +3 -14
- package/dist/cli/commands/connect.js.map +1 -1
- package/dist/cli/commands/doctor.d.ts.map +1 -1
- package/dist/cli/commands/doctor.js +50 -0
- package/dist/cli/commands/doctor.js.map +1 -1
- package/dist/cli/commands/extensions.d.ts.map +1 -1
- package/dist/cli/commands/extensions.js +3 -40
- package/dist/cli/commands/extensions.js.map +1 -1
- package/dist/cli/commands/image.d.ts +17 -0
- package/dist/cli/commands/image.d.ts.map +1 -0
- package/dist/cli/commands/image.js +109 -0
- package/dist/cli/commands/image.js.map +1 -0
- package/dist/cli/commands/init.js +1 -1
- package/dist/cli/commands/init.js.map +1 -1
- package/dist/cli/commands/mission.d.ts +12 -0
- package/dist/cli/commands/mission.d.ts.map +1 -0
- package/dist/cli/commands/mission.js +93 -0
- package/dist/cli/commands/mission.js.map +1 -0
- package/dist/cli/commands/skills.d.ts.map +1 -1
- package/dist/cli/commands/skills.js +3 -49
- package/dist/cli/commands/skills.js.map +1 -1
- package/dist/cli/commands/start/http-server.d.ts.map +1 -1
- package/dist/cli/commands/start/http-server.js +27 -0
- package/dist/cli/commands/start/http-server.js.map +1 -1
- package/dist/cli/commands/status.d.ts +4 -5
- package/dist/cli/commands/status.d.ts.map +1 -1
- package/dist/cli/commands/status.js +15 -15
- package/dist/cli/commands/status.js.map +1 -1
- package/dist/cli/commands/structured.d.ts +19 -0
- package/dist/cli/commands/structured.d.ts.map +1 -0
- package/dist/cli/commands/structured.js +126 -0
- package/dist/cli/commands/structured.js.map +1 -0
- package/dist/cli/commands/workflows.d.ts +6 -0
- package/dist/cli/commands/workflows.d.ts.map +1 -1
- package/dist/cli/commands/workflows.js +184 -9
- package/dist/cli/commands/workflows.js.map +1 -1
- package/dist/cli/constants.d.ts +1 -0
- package/dist/cli/constants.d.ts.map +1 -1
- package/dist/cli/constants.js +1 -0
- package/dist/cli/constants.js.map +1 -1
- package/dist/cli/help/topics.d.ts +1 -1
- package/dist/cli/help/topics.d.ts.map +1 -1
- package/dist/cli/help/topics.js +170 -0
- package/dist/cli/help/topics.js.map +1 -1
- package/dist/cli/helpers/build-agent-scaffold.d.ts.map +1 -1
- package/dist/cli/helpers/build-agent-scaffold.js +8 -0
- package/dist/cli/helpers/build-agent-scaffold.js.map +1 -1
- package/dist/cli/index.d.ts.map +1 -1
- package/dist/cli/index.js +33 -5
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/tui/views/extensions-view.d.ts.map +1 -1
- package/dist/cli/tui/views/extensions-view.js +4 -6
- package/dist/cli/tui/views/extensions-view.js.map +1 -1
- package/dist/cli/tui/views/skills-view.d.ts.map +1 -1
- package/dist/cli/tui/views/skills-view.js +4 -6
- package/dist/cli/tui/views/skills-view.js.map +1 -1
- package/dist/cli/utils/search-scoring.d.ts +43 -0
- package/dist/cli/utils/search-scoring.d.ts.map +1 -0
- package/dist/cli/utils/search-scoring.js +106 -0
- package/dist/cli/utils/search-scoring.js.map +1 -0
- package/dist/observability/session-text-log.d.ts +73 -0
- package/dist/observability/session-text-log.d.ts.map +1 -0
- package/dist/observability/session-text-log.js +187 -0
- package/dist/observability/session-text-log.js.map +1 -0
- package/dist/observability/token-usage.d.ts +23 -0
- package/dist/observability/token-usage.d.ts.map +1 -0
- package/dist/observability/token-usage.js +24 -0
- package/dist/observability/token-usage.js.map +1 -0
- package/dist/observability/usage-ledger.d.ts +51 -0
- package/dist/observability/usage-ledger.d.ts.map +1 -0
- package/dist/observability/usage-ledger.js +233 -0
- package/dist/observability/usage-ledger.js.map +1 -0
- package/dist/orchestration/index.d.ts +3 -0
- package/dist/orchestration/index.d.ts.map +1 -0
- package/dist/orchestration/index.js +3 -0
- package/dist/orchestration/index.js.map +1 -0
- package/dist/orchestration/yaml-compiler.d.ts +112 -0
- package/dist/orchestration/yaml-compiler.d.ts.map +1 -0
- package/dist/orchestration/yaml-compiler.js +270 -0
- package/dist/orchestration/yaml-compiler.js.map +1 -0
- package/dist/orchestration/yaml-schema.d.ts +37 -0
- package/dist/orchestration/yaml-schema.d.ts.map +1 -0
- package/dist/orchestration/yaml-schema.js +62 -0
- package/dist/orchestration/yaml-schema.js.map +1 -0
- package/dist/public/index.d.ts +6 -1
- package/dist/public/index.d.ts.map +1 -1
- package/dist/public/index.js +403 -2
- package/dist/public/index.js.map +1 -1
- package/dist/public/types.d.ts +82 -6
- package/dist/public/types.d.ts.map +1 -1
- package/dist/runtime/graph-runner.d.ts +45 -0
- package/dist/runtime/graph-runner.d.ts.map +1 -0
- package/dist/runtime/graph-runner.js +232 -0
- package/dist/runtime/graph-runner.js.map +1 -0
- package/dist/runtime/index.d.ts +1 -0
- package/dist/runtime/index.d.ts.map +1 -1
- package/dist/runtime/index.js +1 -0
- package/dist/runtime/index.js.map +1 -1
- package/dist/runtime/llm-stream-adapter.d.ts +101 -0
- package/dist/runtime/llm-stream-adapter.d.ts.map +1 -0
- package/dist/runtime/llm-stream-adapter.js +180 -0
- package/dist/runtime/llm-stream-adapter.js.map +1 -0
- package/dist/runtime/tool-calling.d.ts +81 -0
- package/dist/runtime/tool-calling.d.ts.map +1 -1
- package/dist/runtime/tool-calling.js +1040 -497
- package/dist/runtime/tool-calling.js.map +1 -1
- package/dist/runtime/tool-helpers.d.ts +42 -0
- package/dist/runtime/tool-helpers.d.ts.map +1 -1
- package/dist/runtime/tool-helpers.js +166 -0
- package/dist/runtime/tool-helpers.js.map +1 -1
- package/dist/security/WunderlandSecurityPipeline.d.ts.map +1 -1
- package/dist/security/WunderlandSecurityPipeline.js +5 -0
- package/dist/security/WunderlandSecurityPipeline.js.map +1 -1
- package/dist/voice/index.d.ts +6 -0
- package/dist/voice/index.d.ts.map +1 -1
- package/dist/voice/index.js +6 -0
- package/dist/voice/index.js.map +1 -1
- package/dist/voice/streaming-pipeline.d.ts +115 -0
- package/dist/voice/streaming-pipeline.d.ts.map +1 -0
- package/dist/voice/streaming-pipeline.js +162 -0
- package/dist/voice/streaming-pipeline.js.map +1 -0
- package/dist/voice/telephony-webhook-server.d.ts +79 -0
- package/dist/voice/telephony-webhook-server.d.ts.map +1 -0
- package/dist/voice/telephony-webhook-server.js +157 -0
- package/dist/voice/telephony-webhook-server.js.map +1 -0
- package/dist/voice/ws-server.d.ts +73 -0
- package/dist/voice/ws-server.d.ts.map +1 -0
- package/dist/voice/ws-server.js +186 -0
- package/dist/voice/ws-server.js.map +1 -0
- package/dist/workflows/index.d.ts +9 -2
- package/dist/workflows/index.d.ts.map +1 -1
- package/dist/workflows/index.js +9 -2
- package/dist/workflows/index.js.map +1 -1
- package/package.json +12 -6
- package/presets/missions/deep-research.mission.yaml +15 -0
- package/presets/missions/report-writer.mission.yaml +14 -0
- package/presets/workflows/content-generation.workflow.yaml +21 -0
- package/presets/workflows/data-extraction.workflow.yaml +20 -0
- package/presets/workflows/evaluation.workflow.yaml +21 -0
- package/presets/workflows/research-pipeline.workflow.yaml +19 -0
package/README.md
CHANGED
|
@@ -76,7 +76,7 @@
|
|
|
76
76
|
- **Tool registry** -- Loads curated AgentOS tools via `@framers/agentos-extensions-registry`
|
|
77
77
|
- **Memory hooks** -- Optional `memory_read` tool with pluggable storage (SQL, vector, graph)
|
|
78
78
|
- **Immutability** -- Seal agent configuration after setup; rotate operational secrets without changing the sealed spec
|
|
79
|
-
- **Streamlined library API** -- `createWunderland()` + sessions from the root import
|
|
79
|
+
- **Streamlined library API** -- `createWunderland()` + sessions from the root import, plus `app.runGraph(...)` / `app.streamGraph(...)` for orchestrated execution
|
|
80
80
|
- **RAG memory** -- Multimodal retrieval-augmented generation with vector, graph, and hybrid search
|
|
81
81
|
- **Multi-agent collectives** -- Agency registry, communication bus, and shared memory
|
|
82
82
|
- **Knowledge graph** -- Entity extraction, semantic search, and graph traversal
|
|
@@ -100,7 +100,7 @@ wunderland/
|
|
|
100
100
|
browser/ BrowserClient, BrowserSession, BrowserInteractions
|
|
101
101
|
scheduling/ CronScheduler (one-shot, interval, cron expression)
|
|
102
102
|
agency/ AgencyRegistry, AgentCommunicationBus, AgencyMemoryManager
|
|
103
|
-
workflows/ WorkflowEngine,
|
|
103
|
+
workflows/ AgentGraph, workflow(), mission(), WorkflowEngine, graph execution bridge
|
|
104
104
|
planning/ PlanningEngine, task decomposition, autonomous loops
|
|
105
105
|
evaluation/ Evaluator, LLMJudge, criteria presets
|
|
106
106
|
knowledge/ KnowledgeGraph, entity extraction, semantic search
|
|
@@ -133,8 +133,13 @@ const session = app.session();
|
|
|
133
133
|
const out = await session.sendText('Hello!');
|
|
134
134
|
|
|
135
135
|
console.log(out.text);
|
|
136
|
+
console.log(await session.usage());
|
|
136
137
|
```
|
|
137
138
|
|
|
139
|
+
Usage and cost totals are persisted in the shared home ledger at `~/.framers/usage-ledger.jsonl` by default, so `wunderland status`, `app.usage()`, and `session.usage()` can all inspect cumulative model usage across separate runs. If you want a different shared file, set `AGENTOS_USAGE_LEDGER_PATH` or `WUNDERLAND_USAGE_LEDGER_PATH`. If you want Wunderland-only isolation, pass an explicit config-dir override.
|
|
140
|
+
|
|
141
|
+
For config-backed agent runs, Wunderland also writes dated plain-text session logs under `./logs/YYYY-MM-DD/*.log` by default. Disable that with `observability.textLogs.enabled=false`, or move it with `observability.textLogs.directory`.
|
|
142
|
+
|
|
138
143
|
### Why `createWunderland()` instead of AgentOS `agent()`
|
|
139
144
|
|
|
140
145
|
Wunderland intentionally keeps `createWunderland()` as its public library entrypoint.
|
|
@@ -144,6 +149,51 @@ Wunderland intentionally keeps `createWunderland()` as its public library entryp
|
|
|
144
149
|
|
|
145
150
|
That means Wunderland should document the AgentOS high-level API, but it should not replace its own runtime with `agent()` until that helper covers the same operational surface.
|
|
146
151
|
|
|
152
|
+
### Orchestrated execution with `wunderland/workflows`
|
|
153
|
+
|
|
154
|
+
Use the AgentOS orchestration builders for authoring, then execute the compiled graph through Wunderland so you keep its tools, approvals, extension loading, and runtime policies.
|
|
155
|
+
|
|
156
|
+
```ts
|
|
157
|
+
import { createWunderland } from 'wunderland';
|
|
158
|
+
import { workflow } from 'wunderland/workflows';
|
|
159
|
+
|
|
160
|
+
const app = await createWunderland({
|
|
161
|
+
llm: { providerId: 'openai' },
|
|
162
|
+
tools: 'curated',
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
const compiled = workflow('research-pipeline')
|
|
166
|
+
.input({
|
|
167
|
+
type: 'object',
|
|
168
|
+
required: ['topic'],
|
|
169
|
+
properties: { topic: { type: 'string' } },
|
|
170
|
+
})
|
|
171
|
+
.returns({
|
|
172
|
+
type: 'object',
|
|
173
|
+
properties: { finalSummary: { type: 'string' } },
|
|
174
|
+
})
|
|
175
|
+
.step('research', {
|
|
176
|
+
gmi: {
|
|
177
|
+
instructions: 'Research the topic and return JSON under scratch.research.',
|
|
178
|
+
},
|
|
179
|
+
})
|
|
180
|
+
.then('judge', {
|
|
181
|
+
gmi: {
|
|
182
|
+
instructions: 'Score the research and return JSON under scratch.judge.',
|
|
183
|
+
},
|
|
184
|
+
})
|
|
185
|
+
.compile();
|
|
186
|
+
|
|
187
|
+
const result = await app.runGraph(compiled, { topic: 'graph-based agent runtimes' });
|
|
188
|
+
console.log(result);
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
Use:
|
|
192
|
+
|
|
193
|
+
- `workflow()` for deterministic DAGs and explicit step ordering
|
|
194
|
+
- `AgentGraph` for loops, routers, and custom control flow
|
|
195
|
+
- `mission()` for planner-driven orchestration that compiles to the same graph IR
|
|
196
|
+
|
|
147
197
|
### With skills + extensions + discovery
|
|
148
198
|
|
|
149
199
|
```ts
|
|
@@ -275,6 +325,7 @@ wunderland
|
|
|
275
325
|
# Health check + operator help
|
|
276
326
|
wunderland doctor
|
|
277
327
|
wunderland help getting-started
|
|
328
|
+
wunderland help workflows
|
|
278
329
|
wunderland help tui
|
|
279
330
|
|
|
280
331
|
# Configure shared provider defaults (image gen, TTS, STT, web search)
|
|
@@ -300,12 +351,93 @@ wunderland doctor
|
|
|
300
351
|
- `examples/library-chat-basic.mjs` — minimal in-process chat
|
|
301
352
|
- `examples/library-chat-with-tools-and-approvals.mjs` — curated tools + safe approvals
|
|
302
353
|
- `examples/library-chat-image-generation.mjs` — image generation extension with provider defaults
|
|
354
|
+
- `examples/workflow-orchestration.mjs` — deterministic `workflow()` with an LLM-as-judge step
|
|
355
|
+
- `examples/agent-graph-orchestration.mjs` — explicit `AgentGraph` routing with a judge loop
|
|
356
|
+
- `examples/mission-orchestration.mjs` — planner-driven `mission()` plus `explain()` and execution
|
|
303
357
|
- `examples/chat-runtime.mjs` — lower-level runtime helper
|
|
358
|
+
- `examples/workflow-research.yaml` — runnable research-pipeline workflow (search → evaluate → summarize)
|
|
359
|
+
- `examples/mission-deep-research.yaml` — intent-driven deep research mission definition
|
|
360
|
+
- `examples/graph-research-loop.ts` — AgentGraph with conditional retry cycle
|
|
361
|
+
- `examples/graph-judge-pipeline.ts` — LLM-as-judge evaluation pipeline using judgeNode
|
|
362
|
+
- `examples/session-streaming.ts` — streaming session events with `session.stream()`
|
|
363
|
+
- `examples/checkpoint-resume.ts` — checkpoint and resume across session turns
|
|
304
364
|
|
|
305
365
|
See `docs/CLI_TUI_GUIDE.md` for the first-run checklist, TUI keybindings, help topics, troubleshooting pointers, and provider-default setup.
|
|
306
366
|
|
|
307
367
|
---
|
|
308
368
|
|
|
369
|
+
## Graph-Based Orchestration
|
|
370
|
+
|
|
371
|
+
Wunderland supports three levels of workflow orchestration powered by the AgentOS unified orchestration layer:
|
|
372
|
+
|
|
373
|
+
### YAML Workflows (Deterministic DAGs)
|
|
374
|
+
|
|
375
|
+
```yaml
|
|
376
|
+
# research-pipeline.workflow.yaml
|
|
377
|
+
name: research-pipeline
|
|
378
|
+
steps:
|
|
379
|
+
- id: search
|
|
380
|
+
tool: web_search
|
|
381
|
+
- id: evaluate
|
|
382
|
+
gmi: { instructions: "Evaluate results" }
|
|
383
|
+
- id: summarize
|
|
384
|
+
gmi: { instructions: "Write summary" }
|
|
385
|
+
```
|
|
386
|
+
|
|
387
|
+
```bash
|
|
388
|
+
# Execute a workflow YAML file
|
|
389
|
+
wunderland workflows run research-pipeline.workflow.yaml
|
|
390
|
+
|
|
391
|
+
# Print the compiled node/edge graph
|
|
392
|
+
wunderland workflows explain research-pipeline.workflow.yaml
|
|
393
|
+
```
|
|
394
|
+
|
|
395
|
+
### YAML Missions (Intent-Driven)
|
|
396
|
+
|
|
397
|
+
```bash
|
|
398
|
+
# Execute a mission YAML file
|
|
399
|
+
wunderland mission run deep-research.mission.yaml
|
|
400
|
+
|
|
401
|
+
# Show the planner-derived mission graph
|
|
402
|
+
wunderland mission explain deep-research.mission.yaml
|
|
403
|
+
```
|
|
404
|
+
|
|
405
|
+
### Library API
|
|
406
|
+
|
|
407
|
+
```typescript
|
|
408
|
+
import { createWunderland } from 'wunderland';
|
|
409
|
+
|
|
410
|
+
const app = await createWunderland({ llm: { providerId: 'openai', model: 'gpt-4o' } });
|
|
411
|
+
|
|
412
|
+
// Load and compile a workflow
|
|
413
|
+
const flow = await app.loadWorkflow('./research-pipeline.workflow.yaml');
|
|
414
|
+
|
|
415
|
+
// Stream session events
|
|
416
|
+
const session = app.session();
|
|
417
|
+
for await (const event of session.stream('Hello')) {
|
|
418
|
+
if (event.type === 'text_delta') process.stdout.write(event.content);
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
// Checkpoint and resume
|
|
422
|
+
const cpId = await session.checkpoint();
|
|
423
|
+
await session.resume(cpId);
|
|
424
|
+
```
|
|
425
|
+
|
|
426
|
+
### Prebuilt Templates
|
|
427
|
+
|
|
428
|
+
| Template | Type | Description |
|
|
429
|
+
|----------|------|-------------|
|
|
430
|
+
| `research-pipeline` | workflow | Search → evaluate → summarize |
|
|
431
|
+
| `content-generation` | workflow | Draft → judge → revise |
|
|
432
|
+
| `data-extraction` | workflow | Fetch → extract → validate |
|
|
433
|
+
| `evaluation` | workflow | Multi-judge scoring |
|
|
434
|
+
| `deep-research` | mission | Planner-driven research |
|
|
435
|
+
| `report-writer` | mission | Structured report generation |
|
|
436
|
+
|
|
437
|
+
See `presets/workflows/` and `presets/missions/` for all templates.
|
|
438
|
+
|
|
439
|
+
---
|
|
440
|
+
|
|
309
441
|
## What is Wunderland?
|
|
310
442
|
|
|
311
443
|
**Wunderland** is a free, open-source npm package for deploying autonomous AI agents. It's a security-hardened fork of [OpenClaw](https://github.com/openclaw) built on [AgentOS](https://agentos.sh), adding:
|
package/dist/advanced/index.d.ts
CHANGED
|
@@ -7,7 +7,15 @@
|
|
|
7
7
|
* (new ergonomic API) unless you specifically need low-level modules.
|
|
8
8
|
*/
|
|
9
9
|
export * from '../core/index.js';
|
|
10
|
-
export * from '../security/
|
|
10
|
+
export * from '../security/types.js';
|
|
11
|
+
export { PreLLMClassifier, type PreLLMClassifierConfig, } from '../security/PreLLMClassifier.js';
|
|
12
|
+
export { DualLLMAuditor } from '../security/DualLLMAuditor.js';
|
|
13
|
+
export { SignedOutputVerifier, IntentChainTracker, } from '../security/SignedOutputVerifier.js';
|
|
14
|
+
export { type SecurityTierName, type SecurityTierConfig, type EnhancedSecurityTierConfig, SECURITY_TIERS, getSecurityTier, createPipelineFromTier, isValidSecurityTier, } from '../security/SecurityTiers.js';
|
|
15
|
+
export { SafeGuardrails, type SafeGuardrailsConfig } from '../security/SafeGuardrails.js';
|
|
16
|
+
export { AuditLogger, type AuditLoggerConfig, type ViolationFilter, type ViolationStats, } from '../security/AuditLogger.js';
|
|
17
|
+
export { type FolderAccessRule, type FolderPermissionConfig, type FolderPermissionResult, type ValidationResult as FolderValidationResult, checkFolderAccess, createDefaultFolderConfig, validateFolderConfig, isContainedPath, validatePluginPath, } from '../security/FolderPermissions.js';
|
|
18
|
+
export { ToolLoopDetector, type ToolLoopDetectorConfig, type LoopDetectionResult, } from '../security/ToolLoopDetector.js';
|
|
11
19
|
export * from '../inference/index.js';
|
|
12
20
|
export * from '../authorization/index.js';
|
|
13
21
|
export * from '../browser/index.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/advanced/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAKH,cAAc,kBAAkB,CAAC;AAGjC,cAAc,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/advanced/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAKH,cAAc,kBAAkB,CAAC;AAGjC,cAAc,sBAAsB,CAAC;AACrC,OAAO,EACL,gBAAgB,EAChB,KAAK,sBAAsB,GAC5B,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAC/D,OAAO,EACL,oBAAoB,EACpB,kBAAkB,GACnB,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EACL,KAAK,gBAAgB,EACrB,KAAK,kBAAkB,EACvB,KAAK,0BAA0B,EAC/B,cAAc,EACd,eAAe,EACf,sBAAsB,EACtB,mBAAmB,GACpB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,cAAc,EAAE,KAAK,oBAAoB,EAAE,MAAM,+BAA+B,CAAC;AAC1F,OAAO,EACL,WAAW,EACX,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MAAM,8BAA8B,CAAC;AAG9D,OAAO,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AAK/D,eAAO,MAAM,OAAO,QAAc,CAAC;AACnC,eAAO,MAAM,YAAY,QAAW,CAAC"}
|
package/dist/advanced/index.js
CHANGED
|
@@ -10,7 +10,15 @@ import { createRequire } from 'node:module';
|
|
|
10
10
|
// Core exports
|
|
11
11
|
export * from '../core/index.js';
|
|
12
12
|
// Security exports
|
|
13
|
-
export * from '../security/
|
|
13
|
+
export * from '../security/types.js';
|
|
14
|
+
export { PreLLMClassifier, } from '../security/PreLLMClassifier.js';
|
|
15
|
+
export { DualLLMAuditor } from '../security/DualLLMAuditor.js';
|
|
16
|
+
export { SignedOutputVerifier, IntentChainTracker, } from '../security/SignedOutputVerifier.js';
|
|
17
|
+
export { SECURITY_TIERS, getSecurityTier, createPipelineFromTier, isValidSecurityTier, } from '../security/SecurityTiers.js';
|
|
18
|
+
export { SafeGuardrails } from '../security/SafeGuardrails.js';
|
|
19
|
+
export { AuditLogger, } from '../security/AuditLogger.js';
|
|
20
|
+
export { checkFolderAccess, createDefaultFolderConfig, validateFolderConfig, isContainedPath, validatePluginPath, } from '../security/FolderPermissions.js';
|
|
21
|
+
export { ToolLoopDetector, } from '../security/ToolLoopDetector.js';
|
|
14
22
|
// Inference exports
|
|
15
23
|
export * from '../inference/index.js';
|
|
16
24
|
// Authorization exports
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/advanced/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE5C,eAAe;AACf,cAAc,kBAAkB,CAAC;AAEjC,mBAAmB;AACnB,cAAc,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/advanced/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,aAAa,EA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AAa,EAAE,MAAM,6BAA6B,CAAC;AAC5D,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAC9D,OAAO,EAAE,mBAAmB,EAAE,MAAM,mCAAmC,CAAC;AAExE,iCAAiC;AACjC,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAE9D,sCAAsC;AACtC,OAAO,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AAE/D,mDAAmD;AACnD,MAAM,OAAO,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC/C,MAAM,GAAG,GAAG,OAAO,CAAC,oBAAoB,CAAsC,CAAC;AAC/E,MAAM,CAAC,MAAM,OAAO,GAAG,GAAG,CAAC,OAAO,CAAC;AACnC,MAAM,CAAC,MAAM,YAAY,GAAG,GAAG,CAAC,IAAI,CAAC"}
|
package/dist/api/server.d.ts
CHANGED
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
import { type Server } from 'node:http';
|
|
15
15
|
import { type LLMProviderConfig } from '../runtime/tool-calling.js';
|
|
16
16
|
import { type NormalizedRuntimePolicy } from '../runtime/policy.js';
|
|
17
|
+
import type { TokenUsageSummary } from '../core/TokenUsageTracker.js';
|
|
17
18
|
import type { WunderlandAdaptiveExecutionConfig, WunderlandAgentConfig, WunderlandProviderId, WunderlandTaskOutcomeTelemetryConfig, WunderlandToolFailureMode, WunderlandWorkspace } from './types.js';
|
|
18
19
|
type LoggerLike = {
|
|
19
20
|
debug?: (msg: string, meta?: unknown) => void;
|
|
@@ -42,6 +43,9 @@ export type WunderlandServerHandle = {
|
|
|
42
43
|
autoApproveToolCalls: boolean;
|
|
43
44
|
turnApprovalMode: 'off' | 'after-each-turn' | 'after-each-round';
|
|
44
45
|
openaiFallbackEnabled: boolean;
|
|
46
|
+
usage: (opts?: {
|
|
47
|
+
sessionId?: string;
|
|
48
|
+
}) => Promise<TokenUsageSummary>;
|
|
45
49
|
close: () => Promise<void>;
|
|
46
50
|
};
|
|
47
51
|
export declare function createWunderlandServer(opts?: {
|
package/dist/api/server.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/api/server.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAKH,OAAO,EAAgB,KAAK,MAAM,EAAE,MAAM,WAAW,CAAC;AAqBtD,OAAO,EAGL,KAAK,iBAAiB,EAEvB,MAAM,4BAA4B,CAAC;AAKpC,OAAO,EAIL,KAAK,uBAAuB,EAC7B,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/api/server.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAKH,OAAO,EAAgB,KAAK,MAAM,EAAE,MAAM,WAAW,CAAC;AAqBtD,OAAO,EAGL,KAAK,iBAAiB,EAEvB,MAAM,4BAA4B,CAAC;AAKpC,OAAO,EAIL,KAAK,uBAAuB,EAC7B,MAAM,sBAAsB,CAAC;AAqB9B,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AAEtE,OAAO,KAAK,EACV,iCAAiC,EACjC,qBAAqB,EACrB,oBAAoB,EACpB,oCAAoC,EACpC,yBAAyB,EACzB,mBAAmB,EACpB,MAAM,YAAY,CAAC;AAEpB,KAAK,UAAU,GAAG;IAChB,KAAK,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO,KAAK,IAAI,CAAC;IAC9C,IAAI,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO,KAAK,IAAI,CAAC;IAC7C,IAAI,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO,KAAK,IAAI,CAAC;IAC7C,KAAK,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,EA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|
import { maybeProxyAgentosRagRequest } from '../rag/http-proxy.js';
|
|
42
42
|
import { mergeExtensionOverrides } from '../cli/extensions/settings.js';
|
|
43
43
|
import { createSpeechExtensionEnvOverrides, getDefaultVoiceExtensions, } from '../voice/speech-catalog.js';
|
|
44
|
+
import { getRecordedWunderlandSessionUsage, getRecordedWunderlandTokenUsage } from '../observability/token-usage.js';
|
|
45
|
+
import { resolveWunderlandTextLogConfig, WunderlandSessionTextLogger } from '../observability/session-text-log.js';
|
|
44
46
|
// HTTP helpers extracted to server-helpers.ts
|
|
45
47
|
export { consoleLogger, toToolInstance, readBody, sendJson, getHeaderString, extractHitlSecret, isHitlAuthorized, inferTurnApprovalMode, finiteNumber, HITL_PAGE_HTML, PAIRING_PAGE_HTML, } from "./server-helpers.js";
|
|
46
48
|
import { consoleLogger, toToolInstance, readBody, sendJson, isHitlAuthorized, inferTurnApprovalMode, finiteNumber, HITL_PAGE_HTML, PAIRING_PAGE_HTML, } from "./server-helpers.js";
|
|
@@ -150,6 +152,13 @@ export async function createWunderlandServer(opts) {
|
|
|
150
152
|
const lazyTools = opts?.lazyTools === true || cfg?.lazyTools === true;
|
|
151
153
|
const workspaceBaseDir = opts?.workspace?.baseDir ?? resolveAgentWorkspaceBaseDir();
|
|
152
154
|
const workspaceAgentId = sanitizeAgentWorkspaceId(opts?.workspace?.agentId ?? seedId);
|
|
155
|
+
const sessionTextLogger = new WunderlandSessionTextLogger(resolveWunderlandTextLogConfig({
|
|
156
|
+
agentConfig: cfg,
|
|
157
|
+
workingDirectory,
|
|
158
|
+
workspace: { agentId: workspaceAgentId, baseDir: workspaceBaseDir },
|
|
159
|
+
defaultAgentId: workspaceAgentId,
|
|
160
|
+
configBacked: true,
|
|
161
|
+
}), logger);
|
|
153
162
|
const ollamaBaseUrl = (() => {
|
|
154
163
|
if (opts?.llm?.baseUrl)
|
|
155
164
|
return opts.llm.baseUrl;
|
|
@@ -737,6 +746,7 @@ export async function createWunderlandServer(opts) {
|
|
|
737
746
|
if (canUseLLM) {
|
|
738
747
|
const toolContext = {
|
|
739
748
|
gmiId: `wunderland-channel-${sessionKey}`,
|
|
749
|
+
sessionId: sessionKey,
|
|
740
750
|
personaId: activePersonaId,
|
|
741
751
|
userContext: {
|
|
742
752
|
userId: senderId,
|
|
@@ -744,6 +754,7 @@ export async function createWunderlandServer(opts) {
|
|
|
744
754
|
conversationId,
|
|
745
755
|
...(tenantId ? { organizationId: tenantId } : null),
|
|
746
756
|
},
|
|
757
|
+
...(opts?.configDirOverride ? { wunderlandConfigDir: opts.configDirOverride } : null),
|
|
747
758
|
agentWorkspace: { agentId: workspaceAgentId, baseDir: workspaceBaseDir },
|
|
748
759
|
permissionSet: policy.permissionSet,
|
|
749
760
|
securityTier: policy.securityTier,
|
|
@@ -1130,6 +1141,7 @@ export async function createWunderlandServer(opts) {
|
|
|
1130
1141
|
let turnFailed = false;
|
|
1131
1142
|
let fallbackTriggered = false;
|
|
1132
1143
|
let toolCallCount = 0;
|
|
1144
|
+
let turnError;
|
|
1133
1145
|
const sessionId = typeof parsed.sessionId === 'string' && parsed.sessionId.trim() ? parsed.sessionId.trim().slice(0, 128) : 'default';
|
|
1134
1146
|
const requestedPersonaId = extractRequestedPersonaId(parsed);
|
|
1135
1147
|
let requestActivePersonaId = activePersonaId;
|
|
@@ -1194,11 +1206,13 @@ export async function createWunderlandServer(opts) {
|
|
|
1194
1206
|
if (canUseLLM) {
|
|
1195
1207
|
const toolContext = {
|
|
1196
1208
|
gmiId: `wunderland-server-${internalSessionId}`,
|
|
1209
|
+
sessionId,
|
|
1197
1210
|
personaId: requestActivePersonaId,
|
|
1198
1211
|
userContext: {
|
|
1199
1212
|
userId: sessionId,
|
|
1200
1213
|
...(tenantId ? { organizationId: tenantId } : null),
|
|
1201
1214
|
},
|
|
1215
|
+
...(opts?.configDirOverride ? { wunderlandConfigDir: opts.configDirOverride } : null),
|
|
1202
1216
|
agentWorkspace: { agentId: workspaceAgentId, baseDir: workspaceBaseDir },
|
|
1203
1217
|
permissionSet: policy.permissionSet,
|
|
1204
1218
|
securityTier: policy.securityTier,
|
|
@@ -1305,6 +1319,7 @@ export async function createWunderlandServer(opts) {
|
|
|
1305
1319
|
}
|
|
1306
1320
|
catch (error) {
|
|
1307
1321
|
turnFailed = true;
|
|
1322
|
+
turnError = error;
|
|
1308
1323
|
throw error;
|
|
1309
1324
|
}
|
|
1310
1325
|
finally {
|
|
@@ -1327,6 +1342,23 @@ export async function createWunderlandServer(opts) {
|
|
|
1327
1342
|
error: error instanceof Error ? error.message : String(error),
|
|
1328
1343
|
});
|
|
1329
1344
|
}
|
|
1345
|
+
await sessionTextLogger.logTurn({
|
|
1346
|
+
meta: {
|
|
1347
|
+
agentId: workspaceAgentId,
|
|
1348
|
+
seedId,
|
|
1349
|
+
displayName,
|
|
1350
|
+
providerId: String(providerId),
|
|
1351
|
+
model,
|
|
1352
|
+
personaId: requestActivePersonaId,
|
|
1353
|
+
},
|
|
1354
|
+
sessionId,
|
|
1355
|
+
userText: message,
|
|
1356
|
+
reply,
|
|
1357
|
+
error: turnError,
|
|
1358
|
+
toolCallCount,
|
|
1359
|
+
durationMs: 0,
|
|
1360
|
+
fallbackTriggered,
|
|
1361
|
+
});
|
|
1330
1362
|
}
|
|
1331
1363
|
sendJson(res, 200, { reply, personaId: requestActivePersonaId });
|
|
1332
1364
|
return;
|
|
@@ -1438,6 +1470,12 @@ export async function createWunderlandServer(opts) {
|
|
|
1438
1470
|
channelCount: adapterByPlatform.size,
|
|
1439
1471
|
pairingEnabled,
|
|
1440
1472
|
});
|
|
1473
|
+
const usage = async (usageOpts) => {
|
|
1474
|
+
if (usageOpts?.sessionId) {
|
|
1475
|
+
return getRecordedWunderlandSessionUsage(usageOpts.sessionId, opts?.configDirOverride);
|
|
1476
|
+
}
|
|
1477
|
+
return getRecordedWunderlandTokenUsage(opts?.configDirOverride);
|
|
1478
|
+
};
|
|
1441
1479
|
return {
|
|
1442
1480
|
server,
|
|
1443
1481
|
url,
|
|
@@ -1458,6 +1496,7 @@ export async function createWunderlandServer(opts) {
|
|
|
1458
1496
|
autoApproveToolCalls,
|
|
1459
1497
|
turnApprovalMode,
|
|
1460
1498
|
openaiFallbackEnabled,
|
|
1499
|
+
usage,
|
|
1461
1500
|
close,
|
|
1462
1501
|
};
|
|
1463
1502
|
}
|