@xeno-corporation/xeno-agent-sdk 0.6.8 → 0.7.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 +101 -15
- package/dist/agents/index.d.ts +131 -1
- package/dist/agents/index.js +16 -6
- package/dist/agents/metafile-esm.json +1 -0
- package/dist/control-plane/index.d.ts +266 -1
- package/dist/control-plane/index.js +7 -4
- package/dist/control-plane/metafile-esm.json +1 -0
- package/dist/electron/index.d.ts +475 -150
- package/dist/electron/index.js +702 -167
- package/dist/electron/metafile-esm.json +1 -0
- package/dist/governance/index.d.ts +397 -0
- package/dist/governance/index.js +33 -0
- package/dist/governance/metafile-esm.json +1 -0
- package/dist/hooks/index.d.ts +50 -2
- package/dist/hooks/index.js +4 -4
- package/dist/hooks/metafile-esm.json +1 -0
- package/dist/index.d.ts +2918 -405
- package/dist/index.js +944 -319
- package/dist/mcp/index.d.ts +91 -2
- package/dist/mcp/metafile-esm.json +1 -0
- package/dist/metafile-esm.json +1 -0
- package/dist/providers/index.cjs +9 -3
- package/dist/providers/index.d.cts +158 -3
- package/dist/providers/index.d.ts +158 -3
- package/dist/providers/index.js +9 -3
- package/dist/providers/metafile-cjs.json +1 -0
- package/dist/providers/metafile-esm.json +1 -0
- package/dist/session/index.d.ts +110 -1
- package/dist/session/index.js +21 -17
- package/dist/session/metafile-esm.json +1 -0
- package/dist/soul/metafile-esm.json +1 -0
- package/dist/terminal/index.d.ts +55 -0
- package/dist/terminal/index.js +4 -0
- package/dist/terminal/metafile-esm.json +1 -0
- package/dist/ui/index.d.ts +203 -2953
- package/dist/ui/index.js +35 -32
- package/dist/ui/metafile-esm.json +1 -0
- package/dist/utils/index.d.ts +79 -1
- package/dist/utils/index.js +19 -18
- package/dist/utils/metafile-esm.json +1 -0
- package/ownership/CLEAN_ROOM_CONTRIBUTOR_GUIDE.md +63 -0
- package/ownership/audit.mjs +703 -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 +214 -0
- package/ownership/ownership-policy.schema.json +186 -0
- package/ownership/templates/clean-room-implementation-record.md +70 -0
- package/ownership/templates/provenance-review.md +51 -0
- package/package.json +137 -114
package/README.md
CHANGED
|
@@ -2,6 +2,12 @@
|
|
|
2
2
|
|
|
3
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
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
|
+
|
|
5
11
|
## Vision
|
|
6
12
|
|
|
7
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.
|
|
@@ -25,8 +31,16 @@ With agent SDK: User says "Create a product video" -> agents in all 3 apps c
|
|
|
25
31
|
- **Session persistence** with checkpoints, transcript writing, and crash recovery
|
|
26
32
|
- **Audit logging** in JSON-lines format (who, what, when, result)
|
|
27
33
|
- **Delegation system**: planner/executor/reviewer sub-agent workflows
|
|
28
|
-
- ESM-only, TypeScript
|
|
29
|
-
-
|
|
34
|
+
- ESM-only, TypeScript 7 native typechecking, TypeScript 6 compiler-API compatibility, tsup build
|
|
35
|
+
- Production dependencies: none
|
|
36
|
+
|
|
37
|
+
### Agent Profiles
|
|
38
|
+
|
|
39
|
+
The SDK includes versioned specialist contracts that bind prompts to
|
|
40
|
+
enforceable tool, permission, skill, hook, memory, Soul, isolation,
|
|
41
|
+
external-action, and completion policies. Profiles compile through monotonic
|
|
42
|
+
capability intersection, so organization and host boundaries can narrow but
|
|
43
|
+
never widen authority. See [docs/agent-profiles.md](docs/agent-profiles.md).
|
|
30
44
|
|
|
31
45
|
## Automation
|
|
32
46
|
|
|
@@ -65,7 +79,7 @@ src/
|
|
|
65
79
|
|-----------|---------|-------------|
|
|
66
80
|
| **Core Loop** | Agentic turn loop with tool dispatch, streaming, reducer | `AgentLoop`, `AgentLoopConfig` |
|
|
67
81
|
| **Tools** | Registry pattern for tool registration + 6 built-in tools | `ToolRegistry`, `registry` |
|
|
68
|
-
| **Security** | Permission engine
|
|
82
|
+
| **Security** | Permission engine, filesystem/shell policy, optional OS containment | `PermissionEngine`, `PolicyEnforcerConfig` |
|
|
69
83
|
| **Session** | Persistence, checkpoints, transcripts, locks, recovery | `SessionManager`, `CheckpointManager` |
|
|
70
84
|
| **Identity** | Persona loading and resolution across 4 levels | `IdentityLoader`, `IdentityResolver` |
|
|
71
85
|
| **Memory** | Hierarchical memory with budget management | `MemoryManager`, `MemoryBudget` |
|
|
@@ -173,12 +187,71 @@ Messages are JSON-serializable for cross-process IPC. Timeout and retry are buil
|
|
|
173
187
|
|
|
174
188
|
### Safety Features
|
|
175
189
|
|
|
176
|
-
- **
|
|
190
|
+
- **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
|
|
191
|
+
- **Shell policy**: parsed PowerShell/Bash file operands, redirections, and path parameters enforce read/write capabilities; unresolved dynamic filesystem operands fail closed
|
|
192
|
+
- **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.
|
|
193
|
+
- **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.
|
|
194
|
+
- **Fail-closed containment**: no platform currently advertises release-certified `contained` execution. A contained or untrusted request fails with `CONTAINMENT_UNAVAILABLE`; executable discovery is not treated as certification.
|
|
177
195
|
- **Destructive action gates**: delete, overwrite, and shell commands require explicit approval
|
|
178
196
|
- **Audit trail**: every tool call logged in JSON-lines format with trace IDs
|
|
179
197
|
- **Risk classification**: each tool call classified as low/medium/high risk
|
|
180
198
|
- **Permission rules**: per-tool, per-path override rules
|
|
181
199
|
|
|
200
|
+
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.
|
|
201
|
+
|
|
202
|
+
### Managed Shell Processes
|
|
203
|
+
|
|
204
|
+
`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.
|
|
205
|
+
|
|
206
|
+
- `Bash` accepts `tty: true` only with `run_in_background: true`.
|
|
207
|
+
- `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.
|
|
208
|
+
- PTY support is adapter based. Hosts register an optional `XenoPtyAdapter`; missing capability returns `PTY_UNAVAILABLE` and never silently falls back to a pipe.
|
|
209
|
+
- App-server `exec.start` accepts `tty`, `cols`, and `rows`; `exec.resize` is owner scoped alongside write, output, list, and terminate.
|
|
210
|
+
- `SessionManager.recordDirectShellResult` persists bounded local-command output as user-role untrusted context with semantic metadata, not as a fabricated model tool call.
|
|
211
|
+
|
|
212
|
+
### Managed Tool Operations
|
|
213
|
+
|
|
214
|
+
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.
|
|
215
|
+
|
|
216
|
+
- 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.
|
|
217
|
+
- `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.
|
|
218
|
+
- 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.
|
|
219
|
+
- `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.
|
|
220
|
+
- `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).
|
|
221
|
+
|
|
222
|
+
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.
|
|
223
|
+
|
|
224
|
+
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.
|
|
225
|
+
|
|
226
|
+
See [docs/managed-tool-operations.md](docs/managed-tool-operations.md) for the runtime and troubleshooting contract.
|
|
227
|
+
|
|
228
|
+
### Agent Harness Reliability
|
|
229
|
+
|
|
230
|
+
- Tool inputs are JSON-schema validated by default; malformed calls are returned to the model as typed errors.
|
|
231
|
+
- Interrupted or orphaned tool exchanges are repaired before resumable history is sent back to a provider.
|
|
232
|
+
- Repeated identical failing tool calls are circuit-broken before they can loop indefinitely.
|
|
233
|
+
- Query lifecycle transitions are emitted as typed runtime events and guarded by idle, active-operation lease, and hard timeouts.
|
|
234
|
+
- 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.
|
|
235
|
+
- The default tool registry demand-loads optional schemas through `ToolSearch` instead of advertising every full schema on every request.
|
|
236
|
+
|
|
237
|
+
### Direct Provider Adapters
|
|
238
|
+
|
|
239
|
+
Provider-normalized deployments can continue using the default Xeno API transport. Direct integrations are available from the provider subpath:
|
|
240
|
+
|
|
241
|
+
```typescript
|
|
242
|
+
import { createDirectProvider } from '@xeno-corporation/xeno-agent-sdk/providers'
|
|
243
|
+
import { createXenoAgent } from '@xeno-corporation/xeno-agent-sdk'
|
|
244
|
+
|
|
245
|
+
const provider = createDirectProvider({
|
|
246
|
+
kind: 'openai-responses', // 'anthropic' | 'openai-responses' | 'google' | 'openai-compatible'
|
|
247
|
+
apiKey: process.env.PROVIDER_API_KEY!,
|
|
248
|
+
})
|
|
249
|
+
|
|
250
|
+
const { agent } = await createXenoAgent({ provider })
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
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).
|
|
254
|
+
|
|
182
255
|
## Session Persistence
|
|
183
256
|
|
|
184
257
|
- Sessions have unique IDs with embedded timestamps
|
|
@@ -209,7 +282,7 @@ Memory is injected into the system prompt with configurable token budgets to avo
|
|
|
209
282
|
| **xeno-rt** (local) | OpenAI-compatible API on localhost | Offline, privacy, no cost |
|
|
210
283
|
| **Ollama** (local) | OpenAI-compatible API | Alternative local provider |
|
|
211
284
|
|
|
212
|
-
The SDK is provider-agnostic.
|
|
285
|
+
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.
|
|
213
286
|
|
|
214
287
|
## Consumers
|
|
215
288
|
|
|
@@ -221,18 +294,30 @@ The SDK is provider-agnostic. Any OpenAI-compatible endpoint works. Provider sel
|
|
|
221
294
|
| **xeno-sound** | Audio editing agent sidebar | "Master this podcast to -16 LUFS" |
|
|
222
295
|
| **xeno-hub** | Orchestrator routing tasks between apps | "Create marketing materials" dispatches to Pixel + Motion + Sound |
|
|
223
296
|
|
|
224
|
-
##
|
|
297
|
+
## Xeno-Owned UI
|
|
225
298
|
|
|
226
|
-
|
|
299
|
+
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.
|
|
227
300
|
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
301
|
+
```ts
|
|
302
|
+
import {
|
|
303
|
+
createAgentUiController,
|
|
304
|
+
mountAgentUi,
|
|
305
|
+
} from "@xeno-corporation/xeno-agent-sdk/ui";
|
|
306
|
+
|
|
307
|
+
const controller = createAgentUiController({
|
|
308
|
+
agent: myAgentLoop,
|
|
309
|
+
enablePermissionRequests: true,
|
|
310
|
+
});
|
|
311
|
+
const view = mountAgentUi(document.querySelector("#agent")!, controller, {
|
|
312
|
+
agentName: "Xeno Agent",
|
|
313
|
+
});
|
|
314
|
+
|
|
315
|
+
// App shutdown:
|
|
316
|
+
view.dispose();
|
|
317
|
+
controller.dispose();
|
|
318
|
+
```
|
|
234
319
|
|
|
235
|
-
|
|
320
|
+
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).
|
|
236
321
|
|
|
237
322
|
## Ecosystem Position
|
|
238
323
|
|
|
@@ -254,7 +339,8 @@ See [Full Ecosystem Report](../XENO%20CORPORATION%20-%20Full%20Ecosystem%20Repor
|
|
|
254
339
|
```bash
|
|
255
340
|
npm install
|
|
256
341
|
npm run build # tsup -> ESM output
|
|
257
|
-
npm run typecheck # TypeScript
|
|
342
|
+
npm run typecheck # TypeScript 7 native strict-mode check
|
|
343
|
+
npm run typecheck:compat # TypeScript 6 compatibility check for API-based tooling
|
|
258
344
|
```
|
|
259
345
|
|
|
260
346
|
## License
|
package/dist/agents/index.d.ts
CHANGED
|
@@ -111,4 +111,134 @@ declare function createAgentDefinitionFile(input: {
|
|
|
111
111
|
prompt?: string;
|
|
112
112
|
force?: boolean;
|
|
113
113
|
}): string;
|
|
114
|
-
|
|
114
|
+
type PermissionProfileName = "default" | "read-only" | "trusted-dev";
|
|
115
|
+
declare const XENO_AGENT_PROFILE_SCHEMA_VERSION: 2;
|
|
116
|
+
type AgentProfileKind = "primary" | "subagent" | "service";
|
|
117
|
+
type AgentProfileCollaborationMode = "chat" | "plan" | "execute" | "review";
|
|
118
|
+
type AgentProfileMemoryScope = "none" | "session" | "project" | "user";
|
|
119
|
+
type AgentProfileSoulMode = "disabled" | "read" | "learn";
|
|
120
|
+
type AgentProfileIsolation = AgentDefinitionIsolation | "container";
|
|
121
|
+
type AgentProfileExternalAction = "publish" | "deploy" | "push" | "send" | "purchase" | "sign" | "file-legal" | "change-infrastructure";
|
|
122
|
+
type AgentProfileActionDecision = "allow" | "ask" | "deny";
|
|
123
|
+
type AgentProfileEvidenceKind = "sources" | "file-references" | "tests" | "typecheck" | "build" | "diff" | "deployment-proof" | "human-review";
|
|
124
|
+
interface AgentProfileSkillPolicy {
|
|
125
|
+
preload: string[];
|
|
126
|
+
allow?: string[];
|
|
127
|
+
deny: string[];
|
|
128
|
+
}
|
|
129
|
+
interface AgentProfileExternalActionPolicy {
|
|
130
|
+
default: AgentProfileActionDecision;
|
|
131
|
+
overrides?: Partial<Record<AgentProfileExternalAction, AgentProfileActionDecision>>;
|
|
132
|
+
requireCurrentTurnApproval: AgentProfileExternalAction[];
|
|
133
|
+
}
|
|
134
|
+
interface AgentProfileCapabilities {
|
|
135
|
+
tools: AgentToolPolicy;
|
|
136
|
+
skills: AgentProfileSkillPolicy;
|
|
137
|
+
hooks: string[];
|
|
138
|
+
mcpServers?: string[];
|
|
139
|
+
delegatedAgents?: string[];
|
|
140
|
+
permissionProfile: PermissionProfileName;
|
|
141
|
+
externalActions: AgentProfileExternalActionPolicy;
|
|
142
|
+
}
|
|
143
|
+
interface AgentProfileMemoryPolicy {
|
|
144
|
+
scope: AgentProfileMemoryScope;
|
|
145
|
+
role: string;
|
|
146
|
+
soul: AgentProfileSoulMode;
|
|
147
|
+
}
|
|
148
|
+
interface AgentProfileExecutionPolicy {
|
|
149
|
+
defaultMode: AgentProfileCollaborationMode;
|
|
150
|
+
allowedModes: AgentProfileCollaborationMode[];
|
|
151
|
+
isolation: AgentProfileIsolation;
|
|
152
|
+
allowBackground: boolean;
|
|
153
|
+
planForComplexTasks: boolean;
|
|
154
|
+
defaultDryRun: boolean;
|
|
155
|
+
maxTurns?: number;
|
|
156
|
+
}
|
|
157
|
+
interface AgentProfileCompletionPolicy {
|
|
158
|
+
evidence: AgentProfileEvidenceKind[];
|
|
159
|
+
requirePrimarySources: boolean;
|
|
160
|
+
requireCurrentInformation: boolean;
|
|
161
|
+
requireHumanReview: boolean;
|
|
162
|
+
stopConditions: string[];
|
|
163
|
+
}
|
|
164
|
+
interface AgentProfilePresentation {
|
|
165
|
+
label: string;
|
|
166
|
+
color: string;
|
|
167
|
+
glyph: string;
|
|
168
|
+
}
|
|
169
|
+
interface AgentProfileV2 {
|
|
170
|
+
schemaVersion: typeof XENO_AGENT_PROFILE_SCHEMA_VERSION;
|
|
171
|
+
id: string;
|
|
172
|
+
version: string;
|
|
173
|
+
displayName: string;
|
|
174
|
+
description: string;
|
|
175
|
+
kind: AgentProfileKind;
|
|
176
|
+
prompt: string;
|
|
177
|
+
model?: {
|
|
178
|
+
preferred?: string;
|
|
179
|
+
effort?: "low" | "medium" | "high";
|
|
180
|
+
};
|
|
181
|
+
capabilities: AgentProfileCapabilities;
|
|
182
|
+
memory: AgentProfileMemoryPolicy;
|
|
183
|
+
execution: AgentProfileExecutionPolicy;
|
|
184
|
+
completion: AgentProfileCompletionPolicy;
|
|
185
|
+
presentation: AgentProfilePresentation;
|
|
186
|
+
tags: string[];
|
|
187
|
+
}
|
|
188
|
+
interface AgentProfileCapabilityBoundary {
|
|
189
|
+
source: string;
|
|
190
|
+
tools?: AgentToolPolicy;
|
|
191
|
+
skills?: {
|
|
192
|
+
allow?: string[];
|
|
193
|
+
deny?: string[];
|
|
194
|
+
};
|
|
195
|
+
hooks?: {
|
|
196
|
+
allow?: string[];
|
|
197
|
+
require?: string[];
|
|
198
|
+
};
|
|
199
|
+
mcpServers?: {
|
|
200
|
+
allow?: string[];
|
|
201
|
+
deny?: string[];
|
|
202
|
+
};
|
|
203
|
+
delegatedAgents?: {
|
|
204
|
+
allow?: string[];
|
|
205
|
+
deny?: string[];
|
|
206
|
+
};
|
|
207
|
+
permissionProfile?: PermissionProfileName;
|
|
208
|
+
externalActions?: {
|
|
209
|
+
default?: AgentProfileActionDecision;
|
|
210
|
+
overrides?: Partial<Record<AgentProfileExternalAction, AgentProfileActionDecision>>;
|
|
211
|
+
requireCurrentTurnApproval?: AgentProfileExternalAction[];
|
|
212
|
+
};
|
|
213
|
+
maximumMemoryScope?: AgentProfileMemoryScope;
|
|
214
|
+
maximumSoulMode?: AgentProfileSoulMode;
|
|
215
|
+
requiredIsolation?: AgentProfileIsolation;
|
|
216
|
+
}
|
|
217
|
+
interface CompileAgentProfileOptions {
|
|
218
|
+
boundaries?: AgentProfileCapabilityBoundary[];
|
|
219
|
+
}
|
|
220
|
+
interface CompiledAgentProfile {
|
|
221
|
+
schemaVersion: typeof XENO_AGENT_PROFILE_SCHEMA_VERSION;
|
|
222
|
+
profile: AgentProfileV2;
|
|
223
|
+
fingerprint: string;
|
|
224
|
+
boundarySources: string[];
|
|
225
|
+
capabilities: AgentProfileCapabilities;
|
|
226
|
+
memory: AgentProfileMemoryPolicy;
|
|
227
|
+
execution: AgentProfileExecutionPolicy;
|
|
228
|
+
completion: AgentProfileCompletionPolicy;
|
|
229
|
+
promptSection: PromptSectionProvider;
|
|
230
|
+
}
|
|
231
|
+
declare class AgentProfileValidationError extends Error {
|
|
232
|
+
constructor(message: string);
|
|
233
|
+
}
|
|
234
|
+
declare function compileAgentProfile(sourceProfile: AgentProfileV2, options?: CompileAgentProfileOptions): CompiledAgentProfile;
|
|
235
|
+
declare function listBuiltInAgentProfiles(): AgentProfileV2[];
|
|
236
|
+
declare function resolveBuiltInAgentProfile(id: string): AgentProfileV2 | null;
|
|
237
|
+
declare function agentProfileFromDefinition(definition: AgentDefinition): AgentProfileV2;
|
|
238
|
+
declare function agentDefinitionFromProfile(profile: AgentProfileV2): AgentDefinition;
|
|
239
|
+
declare function resolveAgentProfile(input: {
|
|
240
|
+
name: string;
|
|
241
|
+
definition?: AgentDefinition | null;
|
|
242
|
+
boundaries?: AgentProfileCapabilityBoundary[];
|
|
243
|
+
}): CompiledAgentProfile | null;
|
|
244
|
+
export { type AgentDefinition, type AgentDefinitionIsolation, type AgentDefinitionIssue, AgentDefinitionLoader, type AgentDefinitionLoaderOptions, type AgentDefinitionMetadata, AgentDefinitionResolver, type AgentDefinitionScanResult, type AgentDefinitionScope, type AgentDefinitionShadowRef, type AgentProfileActionDecision, type AgentProfileCapabilities, type AgentProfileCapabilityBoundary, type AgentProfileCollaborationMode, type AgentProfileCompletionPolicy, type AgentProfileEvidenceKind, type AgentProfileExecutionPolicy, type AgentProfileExternalAction, type AgentProfileExternalActionPolicy, type AgentProfileIsolation, type AgentProfileKind, type AgentProfileMemoryPolicy, type AgentProfileMemoryScope, type AgentProfilePresentation, type AgentProfileSkillPolicy, type AgentProfileSoulMode, type AgentProfileV2, AgentProfileValidationError, type AgentToolPolicy, type CompileAgentProfileOptions, type CompiledAgentProfile, XENO_AGENT_PROFILE_SCHEMA_VERSION, agentDefinitionFromProfile, agentProfileFromDefinition, compileAgentProfile, createAgentDefinitionFile, createAgentDefinitionPromptSection, getProjectAgentDefinitionDirs, getProjectAgentDefinitionsDir, getUserAgentDefinitionsDir, isValidAgentDefinitionName, listBuiltInAgentProfiles, renderAgentDefinition, renderAgentDefinitions, resolveAgentDefinition, resolveAgentProfile, resolveAgentToolPolicy, resolveBuiltInAgentProfile, scanAgentDefinitions, toAgentDefinitionMetadata, validateAgentDefinition };
|
package/dist/agents/index.js
CHANGED
|
@@ -1,7 +1,17 @@
|
|
|
1
|
-
import{existsSync as
|
|
2
|
-
`)),nextIndex:o}}function
|
|
3
|
-
`)}}}function
|
|
1
|
+
import{existsSync as I,mkdirSync as le,readFileSync as ae,readdirSync as ce,writeFileSync as de}from"fs";import{homedir as ue}from"os";import{basename as fe,dirname as pe,join as k,parse as ge,resolve as me}from"path";function W(e){let n=te(e);return{frontmatter:n.frontmatter,content:n.content.trim()}}function te(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:U(i),content:o.slice(s)}}function U(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=se(t,o+1);if(i.key==="<<")throw new Error("YAML merge keys are not supported.");if(i.value!==""){n[i.key]=H(i.value,o+1);continue}let l=ie(r,o+1);n[i.key]=l.value,o=l.nextIndex-1}return n}function ie(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)=>H(i.trimStart().slice(2),n+l+1)),nextIndex:o}:{value:U(r.join(`
|
|
2
|
+
`)),nextIndex:o}}function se(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 H(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 V(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 V(e,n);if(e.includes("[")||e.includes("]")||e.includes("{")||e.includes("}"))throw new Error(`Unsupported YAML scalar at line ${n}.`);return e}function V(e,n){try{return JSON.parse(e)}catch{throw new Error(`Invalid YAML scalar at line ${n}.`)}}var ye=/^[a-z][a-z0-9_-]{0,63}$/;function he(){return process.env.XENO_AGENT_HOME?.trim()||k(ue(),".xeno-agent")}function z(e=he()){return k(e,"agents")}function G(e){return me(e)}function Ae(e){let n=pe(e);return n===e?e:n}function Pe(e=process.cwd()){let n=G(e),r=[],o=n;for(;;){let t=k(o,".xeno","agents");I(t)&&r.push(t);let i=Ae(o);if(i===o)break;o=i}return r.reverse()}function we(e=process.cwd()){return k(G(e),".xeno","agents")}function be(e){return I(e)?ce(e,{withFileTypes:!0}).filter(n=>n.isFile()&&n.name.toLowerCase().endsWith(".md")).map(n=>k(e,n.name)).sort((n,r)=>n.localeCompare(r)):[]}function w(e){if(typeof e!="string")return;let n=e.trim();return n.length>0?n:void 0}function b(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 ke(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 xe(e){return ge(fe(e)).name.toLowerCase()}function Y(e){return ye.test(e)}function ve(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function De(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 Se(e){if(e===void 0)return;if(typeof e=="string"||Array.isArray(e)){let i=b(e);return i.length>0?{allow:i}:void 0}if(!ve(e))return;let n=b(e.allow),r=b(e.deny),o=De(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 $e(e){let n=ke(e.worktree??e.defaultWorktreeIsolation);if(n===!0)return"worktree";if(n===!1)return"none";let r=w(e.isolation)?.toLowerCase();if(r==="worktree")return"worktree";if(r==="none"||r==="off"||r==="disabled")return"none"}function Ee(e){let n=[];return Y(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 Te(e,n,r){let o=ae(e,"utf8"),t=W(o),i=t.frontmatter,l=xe(e),s=w(i.name)?.toLowerCase()??l,d=t.content.trim(),p=Ee({name:s,prompt:d});if(p.length>0)throw new Error(p.join(" "));let u=w(i.description),c=w(i.model),f=w(i.color),y=w(i.memory??i.memoryScope),A=$e(i),v=Se(i.tools);return{name:s,scope:n,path:e,...u?{description:u}:{},...c?{model:c}:{},...f?{color:f}:{},...y?{memory:y}:{},...A?{isolation:A}:{},tags:b(i.tags),skills:b(i.skills),hooks:b(i.hooks),prompt:d,active:!0,priority:r,...v?{toolPolicy:v}:{}}}function D(e,n,r,o,t){for(let i of be(e))try{o.push(Te(i,n,r))}catch(l){t.push({path:i,scope:n,message:l instanceof Error?l.message:String(l)})}}function Ce(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 Ie(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 K(e=process.cwd(),n={}){let r=n.cwd??e,o=n.userDir??z(n.agentHome),t=n.projectDirs??Pe(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 p=Ce(s),u=s.map(c=>Ie(c,p));return u.sort((c,f)=>{if(c.active!==f.active)return c.active?-1:1;let y=c.name.localeCompare(f.name);return y!==0?y: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 Xe(e,n=process.cwd(),r={}){let o=e.trim().toLowerCase(),t=K(n,r);return{definition:t.definitions.find(i=>i.active&&i.name===o)??null,scan:t}}var C=class{constructor(n={}){this.options=n}options;scan(n=this.options.cwd??process.cwd()){return K(n,this.options)}},J=class{constructor(n=new C){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 S(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 Re(e,n){if(!e&&!n)return;if(!e)return S(n);if(!n)return S(e);let r=new Set(n);return S(e.filter(o=>r.has(o)))}function Me(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 R(e,n={}){let r=e.toolPolicy??{},o={mode:Me(r.mode,n.mode)},t=Re(n.allow,r.allow),i=S([...n.deny??[],...r.deny??[]]);return t&&(o.allow=t),i&&(o.deny=i),o}function Qe(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 Ze(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 P(e,n){return e.length>=n?e:e+" ".repeat(n-e.length)}function en(e,n){let r=[];if(e.length===0)r.push("No custom agent definitions found.");else{r.push(`${P("name",22)} ${P("scope",8)} ${P("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(`${P(o.name,22)} ${P(o.scope,8)} ${P(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
4
|
`)+`
|
|
5
|
-
`}function
|
|
6
|
-
`)}function
|
|
7
|
-
`);return
|
|
5
|
+
`}function nn(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 rn(e){let n=e.name.trim().toLowerCase();if(!Y(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"?z(e.agentHome):we(e.cwd??process.cwd());le(r,{recursive:!0});let o=k(r,`${n}.md`);if(I(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 de(o,s,"utf8"),o}import{createHash as Ne}from"crypto";var j=2,h=class extends Error{constructor(n){super(n),this.name="AgentProfileValidationError"}},je=/^[a-z][a-z0-9_-]{0,63}$/,$=["publish","deploy","push","send","purchase","sign","file-legal","change-infrastructure"];function g(e){return Array.from(new Set((e??[]).map(n=>n.trim()).filter(Boolean)))}function Oe(e,n){if(e===void 0)return n===void 0?void 0:g(n);if(n===void 0)return g(e);let r=new Set(n);return g(e.filter(o=>r.has(o)))}function qe(e,n){if(e===void 0)return;let r=new Set(n);return e.filter(o=>!r.has(o))}function M(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:g(n).filter(i=>!t.has(i)):g(e).filter(i=>(o===null||o.has(i))&&!t.has(i))}function E(e,n,r){return r[e]<=r[n]?e:n}function Le(e,n,r){return r[e]>=r[n]?e:n}function N(e){return Array.isArray(e)?e.map(N):!e||typeof e!="object"?e:Object.fromEntries(Object.entries(e).sort(([n],[r])=>n.localeCompare(r)).map(([n,r])=>[n,N(r)]))}function Be(e){return Ne("sha256").update(JSON.stringify(N(e))).digest("hex")}function x(e){return structuredClone(e)}function X(e,n){return e.overrides?.[n]??e.default}function Fe(e,n){let r={deny:0,ask:1,allow:2},o=new Set(e.requireCurrentTurnApproval),t=Object.fromEntries($.map(d=>[d,X(e,d)]));for(let d of n){let p=d.externalActions;if(p){for(let u of $){let c=p.overrides?.[u]??p.default;c&&(t[u]=E(t[u],c,r))}for(let u of p.requireCurrentTurnApproval??[])o.add(u)}}let l=new Set(Object.values(t)).size===1?t.publish:"deny",s={};for(let d of $)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 Q(e){if(e.schemaVersion!==j)throw new h(`Unsupported agent profile schema: ${String(e.schemaVersion)}.`);if(!je.test(e.id))throw new h(`Invalid agent profile id: ${e.id}.`);if(!e.version.trim())throw new h(`Agent profile ${e.id} has no version.`);if(!e.displayName.trim()||!e.description.trim()||!e.prompt.trim())throw new h(`Agent profile ${e.id} requires displayName, description, and prompt.`);if(e.execution.allowedModes.length===0)throw new h(`Agent profile ${e.id} allows no collaboration modes.`);if(!e.execution.allowedModes.includes(e.execution.defaultMode))throw new h(`Agent profile ${e.id} default mode must be included in allowedModes.`)}function _e(e,n,r,o,t,i){return{name:`agent-profile:${e.id}`,order:20,provide(){let l=$.map(s=>`${s}=${X(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 Ve(e,n={}){Q(e);let r=x(e),o=n.boundaries??[],t=x(r.capabilities.tools),i=r.capabilities.skills.allow?g(r.capabilities.skills.allow):void 0,l=new Set(g(r.capabilities.skills.deny)),s=g(r.capabilities.hooks),d=new Set,p=r.capabilities.mcpServers?g(r.capabilities.mcpServers):void 0,u=r.capabilities.delegatedAgents?g(r.capabilities.delegatedAgents):void 0,c=r.capabilities.permissionProfile,f=r.memory.scope,y=r.memory.soul,A=r.execution.isolation,v={"read-only":0,default:1,"trusted-dev":2},ee={none:0,session:1,project:2,user:3},ne={disabled:0,read:1,learn:2},re={none:0,worktree:1,container:2};for(let a of o){a.tools&&(t=R({toolPolicy:t},a.tools)),i=Oe(i,a.skills?.allow);for(let T of a.skills?.deny??[])l.add(T);s=M(s,a.hooks?.allow,void 0)??[];for(let T of a.hooks?.require??[])d.add(T);p=M(p,a.mcpServers?.allow,a.mcpServers?.deny),u=M(u,a.delegatedAgents?.allow,a.delegatedAgents?.deny),a.permissionProfile&&(c=E(c,a.permissionProfile,v)),a.maximumMemoryScope&&(f=E(f,a.maximumMemoryScope,ee)),a.maximumSoulMode&&(y=E(y,a.maximumSoulMode,ne)),a.requiredIsolation&&(A=Le(A,a.requiredIsolation,re))}let O=[...l].sort();c==="read-only"&&(t=R({toolPolicy:t},{mode:"readOnly",deny:["WebSearch","WebFetch"]})),i=qe(i,O);let oe=g(r.capabilities.skills.preload).filter(a=>!l.has(a)).filter(a=>i===void 0||i.includes(a));s=g([...s,...d]);let q={tools:t,skills:{preload:oe,...i!==void 0?{allow:i}:{},deny:O},hooks:s,...p!==void 0?{mcpServers:p}:{},...u!==void 0?{delegatedAgents:u}:{},permissionProfile:c,externalActions:Fe(r.capabilities.externalActions,o)},L={...r.memory,scope:f,soul:y},B={...r.execution,isolation:A},F={schemaVersion:j,profile:r,boundarySources:o.map(a=>a.source),capabilities:q,memory:L,execution:B,completion:r.completion},_=Be(F);return{...F,fingerprint:_,promptSection:_e(r,q,L,B,r.completion,_)}}function m(e){return{schemaVersion:j,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:g(e.tags)}}var Z=[m({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"]}),m({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"]}),m({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"]}),m({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"]},skills:["verify"],evidence:["sources","file-references","diff"],currentTurnApproval:["send","publish"],color:"magenta",glyph:"\u2726",tags:["writing","editing"]}),m({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"]}),m({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"]},skills:["verify"],evidence:["sources","file-references","diff"],currentTurnApproval:["send","publish","change-infrastructure"],color:"cyan",glyph:"\u25A3",tags:["product","planning"]}),m({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"]}),m({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"]}),m({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."]})],We={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 ln(){return Z.map(x)}function Ue(e){let n=e.trim().toLowerCase(),r=We[n]??n,o=Z.find(t=>t.id===r);return o?x(o):null}function He(e){let n=e.memory?.trim().toLowerCase(),r=n==="none"||n==="session"||n==="project"||n==="user"?n:"project",o=m({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 an(e){return Q(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:x(e.capabilities.tools),prompt:e.prompt}}function cn(e){let n=e.definition?He(e.definition):Ue(e.name);return n?Ve(n,{boundaries:e.boundaries}):null}export{C as AgentDefinitionLoader,J as AgentDefinitionResolver,h as AgentProfileValidationError,j as XENO_AGENT_PROFILE_SCHEMA_VERSION,an as agentDefinitionFromProfile,He as agentProfileFromDefinition,Ve as compileAgentProfile,rn as createAgentDefinitionFile,Qe as createAgentDefinitionPromptSection,Pe as getProjectAgentDefinitionDirs,we as getProjectAgentDefinitionsDir,z as getUserAgentDefinitionsDir,Y as isValidAgentDefinitionName,ln as listBuiltInAgentProfiles,nn as renderAgentDefinition,en as renderAgentDefinitions,Xe as resolveAgentDefinition,cn as resolveAgentProfile,R as resolveAgentToolPolicy,Ue as resolveBuiltInAgentProfile,K as scanAgentDefinitions,Ze as toAgentDefinitionMetadata,Ee as validateAgentDefinition};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"inputs":{"src/utils/yaml.ts":{"bytes":5506,"imports":[],"format":"esm"},"src/agents/definitions.ts":{"bytes":20613,"imports":[{"path":"fs","kind":"import-statement","external":true},{"path":"os","kind":"import-statement","external":true},{"path":"path","kind":"import-statement","external":true},{"path":"src/utils/yaml.ts","kind":"import-statement","original":"../utils/yaml.js"}],"format":"esm"},"src/agents/profiles.ts":{"bytes":32438,"imports":[{"path":"crypto","kind":"import-statement","external":true},{"path":"src/agents/definitions.ts","kind":"import-statement","original":"./definitions.js"}],"format":"esm"},"src/agents/index.ts":{"bytes":65,"imports":[{"path":"src/agents/definitions.ts","kind":"import-statement","original":"./definitions.js"},{"path":"src/agents/profiles.ts","kind":"import-statement","original":"./profiles.js"}],"format":"esm"}},"outputs":{"dist/agents/index.js":{"imports":[{"path":"fs","kind":"import-statement","external":true},{"path":"os","kind":"import-statement","external":true},{"path":"path","kind":"import-statement","external":true},{"path":"crypto","kind":"import-statement","external":true}],"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"],"entryPoint":"src/agents/index.ts","inputs":{"src/agents/definitions.ts":{"bytesInOutput":8860},"src/utils/yaml.ts":{"bytesInOutput":2217},"src/agents/index.ts":{"bytesInOutput":0},"src/agents/profiles.ts":{"bytesInOutput":15468}},"bytes":27275}}}
|