@eloxiv/cli 0.0.0-stage → 0.1.1
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 +21 -0
- package/README.md +12 -2
- package/dist/AgentSkills.d.ts +51 -0
- package/dist/AgentSkills.d.ts.map +1 -0
- package/dist/AgentSkills.js +264 -0
- package/dist/AgentSkills.js.map +1 -0
- package/dist/AgentWeb.d.ts +83 -0
- package/dist/AgentWeb.d.ts.map +1 -0
- package/dist/AgentWeb.js +436 -0
- package/dist/AgentWeb.js.map +1 -0
- package/dist/App.d.ts +213 -0
- package/dist/App.d.ts.map +1 -0
- package/dist/App.js +357 -0
- package/dist/App.js.map +1 -0
- package/dist/Blueprint.d.ts +47 -0
- package/dist/Blueprint.d.ts.map +1 -0
- package/dist/Blueprint.js +241 -0
- package/dist/Blueprint.js.map +1 -0
- package/dist/Brand.d.ts +42 -0
- package/dist/Brand.d.ts.map +1 -0
- package/dist/Brand.js +370 -0
- package/dist/Brand.js.map +1 -0
- package/dist/Changelog.d.ts +22 -0
- package/dist/Changelog.d.ts.map +1 -0
- package/dist/Changelog.js +117 -0
- package/dist/Changelog.js.map +1 -0
- package/dist/Cli.d.ts +17 -0
- package/dist/Cli.d.ts.map +1 -0
- package/dist/Cli.js +810 -0
- package/dist/Cli.js.map +1 -0
- package/dist/DbAdmin.d.ts +18 -0
- package/dist/DbAdmin.d.ts.map +1 -0
- package/dist/DbAdmin.js +91 -0
- package/dist/DbAdmin.js.map +1 -0
- package/dist/Dependencies.d.ts +53 -0
- package/dist/Dependencies.d.ts.map +1 -0
- package/dist/Dependencies.js +132 -0
- package/dist/Dependencies.js.map +1 -0
- package/dist/Deploy.d.ts +39 -0
- package/dist/Deploy.d.ts.map +1 -0
- package/dist/Deploy.js +458 -0
- package/dist/Deploy.js.map +1 -0
- package/dist/Docs.d.ts +71 -0
- package/dist/Docs.d.ts.map +1 -0
- package/dist/Docs.js +240 -0
- package/dist/Docs.js.map +1 -0
- package/dist/Doctor.d.ts +56 -0
- package/dist/Doctor.d.ts.map +1 -0
- package/dist/Doctor.js +368 -0
- package/dist/Doctor.js.map +1 -0
- package/dist/Dossier.d.ts +23 -0
- package/dist/Dossier.d.ts.map +1 -0
- package/dist/Dossier.js +92 -0
- package/dist/Dossier.js.map +1 -0
- package/dist/Emit.d.ts +26 -0
- package/dist/Emit.d.ts.map +1 -0
- package/dist/Emit.js +51 -0
- package/dist/Emit.js.map +1 -0
- package/dist/Errors.d.ts +26 -0
- package/dist/Errors.d.ts.map +1 -0
- package/dist/Errors.js +17 -0
- package/dist/Errors.js.map +1 -0
- package/dist/Evals.d.ts +52 -0
- package/dist/Evals.d.ts.map +1 -0
- package/dist/Evals.js +126 -0
- package/dist/Evals.js.map +1 -0
- package/dist/Files.d.ts +47 -0
- package/dist/Files.d.ts.map +1 -0
- package/dist/Files.js +145 -0
- package/dist/Files.js.map +1 -0
- package/dist/Generate.d.ts +80 -0
- package/dist/Generate.d.ts.map +1 -0
- package/dist/Generate.js +310 -0
- package/dist/Generate.js.map +1 -0
- package/dist/Guards.d.ts +45 -0
- package/dist/Guards.d.ts.map +1 -0
- package/dist/Guards.js +530 -0
- package/dist/Guards.js.map +1 -0
- package/dist/Inspect.d.ts +125 -0
- package/dist/Inspect.d.ts.map +1 -0
- package/dist/Inspect.js +270 -0
- package/dist/Inspect.js.map +1 -0
- package/dist/Keychain.d.ts +57 -0
- package/dist/Keychain.d.ts.map +1 -0
- package/dist/Keychain.js +73 -0
- package/dist/Keychain.js.map +1 -0
- package/dist/Lock.d.ts +13 -0
- package/dist/Lock.d.ts.map +1 -0
- package/dist/Lock.js +145 -0
- package/dist/Lock.js.map +1 -0
- package/dist/Mcp.d.ts +91 -0
- package/dist/Mcp.d.ts.map +1 -0
- package/dist/Mcp.js +128 -0
- package/dist/Mcp.js.map +1 -0
- package/dist/Merge.d.ts +18 -0
- package/dist/Merge.d.ts.map +1 -0
- package/dist/Merge.js +43 -0
- package/dist/Merge.js.map +1 -0
- package/dist/Migrate.d.ts +78 -0
- package/dist/Migrate.d.ts.map +1 -0
- package/dist/Migrate.js +288 -0
- package/dist/Migrate.js.map +1 -0
- package/dist/Plugins.d.ts +36 -0
- package/dist/Plugins.d.ts.map +1 -0
- package/dist/Plugins.js +304 -0
- package/dist/Plugins.js.map +1 -0
- package/dist/Postgres.d.ts +73 -0
- package/dist/Postgres.d.ts.map +1 -0
- package/dist/Postgres.js +294 -0
- package/dist/Postgres.js.map +1 -0
- package/dist/Publish.d.ts +23 -0
- package/dist/Publish.d.ts.map +1 -0
- package/dist/Publish.js +59 -0
- package/dist/Publish.js.map +1 -0
- package/dist/Registry.d.ts +539 -0
- package/dist/Registry.d.ts.map +1 -0
- package/dist/Registry.js +340 -0
- package/dist/Registry.js.map +1 -0
- package/dist/Remote.d.ts +90 -0
- package/dist/Remote.d.ts.map +1 -0
- package/dist/Remote.js +1006 -0
- package/dist/Remote.js.map +1 -0
- package/dist/Run.d.ts +120 -0
- package/dist/Run.d.ts.map +1 -0
- package/dist/Run.js +477 -0
- package/dist/Run.js.map +1 -0
- package/dist/SyncGen.d.ts +118 -0
- package/dist/SyncGen.d.ts.map +1 -0
- package/dist/SyncGen.js +392 -0
- package/dist/SyncGen.js.map +1 -0
- package/dist/Update.d.ts +301 -0
- package/dist/Update.d.ts.map +1 -0
- package/dist/Update.js +627 -0
- package/dist/Update.js.map +1 -0
- package/dist/bin.d.ts +3 -0
- package/dist/bin.d.ts.map +1 -0
- package/dist/bin.js +42 -0
- package/dist/bin.js.map +1 -0
- package/dist/docs/backlog.md +56 -0
- package/dist/docs/ci.md +277 -0
- package/dist/docs/cli.md +696 -0
- package/dist/docs/connectors/google.md +115 -0
- package/dist/docs/connectors/http-openapi.md +7 -0
- package/dist/docs/connectors/mcp.md +8 -0
- package/dist/docs/connectors/microsoft-graph.md +75 -0
- package/dist/docs/connectors/openai.md +25 -0
- package/dist/docs/connectors/slack.md +162 -0
- package/dist/docs/connectors/workos.md +39 -0
- package/dist/docs/contracts/README.md +173 -0
- package/dist/docs/contracts/action-consent.md +92 -0
- package/dist/docs/contracts/action-registry.md +85 -0
- package/dist/docs/contracts/actor.md +100 -0
- package/dist/docs/contracts/agent-resources.md +90 -0
- package/dist/docs/contracts/agent-runtime.md +257 -0
- package/dist/docs/contracts/approvals.md +126 -0
- package/dist/docs/contracts/audit.md +75 -0
- package/dist/docs/contracts/auth-provider.md +74 -0
- package/dist/docs/contracts/calendar-provider.md +46 -0
- package/dist/docs/contracts/client-sdk.md +245 -0
- package/dist/docs/contracts/collab-document.md +151 -0
- package/dist/docs/contracts/command.md +44 -0
- package/dist/docs/contracts/connections.md +235 -0
- package/dist/docs/contracts/context-accounting.md +50 -0
- package/dist/docs/contracts/daemon.md +243 -0
- package/dist/docs/contracts/db-tx.md +53 -0
- package/dist/docs/contracts/delegation.md +68 -0
- package/dist/docs/contracts/device-control.md +103 -0
- package/dist/docs/contracts/directory-provider.md +36 -0
- package/dist/docs/contracts/directory.md +161 -0
- package/dist/docs/contracts/document-source.md +33 -0
- package/dist/docs/contracts/files.md +115 -0
- package/dist/docs/contracts/flags.md +83 -0
- package/dist/docs/contracts/host.md +68 -0
- package/dist/docs/contracts/http-api.md +43 -0
- package/dist/docs/contracts/ingestion.md +130 -0
- package/dist/docs/contracts/ingress.md +141 -0
- package/dist/docs/contracts/invocation.md +260 -0
- package/dist/docs/contracts/local-client.md +110 -0
- package/dist/docs/contracts/locale.md +56 -0
- package/dist/docs/contracts/machine-identity.md +117 -0
- package/dist/docs/contracts/mail-provider.md +49 -0
- package/dist/docs/contracts/memory.md +53 -0
- package/dist/docs/contracts/messaging.md +40 -0
- package/dist/docs/contracts/metering.md +139 -0
- package/dist/docs/contracts/model-provider.md +84 -0
- package/dist/docs/contracts/module-manifest.md +213 -0
- package/dist/docs/contracts/notification-channel.md +90 -0
- package/dist/docs/contracts/notifications.md +123 -0
- package/dist/docs/contracts/outbox.md +80 -0
- package/dist/docs/contracts/privacy.md +110 -0
- package/dist/docs/contracts/progress.md +52 -0
- package/dist/docs/contracts/query-surface.md +108 -0
- package/dist/docs/contracts/readiness.md +63 -0
- package/dist/docs/contracts/release.md +142 -0
- package/dist/docs/contracts/result-rendering.md +61 -0
- package/dist/docs/contracts/sandbox.md +186 -0
- package/dist/docs/contracts/scheduler.md +148 -0
- package/dist/docs/contracts/screen-context.md +81 -0
- package/dist/docs/contracts/search.md +120 -0
- package/dist/docs/contracts/secrets.md +74 -0
- package/dist/docs/contracts/settings.md +109 -0
- package/dist/docs/contracts/sharing.md +77 -0
- package/dist/docs/contracts/slot.md +48 -0
- package/dist/docs/contracts/space.md +67 -0
- package/dist/docs/contracts/storage-adapter.md +45 -0
- package/dist/docs/contracts/storage-backend.md +56 -0
- package/dist/docs/contracts/sync.md +213 -0
- package/dist/docs/contracts/telemetry.md +80 -0
- package/dist/docs/contracts/theme-tokens.md +50 -0
- package/dist/docs/contracts/tool-source.md +58 -0
- package/dist/docs/contracts/versioning.md +99 -0
- package/dist/docs/contracts/view.md +65 -0
- package/dist/docs/contracts/work-items.md +99 -0
- package/dist/docs/contracts/workflow.md +82 -0
- package/dist/docs/decisions.md +163 -0
- package/dist/docs/example-app.md +192 -0
- package/dist/docs/getting-started.md +927 -0
- package/dist/docs/goal.md +54 -0
- package/dist/docs/parity.md +29 -0
- package/dist/docs/performance.md +129 -0
- package/dist/docs/registry/README.md +74 -0
- package/dist/docs/registry/app.md +38 -0
- package/dist/docs/registry/approvals-ui-foldkit.md +28 -0
- package/dist/docs/registry/calendar-ui-foldkit.md +27 -0
- package/dist/docs/registry/calendar.md +35 -0
- package/dist/docs/registry/chat-ui-foldkit.md +30 -0
- package/dist/docs/registry/desktop-rune.md +50 -0
- package/dist/docs/registry/desktop.md +32 -0
- package/dist/docs/registry/eloxiv-action.md +25 -0
- package/dist/docs/registry/eloxiv-connector.md +25 -0
- package/dist/docs/registry/eloxiv-module.md +25 -0
- package/dist/docs/registry/eloxiv-policy.md +25 -0
- package/dist/docs/registry/eloxiv-view.md +25 -0
- package/dist/docs/registry/hello-ui-foldkit.md +29 -0
- package/dist/docs/registry/hello.md +39 -0
- package/dist/docs/registry/home-ui-foldkit.md +27 -0
- package/dist/docs/registry/home.md +29 -0
- package/dist/docs/registry/inbox-ui-foldkit.md +27 -0
- package/dist/docs/registry/mail-ui-foldkit.md +27 -0
- package/dist/docs/registry/mail.md +34 -0
- package/dist/docs/registry/meeting-prep.md +26 -0
- package/dist/docs/registry/members-ui-foldkit.md +28 -0
- package/dist/docs/registry/mobile.md +37 -0
- package/dist/docs/registry/notes-ui-foldkit.md +27 -0
- package/dist/docs/registry/notes.md +26 -0
- package/dist/docs/registry/people-ui-foldkit.md +28 -0
- package/dist/docs/registry/people.md +38 -0
- package/dist/docs/registry/shell-foldkit.md +35 -0
- package/dist/docs/registry/theme.md +25 -0
- package/dist/docs/registry/ui-conformance.md +30 -0
- package/dist/docs/release.md +100 -0
- package/dist/docs/scaffold.md +826 -0
- package/dist/docs/security/threat-model.md +299 -0
- package/dist/docs/upstream/zero-cache-socket-handoff.md +105 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +8 -0
- package/dist/index.js.map +1 -0
- package/package.json +48 -3
- package/src/AgentSkills.ts +329 -0
- package/src/AgentWeb.ts +507 -0
- package/src/App.ts +435 -0
- package/src/Blueprint.ts +276 -0
- package/src/Brand.ts +415 -0
- package/src/Changelog.ts +136 -0
- package/src/Cli.ts +1458 -0
- package/src/DbAdmin.ts +115 -0
- package/src/Dependencies.ts +170 -0
- package/src/Deploy.ts +563 -0
- package/src/Docs.ts +309 -0
- package/src/Doctor.ts +424 -0
- package/src/Dossier.ts +148 -0
- package/src/Emit.ts +68 -0
- package/src/Errors.ts +18 -0
- package/src/Evals.ts +153 -0
- package/src/Files.ts +152 -0
- package/src/Generate.ts +402 -0
- package/src/Guards.ts +541 -0
- package/src/Inspect.ts +358 -0
- package/src/Keychain.ts +107 -0
- package/src/Lock.ts +174 -0
- package/src/Mcp.ts +159 -0
- package/src/Merge.ts +70 -0
- package/src/Migrate.ts +331 -0
- package/src/Plugins.ts +347 -0
- package/src/Postgres.ts +353 -0
- package/src/Publish.ts +64 -0
- package/src/Registry.ts +405 -0
- package/src/Remote.ts +1158 -0
- package/src/Run.ts +541 -0
- package/src/SyncGen.ts +570 -0
- package/src/Update.ts +873 -0
- package/src/bin.ts +46 -0
- package/src/index.ts +7 -0
package/dist/Errors.d.ts
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/** The CLI's failures and exit statuses. */
|
|
2
|
+
import { Runtime, Schema } from "effect";
|
|
3
|
+
declare const CliError_base: Schema.Class<CliError, Schema.TaggedStruct<"CliError", {
|
|
4
|
+
readonly message: Schema.String;
|
|
5
|
+
}>, import("effect/Cause").YieldableError>;
|
|
6
|
+
/** A failure of the command itself (exit code 2: bad input, unreachable registry, refused operation). */
|
|
7
|
+
export declare class CliError extends CliError_base {
|
|
8
|
+
readonly [Runtime.errorExitCode] = 2;
|
|
9
|
+
readonly [Runtime.errorReported] = false;
|
|
10
|
+
}
|
|
11
|
+
declare const ExitStatus_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => import("effect/Cause").YieldableError & {
|
|
12
|
+
readonly _tag: "ExitStatus";
|
|
13
|
+
} & Readonly<A>;
|
|
14
|
+
/**
|
|
15
|
+
* The command ran but has something to report to a script: `diff` found differences, `update` left
|
|
16
|
+
* conflicts or was blocked (exit code 1). Its report has already been printed.
|
|
17
|
+
*/
|
|
18
|
+
export declare class ExitStatus extends ExitStatus_base<{
|
|
19
|
+
readonly code: number;
|
|
20
|
+
readonly reason: string;
|
|
21
|
+
}> {
|
|
22
|
+
readonly [Runtime.errorExitCode]: number;
|
|
23
|
+
readonly [Runtime.errorReported] = false;
|
|
24
|
+
}
|
|
25
|
+
export {};
|
|
26
|
+
//# sourceMappingURL=Errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Errors.d.ts","sourceRoot":"","sources":["../src/Errors.ts"],"names":[],"mappings":"AAAA,4CAA4C;AAC5C,OAAO,EAAQ,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;;;;AAE9C,yGAAyG;AACzG,qBAAa,QAAS,SAAQ,aAAsE;IAClG,SAAkB,CAAC,OAAO,CAAC,aAAa,CAAC,KAAI;IAE7C,SAAkB,CAAC,OAAO,CAAC,aAAa,CAAC,SAAQ;CAClD;;;;AAED;;;GAGG;AACH,qBAAa,UAAW,SAAQ,gBAA+B;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC;IAChH,SAAkB,CAAC,OAAO,CAAC,aAAa,CAAC,EAAE,MAAM,CAAY;IAC7D,SAAkB,CAAC,OAAO,CAAC,aAAa,CAAC,SAAQ;CAClD"}
|
package/dist/Errors.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/** The CLI's failures and exit statuses. */
|
|
2
|
+
import { Data, Runtime, Schema } from "effect";
|
|
3
|
+
/** A failure of the command itself (exit code 2: bad input, unreachable registry, refused operation). */
|
|
4
|
+
export class CliError extends Schema.TaggedError()("CliError", { message: Schema.String }) {
|
|
5
|
+
[Runtime.errorExitCode] = 2;
|
|
6
|
+
// bin.ts prints the message alone, without a stack trace.
|
|
7
|
+
[Runtime.errorReported] = false;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* The command ran but has something to report to a script: `diff` found differences, `update` left
|
|
11
|
+
* conflicts or was blocked (exit code 1). Its report has already been printed.
|
|
12
|
+
*/
|
|
13
|
+
export class ExitStatus extends Data.TaggedError("ExitStatus") {
|
|
14
|
+
[Runtime.errorExitCode] = this.code;
|
|
15
|
+
[Runtime.errorReported] = false;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=Errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Errors.js","sourceRoot":"","sources":["../src/Errors.ts"],"names":[],"mappings":"AAAA,4CAA4C;AAC5C,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAE9C,yGAAyG;AACzG,MAAM,OAAO,QAAS,SAAQ,MAAM,CAAC,WAAW,EAAY,CAAC,UAAU,EAAE,EAAE,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC;IAChF,CAAC,OAAO,CAAC,aAAa,CAAC,GAAG,CAAC,CAAA;IAC7C,0DAA0D;IACxC,CAAC,OAAO,CAAC,aAAa,CAAC,GAAG,KAAK,CAAA;CAClD;AAED;;;GAGG;AACH,MAAM,OAAO,UAAW,SAAQ,IAAI,CAAC,WAAW,CAAC,YAAY,CAAqD;IAC9F,CAAC,OAAO,CAAC,aAAa,CAAC,GAAW,IAAI,CAAC,IAAI,CAAA;IAC3C,CAAC,OAAO,CAAC,aAAa,CAAC,GAAG,KAAK,CAAA;CAClD"}
|
package/dist/Evals.d.ts
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Agent evals from the CLI (docs/cli.md, "eval"):
|
|
3
|
+
*
|
|
4
|
+
* eloxiv eval [--module <m>]... [--model <spec>] the app's module skills' eval cases through the real agent
|
|
5
|
+
* runtime on a fresh database (`@eloxiv/testing`'s runner)
|
|
6
|
+
* eloxiv eval promote <run> ... a finished run of the app's agent turned into an eval case,
|
|
7
|
+
* only with a reviewed prompt and explicit allowlists
|
|
8
|
+
*
|
|
9
|
+
* Promotion takes production behaviour into a test without taking production data with it. What a case keeps is what
|
|
10
|
+
* the reviewer names: the prompt is the one they write (bounded; the person's own words are never copied), the run
|
|
11
|
+
* may have called only the tools they allow (and read only the query views they allow), a call's input keeps only
|
|
12
|
+
* the fields they name, and the answer is checked only for the words they give. Anything else in the trace makes the
|
|
13
|
+
* promotion refuse, saying what. Writing the case into a skill's eval file needs `--reviewed`.
|
|
14
|
+
*/
|
|
15
|
+
import { EvalCase } from "@eloxiv/contracts";
|
|
16
|
+
/** The longest prompt a promoted case may carry. */
|
|
17
|
+
export declare const MAX_PROMPT_CHARS = 2000;
|
|
18
|
+
/**
|
|
19
|
+
* `@eloxiv/testing`'s eval runner as the app (or a directory above it) installed it: its build, for an installed
|
|
20
|
+
* package (Node strips no types under `node_modules`), its source for Eloxiv's own workspace package.
|
|
21
|
+
*/
|
|
22
|
+
export declare const evalEntry: (dir: string) => string;
|
|
23
|
+
export interface PromotionReview {
|
|
24
|
+
/** The case's name. */
|
|
25
|
+
readonly name: string;
|
|
26
|
+
/** The prompt the case sends: written (or reviewed) by a person, at most MAX_PROMPT_CHARS. */
|
|
27
|
+
readonly prompt: string;
|
|
28
|
+
/** The tools the run may have called (the agent's tool names, e.g. `notes_write`). */
|
|
29
|
+
readonly allowTools: ReadonlyArray<string>;
|
|
30
|
+
/** The query views the run may have read through the `query` tool. */
|
|
31
|
+
readonly allowViews: ReadonlyArray<string>;
|
|
32
|
+
/** Per tool, the input fields a case keeps (everything else in a call's input is dropped). */
|
|
33
|
+
readonly keepInput: Readonly<Record<string, ReadonlyArray<string>>>;
|
|
34
|
+
readonly answerIncludes: ReadonlyArray<string>;
|
|
35
|
+
readonly forbiddenTools: ReadonlyArray<string>;
|
|
36
|
+
}
|
|
37
|
+
export interface Promotion {
|
|
38
|
+
readonly case: EvalCase;
|
|
39
|
+
/** What was left out of each call, for the reviewer: `<tool>.<field>`. */
|
|
40
|
+
readonly dropped: ReadonlyArray<string>;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Turn a finished run's events into an eval case under `review`. Refuses (CliError, every reason at once) a run that
|
|
44
|
+
* did not succeed, an empty or overlong prompt, a call to a tool not allowed, and a read of a view not allowed.
|
|
45
|
+
*/
|
|
46
|
+
export declare const promoteTrace: (events: ReadonlyArray<{
|
|
47
|
+
readonly type: string;
|
|
48
|
+
readonly data: Record<string, unknown>;
|
|
49
|
+
}>, review: PromotionReview) => Promotion;
|
|
50
|
+
/** Add `promoted` to a skill's eval file (refusing a case name it already has). */
|
|
51
|
+
export declare const addCase: (file: string, promoted: EvalCase) => number;
|
|
52
|
+
//# sourceMappingURL=Evals.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Evals.d.ts","sourceRoot":"","sources":["../src/Evals.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,EAAE,QAAQ,EAAc,MAAM,mBAAmB,CAAA;AAMxD,oDAAoD;AACpD,eAAO,MAAM,gBAAgB,OAAO,CAAA;AAEpC;;;GAGG;AACH,eAAO,MAAM,SAAS,QAAS,MAAM,KAAG,MAcvC,CAAA;AAED,MAAM,WAAW,eAAe;IAC9B,uBAAuB;IACvB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,8FAA8F;IAC9F,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;IACvB,sFAAsF;IACtF,QAAQ,CAAC,UAAU,EAAE,aAAa,CAAC,MAAM,CAAC,CAAA;IAC1C,sEAAsE;IACtE,QAAQ,CAAC,UAAU,EAAE,aAAa,CAAC,MAAM,CAAC,CAAA;IAC1C,8FAA8F;IAC9F,QAAQ,CAAC,SAAS,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC,CAAC,CAAA;IACnE,QAAQ,CAAC,cAAc,EAAE,aAAa,CAAC,MAAM,CAAC,CAAA;IAC9C,QAAQ,CAAC,cAAc,EAAE,aAAa,CAAC,MAAM,CAAC,CAAA;CAC/C;AAOD,MAAM,WAAW,SAAS;IACxB,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAA;IACvB,0EAA0E;IAC1E,QAAQ,CAAC,OAAO,EAAE,aAAa,CAAC,MAAM,CAAC,CAAA;CACxC;AAED;;;GAGG;AACH,eAAO,MAAM,YAAY,WACf,aAAa,CAAC;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAAE,CAAC,UAChF,eAAe,KACtB,SA+DF,CAAA;AAED,mFAAmF;AACnF,eAAO,MAAM,OAAO,SAAU,MAAM,YAAY,QAAQ,WAUvD,CAAA"}
|
package/dist/Evals.js
ADDED
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Agent evals from the CLI (docs/cli.md, "eval"):
|
|
3
|
+
*
|
|
4
|
+
* eloxiv eval [--module <m>]... [--model <spec>] the app's module skills' eval cases through the real agent
|
|
5
|
+
* runtime on a fresh database (`@eloxiv/testing`'s runner)
|
|
6
|
+
* eloxiv eval promote <run> ... a finished run of the app's agent turned into an eval case,
|
|
7
|
+
* only with a reviewed prompt and explicit allowlists
|
|
8
|
+
*
|
|
9
|
+
* Promotion takes production behaviour into a test without taking production data with it. What a case keeps is what
|
|
10
|
+
* the reviewer names: the prompt is the one they write (bounded; the person's own words are never copied), the run
|
|
11
|
+
* may have called only the tools they allow (and read only the query views they allow), a call's input keeps only
|
|
12
|
+
* the fields they name, and the answer is checked only for the words they give. Anything else in the trace makes the
|
|
13
|
+
* promotion refuse, saying what. Writing the case into a skill's eval file needs `--reviewed`.
|
|
14
|
+
*/
|
|
15
|
+
import { EvalCase, SkillEvals } from "@eloxiv/contracts";
|
|
16
|
+
import { Schema } from "effect";
|
|
17
|
+
import { existsSync, readFileSync, realpathSync, writeFileSync } from "node:fs";
|
|
18
|
+
import { dirname, join } from "node:path";
|
|
19
|
+
import { CliError } from "./Errors.js";
|
|
20
|
+
/** The longest prompt a promoted case may carry. */
|
|
21
|
+
export const MAX_PROMPT_CHARS = 2000;
|
|
22
|
+
/**
|
|
23
|
+
* `@eloxiv/testing`'s eval runner as the app (or a directory above it) installed it: its build, for an installed
|
|
24
|
+
* package (Node strips no types under `node_modules`), its source for Eloxiv's own workspace package.
|
|
25
|
+
*/
|
|
26
|
+
export const evalEntry = (dir) => {
|
|
27
|
+
for (let current = dir;; current = dirname(current)) {
|
|
28
|
+
const pkg = join(current, "node_modules", "@eloxiv", "testing");
|
|
29
|
+
if (existsSync(pkg)) {
|
|
30
|
+
const real = realpathSync(pkg);
|
|
31
|
+
const installed = real.split(/[\\/]/).includes("node_modules");
|
|
32
|
+
for (const file of installed ? ["dist/EvalMain.js", "src/EvalMain.ts"] : ["src/EvalMain.ts", "dist/EvalMain.js"])
|
|
33
|
+
if (existsSync(join(real, file)))
|
|
34
|
+
return join(real, file);
|
|
35
|
+
}
|
|
36
|
+
if (dirname(current) === current)
|
|
37
|
+
break;
|
|
38
|
+
}
|
|
39
|
+
throw new CliError({
|
|
40
|
+
message: `${dir} has no @eloxiv/testing (the eval runner): add it to the app's devDependencies and run pnpm install`,
|
|
41
|
+
});
|
|
42
|
+
};
|
|
43
|
+
/**
|
|
44
|
+
* Turn a finished run's events into an eval case under `review`. Refuses (CliError, every reason at once) a run that
|
|
45
|
+
* did not succeed, an empty or overlong prompt, a call to a tool not allowed, and a read of a view not allowed.
|
|
46
|
+
*/
|
|
47
|
+
export const promoteTrace = (events, review) => {
|
|
48
|
+
const problems = [];
|
|
49
|
+
const finished = events.find((e) => e.type === "run-finished");
|
|
50
|
+
if (finished === undefined)
|
|
51
|
+
problems.push("the run has not finished");
|
|
52
|
+
else if (finished.data["status"] !== "succeeded")
|
|
53
|
+
problems.push(`the run ended ${String(finished.data["status"])}: only a run that succeeded is promoted`);
|
|
54
|
+
const prompt = review.prompt.trim();
|
|
55
|
+
if (prompt === "")
|
|
56
|
+
problems.push("--prompt is required: the case's prompt, written or reviewed by you (the person's own words are not copied)");
|
|
57
|
+
if (prompt.length > MAX_PROMPT_CHARS)
|
|
58
|
+
problems.push(`the prompt is ${prompt.length} characters; at most ${MAX_PROMPT_CHARS}`);
|
|
59
|
+
if (review.allowTools.length === 0)
|
|
60
|
+
problems.push("--allow-tool is required: the tools the run may have called");
|
|
61
|
+
const steps = events
|
|
62
|
+
.filter((e) => e.type === "model-step")
|
|
63
|
+
.map((e) => (Array.isArray(e.data["toolCalls"]) ? e.data["toolCalls"] : []))
|
|
64
|
+
.filter((calls) => calls.length > 0);
|
|
65
|
+
for (const call of steps.flat()) {
|
|
66
|
+
if (!review.allowTools.includes(call.toolName))
|
|
67
|
+
problems.push(`the run called ${call.toolName}, which --allow-tool does not allow`);
|
|
68
|
+
if (call.toolName === "query") {
|
|
69
|
+
const view = call.input?.view;
|
|
70
|
+
if (typeof view !== "string" || !review.allowViews.includes(view)) {
|
|
71
|
+
problems.push(`the run read the view ${String(view)}, which --allow-view does not allow`);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
// Tool calls a device served (a turn handed to one of the person's devices) are events of their own: held to the
|
|
76
|
+
// same allowlist, though a case cannot replay them.
|
|
77
|
+
for (const event of events.filter((e) => e.type === "tool-call")) {
|
|
78
|
+
const tool = event.data["toolName"];
|
|
79
|
+
if (typeof tool === "string" && !review.allowTools.includes(tool))
|
|
80
|
+
problems.push(`the run called ${tool}, which --allow-tool does not allow`);
|
|
81
|
+
}
|
|
82
|
+
if (problems.length > 0)
|
|
83
|
+
throw new CliError({ message: `Not promoted: ${[...new Set(problems)].join("; ")}` });
|
|
84
|
+
const dropped = [];
|
|
85
|
+
const kept = (call) => {
|
|
86
|
+
const keep = review.keepInput[call.toolName] ?? (call.toolName === "query" ? ["view"] : []);
|
|
87
|
+
const input = (call.input ?? {});
|
|
88
|
+
for (const field of Object.keys(input))
|
|
89
|
+
if (!keep.includes(field))
|
|
90
|
+
dropped.push(`${call.toolName}.${field}`);
|
|
91
|
+
return Object.fromEntries(Object.entries(input).filter(([field]) => keep.includes(field)));
|
|
92
|
+
};
|
|
93
|
+
const candidate = {
|
|
94
|
+
name: review.name,
|
|
95
|
+
prompt,
|
|
96
|
+
expect: {
|
|
97
|
+
toolCalls: steps.flat().map((call) => {
|
|
98
|
+
const input = kept(call);
|
|
99
|
+
return Object.keys(input).length === 0 ? { tool: call.toolName } : { tool: call.toolName, input };
|
|
100
|
+
}),
|
|
101
|
+
...(review.forbiddenTools.length === 0 ? {} : { forbiddenTools: review.forbiddenTools }),
|
|
102
|
+
...(review.answerIncludes.length === 0 ? {} : { answerIncludes: review.answerIncludes }),
|
|
103
|
+
},
|
|
104
|
+
// The scripted provider's turns (CI): the same calls with the kept inputs, then an answer holding the words the
|
|
105
|
+
// case checks. Review the inputs: a field the case dropped may be one the action needs.
|
|
106
|
+
script: [
|
|
107
|
+
...steps.map((calls) => ({ toolCalls: calls.map((call) => ({ tool: call.toolName, input: kept(call) })) })),
|
|
108
|
+
{ text: review.answerIncludes.length === 0 ? "Done." : review.answerIncludes.join(", ") },
|
|
109
|
+
],
|
|
110
|
+
};
|
|
111
|
+
const decoded = Schema.decodeUnknownSync(EvalCase)(candidate);
|
|
112
|
+
return { case: decoded, dropped: [...new Set(dropped)] };
|
|
113
|
+
};
|
|
114
|
+
/** Add `promoted` to a skill's eval file (refusing a case name it already has). */
|
|
115
|
+
export const addCase = (file, promoted) => {
|
|
116
|
+
if (!existsSync(file))
|
|
117
|
+
throw new CliError({
|
|
118
|
+
message: `${file} does not exist: name a skill's eval file (skills.<id>.evals in its module's contract)`,
|
|
119
|
+
});
|
|
120
|
+
const evals = Schema.decodeUnknownSync(SkillEvals)(JSON.parse(readFileSync(file, "utf8")));
|
|
121
|
+
if (evals.cases.some((c) => c.name === promoted.name))
|
|
122
|
+
throw new CliError({ message: `${file} already has a case named ${promoted.name}` });
|
|
123
|
+
writeFileSync(file, `${JSON.stringify({ ...evals, cases: [...evals.cases, promoted] }, null, 2)}\n`);
|
|
124
|
+
return evals.cases.length + 1;
|
|
125
|
+
};
|
|
126
|
+
//# sourceMappingURL=Evals.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Evals.js","sourceRoot":"","sources":["../src/Evals.ts"],"names":[],"mappings":"AAAA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,CAAC,UAAU,CAAC,IAAI,CAAC;QACnB,MAAM,IAAI,QAAQ,CAAC;YACjB,OAAO,EAAE,GAAG,IAAI,wFAAwF;SACzG,CAAC,CAAA;IACJ,MAAM,KAAK,GAAG,MAAM,CAAC,iBAAiB,CAAC,UAAU,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC,CAAA;IAC1F,IAAI,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,QAAQ,CAAC,IAAI,CAAC;QACnD,MAAM,IAAI,QAAQ,CAAC,EAAE,OAAO,EAAE,GAAG,IAAI,6BAA6B,QAAQ,CAAC,IAAI,EAAE,EAAE,CAAC,CAAA;IACtF,aAAa,CAAC,IAAI,EAAE,GAAG,IAAI,CAAC,SAAS,CAAC,EAAE,GAAG,KAAK,EAAE,KAAK,EAAE,CAAC,GAAG,KAAK,CAAC,KAAK,EAAE,QAAQ,CAAC,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,CAAA;IACpG,OAAO,KAAK,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAA;AAC/B,CAAC,CAAA"}
|
package/dist/Files.d.ts
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The app's files as the CLI touches them: target paths normalised and kept inside the app, writes and
|
|
3
|
+
* deletes refused through symbolic links, and contents read as bytes (text only when they are valid UTF-8).
|
|
4
|
+
*/
|
|
5
|
+
import { Effect, FileSystem, Path } from "effect";
|
|
6
|
+
import { CliError } from "./Errors.ts";
|
|
7
|
+
/**
|
|
8
|
+
* Normalise a target path relative to the app (`./src/a`, `src//a` and `src\a` are `src/a`), or `undefined`
|
|
9
|
+
* if it is absolute, empty or leaves the app (`..`).
|
|
10
|
+
*/
|
|
11
|
+
export declare const normaliseTarget: (target: string) => string | undefined;
|
|
12
|
+
/** The absolute path of a file of the app, for reading: the path must stay inside the app. */
|
|
13
|
+
export declare const appPath: (dir: string, relative: string) => Effect.Effect<string, CliError, Path.Path>;
|
|
14
|
+
/**
|
|
15
|
+
* The one rule for every path the CLI writes or deletes (add, update, eject, restore, clean, generate, mcp): the
|
|
16
|
+
* absolute path of `relative` inside the app, after checking, before anything is touched, that
|
|
17
|
+
*
|
|
18
|
+
* - every ancestor below the app directory that exists is a real directory, not a symbolic link (even a dangling
|
|
19
|
+
* one) nor a file, so nothing is written or deleted through a link;
|
|
20
|
+
* - the path itself is not a symbolic link (`"write"`), or, when it is to be deleted (`"remove"`), may be one: the
|
|
21
|
+
* link is deleted, never what it points at;
|
|
22
|
+
* - resolved (`realpath` of its deepest existing ancestor, with the rest appended), it lies inside the resolved app
|
|
23
|
+
* directory.
|
|
24
|
+
*
|
|
25
|
+
* The returned path is under the resolved app directory.
|
|
26
|
+
*/
|
|
27
|
+
export declare const safeAppPath: (dir: string, relative: string, mode: "write" | "remove") => Effect.Effect<string, CliError, FileSystem.FileSystem | Path.Path>;
|
|
28
|
+
/** The absolute path of a file of the app, for writing or deleting a file (`safeAppPath`'s `"write"` rule). */
|
|
29
|
+
export declare const writablePath: (dir: string, relative: string) => Effect.Effect<string, CliError, FileSystem.FileSystem | Path.Path>;
|
|
30
|
+
/** Read a file of the app as bytes, or `undefined` if it does not exist. */
|
|
31
|
+
export declare const readAppBytes: (dir: string, relative: string) => Effect.Effect<Uint8Array<ArrayBufferLike> | undefined, CliError | import("effect/PlatformError").PlatformError, FileSystem.FileSystem | Path.Path>;
|
|
32
|
+
/** Whether `text` can be line-merged: no NUL. */
|
|
33
|
+
export declare const isMergeableText: (text: string) => boolean;
|
|
34
|
+
/**
|
|
35
|
+
* The bytes as text when they are valid UTF-8 that round-trips exactly and hold no NUL; otherwise
|
|
36
|
+
* `undefined` (binary: compared byte for byte, never line-merged).
|
|
37
|
+
*/
|
|
38
|
+
export declare const asText: (bytes: Uint8Array) => string | undefined;
|
|
39
|
+
export declare const sameBytes: (a: Uint8Array, b: Uint8Array) => boolean;
|
|
40
|
+
/** Whether the app's bytes are exactly `text` encoded as UTF-8. */
|
|
41
|
+
export declare const bytesEqualText: (bytes: Uint8Array, text: string) => boolean;
|
|
42
|
+
export declare const sha256Bytes: (bytes: Uint8Array) => Effect.Effect<string, never, never>;
|
|
43
|
+
/** Write `content` to a file of the app (creating its directory), refusing symbolic links on the way. */
|
|
44
|
+
export declare const writeAppFile: (dir: string, relative: string, content: string | Uint8Array) => Effect.Effect<void, CliError | import("effect/PlatformError").PlatformError, FileSystem.FileSystem | Path.Path>;
|
|
45
|
+
/** Delete a file of the app, refusing symbolic links on the way. */
|
|
46
|
+
export declare const removeAppFile: (dir: string, relative: string) => Effect.Effect<void, CliError | import("effect/PlatformError").PlatformError, FileSystem.FileSystem | Path.Path>;
|
|
47
|
+
//# sourceMappingURL=Files.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Files.d.ts","sourceRoot":"","sources":["../src/Files.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,MAAM,EAAE,UAAU,EAAU,IAAI,EAAE,MAAM,QAAQ,CAAA;AACzD,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AAEtC;;;GAGG;AACH,eAAO,MAAM,eAAe,WAAY,MAAM,KAAG,MAAM,GAAG,SAKzD,CAAA;AASD,8FAA8F;AAC9F,eAAO,MAAM,OAAO,QAAS,MAAM,YAAY,MAAM,+CAIjD,CAAA;AAEJ;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,WAAW,QAAS,MAAM,YAAY,MAAM,QAAQ,OAAO,GAAG,QAAQ,uEAwC/E,CAAA;AAEJ,+GAA+G;AAC/G,eAAO,MAAM,YAAY,QAAS,MAAM,YAAY,MAAM,uEAAwC,CAAA;AAElG,4EAA4E;AAC5E,eAAO,MAAM,YAAY,QAAS,MAAM,YAAY,MAAM,uJAMtD,CAAA;AAKJ,iDAAiD;AACjD,eAAO,MAAM,eAAe,SAAU,MAAM,YAA6B,CAAA;AAEzE;;;GAGG;AACH,eAAO,MAAM,MAAM,UAAW,UAAU,KAAG,MAAM,GAAG,SASnD,CAAA;AAED,eAAO,MAAM,SAAS,MAAO,UAAU,KAAK,UAAU,YAIrD,CAAA;AAED,mEAAmE;AACnE,eAAO,MAAM,cAAc,UAAW,UAAU,QAAQ,MAAM,YAA2C,CAAA;AAEzG,eAAO,MAAM,WAAW,UAAW,UAAU,wCAIzC,CAAA;AAEJ,yGAAyG;AACzG,eAAO,MAAM,YAAY,QAAS,MAAM,YAAY,MAAM,WAAW,MAAM,GAAG,UAAU,oHAQpF,CAAA;AAEJ,oEAAoE;AACpE,eAAO,MAAM,aAAa,QAAS,MAAM,YAAY,MAAM,oHAIvD,CAAA"}
|
package/dist/Files.js
ADDED
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The app's files as the CLI touches them: target paths normalised and kept inside the app, writes and
|
|
3
|
+
* deletes refused through symbolic links, and contents read as bytes (text only when they are valid UTF-8).
|
|
4
|
+
*/
|
|
5
|
+
import { Effect, FileSystem, Option, Path } from "effect";
|
|
6
|
+
import { CliError } from "./Errors.js";
|
|
7
|
+
/**
|
|
8
|
+
* Normalise a target path relative to the app (`./src/a`, `src//a` and `src\a` are `src/a`), or `undefined`
|
|
9
|
+
* if it is absolute, empty or leaves the app (`..`).
|
|
10
|
+
*/
|
|
11
|
+
export const normaliseTarget = (target) => {
|
|
12
|
+
if (target.startsWith("/") || target.startsWith("\\") || /^[a-zA-Z]:/.test(target))
|
|
13
|
+
return undefined;
|
|
14
|
+
const segments = target.split(/[\\/]/).filter((segment) => segment !== "" && segment !== ".");
|
|
15
|
+
if (segments.length === 0 || segments.includes(".."))
|
|
16
|
+
return undefined;
|
|
17
|
+
return segments.join("/");
|
|
18
|
+
};
|
|
19
|
+
const checked = (relative) => Effect.gen(function* () {
|
|
20
|
+
const normal = normaliseTarget(relative);
|
|
21
|
+
if (normal === undefined)
|
|
22
|
+
return yield* new CliError({ message: `${relative} is outside the app` });
|
|
23
|
+
return normal;
|
|
24
|
+
});
|
|
25
|
+
/** The absolute path of a file of the app, for reading: the path must stay inside the app. */
|
|
26
|
+
export const appPath = (dir, relative) => Effect.gen(function* () {
|
|
27
|
+
const path = yield* Path.Path;
|
|
28
|
+
return path.join(dir, yield* checked(relative));
|
|
29
|
+
});
|
|
30
|
+
/**
|
|
31
|
+
* The one rule for every path the CLI writes or deletes (add, update, eject, restore, clean, generate, mcp): the
|
|
32
|
+
* absolute path of `relative` inside the app, after checking, before anything is touched, that
|
|
33
|
+
*
|
|
34
|
+
* - every ancestor below the app directory that exists is a real directory, not a symbolic link (even a dangling
|
|
35
|
+
* one) nor a file, so nothing is written or deleted through a link;
|
|
36
|
+
* - the path itself is not a symbolic link (`"write"`), or, when it is to be deleted (`"remove"`), may be one: the
|
|
37
|
+
* link is deleted, never what it points at;
|
|
38
|
+
* - resolved (`realpath` of its deepest existing ancestor, with the rest appended), it lies inside the resolved app
|
|
39
|
+
* directory.
|
|
40
|
+
*
|
|
41
|
+
* The returned path is under the resolved app directory.
|
|
42
|
+
*/
|
|
43
|
+
export const safeAppPath = (dir, relative, mode) => Effect.gen(function* () {
|
|
44
|
+
const fs = yield* FileSystem.FileSystem;
|
|
45
|
+
const path = yield* Path.Path;
|
|
46
|
+
const normal = yield* checked(relative);
|
|
47
|
+
const verb = mode === "write" ? "write" : "delete";
|
|
48
|
+
const root = yield* fs
|
|
49
|
+
.realPath(dir)
|
|
50
|
+
.pipe(Effect.mapError(() => new CliError({ message: `Cannot resolve the app directory ${dir}` })));
|
|
51
|
+
const segments = normal.split("/");
|
|
52
|
+
let current = root;
|
|
53
|
+
let walked = "";
|
|
54
|
+
let deepestExisting = root;
|
|
55
|
+
for (const [index, segment] of segments.entries()) {
|
|
56
|
+
current = path.join(current, segment);
|
|
57
|
+
walked = walked === "" ? segment : `${walked}/${segment}`;
|
|
58
|
+
const info = yield* fs.lstat(current).pipe(Effect.option);
|
|
59
|
+
if (Option.isNone(info))
|
|
60
|
+
break;
|
|
61
|
+
const last = index === segments.length - 1;
|
|
62
|
+
if (info.value.type === "SymbolicLink" && !(last && mode === "remove")) {
|
|
63
|
+
return yield* new CliError({
|
|
64
|
+
message: `Refusing to ${verb} ${normal}: ${walked} is a symbolic link, and going through it could leave the app`,
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
if (!last && info.value.type !== "Directory") {
|
|
68
|
+
return yield* new CliError({ message: `Refusing to ${verb} ${normal}: ${walked} is not a directory` });
|
|
69
|
+
}
|
|
70
|
+
if (!last || info.value.type !== "SymbolicLink")
|
|
71
|
+
deepestExisting = current;
|
|
72
|
+
}
|
|
73
|
+
// Resolved, the path must still be inside the resolved app directory.
|
|
74
|
+
const resolvedBase = yield* fs
|
|
75
|
+
.realPath(deepestExisting)
|
|
76
|
+
.pipe(Effect.mapError(() => new CliError({ message: `Cannot resolve ${normal} in the app` })));
|
|
77
|
+
const rest = path.relative(deepestExisting, path.join(root, normal));
|
|
78
|
+
const resolved = rest === "" ? resolvedBase : path.join(resolvedBase, rest);
|
|
79
|
+
const inside = path.relative(root, resolved);
|
|
80
|
+
if (inside === "" || inside.startsWith("..") || path.isAbsolute(inside)) {
|
|
81
|
+
return yield* new CliError({ message: `Refusing to ${verb} ${normal}: it resolves outside the app` });
|
|
82
|
+
}
|
|
83
|
+
return path.join(root, normal);
|
|
84
|
+
});
|
|
85
|
+
/** The absolute path of a file of the app, for writing or deleting a file (`safeAppPath`'s `"write"` rule). */
|
|
86
|
+
export const writablePath = (dir, relative) => safeAppPath(dir, relative, "write");
|
|
87
|
+
/** Read a file of the app as bytes, or `undefined` if it does not exist. */
|
|
88
|
+
export const readAppBytes = (dir, relative) => Effect.gen(function* () {
|
|
89
|
+
const fs = yield* FileSystem.FileSystem;
|
|
90
|
+
const file = yield* appPath(dir, relative);
|
|
91
|
+
if (!(yield* fs.exists(file)))
|
|
92
|
+
return undefined;
|
|
93
|
+
return yield* fs.readFile(file);
|
|
94
|
+
});
|
|
95
|
+
const decoder = new TextDecoder("utf-8", { fatal: true, ignoreBOM: true });
|
|
96
|
+
const encoder = new TextEncoder();
|
|
97
|
+
/** Whether `text` can be line-merged: no NUL. */
|
|
98
|
+
export const isMergeableText = (text) => !text.includes("\u0000");
|
|
99
|
+
/**
|
|
100
|
+
* The bytes as text when they are valid UTF-8 that round-trips exactly and hold no NUL; otherwise
|
|
101
|
+
* `undefined` (binary: compared byte for byte, never line-merged).
|
|
102
|
+
*/
|
|
103
|
+
export const asText = (bytes) => {
|
|
104
|
+
let text;
|
|
105
|
+
try {
|
|
106
|
+
text = decoder.decode(bytes);
|
|
107
|
+
}
|
|
108
|
+
catch {
|
|
109
|
+
return undefined;
|
|
110
|
+
}
|
|
111
|
+
if (!isMergeableText(text) || !sameBytes(encoder.encode(text), bytes))
|
|
112
|
+
return undefined;
|
|
113
|
+
return text;
|
|
114
|
+
};
|
|
115
|
+
export const sameBytes = (a, b) => {
|
|
116
|
+
if (a.length !== b.length)
|
|
117
|
+
return false;
|
|
118
|
+
for (let i = 0; i < a.length; i++)
|
|
119
|
+
if (a[i] !== b[i])
|
|
120
|
+
return false;
|
|
121
|
+
return true;
|
|
122
|
+
};
|
|
123
|
+
/** Whether the app's bytes are exactly `text` encoded as UTF-8. */
|
|
124
|
+
export const bytesEqualText = (bytes, text) => sameBytes(bytes, encoder.encode(text));
|
|
125
|
+
export const sha256Bytes = (bytes) => Effect.promise(async () => {
|
|
126
|
+
const digest = await crypto.subtle.digest("SHA-256", bytes);
|
|
127
|
+
return [...new Uint8Array(digest)].map((b) => b.toString(16).padStart(2, "0")).join("");
|
|
128
|
+
});
|
|
129
|
+
/** Write `content` to a file of the app (creating its directory), refusing symbolic links on the way. */
|
|
130
|
+
export const writeAppFile = (dir, relative, content) => Effect.gen(function* () {
|
|
131
|
+
const fs = yield* FileSystem.FileSystem;
|
|
132
|
+
const path = yield* Path.Path;
|
|
133
|
+
const destination = yield* writablePath(dir, relative);
|
|
134
|
+
yield* fs.makeDirectory(path.dirname(destination), { recursive: true });
|
|
135
|
+
if (typeof content === "string")
|
|
136
|
+
yield* fs.writeFileString(destination, content);
|
|
137
|
+
else
|
|
138
|
+
yield* fs.writeFile(destination, content);
|
|
139
|
+
});
|
|
140
|
+
/** Delete a file of the app, refusing symbolic links on the way. */
|
|
141
|
+
export const removeAppFile = (dir, relative) => Effect.gen(function* () {
|
|
142
|
+
const fs = yield* FileSystem.FileSystem;
|
|
143
|
+
yield* fs.remove(yield* writablePath(dir, relative));
|
|
144
|
+
});
|
|
145
|
+
//# sourceMappingURL=Files.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Files.js","sourceRoot":"","sources":["../src/Files.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAA;AACzD,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AAEtC;;;GAGG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,MAAc,EAAsB,EAAE;IACpE,IAAI,MAAM,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,YAAY,CAAC,IAAI,CAAC,MAAM,CAAC;QAAE,OAAO,SAAS,CAAA;IACpG,MAAM,QAAQ,GAAG,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,KAAK,EAAE,IAAI,OAAO,KAAK,GAAG,CAAC,CAAA;IAC7F,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC,IAAI,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC;QAAE,OAAO,SAAS,CAAA;IACtE,OAAO,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;A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GAAG,KAAK,CAAC,CAAC,UAAU,CAAC,UAAU,CAAA;IACvC,MAAM,IAAI,GAAG,KAAK,CAAC,CAAC,IAAI,CAAC,IAAI,CAAA;IAC7B,MAAM,WAAW,GAAG,KAAK,CAAC,CAAC,YAAY,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAA;IACtD,KAAK,CAAC,CAAC,EAAE,CAAC,aAAa,CAAC,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAA;IACvE,IAAI,OAAO,OAAO,KAAK,QAAQ;QAAE,KAAK,CAAC,CAAC,EAAE,CAAC,eAAe,CAAC,WAAW,EAAE,OAAO,CAAC,CAAA;;QAC3E,KAAK,CAAC,CAAC,EAAE,CAAC,SAAS,CAAC,WAAW,EAAE,OAAO,CAAC,CAAA;AAChD,CAAC,CAAC,CAAA;AAEJ,oEAAoE;AACpE,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,GAAW,EAAE,QAAgB,EAAE,EAAE,CAC7D,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC;IAClB,MAAM,EAAE,GAAG,KAAK,CAAC,CAAC,UAAU,CAAC,UAAU,CAAA;IACvC,KAAK,CAAC,CAAC,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,YAAY,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC,CAAA;AACtD,CAAC,CAAC,CAAA"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import type { EloxivMeta } from "./Registry.ts";
|
|
2
|
+
export interface InstalledModule {
|
|
3
|
+
readonly name: string;
|
|
4
|
+
readonly meta: EloxivMeta;
|
|
5
|
+
}
|
|
6
|
+
/** An installed connector item (kind `connector`): its `server` export is a `ConnectorDefinition`. */
|
|
7
|
+
export interface InstalledConnector {
|
|
8
|
+
readonly name: string;
|
|
9
|
+
readonly meta: EloxivMeta;
|
|
10
|
+
}
|
|
11
|
+
/** Any other installed item (a UI item) that asks for kernel-provided modules (`meta.kernelModules`). */
|
|
12
|
+
export interface InstalledItem {
|
|
13
|
+
readonly name: string;
|
|
14
|
+
readonly meta: EloxivMeta;
|
|
15
|
+
}
|
|
16
|
+
declare const KERNEL_ORDER: readonly ["inbox", "sharing", "connections", "search", "agent", "spaces", "devices"];
|
|
17
|
+
type KernelModule = (typeof KERNEL_ORDER)[number];
|
|
18
|
+
/** An installed skill item (kind `skill`): its `server` export is an `AppSkill` (`defineAppSkill`). */
|
|
19
|
+
export interface InstalledSkill {
|
|
20
|
+
readonly name: string;
|
|
21
|
+
readonly meta: EloxivMeta;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Whether a connector item provides kernel Connections (its `server` export is a `ConnectorDefinition`, composed into
|
|
25
|
+
* `KernelApp.connectors`). A model connector (one that provides `ModelProvider`) is not: the app adds it to
|
|
26
|
+
* `KernelApp.agent.providers` itself, as its `next` steps say.
|
|
27
|
+
*/
|
|
28
|
+
export declare const isConnectionConnector: (meta: EloxivMeta) => boolean;
|
|
29
|
+
/** Whether a connector item is a model connector: its `server` export makes a ModelProvider (`ModelProviderFactory`). */
|
|
30
|
+
export declare const isModelConnector: (meta: EloxivMeta) => boolean;
|
|
31
|
+
/**
|
|
32
|
+
* The kernel-provided modules the installed modules and UI items ask for, each once and in dependency order:
|
|
33
|
+
* sharing and the agent need the inbox (access requests reach managers as work items; an agent's consent-marked
|
|
34
|
+
* calls wait in it), and connectors need the connections module.
|
|
35
|
+
*/
|
|
36
|
+
export declare const kernelModulesFor: (modules: ReadonlyArray<InstalledModule>, connectors: ReadonlyArray<InstalledConnector>, requesting?: ReadonlyArray<InstalledItem>) => ReadonlyArray<KernelModule>;
|
|
37
|
+
export declare const identifier: (name: string) => string;
|
|
38
|
+
export declare const modulesFile: (modules: ReadonlyArray<InstalledModule>) => string;
|
|
39
|
+
export declare const serverFile: (modules: ReadonlyArray<InstalledModule>, connectors?: ReadonlyArray<InstalledConnector>, skills?: ReadonlyArray<InstalledSkill>, requesting?: ReadonlyArray<InstalledItem>, models?: ReadonlyArray<InstalledConnector>) => string;
|
|
40
|
+
/** Where a module's generated sync tables live: its `sync.tables`, else `sync.gen.ts` beside its queries. */
|
|
41
|
+
export declare const syncTablesFile: (meta: EloxivMeta) => string | undefined;
|
|
42
|
+
/**
|
|
43
|
+
* Where a synced module's generated files are, relative to the app, for generation and composition alike: its tables
|
|
44
|
+
* (`syncTablesFile`), its `predictions.ts` beside them, and its separate mutators file, `sync.mutators` or
|
|
45
|
+
* `mutators.gen.ts` beside the tables (older metadata names none). The mutators file exists exactly when generation
|
|
46
|
+
* puts the module's mutators apart (`moduleSyncTables`): always with a custom prediction.
|
|
47
|
+
*/
|
|
48
|
+
export declare const syncLayout: (meta: EloxivMeta) => {
|
|
49
|
+
tables: string;
|
|
50
|
+
predictions: string;
|
|
51
|
+
mutators: string;
|
|
52
|
+
} | undefined;
|
|
53
|
+
/**
|
|
54
|
+
* The app's sync schema and named queries (`eloxiv.schema.ts`): what the server imports. It never loads a module's
|
|
55
|
+
* mutators, so a module's predictions (client code, which may need a browser) never run in a server.
|
|
56
|
+
*/
|
|
57
|
+
export declare const schemaFile: (modules: ReadonlyArray<InstalledModule>, connectors?: ReadonlyArray<InstalledConnector>, requesting?: ReadonlyArray<InstalledItem>) => string;
|
|
58
|
+
/**
|
|
59
|
+
* The app's sync schema, named queries and mutators (`eloxiv.sync.ts`): what a client imports. The schema and queries
|
|
60
|
+
* are `eloxiv.schema.ts`'s; a module's mutators come from its separate mutators file (`syncLayout`) when it has one
|
|
61
|
+
* (`separate`: the app's composition asks whether that file exists, since generation writes it exactly when it puts
|
|
62
|
+
* them apart; without it, whether the metadata names one), else from its `sync.gen.ts`.
|
|
63
|
+
*/
|
|
64
|
+
export declare const syncFile: (modules: ReadonlyArray<InstalledModule>, separate?: (module: InstalledModule) => boolean) => string;
|
|
65
|
+
/**
|
|
66
|
+
* Each installed module's generated sync tables: `[file, source]` for every module with sync, from its
|
|
67
|
+
* contract's entities, and its separate mutators file (`syncLayout`) when its mutators go apart: with a custom
|
|
68
|
+
* prediction, whatever its metadata says, or when its metadata names that file. The contract is imported (with its
|
|
69
|
+
* Drizzle tables) from the app, so the app's dependencies must be installed. Runs on Bun and Node.
|
|
70
|
+
*/
|
|
71
|
+
export declare const moduleSyncTables: (dir: string, modules: ReadonlyArray<InstalledModule>) => Promise<ReadonlyArray<readonly [string, string]>>;
|
|
72
|
+
/**
|
|
73
|
+
* The separate mutators files generation no longer writes: a module's generated one (its header says so) whose
|
|
74
|
+
* mutators went back into `sync.gen.ts`, or that has none left. `eloxiv generate` removes them, so the composition,
|
|
75
|
+
* which imports a module's mutators file when it exists, never imports a stale one. Relative to the app.
|
|
76
|
+
*/
|
|
77
|
+
export declare const staleMutatorsFiles: (dir: string, modules: ReadonlyArray<InstalledModule>, generated: ReadonlyArray<readonly [string, string]>) => ReadonlyArray<string>;
|
|
78
|
+
export declare const compositionFiles: (modules: ReadonlyArray<InstalledModule>, connectors?: ReadonlyArray<InstalledConnector>, skills?: ReadonlyArray<InstalledSkill>, requesting?: ReadonlyArray<InstalledItem>, models?: ReadonlyArray<InstalledConnector>, separate?: (module: InstalledModule) => boolean) => ReadonlyArray<readonly [string, string]>;
|
|
79
|
+
export {};
|
|
80
|
+
//# sourceMappingURL=Generate.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Generate.d.ts","sourceRoot":"","sources":["../src/Generate.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAG/C,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAA;CAC1B;AAED,sGAAsG;AACtG,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAA;CAC1B;AA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