gitx.do 0.0.1 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli/commands/blame.d.ts +259 -0
- package/dist/cli/commands/blame.d.ts.map +1 -0
- package/dist/cli/commands/blame.js +609 -0
- package/dist/cli/commands/blame.js.map +1 -0
- package/dist/cli/commands/branch.d.ts +249 -0
- package/dist/cli/commands/branch.d.ts.map +1 -0
- package/dist/cli/commands/branch.js +693 -0
- package/dist/cli/commands/branch.js.map +1 -0
- package/dist/cli/commands/commit.d.ts +182 -0
- package/dist/cli/commands/commit.d.ts.map +1 -0
- package/dist/cli/commands/commit.js +437 -0
- package/dist/cli/commands/commit.js.map +1 -0
- package/dist/cli/commands/diff.d.ts +464 -0
- package/dist/cli/commands/diff.d.ts.map +1 -0
- package/dist/cli/commands/diff.js +958 -0
- package/dist/cli/commands/diff.js.map +1 -0
- package/dist/cli/commands/log.d.ts +239 -0
- package/dist/cli/commands/log.d.ts.map +1 -0
- package/dist/cli/commands/log.js +535 -0
- package/dist/cli/commands/log.js.map +1 -0
- package/dist/cli/commands/review.d.ts +457 -0
- package/dist/cli/commands/review.d.ts.map +1 -0
- package/dist/cli/commands/review.js +533 -0
- package/dist/cli/commands/review.js.map +1 -0
- package/dist/cli/commands/status.d.ts +269 -0
- package/dist/cli/commands/status.d.ts.map +1 -0
- package/dist/cli/commands/status.js +493 -0
- package/dist/cli/commands/status.js.map +1 -0
- package/dist/cli/commands/web.d.ts +199 -0
- package/dist/cli/commands/web.d.ts.map +1 -0
- package/dist/cli/commands/web.js +696 -0
- package/dist/cli/commands/web.js.map +1 -0
- package/dist/cli/fs-adapter.d.ts +656 -0
- package/dist/cli/fs-adapter.d.ts.map +1 -0
- package/dist/cli/fs-adapter.js +1179 -0
- package/dist/cli/fs-adapter.js.map +1 -0
- package/dist/cli/index.d.ts +387 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +523 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/cli/ui/components/DiffView.d.ts +7 -0
- package/dist/cli/ui/components/DiffView.d.ts.map +1 -0
- package/dist/cli/ui/components/DiffView.js +11 -0
- package/dist/cli/ui/components/DiffView.js.map +1 -0
- package/dist/cli/ui/components/ErrorDisplay.d.ts +6 -0
- package/dist/cli/ui/components/ErrorDisplay.d.ts.map +1 -0
- package/dist/cli/ui/components/ErrorDisplay.js +11 -0
- package/dist/cli/ui/components/ErrorDisplay.js.map +1 -0
- package/dist/cli/ui/components/FuzzySearch.d.ts +9 -0
- package/dist/cli/ui/components/FuzzySearch.d.ts.map +1 -0
- package/dist/cli/ui/components/FuzzySearch.js +12 -0
- package/dist/cli/ui/components/FuzzySearch.js.map +1 -0
- package/dist/cli/ui/components/LoadingSpinner.d.ts +6 -0
- package/dist/cli/ui/components/LoadingSpinner.d.ts.map +1 -0
- package/dist/cli/ui/components/LoadingSpinner.js +10 -0
- package/dist/cli/ui/components/LoadingSpinner.js.map +1 -0
- package/dist/cli/ui/components/NavigationList.d.ts +9 -0
- package/dist/cli/ui/components/NavigationList.d.ts.map +1 -0
- package/dist/cli/ui/components/NavigationList.js +11 -0
- package/dist/cli/ui/components/NavigationList.js.map +1 -0
- package/dist/cli/ui/components/ScrollableContent.d.ts +8 -0
- package/dist/cli/ui/components/ScrollableContent.d.ts.map +1 -0
- package/dist/cli/ui/components/ScrollableContent.js +11 -0
- package/dist/cli/ui/components/ScrollableContent.js.map +1 -0
- package/dist/cli/ui/components/index.d.ts +7 -0
- package/dist/cli/ui/components/index.d.ts.map +1 -0
- package/dist/cli/ui/components/index.js +9 -0
- package/dist/cli/ui/components/index.js.map +1 -0
- package/dist/cli/ui/terminal-ui.d.ts +52 -0
- package/dist/cli/ui/terminal-ui.d.ts.map +1 -0
- package/dist/cli/ui/terminal-ui.js +121 -0
- package/dist/cli/ui/terminal-ui.js.map +1 -0
- package/dist/durable-object/object-store.d.ts +401 -23
- package/dist/durable-object/object-store.d.ts.map +1 -1
- package/dist/durable-object/object-store.js +414 -25
- package/dist/durable-object/object-store.js.map +1 -1
- package/dist/durable-object/schema.d.ts +188 -0
- package/dist/durable-object/schema.d.ts.map +1 -1
- package/dist/durable-object/schema.js +160 -0
- package/dist/durable-object/schema.js.map +1 -1
- package/dist/durable-object/wal.d.ts +336 -31
- package/dist/durable-object/wal.d.ts.map +1 -1
- package/dist/durable-object/wal.js +272 -27
- package/dist/durable-object/wal.js.map +1 -1
- package/dist/index.d.ts +379 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +379 -7
- package/dist/index.js.map +1 -1
- package/dist/mcp/adapter.d.ts +579 -38
- package/dist/mcp/adapter.d.ts.map +1 -1
- package/dist/mcp/adapter.js +426 -33
- package/dist/mcp/adapter.js.map +1 -1
- package/dist/mcp/sandbox.d.ts +532 -29
- package/dist/mcp/sandbox.d.ts.map +1 -1
- package/dist/mcp/sandbox.js +389 -22
- package/dist/mcp/sandbox.js.map +1 -1
- package/dist/mcp/sdk-adapter.d.ts +478 -56
- package/dist/mcp/sdk-adapter.d.ts.map +1 -1
- package/dist/mcp/sdk-adapter.js +346 -44
- package/dist/mcp/sdk-adapter.js.map +1 -1
- package/dist/mcp/tools.d.ts +445 -30
- package/dist/mcp/tools.d.ts.map +1 -1
- package/dist/mcp/tools.js +363 -33
- package/dist/mcp/tools.js.map +1 -1
- package/dist/ops/blame.d.ts +424 -21
- package/dist/ops/blame.d.ts.map +1 -1
- package/dist/ops/blame.js +303 -20
- package/dist/ops/blame.js.map +1 -1
- package/dist/ops/branch.d.ts +583 -32
- package/dist/ops/branch.d.ts.map +1 -1
- package/dist/ops/branch.js +365 -23
- package/dist/ops/branch.js.map +1 -1
- package/dist/ops/commit-traversal.d.ts +164 -24
- package/dist/ops/commit-traversal.d.ts.map +1 -1
- package/dist/ops/commit-traversal.js +68 -2
- package/dist/ops/commit-traversal.js.map +1 -1
- package/dist/ops/commit.d.ts +387 -53
- package/dist/ops/commit.d.ts.map +1 -1
- package/dist/ops/commit.js +249 -29
- package/dist/ops/commit.js.map +1 -1
- package/dist/ops/merge-base.d.ts +195 -21
- package/dist/ops/merge-base.d.ts.map +1 -1
- package/dist/ops/merge-base.js +122 -12
- package/dist/ops/merge-base.js.map +1 -1
- package/dist/ops/merge.d.ts +600 -130
- package/dist/ops/merge.d.ts.map +1 -1
- package/dist/ops/merge.js +408 -60
- package/dist/ops/merge.js.map +1 -1
- package/dist/ops/tag.d.ts +67 -2
- package/dist/ops/tag.d.ts.map +1 -1
- package/dist/ops/tag.js +42 -1
- package/dist/ops/tag.js.map +1 -1
- package/dist/ops/tree-builder.d.ts +102 -6
- package/dist/ops/tree-builder.d.ts.map +1 -1
- package/dist/ops/tree-builder.js +30 -5
- package/dist/ops/tree-builder.js.map +1 -1
- package/dist/ops/tree-diff.d.ts +50 -2
- package/dist/ops/tree-diff.d.ts.map +1 -1
- package/dist/ops/tree-diff.js +50 -2
- package/dist/ops/tree-diff.js.map +1 -1
- package/dist/pack/delta.d.ts +211 -39
- package/dist/pack/delta.d.ts.map +1 -1
- package/dist/pack/delta.js +232 -46
- package/dist/pack/delta.js.map +1 -1
- package/dist/pack/format.d.ts +390 -28
- package/dist/pack/format.d.ts.map +1 -1
- package/dist/pack/format.js +344 -33
- package/dist/pack/format.js.map +1 -1
- package/dist/pack/full-generation.d.ts +313 -28
- package/dist/pack/full-generation.d.ts.map +1 -1
- package/dist/pack/full-generation.js +238 -19
- package/dist/pack/full-generation.js.map +1 -1
- package/dist/pack/generation.d.ts +346 -23
- package/dist/pack/generation.d.ts.map +1 -1
- package/dist/pack/generation.js +269 -21
- package/dist/pack/generation.js.map +1 -1
- package/dist/pack/index.d.ts +407 -86
- package/dist/pack/index.d.ts.map +1 -1
- package/dist/pack/index.js +351 -70
- package/dist/pack/index.js.map +1 -1
- package/dist/refs/branch.d.ts +517 -71
- package/dist/refs/branch.d.ts.map +1 -1
- package/dist/refs/branch.js +410 -26
- package/dist/refs/branch.js.map +1 -1
- package/dist/refs/storage.d.ts +610 -57
- package/dist/refs/storage.d.ts.map +1 -1
- package/dist/refs/storage.js +481 -29
- package/dist/refs/storage.js.map +1 -1
- package/dist/refs/tag.d.ts +677 -67
- package/dist/refs/tag.d.ts.map +1 -1
- package/dist/refs/tag.js +497 -30
- package/dist/refs/tag.js.map +1 -1
- package/dist/storage/lru-cache.d.ts +556 -53
- package/dist/storage/lru-cache.d.ts.map +1 -1
- package/dist/storage/lru-cache.js +439 -36
- package/dist/storage/lru-cache.js.map +1 -1
- package/dist/storage/object-index.d.ts +483 -38
- package/dist/storage/object-index.d.ts.map +1 -1
- package/dist/storage/object-index.js +388 -22
- package/dist/storage/object-index.js.map +1 -1
- package/dist/storage/r2-pack.d.ts +957 -94
- package/dist/storage/r2-pack.d.ts.map +1 -1
- package/dist/storage/r2-pack.js +756 -48
- package/dist/storage/r2-pack.js.map +1 -1
- package/dist/tiered/cdc-pipeline.d.ts +1610 -38
- package/dist/tiered/cdc-pipeline.d.ts.map +1 -1
- package/dist/tiered/cdc-pipeline.js +1131 -22
- package/dist/tiered/cdc-pipeline.js.map +1 -1
- package/dist/tiered/migration.d.ts +903 -41
- package/dist/tiered/migration.d.ts.map +1 -1
- package/dist/tiered/migration.js +646 -24
- package/dist/tiered/migration.js.map +1 -1
- package/dist/tiered/parquet-writer.d.ts +944 -47
- package/dist/tiered/parquet-writer.d.ts.map +1 -1
- package/dist/tiered/parquet-writer.js +667 -39
- package/dist/tiered/parquet-writer.js.map +1 -1
- package/dist/tiered/read-path.d.ts +728 -34
- package/dist/tiered/read-path.d.ts.map +1 -1
- package/dist/tiered/read-path.js +310 -27
- package/dist/tiered/read-path.js.map +1 -1
- package/dist/types/objects.d.ts +457 -0
- package/dist/types/objects.d.ts.map +1 -1
- package/dist/types/objects.js +305 -4
- package/dist/types/objects.js.map +1 -1
- package/dist/types/storage.d.ts +407 -35
- package/dist/types/storage.d.ts.map +1 -1
- package/dist/types/storage.js +27 -3
- package/dist/types/storage.js.map +1 -1
- package/dist/utils/hash.d.ts +133 -12
- package/dist/utils/hash.d.ts.map +1 -1
- package/dist/utils/hash.js +133 -12
- package/dist/utils/hash.js.map +1 -1
- package/dist/utils/sha1.d.ts +102 -9
- package/dist/utils/sha1.d.ts.map +1 -1
- package/dist/utils/sha1.js +114 -11
- package/dist/utils/sha1.js.map +1 -1
- package/dist/wire/capabilities.d.ts +896 -88
- package/dist/wire/capabilities.d.ts.map +1 -1
- package/dist/wire/capabilities.js +566 -62
- package/dist/wire/capabilities.js.map +1 -1
- package/dist/wire/pkt-line.d.ts +293 -15
- package/dist/wire/pkt-line.d.ts.map +1 -1
- package/dist/wire/pkt-line.js +251 -15
- package/dist/wire/pkt-line.js.map +1 -1
- package/dist/wire/receive-pack.d.ts +814 -64
- package/dist/wire/receive-pack.d.ts.map +1 -1
- package/dist/wire/receive-pack.js +542 -41
- package/dist/wire/receive-pack.js.map +1 -1
- package/dist/wire/smart-http.d.ts +575 -97
- package/dist/wire/smart-http.d.ts.map +1 -1
- package/dist/wire/smart-http.js +337 -46
- package/dist/wire/smart-http.js.map +1 -1
- package/dist/wire/upload-pack.d.ts +492 -98
- package/dist/wire/upload-pack.d.ts.map +1 -1
- package/dist/wire/upload-pack.js +347 -59
- package/dist/wire/upload-pack.js.map +1 -1
- package/package.json +10 -2
|
@@ -1,236 +1,1044 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Git wire protocol capability negotiation
|
|
2
|
+
* @fileoverview Git wire protocol capability negotiation
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
4
|
+
* This module implements the capability negotiation mechanism used in Git's wire protocol.
|
|
5
|
+
* Capabilities are exchanged during the initial handshake between git client and server
|
|
6
|
+
* to determine what features are supported by both sides, enabling backward compatibility
|
|
7
|
+
* and feature detection.
|
|
6
8
|
*
|
|
7
|
-
* Protocol
|
|
8
|
-
* Protocol v2: Capabilities are advertised line by line in the initial handshake
|
|
9
|
+
* ## Protocol Versions
|
|
9
10
|
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
11
|
+
* **Protocol v1:**
|
|
12
|
+
* - Capabilities are sent as a space-separated list after the first ref line
|
|
13
|
+
* - Format: `<oid> <refname>\0<cap1> <cap2> cap3=value...`
|
|
14
|
+
* - The NUL byte (`\0`) separates ref information from capabilities
|
|
15
|
+
* - Only the first ref line contains capabilities
|
|
16
|
+
*
|
|
17
|
+
* **Protocol v2:**
|
|
18
|
+
* - Capabilities are advertised line by line in the initial handshake
|
|
19
|
+
* - Starts with `version 2` line
|
|
20
|
+
* - Each capability on its own line, with optional values after `=`
|
|
21
|
+
* - More structured and extensible than v1
|
|
22
|
+
*
|
|
23
|
+
* ## Common Capabilities
|
|
24
|
+
*
|
|
25
|
+
* **Fetch operations:**
|
|
26
|
+
* - `multi_ack`, `multi_ack_detailed`: Improved negotiation
|
|
27
|
+
* - `thin-pack`: Send thin packs requiring client to resolve deltas
|
|
28
|
+
* - `side-band`, `side-band-64k`: Multiplexed data channels
|
|
29
|
+
* - `ofs-delta`: Use offset-based delta encoding
|
|
30
|
+
* - `shallow`: Support shallow clone operations
|
|
31
|
+
*
|
|
32
|
+
* **Push operations:**
|
|
33
|
+
* - `report-status`, `report-status-v2`: Push result reporting
|
|
34
|
+
* - `atomic`: All-or-nothing ref updates
|
|
35
|
+
* - `delete-refs`: Allow ref deletion
|
|
36
|
+
* - `push-options`: Support push options
|
|
37
|
+
*
|
|
38
|
+
* ## Usage Example
|
|
39
|
+
*
|
|
40
|
+
* ```typescript
|
|
41
|
+
* import {
|
|
42
|
+
* parseCapabilityString,
|
|
43
|
+
* findCommonCapabilities,
|
|
44
|
+
* buildCapabilityString,
|
|
45
|
+
* DEFAULT_FETCH_CAPABILITIES_V1
|
|
46
|
+
* } from './capabilities';
|
|
47
|
+
*
|
|
48
|
+
* // Parse capabilities from server advertisement
|
|
49
|
+
* const serverCaps = parseCapabilityString('abc123... refs/heads/main\0multi_ack side-band-64k');
|
|
50
|
+
*
|
|
51
|
+
* // Find common capabilities
|
|
52
|
+
* const clientCaps = DEFAULT_FETCH_CAPABILITIES_V1.map(name => ({ name }));
|
|
53
|
+
* const common = findCommonCapabilities(clientCaps, serverCaps);
|
|
54
|
+
*
|
|
55
|
+
* // Build capability string for request
|
|
56
|
+
* const capString = buildCapabilityString([
|
|
57
|
+
* { name: 'multi_ack' },
|
|
58
|
+
* { name: 'agent', value: 'gitdo/1.0' }
|
|
59
|
+
* ]);
|
|
60
|
+
* ```
|
|
61
|
+
*
|
|
62
|
+
* @module wire/capabilities
|
|
63
|
+
* @see {@link https://git-scm.com/docs/protocol-capabilities} - Protocol capabilities reference
|
|
64
|
+
* @see {@link https://git-scm.com/docs/protocol-v2} - Protocol v2 specification
|
|
65
|
+
*/
|
|
66
|
+
/**
|
|
67
|
+
* Git wire protocol version.
|
|
68
|
+
*
|
|
69
|
+
* @description
|
|
70
|
+
* Represents the Git wire protocol version used for communication.
|
|
71
|
+
* Version 1 is the traditional protocol, while version 2 offers improved
|
|
72
|
+
* capability negotiation and command structure.
|
|
73
|
+
*
|
|
74
|
+
* @example
|
|
75
|
+
* ```typescript
|
|
76
|
+
* const version: ProtocolVersion = 2;
|
|
77
|
+
*
|
|
78
|
+
* if (version === 2) {
|
|
79
|
+
* // Use v2 command-based protocol
|
|
80
|
+
* } else {
|
|
81
|
+
* // Use v1 ref advertisement protocol
|
|
82
|
+
* }
|
|
83
|
+
* ```
|
|
12
84
|
*/
|
|
13
|
-
/** Git wire protocol version */
|
|
14
85
|
export type ProtocolVersion = 1 | 2;
|
|
15
|
-
/**
|
|
86
|
+
/**
|
|
87
|
+
* Standard protocol v1 capabilities.
|
|
88
|
+
*
|
|
89
|
+
* @description
|
|
90
|
+
* Union type of all standard capability names supported in Git protocol v1.
|
|
91
|
+
* These capabilities control various aspects of fetch and push operations.
|
|
92
|
+
*
|
|
93
|
+
* **Negotiation capabilities:**
|
|
94
|
+
* - `multi_ack`: Multiple acknowledgment during negotiation
|
|
95
|
+
* - `multi_ack_detailed`: Extended ack with common/ready/continue states
|
|
96
|
+
*
|
|
97
|
+
* **Pack transfer capabilities:**
|
|
98
|
+
* - `thin-pack`: Allow thin packs requiring delta base reconstruction
|
|
99
|
+
* - `side-band`, `side-band-64k`: Multiplexed data/progress/error channels
|
|
100
|
+
* - `ofs-delta`: Use offset-based delta references (more efficient)
|
|
101
|
+
* - `include-tag`: Include tags that point to requested objects
|
|
102
|
+
*
|
|
103
|
+
* **Shallow clone capabilities:**
|
|
104
|
+
* - `shallow`: Basic shallow clone support
|
|
105
|
+
* - `deepen-since`: Shallow by date
|
|
106
|
+
* - `deepen-not`: Shallow excluding specific refs
|
|
107
|
+
* - `deepen-relative`: Deepen relative to current shallow boundary
|
|
108
|
+
*
|
|
109
|
+
* **Push capabilities:**
|
|
110
|
+
* - `report-status`, `report-status-v2`: Detailed push result reporting
|
|
111
|
+
* - `delete-refs`: Allow ref deletion via push
|
|
112
|
+
* - `atomic`: Atomic ref updates (all-or-nothing)
|
|
113
|
+
* - `push-options`: Support for push options
|
|
114
|
+
* - `push-cert`: Push certificate for signed pushes
|
|
115
|
+
* - `quiet`: Suppress progress output
|
|
116
|
+
*
|
|
117
|
+
* **Other capabilities:**
|
|
118
|
+
* - `no-progress`: Client doesn't want progress messages
|
|
119
|
+
* - `allow-tip-sha1-in-want`: Allow fetching by SHA-1 at ref tips
|
|
120
|
+
* - `allow-reachable-sha1-in-want`: Allow fetching any reachable SHA-1
|
|
121
|
+
* - `filter`: Partial clone filtering support
|
|
122
|
+
* - `agent`: Client/server identification
|
|
123
|
+
* - `symref`: Symbolic ref information (e.g., HEAD -> refs/heads/main)
|
|
124
|
+
* - `object-format`: Hash algorithm (sha1 or sha256)
|
|
125
|
+
*
|
|
126
|
+
* @example
|
|
127
|
+
* ```typescript
|
|
128
|
+
* const caps: CapabilityV1[] = ['multi_ack_detailed', 'side-band-64k', 'thin-pack'];
|
|
129
|
+
*
|
|
130
|
+
* const entries: CapabilityEntry[] = caps.map(name => ({ name }));
|
|
131
|
+
* ```
|
|
132
|
+
*/
|
|
16
133
|
export type CapabilityV1 = 'multi_ack' | 'multi_ack_detailed' | 'thin-pack' | 'side-band' | 'side-band-64k' | 'ofs-delta' | 'shallow' | 'deepen-since' | 'deepen-not' | 'deepen-relative' | 'no-progress' | 'include-tag' | 'report-status' | 'report-status-v2' | 'delete-refs' | 'quiet' | 'atomic' | 'push-options' | 'allow-tip-sha1-in-want' | 'allow-reachable-sha1-in-want' | 'push-cert' | 'filter' | 'agent' | 'symref' | 'object-format';
|
|
17
|
-
/**
|
|
134
|
+
/**
|
|
135
|
+
* Protocol v2 capabilities/commands.
|
|
136
|
+
*
|
|
137
|
+
* @description
|
|
138
|
+
* Union type of capabilities and commands available in Git protocol v2.
|
|
139
|
+
* Protocol v2 uses a command-based model where capabilities are more
|
|
140
|
+
* like available services.
|
|
141
|
+
*
|
|
142
|
+
* **Commands:**
|
|
143
|
+
* - `ls-refs`: List refs (replaces ref advertisement)
|
|
144
|
+
* - `fetch`: Fetch objects (replaces upload-pack negotiation)
|
|
145
|
+
* - `object-info`: Query object information without fetching
|
|
146
|
+
* - `bundle-uri`: Bundle URI advertisement
|
|
147
|
+
*
|
|
148
|
+
* **Other capabilities:**
|
|
149
|
+
* - `agent`: Client/server identification
|
|
150
|
+
* - `server-option`: Support for server-specific options
|
|
151
|
+
* - `object-format`: Hash algorithm (sha1 or sha256)
|
|
152
|
+
* - `session-id`: Session tracking for debugging
|
|
153
|
+
* - `wait-for-done`: Wait for client "done" before sending pack
|
|
154
|
+
*
|
|
155
|
+
* @example
|
|
156
|
+
* ```typescript
|
|
157
|
+
* const v2Caps: CapabilityV2[] = ['ls-refs', 'fetch', 'agent'];
|
|
158
|
+
* ```
|
|
159
|
+
*/
|
|
18
160
|
export type CapabilityV2 = 'agent' | 'ls-refs' | 'fetch' | 'server-option' | 'object-format' | 'session-id' | 'wait-for-done' | 'object-info' | 'bundle-uri';
|
|
19
|
-
/**
|
|
161
|
+
/**
|
|
162
|
+
* Capability with optional value.
|
|
163
|
+
*
|
|
164
|
+
* @description
|
|
165
|
+
* Represents a single capability entry that may have an associated value.
|
|
166
|
+
* Some capabilities are boolean (presence indicates support), while others
|
|
167
|
+
* carry values (e.g., `agent=git/2.30.0`, `symref=HEAD:refs/heads/main`).
|
|
168
|
+
*
|
|
169
|
+
* @example
|
|
170
|
+
* ```typescript
|
|
171
|
+
* // Boolean capability (no value)
|
|
172
|
+
* const multiAck: CapabilityEntry = { name: 'multi_ack' };
|
|
173
|
+
*
|
|
174
|
+
* // Capability with value
|
|
175
|
+
* const agent: CapabilityEntry = { name: 'agent', value: 'gitdo/1.0' };
|
|
176
|
+
*
|
|
177
|
+
* // Symref capability (multiple values possible)
|
|
178
|
+
* const symref: CapabilityEntry = { name: 'symref', value: 'HEAD:refs/heads/main' };
|
|
179
|
+
* ```
|
|
180
|
+
*/
|
|
20
181
|
export interface CapabilityEntry {
|
|
182
|
+
/**
|
|
183
|
+
* The capability name (e.g., 'multi_ack', 'agent', 'symref').
|
|
184
|
+
* Must not contain spaces, NUL bytes, or newlines.
|
|
185
|
+
*/
|
|
21
186
|
name: string;
|
|
187
|
+
/**
|
|
188
|
+
* Optional value for the capability.
|
|
189
|
+
* Format depends on the capability (e.g., 'git/2.30.0' for agent).
|
|
190
|
+
* @default undefined
|
|
191
|
+
*/
|
|
22
192
|
value?: string;
|
|
23
193
|
}
|
|
24
|
-
/**
|
|
194
|
+
/**
|
|
195
|
+
* Parsed capability set.
|
|
196
|
+
*
|
|
197
|
+
* @description
|
|
198
|
+
* A collection of capabilities parsed from a protocol exchange,
|
|
199
|
+
* along with the protocol version. Provides efficient lookup
|
|
200
|
+
* via a Map structure.
|
|
201
|
+
*
|
|
202
|
+
* @example
|
|
203
|
+
* ```typescript
|
|
204
|
+
* const capSet: CapabilitySet = {
|
|
205
|
+
* version: 1,
|
|
206
|
+
* capabilities: new Map([
|
|
207
|
+
* ['multi_ack', undefined],
|
|
208
|
+
* ['side-band-64k', undefined],
|
|
209
|
+
* ['agent', 'git/2.30.0'],
|
|
210
|
+
* ['symref', 'HEAD:refs/heads/main']
|
|
211
|
+
* ])
|
|
212
|
+
* };
|
|
213
|
+
*
|
|
214
|
+
* // Check if capability exists
|
|
215
|
+
* if (capSet.capabilities.has('multi_ack')) {
|
|
216
|
+
* console.log('Server supports multi_ack');
|
|
217
|
+
* }
|
|
218
|
+
*
|
|
219
|
+
* // Get capability value
|
|
220
|
+
* const agent = capSet.capabilities.get('agent');
|
|
221
|
+
* ```
|
|
222
|
+
*/
|
|
25
223
|
export interface CapabilitySet {
|
|
26
|
-
/**
|
|
224
|
+
/**
|
|
225
|
+
* Protocol version being used (1 or 2).
|
|
226
|
+
*/
|
|
27
227
|
version: ProtocolVersion;
|
|
28
|
-
/**
|
|
228
|
+
/**
|
|
229
|
+
* Map of capability name to optional value.
|
|
230
|
+
* The key is the capability name, value is the capability value or undefined.
|
|
231
|
+
*/
|
|
29
232
|
capabilities: Map<string, string | undefined>;
|
|
30
233
|
}
|
|
31
|
-
/**
|
|
234
|
+
/**
|
|
235
|
+
* Ref advertisement with capabilities (protocol v1).
|
|
236
|
+
*
|
|
237
|
+
* @description
|
|
238
|
+
* Represents a single ref line from the server's ref advertisement.
|
|
239
|
+
* The first ref line includes capabilities after a NUL byte separator.
|
|
240
|
+
*
|
|
241
|
+
* @example
|
|
242
|
+
* ```typescript
|
|
243
|
+
* // First ref (with capabilities)
|
|
244
|
+
* const firstRef: RefAdvertisement = {
|
|
245
|
+
* oid: 'abc123def456...',
|
|
246
|
+
* name: 'refs/heads/main',
|
|
247
|
+
* capabilities: {
|
|
248
|
+
* version: 1,
|
|
249
|
+
* capabilities: new Map([['multi_ack', undefined]])
|
|
250
|
+
* }
|
|
251
|
+
* };
|
|
252
|
+
*
|
|
253
|
+
* // Subsequent ref (no capabilities)
|
|
254
|
+
* const otherRef: RefAdvertisement = {
|
|
255
|
+
* oid: 'def789abc012...',
|
|
256
|
+
* name: 'refs/heads/feature'
|
|
257
|
+
* };
|
|
258
|
+
* ```
|
|
259
|
+
*/
|
|
32
260
|
export interface RefAdvertisement {
|
|
33
|
-
/**
|
|
261
|
+
/**
|
|
262
|
+
* The SHA-1 hash of the ref's target object.
|
|
263
|
+
* 40 hexadecimal characters for SHA-1.
|
|
264
|
+
*/
|
|
34
265
|
oid: string;
|
|
35
|
-
/**
|
|
266
|
+
/**
|
|
267
|
+
* The full ref name (e.g., 'refs/heads/main', 'refs/tags/v1.0').
|
|
268
|
+
*/
|
|
36
269
|
name: string;
|
|
37
|
-
/**
|
|
270
|
+
/**
|
|
271
|
+
* Capabilities advertised by the server.
|
|
272
|
+
* Only present on the first ref line in protocol v1.
|
|
273
|
+
* @default undefined
|
|
274
|
+
*/
|
|
38
275
|
capabilities?: CapabilitySet;
|
|
39
276
|
}
|
|
40
|
-
/**
|
|
277
|
+
/**
|
|
278
|
+
* Protocol v2 server capabilities response.
|
|
279
|
+
*
|
|
280
|
+
* @description
|
|
281
|
+
* Parsed server capability advertisement for protocol v2.
|
|
282
|
+
* Unlike v1, protocol v2 separates commands (services) from
|
|
283
|
+
* general capabilities and provides structured sub-capability values.
|
|
284
|
+
*
|
|
285
|
+
* @example
|
|
286
|
+
* ```typescript
|
|
287
|
+
* const serverCaps: ServerCapabilitiesV2 = {
|
|
288
|
+
* version: 2,
|
|
289
|
+
* commands: ['ls-refs', 'fetch', 'server-option'],
|
|
290
|
+
* agent: 'git/2.40.0',
|
|
291
|
+
* objectFormat: 'sha1',
|
|
292
|
+
* capabilities: new Map([
|
|
293
|
+
* ['fetch', 'shallow filter'],
|
|
294
|
+
* ['ls-refs', 'symrefs peel']
|
|
295
|
+
* ])
|
|
296
|
+
* };
|
|
297
|
+
*
|
|
298
|
+
* if (serverCaps.commands.includes('fetch')) {
|
|
299
|
+
* console.log('Server supports fetch command');
|
|
300
|
+
* }
|
|
301
|
+
* ```
|
|
302
|
+
*/
|
|
41
303
|
export interface ServerCapabilitiesV2 {
|
|
304
|
+
/**
|
|
305
|
+
* Protocol version, always 2 for this interface.
|
|
306
|
+
*/
|
|
42
307
|
version: 2;
|
|
43
|
-
/**
|
|
308
|
+
/**
|
|
309
|
+
* List of supported commands/services.
|
|
310
|
+
* Common commands: 'ls-refs', 'fetch', 'server-option'.
|
|
311
|
+
*/
|
|
44
312
|
commands: string[];
|
|
45
|
-
/**
|
|
313
|
+
/**
|
|
314
|
+
* Agent identification string (e.g., 'git/2.40.0').
|
|
315
|
+
* @default undefined
|
|
316
|
+
*/
|
|
46
317
|
agent?: string;
|
|
47
|
-
/**
|
|
318
|
+
/**
|
|
319
|
+
* Object hash format used by the repository.
|
|
320
|
+
* @default undefined (implies 'sha1')
|
|
321
|
+
*/
|
|
48
322
|
objectFormat?: 'sha1' | 'sha256';
|
|
49
|
-
/**
|
|
323
|
+
/**
|
|
324
|
+
* Map of capability names to values.
|
|
325
|
+
* Commands may have sub-capabilities as values (e.g., 'fetch' -> 'shallow filter').
|
|
326
|
+
*/
|
|
50
327
|
capabilities: Map<string, string | undefined>;
|
|
51
328
|
}
|
|
52
|
-
/**
|
|
329
|
+
/**
|
|
330
|
+
* Want line with capabilities for fetch request.
|
|
331
|
+
*
|
|
332
|
+
* @description
|
|
333
|
+
* Represents a client's fetch request specifying which objects are wanted
|
|
334
|
+
* and what capabilities the client supports. Capabilities are only sent
|
|
335
|
+
* with the first want line.
|
|
336
|
+
*
|
|
337
|
+
* @example
|
|
338
|
+
* ```typescript
|
|
339
|
+
* const request: WantRequest = {
|
|
340
|
+
* wants: [
|
|
341
|
+
* 'abc123def456789012345678901234567890abcd',
|
|
342
|
+
* 'def456789012345678901234567890abcdef12'
|
|
343
|
+
* ],
|
|
344
|
+
* capabilities: [
|
|
345
|
+
* { name: 'multi_ack_detailed' },
|
|
346
|
+
* { name: 'side-band-64k' },
|
|
347
|
+
* { name: 'agent', value: 'gitdo/1.0' }
|
|
348
|
+
* ]
|
|
349
|
+
* };
|
|
350
|
+
*
|
|
351
|
+
* const lines = buildFetchRequest(request);
|
|
352
|
+
* // First line: "want abc123... multi_ack_detailed side-band-64k agent=gitdo/1.0\n"
|
|
353
|
+
* // Second line: "want def456...\n"
|
|
354
|
+
* ```
|
|
355
|
+
*/
|
|
53
356
|
export interface WantRequest {
|
|
54
|
-
/**
|
|
357
|
+
/**
|
|
358
|
+
* SHA-1 hashes of objects the client wants to receive.
|
|
359
|
+
* These are typically commit objects at ref tips.
|
|
360
|
+
*/
|
|
55
361
|
wants: string[];
|
|
56
|
-
/**
|
|
362
|
+
/**
|
|
363
|
+
* Capabilities to advertise to the server.
|
|
364
|
+
* Sent only with the first want line.
|
|
365
|
+
*/
|
|
57
366
|
capabilities: CapabilityEntry[];
|
|
58
367
|
}
|
|
59
|
-
/**
|
|
368
|
+
/**
|
|
369
|
+
* Have line for negotiation.
|
|
370
|
+
*
|
|
371
|
+
* @description
|
|
372
|
+
* Represents objects the client already has, used during negotiation
|
|
373
|
+
* to determine the minimal set of objects to send.
|
|
374
|
+
*
|
|
375
|
+
* @example
|
|
376
|
+
* ```typescript
|
|
377
|
+
* const haves: HaveRequest = {
|
|
378
|
+
* haves: [
|
|
379
|
+
* 'abc123def456789012345678901234567890abcd',
|
|
380
|
+
* 'def456789012345678901234567890abcdef12'
|
|
381
|
+
* ],
|
|
382
|
+
* done: true
|
|
383
|
+
* };
|
|
384
|
+
* ```
|
|
385
|
+
*/
|
|
60
386
|
export interface HaveRequest {
|
|
61
|
-
/**
|
|
387
|
+
/**
|
|
388
|
+
* SHA-1 hashes of objects the client already has.
|
|
389
|
+
* Used to find common ancestors and minimize data transfer.
|
|
390
|
+
*/
|
|
62
391
|
haves: string[];
|
|
63
|
-
/**
|
|
392
|
+
/**
|
|
393
|
+
* Whether this is the final batch of have lines.
|
|
394
|
+
* When true, indicates the client is ready to receive the packfile.
|
|
395
|
+
* @default undefined
|
|
396
|
+
*/
|
|
64
397
|
done?: boolean;
|
|
65
398
|
}
|
|
66
|
-
/**
|
|
399
|
+
/**
|
|
400
|
+
* Version negotiation result.
|
|
401
|
+
*
|
|
402
|
+
* @description
|
|
403
|
+
* Result of protocol version negotiation between client and server.
|
|
404
|
+
* The agreed version determines the communication format.
|
|
405
|
+
*
|
|
406
|
+
* @example
|
|
407
|
+
* ```typescript
|
|
408
|
+
* const result = negotiateVersion('version 2', 2);
|
|
409
|
+
* // result.version === 2
|
|
410
|
+
* // result.serverSupportsV2 === true
|
|
411
|
+
*
|
|
412
|
+
* const resultV1 = negotiateVersion('abc123... refs/heads/main\0multi_ack', 2);
|
|
413
|
+
* // resultV1.version === 1
|
|
414
|
+
* // resultV1.serverSupportsV2 === false
|
|
415
|
+
* ```
|
|
416
|
+
*/
|
|
67
417
|
export interface VersionNegotiationResult {
|
|
68
|
-
/**
|
|
418
|
+
/**
|
|
419
|
+
* The protocol version that will be used.
|
|
420
|
+
* This is the lower of the client's preference and server's support.
|
|
421
|
+
*/
|
|
69
422
|
version: ProtocolVersion;
|
|
70
|
-
/**
|
|
423
|
+
/**
|
|
424
|
+
* Whether the server advertised protocol v2 support.
|
|
425
|
+
*/
|
|
71
426
|
serverSupportsV2: boolean;
|
|
72
|
-
/**
|
|
427
|
+
/**
|
|
428
|
+
* Capability names supported by both client and server.
|
|
429
|
+
*/
|
|
73
430
|
commonCapabilities: string[];
|
|
74
431
|
}
|
|
75
|
-
/**
|
|
432
|
+
/**
|
|
433
|
+
* Default client capabilities for fetch operations (protocol v1).
|
|
434
|
+
*
|
|
435
|
+
* @description
|
|
436
|
+
* A sensible set of capabilities for fetch operations that provides
|
|
437
|
+
* good performance while maintaining compatibility. These are commonly
|
|
438
|
+
* supported by modern Git servers.
|
|
439
|
+
*
|
|
440
|
+
* - `multi_ack_detailed`: Efficient negotiation with detailed feedback
|
|
441
|
+
* - `side-band-64k`: Large multiplexed data channels for progress/data
|
|
442
|
+
* - `thin-pack`: Receive thin packs (smaller transfer size)
|
|
443
|
+
* - `ofs-delta`: Efficient delta encoding
|
|
444
|
+
* - `agent`: Identify the client
|
|
445
|
+
*
|
|
446
|
+
* @example
|
|
447
|
+
* ```typescript
|
|
448
|
+
* const clientCaps = DEFAULT_FETCH_CAPABILITIES_V1.map(name => ({ name }));
|
|
449
|
+
* // Add agent value
|
|
450
|
+
* clientCaps.find(c => c.name === 'agent')!.value = 'gitdo/1.0';
|
|
451
|
+
*
|
|
452
|
+
* const selected = selectFetchCapabilities(serverCaps, clientCaps);
|
|
453
|
+
* ```
|
|
454
|
+
*/
|
|
76
455
|
export declare const DEFAULT_FETCH_CAPABILITIES_V1: CapabilityV1[];
|
|
77
|
-
/**
|
|
456
|
+
/**
|
|
457
|
+
* Default client capabilities for push operations (protocol v1).
|
|
458
|
+
*
|
|
459
|
+
* @description
|
|
460
|
+
* A sensible set of capabilities for push operations that provides
|
|
461
|
+
* detailed feedback and compatibility with modern Git servers.
|
|
462
|
+
*
|
|
463
|
+
* - `report-status`: Receive detailed push result status
|
|
464
|
+
* - `side-band-64k`: Multiplexed channels for status/errors
|
|
465
|
+
* - `agent`: Identify the client
|
|
466
|
+
* - `quiet`: Suppress unnecessary progress output
|
|
467
|
+
*
|
|
468
|
+
* @example
|
|
469
|
+
* ```typescript
|
|
470
|
+
* const pushCaps = DEFAULT_PUSH_CAPABILITIES_V1.map(name => ({ name }));
|
|
471
|
+
* pushCaps.find(c => c.name === 'agent')!.value = 'gitdo/1.0';
|
|
472
|
+
* ```
|
|
473
|
+
*/
|
|
78
474
|
export declare const DEFAULT_PUSH_CAPABILITIES_V1: CapabilityV1[];
|
|
79
|
-
/**
|
|
475
|
+
/**
|
|
476
|
+
* Minimum required capabilities for basic fetch.
|
|
477
|
+
*
|
|
478
|
+
* @description
|
|
479
|
+
* Capabilities that must be present for fetch to work correctly.
|
|
480
|
+
* Currently empty as Git is designed to work with minimal capabilities,
|
|
481
|
+
* but this can be populated if specific capabilities become required.
|
|
482
|
+
*
|
|
483
|
+
* @example
|
|
484
|
+
* ```typescript
|
|
485
|
+
* const missing = validateRequiredCapabilities(serverCaps, REQUIRED_FETCH_CAPABILITIES);
|
|
486
|
+
* if (missing.length > 0) {
|
|
487
|
+
* throw new Error(`Server missing required capabilities: ${missing.join(', ')}`);
|
|
488
|
+
* }
|
|
489
|
+
* ```
|
|
490
|
+
*/
|
|
80
491
|
export declare const REQUIRED_FETCH_CAPABILITIES: CapabilityV1[];
|
|
81
492
|
/**
|
|
82
493
|
* Parse a capability string from ref advertisement (protocol v1).
|
|
83
494
|
*
|
|
84
|
-
*
|
|
495
|
+
* @description
|
|
496
|
+
* Extracts capabilities from a protocol v1 ref advertisement line.
|
|
497
|
+
* The capabilities appear after a NUL byte (`\0`) separator following
|
|
498
|
+
* the ref information. This is only present on the first ref line.
|
|
85
499
|
*
|
|
86
|
-
*
|
|
87
|
-
*
|
|
500
|
+
* Line format: `<oid> <refname>\0<cap1> <cap2> cap3=value...`
|
|
501
|
+
*
|
|
502
|
+
* @param line - The ref advertisement line containing capabilities
|
|
503
|
+
* @returns Parsed capability set with version 1
|
|
504
|
+
*
|
|
505
|
+
* @throws {Error} If the line doesn't contain a NUL byte separator
|
|
506
|
+
*
|
|
507
|
+
* @example
|
|
508
|
+
* ```typescript
|
|
509
|
+
* // Parse from first ref line
|
|
510
|
+
* const line = 'abc123def456789012345678901234567890abcd refs/heads/main\0multi_ack side-band-64k agent=git/2.30.0';
|
|
511
|
+
* const caps = parseCapabilityString(line);
|
|
512
|
+
*
|
|
513
|
+
* console.log(caps.version); // 1
|
|
514
|
+
* console.log(caps.capabilities.has('multi_ack')); // true
|
|
515
|
+
* console.log(caps.capabilities.get('agent')); // 'git/2.30.0'
|
|
516
|
+
* ```
|
|
88
517
|
*/
|
|
89
518
|
export declare function parseCapabilityString(line: string): CapabilitySet;
|
|
90
519
|
/**
|
|
91
520
|
* Parse individual capability entries from a space-separated string.
|
|
92
521
|
*
|
|
522
|
+
* @description
|
|
523
|
+
* Parses a whitespace-separated capability string into individual entries.
|
|
524
|
+
* Handles both simple capabilities (`multi_ack`) and capabilities with
|
|
525
|
+
* values (`agent=git/2.30.0`).
|
|
526
|
+
*
|
|
93
527
|
* @param capString - Space-separated capability string
|
|
94
528
|
* @returns Array of capability entries
|
|
529
|
+
*
|
|
530
|
+
* @example
|
|
531
|
+
* ```typescript
|
|
532
|
+
* // Simple capabilities
|
|
533
|
+
* const caps1 = parseCapabilities('multi_ack thin-pack ofs-delta');
|
|
534
|
+
* // [{ name: 'multi_ack' }, { name: 'thin-pack' }, { name: 'ofs-delta' }]
|
|
535
|
+
*
|
|
536
|
+
* // Capabilities with values
|
|
537
|
+
* const caps2 = parseCapabilities('agent=git/2.30.0 symref=HEAD:refs/heads/main');
|
|
538
|
+
* // [{ name: 'agent', value: 'git/2.30.0' }, { name: 'symref', value: 'HEAD:refs/heads/main' }]
|
|
539
|
+
*
|
|
540
|
+
* // Empty string
|
|
541
|
+
* const caps3 = parseCapabilities('');
|
|
542
|
+
* // []
|
|
543
|
+
* ```
|
|
95
544
|
*/
|
|
96
545
|
export declare function parseCapabilities(capString: string): CapabilityEntry[];
|
|
97
546
|
/**
|
|
98
547
|
* Parse a ref advertisement line (protocol v1).
|
|
99
548
|
*
|
|
100
|
-
*
|
|
101
|
-
*
|
|
549
|
+
* @description
|
|
550
|
+
* Parses a single line from the server's ref advertisement. The first
|
|
551
|
+
* line has a special format including capabilities after a NUL byte,
|
|
552
|
+
* while subsequent lines contain only the OID and ref name.
|
|
553
|
+
*
|
|
554
|
+
* First line format: `<oid> <refname>\0<capabilities>`
|
|
555
|
+
* Subsequent lines: `<oid> <refname>`
|
|
102
556
|
*
|
|
103
557
|
* @param line - The pkt-line data (without length prefix)
|
|
104
558
|
* @param isFirst - Whether this is the first line (contains capabilities)
|
|
105
559
|
* @returns Parsed ref advertisement
|
|
560
|
+
*
|
|
561
|
+
* @throws {Error} If the first line is missing the NUL byte
|
|
562
|
+
* @throws {Error} If the line is missing the space between OID and refname
|
|
563
|
+
* @throws {Error} If the OID is not 40 characters (SHA-1)
|
|
564
|
+
*
|
|
565
|
+
* @example
|
|
566
|
+
* ```typescript
|
|
567
|
+
* // Parse first line (with capabilities)
|
|
568
|
+
* const firstLine = 'abc123def456789012345678901234567890abcd refs/heads/main\0multi_ack side-band-64k\n';
|
|
569
|
+
* const firstRef = parseRefAdvertisement(firstLine, true);
|
|
570
|
+
* // {
|
|
571
|
+
* // oid: 'abc123def456789012345678901234567890abcd',
|
|
572
|
+
* // name: 'refs/heads/main',
|
|
573
|
+
* // capabilities: { version: 1, capabilities: Map {...} }
|
|
574
|
+
* // }
|
|
575
|
+
*
|
|
576
|
+
* // Parse subsequent line (no capabilities)
|
|
577
|
+
* const otherLine = 'def456789012345678901234567890abcdef12 refs/heads/feature\n';
|
|
578
|
+
* const otherRef = parseRefAdvertisement(otherLine, false);
|
|
579
|
+
* // {
|
|
580
|
+
* // oid: 'def456789012345678901234567890abcdef12',
|
|
581
|
+
* // name: 'refs/heads/feature'
|
|
582
|
+
* // }
|
|
583
|
+
* ```
|
|
106
584
|
*/
|
|
107
585
|
export declare function parseRefAdvertisement(line: string, isFirst: boolean): RefAdvertisement;
|
|
108
586
|
/**
|
|
109
587
|
* Parse protocol v2 capability advertisement.
|
|
110
588
|
*
|
|
111
|
-
*
|
|
112
|
-
*
|
|
113
|
-
*
|
|
114
|
-
*
|
|
115
|
-
*
|
|
116
|
-
* server-option
|
|
117
|
-
* object-format=sha1
|
|
589
|
+
* @description
|
|
590
|
+
* Parses the server's capability advertisement in protocol v2 format.
|
|
591
|
+
* Protocol v2 uses a line-by-line format starting with "version 2",
|
|
592
|
+
* followed by capability lines. Commands and capabilities are distinguished
|
|
593
|
+
* by whether they have values.
|
|
118
594
|
*
|
|
119
|
-
*
|
|
595
|
+
* Response format:
|
|
596
|
+
* ```
|
|
597
|
+
* version 2
|
|
598
|
+
* agent=git/2.30.0
|
|
599
|
+
* ls-refs
|
|
600
|
+
* fetch=shallow filter
|
|
601
|
+
* server-option
|
|
602
|
+
* object-format=sha1
|
|
603
|
+
* ```
|
|
604
|
+
*
|
|
605
|
+
* @param lines - Array of pkt-line data (without length prefixes)
|
|
120
606
|
* @returns Parsed server capabilities
|
|
607
|
+
*
|
|
608
|
+
* @throws {Error} If lines is empty or doesn't start with "version 2"
|
|
609
|
+
*
|
|
610
|
+
* @example
|
|
611
|
+
* ```typescript
|
|
612
|
+
* const lines = [
|
|
613
|
+
* 'version 2',
|
|
614
|
+
* 'agent=git/2.40.0',
|
|
615
|
+
* 'ls-refs',
|
|
616
|
+
* 'fetch=shallow filter',
|
|
617
|
+
* 'server-option',
|
|
618
|
+
* 'object-format=sha1'
|
|
619
|
+
* ];
|
|
620
|
+
*
|
|
621
|
+
* const serverCaps = parseServerCapabilitiesV2(lines);
|
|
622
|
+
* // {
|
|
623
|
+
* // version: 2,
|
|
624
|
+
* // commands: ['ls-refs', 'fetch', 'server-option'],
|
|
625
|
+
* // agent: 'git/2.40.0',
|
|
626
|
+
* // objectFormat: 'sha1',
|
|
627
|
+
* // capabilities: Map { 'ls-refs' => undefined, 'fetch' => 'shallow filter', ... }
|
|
628
|
+
* // }
|
|
629
|
+
*
|
|
630
|
+
* if (serverCaps.commands.includes('fetch')) {
|
|
631
|
+
* console.log('Server supports fetch with:', serverCaps.capabilities.get('fetch'));
|
|
632
|
+
* }
|
|
633
|
+
* ```
|
|
121
634
|
*/
|
|
122
635
|
export declare function parseServerCapabilitiesV2(lines: string[]): ServerCapabilitiesV2;
|
|
123
636
|
/**
|
|
124
637
|
* Build a capability string for want/have request (protocol v1).
|
|
125
638
|
*
|
|
639
|
+
* @description
|
|
640
|
+
* Constructs a space-separated capability string from an array of
|
|
641
|
+
* capability entries. Capabilities with values are formatted as
|
|
642
|
+
* `name=value`, while those without are just the name.
|
|
643
|
+
*
|
|
126
644
|
* @param capabilities - Capabilities to include
|
|
127
645
|
* @returns Space-separated capability string
|
|
646
|
+
*
|
|
647
|
+
* @example
|
|
648
|
+
* ```typescript
|
|
649
|
+
* const caps: CapabilityEntry[] = [
|
|
650
|
+
* { name: 'multi_ack_detailed' },
|
|
651
|
+
* { name: 'side-band-64k' },
|
|
652
|
+
* { name: 'agent', value: 'gitdo/1.0' }
|
|
653
|
+
* ];
|
|
654
|
+
*
|
|
655
|
+
* const str = buildCapabilityString(caps);
|
|
656
|
+
* // 'multi_ack_detailed side-band-64k agent=gitdo/1.0'
|
|
657
|
+
* ```
|
|
128
658
|
*/
|
|
129
659
|
export declare function buildCapabilityString(capabilities: CapabilityEntry[]): string;
|
|
130
660
|
/**
|
|
131
661
|
* Build a want line with capabilities (first want only).
|
|
132
662
|
*
|
|
133
|
-
*
|
|
663
|
+
* @description
|
|
664
|
+
* Constructs a want line for a fetch request. The first want line
|
|
665
|
+
* includes capabilities, while subsequent want lines contain only
|
|
666
|
+
* the object ID.
|
|
134
667
|
*
|
|
135
|
-
*
|
|
136
|
-
*
|
|
137
|
-
*
|
|
668
|
+
* Format: `want <oid> <capabilities>\n` (first line)
|
|
669
|
+
* Format: `want <oid>\n` (subsequent lines)
|
|
670
|
+
*
|
|
671
|
+
* @param oid - The object ID to want (40-character SHA-1 hex string)
|
|
672
|
+
* @param capabilities - Capabilities to include (optional, first want only)
|
|
673
|
+
* @returns Formatted want line with trailing newline
|
|
674
|
+
*
|
|
675
|
+
* @example
|
|
676
|
+
* ```typescript
|
|
677
|
+
* // First want line with capabilities
|
|
678
|
+
* const firstWant = buildWantLine(
|
|
679
|
+
* 'abc123def456789012345678901234567890abcd',
|
|
680
|
+
* [{ name: 'multi_ack' }, { name: 'agent', value: 'gitdo/1.0' }]
|
|
681
|
+
* );
|
|
682
|
+
* // 'want abc123def456789012345678901234567890abcd multi_ack agent=gitdo/1.0\n'
|
|
683
|
+
*
|
|
684
|
+
* // Subsequent want line (no capabilities)
|
|
685
|
+
* const nextWant = buildWantLine('def456789012345678901234567890abcdef12');
|
|
686
|
+
* // 'want def456789012345678901234567890abcdef12\n'
|
|
687
|
+
* ```
|
|
138
688
|
*/
|
|
139
689
|
export declare function buildWantLine(oid: string, capabilities?: CapabilityEntry[]): string;
|
|
140
690
|
/**
|
|
141
691
|
* Build a have line for negotiation.
|
|
142
692
|
*
|
|
143
|
-
*
|
|
693
|
+
* @description
|
|
694
|
+
* Constructs a have line used during fetch negotiation. Have lines
|
|
695
|
+
* inform the server what objects the client already has, allowing
|
|
696
|
+
* the server to determine the minimal set of objects to send.
|
|
697
|
+
*
|
|
698
|
+
* Format: `have <oid>\n`
|
|
699
|
+
*
|
|
700
|
+
* @param oid - The object ID we have (40-character SHA-1 hex string)
|
|
701
|
+
* @returns Formatted have line with trailing newline
|
|
702
|
+
*
|
|
703
|
+
* @example
|
|
704
|
+
* ```typescript
|
|
705
|
+
* const haveLine = buildHaveLine('abc123def456789012345678901234567890abcd');
|
|
706
|
+
* // 'have abc123def456789012345678901234567890abcd\n'
|
|
144
707
|
*
|
|
145
|
-
*
|
|
146
|
-
*
|
|
708
|
+
* // OID is normalized to lowercase
|
|
709
|
+
* const normalized = buildHaveLine('ABC123DEF456789012345678901234567890ABCD');
|
|
710
|
+
* // 'have abc123def456789012345678901234567890abcd\n'
|
|
711
|
+
* ```
|
|
147
712
|
*/
|
|
148
713
|
export declare function buildHaveLine(oid: string): string;
|
|
149
714
|
/**
|
|
150
715
|
* Build a complete want/have request.
|
|
151
716
|
*
|
|
152
|
-
* @
|
|
153
|
-
*
|
|
717
|
+
* @description
|
|
718
|
+
* Constructs all want lines for a fetch request. The first want line
|
|
719
|
+
* includes the client's capabilities, while subsequent want lines
|
|
720
|
+
* contain only the object IDs.
|
|
721
|
+
*
|
|
722
|
+
* @param request - The want request containing object IDs and capabilities
|
|
723
|
+
* @returns Array of formatted want lines (ready for pkt-line encoding)
|
|
724
|
+
*
|
|
725
|
+
* @example
|
|
726
|
+
* ```typescript
|
|
727
|
+
* const request: WantRequest = {
|
|
728
|
+
* wants: [
|
|
729
|
+
* 'abc123def456789012345678901234567890abcd',
|
|
730
|
+
* 'def456789012345678901234567890abcdef12',
|
|
731
|
+
* '123456789012345678901234567890abcdef00'
|
|
732
|
+
* ],
|
|
733
|
+
* capabilities: [
|
|
734
|
+
* { name: 'multi_ack_detailed' },
|
|
735
|
+
* { name: 'side-band-64k' }
|
|
736
|
+
* ]
|
|
737
|
+
* };
|
|
738
|
+
*
|
|
739
|
+
* const lines = buildFetchRequest(request);
|
|
740
|
+
* // [
|
|
741
|
+
* // 'want abc123... multi_ack_detailed side-band-64k\n',
|
|
742
|
+
* // 'want def456...\n',
|
|
743
|
+
* // 'want 123456...\n'
|
|
744
|
+
* // ]
|
|
745
|
+
* ```
|
|
154
746
|
*/
|
|
155
747
|
export declare function buildFetchRequest(request: WantRequest): string[];
|
|
156
748
|
/**
|
|
157
749
|
* Build protocol v2 command request.
|
|
158
750
|
*
|
|
159
|
-
*
|
|
160
|
-
*
|
|
161
|
-
*
|
|
162
|
-
*
|
|
163
|
-
*
|
|
164
|
-
*
|
|
165
|
-
*
|
|
751
|
+
* @description
|
|
752
|
+
* Constructs a protocol v2 command request. Protocol v2 uses a structured
|
|
753
|
+
* format with command specification, capabilities, and optional arguments.
|
|
754
|
+
*
|
|
755
|
+
* Request format:
|
|
756
|
+
* ```
|
|
757
|
+
* command=<cmd>
|
|
758
|
+
* capability1
|
|
759
|
+
* capability2=value
|
|
760
|
+
* 0001 (delimiter - added by caller)
|
|
761
|
+
* <command-specific args>
|
|
762
|
+
* 0000 (flush - added by caller)
|
|
763
|
+
* ```
|
|
166
764
|
*
|
|
167
765
|
* @param command - The v2 command (e.g., 'fetch', 'ls-refs')
|
|
168
|
-
* @param capabilities - Client capabilities
|
|
169
|
-
* @param args - Command-specific arguments
|
|
170
|
-
* @returns Array of pkt-line
|
|
766
|
+
* @param capabilities - Client capabilities to advertise
|
|
767
|
+
* @param args - Command-specific arguments (optional)
|
|
768
|
+
* @returns Array of lines (ready for pkt-line encoding)
|
|
769
|
+
*
|
|
770
|
+
* @example
|
|
771
|
+
* ```typescript
|
|
772
|
+
* // ls-refs request
|
|
773
|
+
* const lsRefsLines = buildV2CommandRequest(
|
|
774
|
+
* 'ls-refs',
|
|
775
|
+
* [{ name: 'agent', value: 'gitdo/1.0' }],
|
|
776
|
+
* ['peel', 'symrefs', 'ref-prefix refs/heads/']
|
|
777
|
+
* );
|
|
778
|
+
* // [
|
|
779
|
+
* // 'command=ls-refs',
|
|
780
|
+
* // 'agent=gitdo/1.0',
|
|
781
|
+
* // 'peel',
|
|
782
|
+
* // 'symrefs',
|
|
783
|
+
* // 'ref-prefix refs/heads/'
|
|
784
|
+
* // ]
|
|
785
|
+
*
|
|
786
|
+
* // fetch request
|
|
787
|
+
* const fetchLines = buildV2CommandRequest(
|
|
788
|
+
* 'fetch',
|
|
789
|
+
* [{ name: 'agent', value: 'gitdo/1.0' }, { name: 'thin-pack' }],
|
|
790
|
+
* ['want abc123...', 'have def456...', 'done']
|
|
791
|
+
* );
|
|
792
|
+
* ```
|
|
171
793
|
*/
|
|
172
794
|
export declare function buildV2CommandRequest(command: string, capabilities: CapabilityEntry[], args?: string[]): string[];
|
|
173
795
|
/**
|
|
174
796
|
* Negotiate protocol version with server.
|
|
175
797
|
*
|
|
176
|
-
* @
|
|
177
|
-
*
|
|
178
|
-
*
|
|
798
|
+
* @description
|
|
799
|
+
* Determines the protocol version to use based on the server's advertisement
|
|
800
|
+
* and the client's preference. The negotiated version is the highest version
|
|
801
|
+
* supported by both parties.
|
|
802
|
+
*
|
|
803
|
+
* @param serverAdvertisement - First line from server's response
|
|
804
|
+
* @param preferredVersion - Client's preferred protocol version (default: 2)
|
|
805
|
+
* @returns Negotiation result with agreed version
|
|
806
|
+
*
|
|
807
|
+
* @example
|
|
808
|
+
* ```typescript
|
|
809
|
+
* // Server supports v2, client prefers v2
|
|
810
|
+
* const v2Result = negotiateVersion('version 2', 2);
|
|
811
|
+
* // { version: 2, serverSupportsV2: true, commonCapabilities: [] }
|
|
812
|
+
*
|
|
813
|
+
* // Server is v1 only, client prefers v2
|
|
814
|
+
* const v1Result = negotiateVersion('abc123... refs/heads/main\0multi_ack', 2);
|
|
815
|
+
* // { version: 1, serverSupportsV2: false, commonCapabilities: [] }
|
|
816
|
+
*
|
|
817
|
+
* // Client explicitly wants v1
|
|
818
|
+
* const explicitV1 = negotiateVersion('version 2', 1);
|
|
819
|
+
* // { version: 1, serverSupportsV2: true, commonCapabilities: [] }
|
|
820
|
+
* ```
|
|
179
821
|
*/
|
|
180
822
|
export declare function negotiateVersion(serverAdvertisement: string, preferredVersion?: ProtocolVersion): VersionNegotiationResult;
|
|
181
823
|
/**
|
|
182
824
|
* Find common capabilities between client and server.
|
|
183
825
|
*
|
|
184
|
-
* @
|
|
185
|
-
*
|
|
186
|
-
*
|
|
826
|
+
* @description
|
|
827
|
+
* Determines which capabilities are supported by both the client and server.
|
|
828
|
+
* This is used to select the optimal set of capabilities for the session.
|
|
829
|
+
*
|
|
830
|
+
* @param clientCaps - Client's supported capabilities
|
|
831
|
+
* @param serverCaps - Server's advertised capabilities
|
|
832
|
+
* @returns Array of capability names supported by both parties
|
|
833
|
+
*
|
|
834
|
+
* @example
|
|
835
|
+
* ```typescript
|
|
836
|
+
* const clientCaps: CapabilityEntry[] = [
|
|
837
|
+
* { name: 'multi_ack_detailed' },
|
|
838
|
+
* { name: 'side-band-64k' },
|
|
839
|
+
* { name: 'thin-pack' },
|
|
840
|
+
* { name: 'ofs-delta' }
|
|
841
|
+
* ];
|
|
842
|
+
*
|
|
843
|
+
* const serverCaps: CapabilitySet = {
|
|
844
|
+
* version: 1,
|
|
845
|
+
* capabilities: new Map([
|
|
846
|
+
* ['multi_ack', undefined],
|
|
847
|
+
* ['multi_ack_detailed', undefined],
|
|
848
|
+
* ['side-band-64k', undefined],
|
|
849
|
+
* ['shallow', undefined]
|
|
850
|
+
* ])
|
|
851
|
+
* };
|
|
852
|
+
*
|
|
853
|
+
* const common = findCommonCapabilities(clientCaps, serverCaps);
|
|
854
|
+
* // ['multi_ack_detailed', 'side-band-64k']
|
|
855
|
+
* ```
|
|
187
856
|
*/
|
|
188
857
|
export declare function findCommonCapabilities(clientCaps: CapabilityEntry[], serverCaps: CapabilitySet): string[];
|
|
189
858
|
/**
|
|
190
859
|
* Check if a specific capability is supported.
|
|
191
860
|
*
|
|
861
|
+
* @description
|
|
862
|
+
* Checks whether a capability is present in the capability set.
|
|
863
|
+
* This is a convenience wrapper around Map.has().
|
|
864
|
+
*
|
|
192
865
|
* @param capSet - The capability set to check
|
|
193
|
-
* @param name - The capability name
|
|
194
|
-
* @returns True if capability is
|
|
866
|
+
* @param name - The capability name to look for
|
|
867
|
+
* @returns True if the capability is present
|
|
868
|
+
*
|
|
869
|
+
* @example
|
|
870
|
+
* ```typescript
|
|
871
|
+
* const caps: CapabilitySet = {
|
|
872
|
+
* version: 1,
|
|
873
|
+
* capabilities: new Map([
|
|
874
|
+
* ['multi_ack', undefined],
|
|
875
|
+
* ['side-band-64k', undefined],
|
|
876
|
+
* ['agent', 'git/2.30.0']
|
|
877
|
+
* ])
|
|
878
|
+
* };
|
|
879
|
+
*
|
|
880
|
+
* hasCapability(caps, 'multi_ack'); // true
|
|
881
|
+
* hasCapability(caps, 'side-band-64k'); // true
|
|
882
|
+
* hasCapability(caps, 'thin-pack'); // false
|
|
883
|
+
* ```
|
|
195
884
|
*/
|
|
196
885
|
export declare function hasCapability(capSet: CapabilitySet, name: string): boolean;
|
|
197
886
|
/**
|
|
198
887
|
* Get the value of a capability (if it has one).
|
|
199
888
|
*
|
|
200
|
-
* @
|
|
889
|
+
* @description
|
|
890
|
+
* Retrieves the value associated with a capability. Returns undefined
|
|
891
|
+
* if the capability is not present or has no value.
|
|
892
|
+
*
|
|
893
|
+
* @param capSet - The capability set to query
|
|
201
894
|
* @param name - The capability name
|
|
202
|
-
* @returns The capability value or undefined
|
|
895
|
+
* @returns The capability value, or undefined if not present/no value
|
|
896
|
+
*
|
|
897
|
+
* @example
|
|
898
|
+
* ```typescript
|
|
899
|
+
* const caps: CapabilitySet = {
|
|
900
|
+
* version: 1,
|
|
901
|
+
* capabilities: new Map([
|
|
902
|
+
* ['multi_ack', undefined],
|
|
903
|
+
* ['agent', 'git/2.30.0'],
|
|
904
|
+
* ['symref', 'HEAD:refs/heads/main']
|
|
905
|
+
* ])
|
|
906
|
+
* };
|
|
907
|
+
*
|
|
908
|
+
* getCapabilityValue(caps, 'agent'); // 'git/2.30.0'
|
|
909
|
+
* getCapabilityValue(caps, 'symref'); // 'HEAD:refs/heads/main'
|
|
910
|
+
* getCapabilityValue(caps, 'multi_ack'); // undefined (present but no value)
|
|
911
|
+
* getCapabilityValue(caps, 'thin-pack'); // undefined (not present)
|
|
912
|
+
* ```
|
|
203
913
|
*/
|
|
204
914
|
export declare function getCapabilityValue(capSet: CapabilitySet, name: string): string | undefined;
|
|
205
915
|
/**
|
|
206
916
|
* Create a capability set from entries.
|
|
207
917
|
*
|
|
208
|
-
* @
|
|
209
|
-
*
|
|
210
|
-
*
|
|
918
|
+
* @description
|
|
919
|
+
* Constructs a CapabilitySet from an array of capability entries.
|
|
920
|
+
* This is useful for creating capability sets programmatically.
|
|
921
|
+
*
|
|
922
|
+
* @param version - Protocol version (1 or 2)
|
|
923
|
+
* @param entries - Array of capability entries
|
|
924
|
+
* @returns A new CapabilitySet
|
|
925
|
+
*
|
|
926
|
+
* @example
|
|
927
|
+
* ```typescript
|
|
928
|
+
* const entries: CapabilityEntry[] = [
|
|
929
|
+
* { name: 'multi_ack_detailed' },
|
|
930
|
+
* { name: 'side-band-64k' },
|
|
931
|
+
* { name: 'agent', value: 'gitdo/1.0' }
|
|
932
|
+
* ];
|
|
933
|
+
*
|
|
934
|
+
* const capSet = createCapabilitySet(1, entries);
|
|
935
|
+
* // {
|
|
936
|
+
* // version: 1,
|
|
937
|
+
* // capabilities: Map {
|
|
938
|
+
* // 'multi_ack_detailed' => undefined,
|
|
939
|
+
* // 'side-band-64k' => undefined,
|
|
940
|
+
* // 'agent' => 'gitdo/1.0'
|
|
941
|
+
* // }
|
|
942
|
+
* // }
|
|
943
|
+
* ```
|
|
211
944
|
*/
|
|
212
945
|
export declare function createCapabilitySet(version: ProtocolVersion, entries: CapabilityEntry[]): CapabilitySet;
|
|
213
946
|
/**
|
|
214
947
|
* Select optimal capabilities for a fetch operation.
|
|
215
948
|
*
|
|
216
|
-
* @
|
|
217
|
-
*
|
|
218
|
-
*
|
|
949
|
+
* @description
|
|
950
|
+
* Filters client-preferred capabilities to only those supported by the server.
|
|
951
|
+
* The client's values are preserved (not the server's), maintaining client
|
|
952
|
+
* identification and preferences.
|
|
953
|
+
*
|
|
954
|
+
* @param serverCaps - Server's advertised capabilities
|
|
955
|
+
* @param clientPrefs - Client's preferred capabilities (in priority order)
|
|
956
|
+
* @returns Array of capabilities to use (subset of client preferences)
|
|
957
|
+
*
|
|
958
|
+
* @example
|
|
959
|
+
* ```typescript
|
|
960
|
+
* const serverCaps: CapabilitySet = {
|
|
961
|
+
* version: 1,
|
|
962
|
+
* capabilities: new Map([
|
|
963
|
+
* ['multi_ack', undefined],
|
|
964
|
+
* ['side-band-64k', undefined],
|
|
965
|
+
* ['thin-pack', undefined]
|
|
966
|
+
* ])
|
|
967
|
+
* };
|
|
968
|
+
*
|
|
969
|
+
* const clientPrefs: CapabilityEntry[] = [
|
|
970
|
+
* { name: 'multi_ack_detailed' }, // Not supported by server
|
|
971
|
+
* { name: 'multi_ack' }, // Supported
|
|
972
|
+
* { name: 'side-band-64k' }, // Supported
|
|
973
|
+
* { name: 'ofs-delta' }, // Not supported
|
|
974
|
+
* { name: 'agent', value: 'gitdo/1.0' } // Not in server caps
|
|
975
|
+
* ];
|
|
976
|
+
*
|
|
977
|
+
* const selected = selectFetchCapabilities(serverCaps, clientPrefs);
|
|
978
|
+
* // [
|
|
979
|
+
* // { name: 'multi_ack' },
|
|
980
|
+
* // { name: 'side-band-64k' }
|
|
981
|
+
* // ]
|
|
982
|
+
* ```
|
|
219
983
|
*/
|
|
220
984
|
export declare function selectFetchCapabilities(serverCaps: CapabilitySet, clientPrefs: CapabilityEntry[]): CapabilityEntry[];
|
|
221
985
|
/**
|
|
222
986
|
* Validate that a capability name is well-formed.
|
|
223
987
|
*
|
|
988
|
+
* @description
|
|
989
|
+
* Checks that a capability name follows the Git protocol requirements.
|
|
990
|
+
* Capability names must be non-empty and cannot contain spaces, NUL bytes,
|
|
991
|
+
* or newline characters.
|
|
992
|
+
*
|
|
224
993
|
* @param name - The capability name to validate
|
|
225
|
-
* @returns True if valid
|
|
994
|
+
* @returns True if the name is valid
|
|
995
|
+
*
|
|
996
|
+
* @example
|
|
997
|
+
* ```typescript
|
|
998
|
+
* isValidCapabilityName('multi_ack'); // true
|
|
999
|
+
* isValidCapabilityName('side-band-64k'); // true
|
|
1000
|
+
* isValidCapabilityName('agent'); // true
|
|
1001
|
+
* isValidCapabilityName(''); // false (empty)
|
|
1002
|
+
* isValidCapabilityName('multi ack'); // false (contains space)
|
|
1003
|
+
* isValidCapabilityName('cap\0name'); // false (contains NUL)
|
|
1004
|
+
* isValidCapabilityName('cap\nname'); // false (contains newline)
|
|
1005
|
+
* ```
|
|
226
1006
|
*/
|
|
227
1007
|
export declare function isValidCapabilityName(name: string): boolean;
|
|
228
1008
|
/**
|
|
229
1009
|
* Validate that required capabilities are present.
|
|
230
1010
|
*
|
|
231
|
-
* @
|
|
232
|
-
*
|
|
233
|
-
*
|
|
1011
|
+
* @description
|
|
1012
|
+
* Checks a capability set for the presence of all required capabilities.
|
|
1013
|
+
* Returns an array of missing capability names. An empty array indicates
|
|
1014
|
+
* all requirements are satisfied.
|
|
1015
|
+
*
|
|
1016
|
+
* @param capSet - The capability set to validate
|
|
1017
|
+
* @param required - Array of required capability names
|
|
1018
|
+
* @returns Array of missing capability names (empty if all present)
|
|
1019
|
+
*
|
|
1020
|
+
* @example
|
|
1021
|
+
* ```typescript
|
|
1022
|
+
* const caps: CapabilitySet = {
|
|
1023
|
+
* version: 1,
|
|
1024
|
+
* capabilities: new Map([
|
|
1025
|
+
* ['multi_ack', undefined],
|
|
1026
|
+
* ['side-band-64k', undefined]
|
|
1027
|
+
* ])
|
|
1028
|
+
* };
|
|
1029
|
+
*
|
|
1030
|
+
* // All present
|
|
1031
|
+
* const missing1 = validateRequiredCapabilities(caps, ['multi_ack']);
|
|
1032
|
+
* // []
|
|
1033
|
+
*
|
|
1034
|
+
* // Some missing
|
|
1035
|
+
* const missing2 = validateRequiredCapabilities(caps, ['multi_ack', 'thin-pack', 'ofs-delta']);
|
|
1036
|
+
* // ['thin-pack', 'ofs-delta']
|
|
1037
|
+
*
|
|
1038
|
+
* if (missing2.length > 0) {
|
|
1039
|
+
* throw new Error(`Server missing capabilities: ${missing2.join(', ')}`);
|
|
1040
|
+
* }
|
|
1041
|
+
* ```
|
|
234
1042
|
*/
|
|
235
1043
|
export declare function validateRequiredCapabilities(capSet: CapabilitySet, required: string[]): string[];
|
|
236
1044
|
//# sourceMappingURL=capabilities.d.ts.map
|