@zabaca/zbc 0.25.0 → 0.26.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +17 -0
- package/package.json +1 -1
- package/src/commands/init.ts +105 -10
- package/src/commands/update.ts +33 -6
- package/src/utils/detect-mode.ts +1 -1
- package/src/utils/host-workspaces.ts +57 -0
- package/src/utils/subtree.ts +54 -15
- package/src/utils/vendor-audit.ts +12 -8
- package/src/utils/vendor-stamp.ts +10 -0
- package/src/utils/vendored-app.ts +3 -0
- package/templates/apps/walgit/CONTEXT.md +45 -4
- package/templates/apps/walgit/README.md +394 -11
- package/templates/apps/walgit/shared/browse.ts +61 -0
- package/templates/apps/walgit/shared/capabilities.ts +26 -0
- package/templates/apps/walgit/shared/container-env.ts +12 -0
- package/templates/apps/walgit/shared/container-lifecycle.ts +1 -1
- package/templates/apps/walgit/shared/credentials.ts +4 -0
- package/templates/apps/walgit/shared/events.ts +35 -1
- package/templates/apps/walgit/shared/instructions.ts +4 -1
- package/templates/apps/walgit/shared/landing.ts +2 -1
- package/templates/apps/walgit/shared/llms.ts +73 -5
- package/templates/apps/walgit/shared/mcp.ts +19 -3
- package/templates/apps/walgit/shared/protocol.ts +40 -3
- package/templates/apps/walgit/shared/repo-list.ts +46 -6
- package/templates/apps/walgit/shared/scoped-token.ts +500 -0
- package/templates/apps/walgit/shared/token-revocation.ts +134 -0
- package/templates/apps/walgit/shared/wal-index.ts +19 -0
- package/templates/apps/walgit/shared/webhook.ts +281 -0
- package/templates/apps/walgit/src/admin.ts +510 -0
- package/templates/apps/walgit/src/announce-main.ts +17 -9
- package/templates/apps/walgit/src/announce.ts +86 -0
- package/templates/apps/walgit/src/browse.ts +255 -2
- package/templates/apps/walgit/src/cli.ts +140 -0
- package/templates/apps/walgit/src/expire.ts +5 -0
- package/templates/apps/walgit/src/git.ts +103 -0
- package/templates/apps/walgit/src/hook-main.ts +6 -3
- package/templates/apps/walgit/src/http.ts +563 -3
- package/templates/apps/walgit/src/limits.ts +3 -0
- package/templates/apps/walgit/src/merge.ts +525 -0
- package/templates/apps/walgit/src/rate-limit.ts +51 -14
- package/templates/apps/walgit/src/server.ts +65 -1
- package/templates/apps/walgit/worker/events-do.ts +218 -3
- package/templates/apps/walgit/worker/index.ts +134 -9
- package/templates/apps/walgit/worker/mcp.ts +17 -2
|
@@ -40,6 +40,7 @@ import { Hono } from 'hono'
|
|
|
40
40
|
|
|
41
41
|
import type { Capabilities } from '../shared/capabilities'
|
|
42
42
|
import { parseTokens } from '../shared/credentials'
|
|
43
|
+
import type { ScopedClaims } from '../shared/scoped-token'
|
|
43
44
|
import { authorizeSubscribe } from '../shared/events'
|
|
44
45
|
import {
|
|
45
46
|
type McpDeps,
|
|
@@ -82,8 +83,9 @@ export async function handleMcp(
|
|
|
82
83
|
caps: Capabilities,
|
|
83
84
|
operator: Operator | null,
|
|
84
85
|
host: string,
|
|
86
|
+
scoped: ScopedClaims | null = null,
|
|
85
87
|
): Promise<Response> {
|
|
86
|
-
const server = createAgentgitMcp(deps(request, env, caps, operator, host))
|
|
88
|
+
const server = createAgentgitMcp(deps(request, env, caps, operator, host, scoped))
|
|
87
89
|
const transport = new StreamableHTTPTransport()
|
|
88
90
|
await server.connect(transport)
|
|
89
91
|
const app = new Hono()
|
|
@@ -97,6 +99,7 @@ function deps(
|
|
|
97
99
|
caps: Capabilities,
|
|
98
100
|
operator: Operator | null,
|
|
99
101
|
host: string,
|
|
102
|
+
scoped: ScopedClaims | null,
|
|
100
103
|
): McpDeps {
|
|
101
104
|
// The caller's own credential, forwarded unchanged to every gated read. An
|
|
102
105
|
// MCP client sends it as an ordinary Authorization header, which is the same
|
|
@@ -136,7 +139,14 @@ function deps(
|
|
|
136
139
|
return { ok: true, repo: name, provenance: read.provenance }
|
|
137
140
|
},
|
|
138
141
|
|
|
139
|
-
watch: (name, ref, timeoutMs) =>
|
|
142
|
+
watch: (name, ref, timeoutMs) =>
|
|
143
|
+
watchRef(env, caps, authorization, name, ref, timeoutMs, scoped !== null),
|
|
144
|
+
|
|
145
|
+
// A scoped token (docs/adr/0021) reaches the endpoint — the edge let it
|
|
146
|
+
// through, because the repositories here are named per tool call — and
|
|
147
|
+
// every tool refuses a name outside its claim before any of the reads
|
|
148
|
+
// above runs, so such a name never wakes the container (`shared/mcp.ts`).
|
|
149
|
+
scopedTo: scoped?.repo ?? null,
|
|
140
150
|
}
|
|
141
151
|
}
|
|
142
152
|
|
|
@@ -211,11 +221,16 @@ async function watchRef(
|
|
|
211
221
|
repo: string,
|
|
212
222
|
ref: string | null,
|
|
213
223
|
timeoutMs: number,
|
|
224
|
+
scoped: boolean,
|
|
214
225
|
): Promise<WatchOutcome> {
|
|
215
226
|
if (!caps.events) {
|
|
216
227
|
throw new Error('this deployment does not serve the ref-event stream')
|
|
217
228
|
}
|
|
229
|
+
// A scoped token stands in for the deployment credential, as it does on the
|
|
230
|
+
// socket route (`events()` in `index.ts`); its claim was checked by the
|
|
231
|
+
// caller and is checked again by the Durable Object.
|
|
218
232
|
if (
|
|
233
|
+
!scoped &&
|
|
219
234
|
!authorizeSubscribe({
|
|
220
235
|
authorization,
|
|
221
236
|
tokens: parseTokens(env.WALGIT_HTTP_TOKENS),
|