@smthrs/sync 0.0.0-stage → 1.0.0-rc.4
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/CHANGELOG.md +208 -0
- package/LICENSE +21 -0
- package/README.md +208 -2
- package/dist/cjs/BranchCommands.d.ts +228 -0
- package/dist/cjs/BranchCommands.d.ts.map +1 -0
- package/dist/cjs/BranchCommands.js +316 -0
- package/dist/cjs/BranchCommands.js.map +7 -0
- package/dist/cjs/BranchIds.d.ts +65 -0
- package/dist/cjs/BranchIds.d.ts.map +1 -0
- package/dist/cjs/BranchIds.js +53 -0
- package/dist/cjs/BranchIds.js.map +7 -0
- package/dist/cjs/BranchPresence.d.ts +195 -0
- package/dist/cjs/BranchPresence.d.ts.map +1 -0
- package/dist/cjs/BranchPresence.js +276 -0
- package/dist/cjs/BranchPresence.js.map +7 -0
- package/dist/cjs/BranchProjection.d.ts +179 -0
- package/dist/cjs/BranchProjection.d.ts.map +1 -0
- package/dist/cjs/BranchProjection.js +197 -0
- package/dist/cjs/BranchProjection.js.map +7 -0
- package/dist/cjs/BranchProtocol.d.ts +415 -0
- package/dist/cjs/BranchProtocol.d.ts.map +1 -0
- package/dist/cjs/BranchProtocol.js +172 -0
- package/dist/cjs/BranchProtocol.js.map +7 -0
- package/dist/cjs/BranchRpcs.d.ts +177 -0
- package/dist/cjs/BranchRpcs.d.ts.map +1 -0
- package/dist/cjs/BranchRpcs.js +85 -0
- package/dist/cjs/BranchRpcs.js.map +7 -0
- package/dist/cjs/BranchServer.d.ts +55 -0
- package/dist/cjs/BranchServer.d.ts.map +1 -0
- package/dist/cjs/BranchServer.js +147 -0
- package/dist/cjs/BranchServer.js.map +7 -0
- package/dist/cjs/BranchShare.d.ts +159 -0
- package/dist/cjs/BranchShare.d.ts.map +1 -0
- package/dist/cjs/BranchShare.js +147 -0
- package/dist/cjs/BranchShare.js.map +7 -0
- package/dist/cjs/RunCatalog.d.ts +207 -0
- package/dist/cjs/RunCatalog.d.ts.map +1 -0
- package/dist/cjs/RunCatalog.js +122 -0
- package/dist/cjs/RunCatalog.js.map +7 -0
- package/dist/cjs/SyncAuth.d.ts +70 -0
- package/dist/cjs/SyncAuth.d.ts.map +1 -0
- package/dist/cjs/SyncAuth.js +109 -0
- package/dist/cjs/SyncAuth.js.map +7 -0
- package/dist/cjs/SyncClient.d.ts +274 -0
- package/dist/cjs/SyncClient.d.ts.map +1 -0
- package/dist/cjs/SyncClient.js +474 -0
- package/dist/cjs/SyncClient.js.map +7 -0
- package/dist/cjs/SyncError.d.ts +107 -0
- package/dist/cjs/SyncError.d.ts.map +1 -0
- package/dist/cjs/SyncError.js +110 -0
- package/dist/cjs/SyncError.js.map +7 -0
- package/dist/cjs/SyncPrincipal.d.ts +100 -0
- package/dist/cjs/SyncPrincipal.d.ts.map +1 -0
- package/dist/cjs/SyncPrincipal.js +48 -0
- package/dist/cjs/SyncPrincipal.js.map +7 -0
- package/dist/cjs/SyncProtocol.d.ts +592 -0
- package/dist/cjs/SyncProtocol.d.ts.map +1 -0
- package/dist/cjs/SyncProtocol.js +165 -0
- package/dist/cjs/SyncProtocol.js.map +7 -0
- package/dist/cjs/SyncRpcs.d.ts +92 -0
- package/dist/cjs/SyncRpcs.d.ts.map +1 -0
- package/dist/cjs/SyncRpcs.js +35 -0
- package/dist/cjs/SyncRpcs.js.map +7 -0
- package/dist/cjs/SyncServer.d.ts +184 -0
- package/dist/cjs/SyncServer.d.ts.map +1 -0
- package/dist/cjs/SyncServer.js +513 -0
- package/dist/cjs/SyncServer.js.map +7 -0
- package/dist/cjs/WorkspaceShare.d.ts +174 -0
- package/dist/cjs/WorkspaceShare.d.ts.map +1 -0
- package/dist/cjs/WorkspaceShare.js +149 -0
- package/dist/cjs/WorkspaceShare.js.map +7 -0
- package/dist/cjs/index.d.ts +91 -0
- package/dist/cjs/index.d.ts.map +1 -0
- package/dist/cjs/index.js +67 -0
- package/dist/cjs/index.js.map +7 -0
- package/dist/cjs/internal/Admission.d.ts +43 -0
- package/dist/cjs/internal/Admission.d.ts.map +1 -0
- package/dist/cjs/internal/Admission.js +90 -0
- package/dist/cjs/internal/Admission.js.map +7 -0
- package/dist/cjs/internal/CauseText.d.ts +55 -0
- package/dist/cjs/internal/CauseText.d.ts.map +1 -0
- package/dist/cjs/internal/CauseText.js +38 -0
- package/dist/cjs/internal/CauseText.js.map +7 -0
- package/dist/cjs/internal/JournalErrorCode.d.ts +23 -0
- package/dist/cjs/internal/JournalErrorCode.d.ts.map +1 -0
- package/dist/cjs/internal/JournalErrorCode.js +34 -0
- package/dist/cjs/internal/JournalErrorCode.js.map +7 -0
- package/dist/cjs/internal/PolicyOptions.d.ts +57 -0
- package/dist/cjs/internal/PolicyOptions.d.ts.map +1 -0
- package/dist/cjs/internal/PolicyOptions.js +62 -0
- package/dist/cjs/internal/PolicyOptions.js.map +7 -0
- package/dist/cjs/internal/ProtocolVersion.d.ts +17 -0
- package/dist/cjs/internal/ProtocolVersion.d.ts.map +1 -0
- package/dist/cjs/internal/ProtocolVersion.js +44 -0
- package/dist/cjs/internal/ProtocolVersion.js.map +7 -0
- package/dist/cjs/internal/ShareSigner.d.ts +173 -0
- package/dist/cjs/internal/ShareSigner.d.ts.map +1 -0
- package/dist/cjs/internal/ShareSigner.js +150 -0
- package/dist/cjs/internal/ShareSigner.js.map +7 -0
- package/dist/cjs/internal/SnapshotBoundary.d.ts +17 -0
- package/dist/cjs/internal/SnapshotBoundary.d.ts.map +1 -0
- package/dist/cjs/internal/SnapshotBoundary.js +97 -0
- package/dist/cjs/internal/SnapshotBoundary.js.map +7 -0
- package/dist/cjs/package.json +1 -0
- package/dist/cjs/test/TestSocket.d.ts +55 -0
- package/dist/cjs/test/TestSocket.d.ts.map +1 -0
- package/dist/cjs/test/TestSocket.js +145 -0
- package/dist/cjs/test/TestSocket.js.map +7 -0
- package/dist/cjs/test/TestSync.d.ts +54 -0
- package/dist/cjs/test/TestSync.d.ts.map +1 -0
- package/dist/cjs/test/TestSync.js +96 -0
- package/dist/cjs/test/TestSync.js.map +7 -0
- package/dist/esm/BranchCommands.d.ts +228 -0
- package/dist/esm/BranchCommands.d.ts.map +1 -0
- package/dist/esm/BranchCommands.js +496 -0
- package/dist/esm/BranchCommands.js.map +1 -0
- package/dist/esm/BranchIds.d.ts +65 -0
- package/dist/esm/BranchIds.d.ts.map +1 -0
- package/dist/esm/BranchIds.js +61 -0
- package/dist/esm/BranchIds.js.map +1 -0
- package/dist/esm/BranchPresence.d.ts +195 -0
- package/dist/esm/BranchPresence.d.ts.map +1 -0
- package/dist/esm/BranchPresence.js +361 -0
- package/dist/esm/BranchPresence.js.map +1 -0
- package/dist/esm/BranchProjection.d.ts +179 -0
- package/dist/esm/BranchProjection.d.ts.map +1 -0
- package/dist/esm/BranchProjection.js +269 -0
- package/dist/esm/BranchProjection.js.map +1 -0
- package/dist/esm/BranchProtocol.d.ts +415 -0
- package/dist/esm/BranchProtocol.d.ts.map +1 -0
- package/dist/esm/BranchProtocol.js +323 -0
- package/dist/esm/BranchProtocol.js.map +1 -0
- package/dist/esm/BranchRpcs.d.ts +177 -0
- package/dist/esm/BranchRpcs.d.ts.map +1 -0
- package/dist/esm/BranchRpcs.js +103 -0
- package/dist/esm/BranchRpcs.js.map +1 -0
- package/dist/esm/BranchServer.d.ts +55 -0
- package/dist/esm/BranchServer.d.ts.map +1 -0
- package/dist/esm/BranchServer.js +168 -0
- package/dist/esm/BranchServer.js.map +1 -0
- package/dist/esm/BranchShare.d.ts +159 -0
- package/dist/esm/BranchShare.d.ts.map +1 -0
- package/dist/esm/BranchShare.js +213 -0
- package/dist/esm/BranchShare.js.map +1 -0
- package/dist/esm/RunCatalog.d.ts +207 -0
- package/dist/esm/RunCatalog.d.ts.map +1 -0
- package/dist/esm/RunCatalog.js +196 -0
- package/dist/esm/RunCatalog.js.map +1 -0
- package/dist/esm/SyncAuth.d.ts +70 -0
- package/dist/esm/SyncAuth.d.ts.map +1 -0
- package/dist/esm/SyncAuth.js +119 -0
- package/dist/esm/SyncAuth.js.map +1 -0
- package/dist/esm/SyncClient.d.ts +274 -0
- package/dist/esm/SyncClient.d.ts.map +1 -0
- package/dist/esm/SyncClient.js +586 -0
- package/dist/esm/SyncClient.js.map +1 -0
- package/dist/esm/SyncError.d.ts +107 -0
- package/dist/esm/SyncError.d.ts.map +1 -0
- package/dist/esm/SyncError.js +133 -0
- package/dist/esm/SyncError.js.map +1 -0
- package/dist/esm/SyncPrincipal.d.ts +100 -0
- package/dist/esm/SyncPrincipal.d.ts.map +1 -0
- package/dist/esm/SyncPrincipal.js +58 -0
- package/dist/esm/SyncPrincipal.js.map +1 -0
- package/dist/esm/SyncProtocol.d.ts +592 -0
- package/dist/esm/SyncProtocol.d.ts.map +1 -0
- package/dist/esm/SyncProtocol.js +434 -0
- package/dist/esm/SyncProtocol.js.map +1 -0
- package/dist/esm/SyncRpcs.d.ts +92 -0
- package/dist/esm/SyncRpcs.d.ts.map +1 -0
- package/dist/esm/SyncRpcs.js +35 -0
- package/dist/esm/SyncRpcs.js.map +1 -0
- package/dist/esm/SyncServer.d.ts +184 -0
- package/dist/esm/SyncServer.d.ts.map +1 -0
- package/dist/esm/SyncServer.js +897 -0
- package/dist/esm/SyncServer.js.map +1 -0
- package/dist/esm/WorkspaceShare.d.ts +174 -0
- package/dist/esm/WorkspaceShare.d.ts.map +1 -0
- package/dist/esm/WorkspaceShare.js +208 -0
- package/dist/esm/WorkspaceShare.js.map +1 -0
- package/dist/esm/index.d.ts +91 -0
- package/dist/esm/index.d.ts.map +1 -0
- package/dist/esm/index.js +91 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/internal/Admission.d.ts +43 -0
- package/dist/esm/internal/Admission.d.ts.map +1 -0
- package/dist/esm/internal/Admission.js +80 -0
- package/dist/esm/internal/Admission.js.map +1 -0
- package/dist/esm/internal/CauseText.d.ts +55 -0
- package/dist/esm/internal/CauseText.d.ts.map +1 -0
- package/dist/esm/internal/CauseText.js +67 -0
- package/dist/esm/internal/CauseText.js.map +1 -0
- package/dist/esm/internal/JournalErrorCode.d.ts +23 -0
- package/dist/esm/internal/JournalErrorCode.d.ts.map +1 -0
- package/dist/esm/internal/JournalErrorCode.js +44 -0
- package/dist/esm/internal/JournalErrorCode.js.map +1 -0
- package/dist/esm/internal/PolicyOptions.d.ts +57 -0
- package/dist/esm/internal/PolicyOptions.d.ts.map +1 -0
- package/dist/esm/internal/PolicyOptions.js +70 -0
- package/dist/esm/internal/PolicyOptions.js.map +1 -0
- package/dist/esm/internal/ProtocolVersion.d.ts +17 -0
- package/dist/esm/internal/ProtocolVersion.d.ts.map +1 -0
- package/dist/esm/internal/ProtocolVersion.js +24 -0
- package/dist/esm/internal/ProtocolVersion.js.map +1 -0
- package/dist/esm/internal/ShareSigner.d.ts +173 -0
- package/dist/esm/internal/ShareSigner.d.ts.map +1 -0
- package/dist/esm/internal/ShareSigner.js +219 -0
- package/dist/esm/internal/ShareSigner.js.map +1 -0
- package/dist/esm/internal/SnapshotBoundary.d.ts +17 -0
- package/dist/esm/internal/SnapshotBoundary.d.ts.map +1 -0
- package/dist/esm/internal/SnapshotBoundary.js +68 -0
- package/dist/esm/internal/SnapshotBoundary.js.map +1 -0
- package/dist/esm/test/TestSocket.d.ts +55 -0
- package/dist/esm/test/TestSocket.d.ts.map +1 -0
- package/dist/esm/test/TestSocket.js +128 -0
- package/dist/esm/test/TestSocket.js.map +1 -0
- package/dist/esm/test/TestSync.d.ts +54 -0
- package/dist/esm/test/TestSync.d.ts.map +1 -0
- package/dist/esm/test/TestSync.js +76 -0
- package/dist/esm/test/TestSync.js.map +1 -0
- package/docs/README.md +156 -0
- package/docs/api.md +328 -0
- package/docs/concepts/authorization.md +117 -0
- package/docs/concepts/branches.md +195 -0
- package/docs/concepts/compaction.md +144 -0
- package/docs/concepts/replay-then-follow.md +129 -0
- package/docs/concepts/scopes-and-cursors.md +135 -0
- package/docs/guides/authorize-a-connection.md +174 -0
- package/docs/guides/follow-a-run.md +174 -0
- package/docs/guides/handle-a-compacted-run.md +158 -0
- package/docs/guides/list-workspace-runs.md +120 -0
- package/docs/guides/run-a-long-soak.md +80 -0
- package/docs/guides/serve-the-read-path.md +146 -0
- package/docs/guides/test-a-follower.md +273 -0
- package/docs/installation.md +92 -0
- package/docs/protocol.md +183 -0
- package/docs/quickstart.md +159 -0
- package/docs/troubleshooting.md +234 -0
- package/package.json +304 -3
- package/src/BranchCommands.ts +684 -0
- package/src/BranchIds.ts +76 -0
- package/src/BranchPresence.ts +512 -0
- package/src/BranchProjection.ts +308 -0
- package/src/BranchProtocol.ts +411 -0
- package/src/BranchRpcs.ts +163 -0
- package/src/BranchServer.ts +202 -0
- package/src/BranchShare.ts +297 -0
- package/src/RunCatalog.ts +308 -0
- package/src/SyncAuth.ts +146 -0
- package/src/SyncClient.ts +902 -0
- package/src/SyncError.ts +147 -0
- package/src/SyncPrincipal.ts +115 -0
- package/src/SyncProtocol.ts +594 -0
- package/src/SyncRpcs.ts +40 -0
- package/src/SyncServer.ts +1184 -0
- package/src/WorkspaceShare.ts +292 -0
- package/src/index.ts +107 -0
- package/src/internal/Admission.ts +119 -0
- package/src/internal/CauseText.ts +74 -0
- package/src/internal/JournalErrorCode.ts +46 -0
- package/src/internal/PolicyOptions.ts +97 -0
- package/src/internal/ProtocolVersion.ts +28 -0
- package/src/internal/ShareSigner.ts +300 -0
- package/src/internal/SnapshotBoundary.ts +91 -0
- package/src/test/TestSocket.ts +192 -0
- package/src/test/TestSync.ts +113 -0
|
@@ -0,0 +1,415 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The branch collaboration contract: a branch is one shared live document.
|
|
3
|
+
*
|
|
4
|
+
* A branch has no store of its own. Its durable state is exactly one journal
|
|
5
|
+
* run — `branchRunId` is the only mapping — so every replication guarantee the
|
|
6
|
+
* rest of this package already provides (canonical per-run `seq`, exclusive
|
|
7
|
+
* cursors, gap detection, resumable follow) carries over unchanged, and
|
|
8
|
+
* multiplayer never introduces a second source of truth.
|
|
9
|
+
*
|
|
10
|
+
* Ephemeral collaboration state (presence, cursors) deliberately has no
|
|
11
|
+
* representation here beyond the wire shapes: it is leased, never journalled.
|
|
12
|
+
*
|
|
13
|
+
* @since 0.1.0
|
|
14
|
+
*/
|
|
15
|
+
import * as JournalEvent from "@smthrs/journal/JournalEvent";
|
|
16
|
+
import * as Schema from "effect/Schema";
|
|
17
|
+
/**
|
|
18
|
+
* Schema for the identifier of one collaboratively edited branch.
|
|
19
|
+
*
|
|
20
|
+
* @category schemas
|
|
21
|
+
* @since 0.1.0
|
|
22
|
+
*/
|
|
23
|
+
export declare const BranchId: Schema.brand<Schema.NonEmptyString, "@smthrs/sync/BranchProtocol/BranchId">;
|
|
24
|
+
/**
|
|
25
|
+
* Identifier of one collaboratively edited branch.
|
|
26
|
+
*
|
|
27
|
+
* @category models
|
|
28
|
+
* @since 0.1.0
|
|
29
|
+
*/
|
|
30
|
+
export type BranchId = typeof BranchId.Type;
|
|
31
|
+
/**
|
|
32
|
+
* Schema for the identifier of one connected client.
|
|
33
|
+
*
|
|
34
|
+
* @category schemas
|
|
35
|
+
* @since 0.1.0
|
|
36
|
+
*/
|
|
37
|
+
export declare const ParticipantId: Schema.brand<Schema.NonEmptyString, "@smthrs/sync/BranchProtocol/ParticipantId">;
|
|
38
|
+
/**
|
|
39
|
+
* Identifier of one connected client.
|
|
40
|
+
*
|
|
41
|
+
* @category models
|
|
42
|
+
* @since 0.1.0
|
|
43
|
+
*/
|
|
44
|
+
export type ParticipantId = typeof ParticipantId.Type;
|
|
45
|
+
/**
|
|
46
|
+
* Schema for a client-minted command identifier.
|
|
47
|
+
*
|
|
48
|
+
* The identifier is minted once per user intent and reused across optimistic
|
|
49
|
+
* application, retransmission, and concurrent submission, which is what makes
|
|
50
|
+
* it the idempotency key rather than a correlation id.
|
|
51
|
+
*
|
|
52
|
+
* @category schemas
|
|
53
|
+
* @since 0.1.0
|
|
54
|
+
*/
|
|
55
|
+
export declare const CommandId: Schema.brand<Schema.NonEmptyString, "@smthrs/sync/BranchProtocol/CommandId">;
|
|
56
|
+
/**
|
|
57
|
+
* Client-minted command identifier used as the idempotency key.
|
|
58
|
+
*
|
|
59
|
+
* @category models
|
|
60
|
+
* @since 0.1.0
|
|
61
|
+
*/
|
|
62
|
+
export type CommandId = typeof CommandId.Type;
|
|
63
|
+
/**
|
|
64
|
+
* Schema for the access a share capability grants.
|
|
65
|
+
*
|
|
66
|
+
* @category schemas
|
|
67
|
+
* @since 0.1.0
|
|
68
|
+
*/
|
|
69
|
+
export declare const Access: Schema.Literals<readonly ["read", "write"]>;
|
|
70
|
+
/**
|
|
71
|
+
* The access a share capability grants.
|
|
72
|
+
*
|
|
73
|
+
* @category models
|
|
74
|
+
* @since 0.1.0
|
|
75
|
+
*/
|
|
76
|
+
export type Access = typeof Access.Type;
|
|
77
|
+
/**
|
|
78
|
+
* The journal run backing a branch document.
|
|
79
|
+
*
|
|
80
|
+
* The prefix keeps branch runs from colliding with engine runs in the same
|
|
81
|
+
* workspace journal, and makes the mapping reversible for tooling.
|
|
82
|
+
*
|
|
83
|
+
* @category constructors
|
|
84
|
+
* @since 0.1.0
|
|
85
|
+
*/
|
|
86
|
+
export declare const branchRunId: (branchId: BranchId) => JournalEvent.RunId;
|
|
87
|
+
/**
|
|
88
|
+
* The branch a journal run belongs to, or `null` for a non-branch run.
|
|
89
|
+
*
|
|
90
|
+
* The bare prefix is a non-branch run, not a branch with an empty id.
|
|
91
|
+
* `BranchId` is a branded `NonEmptyString`, so branding `""` would produce a
|
|
92
|
+
* value the brand forbids and hand it to `share.verify` as the branch under
|
|
93
|
+
* authorization. Refusing it here keeps the brand's promise true everywhere
|
|
94
|
+
* downstream of this function.
|
|
95
|
+
*
|
|
96
|
+
* @category constructors
|
|
97
|
+
* @since 0.1.0
|
|
98
|
+
*/
|
|
99
|
+
export declare const branchOfRunId: (runId: JournalEvent.RunId) => BranchId | null;
|
|
100
|
+
/**
|
|
101
|
+
* The journal producer identity of one admitted command.
|
|
102
|
+
*
|
|
103
|
+
* `(runId, sourceId, sourceSeq)` is the journal's own durable idempotency
|
|
104
|
+
* key. Deriving the source from the client-minted `commandId` — with the
|
|
105
|
+
* fixed {@link commandSourceSeq} — turns that key into the branch's
|
|
106
|
+
* exactly-once admission constraint: two server instances racing the same
|
|
107
|
+
* command collide inside the journal's own transaction, so one appends and
|
|
108
|
+
* the other reads back the canonical sequence, instead of both appending
|
|
109
|
+
* (audit finding F-14). The branch run id already scopes the key, so equal
|
|
110
|
+
* command ids on different branches never collide.
|
|
111
|
+
*
|
|
112
|
+
* @category constructors
|
|
113
|
+
* @since 0.1.0
|
|
114
|
+
*/
|
|
115
|
+
export declare const commandSourceId: (commandId: CommandId) => JournalEvent.SourceId;
|
|
116
|
+
/**
|
|
117
|
+
* The fixed producer sequence of an admitted command.
|
|
118
|
+
*
|
|
119
|
+
* A command's identity lives entirely in {@link commandSourceId}, so its
|
|
120
|
+
* producer sequence is always 0. It must be supplied explicitly: letting the
|
|
121
|
+
* journal allocate would hand a resubmission after a lost response sequence 1,
|
|
122
|
+
* a fresh identity, and therefore a second durable append.
|
|
123
|
+
*
|
|
124
|
+
* @category constructors
|
|
125
|
+
* @since 0.1.0
|
|
126
|
+
*/
|
|
127
|
+
export declare const commandSourceSeq: JournalEvent.SourceSeq;
|
|
128
|
+
/**
|
|
129
|
+
* The single durable event type a branch document is built from.
|
|
130
|
+
*
|
|
131
|
+
* Chat, edits, and flow launches are all commands, so the branch journal has
|
|
132
|
+
* exactly one event shape and the projection has exactly one decoder.
|
|
133
|
+
*
|
|
134
|
+
* @category models
|
|
135
|
+
* @since 0.1.0
|
|
136
|
+
*/
|
|
137
|
+
export declare const CommandEvent = "flows/branch/command";
|
|
138
|
+
declare const ShareClaims_base: Schema.Class<ShareClaims, Schema.Struct<{
|
|
139
|
+
readonly kid: Schema.NonEmptyString;
|
|
140
|
+
readonly branchId: Schema.brand<Schema.NonEmptyString, "@smthrs/sync/BranchProtocol/BranchId">;
|
|
141
|
+
readonly capabilityId: Schema.NonEmptyString;
|
|
142
|
+
readonly access: Schema.Literals<readonly ["read", "write"]>;
|
|
143
|
+
readonly issuedAtMs: Schema.Int;
|
|
144
|
+
readonly expiresAtMs: Schema.Int;
|
|
145
|
+
}>, {}>;
|
|
146
|
+
/**
|
|
147
|
+
* Schema for the claims a share capability carries.
|
|
148
|
+
*
|
|
149
|
+
* `kid` names the key that signed the claims and is itself signed, so a
|
|
150
|
+
* verifier both selects the right key out of a rotating keyring and refuses a
|
|
151
|
+
* capability whose key name was swapped after minting. It matches
|
|
152
|
+
* `WorkspaceShare.WorkspaceClaims`: the two authorities are one scheme, and a
|
|
153
|
+
* branch link that could not survive a secret rotation was the only place they
|
|
154
|
+
* differed.
|
|
155
|
+
*
|
|
156
|
+
* @category schemas
|
|
157
|
+
* @since 0.1.0
|
|
158
|
+
*/
|
|
159
|
+
export declare class ShareClaims extends ShareClaims_base {
|
|
160
|
+
}
|
|
161
|
+
declare const ShareCapability_base: Schema.Class<ShareCapability, Schema.Struct<{
|
|
162
|
+
readonly claims: typeof ShareClaims;
|
|
163
|
+
readonly signature: Schema.String;
|
|
164
|
+
}>, {}>;
|
|
165
|
+
/**
|
|
166
|
+
* Schema for a signed, expiring, branch-scoped share capability.
|
|
167
|
+
*
|
|
168
|
+
* @category schemas
|
|
169
|
+
* @since 0.1.0
|
|
170
|
+
*/
|
|
171
|
+
export declare class ShareCapability extends ShareCapability_base {
|
|
172
|
+
}
|
|
173
|
+
declare const Cursor_base: Schema.Class<Cursor, Schema.Struct<{
|
|
174
|
+
readonly cardId: Schema.NonEmptyString;
|
|
175
|
+
readonly offset: Schema.Int;
|
|
176
|
+
}>, {}>;
|
|
177
|
+
/**
|
|
178
|
+
* Schema for a participant's caret inside one embedded card.
|
|
179
|
+
*
|
|
180
|
+
* @category schemas
|
|
181
|
+
* @since 0.1.0
|
|
182
|
+
*/
|
|
183
|
+
export declare class Cursor extends Cursor_base {
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* BranchCard-compatible display coordinates; paths are metadata only.
|
|
187
|
+
*
|
|
188
|
+
* @category schemas
|
|
189
|
+
* @since 1.0.0-rc.1
|
|
190
|
+
*/
|
|
191
|
+
export declare const PresenceWhere: Schema.Union<readonly [Schema.Struct<{
|
|
192
|
+
readonly kind: Schema.Literal<"file">;
|
|
193
|
+
readonly path: Schema.NonEmptyString;
|
|
194
|
+
readonly line: Schema.optionalKey<Schema.Int>;
|
|
195
|
+
}>, Schema.Struct<{
|
|
196
|
+
readonly kind: Schema.Literal<"terminal">;
|
|
197
|
+
readonly id: Schema.NonEmptyString;
|
|
198
|
+
}>, Schema.Struct<{
|
|
199
|
+
readonly kind: Schema.Literal<"step">;
|
|
200
|
+
readonly label: Schema.NonEmptyString;
|
|
201
|
+
}>, Schema.Struct<{
|
|
202
|
+
readonly kind: Schema.Literal<"branch">;
|
|
203
|
+
}>]>;
|
|
204
|
+
declare const Participant_base: Schema.Class<Participant, Schema.Struct<{
|
|
205
|
+
readonly leaseExpiresAtMs: Schema.Int;
|
|
206
|
+
readonly sessionId: Schema.optionalKey<Schema.NonEmptyString>;
|
|
207
|
+
readonly kind: Schema.optionalKey<Schema.Literals<readonly ["person", "agent"]>>;
|
|
208
|
+
readonly where: Schema.optionalKey<Schema.Union<readonly [Schema.Struct<{
|
|
209
|
+
readonly kind: Schema.Literal<"file">;
|
|
210
|
+
readonly path: Schema.NonEmptyString;
|
|
211
|
+
readonly line: Schema.optionalKey<Schema.Int>;
|
|
212
|
+
}>, Schema.Struct<{
|
|
213
|
+
readonly kind: Schema.Literal<"terminal">;
|
|
214
|
+
readonly id: Schema.NonEmptyString;
|
|
215
|
+
}>, Schema.Struct<{
|
|
216
|
+
readonly kind: Schema.Literal<"step">;
|
|
217
|
+
readonly label: Schema.NonEmptyString;
|
|
218
|
+
}>, Schema.Struct<{
|
|
219
|
+
readonly kind: Schema.Literal<"branch">;
|
|
220
|
+
}>]>>;
|
|
221
|
+
readonly watching: Schema.optionalKey<Schema.NonEmptyString>;
|
|
222
|
+
readonly for_member: Schema.optionalKey<Schema.NonEmptyString>;
|
|
223
|
+
readonly agentKind: Schema.optionalKey<Schema.Literals<readonly ["smithers", "coding", "reviewer", "claude-code", "codex", "external"]>>;
|
|
224
|
+
readonly via: Schema.optionalKey<Schema.Literals<readonly ["ssh", "terminal", "cli"]>>;
|
|
225
|
+
readonly runId: Schema.optionalKey<Schema.NonEmptyString>;
|
|
226
|
+
readonly branchId: Schema.brand<Schema.NonEmptyString, "@smthrs/sync/BranchProtocol/BranchId">;
|
|
227
|
+
readonly participantId: Schema.brand<Schema.NonEmptyString, "@smthrs/sync/BranchProtocol/ParticipantId">;
|
|
228
|
+
readonly displayName: Schema.NonEmptyString;
|
|
229
|
+
readonly cursor: Schema.NullOr<typeof Cursor>;
|
|
230
|
+
}>, {}>;
|
|
231
|
+
/**
|
|
232
|
+
* Schema for one live participant on a branch.
|
|
233
|
+
*
|
|
234
|
+
* `leaseExpiresAtMs` is the whole lifetime contract: presence is a lease, so a
|
|
235
|
+
* client that disconnects without saying so disappears on its own.
|
|
236
|
+
*
|
|
237
|
+
* @category schemas
|
|
238
|
+
* @since 0.1.0
|
|
239
|
+
*/
|
|
240
|
+
export declare class Participant extends Participant_base {
|
|
241
|
+
}
|
|
242
|
+
/**
|
|
243
|
+
* Schema for a capability-bearing request for one branch's roster.
|
|
244
|
+
*
|
|
245
|
+
* @category schemas
|
|
246
|
+
* @since 0.1.0
|
|
247
|
+
*/
|
|
248
|
+
export declare const RosterRequest: Schema.Struct<{
|
|
249
|
+
readonly capability: typeof ShareCapability;
|
|
250
|
+
readonly branchId: Schema.brand<Schema.NonEmptyString, "@smthrs/sync/BranchProtocol/BranchId">;
|
|
251
|
+
/** Only the authenticated host adapter consumes this readiness assertion. */
|
|
252
|
+
readonly sourcesReady: Schema.optionalKey<Schema.Boolean>;
|
|
253
|
+
}>;
|
|
254
|
+
/**
|
|
255
|
+
* A capability-bearing request for one branch's roster.
|
|
256
|
+
*
|
|
257
|
+
* @category models
|
|
258
|
+
* @since 0.1.0
|
|
259
|
+
*/
|
|
260
|
+
export type RosterRequest = typeof RosterRequest.Type;
|
|
261
|
+
/**
|
|
262
|
+
* Schema for a capability-bearing request to drop one participant.
|
|
263
|
+
*
|
|
264
|
+
* @category schemas
|
|
265
|
+
* @since 0.1.0
|
|
266
|
+
*/
|
|
267
|
+
export declare const LeaveRequest: Schema.Struct<{
|
|
268
|
+
readonly participantId: Schema.brand<Schema.NonEmptyString, "@smthrs/sync/BranchProtocol/ParticipantId">;
|
|
269
|
+
readonly sessionId: Schema.optionalKey<Schema.NonEmptyString>;
|
|
270
|
+
readonly capability: typeof ShareCapability;
|
|
271
|
+
readonly branchId: Schema.brand<Schema.NonEmptyString, "@smthrs/sync/BranchProtocol/BranchId">;
|
|
272
|
+
/** Only the authenticated host adapter consumes this readiness assertion. */
|
|
273
|
+
readonly sourcesReady: Schema.optionalKey<Schema.Boolean>;
|
|
274
|
+
}>;
|
|
275
|
+
/**
|
|
276
|
+
* A capability-bearing request to drop one participant.
|
|
277
|
+
*
|
|
278
|
+
* @category models
|
|
279
|
+
* @since 0.1.0
|
|
280
|
+
*/
|
|
281
|
+
export type LeaveRequest = typeof LeaveRequest.Type;
|
|
282
|
+
/**
|
|
283
|
+
* Schema for one participant's announcement of itself on a branch.
|
|
284
|
+
*
|
|
285
|
+
* The same shape serves join, heartbeat, and cursor movement: an announcement
|
|
286
|
+
* is idempotent, so a client that reconnects simply announces again.
|
|
287
|
+
*
|
|
288
|
+
* @category schemas
|
|
289
|
+
* @since 0.1.0
|
|
290
|
+
*/
|
|
291
|
+
export declare const Announcement: Schema.Struct<{
|
|
292
|
+
readonly capability: typeof ShareCapability;
|
|
293
|
+
readonly branchId: Schema.brand<Schema.NonEmptyString, "@smthrs/sync/BranchProtocol/BranchId">;
|
|
294
|
+
readonly participantId: Schema.brand<Schema.NonEmptyString, "@smthrs/sync/BranchProtocol/ParticipantId">;
|
|
295
|
+
readonly displayName: Schema.NonEmptyString;
|
|
296
|
+
readonly cursor: Schema.NullOr<typeof Cursor>;
|
|
297
|
+
readonly sessionId: Schema.optionalKey<Schema.NonEmptyString>;
|
|
298
|
+
readonly kind: Schema.optionalKey<Schema.Literals<readonly ["person", "agent"]>>;
|
|
299
|
+
readonly where: Schema.optionalKey<Schema.Union<readonly [Schema.Struct<{
|
|
300
|
+
readonly kind: Schema.Literal<"file">;
|
|
301
|
+
readonly path: Schema.NonEmptyString;
|
|
302
|
+
readonly line: Schema.optionalKey<Schema.Int>;
|
|
303
|
+
}>, Schema.Struct<{
|
|
304
|
+
readonly kind: Schema.Literal<"terminal">;
|
|
305
|
+
readonly id: Schema.NonEmptyString;
|
|
306
|
+
}>, Schema.Struct<{
|
|
307
|
+
readonly kind: Schema.Literal<"step">;
|
|
308
|
+
readonly label: Schema.NonEmptyString;
|
|
309
|
+
}>, Schema.Struct<{
|
|
310
|
+
readonly kind: Schema.Literal<"branch">;
|
|
311
|
+
}>]>>;
|
|
312
|
+
readonly watching: Schema.optionalKey<Schema.NonEmptyString>;
|
|
313
|
+
readonly for_member: Schema.optionalKey<Schema.NonEmptyString>;
|
|
314
|
+
readonly agentKind: Schema.optionalKey<Schema.Literals<readonly ["smithers", "coding", "reviewer", "claude-code", "codex", "external"]>>;
|
|
315
|
+
readonly via: Schema.optionalKey<Schema.Literals<readonly ["ssh", "terminal", "cli"]>>;
|
|
316
|
+
readonly runId: Schema.optionalKey<Schema.NonEmptyString>;
|
|
317
|
+
}>;
|
|
318
|
+
/**
|
|
319
|
+
* One participant's announcement of itself on a branch.
|
|
320
|
+
*
|
|
321
|
+
* @category models
|
|
322
|
+
* @since 0.1.0
|
|
323
|
+
*/
|
|
324
|
+
export type Announcement = typeof Announcement.Type;
|
|
325
|
+
declare const CommandSubmission_base: Schema.Class<CommandSubmission, Schema.Struct<{
|
|
326
|
+
readonly branchId: Schema.brand<Schema.NonEmptyString, "@smthrs/sync/BranchProtocol/BranchId">;
|
|
327
|
+
readonly commandId: Schema.brand<Schema.NonEmptyString, "@smthrs/sync/BranchProtocol/CommandId">;
|
|
328
|
+
readonly participantId: Schema.brand<Schema.NonEmptyString, "@smthrs/sync/BranchProtocol/ParticipantId">;
|
|
329
|
+
readonly name: Schema.NonEmptyString;
|
|
330
|
+
readonly args: Schema.String;
|
|
331
|
+
readonly target: Schema.String;
|
|
332
|
+
}>, {}>;
|
|
333
|
+
/**
|
|
334
|
+
* Schema for one submitted command or flow invocation.
|
|
335
|
+
*
|
|
336
|
+
* Every user action on a shared branch arrives here first — chat messages are
|
|
337
|
+
* the `branch.say` command, renames are `branch.rename`, and a flow launch is
|
|
338
|
+
* that flow's own name. `target` names the shared field a command durably
|
|
339
|
+
* edits and is `""` for commands that only append.
|
|
340
|
+
*
|
|
341
|
+
* @category schemas
|
|
342
|
+
* @since 0.1.0
|
|
343
|
+
*/
|
|
344
|
+
export declare class CommandSubmission extends CommandSubmission_base {
|
|
345
|
+
}
|
|
346
|
+
/**
|
|
347
|
+
* Schema for a capability-bearing command submission.
|
|
348
|
+
*
|
|
349
|
+
* @category schemas
|
|
350
|
+
* @since 0.1.0
|
|
351
|
+
*/
|
|
352
|
+
export declare const SubmitRequest: Schema.Struct<{
|
|
353
|
+
readonly capability: typeof ShareCapability;
|
|
354
|
+
readonly submission: typeof CommandSubmission;
|
|
355
|
+
}>;
|
|
356
|
+
/**
|
|
357
|
+
* A capability-bearing command submission.
|
|
358
|
+
*
|
|
359
|
+
* @category models
|
|
360
|
+
* @since 0.1.0
|
|
361
|
+
*/
|
|
362
|
+
export type SubmitRequest = typeof SubmitRequest.Type;
|
|
363
|
+
declare const CommandEventPayload_base: Schema.Class<CommandEventPayload, Schema.Struct<{
|
|
364
|
+
readonly commandId: Schema.brand<Schema.NonEmptyString, "@smthrs/sync/BranchProtocol/CommandId">;
|
|
365
|
+
readonly participantId: Schema.brand<Schema.NonEmptyString, "@smthrs/sync/BranchProtocol/ParticipantId">;
|
|
366
|
+
readonly name: Schema.NonEmptyString;
|
|
367
|
+
readonly args: Schema.withDecodingDefaultKey<Schema.String, never>;
|
|
368
|
+
readonly target: Schema.withDecodingDefaultKey<Schema.String, never>;
|
|
369
|
+
readonly capabilityId: Schema.withDecodingDefaultKey<Schema.String, never>;
|
|
370
|
+
}>, {}>;
|
|
371
|
+
/**
|
|
372
|
+
* The durable payload stored for an admitted command.
|
|
373
|
+
*
|
|
374
|
+
* Distinct from the wire request: `args` and `target` carry decoding defaults,
|
|
375
|
+
* so a row written before those fields existed still decodes rather than
|
|
376
|
+
* failing the whole ledger rebuild.
|
|
377
|
+
*
|
|
378
|
+
* `capabilityId` is the verified id of the share capability that submitted the
|
|
379
|
+
* command, stamped by `BranchCommands.submit` and never read from the client.
|
|
380
|
+
* `participantId` is whatever the client claimed, so attribute a command to
|
|
381
|
+
* its `capabilityId`. A row admitted before the field existed decodes with
|
|
382
|
+
* `""`, which no capability can carry.
|
|
383
|
+
*
|
|
384
|
+
* @category schemas
|
|
385
|
+
* @since 0.1.0
|
|
386
|
+
*/
|
|
387
|
+
export declare class CommandEventPayload extends CommandEventPayload_base {
|
|
388
|
+
}
|
|
389
|
+
/**
|
|
390
|
+
* The command that appends a collaborative chat message.
|
|
391
|
+
*
|
|
392
|
+
* @category models
|
|
393
|
+
* @since 0.1.0
|
|
394
|
+
*/
|
|
395
|
+
export declare const SayCommand = "branch.say";
|
|
396
|
+
declare const CommandReceipt_base: Schema.Class<CommandReceipt, Schema.Struct<{
|
|
397
|
+
readonly branchId: Schema.brand<Schema.NonEmptyString, "@smthrs/sync/BranchProtocol/BranchId">;
|
|
398
|
+
readonly commandId: Schema.brand<Schema.NonEmptyString, "@smthrs/sync/BranchProtocol/CommandId">;
|
|
399
|
+
readonly status: Schema.Literals<readonly ["admitted", "duplicate"]>;
|
|
400
|
+
readonly seq: Schema.brand<Schema.Int, "@smthrs/journal/JournalEvent/Seq">;
|
|
401
|
+
}>, {}>;
|
|
402
|
+
/**
|
|
403
|
+
* Schema for the outcome of admitting a command.
|
|
404
|
+
*
|
|
405
|
+
* `duplicate` is a success, not a failure: it reports the canonical sequence
|
|
406
|
+
* the original submission already occupies so a retransmitting client can
|
|
407
|
+
* settle its optimistic row instead of executing the command twice.
|
|
408
|
+
*
|
|
409
|
+
* @category schemas
|
|
410
|
+
* @since 0.1.0
|
|
411
|
+
*/
|
|
412
|
+
export declare class CommandReceipt extends CommandReceipt_base {
|
|
413
|
+
}
|
|
414
|
+
export {};
|
|
415
|
+
//# sourceMappingURL=BranchProtocol.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BranchProtocol.d.ts","sourceRoot":"","sources":["../../src/BranchProtocol.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,YAAY,MAAM,8BAA8B,CAAA;AAE5D,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AAEvC;;;;;GAKG;AACH,eAAO,MAAM,QAAQ,6EAAmF,CAAA;AAExG;;;;;GAKG;AACH,MAAM,MAAM,QAAQ,GAAG,OAAO,QAAQ,CAAC,IAAI,CAAA;AAE3C;;;;;GAKG;AACH,eAAO,MAAM,aAAa,kFAAwF,CAAA;AAElH;;;;;GAKG;AACH,MAAM,MAAM,aAAa,GAAG,OAAO,aAAa,CAAC,IAAI,CAAA;AAErD;;;;;;;;;GASG;AACH,eAAO,MAAM,SAAS,8EAAoF,CAAA;AAE1G;;;;;GAKG;AACH,MAAM,MAAM,SAAS,GAAG,OAAO,SAAS,CAAC,IAAI,CAAA;AAE7C;;;;;GAKG;AACH,eAAO,MAAM,MAAM,6CAAqC,CAAA;AAExD;;;;;GAKG;AACH,MAAM,MAAM,MAAM,GAAG,OAAO,MAAM,CAAC,IAAI,CAAA;AAEvC;;;;;;;;GAQG;AACH,eAAO,MAAM,WAAW,GAAI,UAAU,QAAQ,KAAG,YAAY,CAAC,KACP,CAAA;AAKvD;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,aAAa,GAAI,OAAO,YAAY,CAAC,KAAK,KAAG,QAAQ,GAAG,IAIpE,CAAA;AAED;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,eAAe,GAAI,WAAW,SAAS,KAAG,YAAY,CAAC,QACN,CAAA;AAE9D;;;;;;;;;;GAUG;AACH,eAAO,MAAM,gBAAgB,EAAE,YAAY,CAAC,SAAuC,CAAA;AAEnF;;;;;;;;GAQG;AACH,eAAO,MAAM,YAAY,yBAAyB,CAAA;;;;;;;;;AAElD;;;;;;;;;;;;GAYG;AACH,qBAAa,WAAY,SAAQ,gBAO/B;CAAG;;;;;AAEL;;;;;GAKG;AACH,qBAAa,eAAgB,SAAQ,oBAGnC;CAAG;;;;;AAEL;;;;;GAKG;AACH,qBAAa,MAAO,SAAQ,WAG1B;CAAG;AAEL;;;;;GAKG;AACH,eAAO,MAAM,aAAa;;;;;;;;;;;;IASxB,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgBF;;;;;;;;GAQG;AACH,qBAAa,WAAY,SAAQ,gBAO/B;CAAG;AAEL;;;;;GAKG;AACH,eAAO,MAAM,aAAa;;;IAGxB,6EAA6E;;EAE7E,CAAA;AAEF;;;;;GAKG;AACH,MAAM,MAAM,aAAa,GAAG,OAAO,aAAa,CAAC,IAAI,CAAA;AAErD;;;;;GAKG;AACH,eAAO,MAAM,YAAY;;;;;IAlBvB,6EAA6E;;EAsB7E,CAAA;AAEF;;;;;GAKG;AACH,MAAM,MAAM,YAAY,GAAG,OAAO,YAAY,CAAC,IAAI,CAAA;AAEnD;;;;;;;;GAQG;AACH,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;EAOvB,CAAA;AAEF;;;;;GAKG;AACH,MAAM,MAAM,YAAY,GAAG,OAAO,YAAY,CAAC,IAAI,CAAA;;;;;;;;;AAEnD;;;;;;;;;;GAUG;AACH,qBAAa,iBAAkB,SAAQ,sBASrC;CAAG;AAEL;;;;;GAKG;AACH,eAAO,MAAM,aAAa;;;EAAgF,CAAA;AAE1G;;;;;GAKG;AACH,MAAM,MAAM,aAAa,GAAG,OAAO,aAAa,CAAC,IAAI,CAAA;;;;;;;;;AAErD;;;;;;;;;;;;;;;GAeG;AACH,qBAAa,mBAAoB,SAAQ,wBASvC;CAAG;AAEL;;;;;GAKG;AACH,eAAO,MAAM,UAAU,eAAe,CAAA;;;;;;;AAEtC;;;;;;;;;GASG;AACH,qBAAa,cAAe,SAAQ,mBAKlC;CAAG"}
|