@jini-ai/http-kit 0.4.3 → 0.6.10
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 +145 -0
- package/package.json +7 -7
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,150 @@
|
|
|
1
1
|
# @jini-ai/http-kit
|
|
2
2
|
|
|
3
|
+
## 0.6.10
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 8ff5653: Add the attachment upload capability: `POST`/`DELETE /api/attachments` plus a disk-backed store.
|
|
8
|
+
|
|
9
|
+
Composer file and image uploads were something every host had to build for itself. Getting it _working_
|
|
10
|
+
is easy; getting it right is not, and the parts that are easy to skip are the parts that matter — a
|
|
11
|
+
renderer must never learn a filesystem path, a claimed file must be provably the same file that was
|
|
12
|
+
uploaded, and the bytes must be gone when the run ends. This is that whole capability, extracted from a
|
|
13
|
+
working host implementation rather than designed fresh.
|
|
14
|
+
|
|
15
|
+
`createDiskAttachmentStore({ uploadDirectory, ... })` satisfies the `AttachmentStore` port with every
|
|
16
|
+
quota defaulted (10 files / 50 MB per message, 100 files / 200 MB per store, one-hour retention).
|
|
17
|
+
`registerAttachmentRoutes(app, { store }, adapter)` mounts the two routes, with a per-registration
|
|
18
|
+
concurrent-upload limit, a streaming byte cap, and the same-origin guard on by default.
|
|
19
|
+
|
|
20
|
+
What the store guarantees, all of it re-derived server-side and none of it taken from the client:
|
|
21
|
+
|
|
22
|
+
- the wire `path` is an opaque `attachment:<uuid>` capability, never a filesystem path — `claim()` is
|
|
23
|
+
what exchanges one for a real path, and only once per attachment;
|
|
24
|
+
- `kind` is sniffed from the leading bytes (`detectAttachmentKind`), so a renderer cannot decide whether
|
|
25
|
+
its upload reaches the agent as an image;
|
|
26
|
+
- the display name is a sanitized basename; the _stored_ name is a fresh UUID;
|
|
27
|
+
- `claim()` re-verifies `dev`/`ino`/`size` and `realpath` against what registration recorded, so neither
|
|
28
|
+
the file nor a parent directory can be swapped for a symlink in between;
|
|
29
|
+
- quota decisions happen with no `await` between the check and the commit, so concurrent uploads cannot
|
|
30
|
+
both reserve the last slot;
|
|
31
|
+
- the upload directory is emptied on construction — files from an interrupted previous process cannot be
|
|
32
|
+
authenticated, so they are not adopted.
|
|
33
|
+
|
|
34
|
+
Run-lifecycle wiring stays host-owned, matching `createRunScopedContextStore`'s precedent: a host calls
|
|
35
|
+
`store.claim(...)` in its own `onRunStarted`, threads the result into `AgentExecutor.run()`'s existing
|
|
36
|
+
`imagePaths`/`extraAllowedDirs`/`uploadRoot`, and calls `store.cleanupRun(runId)` in a `finally`. The
|
|
37
|
+
module doc carries that ~10-line pattern. There is no generic run hook to auto-wire into, and inventing
|
|
38
|
+
one here would be worse than documenting the ten lines.
|
|
39
|
+
|
|
40
|
+
Two things found while extracting, both now handled rather than inherited:
|
|
41
|
+
|
|
42
|
+
- **A body parser silently eats uploads.** The route streams the raw request, so an app-wide
|
|
43
|
+
`express.json()` — which `compose-jini-kernel` mounts for every daemon — consumes the body of any
|
|
44
|
+
upload whose content type it claims. Dropping a `.json` file was enough to trigger it, and it surfaced
|
|
45
|
+
as the useless "attachment is empty". The route now detects an already-drained stream and reports it as
|
|
46
|
+
the host misconfiguration it is.
|
|
47
|
+
- **Two redundant integrity checks that could never fire.** A `path.relative` containment test sitting
|
|
48
|
+
behind a `dirname(filePath) === batchDirectory` check added nothing (parent-directory equality is
|
|
49
|
+
strictly stronger and implies containment), and an `isSymbolicLink()` check behind `!isFile()` on an
|
|
50
|
+
`lstat` result can never be the deciding one, since `lstat` reports exactly one file type. Both were
|
|
51
|
+
removed with the reasoning recorded inline. The accepted-input set is unchanged; the integrity decision
|
|
52
|
+
itself moved into a pure, exported `isUnchangedAttachment` so each condition — including a device
|
|
53
|
+
change, which no filesystem test can stage — is directly verifiable.
|
|
54
|
+
|
|
55
|
+
- 601fad5: Removed the `agui-stream` run-stream route: `RUN_STREAM_ROUTE_PATH`, `registerRunStreamRoute`, and
|
|
56
|
+
`handleRunStreamRequest` are no longer exported, and the route no longer mounts.
|
|
57
|
+
|
|
58
|
+
The route was named `agui-stream` from when Jini's own run-event protocol was mistakenly branded as
|
|
59
|
+
AG-UI; the TypeScript symbols were renamed to `GenUi` on 2026-07-27, but the URL was deliberately left
|
|
60
|
+
un-renamed on the assumption it was a wire contract an already-deployed client might be calling. A
|
|
61
|
+
2026-08-18 audit found zero callers anywhere — no client in this repo or in `Tovu` ever requested it,
|
|
62
|
+
`examples/reference-web`'s daemon only registered the route without anything ever calling it, and
|
|
63
|
+
`@jini-ai/http-kit` has never been published to npm, so no external integrator could depend on it either.
|
|
64
|
+
Rather than carry a dead, confusingly-named route indefinitely, it was removed outright.
|
|
65
|
+
|
|
66
|
+
`@jini-ai/agentic`'s `gen-ui` module (`createGenUiEncoder` and the six `GenUi*` event types) is
|
|
67
|
+
unaffected — it remains part of that package's public surface independent of this route.
|
|
68
|
+
|
|
69
|
+
- 4f52784: Publish a route manifest so a reverse proxy stops hand-copying path strings.
|
|
70
|
+
|
|
71
|
+
A host proxying a Jini daemon in another process needs that daemon's route list to forward anything,
|
|
72
|
+
and with no published inventory the only way to build one was to copy path strings by hand. A
|
|
73
|
+
hand-copied list falls behind the moment a family gains a route — which has already happened in a real
|
|
74
|
+
consumer, whose proxy shipped without `GET /api/runs` and left the daemon's list endpoint 404-ing at
|
|
75
|
+
the host's own router.
|
|
76
|
+
|
|
77
|
+
`JINI_ROUTE_MANIFEST`, `routeFamilyManifest(family)`, and `manifestRoutesForFamilies(families)` expose
|
|
78
|
+
`{method, path}` per feature family as inert data, readable without mounting anything.
|
|
79
|
+
|
|
80
|
+
The manifest declares **no method or path literals** — every entry is derived from the same
|
|
81
|
+
`JsonRouteSpec` constant the family's `register*Routes` mounts, so a path change moves the manifest with
|
|
82
|
+
it. A paired test mounts each declared family's real registrar and asserts the manifest matches, so the
|
|
83
|
+
one remaining failure mode (a family gains a route nobody lists) fails a test instead of a consumer.
|
|
84
|
+
|
|
85
|
+
That test earned its keep immediately: it found that the `runs` family mounts a spec-less streaming
|
|
86
|
+
route, `/api/runs/:runId/events`, that a hand-copied proxy list could easily miss. `RUN_EVENTS_ROUTE_PATH`
|
|
87
|
+
is now exported so it never has to be restated as a literal.
|
|
88
|
+
|
|
89
|
+
Scope is honest: the manifest covers the families a sidecar consumer proxies, not all 19 the package can
|
|
90
|
+
mount. `routeFamilyManifest` returns `undefined` for an undeclared family rather than an empty array, so
|
|
91
|
+
"not described here" is never mistaken for "has no routes".
|
|
92
|
+
|
|
93
|
+
- 4f52784: Add a `sidecar-strict` security mode and per-run MCP credential propagation.
|
|
94
|
+
|
|
95
|
+
For a daemon whose threat model is **another process running as the same OS user** rather than a
|
|
96
|
+
remote attacker, the existing `jini-local` mode is a no-op: `registerApiBearerAuthMiddleware`
|
|
97
|
+
short-circuits for any loopback peer before it reads the `Authorization` header, and a `127.0.0.1`
|
|
98
|
+
bind keeps remote hosts out while doing nothing about a co-resident process. A consumer that spawns a
|
|
99
|
+
Jini daemon holding real authority — starting agent runs, executing tools against a real database —
|
|
100
|
+
previously had to write its own middleware.
|
|
101
|
+
|
|
102
|
+
- `@jini-ai/http-kit` gains `requireStrictBearerToken`: fail-closed 503 when the named token env var
|
|
103
|
+
is unset, 401 on mismatch, **no loopback exemption and no disable flag**. Its `tokenEnvVar` is
|
|
104
|
+
required with no default, so this package never names a host's secret.
|
|
105
|
+
- `composeJiniKernel` gains `security: { mode: 'sidecar-strict', host, tokenEnvVar, exemptPaths? }`.
|
|
106
|
+
Purely additive — `host` and `jini-local` are unchanged by construction, since the modes are arms of
|
|
107
|
+
a discriminated union. The strict gate mounts ahead of the JSON body parser, so a caller it rejects
|
|
108
|
+
never has its body parsed.
|
|
109
|
+
- `@jini-ai/daemon`'s `McpJsonInjectionOptions` gains `credential?: (runId) => string | Promise<string>`
|
|
110
|
+
— a **resolver, not a string**, because injection options are built once before any run exists and a
|
|
111
|
+
boot-wide shared secret would defeat the point of scoping a credential to a run. It is delivered to
|
|
112
|
+
the child as `JINI_DAEMON_TOKEN`.
|
|
113
|
+
- `@jini-ai/mcp`'s `jini-mcp` reads that variable and attaches `Authorization` to every daemon call.
|
|
114
|
+
Optional throughout: with no credential, request headers and `.mcp.json` output are byte-identical
|
|
115
|
+
to before.
|
|
116
|
+
|
|
117
|
+
Also generalized: both existing bearer gates now compare tokens in constant time (`timingSafeEqual`)
|
|
118
|
+
and share one header-parsing helper, closing a timing side channel and removing a duplicated regex.
|
|
119
|
+
|
|
120
|
+
- 8ff5653: `GET /api/tools/:id` answers 404 for an unknown tool id, not 400.
|
|
121
|
+
|
|
122
|
+
`toolCatalogDescribeRoute` (the route `@jini-ai/mcp`'s `describe_tool` proxies) reported a
|
|
123
|
+
well-formed request naming a nonexistent catalog entry as `VALIDATION_FAILED` / **400**, because its
|
|
124
|
+
`handle` reached for the same `validationError` helper its `parse` step uses — where 400 genuinely is
|
|
125
|
+
correct. The result was that a caller could not tell "you sent a malformed request" apart from "that
|
|
126
|
+
tool does not exist", which are the two things a status code is supposed to separate.
|
|
127
|
+
|
|
128
|
+
The three sibling route families in this package with the identical "the referenced resource isn't
|
|
129
|
+
there" case — `memory.ts`'s `memory not found`, `routines.ts`'s `routine not found`, and `media.ts`'s
|
|
130
|
+
`media task not found` — all already answered 404. This was the one family out of step, so this is a
|
|
131
|
+
behavior correction toward an existing in-package convention rather than a new one.
|
|
132
|
+
|
|
133
|
+
Now `NOT_FOUND` / **404**, with the message unchanged (`no catalog entry for tool id "<id>"`).
|
|
134
|
+
`parse` failures on this route — a missing `:id` path segment — are still 400.
|
|
135
|
+
|
|
136
|
+
**Behavior change for callers**, hence the minor bump: anything that branched on 400 to detect an
|
|
137
|
+
unknown tool id must branch on 404 instead. Client code that only distinguishes success from failure
|
|
138
|
+
is unaffected. A wire-level test now pins the observed status code for the not-found case, the
|
|
139
|
+
malformed case, and the cross-origin case, so the two cannot silently converge again.
|
|
140
|
+
|
|
141
|
+
- Updated dependencies [22f0619]
|
|
142
|
+
- Updated dependencies [82ed2d3]
|
|
143
|
+
- Updated dependencies [3fe4d14]
|
|
144
|
+
- Updated dependencies [5a3de86]
|
|
145
|
+
- @jini-ai/core@0.6.10
|
|
146
|
+
- @jini-ai/protocol@0.6.10
|
|
147
|
+
|
|
3
148
|
## 0.4.3 — 2026-10-22
|
|
4
149
|
|
|
5
150
|
- 2026-10-22: Completed-request logging off by default (one compact line when enabled), coverage.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jini-ai/http-kit",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.10",
|
|
4
4
|
"description": "Generic Express transport primitives, request parsing, response serialization, origin guards and route-pack mounting.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -71,16 +71,16 @@
|
|
|
71
71
|
"@types/express": "^4.17.21",
|
|
72
72
|
"@vitest/coverage-v8": "^2.1.9",
|
|
73
73
|
"express": "^4.21.0",
|
|
74
|
-
"@jini-ai/core": "0.
|
|
75
|
-
"@jini-ai/platform": "0.
|
|
76
|
-
"@jini-ai/protocol": "0.
|
|
74
|
+
"@jini-ai/core": "0.6.10",
|
|
75
|
+
"@jini-ai/platform": "0.6.10",
|
|
76
|
+
"@jini-ai/protocol": "0.6.10"
|
|
77
77
|
},
|
|
78
78
|
"dependencies": {
|
|
79
|
-
"@jini-ai/
|
|
80
|
-
"@jini-ai/
|
|
79
|
+
"@jini-ai/core": "^0.6.10",
|
|
80
|
+
"@jini-ai/protocol": "^0.6.10"
|
|
81
81
|
},
|
|
82
82
|
"peerDependencies": {
|
|
83
|
-
"@jini-ai/platform": "^0.
|
|
83
|
+
"@jini-ai/platform": "^0.6.10",
|
|
84
84
|
"express": "^4.21.0 || ^5.0.0"
|
|
85
85
|
},
|
|
86
86
|
"peerDependenciesMeta": {
|