@codeworksh/schema 0.0.0 → 0.1.0-canary.165.2.g336229f9
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 +48 -0
- package/common.d.mts +86 -0
- package/common.mjs +88 -0
- package/common.mjs.map +1 -0
- package/daemon.d.mts +12 -0
- package/daemon.mjs +22 -0
- package/daemon.mjs.map +1 -0
- package/door.d.mts +33 -0
- package/door.mjs +52 -0
- package/door.mjs.map +1 -0
- package/event.d.mts +79 -0
- package/event.mjs +35 -0
- package/event.mjs.map +1 -0
- package/forwarded.d.mts +13 -0
- package/forwarded.mjs +25 -0
- package/forwarded.mjs.map +1 -0
- package/host/envelope.d.mts +36 -0
- package/host/envelope.mjs +35 -0
- package/host/envelope.mjs.map +1 -0
- package/host/part.d.mts +2 -0
- package/host/part.mjs +60 -0
- package/host/part.mjs.map +1 -0
- package/host/principal.d.mts +36 -0
- package/host/principal.mjs +24 -0
- package/host/principal.mjs.map +1 -0
- package/host/records.d.mts +1051 -0
- package/host/records.mjs +494 -0
- package/host/records.mjs.map +1 -0
- package/host.d.mts +2224 -0
- package/host.mjs +812 -0
- package/host.mjs.map +1 -0
- package/ids.d.mts +53 -0
- package/ids.mjs +60 -0
- package/ids.mjs.map +1 -0
- package/jws.d.mts +84 -0
- package/jws.mjs +119 -0
- package/jws.mjs.map +1 -0
- package/location.d.mts +55 -0
- package/location.mjs +51 -0
- package/location.mjs.map +1 -0
- package/machine.d.mts +77 -0
- package/machine.mjs +48 -0
- package/machine.mjs.map +1 -0
- package/mcp.d.mts +24 -0
- package/mcp.mjs +36 -0
- package/mcp.mjs.map +1 -0
- package/model.d.mts +18 -0
- package/model.mjs +35 -0
- package/model.mjs.map +1 -0
- package/package.json +181 -4
- package/pairing.d.mts +67 -0
- package/pairing.mjs +67 -0
- package/pairing.mjs.map +1 -0
- package/part-Bzm-yNax.d.mts +69 -0
- package/project.d.mts +30 -0
- package/project.mjs +27 -0
- package/project.mjs.map +1 -0
- package/records-316ZUpKX.mjs +127 -0
- package/records-316ZUpKX.mjs.map +1 -0
- package/relay.d.mts +285 -0
- package/relay.mjs +115 -0
- package/relay.mjs.map +1 -0
- package/repo.d.mts +42 -0
- package/repo.mjs +46 -0
- package/repo.mjs.map +1 -0
- package/rolldown-runtime-D7D4PA-g.mjs +13 -0
- package/sandbox/driver.d.mts +10 -0
- package/sandbox/driver.mjs +13 -0
- package/sandbox/driver.mjs.map +1 -0
- package/sandbox/errors.d.mts +130 -0
- package/sandbox/errors.mjs +112 -0
- package/sandbox/errors.mjs.map +1 -0
- package/sandbox/instance.d.mts +152 -0
- package/sandbox/instance.mjs +150 -0
- package/sandbox/instance.mjs.map +1 -0
- package/session.d.mts +59 -0
- package/session.mjs +69 -0
- package/session.mjs.map +1 -0
- package/settings.d.mts +22 -0
- package/settings.mjs +32 -0
- package/settings.mjs.map +1 -0
- package/shell.d.mts +5 -0
- package/shell.mjs +7 -0
- package/shell.mjs.map +1 -0
- package/space-CR-9UxdT.d.mts +25 -0
- package/space.d.mts +2 -0
- package/space.mjs +33 -0
- package/space.mjs.map +1 -0
- package/thread.d.mts +50 -0
- package/thread.mjs +69 -0
- package/thread.mjs.map +1 -0
- package/usage-B_TDmpKC.d.mts +15 -0
- package/usage.d.mts +2 -0
- package/usage.mjs +43 -0
- package/usage.mjs.map +1 -0
package/host.mjs.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"host.mjs","names":["SandboxInstance.Selection","Machine.Status","Machine.Disconnect","Machine.Disconnected","Machine.ConnectError","Machine.ConnectEvent","SandboxInstance.ID"],"sources":["../../src/host.ts"],"sourcesContent":["import { Schema } from \"effect\";\nimport { Rpc, RpcGroup } from \"effect/rpc\";\nimport { AbsolutePath, optional } from \"./common.ts\";\nimport { DaemonCallError } from \"./daemon.ts\";\nimport { SubscriptionOverflowError } from \"./event.ts\";\nimport { EncodingError, EventEnvelope } from \"./host/envelope.ts\";\nimport { Door, Forbidden } from \"./host/principal.ts\";\nimport {\n\tClone,\n\tDeviceInfo,\n\tFolder,\n\tHistoryEntry,\n\tHostError,\n\tIndexItem,\n\tLogSynced,\n\tModelList,\n\tOAuthCredentials,\n\tOAuthError,\n\tOAuthInfo,\n\tOAuthProvider,\n\tQueuedPrompt,\n\tRepository,\n\tRuntimeConfig,\n\tSandboxInfo,\n\tSessionInfo,\n\tThreadInfo,\n\tThreadItem,\n\tUsageItem,\n} from \"./host/records.ts\";\nimport { MessageID, SessionID, ThreadID } from \"./ids.ts\";\nimport { DirectoryNotFoundError, NotDirectoryError } from \"./location.ts\";\nimport { Machine } from \"./machine.ts\";\nimport { McpSkipped, McpState, UnknownServerError } from \"./mcp.ts\";\nimport { ModelCatalogError } from \"./model.ts\";\nimport { ProjectCheckoutError, ProjectNotFoundError } from \"./project.ts\";\nimport {\n\tSandboxBusyError,\n\tSandboxDriverNotRegisteredError,\n\tSandboxDriverRegistrationError,\n\tSandboxNotFoundError,\n\tSandboxProviderError,\n\tSandboxRemovedError,\n\tSandboxTransitionConflictError,\n\tSandboxUnavailError,\n\tSandboxUnsupportedError,\n} from \"./sandbox/errors.ts\";\nimport { SandboxInstance } from \"./sandbox/instance.ts\";\nimport {\n\tDelivery,\n\tPromptConflictError,\n\tRelinkError,\n\tSessionLinkedSpaceNotFoundError,\n\tSessionNotFoundError,\n} from \"./session.ts\";\nimport { SettingsConflictError, SettingsError } from \"./settings.ts\";\nimport { ForkError, ThreadNotFoundError } from \"./thread.ts\";\n\n/*\n * The contract of a CodeWork RPC server (`codework serve`): what the CLI, the desktop app's server\n * and widget backends call. The server implements it in packages/codework.\n */\n\n/** The HTTP path the RPC endpoint is served on; the version moves with breaking wire changes. */\nexport const path = \"/rpc/v1\";\n\n/** A thread of a session: `threadId`, or the session's `main` thread when absent. */\nconst ThreadRef = {\n\tsessionId: SessionID,\n\tthreadId: optional(ThreadID),\n};\n\n/** A thread's MCP server, by the name its `mcp.json` gives it. */\nconst McpServerRef = { ...ThreadRef, server: Schema.String };\n\nconst SandboxRef = SandboxInstance.Selection;\n\n/** A project's name as a client sets it: trimmed, never empty. */\nconst ProjectName = Schema.Trimmed.check(Schema.isNonEmpty());\n\nconst SessionErrors = Schema.Union([\n\tSessionNotFoundError,\n\tThreadNotFoundError,\n\tSessionLinkedSpaceNotFoundError,\n\tRelinkError,\n]);\n\nconst ThreadErrors = Schema.Union([SessionNotFoundError, ThreadNotFoundError]);\n\n// Every lifecycle error the sandbox control plane can raise; narrowing per\n// endpoint would misreport what `withMount` and `stop` actually fail with.\nconst SandboxErrors = Schema.Union([\n\tSandboxNotFoundError,\n\tSandboxDriverNotRegisteredError,\n\tSandboxDriverRegistrationError,\n\tSandboxUnsupportedError,\n\tSandboxProviderError,\n\tSandboxUnavailError,\n\tSandboxRemovedError,\n\tSandboxTransitionConflictError,\n\tSandboxBusyError,\n]);\n\nconst LocationErrors = Schema.Union([DirectoryNotFoundError, NotDirectoryError]);\n\n/** One of a thread's MCP servers as that thread sees it. */\nconst McpStatus = Schema.Struct({\n\tserver: Schema.String,\n\tstate: McpState,\n\terror: optional(Schema.String),\n\t/** Tools the server offered when last listed, each with its exposure in the thread. */\n\ttools: Schema.Array(\n\t\tSchema.Struct({ name: Schema.String, exposure: Schema.Literals([\"direct\", \"codemode\", \"deferred\", \"hidden\"]) }),\n\t),\n\tresources: Schema.Boolean,\n\t/** Tools it listed last that were left out because the MCP SDK rejects them; absent when none were. */\n\tskipped: optional(McpSkipped),\n});\nexport type McpStatus = typeof McpStatus.Type;\n\nconst McpErrors = Schema.Union([ThreadErrors, UnknownServerError]);\n\nconst SettingsFileRef = { projectId: optional(Schema.String), file: Schema.Literals([\"settings\", \"mcp\"]) };\n/** The settings a project's `settings.jsonc` falls back to, as the page shows them. */\nconst Inherited = Schema.Struct({\n\tretry: Schema.Struct({ maxRetries: Schema.Int, baseDelayMs: Schema.Int, maxDelayMs: Schema.Int }),\n});\nconst SettingsFileErrors = Schema.Union([SettingsError, ProjectNotFoundError, ProjectCheckoutError]);\n\nexport const Api = RpcGroup.make(\n\t/**\n\t * The server's own identity: the process and build a client is talking to.\n\t *\n\t * The health probe: a discovery registration names a pid and version, and a\n\t * caller confirms the process answering is the one that registered before it\n\t * trusts the endpoint. Like every other capability it rides the RPC channel,\n\t * so there is no separate HTTP surface to keep in step.\n\t */\n\tRpc.make(\"server.info\", {\n\t\tpayload: {},\n\t\tsuccess: Schema.Struct({\n\t\t\tpid: Schema.Int,\n\t\t\tversion: Schema.String,\n\t\t\t/** The harness store this server serves; a sync cursor is only valid against it. */\n\t\t\tstoreId: Schema.String,\n\t\t\t/** The store's head: the last revision taken. */\n\t\t\trev: Schema.Int,\n\t\t\t/** The machine it runs on, by the name its user knows it; absent when the OS names it nothing. */\n\t\t\thost: optional(Schema.Struct({ name: Schema.String })),\n\t\t\t/** The id in the home's `machine.json`; absent until the home has one. */\n\t\t\tmachineId: optional(Schema.String),\n\t\t}),\n\t}),\n\t/**\n\t * The index of this machine: every project, space, session and thread whose revision is past\n\t * `after`, in revision order, then `Synced` at the head read when the call began; then the same\n\t * live after each commit. `after: 0` reads the whole index. A row written again moves to a later\n\t * revision and is sent again; the latest wins. A deleted session arrives as `Removed`. `boot` is\n\t * the one the last `Synced` carried: when the store left that line (a restored backup), it reads\n\t * from zero instead.\n\t */\n\tRpc.make(\"index.sync\", {\n\t\tpayload: { after: Schema.Int, boot: optional(Schema.String) },\n\t\tsuccess: IndexItem,\n\t\tstream: true,\n\t}),\n\t/**\n\t * The usage rollup of this machine: every `usage` and `tally` row whose revision is past `after`,\n\t * in revision order, then `Synced` at the head read when the call began; then the same live after\n\t * each commit. `after: 0` reads every row. A row written again moves to a later revision and is\n\t * sent again in full; the latest wins. Rows carry running totals, not deltas: a client replaces a\n\t * row by its key, never adds to it. A deleted session's rows stay. `boot` is the one the last\n\t * `Synced` carried: when the store left that line (a restored backup), it reads from zero instead.\n\t */\n\tRpc.make(\"usage.sync\", {\n\t\tpayload: { after: Schema.Int, boot: optional(Schema.String) },\n\t\tsuccess: UsageItem,\n\t\tstream: true,\n\t}),\n\tRpc.make(\"auth.save\", {\n\t\tpayload: { credentials: OAuthCredentials },\n\t\tsuccess: OAuthInfo,\n\t\terror: OAuthError,\n\t}),\n\tRpc.make(\"auth.status\", {\n\t\tpayload: { provider: OAuthProvider },\n\t\tsuccess: Schema.NullOr(OAuthInfo),\n\t\terror: OAuthError,\n\t}),\n\tRpc.make(\"auth.refresh\", {\n\t\tpayload: { provider: OAuthProvider },\n\t\tsuccess: Schema.NullOr(OAuthInfo),\n\t\terror: OAuthError,\n\t}),\n\tRpc.make(\"auth.logout\", {\n\t\tpayload: { provider: OAuthProvider },\n\t\tsuccess: Schema.Void,\n\t\terror: OAuthError,\n\t}),\n\t/** A session and its `main` thread; the main thread's info, with the session embedded. */\n\tRpc.make(\"session.create\", {\n\t\tpayload: {\n\t\t\t/** The main thread's title; absent = its first prompt names it. */\n\t\t\ttitle: optional(Schema.String),\n\t\t\tdirectory: optional(Schema.String),\n\t\t\t/**\n\t\t\t * The host directory this session is anchored to, usually the caller's project root.\n\t\t\t * Unrelated to `directory`, which names a place inside the session's space.\n\t\t\t *\n\t\t\t * It is an anchor and nothing more: whatever needs a host-side directory resolves from\n\t\t\t * here rather than from wherever the server happens to be running. What reads it is the\n\t\t\t * reader's business, not this field's.\n\t\t\t *\n\t\t\t * Optional and honoured as given. Omitting it is normal, not a failure.\n\t\t\t */\n\t\t\thostDir: optional(AbsolutePath),\n\t\t\tsandbox: optional(SandboxRef),\n\t\t\truntime: optional(RuntimeConfig),\n\t\t\t/**\n\t\t\t * Names the project when this session creates it, ahead of the repository's and the\n\t\t\t * folder's name. A project that already exists keeps its name; `project.rename` changes it.\n\t\t\t */\n\t\t\tproject: optional(Schema.Struct({ name: ProjectName })),\n\t\t},\n\t\tsuccess: ThreadInfo,\n\t\t/** `HostError` when `hostDir` is a clone still running, failed or cancelled. */\n\t\terror: Schema.Union([SessionErrors, SandboxErrors, LocationErrors, HostError]),\n\t}),\n\t/** The `origin` URL of a project's main checkout on the host, credentials taken out; null when there is none. */\n\tRpc.make(\"project.remote\", {\n\t\tpayload: { projectId: Schema.String },\n\t\tsuccess: Schema.Struct({ url: Schema.NullOr(Schema.String) }),\n\t\terror: ProjectNotFoundError,\n\t}),\n\tRpc.make(\"project.rename\", {\n\t\tpayload: { projectId: Schema.String, name: ProjectName },\n\t\tsuccess: Schema.Struct({ id: Schema.String, name: Schema.String }),\n\t\terror: ProjectNotFoundError,\n\t}),\n\t/**\n\t * A settings file as written: the project's when `projectId` is given -- the one sessions in its\n\t * main checkout read -- otherwise the user's. `version` is what `settings.write` is held to;\n\t * `error` is what the runtime would reject in the file as it stands.\n\t */\n\tRpc.make(\"settings.read\", {\n\t\tpayload: SettingsFileRef,\n\t\tsuccess: Schema.Struct({\n\t\t\tpath: Schema.String,\n\t\t\tsource: Schema.String,\n\t\t\texists: Schema.Boolean,\n\t\t\tversion: Schema.String,\n\t\t\t/** The file's JSONC as a value; absent when it does not parse. */\n\t\t\tvalue: optional(Schema.Unknown),\n\t\t\terror: optional(Schema.String),\n\t\t\t/**\n\t\t\t * For `settings.jsonc`: what applies where this file sets nothing -- the user's settings over the\n\t\t\t * defaults for a project's file, the defaults for the user's. Absent when a lower file is broken.\n\t\t\t */\n\t\t\tinherited: optional(Inherited),\n\t\t\t/**\n\t\t\t * For `mcp.json`: the servers as sessions use them, user and project merged; entries the runtime\n\t\t\t * skips are left out. `from` is the file that defines the server, not one that only overrides it.\n\t\t\t */\n\t\t\tservers: optional(\n\t\t\t\tSchema.Array(\n\t\t\t\t\tSchema.Struct({\n\t\t\t\t\t\tname: Schema.String,\n\t\t\t\t\t\tfrom: Schema.Literals([\"user\", \"project\"]),\n\t\t\t\t\t\tenabled: Schema.Boolean,\n\t\t\t\t\t}),\n\t\t\t\t),\n\t\t\t),\n\t\t}),\n\t\terror: SettingsFileErrors,\n\t}),\n\t/** The whole file, written only when it is still at `version` and the runtime would accept it. */\n\tRpc.make(\"settings.write\", {\n\t\tpayload: { ...SettingsFileRef, source: Schema.String, version: Schema.String },\n\t\tsuccess: Schema.Struct({ version: Schema.String }),\n\t\terror: Schema.Union([SettingsFileErrors, SettingsConflictError]),\n\t}),\n\t/**\n\t * One value at `at` set in place, keeping the rest of the file as written; no `value` removes it.\n\t * Refused when the result would not be accepted.\n\t */\n\tRpc.make(\"settings.set\", {\n\t\tpayload: {\n\t\t\t...SettingsFileRef,\n\t\t\tat: Schema.NonEmptyArray(Schema.Union([Schema.String, Schema.Int])),\n\t\t\tvalue: optional(Schema.Unknown),\n\t\t},\n\t\tsuccess: Schema.Struct({ version: Schema.String }),\n\t\terror: SettingsFileErrors,\n\t}),\n\t/**\n\t * The models a session anchored at `hostDir` can use: providers this server holds credentials\n\t * for, in the catalog plus that project's settings, and the model a session runs when it names\n\t * none: the one settings name, else one picked from those providers. `default` is absent when\n\t * neither gives one. Without `hostDir`, only the user's settings apply. Credentials are checked\n\t * for presence, not validity.\n\t */\n\tRpc.make(\"model.list\", {\n\t\tpayload: { hostDir: optional(AbsolutePath) },\n\t\tsuccess: ModelList,\n\t\terror: Schema.Union([SettingsError, ModelCatalogError]),\n\t}),\n\t/**\n\t * Point an existing session at a host directory, or clear it with `null`.\n\t *\n\t * Not `session.relink`: that moves where the *work* happens, this changes which host directory\n\t * the session is *anchored to*. Conflating them would recreate exactly the `cwd`/`hostDir`\n\t * confusion the split exists to remove, which is why they sound alike and stay apart.\n\t */\n\tRpc.make(\"session.link\", {\n\t\tpayload: {\n\t\t\tsessionId: SessionID,\n\t\t\t/** Absent clears the anchor, leaving the session with no host directory. */\n\t\t\thostDir: optional(AbsolutePath),\n\t\t},\n\t\tsuccess: SessionInfo,\n\t\terror: SessionNotFoundError,\n\t}),\n\t/**\n\t * Moves where the work happens. Without `threadId`, the session's default space and directory,\n\t * which every thread without its own placement follows; with it, that thread's placement only.\n\t * Answers with the addressed thread (`main` when absent): its `placement` and embedded session\n\t * show where it now runs.\n\t */\n\tRpc.make(\"session.relink\", {\n\t\tpayload: {\n\t\t\tsessionId: SessionID,\n\t\t\tthreadId: optional(ThreadID),\n\t\t\tsandbox: optional(SandboxRef),\n\t\t\tdirectory: optional(Schema.String),\n\t\t},\n\t\tsuccess: ThreadInfo,\n\t\terror: Schema.Union([SessionErrors, SandboxErrors, LocationErrors]),\n\t}),\n\t/** Stops every thread, then removes the session with its log. `deleted` is false when it did not exist. */\n\tRpc.make(\"session.delete\", {\n\t\tpayload: { sessionId: SessionID },\n\t\tsuccess: Schema.Struct({ deleted: Schema.Boolean }),\n\t}),\n\t/** Interrupts every running thread of the session. */\n\tRpc.make(\"session.interrupt\", {\n\t\tpayload: { sessionId: SessionID },\n\t\tsuccess: Schema.Struct({ interrupted: Schema.Boolean }),\n\t}),\n\t/**\n\t * A session's durable events after `after` (exclusive; omitted reads from the start), then a\n\t * `log.synced` marker at the head read when the call began. With `follow`, each event then\n\t * streams as it commits; without it the stream ends at the marker. Every thread of the session\n\t * writes this one log; events name their `threadId`.\n\t * Ephemeral events (text and tool progress deltas) are never stored, so they are not here;\n\t * `event.subscribe` carries them live. To resume, pass the higher of the last event's\n\t * `durable.seq` and the last marker's `seq`: the marker can sit past the last event sent.\n\t * With `threadId`, only that thread's events; the marker still names the session's head. A fork's\n\t * own log starts at its `session.thread.forked`: what it inherits is in `thread.history`.\n\t */\n\tRpc.make(\"session.log\", {\n\t\tpayload: {\n\t\t\tsessionId: SessionID,\n\t\t\tthreadId: optional(ThreadID),\n\t\t\tafter: optional(Schema.Int),\n\t\t\tfollow: optional(Schema.Boolean),\n\t\t},\n\t\tsuccess: Schema.Union([EventEnvelope, LogSynced]),\n\t\terror: Schema.Union([SessionNotFoundError, EncodingError]),\n\t\tstream: true,\n\t}),\n\t/** Threads newest first, each with its session embedded: of one session, or all. */\n\tRpc.make(\"thread.list\", {\n\t\tpayload: { sessionId: optional(SessionID) },\n\t\tsuccess: Schema.Array(ThreadInfo),\n\t}),\n\tRpc.make(\"thread.info\", {\n\t\tpayload: ThreadRef,\n\t\tsuccess: ThreadInfo,\n\t\terror: ThreadErrors,\n\t}),\n\t/**\n\t * The conversation in a thread's line: user and assistant messages, inherited ones first, oldest\n\t * first. The harness's own entries (compactions, resets, notices) are left out.\n\t */\n\tRpc.make(\"thread.history\", {\n\t\tpayload: ThreadRef,\n\t\tsuccess: Schema.Struct({ entries: Schema.Array(HistoryEntry) }),\n\t\terror: ThreadErrors,\n\t}),\n\t/**\n\t * Prompts admitted to the thread but not yet promoted, in admission order. Admission and\n\t * promotion are durable events, so a client following `session.log` rereads this whenever the\n\t * log moves.\n\t */\n\tRpc.make(\"thread.queue\", {\n\t\tpayload: ThreadRef,\n\t\tsuccess: Schema.Struct({ entries: Schema.Array(QueuedPrompt) }),\n\t\terror: ThreadErrors,\n\t}),\n\t/**\n\t * One thread's detail. Without `after`, the newest entries of its line (inherited ones\n\t * included) within `budget` bytes (default 1 MiB) and its pending inbox, then `Synced` with\n\t * `floor`. With `after`, its own entries and inbox rows whose revision is past it, then\n\t * `Synced`. Then the same live after each commit, with the thread's text and thinking deltas\n\t * as `Delta` between.\n\t */\n\tRpc.make(\"thread.sync\", {\n\t\tpayload: {\n\t\t\tsessionId: SessionID,\n\t\t\tthreadId: ThreadID,\n\t\t\tafter: optional(Schema.Int),\n\t\t\tbudget: optional(Schema.Int),\n\t\t},\n\t\tsuccess: ThreadItem,\n\t\terror: Schema.Union([ThreadErrors, SubscriptionOverflowError, EncodingError]),\n\t\tstream: true,\n\t}),\n\t/**\n\t * Older entries of a thread's line (inherited ones included), oldest first: the newest `limit`\n\t * whose `seq` is below `before`, cut to `budget` bytes (default 1 MiB). The newest is always sent.\n\t */\n\tRpc.make(\"thread.page\", {\n\t\tpayload: {\n\t\t\tsessionId: SessionID,\n\t\t\tthreadId: ThreadID,\n\t\t\tbefore: Schema.Int,\n\t\t\tlimit: Schema.Int,\n\t\t\tbudget: optional(Schema.Int),\n\t\t},\n\t\tsuccess: Schema.Struct({ entries: Schema.Array(HistoryEntry) }),\n\t\terror: ThreadErrors,\n\t}),\n\tRpc.make(\"thread.configure\", {\n\t\tpayload: { ...ThreadRef, runtime: RuntimeConfig },\n\t\tsuccess: ThreadInfo,\n\t\terror: ThreadErrors,\n\t}),\n\t/**\n\t * A new thread whose history continues from this one's line through `entryId`, which must be\n\t * committed. `before` stops at the entry's predecessor and returns its text to edit again.\n\t */\n\tRpc.make(\"thread.fork\", {\n\t\tpayload: { ...ThreadRef, entryId: Schema.String, mode: optional(Schema.Literals([\"at\", \"before\"])) },\n\t\tsuccess: Schema.Struct({ thread: ThreadInfo, text: optional(Schema.String) }),\n\t\terror: Schema.Union([ThreadErrors, ForkError]),\n\t}),\n\tRpc.make(\"thread.prompt\", {\n\t\tpayload: {\n\t\t\t...ThreadRef,\n\t\t\ttext: Schema.String,\n\t\t\tdelivery: optional(Delivery),\n\t\t\tid: optional(MessageID),\n\t\t},\n\t\tsuccess: Schema.Struct({ threadId: ThreadID }),\n\t\terror: Schema.Union([ThreadErrors, PromptConflictError]),\n\t}),\n\t/**\n\t * Withdraws a queued prompt before it joins the conversation. `cancelled` is false when it had\n\t * already been promoted (it then stays in the conversation) or no pending prompt has that id.\n\t */\n\tRpc.make(\"thread.cancel\", {\n\t\tpayload: { ...ThreadRef, messageId: MessageID },\n\t\tsuccess: Schema.Struct({ cancelled: Schema.Boolean }),\n\t\terror: ThreadErrors,\n\t}),\n\t/**\n\t * Moves a queued prompt to the other lane or rewrites it, keeping its place in the queue.\n\t * `delivery: \"steer\"` also wakes the thread, so a prompt left waiting after a stop runs now.\n\t * `updated` is false when it had already been promoted or cancelled, or no pending prompt has that id.\n\t */\n\tRpc.make(\"thread.update\", {\n\t\tpayload: {\n\t\t\t...ThreadRef,\n\t\t\tmessageId: MessageID,\n\t\t\tdelivery: optional(Delivery),\n\t\t\ttext: optional(Schema.String),\n\t\t},\n\t\tsuccess: Schema.Struct({ updated: Schema.Boolean }),\n\t\terror: ThreadErrors,\n\t}),\n\tRpc.make(\"thread.interrupt\", {\n\t\tpayload: ThreadRef,\n\t\tsuccess: Schema.Struct({ interrupted: Schema.Boolean }),\n\t\terror: ThreadErrors,\n\t}),\n\t/**\n\t * Whether a prompt materialized into the thread's conversation. An admitted prompt that is still\n\t * queued has no entry yet, so this is the projection a client reconciles against when the\n\t * volatile stream left it unsure.\n\t */\n\tRpc.make(\"thread.message\", {\n\t\tpayload: { ...ThreadRef, messageId: MessageID },\n\t\tsuccess: Schema.Struct({ found: Schema.Boolean }),\n\t\terror: ThreadErrors,\n\t}),\n\tRpc.make(\"thread.wait\", {\n\t\tpayload: ThreadRef,\n\t\tsuccess: Schema.Void,\n\t\terror: ThreadErrors,\n\t}),\n\t/**\n\t * Re-import every configured plugin, for the whole server.\n\t *\n\t * The one thing an exchange cannot notice on its own: a local plugin whose contents changed\n\t * while its path did not. A failure keeps the previous set and is reported here rather than\n\t * emptying a running server's tool registry.\n\t */\n\tRpc.make(\"plugin.reload\", {\n\t\tpayload: {},\n\t\t// No error channel: a reload that fails keeps the previous set and reports why, because a\n\t\t// server that empties its tool registry over a typo is worse than one that says so.\n\t\tsuccess: Schema.Struct({ plugins: Schema.Int, failure: optional(Schema.String) }),\n\t}),\n\t/**\n\t * Close the instance behind a thread's MCP server, or its attempt, and connect it afresh, for\n\t * every thread sharing it. Answers once that attempt finished, with the server's state then.\n\t */\n\tRpc.make(\"mcp.connect\", {\n\t\tpayload: McpServerRef,\n\t\tsuccess: McpStatus,\n\t\terror: McpErrors,\n\t}),\n\t/** Close it, for every thread sharing it, and keep it closed until `mcp.connect` or a config change. */\n\tRpc.make(\"mcp.disconnect\", {\n\t\tpayload: McpServerRef,\n\t\tsuccess: McpStatus,\n\t\terror: McpErrors,\n\t}),\n\t/** This machine and the workspaces it is connected to. */\n\tRpc.make(\"machine.info\", {\n\t\tpayload: {},\n\t\tsuccess: Machine.Status,\n\t}),\n\t/** Names this machine for people; an empty name goes back to the OS's. */\n\tRpc.make(\"machine.rename\", {\n\t\tpayload: { givenName: Schema.String },\n\t\tsuccess: Machine.Status,\n\t}),\n\t/** Leaves a workspace: the relay revokes this machine's link, and the machine forgets it. */\n\tRpc.make(\"machine.disconnect\", {\n\t\tpayload: Machine.Disconnect,\n\t\tsuccess: Machine.Disconnected,\n\t\terror: Machine.ConnectError,\n\t}),\n\t/**\n\t * Connects this machine to a workspace: the code a member approves, then the link once they have.\n\t * `workspaceId` is the workspace it is meant for; without one the approver picks it.\n\t */\n\tRpc.make(\"machine.connect\", {\n\t\tpayload: { workspaceId: Schema.optional(Schema.String) },\n\t\tsuccess: Machine.ConnectEvent,\n\t\terror: Machine.ConnectError,\n\t\tstream: true,\n\t}),\n\t/**\n\t * A one-time code another computer exchanges at `POST /api/v1/devices` to pair its key, and the\n\t * fingerprint of this machine's key, which that computer keeps. Valid 10 minutes, once; held in\n\t * memory, so a restart forgets it. Local callers only.\n\t */\n\tRpc.make(\"device.pair\", {\n\t\tpayload: {},\n\t\tsuccess: Schema.Struct({ code: Schema.String, expiresAt: Schema.Finite, fingerprint: Schema.String }),\n\t\terror: Forbidden,\n\t}),\n\t/** Every paired device, oldest first. Local callers only. */\n\tRpc.make(\"device.list\", {\n\t\tpayload: {},\n\t\tsuccess: Schema.Array(DeviceInfo),\n\t\terror: Forbidden,\n\t}),\n\t/** Forgets a device and ends its open connections; `applied` is false when none has `id`. Local callers only. */\n\tRpc.make(\"device.revoke\", {\n\t\tpayload: { id: Schema.String },\n\t\tsuccess: Schema.Struct({ applied: Schema.Boolean }),\n\t\terror: Forbidden,\n\t}),\n\t/**\n\t * Ends the calling device's own pairing, as `device.revoke` would. Its sockets end with it, this one\n\t * too, so the reply may never arrive: the connection dropping after the call is sent means it left.\n\t * Devices only; a local caller has no pairing to leave.\n\t */\n\tRpc.make(\"device.leave\", {\n\t\tpayload: {},\n\t\terror: Forbidden,\n\t}),\n\t/** The OS home directory, and the folder `host.create` makes projects in. */\n\tRpc.make(\"host.info\", {\n\t\tpayload: {},\n\t\tsuccess: Schema.Struct({ home: Schema.String, projects: Schema.String }),\n\t}),\n\t/**\n\t * The directories in `path` (a leading `~` is the OS home), hidden ones included, symlinks and\n\t * files left out. One the server may not read lists as empty with `readable` false: it can still\n\t * be added, as a folder macOS keeps from the server can.\n\t */\n\tRpc.make(\"host.browse\", {\n\t\tpayload: { path: Schema.String },\n\t\t// Optional: a client of this contract may reach a server from before it, which lists every folder as readable.\n\t\tsuccess: Schema.Struct({\n\t\t\tpath: Schema.String,\n\t\t\tentries: Schema.Array(Folder),\n\t\t\treadable: optional(Schema.Boolean),\n\t\t}),\n\t\terror: HostError,\n\t}),\n\t/**\n\t * A new folder under `host.info`'s `projects`, named after `name`, with a git repository and a\n\t * README. A first commit git refused is not fatal: `commitError` says why it was skipped.\n\t */\n\tRpc.make(\"host.create\", {\n\t\tpayload: { name: Schema.String },\n\t\tsuccess: Schema.Struct({ path: Schema.String, commitError: optional(Schema.String) }),\n\t\terror: HostError,\n\t}),\n\t/** An existing folder as an absolute path; a missing one is created. */\n\tRpc.make(\"host.add\", {\n\t\tpayload: { path: Schema.String },\n\t\tsuccess: Schema.Struct({ path: Schema.String }),\n\t\terror: HostError,\n\t}),\n\t/**\n\t * Starts a background clone of `remote` into `path`, which must be missing or empty, and answers\n\t * at once with the destination and the redacted remote; `host.clones` follows it. Git never prompts.\n\t */\n\tRpc.make(\"host.clone\", {\n\t\tpayload: { remote: Schema.String, path: Schema.String },\n\t\tsuccess: Schema.Struct({ path: Schema.String, remote: Schema.String }),\n\t\terror: HostError,\n\t}),\n\t/** Every tracked clone now, then the whole list again on each change. A finished one leaves 30 seconds after. */\n\tRpc.make(\"host.clones\", {\n\t\tpayload: {},\n\t\tsuccess: Schema.Array(Clone),\n\t\tstream: true,\n\t}),\n\t/** Stops a running clone and empties its folder; `applied` is false when it was not running. */\n\tRpc.make(\"host.cancel\", {\n\t\tpayload: { path: Schema.String },\n\t\tsuccess: Schema.Struct({ applied: Schema.Boolean }),\n\t}),\n\t/** Clones a failed or cancelled one again into its emptied folder; `applied` is false otherwise. */\n\tRpc.make(\"host.retry\", {\n\t\tpayload: { path: Schema.String },\n\t\tsuccess: Schema.Struct({ applied: Schema.Boolean }),\n\t\terror: HostError,\n\t}),\n\t/** Stops tracking a clone, stopping it and emptying its folder unless it finished. */\n\tRpc.make(\"host.discard\", {\n\t\tpayload: { path: Schema.String },\n\t\tsuccess: Schema.Void,\n\t}),\n\t/** Whether `gh` is installed and signed in; `hint` says what to do when it is not. */\n\tRpc.make(\"github.status\", {\n\t\tpayload: {},\n\t\tsuccess: Schema.Struct({ ready: Schema.Boolean, hint: optional(Schema.String) }),\n\t}),\n\t/** A repository by `owner/name`, `host/owner/name`, its URL, or a bare name of the signed-in user's. */\n\tRpc.make(\"github.lookup\", {\n\t\tpayload: { repository: Schema.String },\n\t\tsuccess: Repository,\n\t\terror: HostError,\n\t}),\n\tRpc.make(\"sandbox.drivers\", {\n\t\tpayload: {},\n\t\tsuccess: Schema.Array(Schema.Struct({ name: Schema.String, kind: Schema.String })),\n\t}),\n\tRpc.make(\"sandbox.list\", {\n\t\tpayload: {},\n\t\tsuccess: Schema.Array(SandboxInfo),\n\t}),\n\tRpc.make(\"sandbox.create\", {\n\t\tpayload: { driver: Schema.String },\n\t\tsuccess: SandboxInfo,\n\t\terror: SandboxErrors,\n\t}),\n\tRpc.make(\"sandbox.register\", {\n\t\tpayload: { driver: Schema.String, providerResourceId: Schema.String },\n\t\tsuccess: SandboxInfo,\n\t\terror: SandboxErrors,\n\t}),\n\tRpc.make(\"sandbox.stop\", {\n\t\tpayload: { sandboxId: SandboxInstance.ID },\n\t\tsuccess: Schema.Void,\n\t\terror: SandboxErrors,\n\t}),\n\t/**\n\t * Calls a method of a space daemon running in `spaceId`, such as `git.diff`. Never starts a daemon\n\t * and never wakes a sandbox: `unavailable` when none runs there, `detached` when the space is not\n\t * mounted.\n\t */\n\tRpc.make(\"daemon.call\", {\n\t\tpayload: {\n\t\t\tplugin: Schema.String,\n\t\t\tspaceId: Schema.String,\n\t\t\tmethod: Schema.String,\n\t\t\tinput: optional(Schema.Unknown),\n\t\t},\n\t\tsuccess: Schema.Unknown,\n\t\terror: DaemonCallError,\n\t}),\n\t/**\n\t * Every event the server publishes, live, after a `server.connected` frame. With `threadId`,\n\t * only the events naming that thread; the frame still comes first.\n\t */\n\tRpc.make(\"event.subscribe\", {\n\t\tpayload: {\n\t\t\tthreadId: optional(ThreadID),\n\t\t\t/**\n\t\t\t * Only these event types. The last event of each type that a space daemon published is sent\n\t\t\t * first, after `server.connected`: a client that was away catches up without a change.\n\t\t\t */\n\t\t\ttypes: optional(Schema.Array(Schema.String)),\n\t\t\t// With `threadId` too, only events naming that thread pass: daemon events name none.\n\t\t},\n\t\tsuccess: EventEnvelope,\n\t\terror: Schema.Union([SubscriptionOverflowError, EncodingError]),\n\t\tstream: true,\n\t}),\n).middleware(Door);\n\nexport * from \"./host/records.ts\";\nexport { EventEnvelope };\nexport {\n\tDaemonCallError,\n\tEncodingError,\n\tForkError,\n\tForbidden,\n\tModelCatalogError,\n\tProjectCheckoutError,\n\tProjectNotFoundError,\n\tPromptConflictError,\n\tRelinkError,\n\tSessionLinkedSpaceNotFoundError,\n\tSessionNotFoundError,\n\tSettingsConflictError,\n\tSettingsError,\n\tSubscriptionOverflowError,\n\tThreadNotFoundError,\n\tUnknownServerError,\n};\n\nexport * as Host from \"./host.ts\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+DA,MAAa,OAAO;;AAGpB,MAAM,YAAY;CACjB,WAAW;CACX,UAAU,SAAS,QAAQ;AAC5B;;AAGA,MAAM,eAAe;CAAE,GAAG;CAAW,QAAQ,OAAO;AAAO;AAE3D,MAAM,aAAaA;;AAGnB,MAAM,cAAc,OAAO,QAAQ,MAAM,OAAO,WAAW,CAAC;AAE5D,MAAM,gBAAgB,OAAO,MAAM;CAClC;CACA;CACA;CACA;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,QAAQ,OAAO;GACf,SAAS,OAAO;GAChB,QAAQ,OAAO;GACf,OAAO,SAAS,OAAO,OAAO;EAC/B;EACA,SAAS,OAAO;EAChB,OAAO;CACR,CAAC;;;;;CAKD,IAAI,KAAK,mBAAmB;EAC3B,SAAS;GACR,UAAU,SAAS,QAAQ;;;;;GAK3B,OAAO,SAAS,OAAO,MAAM,OAAO,MAAM,CAAC;EAE5C;EACA,SAAS;EACT,OAAO,OAAO,MAAM,CAAC,2BAA2B,aAAa,CAAC;EAC9D,QAAQ;CACT,CAAC;AACF,CAAC,CAAC,WAAW,IAAI"}
|
package/ids.d.mts
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { Schema } from "effect";
|
|
2
|
+
declare namespace ids_d_exports {
|
|
3
|
+
export { ids_d_exports as Ids, MessageID, SessionID, ThreadID };
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* The identifiers that cross the plugin boundary.
|
|
7
|
+
*
|
|
8
|
+
* A plugin reads a session and thread id off its context and a message id off every tool call, so both
|
|
9
|
+
* brands have to be the ones the harness itself mints -- a structurally identical brand declared
|
|
10
|
+
* twice is two types, and a plugin would have to cast to hand either back. They live here, in the
|
|
11
|
+
* package both sides depend on, rather than being re-declared on each side.
|
|
12
|
+
*/
|
|
13
|
+
export declare const SessionID: Schema.brand<Schema.String, "Session.ID"> & {
|
|
14
|
+
ascending: (id?: string) => string & import("effect/Brand").Brand<"Session.ID">;
|
|
15
|
+
create: () => string & import("effect/Brand").Brand<"Session.ID">;
|
|
16
|
+
};
|
|
17
|
+
export type SessionID = typeof SessionID.Type;
|
|
18
|
+
/**
|
|
19
|
+
* Thread identity: one linear transcript inside a session. Every session has a `main` thread;
|
|
20
|
+
* forks add more. Also the provider session and prompt-cache key, so it is fresh per thread.
|
|
21
|
+
*/
|
|
22
|
+
export declare const ThreadID: Schema.brand<Schema.String, "Thread.ID"> & {
|
|
23
|
+
create: () => string & import("effect/Brand").Brand<"Thread.ID">;
|
|
24
|
+
};
|
|
25
|
+
export type ThreadID = typeof ThreadID.Type;
|
|
26
|
+
/**
|
|
27
|
+
* A conversation message id.
|
|
28
|
+
*
|
|
29
|
+
* Deliberately unprefixed. aikit mints assistant message ids itself, as bare
|
|
30
|
+
* uuidv7, and `stream()` accepts no id -- so any naming rule of ours would have
|
|
31
|
+
* to be imposed on messages aikit hands us, by rewriting a field of the value we
|
|
32
|
+
* were given. Sharing aikit's format instead means an id means the same thing on
|
|
33
|
+
* both sides of the boundary and never needs translating.
|
|
34
|
+
*
|
|
35
|
+
* The brand carries the meaning; uuidv7 keeps ids time-ordered, so they sort by
|
|
36
|
+
* creation.
|
|
37
|
+
*/
|
|
38
|
+
export declare const MessageID: Schema.brand<Schema.String, "Message.ID"> & {
|
|
39
|
+
create: () => string & import("effect/Brand").Brand<"Message.ID">;
|
|
40
|
+
/**
|
|
41
|
+
* Adopt an id minted elsewhere -- in practice aikit's, which arrives as a
|
|
42
|
+
* plain string on every stream event and inside every assistant message.
|
|
43
|
+
*
|
|
44
|
+
* `make` does the same thing. This exists so the boundary where a foreign
|
|
45
|
+
* id enters the domain is named and greppable, and so the pairing with
|
|
46
|
+
* `create` says which side chose the id.
|
|
47
|
+
*/
|
|
48
|
+
from: (id: string) => string & import("effect/Brand").Brand<"Message.ID">;
|
|
49
|
+
};
|
|
50
|
+
export type MessageID = typeof MessageID.Type;
|
|
51
|
+
//#endregion
|
|
52
|
+
export { ids_d_exports as Ids };
|
|
53
|
+
//# sourceMappingURL=ids.d.mts.map
|
package/ids.mjs
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.mjs";
|
|
2
|
+
import { withStatics } from "./common.mjs";
|
|
3
|
+
import { Schema } from "effect";
|
|
4
|
+
import { uuidv7 } from "uuidv7";
|
|
5
|
+
//#region src/ids.ts
|
|
6
|
+
var ids_exports = /* @__PURE__ */ __exportAll({
|
|
7
|
+
Ids: () => ids_exports,
|
|
8
|
+
MessageID: () => MessageID,
|
|
9
|
+
SessionID: () => SessionID,
|
|
10
|
+
ThreadID: () => ThreadID
|
|
11
|
+
});
|
|
12
|
+
/**
|
|
13
|
+
* The identifiers that cross the plugin boundary.
|
|
14
|
+
*
|
|
15
|
+
* A plugin reads a session and thread id off its context and a message id off every tool call, so both
|
|
16
|
+
* brands have to be the ones the harness itself mints -- a structurally identical brand declared
|
|
17
|
+
* twice is two types, and a plugin would have to cast to hand either back. They live here, in the
|
|
18
|
+
* package both sides depend on, rather than being re-declared on each side.
|
|
19
|
+
*/
|
|
20
|
+
const SessionID = Schema.String.check(Schema.isStartingWith("ses")).pipe(Schema.brand("Session.ID"), withStatics((schema) => ({
|
|
21
|
+
ascending: (id) => {
|
|
22
|
+
if (!id) return schema.make("ses_" + uuidv7());
|
|
23
|
+
if (!id.startsWith("ses")) throw new Error(`ID ${id} does not start with ses`);
|
|
24
|
+
return schema.make(id);
|
|
25
|
+
},
|
|
26
|
+
create: () => schema.make("ses_" + uuidv7())
|
|
27
|
+
})));
|
|
28
|
+
/**
|
|
29
|
+
* Thread identity: one linear transcript inside a session. Every session has a `main` thread;
|
|
30
|
+
* forks add more. Also the provider session and prompt-cache key, so it is fresh per thread.
|
|
31
|
+
*/
|
|
32
|
+
const ThreadID = Schema.String.check(Schema.isStartingWith("thr")).pipe(Schema.brand("Thread.ID"), withStatics((schema) => ({ create: () => schema.make("thr_" + uuidv7()) })));
|
|
33
|
+
/**
|
|
34
|
+
* A conversation message id.
|
|
35
|
+
*
|
|
36
|
+
* Deliberately unprefixed. aikit mints assistant message ids itself, as bare
|
|
37
|
+
* uuidv7, and `stream()` accepts no id -- so any naming rule of ours would have
|
|
38
|
+
* to be imposed on messages aikit hands us, by rewriting a field of the value we
|
|
39
|
+
* were given. Sharing aikit's format instead means an id means the same thing on
|
|
40
|
+
* both sides of the boundary and never needs translating.
|
|
41
|
+
*
|
|
42
|
+
* The brand carries the meaning; uuidv7 keeps ids time-ordered, so they sort by
|
|
43
|
+
* creation.
|
|
44
|
+
*/
|
|
45
|
+
const MessageID = Schema.String.pipe(Schema.brand("Message.ID"), withStatics((schema) => ({
|
|
46
|
+
create: () => schema.make(uuidv7()),
|
|
47
|
+
/**
|
|
48
|
+
* Adopt an id minted elsewhere -- in practice aikit's, which arrives as a
|
|
49
|
+
* plain string on every stream event and inside every assistant message.
|
|
50
|
+
*
|
|
51
|
+
* `make` does the same thing. This exists so the boundary where a foreign
|
|
52
|
+
* id enters the domain is named and greppable, and so the pairing with
|
|
53
|
+
* `create` says which side chose the id.
|
|
54
|
+
*/
|
|
55
|
+
from: (id) => schema.make(id)
|
|
56
|
+
})));
|
|
57
|
+
//#endregion
|
|
58
|
+
export { ids_exports as Ids, MessageID, SessionID, ThreadID };
|
|
59
|
+
|
|
60
|
+
//# sourceMappingURL=ids.mjs.map
|
package/ids.mjs.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ids.mjs","names":[],"sources":["../../src/ids.ts"],"sourcesContent":["import { Schema } from \"effect\";\nimport { uuidv7 } from \"uuidv7\";\nimport { withStatics } from \"./common.ts\";\n\n/**\n * The identifiers that cross the plugin boundary.\n *\n * A plugin reads a session and thread id off its context and a message id off every tool call, so both\n * brands have to be the ones the harness itself mints -- a structurally identical brand declared\n * twice is two types, and a plugin would have to cast to hand either back. They live here, in the\n * package both sides depend on, rather than being re-declared on each side.\n */\n\n// Session identity. Branded so a session ID is not interchangeable with an\n// entry, part, or workspace ID at the type level — service signatures take\n// `SessionID`, never a bare `string`.\n//\n// `create` mints a new one; `ascending` adopts an ID that came from outside\n// (a persisted row, a request payload) and rejects a foreign prefix rather\n// than branding it silently. uuidv7 keeps IDs lexicographically sortable by\n// creation time, so `ORDER BY id` is `ORDER BY created`.\nexport const SessionID = Schema.String.check(Schema.isStartingWith(\"ses\")).pipe(\n\tSchema.brand(\"Session.ID\"),\n\twithStatics((schema) => ({\n\t\tascending: (id?: string) => {\n\t\t\tif (!id) return schema.make(\"ses_\" + uuidv7());\n\t\t\tif (!id.startsWith(\"ses\")) throw new Error(`ID ${id} does not start with ses`);\n\t\t\treturn schema.make(id);\n\t\t},\n\t\tcreate: () => schema.make(\"ses_\" + uuidv7()),\n\t})),\n);\nexport type SessionID = typeof SessionID.Type;\n\n/**\n * Thread identity: one linear transcript inside a session. Every session has a `main` thread;\n * forks add more. Also the provider session and prompt-cache key, so it is fresh per thread.\n */\nexport const ThreadID = Schema.String.check(Schema.isStartingWith(\"thr\")).pipe(\n\tSchema.brand(\"Thread.ID\"),\n\twithStatics((schema) => ({\n\t\tcreate: () => schema.make(\"thr_\" + uuidv7()),\n\t})),\n);\nexport type ThreadID = typeof ThreadID.Type;\n\n/**\n * A conversation message id.\n *\n * Deliberately unprefixed. aikit mints assistant message ids itself, as bare\n * uuidv7, and `stream()` accepts no id -- so any naming rule of ours would have\n * to be imposed on messages aikit hands us, by rewriting a field of the value we\n * were given. Sharing aikit's format instead means an id means the same thing on\n * both sides of the boundary and never needs translating.\n *\n * The brand carries the meaning; uuidv7 keeps ids time-ordered, so they sort by\n * creation.\n */\nexport const MessageID = Schema.String.pipe(\n\tSchema.brand(\"Message.ID\"),\n\twithStatics((schema) => ({\n\t\tcreate: () => schema.make(uuidv7()),\n\t\t/**\n\t\t * Adopt an id minted elsewhere -- in practice aikit's, which arrives as a\n\t\t * plain string on every stream event and inside every assistant message.\n\t\t *\n\t\t * `make` does the same thing. This exists so the boundary where a foreign\n\t\t * id enters the domain is named and greppable, and so the pairing with\n\t\t * `create` says which side chose the id.\n\t\t */\n\t\tfrom: (id: string) => schema.make(id),\n\t})),\n);\nexport type MessageID = typeof MessageID.Type;\n\nexport * as Ids from \"./ids.ts\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAqBA,MAAa,YAAY,OAAO,OAAO,MAAM,OAAO,eAAe,KAAK,CAAC,CAAC,CAAC,KAC1E,OAAO,MAAM,YAAY,GACzB,aAAa,YAAY;CACxB,YAAY,OAAgB;EAC3B,IAAI,CAAC,IAAI,OAAO,OAAO,KAAK,SAAS,OAAO,CAAC;EAC7C,IAAI,CAAC,GAAG,WAAW,KAAK,GAAG,MAAM,IAAI,MAAM,MAAM,GAAG,yBAAyB;EAC7E,OAAO,OAAO,KAAK,EAAE;CACtB;CACA,cAAc,OAAO,KAAK,SAAS,OAAO,CAAC;AAC5C,EAAE,CACH;;;;;AAOA,MAAa,WAAW,OAAO,OAAO,MAAM,OAAO,eAAe,KAAK,CAAC,CAAC,CAAC,KACzE,OAAO,MAAM,WAAW,GACxB,aAAa,YAAY,EACxB,cAAc,OAAO,KAAK,SAAS,OAAO,CAAC,EAC5C,EAAE,CACH;;;;;;;;;;;;;AAeA,MAAa,YAAY,OAAO,OAAO,KACtC,OAAO,MAAM,YAAY,GACzB,aAAa,YAAY;CACxB,cAAc,OAAO,KAAK,OAAO,CAAC;;;;;;;;;CASlC,OAAO,OAAe,OAAO,KAAK,EAAE;AACrC,EAAE,CACH"}
|
package/jws.d.mts
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { Effect, Schema } from "effect";
|
|
2
|
+
declare namespace jws_d_exports {
|
|
3
|
+
export { Header, jws_d_exports as Jws, JwsError, PrivateKey, PublicKey, fingerprint, fingerprintOf, generate, peek, peekClaims, publicOf, sign, thumbprint, verify };
|
|
4
|
+
}
|
|
5
|
+
export declare const PublicKey: Schema.Struct<{
|
|
6
|
+
readonly kty: Schema.Literal<"OKP">;
|
|
7
|
+
readonly crv: Schema.Literal<"Ed25519">;
|
|
8
|
+
readonly x: Schema.String;
|
|
9
|
+
}>;
|
|
10
|
+
export type PublicKey = typeof PublicKey.Type;
|
|
11
|
+
export declare const PrivateKey: Schema.Struct<{
|
|
12
|
+
readonly kty: Schema.Literal<"OKP">;
|
|
13
|
+
readonly crv: Schema.Literal<"Ed25519">;
|
|
14
|
+
readonly x: Schema.String;
|
|
15
|
+
readonly d: Schema.String;
|
|
16
|
+
}>;
|
|
17
|
+
export type PrivateKey = typeof PrivateKey.Type;
|
|
18
|
+
export declare const Header: Schema.Struct<{
|
|
19
|
+
readonly alg: Schema.Literal<"EdDSA">;
|
|
20
|
+
/** The signing key's thumbprint, for a key the verifier already holds. */
|
|
21
|
+
readonly kid: Schema.optional<Schema.String>;
|
|
22
|
+
/** The signing key itself, for a request that registers it. */
|
|
23
|
+
readonly jwk: Schema.optional<Schema.Struct<{
|
|
24
|
+
readonly kty: Schema.Literal<"OKP">;
|
|
25
|
+
readonly crv: Schema.Literal<"Ed25519">;
|
|
26
|
+
readonly x: Schema.String;
|
|
27
|
+
}>>;
|
|
28
|
+
}>;
|
|
29
|
+
export type Header = typeof Header.Type;
|
|
30
|
+
declare const JwsError_base: Schema.Class<JwsError, Schema.TaggedStruct<"Jws.JwsError", {
|
|
31
|
+
readonly reason: Schema.Literals<readonly ["malformed", "signature", "crypto"]>;
|
|
32
|
+
}>, import("effect/Cause").YieldableError>;
|
|
33
|
+
export declare class JwsError extends JwsError_base {}
|
|
34
|
+
/** The public half of a private key. */
|
|
35
|
+
export declare const publicOf: (key: PrivateKey) => PublicKey;
|
|
36
|
+
/** A fresh Ed25519 keypair as a private JWK; its public half is {@link publicOf}. */
|
|
37
|
+
export declare const generate: () => Effect.Effect<{
|
|
38
|
+
readonly kty: "OKP";
|
|
39
|
+
readonly crv: "Ed25519";
|
|
40
|
+
readonly x: string;
|
|
41
|
+
readonly d: string;
|
|
42
|
+
}, JwsError, never>;
|
|
43
|
+
/** The RFC 7638 thumbprint of a public key: base64url SHA-256 of its required members, in order. */
|
|
44
|
+
export declare const thumbprint: (key: {
|
|
45
|
+
readonly kty: "OKP";
|
|
46
|
+
readonly crv: "Ed25519";
|
|
47
|
+
readonly x: string;
|
|
48
|
+
}) => Effect.Effect<string, JwsError, never>;
|
|
49
|
+
/** A key's thumbprint as people compare it, `SHA256:<thumbprint>`. */
|
|
50
|
+
export declare const fingerprintOf: (thumbprint: string) => string;
|
|
51
|
+
/** A public key as people compare it: {@link fingerprintOf} its thumbprint. */
|
|
52
|
+
export declare const fingerprint: (key: PublicKey) => Effect.Effect<string, JwsError, never>;
|
|
53
|
+
/** Signs `claims` with `key`, naming it by `kid` or embedding its public half. */
|
|
54
|
+
export declare const sign: (claims: unknown, key: {
|
|
55
|
+
readonly kty: "OKP";
|
|
56
|
+
readonly crv: "Ed25519";
|
|
57
|
+
readonly x: string;
|
|
58
|
+
readonly d: string;
|
|
59
|
+
}, name: {
|
|
60
|
+
readonly kid: string;
|
|
61
|
+
} | {
|
|
62
|
+
readonly embed: true;
|
|
63
|
+
}) => Effect.Effect<string, JwsError, never>;
|
|
64
|
+
/** A token's header, read before its signature is checked, to find the key that checks it. */
|
|
65
|
+
export declare const peek: (token: string) => Effect.Effect<{
|
|
66
|
+
readonly alg: "EdDSA";
|
|
67
|
+
readonly kid?: string | undefined;
|
|
68
|
+
readonly jwk?: {
|
|
69
|
+
readonly kty: "OKP";
|
|
70
|
+
readonly crv: "Ed25519";
|
|
71
|
+
readonly x: string;
|
|
72
|
+
} | undefined;
|
|
73
|
+
}, JwsError, never>;
|
|
74
|
+
/** A token's claims, still undecoded, read without checking its signature: for echoing, never for trusting. */
|
|
75
|
+
export declare const peekClaims: (token: string) => Effect.Effect<unknown, JwsError, never>;
|
|
76
|
+
/** Checks `token`'s signature against `key` and returns its claims, still undecoded. */
|
|
77
|
+
export declare const verify: (token: string, key: {
|
|
78
|
+
readonly kty: "OKP";
|
|
79
|
+
readonly crv: "Ed25519";
|
|
80
|
+
readonly x: string;
|
|
81
|
+
}) => Effect.Effect<unknown, JwsError, never>;
|
|
82
|
+
//#endregion
|
|
83
|
+
export { jws_d_exports as Jws };
|
|
84
|
+
//# sourceMappingURL=jws.d.mts.map
|
package/jws.mjs
ADDED
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.mjs";
|
|
2
|
+
import { Effect, Result, Schema } from "effect";
|
|
3
|
+
import { Base64Url } from "effect/encoding";
|
|
4
|
+
//#region src/jws.ts
|
|
5
|
+
var jws_exports = /* @__PURE__ */ __exportAll({
|
|
6
|
+
Header: () => Header,
|
|
7
|
+
Jws: () => jws_exports,
|
|
8
|
+
JwsError: () => JwsError,
|
|
9
|
+
PrivateKey: () => PrivateKey,
|
|
10
|
+
PublicKey: () => PublicKey,
|
|
11
|
+
fingerprint: () => fingerprint,
|
|
12
|
+
fingerprintOf: () => fingerprintOf,
|
|
13
|
+
generate: () => generate,
|
|
14
|
+
peek: () => peek,
|
|
15
|
+
peekClaims: () => peekClaims,
|
|
16
|
+
publicOf: () => publicOf,
|
|
17
|
+
sign: () => sign,
|
|
18
|
+
thumbprint: () => thumbprint,
|
|
19
|
+
verify: () => verify
|
|
20
|
+
});
|
|
21
|
+
const PublicKey = Schema.Struct({
|
|
22
|
+
kty: Schema.Literal("OKP"),
|
|
23
|
+
crv: Schema.Literal("Ed25519"),
|
|
24
|
+
x: Schema.String
|
|
25
|
+
});
|
|
26
|
+
const PrivateKey = Schema.Struct({
|
|
27
|
+
...PublicKey.fields,
|
|
28
|
+
d: Schema.String
|
|
29
|
+
});
|
|
30
|
+
const Header = Schema.Struct({
|
|
31
|
+
alg: Schema.Literal("EdDSA"),
|
|
32
|
+
/** The signing key's thumbprint, for a key the verifier already holds. */
|
|
33
|
+
kid: Schema.optional(Schema.String),
|
|
34
|
+
/** The signing key itself, for a request that registers it. */
|
|
35
|
+
jwk: Schema.optional(PublicKey)
|
|
36
|
+
});
|
|
37
|
+
var JwsError = class extends Schema.TaggedError()("Jws.JwsError", { reason: Schema.Literals([
|
|
38
|
+
"malformed",
|
|
39
|
+
"signature",
|
|
40
|
+
"crypto"
|
|
41
|
+
]) }) {};
|
|
42
|
+
const algorithm = { name: "Ed25519" };
|
|
43
|
+
const decodeHeader = Schema.decodeUnknownEffect(Schema.fromJsonString(Header));
|
|
44
|
+
const decodeJson = Schema.decodeUnknownEffect(Schema.fromJsonString(Schema.Unknown));
|
|
45
|
+
const crypto = (evaluate) => Effect.tryPromise({
|
|
46
|
+
try: evaluate,
|
|
47
|
+
catch: () => new JwsError({ reason: "crypto" })
|
|
48
|
+
});
|
|
49
|
+
const bytes = (part) => Result.match(Base64Url.decode(part), {
|
|
50
|
+
onFailure: () => Effect.fail(new JwsError({ reason: "malformed" })),
|
|
51
|
+
onSuccess: (decoded) => Effect.succeed(Uint8Array.from(decoded))
|
|
52
|
+
});
|
|
53
|
+
/** The public half of a private key. */
|
|
54
|
+
const publicOf = (key) => ({
|
|
55
|
+
kty: key.kty,
|
|
56
|
+
crv: key.crv,
|
|
57
|
+
x: key.x
|
|
58
|
+
});
|
|
59
|
+
/** A fresh Ed25519 keypair as a private JWK; its public half is {@link publicOf}. */
|
|
60
|
+
const generate = Effect.fn("Jws.generate")(function* () {
|
|
61
|
+
const pair = yield* crypto(() => globalThis.crypto.subtle.generateKey("Ed25519", true, ["sign", "verify"]));
|
|
62
|
+
if (!("privateKey" in pair)) return yield* new JwsError({ reason: "crypto" });
|
|
63
|
+
const jwk = yield* crypto(() => globalThis.crypto.subtle.exportKey("jwk", pair.privateKey));
|
|
64
|
+
return yield* Schema.decodeUnknownEffect(PrivateKey)(jwk).pipe(Effect.mapError(() => new JwsError({ reason: "crypto" })));
|
|
65
|
+
});
|
|
66
|
+
/** The RFC 7638 thumbprint of a public key: base64url SHA-256 of its required members, in order. */
|
|
67
|
+
const thumbprint = Effect.fn("Jws.thumbprint")(function* (key) {
|
|
68
|
+
const canonical = `{"crv":"${key.crv}","kty":"${key.kty}","x":"${key.x}"}`;
|
|
69
|
+
const digest = yield* crypto(() => globalThis.crypto.subtle.digest("SHA-256", new TextEncoder().encode(canonical)));
|
|
70
|
+
return Base64Url.encode(new Uint8Array(digest));
|
|
71
|
+
});
|
|
72
|
+
/** A key's thumbprint as people compare it, `SHA256:<thumbprint>`. */
|
|
73
|
+
const fingerprintOf = (thumbprint) => `SHA256:${thumbprint}`;
|
|
74
|
+
/** A public key as people compare it: {@link fingerprintOf} its thumbprint. */
|
|
75
|
+
const fingerprint = (key) => Effect.map(thumbprint(key), fingerprintOf);
|
|
76
|
+
/** Signs `claims` with `key`, naming it by `kid` or embedding its public half. */
|
|
77
|
+
const sign = Effect.fn("Jws.sign")(function* (claims, key, name) {
|
|
78
|
+
const header = "kid" in name ? {
|
|
79
|
+
alg: "EdDSA",
|
|
80
|
+
kid: name.kid
|
|
81
|
+
} : {
|
|
82
|
+
alg: "EdDSA",
|
|
83
|
+
jwk: publicOf(key)
|
|
84
|
+
};
|
|
85
|
+
const input = `${Base64Url.encode(JSON.stringify(header))}.${Base64Url.encode(JSON.stringify(claims))}`;
|
|
86
|
+
const signer = yield* crypto(() => globalThis.crypto.subtle.importKey("jwk", key, algorithm, false, ["sign"]));
|
|
87
|
+
const signature = yield* crypto(() => globalThis.crypto.subtle.sign(algorithm, signer, new TextEncoder().encode(input)));
|
|
88
|
+
return `${input}.${Base64Url.encode(new Uint8Array(signature))}`;
|
|
89
|
+
});
|
|
90
|
+
const parts = (token) => {
|
|
91
|
+
const [header, claims, signature, extra] = token.split(".");
|
|
92
|
+
return header === void 0 || claims === void 0 || signature === void 0 || extra !== void 0 ? Effect.fail(new JwsError({ reason: "malformed" })) : Effect.succeed({
|
|
93
|
+
header,
|
|
94
|
+
claims,
|
|
95
|
+
signature
|
|
96
|
+
});
|
|
97
|
+
};
|
|
98
|
+
const decodeClaims = (part) => Effect.flatMap(bytes(part), (decoded) => decodeJson(new TextDecoder().decode(decoded)).pipe(Effect.mapError(() => new JwsError({ reason: "malformed" }))));
|
|
99
|
+
/** A token's header, read before its signature is checked, to find the key that checks it. */
|
|
100
|
+
const peek = Effect.fn("Jws.peek")(function* (token) {
|
|
101
|
+
const { header } = yield* parts(token);
|
|
102
|
+
return yield* decodeHeader(new TextDecoder().decode(yield* bytes(header))).pipe(Effect.mapError(() => new JwsError({ reason: "malformed" })));
|
|
103
|
+
});
|
|
104
|
+
/** A token's claims, still undecoded, read without checking its signature: for echoing, never for trusting. */
|
|
105
|
+
const peekClaims = Effect.fn("Jws.peekClaims")(function* (token) {
|
|
106
|
+
return yield* decodeClaims((yield* parts(token)).claims);
|
|
107
|
+
});
|
|
108
|
+
/** Checks `token`'s signature against `key` and returns its claims, still undecoded. */
|
|
109
|
+
const verify = Effect.fn("Jws.verify")(function* (token, key) {
|
|
110
|
+
const { header, claims, signature } = yield* parts(token);
|
|
111
|
+
const signed = yield* bytes(signature);
|
|
112
|
+
const verifier = yield* crypto(() => globalThis.crypto.subtle.importKey("jwk", key, algorithm, false, ["verify"]));
|
|
113
|
+
if (!(yield* crypto(() => globalThis.crypto.subtle.verify(algorithm, verifier, signed, new TextEncoder().encode(`${header}.${claims}`))))) return yield* new JwsError({ reason: "signature" });
|
|
114
|
+
return yield* decodeClaims(claims);
|
|
115
|
+
});
|
|
116
|
+
//#endregion
|
|
117
|
+
export { Header, jws_exports as Jws, JwsError, PrivateKey, PublicKey, fingerprint, fingerprintOf, generate, peek, peekClaims, publicOf, sign, thumbprint, verify };
|
|
118
|
+
|
|
119
|
+
//# sourceMappingURL=jws.mjs.map
|
package/jws.mjs.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jws.mjs","names":[],"sources":["../../src/jws.ts"],"sourcesContent":["import { Effect, Result, Schema } from \"effect\";\nimport { Base64Url } from \"effect/encoding\";\n\n// Compact JWS with Ed25519 (EdDSA) over WebCrypto, so the same code signs on a machine (Node) and\n// verifies in the relay (Node or a Worker).\n\nexport const PublicKey = Schema.Struct({\n\tkty: Schema.Literal(\"OKP\"),\n\tcrv: Schema.Literal(\"Ed25519\"),\n\tx: Schema.String,\n});\nexport type PublicKey = typeof PublicKey.Type;\n\nexport const PrivateKey = Schema.Struct({ ...PublicKey.fields, d: Schema.String });\nexport type PrivateKey = typeof PrivateKey.Type;\n\nexport const Header = Schema.Struct({\n\talg: Schema.Literal(\"EdDSA\"),\n\t/** The signing key's thumbprint, for a key the verifier already holds. */\n\tkid: Schema.optional(Schema.String),\n\t/** The signing key itself, for a request that registers it. */\n\tjwk: Schema.optional(PublicKey),\n});\nexport type Header = typeof Header.Type;\n\nexport class JwsError extends Schema.TaggedError<JwsError>()(\"Jws.JwsError\", {\n\treason: Schema.Literals([\"malformed\", \"signature\", \"crypto\"]),\n}) {}\n\nconst algorithm = { name: \"Ed25519\" } as const;\nconst decodeHeader = Schema.decodeUnknownEffect(Schema.fromJsonString(Header));\nconst decodeJson = Schema.decodeUnknownEffect(Schema.fromJsonString(Schema.Unknown));\nconst crypto = <A>(evaluate: () => Promise<A>) =>\n\tEffect.tryPromise({ try: evaluate, catch: () => new JwsError({ reason: \"crypto\" }) });\nconst bytes = (part: string) =>\n\tResult.match(Base64Url.decode(part), {\n\t\tonFailure: () => Effect.fail(new JwsError({ reason: \"malformed\" })),\n\t\tonSuccess: (decoded) => Effect.succeed(Uint8Array.from(decoded)),\n\t});\n\n/** The public half of a private key. */\nexport const publicOf = (key: PrivateKey): PublicKey => ({ kty: key.kty, crv: key.crv, x: key.x });\n\n/** A fresh Ed25519 keypair as a private JWK; its public half is {@link publicOf}. */\nexport const generate = Effect.fn(\"Jws.generate\")(function* () {\n\tconst pair = yield* crypto(() => globalThis.crypto.subtle.generateKey(\"Ed25519\", true, [\"sign\", \"verify\"]));\n\tif (!(\"privateKey\" in pair)) return yield* new JwsError({ reason: \"crypto\" });\n\tconst jwk = yield* crypto(() => globalThis.crypto.subtle.exportKey(\"jwk\", pair.privateKey));\n\treturn yield* Schema.decodeUnknownEffect(PrivateKey)(jwk).pipe(\n\t\tEffect.mapError(() => new JwsError({ reason: \"crypto\" })),\n\t);\n});\n\n/** The RFC 7638 thumbprint of a public key: base64url SHA-256 of its required members, in order. */\nexport const thumbprint = Effect.fn(\"Jws.thumbprint\")(function* (key: PublicKey) {\n\tconst canonical = `{\"crv\":\"${key.crv}\",\"kty\":\"${key.kty}\",\"x\":\"${key.x}\"}`;\n\tconst digest = yield* crypto(() => globalThis.crypto.subtle.digest(\"SHA-256\", new TextEncoder().encode(canonical)));\n\treturn Base64Url.encode(new Uint8Array(digest));\n});\n\n/** A key's thumbprint as people compare it, `SHA256:<thumbprint>`. */\nexport const fingerprintOf = (thumbprint: string) => `SHA256:${thumbprint}`;\n\n/** A public key as people compare it: {@link fingerprintOf} its thumbprint. */\nexport const fingerprint = (key: PublicKey) => Effect.map(thumbprint(key), fingerprintOf);\n\n/** Signs `claims` with `key`, naming it by `kid` or embedding its public half. */\nexport const sign = Effect.fn(\"Jws.sign\")(function* (\n\tclaims: unknown,\n\tkey: PrivateKey,\n\tname: { readonly kid: string } | { readonly embed: true },\n) {\n\tconst header: Header = \"kid\" in name ? { alg: \"EdDSA\", kid: name.kid } : { alg: \"EdDSA\", jwk: publicOf(key) };\n\tconst input = `${Base64Url.encode(JSON.stringify(header))}.${Base64Url.encode(JSON.stringify(claims))}`;\n\tconst signer = yield* crypto(() => globalThis.crypto.subtle.importKey(\"jwk\", key, algorithm, false, [\"sign\"]));\n\tconst signature = yield* crypto(() =>\n\t\tglobalThis.crypto.subtle.sign(algorithm, signer, new TextEncoder().encode(input)),\n\t);\n\treturn `${input}.${Base64Url.encode(new Uint8Array(signature))}`;\n});\n\nconst parts = (token: string) => {\n\tconst [header, claims, signature, extra] = token.split(\".\");\n\treturn header === undefined || claims === undefined || signature === undefined || extra !== undefined\n\t\t? Effect.fail(new JwsError({ reason: \"malformed\" }))\n\t\t: Effect.succeed({ header, claims, signature });\n};\n\nconst decodeClaims = (part: string) =>\n\tEffect.flatMap(bytes(part), (decoded) =>\n\t\tdecodeJson(new TextDecoder().decode(decoded)).pipe(Effect.mapError(() => new JwsError({ reason: \"malformed\" }))),\n\t);\n\n/** A token's header, read before its signature is checked, to find the key that checks it. */\nexport const peek = Effect.fn(\"Jws.peek\")(function* (token: string) {\n\tconst { header } = yield* parts(token);\n\treturn yield* decodeHeader(new TextDecoder().decode(yield* bytes(header))).pipe(\n\t\tEffect.mapError(() => new JwsError({ reason: \"malformed\" })),\n\t);\n});\n\n/** A token's claims, still undecoded, read without checking its signature: for echoing, never for trusting. */\nexport const peekClaims = Effect.fn(\"Jws.peekClaims\")(function* (token: string) {\n\treturn yield* decodeClaims((yield* parts(token)).claims);\n});\n\n/** Checks `token`'s signature against `key` and returns its claims, still undecoded. */\nexport const verify = Effect.fn(\"Jws.verify\")(function* (token: string, key: PublicKey) {\n\tconst { header, claims, signature } = yield* parts(token);\n\tconst signed = yield* bytes(signature);\n\tconst verifier = yield* crypto(() => globalThis.crypto.subtle.importKey(\"jwk\", key, algorithm, false, [\"verify\"]));\n\tconst valid = yield* crypto(() =>\n\t\tglobalThis.crypto.subtle.verify(algorithm, verifier, signed, new TextEncoder().encode(`${header}.${claims}`)),\n\t);\n\tif (!valid) return yield* new JwsError({ reason: \"signature\" });\n\treturn yield* decodeClaims(claims);\n});\n\nexport * as Jws from \"./jws.ts\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAMA,MAAa,YAAY,OAAO,OAAO;CACtC,KAAK,OAAO,QAAQ,KAAK;CACzB,KAAK,OAAO,QAAQ,SAAS;CAC7B,GAAG,OAAO;AACX,CAAC;AAGD,MAAa,aAAa,OAAO,OAAO;CAAE,GAAG,UAAU;CAAQ,GAAG,OAAO;AAAO,CAAC;AAGjF,MAAa,SAAS,OAAO,OAAO;CACnC,KAAK,OAAO,QAAQ,OAAO;;CAE3B,KAAK,OAAO,SAAS,OAAO,MAAM;;CAElC,KAAK,OAAO,SAAS,SAAS;AAC/B,CAAC;AAGD,IAAa,WAAb,cAA8B,OAAO,YAAsB,CAAC,CAAC,gBAAgB,EAC5E,QAAQ,OAAO,SAAS;CAAC;CAAa;CAAa;AAAQ,CAAC,EAC7D,CAAC,CAAC,CAAC,CAAC;AAEJ,MAAM,YAAY,EAAE,MAAM,UAAU;AACpC,MAAM,eAAe,OAAO,oBAAoB,OAAO,eAAe,MAAM,CAAC;AAC7E,MAAM,aAAa,OAAO,oBAAoB,OAAO,eAAe,OAAO,OAAO,CAAC;AACnF,MAAM,UAAa,aAClB,OAAO,WAA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,OAAO,MAAM,MAAM,CAAC,CAAC,CAAC,CAAC,KAC1E,OAAO,eAAe,IAAI,SAAS,EAAE,QAAQ,YAAY,CAAC,CAAC,CAC5D;AACD,CAAC;;AAGD,MAAa,aAAa,OAAO,GAAG,gBAAgB,CAAC,CAAC,WAAW,OAAe;CAC/E,OAAO,OAAO,cAAc,OAAO,MAAM,KAAK,EAAA,CAAG,MAAM;AACxD,CAAC;;AAGD,MAAa,SAAS,OAAO,GAAG,YAAY,CAAC,CAAC,WAAW,OAAe,KAAgB;CACvF,MAAM,EAAE,QAAQ,QAAQ,cAAc,OAAO,MAAM,KAAK;CACxD,MAAM,SAAS,OAAO,MAAM,SAAS;CACrC,MAAM,WAAW,OAAO,aAAa,WAAW,OAAO,OAAO,UAAU,OAAO,KAAK,WAAW,OAAO,CAAC,QAAQ,CAAC,CAAC;CAIjH,IAAI,EAAC,OAHgB,aACpB,WAAW,OAAO,OAAO,OAAO,WAAW,UAAU,QAAQ,IAAI,YAAY,CAAC,CAAC,OAAO,GAAG,OAAO,GAAG,QAAQ,CAAC,CAC7G,IACY,OAAO,OAAO,IAAI,SAAS,EAAE,QAAQ,YAAY,CAAC;CAC9D,OAAO,OAAO,aAAa,MAAM;AAClC,CAAC"}
|
package/location.d.mts
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { Info as Info$1, ProjectSchema as project_d_exports } from "./project.mjs";
|
|
2
|
+
import { a as space_d_exports, n as Info$2 } from "./space-CR-9UxdT.mjs";
|
|
3
|
+
import { Schema } from "effect";
|
|
4
|
+
declare namespace location_d_exports {
|
|
5
|
+
export { DirectoryNotFoundError, Error, Info, location_d_exports as Location, NotDirectoryError };
|
|
6
|
+
}
|
|
7
|
+
declare const Info_base: Schema.Class<Info, Schema.Struct<{
|
|
8
|
+
/** The absolute cwd tools run in; `space.location` is the root it lives under. */
|
|
9
|
+
readonly directory: Schema.brand<Schema.String, "AbsolutePath">;
|
|
10
|
+
readonly space: typeof Info$2;
|
|
11
|
+
readonly project: typeof Info$1;
|
|
12
|
+
}>, {}>;
|
|
13
|
+
/**
|
|
14
|
+
* Where work happens: a directory inside a space.
|
|
15
|
+
*
|
|
16
|
+
* The pair (space, directory) is the key. A path alone does not name a place —
|
|
17
|
+
* `/app/repo` on the host and `/app/repo` inside a remote sandbox are different
|
|
18
|
+
* trees wearing the same spelling — so the space carries the env and the
|
|
19
|
+
* root it lives under (`space.location`), and `directory` is the absolute cwd
|
|
20
|
+
* equal to or beneath that root. Sessions sharing a space share the project;
|
|
21
|
+
* worktree relationships stay a Project concern beneath it.
|
|
22
|
+
*
|
|
23
|
+
* **Both halves come from the mount, and nothing overrides them.**
|
|
24
|
+
* A Location is a directory *within* a mounted namespace — the mount has to be
|
|
25
|
+
* resolved first, the way a volume is mounted before any path on it means
|
|
26
|
+
* anything — and once it is, the namespace and the working directory are already
|
|
27
|
+
* in scope. Re-declaring them would be two spellings of one value, free to drift;
|
|
28
|
+
* a Location pointing somewhere its own shell is not becomes unrepresentable
|
|
29
|
+
* rather than merely avoided by discipline.
|
|
30
|
+
*
|
|
31
|
+
* Only the shape and its errors live here. Building one needs Project, Space, Repo and Git,
|
|
32
|
+
* which belong to the harness; a plugin receives a resolved `Info` on its context, and the
|
|
33
|
+
* service tag for the live one is in `@codeworksh/plugin/location`.
|
|
34
|
+
*/
|
|
35
|
+
export declare class Info extends Info_base {}
|
|
36
|
+
declare const DirectoryNotFoundError_base: Schema.Class<DirectoryNotFoundError, Schema.TaggedStruct<"Location.DirectoryNotFoundError", {
|
|
37
|
+
directory: Schema.brand<Schema.String, "AbsolutePath">;
|
|
38
|
+
sandboxInstanceId: Schema.brand<Schema.String, "SandboxInstance.ID"> & {
|
|
39
|
+
local: string & import("effect/Brand").Brand<"SandboxInstance.ID">;
|
|
40
|
+
create: () => string & import("effect/Brand").Brand<"SandboxInstance.ID">;
|
|
41
|
+
};
|
|
42
|
+
}>, import("effect/Cause").YieldableError>;
|
|
43
|
+
export declare class DirectoryNotFoundError extends DirectoryNotFoundError_base {}
|
|
44
|
+
declare const NotDirectoryError_base: Schema.Class<NotDirectoryError, Schema.TaggedStruct<"Location.NotDirectoryError", {
|
|
45
|
+
directory: Schema.brand<Schema.String, "AbsolutePath">;
|
|
46
|
+
sandboxInstanceId: Schema.brand<Schema.String, "SandboxInstance.ID"> & {
|
|
47
|
+
local: string & import("effect/Brand").Brand<"SandboxInstance.ID">;
|
|
48
|
+
create: () => string & import("effect/Brand").Brand<"SandboxInstance.ID">;
|
|
49
|
+
};
|
|
50
|
+
}>, import("effect/Cause").YieldableError>;
|
|
51
|
+
export declare class NotDirectoryError extends NotDirectoryError_base {}
|
|
52
|
+
export type Error = DirectoryNotFoundError | NotDirectoryError;
|
|
53
|
+
//#endregion
|
|
54
|
+
export { location_d_exports as Location };
|
|
55
|
+
//# sourceMappingURL=location.d.mts.map
|
package/location.mjs
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.mjs";
|
|
2
|
+
import { AbsolutePath } from "./common.mjs";
|
|
3
|
+
import { ID } from "./sandbox/instance.mjs";
|
|
4
|
+
import { Info as Info$1 } from "./project.mjs";
|
|
5
|
+
import { Info as Info$2 } from "./space.mjs";
|
|
6
|
+
import { Schema } from "effect";
|
|
7
|
+
//#region src/location.ts
|
|
8
|
+
var location_exports = /* @__PURE__ */ __exportAll({
|
|
9
|
+
DirectoryNotFoundError: () => DirectoryNotFoundError,
|
|
10
|
+
Info: () => Info,
|
|
11
|
+
Location: () => location_exports,
|
|
12
|
+
NotDirectoryError: () => NotDirectoryError
|
|
13
|
+
});
|
|
14
|
+
/**
|
|
15
|
+
* Where work happens: a directory inside a space.
|
|
16
|
+
*
|
|
17
|
+
* The pair (space, directory) is the key. A path alone does not name a place —
|
|
18
|
+
* `/app/repo` on the host and `/app/repo` inside a remote sandbox are different
|
|
19
|
+
* trees wearing the same spelling — so the space carries the env and the
|
|
20
|
+
* root it lives under (`space.location`), and `directory` is the absolute cwd
|
|
21
|
+
* equal to or beneath that root. Sessions sharing a space share the project;
|
|
22
|
+
* worktree relationships stay a Project concern beneath it.
|
|
23
|
+
*
|
|
24
|
+
* **Both halves come from the mount, and nothing overrides them.**
|
|
25
|
+
* A Location is a directory *within* a mounted namespace — the mount has to be
|
|
26
|
+
* resolved first, the way a volume is mounted before any path on it means
|
|
27
|
+
* anything — and once it is, the namespace and the working directory are already
|
|
28
|
+
* in scope. Re-declaring them would be two spellings of one value, free to drift;
|
|
29
|
+
* a Location pointing somewhere its own shell is not becomes unrepresentable
|
|
30
|
+
* rather than merely avoided by discipline.
|
|
31
|
+
*
|
|
32
|
+
* Only the shape and its errors live here. Building one needs Project, Space, Repo and Git,
|
|
33
|
+
* which belong to the harness; a plugin receives a resolved `Info` on its context, and the
|
|
34
|
+
* service tag for the live one is in `@codeworksh/plugin/location`.
|
|
35
|
+
*/
|
|
36
|
+
var Info = class extends Schema.Class("Location.Info")({
|
|
37
|
+
/** The absolute cwd tools run in; `space.location` is the root it lives under. */
|
|
38
|
+
directory: AbsolutePath,
|
|
39
|
+
space: Info$2,
|
|
40
|
+
project: Info$1
|
|
41
|
+
}) {};
|
|
42
|
+
const Fields = {
|
|
43
|
+
directory: AbsolutePath,
|
|
44
|
+
sandboxInstanceId: ID
|
|
45
|
+
};
|
|
46
|
+
var DirectoryNotFoundError = class extends Schema.TaggedError()("Location.DirectoryNotFoundError", Fields) {};
|
|
47
|
+
var NotDirectoryError = class extends Schema.TaggedError()("Location.NotDirectoryError", Fields) {};
|
|
48
|
+
//#endregion
|
|
49
|
+
export { DirectoryNotFoundError, Info, location_exports as Location, NotDirectoryError };
|
|
50
|
+
|
|
51
|
+
//# sourceMappingURL=location.mjs.map
|
package/location.mjs.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"location.mjs","names":["SpaceSchema.Info","ProjectSchema.Info","SandboxInstance.ID"],"sources":["../../src/location.ts"],"sourcesContent":["import { Schema } from \"effect\";\nimport { ProjectSchema } from \"./project.ts\";\nimport { AbsolutePath } from \"./common.ts\";\nimport { SandboxInstance } from \"./sandbox/instance.ts\";\nimport { SpaceSchema } from \"./space.ts\";\n\n/**\n * Where work happens: a directory inside a space.\n *\n * The pair (space, directory) is the key. A path alone does not name a place —\n * `/app/repo` on the host and `/app/repo` inside a remote sandbox are different\n * trees wearing the same spelling — so the space carries the env and the\n * root it lives under (`space.location`), and `directory` is the absolute cwd\n * equal to or beneath that root. Sessions sharing a space share the project;\n * worktree relationships stay a Project concern beneath it.\n *\n * **Both halves come from the mount, and nothing overrides them.**\n * A Location is a directory *within* a mounted namespace — the mount has to be\n * resolved first, the way a volume is mounted before any path on it means\n * anything — and once it is, the namespace and the working directory are already\n * in scope. Re-declaring them would be two spellings of one value, free to drift;\n * a Location pointing somewhere its own shell is not becomes unrepresentable\n * rather than merely avoided by discipline.\n *\n * Only the shape and its errors live here. Building one needs Project, Space, Repo and Git,\n * which belong to the harness; a plugin receives a resolved `Info` on its context, and the\n * service tag for the live one is in `@codeworksh/plugin/location`.\n */\nexport class Info extends Schema.Class<Info>(\"Location.Info\")({\n\t/** The absolute cwd tools run in; `space.location` is the root it lives under. */\n\tdirectory: AbsolutePath,\n\tspace: SpaceSchema.Info,\n\tproject: ProjectSchema.Info,\n}) {}\n\nconst Fields = {\n\tdirectory: AbsolutePath,\n\tsandboxInstanceId: SandboxInstance.ID,\n};\n\nexport class DirectoryNotFoundError extends Schema.TaggedError<DirectoryNotFoundError>()(\n\t\"Location.DirectoryNotFoundError\",\n\tFields,\n) {}\n\nexport class NotDirectoryError extends Schema.TaggedError<NotDirectoryError>()(\"Location.NotDirectoryError\", Fields) {}\n\nexport type Error = DirectoryNotFoundError | NotDirectoryError;\n\nexport * as Location from \"./location.ts\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4BA,IAAa,OAAb,cAA0B,OAAO,MAAY,eAAe,CAAC,CAAC;;CAE7D,WAAW;CACX,OAAOA;CACP,SAASC;AACV,CAAC,CAAC,CAAC,CAAC;AAEJ,MAAM,SAAS;CACd,WAAW;CACX,mBAAmBC;AACpB;AAEA,IAAa,yBAAb,cAA4C,OAAO,YAAoC,CAAC,CACvF,mCACA,MACD,CAAC,CAAC,CAAC;AAEH,IAAa,oBAAb,cAAuC,OAAO,YAA+B,CAAC,CAAC,8BAA8B,MAAM,CAAC,CAAC,CAAC"}
|
package/machine.d.mts
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { Schema } from "effect";
|
|
2
|
+
declare namespace machine_d_exports {
|
|
3
|
+
export { ConnectError, ConnectEvent, Disconnect, Disconnected, machine_d_exports as Machine, Status };
|
|
4
|
+
}
|
|
5
|
+
/** This machine and the workspaces it is connected to, from its `machine.json`. */
|
|
6
|
+
export declare const Status: Schema.Struct<{
|
|
7
|
+
/** None before the machine's first connect gives it an identity. */
|
|
8
|
+
readonly id: Schema.NullOr<Schema.String>;
|
|
9
|
+
/** The OS's name for the host, read fresh. */
|
|
10
|
+
readonly localHostName: Schema.String;
|
|
11
|
+
/** The user's own name for it, shown in place of `localHostName` when set. */
|
|
12
|
+
readonly givenName: Schema.NullOr<Schema.String>;
|
|
13
|
+
/**
|
|
14
|
+
* Each link with the thumbprint of its key: a relay row under another key is not this machine's. A
|
|
15
|
+
* leaving link was ended here while the relay couldn't be reached; it is revoked once it can. Older
|
|
16
|
+
* machines don't report it.
|
|
17
|
+
*/
|
|
18
|
+
readonly workspaces: Schema.$Array<Schema.Struct<{
|
|
19
|
+
readonly id: Schema.String;
|
|
20
|
+
readonly name: Schema.String;
|
|
21
|
+
readonly keyId: Schema.String;
|
|
22
|
+
readonly leaving: Schema.optionalKey<Schema.Boolean>;
|
|
23
|
+
}>>;
|
|
24
|
+
}>;
|
|
25
|
+
export type Status = typeof Status.Type;
|
|
26
|
+
export declare const Disconnect: Schema.Struct<{
|
|
27
|
+
readonly workspaceId: Schema.String;
|
|
28
|
+
readonly keyId: Schema.String;
|
|
29
|
+
}>;
|
|
30
|
+
/** A disconnect: this machine afterwards, and whether the relay confirmed; if not, the link is left leaving. */
|
|
31
|
+
export declare const Disconnected: Schema.Struct<{
|
|
32
|
+
readonly status: Schema.Struct<{
|
|
33
|
+
/** None before the machine's first connect gives it an identity. */
|
|
34
|
+
readonly id: Schema.NullOr<Schema.String>;
|
|
35
|
+
/** The OS's name for the host, read fresh. */
|
|
36
|
+
readonly localHostName: Schema.String;
|
|
37
|
+
/** The user's own name for it, shown in place of `localHostName` when set. */
|
|
38
|
+
readonly givenName: Schema.NullOr<Schema.String>;
|
|
39
|
+
/**
|
|
40
|
+
* Each link with the thumbprint of its key: a relay row under another key is not this machine's. A
|
|
41
|
+
* leaving link was ended here while the relay couldn't be reached; it is revoked once it can. Older
|
|
42
|
+
* machines don't report it.
|
|
43
|
+
*/
|
|
44
|
+
readonly workspaces: Schema.$Array<Schema.Struct<{
|
|
45
|
+
readonly id: Schema.String;
|
|
46
|
+
readonly name: Schema.String;
|
|
47
|
+
readonly keyId: Schema.String;
|
|
48
|
+
readonly leaving: Schema.optionalKey<Schema.Boolean>;
|
|
49
|
+
}>>;
|
|
50
|
+
}>;
|
|
51
|
+
readonly revoked: Schema.Boolean;
|
|
52
|
+
}>;
|
|
53
|
+
export type Disconnected = typeof Disconnected.Type;
|
|
54
|
+
/** A connect's progress: the code to approve, then the link once a member approved it. */
|
|
55
|
+
export declare const ConnectEvent: Schema.Union<readonly [Schema.TaggedStruct<"Code", {
|
|
56
|
+
readonly userCode: Schema.String;
|
|
57
|
+
}>, Schema.TaggedStruct<"Connected", {
|
|
58
|
+
readonly connected: Schema.Struct<{
|
|
59
|
+
readonly machineId: Schema.String;
|
|
60
|
+
readonly workspace: Schema.Struct<{
|
|
61
|
+
readonly id: Schema.String;
|
|
62
|
+
readonly name: Schema.String;
|
|
63
|
+
}>;
|
|
64
|
+
readonly account: Schema.Struct<{
|
|
65
|
+
readonly id: Schema.String;
|
|
66
|
+
readonly name: Schema.NullOr<Schema.String>;
|
|
67
|
+
}>;
|
|
68
|
+
}>;
|
|
69
|
+
}>]>;
|
|
70
|
+
export type ConnectEvent = typeof ConnectEvent.Type;
|
|
71
|
+
declare const ConnectError_base: Schema.Class<ConnectError, Schema.TaggedStruct<"Machine.ConnectError", {
|
|
72
|
+
readonly message: Schema.String;
|
|
73
|
+
}>, import("effect/Cause").YieldableError>;
|
|
74
|
+
export declare class ConnectError extends ConnectError_base {}
|
|
75
|
+
//#endregion
|
|
76
|
+
export { machine_d_exports as Machine };
|
|
77
|
+
//# sourceMappingURL=machine.d.mts.map
|