@alineo-labs/schema 0.0.0-stage → 0.3.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/dist/index.mjs ADDED
@@ -0,0 +1,185 @@
1
+ import { _ as parseName, a as workflow_exports, c as sandbox_exports, d as durableEvents, f as getEvent, g as isVerb, h as isSubject, i as alineod_exports, l as allEvents, m as VERBS, n as deprecatedSpecFields, o as harness_exports, p as SUBJECTS, r as normalizeAgentSpec, s as agent_exports, t as AgentSpecSchema, u as defineEvent } from "./agent-spec-BiNRKcYr.mjs";
2
+ import { z } from "zod";
3
+ //#region src/envelope.ts
4
+ function isPersisted(envelope) {
5
+ return envelope.durable !== void 0;
6
+ }
7
+ //#endregion
8
+ //#region src/resource-ref.ts
9
+ /**
10
+ * The durable identity an agent's memory is scoped by — `resourceId`, defaulting to `name`,
11
+ * plus the optional `teamId`.
12
+ *
13
+ * This is the one place the rule lives. The SDK (`Alineo.resourceId`, a spawned child's frozen
14
+ * `resourceId`, the ledger's `resourceId` threading) and alineod (which resolves an agent's
15
+ * memory scope from its persisted spec, with no live `Alineo` to ask) both call it, so a change
16
+ * to the rule cannot leave one of them scoping memory differently from the other.
17
+ *
18
+ * `resourceId` is `??`, not `||`: an explicitly set value wins even when it is falsy, exactly as
19
+ * it did when this was written inline.
20
+ */
21
+ function resourceRefOf(spec) {
22
+ const resourceId = spec.resourceId ?? spec.name;
23
+ return spec.teamId === void 0 ? { resourceId } : {
24
+ resourceId,
25
+ teamId: spec.teamId
26
+ };
27
+ }
28
+ //#endregion
29
+ //#region src/project.ts
30
+ /**
31
+ * The shape of `alineo.config.json`.
32
+ *
33
+ * Three consumers read the same file — `packages/agent`, `packages/cli-shared` and (through
34
+ * the Docker entrypoint) `apps/alineod` — so it cannot live in any one of them without forcing
35
+ * the other two to depend on a package for a file none of them owns. It lived in
36
+ * `config-shared` for that reason, which was the neutral home available at the time.
37
+ *
38
+ * Here now because this is the neutral home: shapes, no behaviour, and published, so a user
39
+ * writing an `alineo.config.json` by hand can get the type from the same place the tooling
40
+ * does. The mechanism — discovery, precedence, env overlay — stays in `config-shared`.
41
+ *
42
+ * Settings specific to a single consumer, such as alineod's timeouts, stay with that consumer
43
+ * and use `defineEnv`/`loadConfig` directly.
44
+ */
45
+ const ProjectConfigObject = z.object({
46
+ /**
47
+ * Which sandbox provider to run on. Only `"opensandbox"` exists today, and it is what a file
48
+ * without this key means, so every config written before the key existed keeps working.
49
+ * `serverUrl`, `apiKey` and `useServerProxy` below are that provider's settings.
50
+ */
51
+ provider: z.string().min(1).default("opensandbox"),
52
+ /**
53
+ * 127.0.0.1, not "localhost" — some hosts resolve "localhost" to ::1 first, and OpenSandbox
54
+ * typically only listens on IPv4.
55
+ */
56
+ serverUrl: z.string().min(1).default("http://127.0.0.1:8080"),
57
+ /** OpenSandbox API key. Empty string for local dev with no auth. */
58
+ apiKey: z.string().default(""),
59
+ /**
60
+ * Route execd and proxy traffic through the OpenSandbox server. Required when the server runs
61
+ * in Docker (e.g. started by `alineo init`).
62
+ */
63
+ useServerProxy: z.boolean().default(true),
64
+ /**
65
+ * Anchor path used to derive the agent snapshot store location (`agent-snapshots.json` is
66
+ * written next to it). Does not select the ledger storage adapter.
67
+ */
68
+ adapterPath: z.string().min(1).default("./.alineo/ledger.db"),
69
+ /** Directory holding agent spec files. */
70
+ agentsDir: z.string().min(1).default("./agents"),
71
+ /**
72
+ * Applied when an agent spec omits the field.
73
+ *
74
+ * `.prefault({})` rather than `.default({})`: Zod 4 uses a `default` value as-is, so
75
+ * `.default({})` on a nested object would yield a literal `{}` and leave `cpu`/`memory`
76
+ * undefined. `prefault` parses the value through the schema, which fills the inner defaults.
77
+ */
78
+ defaults: z.object({ resources: z.object({
79
+ cpu: z.string().min(1).default("1000m"),
80
+ memory: z.string().min(1).default("1Gi")
81
+ }).prefault({}) }).prefault({})
82
+ });
83
+ /**
84
+ * In this file `null` means "not set", exactly as the hand-written reader's `??` chain used to
85
+ * treat it. The file is hand-editable, an interrupted write can leave `{"defaults": {"resources":
86
+ * null}}` behind, and no field here has a meaningful null value — so a stray null falls back to
87
+ * the built-in default instead of failing validation and taking the CLI or the daemon down.
88
+ */
89
+ function dropNulls(value) {
90
+ if (value === null || typeof value !== "object" || Array.isArray(value)) return value;
91
+ const out = {};
92
+ for (const [key, inner] of Object.entries(value)) {
93
+ if (inner === null) continue;
94
+ out[key] = dropNulls(inner);
95
+ }
96
+ return out;
97
+ }
98
+ /** The project config schema, with nulls treated as absent. */
99
+ const ProjectConfigSchema = z.preprocess(dropNulls, ProjectConfigObject);
100
+ /** The underlying object schema, for JSON Schema emit (preprocess has no JSON Schema form). */
101
+ const ProjectConfigObjectSchema = ProjectConfigObject;
102
+ /** `$schema` URL written into a generated `alineo.config.json`. */
103
+ const PROJECT_CONFIG_SCHEMA_URL = "https://alineo.tech/schema/alineo.config.json";
104
+ //#endregion
105
+ //#region src/renames.ts
106
+ /**
107
+ * The old flat event names, and what each became.
108
+ *
109
+ * This table is **dated and deletable**, not a standing feature. An earlier draft carried a
110
+ * `legacy` field on every definition so both names kept being written forever; that was
111
+ * dropped because a permanent two-names-per-event alias costs more than the break. The
112
+ * mapping survives here only because three stores hold old names in an `event` column and
113
+ * need a one-time migration — once no deployed database predates the rename, this file goes.
114
+ *
115
+ * Nothing reads it at runtime on the hot path. Its consumers are the store migrations and
116
+ * the test that proves every old name maps to a registered event.
117
+ */
118
+ const RENAMED_EVENTS = Object.freeze({
119
+ sandbox_created: "sandbox.created",
120
+ sandbox_closed: "sandbox.closed",
121
+ sandbox_paused: "sandbox.paused",
122
+ sandbox_resumed: "sandbox.resumed",
123
+ checkpoint_created: "sandbox.checkpoint_created",
124
+ exec_start: "exec.started",
125
+ exec_event: "exec.output",
126
+ exec_complete: "exec.completed",
127
+ egress_rule_added: "egress.rule_added",
128
+ egress_rule_removed: "egress.rule_removed",
129
+ credential_bound: "credential.bound",
130
+ credential_revoked: "credential.revoked",
131
+ permission_requested: "permission.requested",
132
+ permission_resolved: "permission.resolved",
133
+ permission_request: "permission.requested",
134
+ workflow_complete: "workflow.completed",
135
+ workflow_failed: "workflow.failed",
136
+ step_start: "step.started",
137
+ step_complete: "step.completed",
138
+ step_failed: "step.failed",
139
+ step_rolled_back: "step.rolled_back",
140
+ snapshot: "sandbox.checkpoint_created",
141
+ agent_spawned: "agent.spawned",
142
+ agent_provisioned: "agent.provisioned",
143
+ agent_state_changed: "agent.state_changed",
144
+ agent_steered: "agent.steered",
145
+ agent_released: "agent.released",
146
+ agent_ended: "agent.ended",
147
+ handle_settled: "handle.settled",
148
+ wait_resolved: "wait.resolved",
149
+ wait_blocked_on_paused: "wait.blocked",
150
+ inbox_queued: "inbox.queued",
151
+ inbox_delivered: "inbox.delivered",
152
+ inbox_dropped: "inbox.dropped",
153
+ notify_registered: "notify.registered",
154
+ budget_denied: "budget.denied",
155
+ subtree_quiescent: "run.quiescent",
156
+ agent_start: "session.started",
157
+ agent_end: "session.ended",
158
+ turn_start: "turn.started",
159
+ turn_end: "turn.ended",
160
+ tool_start: "tool.started",
161
+ tool_update: "tool.updated",
162
+ tool_end: "tool.ended",
163
+ message_start: "message.started",
164
+ message_update: "message.updated",
165
+ message_end: "message.ended",
166
+ text: "message.updated",
167
+ compaction_start: "compaction.started",
168
+ compaction_end: "compaction.ended",
169
+ auto_retry_start: "retry.started",
170
+ auto_retry_end: "retry.ended",
171
+ queue_update: "queue.updated",
172
+ extension_ui: "extension.ui",
173
+ extension_error: "extension.error"
174
+ });
175
+ /**
176
+ * The new name for an old one, or `undefined` if the name was never renamed.
177
+ *
178
+ * `run_started` returns `undefined` on purpose — it is the one name that meant two different
179
+ * events, so the caller's own context decides.
180
+ */
181
+ function renamedEventType(old) {
182
+ return RENAMED_EVENTS[old];
183
+ }
184
+ //#endregion
185
+ export { agent_exports as AgentEvents, AgentSpecSchema, alineod_exports as AlineodEvents, harness_exports as HarnessEvents, PROJECT_CONFIG_SCHEMA_URL, ProjectConfigObjectSchema, ProjectConfigSchema, RENAMED_EVENTS, SUBJECTS, sandbox_exports as SandboxEvents, VERBS, workflow_exports as WorkflowEvents, allEvents, defineEvent, deprecatedSpecFields, durableEvents, getEvent, isPersisted, isSubject, isVerb, normalizeAgentSpec, parseName, renamedEventType, resourceRefOf };
@@ -0,0 +1,13 @@
1
+ //#region \0rolldown/runtime.js
2
+ var __defProp = Object.defineProperty;
3
+ var __exportAll = (all, no_symbols) => {
4
+ let target = {};
5
+ for (var name in all) __defProp(target, name, {
6
+ get: all[name],
7
+ enumerable: true
8
+ });
9
+ if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
10
+ return target;
11
+ };
12
+ //#endregion
13
+ export { __exportAll as t };
@@ -0,0 +1,2 @@
1
+ import { S as Subject, _ as EventRef, c as SetupStep, d as NormalizedPermissionPolicy, f as PermissionAction, g as DurableRef, h as PermissionRule, i as CredentialEnvBinding, m as PermissionPolicy, p as PermissionMode, t as AgentSpec, v as LedgerEnvelope, w as Verb, y as PersistedEnvelope } from "./agent-spec-C7UBd_R2.mjs";
2
+ export type { AgentSpec, CredentialEnvBinding, DurableRef, EventRef, LedgerEnvelope, NormalizedPermissionPolicy, PermissionAction, PermissionMode, PermissionPolicy, PermissionRule, PersistedEnvelope, SetupStep, Subject, Verb };
package/dist/types.mjs ADDED
@@ -0,0 +1 @@
1
+ export {};
package/package.json CHANGED
@@ -1,6 +1,49 @@
1
1
  {
2
2
  "name": "@alineo-labs/schema",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.3.0",
4
+ "description": "The shapes of the system: the ledger envelope, every event definition, and the subjects and verbs that CLI commands, SDK methods, HTTP routes, MCP tools and event names are built out of. Types and Zod schemas only — no behaviour.",
5
+ "license": "Apache-2.0",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/DrejT/alineo.git",
9
+ "directory": "packages/schema"
10
+ },
11
+ "files": [
12
+ "dist"
13
+ ],
14
+ "type": "module",
15
+ "main": "./dist/index.mjs",
16
+ "types": "./dist/index.d.mts",
17
+ "exports": {
18
+ ".": {
19
+ "import": "./dist/index.mjs",
20
+ "types": "./dist/index.d.mts"
21
+ },
22
+ "./types": {
23
+ "import": "./dist/types.mjs",
24
+ "types": "./dist/types.d.mts"
25
+ },
26
+ "./alineod": {
27
+ "import": "./dist/alineod.mjs",
28
+ "types": "./dist/alineod.d.mts"
29
+ }
30
+ },
31
+ "publishConfig": {
32
+ "access": "public",
33
+ "provenance": true
34
+ },
35
+ "scripts": {
36
+ "build": "tsdown",
37
+ "test": "vitest run",
38
+ "test:watch": "vitest"
39
+ },
40
+ "dependencies": {
41
+ "zod": "^4.4.3"
42
+ },
43
+ "devDependencies": {
44
+ "bun-types": "1.4.2",
45
+ "tsdown": "0.23.0",
46
+ "typescript": "6.0.3",
47
+ "vitest": "5.0.0"
48
+ }
49
+ }