@xenosystem/agent-sdk 0.8.12
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 +15 -0
- package/README.md +511 -0
- package/dist/agents/index.cjs +17 -0
- package/dist/agents/index.d.cts +244 -0
- package/dist/agents/index.d.ts +244 -0
- package/dist/agents/index.js +17 -0
- package/dist/agents/metafile-cjs.json +1 -0
- package/dist/agents/metafile-esm.json +1 -0
- package/dist/artifacts/browser.cjs +1 -0
- package/dist/artifacts/browser.d.cts +8 -0
- package/dist/artifacts/browser.d.ts +8 -0
- package/dist/artifacts/browser.js +1 -0
- package/dist/artifacts/diff-artifact-C2tQZWcs.d.cts +354 -0
- package/dist/artifacts/diff-artifact-C2tQZWcs.d.ts +354 -0
- package/dist/artifacts/index.cjs +10 -0
- package/dist/artifacts/index.d.cts +588 -0
- package/dist/artifacts/index.d.ts +588 -0
- package/dist/artifacts/index.js +10 -0
- package/dist/artifacts/metafile-cjs.json +1 -0
- package/dist/artifacts/metafile-esm.json +1 -0
- package/dist/automation/index.cjs +438 -0
- package/dist/automation/index.d.cts +878 -0
- package/dist/automation/index.d.ts +878 -0
- package/dist/automation/index.js +438 -0
- package/dist/automation/metafile-cjs.json +1 -0
- package/dist/automation/metafile-esm.json +1 -0
- package/dist/control-plane/index.cjs +7 -0
- package/dist/control-plane/index.d.cts +403 -0
- package/dist/control-plane/index.d.ts +403 -0
- package/dist/control-plane/index.js +7 -0
- package/dist/control-plane/metafile-cjs.json +1 -0
- package/dist/control-plane/metafile-esm.json +1 -0
- package/dist/control-room/index.cjs +1 -0
- package/dist/control-room/index.d.cts +216 -0
- package/dist/control-room/index.d.ts +216 -0
- package/dist/control-room/index.js +1 -0
- package/dist/control-room/metafile-cjs.json +1 -0
- package/dist/control-room/metafile-esm.json +1 -0
- package/dist/electron/index.cjs +1476 -0
- package/dist/electron/index.d.cts +1583 -0
- package/dist/electron/index.d.ts +1583 -0
- package/dist/electron/index.js +1476 -0
- package/dist/electron/metafile-cjs.json +1 -0
- package/dist/electron/metafile-esm.json +1 -0
- package/dist/governance/index.cjs +33 -0
- package/dist/governance/index.d.cts +397 -0
- package/dist/governance/index.d.ts +397 -0
- package/dist/governance/index.js +33 -0
- package/dist/governance/metafile-cjs.json +1 -0
- package/dist/governance/metafile-esm.json +1 -0
- package/dist/hooks/index.cjs +9 -0
- package/dist/hooks/index.d.cts +198 -0
- package/dist/hooks/index.d.ts +198 -0
- package/dist/hooks/index.js +9 -0
- package/dist/hooks/metafile-cjs.json +1 -0
- package/dist/hooks/metafile-esm.json +1 -0
- package/dist/hosted/index.cjs +1 -0
- package/dist/hosted/index.d.cts +490 -0
- package/dist/hosted/index.d.ts +490 -0
- package/dist/hosted/index.js +1 -0
- package/dist/hosted/metafile-cjs.json +1 -0
- package/dist/hosted/metafile-esm.json +1 -0
- package/dist/index.cjs +2161 -0
- package/dist/index.d.cts +12259 -0
- package/dist/index.d.ts +12259 -0
- package/dist/index.js +2161 -0
- package/dist/intelligence/index.cjs +10 -0
- package/dist/intelligence/index.d.cts +220 -0
- package/dist/intelligence/index.d.ts +220 -0
- package/dist/intelligence/index.js +10 -0
- package/dist/intelligence/metafile-cjs.json +1 -0
- package/dist/intelligence/metafile-esm.json +1 -0
- package/dist/mcp/index.cjs +28 -0
- package/dist/mcp/index.d.cts +960 -0
- package/dist/mcp/index.d.ts +960 -0
- package/dist/mcp/index.js +28 -0
- package/dist/mcp/metafile-cjs.json +1 -0
- package/dist/mcp/metafile-esm.json +1 -0
- package/dist/metafile-cjs.json +1 -0
- package/dist/metafile-esm.json +1 -0
- package/dist/oracle/index.cjs +1 -0
- package/dist/oracle/index.d.cts +310 -0
- package/dist/oracle/index.d.ts +310 -0
- package/dist/oracle/index.js +1 -0
- package/dist/oracle/metafile-cjs.json +1 -0
- package/dist/oracle/metafile-esm.json +1 -0
- package/dist/providers/index.cjs +11 -0
- package/dist/providers/index.d.cts +462 -0
- package/dist/providers/index.d.ts +462 -0
- package/dist/providers/index.js +11 -0
- package/dist/providers/metafile-cjs.json +1 -0
- package/dist/providers/metafile-esm.json +1 -0
- package/dist/recipes/index.cjs +2 -0
- package/dist/recipes/index.d.cts +86 -0
- package/dist/recipes/index.d.ts +86 -0
- package/dist/recipes/index.js +2 -0
- package/dist/recipes/metafile-cjs.json +1 -0
- package/dist/recipes/metafile-esm.json +1 -0
- package/dist/research/index.cjs +3 -0
- package/dist/research/index.d.cts +285 -0
- package/dist/research/index.d.ts +285 -0
- package/dist/research/index.js +3 -0
- package/dist/research/metafile-cjs.json +1 -0
- package/dist/research/metafile-esm.json +1 -0
- package/dist/session/index.cjs +56 -0
- package/dist/session/index.d.cts +523 -0
- package/dist/session/index.d.ts +523 -0
- package/dist/session/index.js +56 -0
- package/dist/session/metafile-cjs.json +1 -0
- package/dist/session/metafile-esm.json +1 -0
- package/dist/sharing/index.cjs +4 -0
- package/dist/sharing/index.d.cts +272 -0
- package/dist/sharing/index.d.ts +272 -0
- package/dist/sharing/index.js +4 -0
- package/dist/sharing/metafile-cjs.json +1 -0
- package/dist/sharing/metafile-esm.json +1 -0
- package/dist/skills/index.cjs +6 -0
- package/dist/skills/index.d.cts +277 -0
- package/dist/skills/index.d.ts +277 -0
- package/dist/skills/index.js +6 -0
- package/dist/skills/metafile-cjs.json +1 -0
- package/dist/skills/metafile-esm.json +1 -0
- package/dist/soul/index.cjs +32 -0
- package/dist/soul/index.d.cts +138 -0
- package/dist/soul/index.d.ts +138 -0
- package/dist/soul/index.js +32 -0
- package/dist/soul/metafile-cjs.json +1 -0
- package/dist/soul/metafile-esm.json +1 -0
- package/dist/terminal/index.cjs +4 -0
- package/dist/terminal/index.d.cts +55 -0
- package/dist/terminal/index.d.ts +55 -0
- package/dist/terminal/index.js +4 -0
- package/dist/terminal/metafile-cjs.json +1 -0
- package/dist/terminal/metafile-esm.json +1 -0
- package/dist/ui/index.cjs +35 -0
- package/dist/ui/index.d.cts +298 -0
- package/dist/ui/index.d.ts +298 -0
- package/dist/ui/index.js +35 -0
- package/dist/ui/metafile-cjs.json +1 -0
- package/dist/ui/metafile-esm.json +1 -0
- package/dist/utils/index.cjs +23 -0
- package/dist/utils/index.d.cts +245 -0
- package/dist/utils/index.d.ts +245 -0
- package/dist/utils/index.js +23 -0
- package/dist/utils/metafile-cjs.json +1 -0
- package/dist/utils/metafile-esm.json +1 -0
- package/native/mxc/LICENSE.microsoft-mxc-sdk.md +21 -0
- package/native/mxc/README.md +25 -0
- package/native/mxc/bin/arm64/lxc-exec +0 -0
- package/native/mxc/bin/arm64/mxc-exec-mac +0 -0
- package/native/mxc/bin/arm64/wxc-exec.exe +0 -0
- package/native/mxc/bin/arm64/wxc-host-prep.exe +0 -0
- package/native/mxc/bin/x64/lxc-exec +0 -0
- package/native/mxc/bin/x64/wxc-exec.exe +0 -0
- package/native/mxc/bin/x64/wxc-host-prep.exe +0 -0
- package/native/mxc/package.json +58 -0
- package/ownership/CLEAN_ROOM_CONTRIBUTOR_GUIDE.md +63 -0
- package/ownership/audit.mjs +727 -0
- package/ownership/evidence/PROPRIETARY-COMMAND-1/implementation-record.md +77 -0
- package/ownership/evidence/PROPRIETARY-COMMAND-1/provenance-review.md +51 -0
- package/ownership/evidence/PROPRIETARY-MEDIA-1/implementation-record.md +131 -0
- package/ownership/evidence/PROPRIETARY-MEDIA-1/provenance-review.md +50 -0
- package/ownership/evidence/PROPRIETARY-PTY-1/implementation-record.md +86 -0
- package/ownership/evidence/PROPRIETARY-PTY-1/provenance-review.md +52 -0
- package/ownership/evidence/PROPRIETARY-RUNTIME-1/implementation-record.md +68 -0
- package/ownership/evidence/PROPRIETARY-RUNTIME-1/provenance-review.md +32 -0
- package/ownership/evidence/PROPRIETARY-TOOLCHAIN-1/implementation-record.md +53 -0
- package/ownership/evidence/PROPRIETARY-TOOLCHAIN-1/provenance-review.md +32 -0
- package/ownership/evidence/PROPRIETARY-UI-1/implementation-record.md +96 -0
- package/ownership/evidence/PROPRIETARY-UI-1/provenance-review.md +46 -0
- package/ownership/ownership-policy.json +232 -0
- package/ownership/ownership-policy.schema.json +192 -0
- package/ownership/templates/clean-room-implementation-record.md +70 -0
- package/ownership/templates/provenance-review.md +51 -0
- package/package.json +209 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
Copyright (c) 2026 XENO Corporation
|
|
2
|
+
All rights reserved.
|
|
3
|
+
|
|
4
|
+
This software and the accompanying documentation are proprietary and
|
|
5
|
+
confidential. No license or other right is granted to use, copy, modify,
|
|
6
|
+
merge, publish, distribute, sublicense, sell, reverse engineer, create
|
|
7
|
+
derivative works from, or otherwise exploit this software or any portion of it
|
|
8
|
+
without prior written permission from XENO Corporation.
|
|
9
|
+
|
|
10
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
11
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
12
|
+
FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT, OR TITLE. IN NO EVENT
|
|
13
|
+
SHALL XENO CORPORATION OR ITS LICENSORS BE LIABLE FOR ANY CLAIM, DAMAGES, OR
|
|
14
|
+
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT, OR OTHERWISE, ARISING
|
|
15
|
+
FROM, OUT OF, OR IN CONNECTION WITH THE SOFTWARE OR THE USE OF THE SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,511 @@
|
|
|
1
|
+
# XENO Agent SDK
|
|
2
|
+
|
|
3
|
+
Core runtime for XENO agent-enabled products. It provides the agent loop, tool execution, permissions, sessions, memory, audit logging, and provider integration used across the XENO platform.
|
|
4
|
+
|
|
5
|
+
## Runtime Ownership
|
|
6
|
+
|
|
7
|
+
The ownership program targets P2 feature parity, but this checkout must be described by its generated audit rather than by the target. Run `npm run build && npm run compliance:ownership:artifacts` or inspect `docs/compliance/ownership-inventory.md`. Node remains an explicitly external host through P2, and development/build packages remain third-party build inputs. Do not claim that a release is fully proprietary, entirely Xeno-owned, or free of third-party runtime code unless the packaged release smoke prints the corresponding achieved level and the required provenance/counsel gates are complete.
|
|
8
|
+
|
|
9
|
+
The canonical policy and engineering clean-room controls are under `ownership/`.
|
|
10
|
+
|
|
11
|
+
## Vision
|
|
12
|
+
|
|
13
|
+
Every XENO creative app (Pixel, Motion, Sound) has an AI agent embedded directly into the interface. Users open a sidebar, type what they want ("remove the background from this layer", "cut the silence from this podcast", "match-cut these two clips"), and the agent translates that into tool calls against the app's engine. One request can span multiple apps: "Create a product video from these photos with background music" triggers coordinated work across Pixel, Motion, and Sound simultaneously.
|
|
14
|
+
|
|
15
|
+
The SDK is designed so the same governed agent contracts can be embedded across
|
|
16
|
+
creative products instead of rebuilding orchestration in every application.
|
|
17
|
+
|
|
18
|
+
```
|
|
19
|
+
Without agent SDK: User manually opens Pixel, edits, opens Motion, edits, opens Sound, edits
|
|
20
|
+
With agent SDK: User says "Create a product video" -> agents in all 3 apps coordinate automatically
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Current State
|
|
24
|
+
|
|
25
|
+
- **Provider-agnostic runtime** with XENO-hosted, local, direct-provider, and
|
|
26
|
+
generic compatible routes
|
|
27
|
+
- **Extensible tool system** with demand-loaded schemas, managed background
|
|
28
|
+
operations, terminal support, and host-registered domain tools
|
|
29
|
+
- **4 permission modes**: `default`, `acceptEdits`, `bypassPermissions`, `plan`
|
|
30
|
+
- **4-level identity hierarchy**: global, project, role, session
|
|
31
|
+
- **4-level memory system** with auto-capture (conversation, session, project, global)
|
|
32
|
+
- **Session persistence** with checkpoints, transcript writing, and crash recovery
|
|
33
|
+
- **Audit logging** in JSON-lines format (who, what, when, result)
|
|
34
|
+
- **Agent orchestration** with profiles, delegation, teams, goals, workflows,
|
|
35
|
+
monitors, schedules, hooks, and durable recovery
|
|
36
|
+
- **Artifact and evidence protocol** with immutable revisions, review events,
|
|
37
|
+
stable anchors, provenance, and evidence graphs
|
|
38
|
+
- **Secure execution contracts and capability leases** that preserve
|
|
39
|
+
profile/host denials and distinguish policy, hardening, and containment
|
|
40
|
+
- **Agent Skills v2** with interoperable `SKILL.md` discovery, progressive
|
|
41
|
+
disclosure, hash-bound resources, policy intersection, and privacy-safe audit
|
|
42
|
+
- **Current MCP transport and OAuth** with Streamable HTTP, resumable SSE,
|
|
43
|
+
session recovery, legacy negotiation, PKCE/resource binding, refresh rotation,
|
|
44
|
+
and network-policy enforcement
|
|
45
|
+
- **Advanced governed contracts** for cross-model Oracle review, commit-bound
|
|
46
|
+
source research, portable Recipes, Git mutation restore, plugin signatures
|
|
47
|
+
and relevance, MCP Apps, and authenticated hosted channels
|
|
48
|
+
- Dual ESM/CommonJS package conditions for every public entry point, TypeScript
|
|
49
|
+
7 native typechecking, TypeScript 6 compiler-API compatibility, tsup build
|
|
50
|
+
- Production dependencies: none
|
|
51
|
+
|
|
52
|
+
### Agent Profiles
|
|
53
|
+
|
|
54
|
+
The SDK includes versioned specialist contracts that bind prompts to
|
|
55
|
+
enforceable tool, permission, skill, hook, memory, Soul, isolation,
|
|
56
|
+
external-action, and completion policies. Profiles compile through monotonic
|
|
57
|
+
capability intersection, so organization and host boundaries can narrow but
|
|
58
|
+
never widen authority. See [docs/agent-profiles.md](docs/agent-profiles.md).
|
|
59
|
+
|
|
60
|
+
### Artifact Protocol and secure execution foundations
|
|
61
|
+
|
|
62
|
+
`@xenosystem/agent-sdk/artifacts` provides the durable interchange
|
|
63
|
+
contract for plans, patches, diffs, documents, diagrams, screenshots,
|
|
64
|
+
recordings, tests, reviews, releases, SBOMs, provenance, and attestations.
|
|
65
|
+
Content revisions are immutable; comments and decisions are append-only; an
|
|
66
|
+
approval applies only to the exact revision and content hash reviewed.
|
|
67
|
+
|
|
68
|
+
The artifact barrel also provides first-class Wave 3 planning and review
|
|
69
|
+
contracts. `XenoSpecLifecycleService` persists separately hashed requirements,
|
|
70
|
+
design, task-graph, and plan artifacts; approved plans remain immutable while
|
|
71
|
+
execution and task evidence advance through separate revisions.
|
|
72
|
+
`detectXenoSpecDrift()` checks plan binding, dependencies, acceptance evidence,
|
|
73
|
+
and observed paths. `XenoMultiAgentReviewCoordinator` runs independent review
|
|
74
|
+
dimensions, deduplicates findings, requires verifier reproduction (or an
|
|
75
|
+
explicit evidence quorum) before marking a finding verified, and emits one
|
|
76
|
+
portable `xeno.review-report.v1` artifact.
|
|
77
|
+
|
|
78
|
+
`@xenosystem/agent-sdk/intelligence` provides the persistent
|
|
79
|
+
repository-index contract: bounded documents and chunks, symbols, imports,
|
|
80
|
+
test/document links, Git provenance, deterministic lexical retrieval,
|
|
81
|
+
host-supplied exact-model semantic vectors, multi-workspace identity, freshness
|
|
82
|
+
inspection, relationship traversal, and an atomic owner-private file store.
|
|
83
|
+
Semantic vectors are compared only when model identity and dimensions match.
|
|
84
|
+
Hosts retain source collection and embedding-provider authority.
|
|
85
|
+
|
|
86
|
+
`@xenosystem/agent-sdk/control-room` projects durable product state
|
|
87
|
+
into one hash-bound supervision snapshot. It validates agent hierarchies and
|
|
88
|
+
task dependencies, categorizes health and stale heartbeats, aggregates usage,
|
|
89
|
+
prioritizes attention, and plans scoped actions. Source adapters can explicitly
|
|
90
|
+
narrow advertised actions; they cannot grant controls disallowed by runtime
|
|
91
|
+
status. This lets CLI, Hub, and hosted clients share one view without
|
|
92
|
+
fabricating unsupported buttons or exposing private reasoning.
|
|
93
|
+
|
|
94
|
+
`@xenosystem/agent-sdk/hosted` defines the immutable hosted-
|
|
95
|
+
environment, trigger, replay, execution-adapter, cross-device control, and run-
|
|
96
|
+
result contracts. Protocol-v2 adapter certificates bind interactive control,
|
|
97
|
+
Artifact Protocol output, and Git-result reporting in addition to the OS
|
|
98
|
+
containment claims. Hosted messages and exact-scope approval decisions are
|
|
99
|
+
normalized, bounded, and tamper-evident; acknowledgements are normalized; run
|
|
100
|
+
results hash-bind Git/credential-free PR metadata and artifact/evidence IDs.
|
|
101
|
+
These contracts let the Agents API, CLI, and Hub interoperate without treating
|
|
102
|
+
policy metadata as proof of containment.
|
|
103
|
+
|
|
104
|
+
Graphical and web renderers must import
|
|
105
|
+
`@xenosystem/agent-sdk/artifacts/browser`. That browser-safe entry
|
|
106
|
+
contains bounded record/diff projection and protocol types without importing
|
|
107
|
+
the Node filesystem, process-lock, or crypto implementations owned by the main
|
|
108
|
+
artifact barrel.
|
|
109
|
+
|
|
110
|
+
The security barrel exposes capability leases and the Secure Execution
|
|
111
|
+
Contract. A lease is narrow, expiring, operation-bound authority and cannot
|
|
112
|
+
override an Agent Profile or host denial. The execution contract fingerprints
|
|
113
|
+
the effective filesystem, network, process, environment, secret,
|
|
114
|
+
external-action, browser, and computer-use boundary. These are shared protocol
|
|
115
|
+
foundations; they do not by themselves make an OS adapter release-certified.
|
|
116
|
+
|
|
117
|
+
### Governed browser and computer automation
|
|
118
|
+
|
|
119
|
+
`@xenosystem/agent-sdk/automation` defines one versioned operation
|
|
120
|
+
catalog and adapter contract for XENO Browser and XENO Use. The governed
|
|
121
|
+
executor validates the execution-contract fingerprint and real preflight
|
|
122
|
+
target, persists required before evidence, consumes an exact capability lease,
|
|
123
|
+
dispatches through the adapter, revalidates the resulting target, and persists
|
|
124
|
+
after/recording evidence as Artifact Protocol records. Missing required evidence
|
|
125
|
+
is quarantined as `evidence-incomplete` rather than accepted as success.
|
|
126
|
+
|
|
127
|
+
`XenoLoopbackAutomationAdapter` provides the bearer-authenticated, response-
|
|
128
|
+
bounded local transport to XENO Browser. Read and action domain authority are
|
|
129
|
+
separate; explicit browser/network deny rules take precedence; operation IDs
|
|
130
|
+
are idempotent; and immediate stop propagates to the bound native target. See
|
|
131
|
+
[Governed Automation](docs/GOVERNED_AUTOMATION.md).
|
|
132
|
+
|
|
133
|
+
### Agent Skills v2
|
|
134
|
+
|
|
135
|
+
`@xenosystem/agent-sdk/skills` provides a host-neutral implementation
|
|
136
|
+
of directory-based `SKILL.md` packages. Discovery reads only metadata and hashed
|
|
137
|
+
resource descriptors. `createXenoSkillTool()` demand-loads and re-verifies full
|
|
138
|
+
instructions when invoked, then intersects tool and external-action policy with
|
|
139
|
+
the active host/Profile boundary. Standard `allowed-tools` is treated as a
|
|
140
|
+
preapproval request, never as an authority grant. Legacy inline XENO skills can
|
|
141
|
+
be adapted without breaking existing hosts.
|
|
142
|
+
|
|
143
|
+
### MCP Streamable HTTP and OAuth
|
|
144
|
+
|
|
145
|
+
`@xenosystem/agent-sdk/mcp` targets MCP protocol `2025-11-25`.
|
|
146
|
+
URL-only server configs use Streamable HTTP; explicit `sse` remains available
|
|
147
|
+
for deprecated servers and can be negotiated only after a rejected Streamable
|
|
148
|
+
HTTP initialization. The transport handles protocol/session headers, JSON and
|
|
149
|
+
SSE responses, `Last-Event-ID` resumption, duplicate suppression, session
|
|
150
|
+
reinitialization, server instructions, manual redirect checks, and permission-
|
|
151
|
+
profile validation.
|
|
152
|
+
|
|
153
|
+
`MCPOAuthClient` implements protected-resource and authorization-server
|
|
154
|
+
discovery, PKCE S256, RFC 8707 resource binding, pre-registered/CIMD/explicit
|
|
155
|
+
DCR client selection, authorization-code exchange, refresh-token rotation, and
|
|
156
|
+
bounded metadata responses. Hosts own user interaction and secret persistence;
|
|
157
|
+
token values are never added to MCP state or model context.
|
|
158
|
+
|
|
159
|
+
### Advanced runtime contracts
|
|
160
|
+
|
|
161
|
+
The SDK also exposes additive contracts for cross-model Oracle reports,
|
|
162
|
+
commit-bound remote-source research, portable Recipes, automatic Git mutation
|
|
163
|
+
checkpoints, signed/locked plugins, repository-aware relevance, MCP Apps, and
|
|
164
|
+
authenticated GitLab/Teams/Jira hosted events. These contracts bind identity,
|
|
165
|
+
authority, evidence, and persistence without granting a host UI, network,
|
|
166
|
+
credential, or deployment authority. See
|
|
167
|
+
[Advanced Runtime Contracts](docs/ADVANCED_RUNTIME_CONTRACTS.md).
|
|
168
|
+
|
|
169
|
+
## Delivery automation
|
|
170
|
+
|
|
171
|
+
The SDK repo now carries the same production automation discipline as the CLI:
|
|
172
|
+
|
|
173
|
+
- `.github/workflows/ci.yml` -- cross-platform build verification plus full Linux runtime checks
|
|
174
|
+
- `.github/workflows/certification.yml` -- scheduled production/stress verification and large-repo coding benchmarks
|
|
175
|
+
- `.github/workflows/release.yml` -- npm Trusted Publishing with provenance, checksums, and GitHub release artifacts
|
|
176
|
+
|
|
177
|
+
## Architecture
|
|
178
|
+
|
|
179
|
+
```
|
|
180
|
+
xeno-agent-sdk/
|
|
181
|
+
src/
|
|
182
|
+
core/, runtime/, providers/ Agent loop, streaming, context, providers
|
|
183
|
+
tools/, terminal/, media/ Tools and managed operations
|
|
184
|
+
security/, governance/ Policy, permissions, leases, execution law
|
|
185
|
+
session/, memory/, identity/ Durable user and conversation context
|
|
186
|
+
orchestration/, control-plane/ Agents, teams, workflows, goals, recovery
|
|
187
|
+
agents/, prompts/, soul/ Profiles, prompts, learned state
|
|
188
|
+
artifacts/ Artifacts, reviews, provenance, evidence
|
|
189
|
+
automation/ Governed browser/computer adapter protocol
|
|
190
|
+
oracle/, research/, recipes/ Independent review, source evidence, reusable DAGs
|
|
191
|
+
hosted/, intelligence/ Fleet contracts and repository intelligence
|
|
192
|
+
skills/ Skills v2 discovery, loading, policy, audit
|
|
193
|
+
hooks/, plugins/, mcp/ Extension and interoperability contracts
|
|
194
|
+
app-server/, integrations/ Remote and host protocols
|
|
195
|
+
audit/, observability/ Audit, usage, telemetry, diagnostics
|
|
196
|
+
ui/, electron/, adapters/ Optional UI and host integration layers
|
|
197
|
+
persistence/, config/, utils/ Durable and cross-cutting utilities
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
## Selected subsystems
|
|
201
|
+
|
|
202
|
+
| Subsystem | Purpose | Key exports |
|
|
203
|
+
|-----------|---------|-------------|
|
|
204
|
+
| **Core Loop** | Agentic turn loop with tool dispatch, streaming, reducer | `AgentLoop`, `AgentLoopConfig` |
|
|
205
|
+
| **Tools** | Demand-loaded registry, built-ins, managed operations, host tools | `ToolRegistry`, `registry` |
|
|
206
|
+
| **Security** | Permissions, policy, leases, execution contracts, adapter claims | `PermissionEngine`, `SecureExecutionContract` |
|
|
207
|
+
| **Session** | Persistence, checkpoints, transcripts, locks, recovery | `SessionManager`, `CheckpointManager` |
|
|
208
|
+
| **Identity** | Persona loading and resolution across 4 levels | `IdentityLoader`, `IdentityResolver` |
|
|
209
|
+
| **Memory** | Hierarchical memory with budget management | `MemoryManager`, `MemoryBudget` |
|
|
210
|
+
| **Audit** | JSON-lines logging for every action | `AuditLogger` |
|
|
211
|
+
| **Config** | Model settings, API endpoints, defaults | `XENO_API_BASE`, `DEFAULT_MODEL` |
|
|
212
|
+
| **Delegation** | Planner/executor/reviewer sub-agent workflows | `DelegatedAgent`, `DelegatedTurn` |
|
|
213
|
+
| **Artifacts** | Immutable revisions, review lifecycle, anchors, evidence graph | `XenoArtifact`, `ArtifactRepository` |
|
|
214
|
+
| **Agent Profiles** | Enforceable specialist runtime identities | `CompiledAgentProfile` |
|
|
215
|
+
| **Agent Skills** | Metadata-first `SKILL.md` catalog and demand-loaded invocation | `discoverXenoSkills`, `createXenoSkillTool` |
|
|
216
|
+
| **MCP** | Stdio, Streamable HTTP, legacy SSE, OAuth discovery/PKCE/refresh | `MCPManager`, `StreamableHTTPTransport`, `MCPOAuthClient` |
|
|
217
|
+
| **Oracle** | Independent opinions, adjudication, citations, disagreement | `XenoOracleCoordinator` |
|
|
218
|
+
| **Research** | Commit-bound source excerpts, findings, provenance | `XenoSourceResearchReport` |
|
|
219
|
+
| **Recipes** | Strict portable DAGs with authority, budgets, and fingerprints | `compileXenoRecipe` |
|
|
220
|
+
| **Plugin trust** | Signatures, locks, publisher policy, advisory relevance | `verifyPluginSupplyChain`, `scorePluginRelevance` |
|
|
221
|
+
| **Types** | All shared TypeScript types | `ExecutionMode`, `ResolvedIdentity`, etc. |
|
|
222
|
+
|
|
223
|
+
## How Apps Integrate
|
|
224
|
+
|
|
225
|
+
The primary entry point is `createXenoAgent()`. Each app registers its own operations as tools, and the SDK handles everything else: the agentic loop, permission checks, audit logging, memory, sessions.
|
|
226
|
+
|
|
227
|
+
```typescript
|
|
228
|
+
import { createXenoAgent } from '@xenosystem/agent-sdk'
|
|
229
|
+
|
|
230
|
+
// Each app defines its domain-specific tools
|
|
231
|
+
const pixelTools = {
|
|
232
|
+
'layer.remove-bg': {
|
|
233
|
+
description: 'Remove background from the active layer',
|
|
234
|
+
execute: async (params) => {
|
|
235
|
+
const result = await xenoLib.rmbg(params.layerId) // xeno-lib AI model
|
|
236
|
+
await engine.applyMask(params.layerId, result.mask) // app engine
|
|
237
|
+
return { success: true, layerId: params.layerId }
|
|
238
|
+
},
|
|
239
|
+
confirm: true, // requires user approval
|
|
240
|
+
},
|
|
241
|
+
'brush.draw': {
|
|
242
|
+
description: 'Draw a stroke on the active layer',
|
|
243
|
+
execute: async (params) => engine.drawStroke(params),
|
|
244
|
+
confirm: false, // safe, no confirmation needed
|
|
245
|
+
},
|
|
246
|
+
'file.export': {
|
|
247
|
+
description: 'Export the current document',
|
|
248
|
+
execute: async (params) => exporter.save(params),
|
|
249
|
+
confirm: true,
|
|
250
|
+
destructive: false,
|
|
251
|
+
},
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
const agent = await createXenoAgent({
|
|
255
|
+
toolRegistry: pixelTools,
|
|
256
|
+
model: 'claude-sonnet-4-20250514',
|
|
257
|
+
permissionConfig: { mode: 'default' },
|
|
258
|
+
// identity, memory, session all auto-configured
|
|
259
|
+
})
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
### End-to-End Example
|
|
263
|
+
|
|
264
|
+
User types in Pixel's agent sidebar: **"Remove the background from this layer"**
|
|
265
|
+
|
|
266
|
+
```
|
|
267
|
+
1. Agent receives natural language input
|
|
268
|
+
2. LLM decides to call tool: layer.remove-bg({ layerId: 'layer-3' })
|
|
269
|
+
3. Permission engine checks: confirm=true -> prompts user for approval
|
|
270
|
+
4. User approves -> tool executes:
|
|
271
|
+
a. Calls xeno-lib's RMBG model (Rust, ONNX, GPU-accelerated)
|
|
272
|
+
b. Receives alpha mask
|
|
273
|
+
c. Applies mask to layer in Pixel's rendering engine
|
|
274
|
+
5. Audit logger records: who=user, what=layer.remove-bg, when=timestamp, result=success
|
|
275
|
+
6. Agent responds: "Done. Background removed from Layer 3."
|
|
276
|
+
```
|
|
277
|
+
|
|
278
|
+
## The Tool Registry Pattern
|
|
279
|
+
|
|
280
|
+
Apps extend the SDK by registering their operations as tools. The SDK provides
|
|
281
|
+
file, search, shell, background-process, terminal, media, and other reusable
|
|
282
|
+
tool contracts; apps add namespaced domain-specific tools:
|
|
283
|
+
|
|
284
|
+
| App | Example tools |
|
|
285
|
+
|-----|---------------|
|
|
286
|
+
| **Pixel** | `brush.draw`, `layer.remove-bg`, `selection.expand`, `filter.blur`, `file.export` |
|
|
287
|
+
| **Motion** | `timeline.cut`, `clip.speed`, `transition.add`, `keyframe.set`, `render.export` |
|
|
288
|
+
| **Sound** | `track.eq`, `region.normalize`, `master.lufs`, `effect.reverb`, `bounce.export` |
|
|
289
|
+
| **Hub** | `workspace.create`, `app.launch`, `agent.dispatch` |
|
|
290
|
+
|
|
291
|
+
Each tool declares: `description` (for the LLM), `execute` (the implementation), `confirm` (whether to ask the user), and `destructive` (whether it's irreversible).
|
|
292
|
+
|
|
293
|
+
## Cross-App Orchestration
|
|
294
|
+
|
|
295
|
+
One agent request can trigger coordinated work across multiple apps. The Hub acts as an orchestrator, dispatching tasks to per-app agents via a mailbox system.
|
|
296
|
+
|
|
297
|
+
```
|
|
298
|
+
User: "Create a product video from these photos with background music"
|
|
299
|
+
|
|
300
|
+
xeno-hub (orchestrator)
|
|
301
|
+
|-- mailbox.send('pixel-agent', { task: 'export hero images as PNGs' })
|
|
302
|
+
|-- mailbox.send('motion-agent', { task: 'create timeline from exported images' })
|
|
303
|
+
|-- mailbox.send('sound-agent', { task: 'add background track, master to -14 LUFS' })
|
|
304
|
+
|
|
305
|
+
Each agent receives via:
|
|
306
|
+
mailbox.onMessage((msg) => agent.execute(msg.task))
|
|
307
|
+
```
|
|
308
|
+
|
|
309
|
+
Messages are JSON-serializable for cross-process IPC. The SDK includes agent
|
|
310
|
+
protocol/registry and `CrossAppRouter` primitives with bounded delivery.
|
|
311
|
+
Production transport, durable replay, authentication, and product adoption are
|
|
312
|
+
host responsibilities and must be verified in each consuming repository.
|
|
313
|
+
|
|
314
|
+
## Security Model
|
|
315
|
+
|
|
316
|
+
### Permission Modes
|
|
317
|
+
|
|
318
|
+
| Mode | Behavior |
|
|
319
|
+
|------|----------|
|
|
320
|
+
| `default` | Ask user before writes and shell commands |
|
|
321
|
+
| `acceptEdits` | Auto-approve file edits, ask for shell commands |
|
|
322
|
+
| `bypassPermissions` | Auto-approve everything (development/testing only) |
|
|
323
|
+
| `plan` | Read-only mode, agent can only plan and suggest |
|
|
324
|
+
|
|
325
|
+
### Safety Features
|
|
326
|
+
|
|
327
|
+
- **Policy enforcement**: canonical physical-path checks reject traversal through symlinks/junctions, UNC/device, extended-length, drive-relative, root-relative, alternate-data-stream, reserved-device, and ambiguous paths
|
|
328
|
+
- **Shell policy**: parsed PowerShell/Bash file operands, redirections, and path parameters enforce read/write capabilities; unresolved dynamic filesystem operands fail closed
|
|
329
|
+
- **Execution security levels**: `policy-only`, `process-hardened`, and `contained` are separate API contracts. The legacy `requireOsContainment: true` flag now means strict `contained` and never accepts process hardening as a substitute.
|
|
330
|
+
- **Windows process hardening**: `executionLevel: "process-hardened"` uses a reduced primary token, low integrity for read-only execution, an explicit inherited-handle allowlist, a minimized environment, and a kill-on-close Job Object. It does not isolate filesystem reads or network access and is for trusted workspaces only.
|
|
331
|
+
- **Fail-closed containment**: the SDK ships five reviewed, digest-pinned runtime executables plus two Windows host-preparation helpers extracted from the integrity-pinned MXC 0.7.0 artifact; it does not install or execute MXC's JavaScript wrapper or transitive `node-pty` graph. Windows x64/ARM64, Linux x64/ARM64, and macOS ARM64 are supported, but asset presence is not certification. Windows setup is an explicit elevated host operation and is never attempted by normal agent execution. `contained` activates only with a short-lived, candidate-, platform-, adapter-, native-report-, and independently signed reviewer-bound host manifest. A source build, unsupported target, mismatch, or missing binding fails with `CONTAINMENT_UNAVAILABLE`; executable discovery is never treated as certification.
|
|
332
|
+
- **Destructive action gates**: delete, overwrite, and shell commands require explicit approval
|
|
333
|
+
- **Audit trail**: every tool call logged in JSON-lines format with trace IDs
|
|
334
|
+
- **Risk classification**: each tool call classified as low/medium/high risk
|
|
335
|
+
- **Permission rules**: per-tool, per-path override rules
|
|
336
|
+
|
|
337
|
+
The policy layer and Windows process hardening are defense in depth, not a claim that arbitrary untrusted code is contained. See [Security Boundaries](docs/SECURITY_BOUNDARIES.md) for the capability matrix and migration contract.
|
|
338
|
+
|
|
339
|
+
### Managed Shell Processes
|
|
340
|
+
|
|
341
|
+
`UnifiedExecManager` is the canonical owner for pipe and PTY process lifecycles. `BackgroundProcessManager` remains the task-oriented compatibility facade and adds owner scoping, bounded file-backed output, same-process foreground-to-background promotion, completion events, input, resize, and human-writer leases.
|
|
342
|
+
|
|
343
|
+
- `Bash` accepts `tty: true` only with `run_in_background: true`.
|
|
344
|
+
- `TaskInput` writes to or waits on an interactive task. Input text is projected to byte-count/task metadata before audit, permission, callback, and transcript sinks.
|
|
345
|
+
- PTY support is adapter based. Hosts register an optional `XenoPtyAdapter`; missing capability returns `PTY_UNAVAILABLE` and never silently falls back to a pipe.
|
|
346
|
+
- App-server `exec.start` accepts `tty`, `cols`, and `rows`; `exec.resize` is owner scoped alongside write, output, list, and terminate.
|
|
347
|
+
- `SessionManager.recordDirectShellResult` persists bounded local-command output as user-role untrusted context with semantic metadata, not as a fabricated model tool call.
|
|
348
|
+
|
|
349
|
+
### Managed Tool Operations
|
|
350
|
+
|
|
351
|
+
Tool calls now receive a stable operation ID, deadline, completion policy (`await`, `observe`, or `detach`), progress counters, terminal reason, and artifact evidence. Recovery snapshots are written atomically under the user control-plane directory, while redacted operation transitions are appended to a private JSONL ledger. Raw command text is not copied into operation lists or the ledger.
|
|
352
|
+
|
|
353
|
+
- A promotable foreground `Bash` command moves to the background by changing presentation on the same process. PID, task/process IDs, output cursor, and deadline are retained; the command is never re-executed.
|
|
354
|
+
- `TaskOutput({ task_id, offset })` remains a nonblocking compatibility read. `wait: true` adds an event-driven wait capped at 30 seconds and always reports explicit `Operation terminal: yes|no`, state, runtime, idle time, output delta, UTF-8-safe next offset, and suggested action.
|
|
355
|
+
- Finite model-created background work defaults to `await`. The parent turn suspends without another provider request and resumes from a durable continuation notification after terminal output arrives. User stop, detach, clear, interrupt, or rewind cancels stale automatic continuation.
|
|
356
|
+
- `expected_outputs` on `Bash` records generic file postconditions. Missing or unstable outputs fail the logical operation even after exit code 0; partial artifacts are still reported after timeout/failure.
|
|
357
|
+
- `ReadImage` preflights format, dimensions, and bytes. The dependency-free `xeno-owned-raster` path performs owned PNG/DEFLATE decode and encode, JPEG, GIF, VP8/VP8L WebP decode, bounded SVG software rasterization, and resizing; BMP and Netpbm inputs normalize through the same owned PNG path. Oversized supported inputs become owner-private bounded PNG previews without an ambient decoder or canvas fallback. Private previews are removed during session cleanup and originals stay unchanged. The exact approved profiles and explicit rejections are documented in [`docs/owned-media-matrix.md`](docs/owned-media-matrix.md).
|
|
358
|
+
|
|
359
|
+
Temporary rollback controls default to enabled: `XENO_TOOL_OPERATION_RUNTIME`, `XENO_AUTO_BACKGROUND_FOREGROUND_BASH`, `XENO_TASK_OUTPUT_WAIT`, `XENO_AUTO_TOOL_CONTINUATION`, and `XENO_READ_IMAGE_AUTO_PREVIEW`. Setting a control to `0` disables its optional behavior without deleting active tasks or persisted operation records.
|
|
360
|
+
|
|
361
|
+
On Windows, ordinary managed pipe tasks use the existing kill-on-close Job Object launcher when available and report `windows-job-object`; the explicit `windows-tree-fallback` uses tree termination but is not reported as verified Job ownership. Persistent PowerShell defaults to Windows PowerShell 5.1. Set `XENO_POWERSHELL_EXECUTABLE=pwsh.exe` to use PowerShell 7. Process ownership and cleanup are not claims of untrusted-code containment.
|
|
362
|
+
|
|
363
|
+
See [docs/managed-tool-operations.md](docs/managed-tool-operations.md) for the runtime and troubleshooting contract.
|
|
364
|
+
|
|
365
|
+
### Agent Harness Reliability
|
|
366
|
+
|
|
367
|
+
- Tool inputs are JSON-schema validated by default; malformed calls are returned to the model as typed errors.
|
|
368
|
+
- Interrupted or orphaned tool exchanges are repaired before resumable history is sent back to a provider.
|
|
369
|
+
- Repeated identical failing tool calls are circuit-broken before they can loop indefinitely.
|
|
370
|
+
- Query lifecycle transitions are emitted as typed runtime events and guarded by idle, active-operation lease, and hard timeouts.
|
|
371
|
+
- Context overflow triggers one semantic compact-and-retry path. Old tool payloads are compacted before conversation history is dropped, message count has a hard cap, and preflight token estimates are model-aware with an injectable exact-tokenizer seam.
|
|
372
|
+
- The default tool registry demand-loads optional schemas through `ToolSearch` instead of advertising every full schema on every request.
|
|
373
|
+
|
|
374
|
+
### Direct Provider Adapters
|
|
375
|
+
|
|
376
|
+
Provider-normalized deployments can continue using the default Xeno API transport. Direct integrations are available from the provider subpath:
|
|
377
|
+
|
|
378
|
+
```typescript
|
|
379
|
+
import { createDirectProvider } from '@xenosystem/agent-sdk/providers'
|
|
380
|
+
import { createXenoAgent } from '@xenosystem/agent-sdk'
|
|
381
|
+
|
|
382
|
+
const provider = createDirectProvider({
|
|
383
|
+
kind: 'openai-responses', // 'anthropic' | 'openai-responses' | 'google' | 'openai-compatible'
|
|
384
|
+
apiKey: process.env.PROVIDER_API_KEY!,
|
|
385
|
+
})
|
|
386
|
+
|
|
387
|
+
const { agent } = await createXenoAgent({ provider })
|
|
388
|
+
```
|
|
389
|
+
|
|
390
|
+
The adapters translate streaming text, images, parallel tool calls/results, usage, cancellation, and typed failures for Messages, Responses, Gemini, and explicitly profiled chat-compatible endpoints. Generic endpoints require a capability profile and local HTTP requires an explicit local-network endpoint profile. See [docs/PROVIDER_CONFORMANCE.md](docs/PROVIDER_CONFORMANCE.md).
|
|
391
|
+
|
|
392
|
+
The provider subpath also exposes a capability-driven product catalog, atomic workspace connection store, bounded credential/model probe, and routing policy. Connections hold credential reference names, never raw credentials. Presets for Azure OpenAI, Bedrock, and Vertex truthfully report `requires-host-adapter` until dedicated adapters are supplied.
|
|
393
|
+
|
|
394
|
+
```typescript
|
|
395
|
+
import {
|
|
396
|
+
FileXenoProviderConnectionStore,
|
|
397
|
+
XenoProviderCatalog,
|
|
398
|
+
probeXenoProvider,
|
|
399
|
+
selectXenoProviderRoute,
|
|
400
|
+
} from '@xenosystem/agent-sdk/providers'
|
|
401
|
+
```
|
|
402
|
+
|
|
403
|
+
### Secure Sharing and Handoff
|
|
404
|
+
|
|
405
|
+
`@xenosystem/agent-sdk/sharing` provides deterministic redaction, Ed25519-signed expiring read-only shares, capability/audience/revocation verification, signed session handoffs, and an atomic checksum-protected local registry. Embedded public keys prove integrity but do not imply issuer trust; consuming products supply their own trust store and must intersect handoff authority with local policy.
|
|
406
|
+
|
|
407
|
+
```typescript
|
|
408
|
+
import {
|
|
409
|
+
createXenoSecureShare,
|
|
410
|
+
verifyXenoSecureShare,
|
|
411
|
+
createXenoSessionHandoff,
|
|
412
|
+
verifyXenoSessionHandoff,
|
|
413
|
+
FileXenoShareRegistry,
|
|
414
|
+
} from '@xenosystem/agent-sdk/sharing'
|
|
415
|
+
```
|
|
416
|
+
|
|
417
|
+
## Session Persistence
|
|
418
|
+
|
|
419
|
+
- Sessions have unique IDs with embedded timestamps
|
|
420
|
+
- Full conversation transcripts written to disk
|
|
421
|
+
- Checkpoint system for long-running workflows
|
|
422
|
+
- Lock management prevents concurrent access to the same session
|
|
423
|
+
- Turn restore for crash recovery (resume mid-conversation)
|
|
424
|
+
- Session registry tracks all sessions per project
|
|
425
|
+
|
|
426
|
+
## Memory System
|
|
427
|
+
|
|
428
|
+
4-level hierarchy with automatic capture and budget management:
|
|
429
|
+
|
|
430
|
+
| Level | Scope | Persists | Example |
|
|
431
|
+
|-------|-------|----------|---------|
|
|
432
|
+
| **Conversation** | Current turn | No | "The user just asked about Layer 3" |
|
|
433
|
+
| **Session** | Current session | Until session ends | "We're working on the hero image" |
|
|
434
|
+
| **Project** | Current project | Yes | "This project uses 300 DPI, CMYK" |
|
|
435
|
+
| **Global** | All projects | Yes | "User prefers dark theme, metric units" |
|
|
436
|
+
|
|
437
|
+
Memory is injected into the system prompt with configurable token budgets to avoid context overflow.
|
|
438
|
+
|
|
439
|
+
## LLM Providers
|
|
440
|
+
|
|
441
|
+
| Provider | How | When |
|
|
442
|
+
|----------|-----|------|
|
|
443
|
+
| **Xeno API** (cloud) | `api.xenostudio.ai` proxy to hosted models | Online, highest capability |
|
|
444
|
+
| **xeno-rt** (local) | OpenAI-compatible API on localhost | Offline, privacy, no cost |
|
|
445
|
+
| **Ollama** (local) | OpenAI-compatible API | Alternative local provider |
|
|
446
|
+
|
|
447
|
+
The SDK is provider-agnostic. OpenAI-compatible endpoints are supported through an explicit capability and endpoint-security profile; compatibility is verified by conformance fixtures rather than inferred from the endpoint label. Provider selection and fallback logic are handled by the config subsystem.
|
|
448
|
+
|
|
449
|
+
## Consumers
|
|
450
|
+
|
|
451
|
+
| App | How it uses the SDK | Example agent task |
|
|
452
|
+
|-----|--------------------|--------------------|
|
|
453
|
+
| **xeno-agent-cli** | Terminal agent (reference implementation) | "Refactor this codebase" |
|
|
454
|
+
| **xeno-pixel** | Image editing agent sidebar | "Remove backgrounds from 50 images" |
|
|
455
|
+
| **xeno-motion** | Video editing agent sidebar | "Cut this interview into a highlight reel" |
|
|
456
|
+
| **xeno-sound** | Audio editing agent sidebar | "Master this podcast to -16 LUFS" |
|
|
457
|
+
| **xeno-hub** | Orchestrator routing tasks between apps | "Create marketing materials" dispatches to Pixel + Motion + Sound |
|
|
458
|
+
|
|
459
|
+
## Xeno-Owned UI
|
|
460
|
+
|
|
461
|
+
The `/ui` subpath provides a framework-neutral controller, semantic accessibility view, and optional owned DOM renderer. It has no React runtime or peer dependency and remains isolated from the Node-only core entry point.
|
|
462
|
+
|
|
463
|
+
```ts
|
|
464
|
+
import {
|
|
465
|
+
createAgentUiController,
|
|
466
|
+
mountAgentUi,
|
|
467
|
+
} from "@xenosystem/agent-sdk/ui";
|
|
468
|
+
|
|
469
|
+
const controller = createAgentUiController({
|
|
470
|
+
agent: myAgentLoop,
|
|
471
|
+
enablePermissionRequests: true,
|
|
472
|
+
});
|
|
473
|
+
const view = mountAgentUi(document.querySelector("#agent")!, controller, {
|
|
474
|
+
agentName: "Xeno Agent",
|
|
475
|
+
});
|
|
476
|
+
|
|
477
|
+
// App shutdown:
|
|
478
|
+
view.dispose();
|
|
479
|
+
controller.dispose();
|
|
480
|
+
```
|
|
481
|
+
|
|
482
|
+
Framework integrations can subscribe to immutable controller snapshots and call `createAgentUiView` instead of mounting the DOM renderer. Renderer contract version `1` includes message streaming, tool state, token usage, cancellation, retry, permission decisions, safe markdown segments, keyboard submission, and accessible roles/live regions. See [the UI v1 migration guide](docs/migrations/sdk-ui-v1.md).
|
|
483
|
+
|
|
484
|
+
## Ecosystem Position
|
|
485
|
+
|
|
486
|
+
```
|
|
487
|
+
LAYER 5 -- APPS (Pixel, Motion, Sound, Hub)
|
|
488
|
+
| embed xeno-agent-sdk for AI automation
|
|
489
|
+
| agent sidebar in every app
|
|
490
|
+
LAYER 3 -- THIS REPO (xeno-agent-sdk)
|
|
491
|
+
| uses LLM providers + invokes AI models
|
|
492
|
+
LAYER 2 -- COMPUTE (xeno-rt for LLM, xeno-lib for 17 AI models)
|
|
493
|
+
| runs on
|
|
494
|
+
LAYER 1 -- PLATFORM (servers, auth, credits)
|
|
495
|
+
```
|
|
496
|
+
|
|
497
|
+
See [Full Ecosystem Report](../XENO%20CORPORATION%20-%20Full%20Ecosystem%20Report.md) for complete context.
|
|
498
|
+
|
|
499
|
+
## Development
|
|
500
|
+
|
|
501
|
+
```bash
|
|
502
|
+
npm install
|
|
503
|
+
npm run build # tsup -> ESM + CommonJS package outputs
|
|
504
|
+
npm run typecheck # TypeScript 7 native strict-mode check
|
|
505
|
+
npm run typecheck:compat # TypeScript 6 compatibility check for API-based tooling
|
|
506
|
+
```
|
|
507
|
+
|
|
508
|
+
## License
|
|
509
|
+
|
|
510
|
+
Proprietary and confidential. Copyright (c) 2026 XENO Corporation.
|
|
511
|
+
All rights reserved.
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";var N=Object.defineProperty;var pe=Object.getOwnPropertyDescriptor;var ge=Object.getOwnPropertyNames;var me=Object.prototype.hasOwnProperty;var ye=(e,n)=>{for(var r in n)N(e,r,{get:n[r],enumerable:!0})},he=(e,n,r,o)=>{if(n&&typeof n=="object"||typeof n=="function")for(let t of ge(n))!me.call(e,t)&&t!==r&&N(e,t,{get:()=>n[t],enumerable:!(o=pe(n,t))||o.enumerable});return e};var Ae=e=>he(N({},"__esModule",{value:!0}),e);var en={};ye(en,{AgentDefinitionLoader:()=>E,AgentDefinitionResolver:()=>j,AgentProfileValidationError:()=>P,XENO_AGENT_PROFILE_SCHEMA_VERSION:()=>R,agentDefinitionFromProfile:()=>Qe,agentProfileFromDefinition:()=>ae,compileAgentProfile:()=>ie,createAgentDefinitionFile:()=>Ve,createAgentDefinitionPromptSection:()=>Le,getProjectAgentDefinitionDirs:()=>Z,getProjectAgentDefinitionsDir:()=>ee,getUserAgentDefinitionsDir:()=>O,isValidAgentDefinitionName:()=>q,listBuiltInAgentProfiles:()=>Xe,renderAgentDefinition:()=>_e,renderAgentDefinitions:()=>Fe,resolveAgentDefinition:()=>je,resolveAgentProfile:()=>Ze,resolveAgentToolPolicy:()=>T,resolveBuiltInAgentProfile:()=>le,scanAgentDefinitions:()=>L,toAgentDefinitionMetadata:()=>Be,validateAgentDefinition:()=>ne});module.exports=Ae(en);var y=require("node:fs"),X=require("node:os"),p=require("node:path");function G(e){let n=Pe(e);return{frontmatter:n.frontmatter,content:n.content.trim()}}function Pe(e){let n=e.replace(/^\uFEFF/,"");if(!n.startsWith("---"))return{frontmatter:{},content:e};let r=n.search(/\r?\n/);if(r<0||n.slice(0,r).trim()!=="---")return{frontmatter:{},content:e};let o=n.slice(r+(n[r]==="\r"?2:1)),t=o.match(/(?:^|\r?\n)---[ \t]*(?:\r?\n|$)/);if(!t||t.index===void 0)throw new Error("YAML frontmatter is not closed.");let i=o.slice(0,t.index),l=t[0],s=t.index+l.length;return{frontmatter:Y(i),content:o.slice(s)}}function Y(e){let n={},r=e.split(/\r?\n/);for(let o=0;o<r.length;o+=1){let t=r[o];if(!t.trim()||t.trimStart().startsWith("#"))continue;if(/^\s/.test(t))throw new Error(`Unexpected indentation at line ${o+1}.`);let i=be(t,o+1);if(i.key==="<<")throw new Error("YAML merge keys are not supported.");if(i.value!==""){n[i.key]=K(i.value,o+1);continue}let l=we(r,o+1);n[i.key]=l.value,o=l.nextIndex-1}return n}function we(e,n){let r=[],o=n;for(;o<e.length;o+=1){let i=e[o];if(!i.trim()){r.push(i);continue}if(!/^\s/.test(i))break;r.push(i.replace(/^ {2}/,""))}let t=r.filter(i=>i.trim()&&!i.trimStart().startsWith("#"));return t.length===0?{value:{},nextIndex:o}:t.every(i=>i.trimStart().startsWith("- "))?{value:t.map((i,l)=>K(i.trimStart().slice(2),n+l+1)),nextIndex:o}:{value:Y(r.join(`
|
|
2
|
+
`)),nextIndex:o}}function be(e,n){let r=e.indexOf(":");if(r<=0)throw new Error(`Invalid YAML line ${n}.`);let o=e.slice(0,r).trim(),t=e.slice(r+1).trim();if(!o)throw new Error(`Invalid YAML key at line ${n}.`);return{key:o,value:t}}function K(e,n){if(e==="")return"";if(e==="[]")return[];if(e==="{}")return{};if(e==="true")return!0;if(e==="false")return!1;if(e==="null"||e==="~")return null;if(/^-?\d+(?:\.\d+)?$/.test(e))return Number(e);if(e.startsWith('"'))return z(e,n);if(e.startsWith("'")){if(!e.endsWith("'"))throw new Error(`Unclosed quoted scalar at line ${n}.`);return e.slice(1,-1).replace(/''/g,"'")}if(e.startsWith("[")||e.startsWith("{"))return z(e,n);if(e.includes("[")||e.includes("]")||e.includes("{")||e.includes("}"))throw new Error(`Unsupported YAML scalar at line ${n}.`);return e}function z(e,n){try{return JSON.parse(e)}catch{throw new Error(`Invalid YAML scalar at line ${n}.`)}}var ke=/^[a-z][a-z0-9_-]{0,63}$/;function xe(){return process.env.XENO_AGENT_HOME?.trim()||(0,p.join)((0,X.homedir)(),".xeno-agent")}function O(e=xe()){return(0,p.join)(e,"agents")}function Q(e){return(0,p.resolve)(e)}function ve(e){let n=(0,p.dirname)(e);return n===e?e:n}function Z(e=process.cwd()){let n=Q(e),r=[],o=n;for(;;){let t=(0,p.join)(o,".xeno","agents");(0,y.existsSync)(t)&&r.push(t);let i=ve(o);if(i===o)break;o=i}return r.reverse()}function ee(e=process.cwd()){return(0,p.join)(Q(e),".xeno","agents")}function Se(e){return(0,y.existsSync)(e)?(0,y.readdirSync)(e,{withFileTypes:!0}).filter(n=>n.isFile()&&n.name.toLowerCase().endsWith(".md")).map(n=>(0,p.join)(e,n.name)).sort((n,r)=>n.localeCompare(r)):[]}function k(e){if(typeof e!="string")return;let n=e.trim();return n.length>0?n:void 0}function x(e){return Array.isArray(e)?e.map(n=>String(n).trim()).filter(Boolean):typeof e=="string"?e.split(",").map(n=>n.trim()).filter(Boolean):[]}function De(e){if(typeof e=="boolean")return e;if(typeof e!="string")return;let n=e.trim().toLowerCase();if(["1","true","yes","on"].includes(n))return!0;if(["0","false","no","off"].includes(n))return!1}function $e(e){return(0,p.parse)((0,p.basename)(e)).name.toLowerCase()}function q(e){return ke.test(e)}function Ee(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Te(e){if(typeof e!="string")return;let n=e.trim().toLowerCase();if(n==="inherit")return"inherit";if(n==="none"||n==="off"||n==="disabled")return"none";if(n==="read"||n==="readonly"||n==="read-only")return"readOnly";if(n==="default"||n==="standard")return"default";if(n==="full"||n==="fullaccess"||n==="full-access")return"fullAccess"}function Ce(e){if(e===void 0)return;if(typeof e=="string"||Array.isArray(e)){let i=x(e);return i.length>0?{allow:i}:void 0}if(!Ee(e))return;let n=x(e.allow),r=x(e.deny),o=Te(e.mode),t={};return o&&(t.mode=o),n.length>0&&(t.allow=n),r.length>0&&(t.deny=r),Object.keys(t).length>0?t:void 0}function Ie(e){let n=De(e.worktree??e.defaultWorktreeIsolation);if(n===!0)return"worktree";if(n===!1)return"none";let r=k(e.isolation)?.toLowerCase();if(r==="worktree")return"worktree";if(r==="none"||r==="off"||r==="disabled")return"none"}function ne(e){let n=[];return q(e.name)||n.push(`Invalid agent name "${e.name}". Use 1-64 lowercase letters, digits, hyphens, or underscores, starting with a letter.`),e.prompt.trim().length===0&&n.push("Agent definition body is empty."),n}function Re(e,n,r){let o=(0,y.readFileSync)(e,"utf8"),t=G(o),i=t.frontmatter,l=$e(e),s=k(i.name)?.toLowerCase()??l,d=t.content.trim(),g=ne({name:s,prompt:d});if(g.length>0)throw new Error(g.join(" "));let u=k(i.description),c=k(i.model),f=k(i.color),A=k(i.memory??i.memoryScope),w=Ie(i),S=Ce(i.tools);return{name:s,scope:n,path:e,...u?{description:u}:{},...c?{model:c}:{},...f?{color:f}:{},...A?{memory:A}:{},...w?{isolation:w}:{},tags:x(i.tags),skills:x(i.skills),hooks:x(i.hooks),prompt:d,active:!0,priority:r,...S?{toolPolicy:S}:{}}}function D(e,n,r,o,t){for(let i of Se(e))try{o.push(Re(i,n,r))}catch(l){t.push({path:i,scope:n,message:l instanceof Error?l.message:String(l)})}}function Me(e){let n=new Map;for(let r of e){let o=n.get(r.name);(!o||r.priority>o.priority)&&n.set(r.name,r)}return n}function Ne(e,n){let r=n.get(e.name),o=r?.path===e.path;return{name:e.name,scope:e.scope,path:e.path,...e.description?{description:e.description}:{},...e.model?{model:e.model}:{},...e.color?{color:e.color}:{},...e.memory?{memory:e.memory}:{},...e.isolation?{isolation:e.isolation}:{},tags:e.tags,skills:e.skills,hooks:e.hooks,prompt:e.prompt,active:o,...e.toolPolicy?{toolPolicy:e.toolPolicy}:{},...!o&&r?{shadowedBy:{name:r.name,scope:r.scope,path:r.path}}:{}}}function L(e=process.cwd(),n={}){let r=n.cwd??e,o=n.userDir??O(n.agentHome),t=n.projectDirs??Z(r),i=n.pluginDirs??[],l=n.builtInDirs??[],s=[],d=[];n.includeUser!==!1&&D(o,"user",0,s,d),n.includeProject!==!1&&t.forEach((c,f)=>D(c,"project",100+f,s,d)),n.includePlugins&&i.forEach((c,f)=>D(c,"plugin",1e3+f,s,d)),n.includeBuiltIns&&l.forEach((c,f)=>D(c,"built-in",2e3+f,s,d));let g=Me(s),u=s.map(c=>Ne(c,g));return u.sort((c,f)=>{if(c.active!==f.active)return c.active?-1:1;let A=c.name.localeCompare(f.name);return A!==0?A:c.path.localeCompare(f.path)}),{definitions:u,issues:d,searchPaths:{...n.includeUser!==!1?{user:o}:{},project:n.includeProject===!1?[]:t,plugin:n.includePlugins?i:[],builtIn:n.includeBuiltIns?l:[]}}}function je(e,n=process.cwd(),r={}){let o=e.trim().toLowerCase(),t=L(n,r);return{definition:t.definitions.find(i=>i.active&&i.name===o)??null,scan:t}}var E=class{constructor(n={}){this.options=n}options;scan(n=this.options.cwd??process.cwd()){return L(n,this.options)}},j=class{constructor(n=new E){this.loader=n}loader;resolve(n,r=process.cwd()){let o=this.loader.scan(r),t=n.trim().toLowerCase();return{definition:o.definitions.find(i=>i.active&&i.name===t)??null,scan:o}}};function $(e){if(!e||e.length===0)return;let n=Array.from(new Set(e.map(r=>r.trim()).filter(Boolean)));return n.length>0?n:void 0}function Oe(e,n){if(!e&&!n)return;if(!e)return $(n);if(!n)return $(e);let r=new Set(n);return $(e.filter(o=>r.has(o)))}function qe(e,n){let r={none:0,readOnly:1,default:2,fullAccess:3,inherit:4},o=n??"inherit",t=e??"inherit";return r[o]<=r[t]?o:t}function T(e,n={}){let r=e.toolPolicy??{},o={mode:qe(r.mode,n.mode)},t=Oe(n.allow,r.allow),i=$([...n.deny??[],...r.deny??[]]);return t&&(o.allow=t),i&&(o.deny=i),o}function Le(e){return{name:`custom-agent:${e.name}`,order:20,provide(){let n=["","","# Custom Agent",`Active agent: ${e.name}`,`Definition scope: ${e.scope}`,`Definition path: ${e.path}`];return e.description&&n.push(`Description: ${e.description}`),n.push("",e.prompt),n.join(`
|
|
3
|
+
`)}}}function Be(e){return{name:e.name,scope:e.scope,path:e.path,...e.description?{description:e.description}:{},...e.model?{model:e.model}:{},...e.color?{color:e.color}:{},...e.memory?{memory:e.memory}:{},...e.isolation?{isolation:e.isolation}:{},tags:e.tags,skills:e.skills,hooks:e.hooks,active:e.active,...e.toolPolicy?{toolPolicy:e.toolPolicy}:{},...e.shadowedBy?{shadowedBy:e.shadowedBy}:{}}}function b(e,n){return e.length>=n?e:e+" ".repeat(n-e.length)}function Fe(e,n){let r=[];if(e.length===0)r.push("No custom agent definitions found.");else{r.push(`${b("name",22)} ${b("scope",8)} ${b("status",9)} description`),r.push(`${"-".repeat(22)} ${"-".repeat(8)} ${"-".repeat(9)} ${"-".repeat(32)}`);for(let o of e){let t=o.active?"active":"shadowed";r.push(`${b(o.name,22)} ${b(o.scope,8)} ${b(t,9)} ${o.description??""}`)}}if(n.length>0){r.push("","Invalid definitions:");for(let o of n)r.push(`- ${o.path}: ${o.message}`)}return r.join(`
|
|
4
|
+
`)+`
|
|
5
|
+
`}function _e(e){let n=[`Agent: ${e.name}`,`Scope: ${e.scope}`,`Path: ${e.path}`,`Status: ${e.active?"active":"shadowed"}`];return e.description&&n.push(`Description: ${e.description}`),e.model&&n.push(`Model: ${e.model}`),e.color&&n.push(`Color: ${e.color}`),e.memory&&n.push(`Memory: ${e.memory}`),e.isolation&&n.push(`Isolation: ${e.isolation}`),e.tags.length>0&&n.push(`Tags: ${e.tags.join(", ")}`),e.skills.length>0&&n.push(`Skills: ${e.skills.join(", ")}`),e.hooks.length>0&&n.push(`Hooks: ${e.hooks.join(", ")}`),e.toolPolicy&&n.push(`Tools: ${JSON.stringify(e.toolPolicy)}`),e.shadowedBy&&n.push(`Shadowed by: ${e.shadowedBy.scope} ${e.shadowedBy.path}`),n.push("",e.prompt,""),n.join(`
|
|
6
|
+
`)}function Ve(e){let n=e.name.trim().toLowerCase();if(!q(n))throw new Error(`Invalid agent name "${e.name}". Use 1-64 lowercase letters, digits, hyphens, or underscores, starting with a letter.`);let r=e.scope==="user"?O(e.agentHome):ee(e.cwd??process.cwd());(0,y.mkdirSync)(r,{recursive:!0});let o=(0,p.join)(r,`${n}.md`);if((0,y.existsSync)(o)&&!e.force)throw new Error(`Agent definition already exists: ${o}`);let t=e.description?.trim()||`${n} custom agent`,i=e.prompt?.trim()||`You are ${n}. Replace this paragraph with precise operating instructions, constraints, tools policy, verification expectations, and the kind of work this agent should own.`,s=[...["---",`name: ${n}`,`description: ${JSON.stringify(t)}`,...e.model?.trim()?[`model: ${JSON.stringify(e.model.trim())}`]:[],...e.color?.trim()?[`color: ${JSON.stringify(e.color.trim())}`]:[],...e.memory?.trim()?[`memory: ${JSON.stringify(e.memory.trim())}`]:[],...e.isolation?[`isolation: ${e.isolation}`]:[],"tags: []",...e.skills&&e.skills.length>0?[`skills: ${JSON.stringify(e.skills)}`]:[],...e.hooks&&e.hooks.length>0?[`hooks: ${JSON.stringify(e.hooks)}`]:[],...e.toolPolicy?["tools:",...e.toolPolicy.mode?[` mode: ${e.toolPolicy.mode}`]:[],...e.toolPolicy.allow&&e.toolPolicy.allow.length>0?[` allow: ${JSON.stringify(e.toolPolicy.allow)}`]:[],...e.toolPolicy.deny&&e.toolPolicy.deny.length>0?[` deny: ${JSON.stringify(e.toolPolicy.deny)}`]:[]]:[],"---"],"",i,""].join(`
|
|
7
|
+
`);return(0,y.writeFileSync)(o,s,"utf8"),o}var re=require("node:crypto");var R=2,P=class extends Error{constructor(n){super(n),this.name="AgentProfileValidationError"}},We=/^[a-z][a-z0-9_-]{0,63}$/,C=["publish","deploy","push","send","purchase","sign","file-legal","change-infrastructure"];function m(e){return Array.from(new Set((e??[]).map(n=>n.trim()).filter(Boolean)))}function Ue(e,n){if(e===void 0)return n===void 0?void 0:m(n);if(n===void 0)return m(e);let r=new Set(n);return m(e.filter(o=>r.has(o)))}function He(e,n){if(e===void 0)return;let r=new Set(n);return e.filter(o=>!r.has(o))}function B(e,n,r){let o=n===void 0?null:new Set(n),t=new Set(r??[]);return e===void 0?n===void 0?void 0:m(n).filter(i=>!t.has(i)):m(e).filter(i=>(o===null||o.has(i))&&!t.has(i))}function I(e,n,r){return r[e]<=r[n]?e:n}function Je(e,n,r){return r[e]>=r[n]?e:n}function F(e){return Array.isArray(e)?e.map(F):!e||typeof e!="object"?e:Object.fromEntries(Object.entries(e).sort(([n],[r])=>n.localeCompare(r)).map(([n,r])=>[n,F(r)]))}function ze(e){return(0,re.createHash)("sha256").update(JSON.stringify(F(e))).digest("hex")}function v(e){return structuredClone(e)}function oe(e,n){return e.overrides?.[n]??e.default}function Ge(e,n){let r={deny:0,ask:1,allow:2},o=new Set(e.requireCurrentTurnApproval),t=Object.fromEntries(C.map(d=>[d,oe(e,d)]));for(let d of n){let g=d.externalActions;if(g){for(let u of C){let c=g.overrides?.[u]??g.default;c&&(t[u]=I(t[u],c,r))}for(let u of g.requireCurrentTurnApproval??[])o.add(u)}}let l=new Set(Object.values(t)).size===1?t.publish:"deny",s={};for(let d of C)t[d]!==l&&(s[d]=t[d]);return{default:l,...Object.keys(s).length>0?{overrides:s}:{},requireCurrentTurnApproval:[...o].filter(d=>t[d]!=="deny").sort()}}function te(e){if(e.schemaVersion!==R)throw new P(`Unsupported agent profile schema: ${String(e.schemaVersion)}.`);if(!We.test(e.id))throw new P(`Invalid agent profile id: ${e.id}.`);if(!e.version.trim())throw new P(`Agent profile ${e.id} has no version.`);if(!e.displayName.trim()||!e.description.trim()||!e.prompt.trim())throw new P(`Agent profile ${e.id} requires displayName, description, and prompt.`);if(e.execution.allowedModes.length===0)throw new P(`Agent profile ${e.id} allows no collaboration modes.`);if(!e.execution.allowedModes.includes(e.execution.defaultMode))throw new P(`Agent profile ${e.id} default mode must be included in allowedModes.`)}function Ye(e,n,r,o,t,i){return{name:`agent-profile:${e.id}`,order:20,provide(){let l=C.map(s=>`${s}=${oe(n.externalActions,s)}`).join(", ");return["","","# XENO Agent Profile",`Profile: ${e.displayName} (${e.id}@${e.version})`,`Profile fingerprint: ${i}`,`Role: ${e.description}`,`Collaboration mode: ${o.defaultMode}`,`Isolation: ${o.isolation}`,`Memory: ${r.scope}; soul=${r.soul}`,`Permission profile ceiling: ${n.permissionProfile}`,`External actions: ${l}`,n.externalActions.requireCurrentTurnApproval.length>0?`Current-turn approval required for: ${n.externalActions.requireCurrentTurnApproval.join(", ")}`:"Current-turn approval required for: none",t.evidence.length>0?`Completion evidence: ${t.evidence.join(", ")}`:"Completion evidence: task-dependent",t.requirePrimarySources?"Use primary sources for factual claims and cite them near the claim.":"",t.requireCurrentInformation?"Verify time-sensitive claims against current authoritative information.":"",t.requireHumanReview?"Do not represent the result as professional approval; require human review before consequential use.":"",o.defaultDryRun?"Default to preview or dry-run. Do not perform external state changes without the required approval.":"","",e.prompt,"","Stop conditions:",...t.stopConditions.map(s=>`- ${s}`)].filter(s=>s!=="").join(`
|
|
8
|
+
`)}}}function ie(e,n={}){te(e);let r=v(e),o=n.boundaries??[],t=v(r.capabilities.tools),i=r.capabilities.skills.allow?m(r.capabilities.skills.allow):void 0,l=new Set(m(r.capabilities.skills.deny)),s=m(r.capabilities.hooks),d=new Set,g=r.capabilities.mcpServers?m(r.capabilities.mcpServers):void 0,u=r.capabilities.delegatedAgents?m(r.capabilities.delegatedAgents):void 0,c=r.capabilities.permissionProfile,f=r.memory.scope,A=r.memory.soul,w=r.execution.isolation,S={"read-only":0,default:1,"trusted-dev":2},ce={none:0,session:1,project:2,user:3},de={disabled:0,read:1,learn:2},ue={none:0,worktree:1,container:2};for(let a of o){a.tools&&(t=T({toolPolicy:t},a.tools)),i=Ue(i,a.skills?.allow);for(let M of a.skills?.deny??[])l.add(M);s=B(s,a.hooks?.allow,void 0)??[];for(let M of a.hooks?.require??[])d.add(M);g=B(g,a.mcpServers?.allow,a.mcpServers?.deny),u=B(u,a.delegatedAgents?.allow,a.delegatedAgents?.deny),a.permissionProfile&&(c=I(c,a.permissionProfile,S)),a.maximumMemoryScope&&(f=I(f,a.maximumMemoryScope,ce)),a.maximumSoulMode&&(A=I(A,a.maximumSoulMode,de)),a.requiredIsolation&&(w=Je(w,a.requiredIsolation,ue))}let _=[...l].sort();c==="read-only"&&(t=T({toolPolicy:t},{mode:"readOnly",deny:["WebSearch","WebFetch"]})),i=He(i,_);let fe=m(r.capabilities.skills.preload).filter(a=>!l.has(a)).filter(a=>i===void 0||i.includes(a));s=m([...s,...d]);let V={tools:t,skills:{preload:fe,...i!==void 0?{allow:i}:{},deny:_},hooks:s,...g!==void 0?{mcpServers:g}:{},...u!==void 0?{delegatedAgents:u}:{},permissionProfile:c,externalActions:Ge(r.capabilities.externalActions,o)},W={...r.memory,scope:f,soul:A},U={...r.execution,isolation:w},H={schemaVersion:R,profile:r,boundarySources:o.map(a=>a.source),capabilities:V,memory:W,execution:U,completion:r.completion},J=ze(H);return{...H,fingerprint:J,promptSection:Ye(r,V,W,U,r.completion,J)}}function h(e){return{schemaVersion:R,id:e.id,version:"1.0.0",displayName:e.displayName,description:e.description,kind:e.kind??"primary",prompt:e.prompt,capabilities:{tools:e.toolPolicy??{mode:"inherit"},skills:{preload:e.skills??[],...e.skillAllow?{allow:e.skillAllow}:{},deny:[]},hooks:[],permissionProfile:e.permissionProfile??"default",externalActions:{default:e.externalDefault??"ask",...e.externalOverrides?{overrides:e.externalOverrides}:{},requireCurrentTurnApproval:e.currentTurnApproval??[]}},memory:{scope:e.memoryScope??"project",role:e.id,soul:e.soul??"read"},execution:{defaultMode:e.defaultMode??"chat",allowedModes:e.allowedModes??["chat","plan","execute","review"],isolation:e.isolation??"none",allowBackground:e.allowBackground??!0,planForComplexTasks:e.planForComplexTasks??!0,defaultDryRun:e.defaultDryRun??!1},completion:{evidence:e.evidence??[],requirePrimarySources:e.primarySources??!1,requireCurrentInformation:e.currentInformation??!1,requireHumanReview:e.humanReview??!1,stopConditions:e.stopConditions??["The requested outcome is complete and required evidence has been reported.","A real authorization, information, or external-state blocker prevents safe progress."]},presentation:{label:e.displayName,color:e.color,glyph:e.glyph},tags:m(e.tags)}}var se=[h({id:"assistant",displayName:"Assistant",description:"General-purpose XENO collaborator for mixed research, planning, and implementation work.",prompt:["Work as a thoughtful generalist. Establish the user's actual outcome, inspect relevant context, and take scoped action.","Escalate into a narrower specialist profile when domain risk or task depth warrants it."].join(`
|
|
9
|
+
`),toolPolicy:{mode:"inherit"},skills:[],memoryScope:"user",evidence:["file-references"],currentTurnApproval:["publish","deploy","push","send","purchase","sign","file-legal","change-infrastructure"],color:"cyan",glyph:"\u25A0",tags:["general","primary"]}),h({id:"swe",displayName:"Software Engineer",description:"Repository-aware software engineer for careful implementation, debugging, refactoring, and verification.",prompt:["Inspect the repository before editing. Follow project instructions and preserve unrelated work.","Trace the smallest root cause, implement the narrowest coherent change, and verify from focused checks outward.","Do not claim completion without concrete test, typecheck, build, or runtime evidence appropriate to the risk."].join(`
|
|
10
|
+
`),toolPolicy:{mode:"default"},skills:["debug","run","verify"],permissionProfile:"trusted-dev",soul:"learn",evidence:["file-references","tests","typecheck","build","diff"],currentTurnApproval:["publish","deploy","push","change-infrastructure"],color:"green",glyph:"\u25C6",tags:["engineering","implementation"]}),h({id:"reviewer",displayName:"Code Reviewer",description:"Read-only reviewer focused on correctness, regressions, safety, tests, and maintainability.",prompt:["Lead with concrete findings ordered by severity. Cite exact file locations and explain impact.","Do not edit code. Distinguish confirmed defects from risks and questions. State when no material finding is present."].join(`
|
|
11
|
+
`),kind:"subagent",toolPolicy:{mode:"readOnly"},skills:["code-review","verify"],permissionProfile:"read-only",memoryScope:"session",soul:"read",allowedModes:["chat","review"],defaultMode:"review",evidence:["file-references","diff"],externalDefault:"deny",color:"yellow",glyph:"\u25C7",tags:["engineering","review","read-only"]}),h({id:"writer",displayName:"Writer",description:"Audience-aware writer and editor for clear, accurate, structurally coherent content.",prompt:["Determine audience, purpose, voice, format, and source constraints before drafting.","Preserve factual meaning, avoid invented claims, and revise for clarity, rhythm, consistency, and usefulness."].join(`
|
|
12
|
+
`),toolPolicy:{mode:"default",allow:["Read","Glob","Grep","LS","Write","Edit","WebSearch","WebFetch","Think","AskUser","Skill"]},skills:["verify"],evidence:["sources","file-references","diff"],currentTurnApproval:["send","publish"],color:"magenta",glyph:"\u2726",tags:["writing","editing"]}),h({id:"research",displayName:"Researcher",description:"Evidence-first researcher for questions, comparisons, synthesis, and source-backed analysis.",prompt:["Break the question into verifiable claims. Prefer primary and authoritative sources, compare dates, and cite near each claim.","Separate sourced fact, inference, uncertainty, and recommendation. Do not make changes unless the user explicitly expands scope."].join(`
|
|
13
|
+
`),toolPolicy:{mode:"readOnly"},skills:["verify"],permissionProfile:"default",memoryScope:"session",soul:"read",allowedModes:["chat","plan","review"],evidence:["sources","file-references"],primarySources:!0,currentInformation:!0,externalDefault:"deny",color:"blue",glyph:"\u25C8",tags:["research","qa","read-only"]}),h({id:"product",displayName:"Product",description:"Product strategist for problem framing, requirements, sequencing, metrics, and trade-off decisions.",prompt:["Start from the user problem and observable outcome. Distinguish evidence, assumptions, constraints, and open decisions.","Translate strategy into testable requirements, acceptance criteria, telemetry, risks, and a sequenced delivery path."].join(`
|
|
14
|
+
`),toolPolicy:{mode:"default",allow:["Read","Glob","Grep","LS","Write","Edit","WebSearch","WebFetch","Think","AskUser","Skill"]},skills:["verify"],evidence:["sources","file-references","diff"],currentTurnApproval:["send","publish","change-infrastructure"],color:"cyan",glyph:"\u25A3",tags:["product","planning"]}),h({id:"ci",displayName:"CI Engineer",description:"Continuous-integration specialist for reproducing, repairing, and hardening automated gates.",prompt:["Identify the exact failing job and command. Reproduce it locally or in an equivalent immutable environment before patching.","Fix only the underlying failure, retain logs as evidence, and rerun the matching gate before broader validation."].join(`
|
|
15
|
+
`),toolPolicy:{mode:"default"},skills:["ci-repair","debug","run","verify"],permissionProfile:"trusted-dev",soul:"learn",evidence:["tests","typecheck","build","diff"],currentTurnApproval:["push","deploy","change-infrastructure"],color:"green",glyph:"\u25A4",tags:["engineering","ci","automation"]}),h({id:"devops",displayName:"DevOps and Release",description:"Dry-run-first infrastructure and release specialist with explicit external-action gates.",prompt:["Inspect the release or infrastructure contract first. Build an immutable candidate and produce reproducible evidence.","Default to plan, preview, dry-run, and local verification. Never publish, deploy, push, sign, purchase, or mutate infrastructure unless the current user turn explicitly authorizes that exact action and target.","For releases, preserve SDK-before-CLI dependency order and verify the public artifact after publication."].join(`
|
|
16
|
+
`),toolPolicy:{mode:"default"},skills:["release","run","verify"],permissionProfile:"default",memoryScope:"project",soul:"learn",isolation:"worktree",defaultMode:"plan",defaultDryRun:!0,evidence:["tests","build","diff","deployment-proof","human-review"],humanReview:!0,currentTurnApproval:["publish","deploy","push","purchase","sign","change-infrastructure"],color:"yellow",glyph:"\u2B22",tags:["devops","release","infrastructure"]}),h({id:"legal-research",displayName:"Legal Research",description:"Restricted legal-information researcher that produces sourced analysis for qualified human review.",prompt:["Identify jurisdiction, effective date, parties, and the precise legal question before analyzing it.","Use current primary legal sources wherever possible. Cite each material proposition and distinguish law, interpretation, uncertainty, and practical next steps.","Provide legal information, not professional representation. Never sign, file, submit, contact a party, accept terms, or make a payment."].join(`
|
|
17
|
+
`),toolPolicy:{mode:"readOnly"},skills:["verify"],permissionProfile:"default",memoryScope:"session",soul:"disabled",allowedModes:["chat","plan","review"],defaultMode:"review",evidence:["sources","human-review"],primarySources:!0,currentInformation:!0,humanReview:!0,externalDefault:"deny",color:"red",glyph:"\xA7",tags:["legal","research","restricted","read-only"],stopConditions:["The jurisdiction or effective date is unknown and materially changes the answer.","The task requires legal representation, filing, signature, payment, or contact with a third party.","The sourced analysis is complete and clearly marked for qualified human review."]})],Ke={general:"assistant",software:"swe",engineer:"swe","software-engineer":"swe",review:"reviewer","code-reviewer":"reviewer",qa:"research","q-and-a":"research",researcher:"research","product-manager":"product","ci-cd":"ci",cicd:"ci",release:"devops","devops-release":"devops",legal:"legal-research"};function Xe(){return se.map(v)}function le(e){let n=e.trim().toLowerCase(),r=Ke[n]??n,o=se.find(t=>t.id===r);return o?v(o):null}function ae(e){let n=e.memory?.trim().toLowerCase(),r=n==="none"||n==="session"||n==="project"||n==="user"?n:"project",o=h({id:e.name,displayName:e.name,description:e.description??`Custom XENO agent ${e.name}.`,prompt:e.prompt,toolPolicy:e.toolPolicy??{mode:"inherit"},skills:e.skills,memoryScope:r,isolation:e.isolation??"none",color:e.color??"cyan",glyph:"\u25A0",tags:["custom",...e.tags]});return e.model&&(o.model={preferred:e.model}),o.capabilities.hooks=[...e.hooks],o}function Qe(e){return te(e),{name:e.id,scope:"built-in",path:`builtin:xeno-agent-profile/${e.id}@${e.version}`,description:e.description,...e.model?.preferred?{model:e.model.preferred}:{},color:e.presentation.color,memory:e.memory.scope,isolation:e.execution.isolation==="container"?"worktree":e.execution.isolation,tags:[...e.tags],skills:[...e.capabilities.skills.preload],hooks:[...e.capabilities.hooks],active:!0,toolPolicy:v(e.capabilities.tools),prompt:e.prompt}}function Ze(e){let n=e.definition?ae(e.definition):le(e.name);return n?ie(n,{boundaries:e.boundaries}):null}0&&(module.exports={AgentDefinitionLoader,AgentDefinitionResolver,AgentProfileValidationError,XENO_AGENT_PROFILE_SCHEMA_VERSION,agentDefinitionFromProfile,agentProfileFromDefinition,compileAgentProfile,createAgentDefinitionFile,createAgentDefinitionPromptSection,getProjectAgentDefinitionDirs,getProjectAgentDefinitionsDir,getUserAgentDefinitionsDir,isValidAgentDefinitionName,listBuiltInAgentProfiles,renderAgentDefinition,renderAgentDefinitions,resolveAgentDefinition,resolveAgentProfile,resolveAgentToolPolicy,resolveBuiltInAgentProfile,scanAgentDefinitions,toAgentDefinitionMetadata,validateAgentDefinition});
|