@jini-ai/platform 0.7.3-next.1 → 0.7.3-next.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/CHANGELOG.md +6 -0
- package/README.md +13 -0
- package/dist/download-lock.d.ts +3 -1
- package/dist/download-lock.js +4 -4
- package/dist/download-maintenance.js +6 -6
- package/dist/download-state.js +17 -14
- package/dist/download-store.d.ts +34 -10
- package/dist/download-store.js +24 -20
- package/dist/download-target.d.ts +6 -2
- package/dist/download-target.js +7 -7
- package/dist/download-transfer.js +18 -12
- package/dist/download.js +4 -4
- package/dist/fetch-with-timeout.d.ts +0 -53
- package/dist/fetch-with-timeout.js +56 -6
- package/dist/fs/directory-running-lock.d.ts +4 -0
- package/dist/fs/directory-running-lock.js +8 -1
- package/dist/fs/directory-workspace.d.ts +2 -1
- package/dist/fs/directory-workspace.js +2 -2
- package/dist/fs/durable-json.d.ts +3 -16
- package/dist/fs/durable-json.js +4 -2
- package/dist/fs/guarded-reader.d.ts +10 -0
- package/dist/fs/guarded-reader.js +34 -1
- package/dist/fs/index.d.ts +4 -0
- package/dist/fs/index.js +4 -0
- package/dist/fs/leased-directory-move.d.ts +49 -0
- package/dist/fs/leased-directory-move.js +31 -0
- package/dist/fs/owned-temp-root.d.ts +74 -0
- package/dist/fs/owned-temp-root.js +203 -0
- package/dist/fs/recent-directories.d.ts +2 -1
- package/dist/fs/resolve-directory-target.d.ts +33 -0
- package/dist/fs/resolve-directory-target.js +58 -0
- package/dist/fs/staged-file.d.ts +40 -0
- package/dist/fs/staged-file.js +75 -0
- package/dist/fs/strict-containment.d.ts +14 -0
- package/dist/fs/strict-containment.js +14 -0
- package/dist/image/png-encode.d.ts +41 -0
- package/dist/image/png-encode.js +96 -0
- package/dist/index.d.ts +3 -1
- package/dist/mail/email-template-agent-tools.d.ts +150 -0
- package/dist/mail/email-template-agent-tools.js +86 -0
- package/dist/mail/email-template-tool-registrations.d.ts +73 -0
- package/dist/mail/email-template-tool-registrations.js +66 -0
- package/dist/mail/feedback-route.d.ts +50 -0
- package/dist/mail/feedback-route.js +46 -0
- package/dist/mail/feedback-setup.d.ts +44 -0
- package/dist/mail/feedback-setup.js +53 -0
- package/dist/mail/feedback-sources.d.ts +67 -0
- package/dist/mail/feedback-sources.js +42 -0
- package/dist/mail/index.d.ts +10 -1
- package/dist/mail/index.js +4 -0
- package/dist/mail/mail-status.d.ts +32 -0
- package/dist/mail/mail-status.js +2 -0
- package/dist/mail/positional-purpose-gate.d.ts +14 -0
- package/dist/mail/positional-purpose-gate.js +18 -0
- package/dist/mail/purpose-gate-probe.d.ts +18 -0
- package/dist/mail/purpose-gate-probe.js +22 -0
- package/dist/mail/resolve-mailer.d.ts +13 -1
- package/dist/mail/resolve-mailer.js +11 -5
- package/dist/mail/sql/activity.repo.d.ts +20 -0
- package/dist/mail/sql/activity.repo.js +133 -0
- package/dist/mail/sql/attempts.repo.d.ts +17 -0
- package/dist/mail/sql/attempts.repo.js +32 -0
- package/dist/mail/sql/capture.repo.d.ts +69 -0
- package/dist/mail/sql/capture.repo.js +119 -0
- package/dist/mail/sql/feedback-inbox.repo.d.ts +12 -0
- package/dist/mail/sql/feedback-inbox.repo.js +32 -0
- package/dist/mail/sql/index.d.ts +12 -0
- package/dist/mail/sql/index.js +12 -0
- package/dist/mail/sql/ledger.repo.d.ts +29 -0
- package/dist/mail/sql/ledger.repo.js +57 -0
- package/dist/mail/sql/retention.d.ts +23 -0
- package/dist/mail/sql/retention.js +53 -0
- package/dist/mail/sql/site-feedback-route.d.ts +18 -0
- package/dist/mail/sql/site-feedback-route.js +22 -0
- package/dist/mail/sql/suppression-admin.repo.d.ts +11 -0
- package/dist/mail/sql/suppression-admin.repo.js +76 -0
- package/dist/mail/sql/suppression.repo.d.ts +10 -0
- package/dist/mail/sql/suppression.repo.js +33 -0
- package/dist/mail/test-send.d.ts +147 -0
- package/dist/mail/test-send.js +201 -0
- package/dist/mail/use-readiness.d.ts +104 -0
- package/dist/mail/use-readiness.js +140 -0
- package/dist/object-store/local-fs.js +34 -1
- package/dist/object-store/site/artifact-provider.d.ts +65 -0
- package/dist/object-store/site/artifact-provider.js +37 -0
- package/dist/object-store/site/registry.d.ts +110 -0
- package/dist/object-store/site/registry.js +93 -0
- package/dist/object-store/site/setting.d.ts +34 -0
- package/dist/object-store/site/setting.js +32 -0
- package/dist/process-probes.d.ts +11 -4
- package/dist/process-probes.js +3 -3
- package/dist/process-top-footprint.d.ts +1 -1
- package/dist/process.d.ts +3 -17
- package/dist/process.js +3 -2
- package/dist/retention/index.d.ts +6 -0
- package/dist/retention/index.js +6 -0
- package/dist/retention/measure-tree.d.ts +68 -0
- package/dist/retention/measure-tree.js +205 -0
- package/dist/retention/preview-store.d.ts +10 -0
- package/dist/retention/preview-store.js +26 -0
- package/dist/retention/routes.d.ts +23 -0
- package/dist/retention/routes.js +24 -0
- package/dist/retention/runner.d.ts +103 -0
- package/dist/retention/runner.js +164 -0
- package/dist/secrets/credential-sets/index.d.ts +1 -0
- package/dist/secrets/credential-sets/index.js +1 -0
- package/dist/secrets/credential-sets/store-vault-guards.d.ts +26 -0
- package/dist/secrets/credential-sets/store-vault-guards.js +30 -0
- package/dist/secrets/credential-sets/vault.service.d.ts +1 -1
- package/dist/secrets/index.d.ts +1 -1
- package/dist/secrets/index.js +1 -1
- package/dist/secrets/keyring.env.d.ts +1 -1
- package/dist/secrets/keyring.env.js +3 -5
- package/dist/secrets/keyring.memory.d.ts +4 -1
- package/dist/secrets/keyring.memory.js +4 -1
- package/dist/secrets/legacy-codecs.d.ts +381 -0
- package/dist/secrets/legacy-codecs.js +468 -0
- package/dist/secrets/legacy-owner.d.ts +3 -11
- package/dist/secrets/root-key/ensure.d.ts +154 -0
- package/dist/secrets/root-key/ensure.js +328 -0
- package/dist/secrets/root-key/files.d.ts +104 -0
- package/dist/secrets/root-key/files.js +166 -0
- package/dist/secrets/root-key/material.d.ts +132 -0
- package/dist/secrets/root-key/material.js +116 -0
- package/dist/secrets/root-key/ordered-keyring.d.ts +157 -0
- package/dist/secrets/root-key/ordered-keyring.js +104 -0
- package/dist/secrets/root-key/reconcile.d.ts +50 -0
- package/dist/secrets/root-key/reconcile.js +147 -0
- package/dist/secrets/root-key/site-keyring-errors.d.ts +78 -0
- package/dist/secrets/root-key/site-keyring-errors.js +37 -0
- package/dist/secrets/root-key/sources.d.ts +79 -0
- package/dist/secrets/root-key/sources.js +119 -0
- package/dist/secrets/secret-sealer.aesgcm.d.ts +50 -2
- package/dist/secrets/secret-sealer.aesgcm.js +107 -19
- package/dist/web/tool-registrations.d.ts +67 -0
- package/dist/web/tool-registrations.js +44 -0
- package/package.json +139 -7
|
@@ -1,13 +1,61 @@
|
|
|
1
1
|
/** AES-256-GCM with a fresh 12-byte IV and ciphertext || 16-byte tag, both base64 encoded.
|
|
2
2
|
* Uses purpose "secret-sealer.v1" and scope "secret-sealer" for HKDF domain separation.
|
|
3
|
-
* Seal requires context AAD; open accepts absent AAD solely for historical
|
|
3
|
+
* Seal requires context AAD on the default entry point; open accepts absent AAD solely for historical
|
|
4
|
+
* unbound records. Writing a NEW unbound record is opt-in through {@link LegacyUnboundAesGcmSecretSealer}.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* @file `SecretSealerPort`'s real adapter (ADR-058).
|
|
8
|
+
*
|
|
9
|
+
* Bare `node:crypto`, no extra dependency. The AES key is never held or generated here: it is
|
|
10
|
+
* re-derived on every `seal`/`open` from the injected `KeyringPort` (by-handle discipline: raw
|
|
11
|
+
* root-key bytes never cross this class's boundary, only the handle's `keyId` does). The purpose
|
|
12
|
+
* binds this derivation into its own HKDF domain, separate from webhook signing
|
|
13
|
+
* (`deriveSigningSecret`) and token derivations sharing the same root key: `purpose` MUST be a
|
|
14
|
+
* real separation boundary, not decorative.
|
|
15
|
+
*
|
|
16
|
+
* One shared sealing capability per root-key generation, not one key per tenant. Multi-tenant
|
|
17
|
+
* separation is a property of the DATA layer (each row carries its own owner columns), matching
|
|
18
|
+
* `SealedSecret.keyId`'s meaning: the generation the value was wrapped under, for the whole store.
|
|
19
|
+
*
|
|
20
|
+
* `aad`: because the key is shared, the key alone does not separate one row's ciphertext from
|
|
21
|
+
* another's. A caller-supplied `aad` closes that gap per CALL: it is bound into the GCM tag via
|
|
22
|
+
* `setAAD` (RFC 5116 §5.1), so opening with a different or absent `aad` fails exactly like a
|
|
23
|
+
* tampered ciphertext. `AesGcmSecretSealer.seal` REFUSES an omitted `aad` (strict by default, like
|
|
24
|
+
* the `SecretSealerPort` type): a forgotten binding must fail loudly, never write a row that any other
|
|
25
|
+
* row's context could open. Reads stay compatible: `open` with `aad` omitted verifies zero AAD bytes,
|
|
26
|
+
* the same tag as the original implementation that never called `setAAD`, so rows sealed before AAD
|
|
27
|
+
* existed keep opening byte-for-byte. A host that still has to WRITE that historical unbound format
|
|
28
|
+
* opts in by constructing {@link LegacyUnboundAesGcmSecretSealer} by name at its composition root.
|
|
29
|
+
*
|
|
30
|
+
* Rule-of-two: deliberately no plaintext-passthrough test double for this port. A fake that skips
|
|
31
|
+
* encryption would defeat the one thing worth testing (a value round-trips through REAL AES-GCM);
|
|
32
|
+
* the lightweight test path is this class over the in-memory keyring.
|
|
4
33
|
*/
|
|
5
34
|
import { createCipheriv, createDecipheriv, randomBytes } from "node:crypto";
|
|
6
35
|
const ALG = "aes-256-gcm";
|
|
7
36
|
const IV_LENGTH_BYTES = 12;
|
|
8
37
|
const AUTH_TAG_LENGTH_BYTES = 16;
|
|
9
38
|
const SEALER_PURPOSE = "secret-sealer.v1";
|
|
39
|
+
/** Fixed `KeyringPort.derive()` workspace-scope label for the sealer's OWN key derivation: one shared
|
|
40
|
+
* key per root-key generation, not one per tenant (see this file's header). */
|
|
10
41
|
const SEALER_KEY_SCOPE = "secret-sealer";
|
|
42
|
+
/**
|
|
43
|
+
* `code` on what {@link AesGcmSecretSealer.open} throws when the sealed value itself can't be opened:
|
|
44
|
+
* a wrong, lost or re-minted key (the GCM auth tag fails), a tampered or damaged envelope, an
|
|
45
|
+
* unsupported `alg`. Callers classify by this code, never by the message: the auth-tag failure's
|
|
46
|
+
* wording is the crypto runtime's own (OpenSSL in Node, BoringSSL in Electron) and may change. A
|
|
47
|
+
* keyring that can't derive at all (no key, an unusable key) is NOT this: its error passes through.
|
|
48
|
+
*/
|
|
49
|
+
export const SECRET_OPEN_FAILED = "SECRET_OPEN_FAILED";
|
|
50
|
+
/** A sealed value that could not be opened ({@link SECRET_OPEN_FAILED}); the message is the cause's. */
|
|
51
|
+
export class SecretOpenError extends Error {
|
|
52
|
+
code = SECRET_OPEN_FAILED;
|
|
53
|
+
constructor(required, _optional = {}) {
|
|
54
|
+
super(required.cause instanceof Error ? required.cause.message : String(required.cause), { cause: required.cause });
|
|
55
|
+
this.name = "SecretOpenError";
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
/** AES-256-GCM `SecretSealerPort` adapter over a `KeyringPort`; the key is re-derived on every call. */
|
|
11
59
|
export class AesGcmSecretSealer {
|
|
12
60
|
// Derive one key per root generation, not per tenant. Data-layer ownership checks and context AAD
|
|
13
61
|
// must prevent ciphertext substitution between rows; the shared encryption key alone cannot.
|
|
@@ -20,9 +68,17 @@ export class AesGcmSecretSealer {
|
|
|
20
68
|
this.keyring = keyring;
|
|
21
69
|
this.randomBytesFn = optional.randomBytesFn ?? (({ byteLength }) => randomBytes(byteLength));
|
|
22
70
|
}
|
|
23
|
-
/** Encrypts under the requested generation with a fresh IV; AAD must be reconstructed on open.
|
|
71
|
+
/** Encrypts under the requested generation with a fresh IV; AAD must be reconstructed on open.
|
|
72
|
+
* @param input.aad - Required context bound into the GCM tag, never stored. An omitted or
|
|
73
|
+
* non-string `aad` is refused before any key derivation (no unbound write on this entry point).
|
|
74
|
+
* @returns `{keyId, ciphertext, nonce, alg}`; `ciphertext` is base64(ciphertext || 16-byte tag).
|
|
75
|
+
* @throws Whatever `KeyringPort.derive()` throws (e.g. a missing root key), never swallowed into a
|
|
76
|
+
* plaintext fallback; `TypeError` for a missing/non-string `aad` or a non-12-byte injected IV.
|
|
77
|
+
* @complexity O(plaintext bytes).
|
|
78
|
+
*/
|
|
24
79
|
async seal(input) {
|
|
25
|
-
|
|
80
|
+
const { aad } = input;
|
|
81
|
+
if (typeof aad !== "string")
|
|
26
82
|
throw new TypeError("AesGcmSecretSealer: aad must be a string");
|
|
27
83
|
const aesKey = await this.deriveAesKey(input.key);
|
|
28
84
|
const iv = Buffer.from(this.randomBytesFn({ byteLength: IV_LENGTH_BYTES }));
|
|
@@ -31,7 +87,7 @@ export class AesGcmSecretSealer {
|
|
|
31
87
|
// GCM must never reuse an IV under the same key. AAD is authenticated but not stored in the
|
|
32
88
|
// envelope, so callers must reconstruct the byte-identical context when opening the record.
|
|
33
89
|
const cipher = createCipheriv(ALG, aesKey, iv);
|
|
34
|
-
cipher.setAAD(Buffer.from(
|
|
90
|
+
cipher.setAAD(Buffer.from(aad, "utf8"));
|
|
35
91
|
const ciphertext = Buffer.concat([cipher.update(input.plaintext, "utf8"), cipher.final()]);
|
|
36
92
|
const authTag = cipher.getAuthTag();
|
|
37
93
|
return {
|
|
@@ -41,31 +97,63 @@ export class AesGcmSecretSealer {
|
|
|
41
97
|
alg: ALG,
|
|
42
98
|
};
|
|
43
99
|
}
|
|
44
|
-
/** Opens under the envelope's generation. Wrong key, tag, nonce, or AAD fails authentication.
|
|
100
|
+
/** Opens under the envelope's generation. Wrong key, tag, nonce, or AAD fails authentication.
|
|
101
|
+
* @param optional.aad - The byte-identical string the value was sealed with; omitted iff it was
|
|
102
|
+
* sealed with none. Any mismatch, in either direction, fails the auth tag.
|
|
103
|
+
* @throws {SecretOpenError} Unsupported `alg`, a malformed/short envelope, or a failed auth tag
|
|
104
|
+
* (wrong key, tampering, changed AAD), with the runtime's error kept as `cause`.
|
|
105
|
+
* @throws Whatever `KeyringPort.derive()` throws, as itself (an unconfigured store, not a bad row).
|
|
106
|
+
* @complexity O(ciphertext bytes).
|
|
107
|
+
*/
|
|
45
108
|
async open(input, { aad } = {}) {
|
|
46
109
|
if (input.sealed.alg !== ALG) {
|
|
47
|
-
throw new Error(`AesGcmSecretSealer cannot open alg '${input.sealed.alg}' (expected '${ALG}')`);
|
|
110
|
+
throw new SecretOpenError({ cause: new Error(`AesGcmSecretSealer cannot open alg '${input.sealed.alg}' (expected '${ALG}')`) });
|
|
48
111
|
}
|
|
49
|
-
const aesKey = await this.deriveAesKey({ keyId: input.sealed.keyId });
|
|
50
112
|
// Use the stored generation, not the active one, so rotation does not strand older ciphertext.
|
|
51
113
|
// Derivation/authentication failures propagate; there is no plaintext or partial-output fallback.
|
|
52
|
-
|
|
53
|
-
const
|
|
54
|
-
|
|
55
|
-
|
|
114
|
+
// Derivation failures propagate as themselves; only the opening itself is SECRET_OPEN_FAILED.
|
|
115
|
+
const aesKey = await this.deriveAesKey({ keyId: input.sealed.keyId });
|
|
116
|
+
try {
|
|
117
|
+
return decrypt({ sealed: input.sealed, aesKey, aad });
|
|
56
118
|
}
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
const decipher = createDecipheriv(ALG, aesKey, iv);
|
|
60
|
-
if (aad !== undefined) {
|
|
61
|
-
decipher.setAAD(Buffer.from(aad, "utf8"));
|
|
119
|
+
catch (error) {
|
|
120
|
+
throw new SecretOpenError({ cause: error });
|
|
62
121
|
}
|
|
63
|
-
decipher.setAuthTag(authTag);
|
|
64
|
-
const plaintext = Buffer.concat([decipher.update(ciphertext), decipher.final()]);
|
|
65
|
-
return plaintext.toString("utf8");
|
|
66
122
|
}
|
|
67
123
|
async deriveAesKey(key) {
|
|
68
124
|
return this.keyring.derive({ workspaceId: SEALER_KEY_SCOPE, purpose: SEALER_PURPOSE, info: key.keyId });
|
|
69
125
|
}
|
|
70
126
|
}
|
|
127
|
+
/**
|
|
128
|
+
* COMPATIBILITY binding: an {@link AesGcmSecretSealer} whose `seal` also accepts an omitted `aad`
|
|
129
|
+
* and writes the historical UNBOUND format (zero AAD bytes; byte-identical to `aad: ""` and to the
|
|
130
|
+
* pre-AAD implementation). Such a record is not tied to any row: it opens wherever no context is
|
|
131
|
+
* supplied. Only a host that must keep producing that format constructs this class, by name, at its
|
|
132
|
+
* composition root; every other caller uses the strict {@link AesGcmSecretSealer}. Opening is unchanged.
|
|
133
|
+
*/
|
|
134
|
+
export class LegacyUnboundAesGcmSecretSealer extends AesGcmSecretSealer {
|
|
135
|
+
/** Seals like {@link AesGcmSecretSealer.seal}; an omitted `aad` (only `undefined`) becomes zero AAD bytes.
|
|
136
|
+
* @throws `TypeError` for a present non-string `aad` (e.g. `null`); otherwise as the strict `seal`.
|
|
137
|
+
* @complexity O(plaintext bytes).
|
|
138
|
+
*/
|
|
139
|
+
async seal(input) {
|
|
140
|
+
return super.seal({ ...input, aad: input.aad === undefined ? "" : input.aad });
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
/** GCM-decrypts one envelope; no plaintext or partial-output fallback on any failure. */
|
|
144
|
+
function decrypt({ sealed, aesKey, aad }, _optional = {}) {
|
|
145
|
+
const iv = Buffer.from(sealed.nonce, "base64");
|
|
146
|
+
const combined = Buffer.from(sealed.ciphertext, "base64");
|
|
147
|
+
if (combined.length < AUTH_TAG_LENGTH_BYTES) {
|
|
148
|
+
throw new Error("AesGcmSecretSealer: ciphertext too short to contain an auth tag");
|
|
149
|
+
}
|
|
150
|
+
const authTag = combined.subarray(combined.length - AUTH_TAG_LENGTH_BYTES);
|
|
151
|
+
const ciphertext = combined.subarray(0, combined.length - AUTH_TAG_LENGTH_BYTES);
|
|
152
|
+
const decipher = createDecipheriv(ALG, aesKey, iv);
|
|
153
|
+
if (aad !== undefined) {
|
|
154
|
+
decipher.setAAD(Buffer.from(aad, "utf8"));
|
|
155
|
+
}
|
|
156
|
+
decipher.setAuthTag(authTag);
|
|
157
|
+
return Buffer.concat([decipher.update(ciphertext), decipher.final()]).toString("utf8");
|
|
158
|
+
}
|
|
71
159
|
//# sourceMappingURL=secret-sealer.aesgcm.js.map
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { type AgentToolSideEffect, type ToolRegistration } from "@jini-ai/core";
|
|
2
|
+
import { type AgentToolDefinition } from "@jini-ai/core";
|
|
3
|
+
import type { ToolContributor } from "@jini-ai/core";
|
|
4
|
+
import type { AuthorizeFn } from "@jini-ai/core/contracts/events";
|
|
5
|
+
import { type WebFetchInput, type WebFetchResult } from "./web-page.js";
|
|
6
|
+
/** This layer's own risk classification, cross-checked against the catalog's `sideEffects`. */
|
|
7
|
+
export declare const webDerivedRisk: ReadonlyMap<string, AgentToolSideEffect>;
|
|
8
|
+
export interface WebToolDeps {
|
|
9
|
+
workspaceId: string;
|
|
10
|
+
authorize: AuthorizeFn;
|
|
11
|
+
derivedPublicOrigin?: string | undefined;
|
|
12
|
+
}
|
|
13
|
+
export declare function buildWebRegistrations<P>({ routeDeps, ports, host }: {
|
|
14
|
+
routeDeps: WebToolDeps;
|
|
15
|
+
ports: P;
|
|
16
|
+
host: {
|
|
17
|
+
catalog: readonly AgentToolDefinition[];
|
|
18
|
+
permission: string;
|
|
19
|
+
catalogModule: string;
|
|
20
|
+
fetchPage: (required: {
|
|
21
|
+
input: WebFetchInput;
|
|
22
|
+
ports: P;
|
|
23
|
+
rateLimitScope: string;
|
|
24
|
+
}, optional?: {
|
|
25
|
+
signal?: AbortSignal;
|
|
26
|
+
}) => Promise<WebFetchResult>;
|
|
27
|
+
readPageBodyOptions: (required: {
|
|
28
|
+
input: Record<string, unknown>;
|
|
29
|
+
}) => {
|
|
30
|
+
find?: string | undefined;
|
|
31
|
+
maxBytes?: number | undefined;
|
|
32
|
+
textOnly?: boolean | undefined;
|
|
33
|
+
};
|
|
34
|
+
shapePageBody: (required: {
|
|
35
|
+
body: string;
|
|
36
|
+
}, optional?: {
|
|
37
|
+
find?: string;
|
|
38
|
+
maxBytes?: number;
|
|
39
|
+
textOnly?: boolean;
|
|
40
|
+
}) => {
|
|
41
|
+
bodyBytes: number;
|
|
42
|
+
truncated: boolean;
|
|
43
|
+
} & ({
|
|
44
|
+
body: string;
|
|
45
|
+
matches?: never;
|
|
46
|
+
matchCount?: never;
|
|
47
|
+
} | {
|
|
48
|
+
matches: Array<{
|
|
49
|
+
offset: number;
|
|
50
|
+
snippet: string;
|
|
51
|
+
}>;
|
|
52
|
+
matchCount: number;
|
|
53
|
+
body?: never;
|
|
54
|
+
});
|
|
55
|
+
};
|
|
56
|
+
}, _optional?: {}): ToolRegistration[];
|
|
57
|
+
/**
|
|
58
|
+
* Contributes the `web` tools — called once by `tool-catalog-manifest.ts`'s
|
|
59
|
+
* `installFirstPartyToolContributors()`, which owns the guarded client (`WEB_FETCH_EGRESS_POLICY`).
|
|
60
|
+
* One limiter per contributor, so the daemon and BYOK surfaces in one process share the budget.
|
|
61
|
+
*/
|
|
62
|
+
export declare function contributeWebTools<P>({ ports, host }: Pick<Parameters<typeof buildWebRegistrations<P>>[0], "ports" | "host">, { portsForSite }?: {
|
|
63
|
+
portsForSite?: (required: {
|
|
64
|
+
deps: WebToolDeps;
|
|
65
|
+
}) => Partial<P>;
|
|
66
|
+
}): ToolContributor<WebToolDeps, unknown>;
|
|
67
|
+
//# sourceMappingURL=tool-registrations.d.ts.map
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { toolMetadata } from '@jini-ai/core/tool-metadata/web';
|
|
2
|
+
import { buildDomainRegistrations, indexCatalogById, requireInputRecord } from "@jini-ai/core";
|
|
3
|
+
import { adaptLegacyAuthorize, requireToolPermission } from "@jini-ai/core";
|
|
4
|
+
import { MAX_MAX_CHARS, readWebFetchInput } from "./web-page.js";
|
|
5
|
+
/**
|
|
6
|
+
* @file Maps the `web` catalog onto {@link fetchWebPage}. Every catalog entry is wired, so a future
|
|
7
|
+
* entry without a handler fails the build. The handler gates on the same permission the catalog
|
|
8
|
+
* declares (one evaluator, at the handler, per ADR-021 §2).
|
|
9
|
+
*/
|
|
10
|
+
const DOMAIN = "web";
|
|
11
|
+
/** This layer's own risk classification, cross-checked against the catalog's `sideEffects`. */
|
|
12
|
+
export const webDerivedRisk = new Map([
|
|
13
|
+
// -> fetchWebPage(): guarded anonymous reads, optionally with browser data POST/PUT/PATCH; no local writes.
|
|
14
|
+
["web_fetch_page", "none"],
|
|
15
|
+
]);
|
|
16
|
+
export function buildWebRegistrations({ routeDeps, ports, host }, _optional = {}) {
|
|
17
|
+
const handlers = {
|
|
18
|
+
web_fetch_page: async (ctx) => {
|
|
19
|
+
const raw = requireInputRecord({ input: ctx.input });
|
|
20
|
+
const input = readWebFetchInput(raw);
|
|
21
|
+
const { find } = host.readPageBodyOptions({ input: { find: raw.find } });
|
|
22
|
+
await requireToolPermission({ authorize: adaptLegacyAuthorize({ authorize: routeDeps.authorize }), workspaceId: routeDeps.workspaceId, principalId: ctx.principal.id, permission: host.permission }, { entityType: "web-page" });
|
|
23
|
+
// Search beyond the output window, within the existing reader ceiling; maxChars bounds snippets.
|
|
24
|
+
const page = await host.fetchPage({ input: find === undefined ? input : { ...input, maxChars: MAX_MAX_CHARS }, ports, rateLimitScope: routeDeps.workspaceId }, ctx.signal ? { signal: ctx.signal } : {});
|
|
25
|
+
const { content, ...pageFacts } = page;
|
|
26
|
+
const shaped = find === undefined ? undefined : host.shapePageBody({ body: content }, { find, maxBytes: input.maxChars });
|
|
27
|
+
const result = shaped ? { ...pageFacts, ...shaped, truncated: page.truncated || shaped.truncated } : page;
|
|
28
|
+
if (!result.screenshot)
|
|
29
|
+
return result;
|
|
30
|
+
const { screenshot, ...facts } = result;
|
|
31
|
+
return { content: [{ type: "text", text: JSON.stringify(facts) }, { type: "image", mimeType: screenshot.mimeType, data: screenshot.data }] };
|
|
32
|
+
},
|
|
33
|
+
};
|
|
34
|
+
return buildDomainRegistrations({ metadata: toolMetadata, domain: DOMAIN, catalogModule: host.catalogModule, catalog: indexCatalogById({ catalog: host.catalog }), handlers, derivedRisk: webDerivedRisk });
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Contributes the `web` tools — called once by `tool-catalog-manifest.ts`'s
|
|
38
|
+
* `installFirstPartyToolContributors()`, which owns the guarded client (`WEB_FETCH_EGRESS_POLICY`).
|
|
39
|
+
* One limiter per contributor, so the daemon and BYOK surfaces in one process share the budget.
|
|
40
|
+
*/
|
|
41
|
+
export function contributeWebTools({ ports, host }, { portsForSite } = {}) {
|
|
42
|
+
return { domain: DOMAIN, build: deps => buildWebRegistrations({ routeDeps: deps, ports: { ...ports, ...portsForSite?.({ deps }) }, host }), risk: webDerivedRisk };
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=tool-registrations.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jini-ai/platform",
|
|
3
|
-
"version": "0.7.3-next.
|
|
3
|
+
"version": "0.7.3-next.3",
|
|
4
4
|
"description": "Generic OS/platform primitives: process exec and lifecycle, filesystem containment, HTTP readiness polling, toolchain discovery, blob storage, AWS signing, and an SSRF-safe asset cache.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -13,6 +13,8 @@
|
|
|
13
13
|
"kind": "abstraction",
|
|
14
14
|
"runtime": "node",
|
|
15
15
|
"entries": {
|
|
16
|
+
"./mail/email-template-tool-registrations": "node",
|
|
17
|
+
"./secrets/root-key/reconcile": "node",
|
|
16
18
|
".": "node",
|
|
17
19
|
"./fetch-with-timeout": "node",
|
|
18
20
|
"./asset-cache": "node",
|
|
@@ -28,22 +30,41 @@
|
|
|
28
30
|
"./system": "universal",
|
|
29
31
|
"./mail/email-template": "node",
|
|
30
32
|
"./mail/email-template-operations": "node",
|
|
33
|
+
"./mail/email-template-agent-tools": "universal",
|
|
31
34
|
"./mail/smtp": "node",
|
|
35
|
+
"./mail/test-send": "node",
|
|
36
|
+
"./mail/feedback-setup": "node",
|
|
37
|
+
"./mail/use-readiness": "node",
|
|
38
|
+
"./mail/sql": "node",
|
|
32
39
|
"./fs/guarded-reader": "node",
|
|
33
40
|
"./fs/durable-json": "node",
|
|
34
41
|
"./fs": "node",
|
|
35
42
|
"./object-store": "node",
|
|
36
43
|
"./net": "node",
|
|
37
44
|
"./fs/file-lock": "node",
|
|
45
|
+
"./image/png-encode": "node",
|
|
38
46
|
"./secrets/credential-token": "universal",
|
|
39
47
|
"./secrets/legacy-owner": "node",
|
|
48
|
+
"./secrets/legacy-codecs": "node",
|
|
40
49
|
"./web": "node",
|
|
41
50
|
"./command": "node",
|
|
42
51
|
"./process": "node",
|
|
43
52
|
"./toolchain": "node",
|
|
44
53
|
"./proxy-env": "node",
|
|
45
54
|
"./shell": "node",
|
|
46
|
-
"./child-environment": "node"
|
|
55
|
+
"./child-environment": "node",
|
|
56
|
+
"./retention": "node",
|
|
57
|
+
"./object-store/site/setting": "node",
|
|
58
|
+
"./object-store/site/registry": "node",
|
|
59
|
+
"./retention/routes": "node",
|
|
60
|
+
"./web/tool-registrations": "universal",
|
|
61
|
+
"./object-store/site/artifact-provider": "universal",
|
|
62
|
+
"./secrets/root-key/decide": "node",
|
|
63
|
+
"./secrets/root-key/files": "node",
|
|
64
|
+
"./secrets/root-key/material": "node",
|
|
65
|
+
"./secrets/root-key/ordered-keyring": "node",
|
|
66
|
+
"./secrets/root-key/sources": "node",
|
|
67
|
+
"./secrets/root-key/ensure": "node"
|
|
47
68
|
},
|
|
48
69
|
"isolation": {
|
|
49
70
|
"entries": {
|
|
@@ -68,7 +89,8 @@
|
|
|
68
89
|
"hast-util-to-mdast": "opt-in: html to markdown conversion; import @jini-ai/platform/web — HTML to Markdown conversion could not load hast-util-to-mdast. Install hast-util-to-mdast to enable this feature, or check its installed version and native binaries.",
|
|
69
90
|
"mdast-util-to-markdown": "opt-in: html to markdown conversion; import @jini-ai/platform/web — HTML to Markdown conversion could not load mdast-util-to-markdown. Install mdast-util-to-markdown to enable this feature, or check its installed version and native binaries.",
|
|
70
91
|
"mdast-util-gfm-table": "opt-in: markdown table conversion; import @jini-ai/platform/web — Markdown table conversion could not load mdast-util-gfm-table. Install mdast-util-gfm-table to enable this feature, or check its installed version and native binaries.",
|
|
71
|
-
"parse5": "opt-in: html parsing;
|
|
92
|
+
"parse5": "opt-in: html parsing; also loaded by @jini-ai/platform/mail/email-template and @jini-ai/platform/mail/email-template-operations; import @jini-ai/platform/web — HTML parsing could not load parse5. Install parse5 to enable this feature, or check its installed version and native binaries.",
|
|
93
|
+
"kysely": "opt-in: sql storage adapters; import @jini-ai/platform/mail/sql — SQL storage adapters could not load kysely. Install kysely to enable this feature, or check its installed version and native binaries."
|
|
72
94
|
}
|
|
73
95
|
},
|
|
74
96
|
"type": "module",
|
|
@@ -76,6 +98,16 @@
|
|
|
76
98
|
"main": "./dist/index.js",
|
|
77
99
|
"types": "./dist/index.d.ts",
|
|
78
100
|
"exports": {
|
|
101
|
+
"./mail/email-template-tool-registrations": {
|
|
102
|
+
"types": "./dist/mail/email-template-tool-registrations.d.ts",
|
|
103
|
+
"import": "./dist/mail/email-template-tool-registrations.js",
|
|
104
|
+
"default": "./dist/mail/email-template-tool-registrations.js"
|
|
105
|
+
},
|
|
106
|
+
"./secrets/root-key/reconcile": {
|
|
107
|
+
"types": "./dist/secrets/root-key/reconcile.d.ts",
|
|
108
|
+
"import": "./dist/secrets/root-key/reconcile.js",
|
|
109
|
+
"default": "./dist/secrets/root-key/reconcile.js"
|
|
110
|
+
},
|
|
79
111
|
".": {
|
|
80
112
|
"types": "./dist/index.d.ts",
|
|
81
113
|
"import": "./dist/index.js",
|
|
@@ -151,11 +183,36 @@
|
|
|
151
183
|
"import": "./dist/mail/email-template-operations.js",
|
|
152
184
|
"default": "./dist/mail/email-template-operations.js"
|
|
153
185
|
},
|
|
186
|
+
"./mail/email-template-agent-tools": {
|
|
187
|
+
"types": "./dist/mail/email-template-agent-tools.d.ts",
|
|
188
|
+
"import": "./dist/mail/email-template-agent-tools.js",
|
|
189
|
+
"default": "./dist/mail/email-template-agent-tools.js"
|
|
190
|
+
},
|
|
154
191
|
"./mail/smtp": {
|
|
155
192
|
"types": "./dist/mail/smtp.d.ts",
|
|
156
193
|
"import": "./dist/mail/smtp.js",
|
|
157
194
|
"default": "./dist/mail/smtp.js"
|
|
158
195
|
},
|
|
196
|
+
"./mail/test-send": {
|
|
197
|
+
"types": "./dist/mail/test-send.d.ts",
|
|
198
|
+
"import": "./dist/mail/test-send.js",
|
|
199
|
+
"default": "./dist/mail/test-send.js"
|
|
200
|
+
},
|
|
201
|
+
"./mail/feedback-setup": {
|
|
202
|
+
"types": "./dist/mail/feedback-setup.d.ts",
|
|
203
|
+
"import": "./dist/mail/feedback-setup.js",
|
|
204
|
+
"default": "./dist/mail/feedback-setup.js"
|
|
205
|
+
},
|
|
206
|
+
"./mail/use-readiness": {
|
|
207
|
+
"types": "./dist/mail/use-readiness.d.ts",
|
|
208
|
+
"import": "./dist/mail/use-readiness.js",
|
|
209
|
+
"default": "./dist/mail/use-readiness.js"
|
|
210
|
+
},
|
|
211
|
+
"./mail/sql": {
|
|
212
|
+
"types": "./dist/mail/sql/index.d.ts",
|
|
213
|
+
"import": "./dist/mail/sql/index.js",
|
|
214
|
+
"default": "./dist/mail/sql/index.js"
|
|
215
|
+
},
|
|
159
216
|
"./fs/guarded-reader": {
|
|
160
217
|
"types": "./dist/fs/guarded-reader.d.ts",
|
|
161
218
|
"import": "./dist/fs/guarded-reader.js",
|
|
@@ -186,6 +243,11 @@
|
|
|
186
243
|
"import": "./dist/fs/file-lock.js",
|
|
187
244
|
"default": "./dist/fs/file-lock.js"
|
|
188
245
|
},
|
|
246
|
+
"./image/png-encode": {
|
|
247
|
+
"types": "./dist/image/png-encode.d.ts",
|
|
248
|
+
"import": "./dist/image/png-encode.js",
|
|
249
|
+
"default": "./dist/image/png-encode.js"
|
|
250
|
+
},
|
|
189
251
|
"./secrets/credential-token": {
|
|
190
252
|
"types": "./dist/secrets/credential-token.d.ts",
|
|
191
253
|
"import": "./dist/secrets/credential-token.js",
|
|
@@ -196,6 +258,11 @@
|
|
|
196
258
|
"import": "./dist/secrets/legacy-owner.js",
|
|
197
259
|
"default": "./dist/secrets/legacy-owner.js"
|
|
198
260
|
},
|
|
261
|
+
"./secrets/legacy-codecs": {
|
|
262
|
+
"types": "./dist/secrets/legacy-codecs.d.ts",
|
|
263
|
+
"import": "./dist/secrets/legacy-codecs.js",
|
|
264
|
+
"default": "./dist/secrets/legacy-codecs.js"
|
|
265
|
+
},
|
|
199
266
|
"./web": {
|
|
200
267
|
"types": "./dist/web/index.d.ts",
|
|
201
268
|
"import": "./dist/web/index.js",
|
|
@@ -230,6 +297,66 @@
|
|
|
230
297
|
"types": "./dist/child-environment.d.ts",
|
|
231
298
|
"import": "./dist/child-environment.js",
|
|
232
299
|
"default": "./dist/child-environment.js"
|
|
300
|
+
},
|
|
301
|
+
"./retention": {
|
|
302
|
+
"types": "./dist/retention/index.d.ts",
|
|
303
|
+
"import": "./dist/retention/index.js",
|
|
304
|
+
"default": "./dist/retention/index.js"
|
|
305
|
+
},
|
|
306
|
+
"./object-store/site/setting": {
|
|
307
|
+
"types": "./dist/object-store/site/setting.d.ts",
|
|
308
|
+
"import": "./dist/object-store/site/setting.js",
|
|
309
|
+
"default": "./dist/object-store/site/setting.js"
|
|
310
|
+
},
|
|
311
|
+
"./object-store/site/registry": {
|
|
312
|
+
"types": "./dist/object-store/site/registry.d.ts",
|
|
313
|
+
"import": "./dist/object-store/site/registry.js",
|
|
314
|
+
"default": "./dist/object-store/site/registry.js"
|
|
315
|
+
},
|
|
316
|
+
"./retention/routes": {
|
|
317
|
+
"types": "./dist/retention/routes.d.ts",
|
|
318
|
+
"import": "./dist/retention/routes.js",
|
|
319
|
+
"default": "./dist/retention/routes.js"
|
|
320
|
+
},
|
|
321
|
+
"./web/tool-registrations": {
|
|
322
|
+
"types": "./dist/web/tool-registrations.d.ts",
|
|
323
|
+
"import": "./dist/web/tool-registrations.js",
|
|
324
|
+
"default": "./dist/web/tool-registrations.js"
|
|
325
|
+
},
|
|
326
|
+
"./object-store/site/artifact-provider": {
|
|
327
|
+
"types": "./dist/object-store/site/artifact-provider.d.ts",
|
|
328
|
+
"import": "./dist/object-store/site/artifact-provider.js",
|
|
329
|
+
"default": "./dist/object-store/site/artifact-provider.js"
|
|
330
|
+
},
|
|
331
|
+
"./secrets/root-key/decide": {
|
|
332
|
+
"types": "./dist/secrets/root-key/decide.d.ts",
|
|
333
|
+
"import": "./dist/secrets/root-key/decide.js",
|
|
334
|
+
"default": "./dist/secrets/root-key/decide.js"
|
|
335
|
+
},
|
|
336
|
+
"./secrets/root-key/files": {
|
|
337
|
+
"types": "./dist/secrets/root-key/files.d.ts",
|
|
338
|
+
"import": "./dist/secrets/root-key/files.js",
|
|
339
|
+
"default": "./dist/secrets/root-key/files.js"
|
|
340
|
+
},
|
|
341
|
+
"./secrets/root-key/material": {
|
|
342
|
+
"types": "./dist/secrets/root-key/material.d.ts",
|
|
343
|
+
"import": "./dist/secrets/root-key/material.js",
|
|
344
|
+
"default": "./dist/secrets/root-key/material.js"
|
|
345
|
+
},
|
|
346
|
+
"./secrets/root-key/ordered-keyring": {
|
|
347
|
+
"types": "./dist/secrets/root-key/ordered-keyring.d.ts",
|
|
348
|
+
"import": "./dist/secrets/root-key/ordered-keyring.js",
|
|
349
|
+
"default": "./dist/secrets/root-key/ordered-keyring.js"
|
|
350
|
+
},
|
|
351
|
+
"./secrets/root-key/sources": {
|
|
352
|
+
"types": "./dist/secrets/root-key/sources.d.ts",
|
|
353
|
+
"import": "./dist/secrets/root-key/sources.js",
|
|
354
|
+
"default": "./dist/secrets/root-key/sources.js"
|
|
355
|
+
},
|
|
356
|
+
"./secrets/root-key/ensure": {
|
|
357
|
+
"types": "./dist/secrets/root-key/ensure.d.ts",
|
|
358
|
+
"import": "./dist/secrets/root-key/ensure.js",
|
|
359
|
+
"default": "./dist/secrets/root-key/ensure.js"
|
|
233
360
|
}
|
|
234
361
|
},
|
|
235
362
|
"files": [
|
|
@@ -246,28 +373,30 @@
|
|
|
246
373
|
],
|
|
247
374
|
"dependencies": {
|
|
248
375
|
"undici": "^7.30.1",
|
|
249
|
-
"@jini-ai/core": "^0.7.3-next.
|
|
376
|
+
"@jini-ai/core": "^0.7.3-next.3"
|
|
250
377
|
},
|
|
251
378
|
"publishConfig": {
|
|
252
379
|
"access": "public",
|
|
253
380
|
"registry": "https://registry.npmjs.org"
|
|
254
381
|
},
|
|
255
382
|
"devDependencies": {
|
|
256
|
-
"@vitest/coverage-v8": "^2.
|
|
383
|
+
"@vitest/coverage-v8": "^3.2.6",
|
|
257
384
|
"undici": "^7.30.1",
|
|
258
385
|
"hast-util-from-parse5": "8.0.3",
|
|
259
386
|
"hast-util-to-mdast": "10.1.2",
|
|
260
387
|
"mdast-util-to-markdown": "2.1.2",
|
|
261
388
|
"mdast-util-gfm-table": "2.0.0",
|
|
262
389
|
"parse5": "7.3.0",
|
|
263
|
-
"fast-check": "4.3.0"
|
|
390
|
+
"fast-check": "4.3.0",
|
|
391
|
+
"kysely": "^0.29.6"
|
|
264
392
|
},
|
|
265
393
|
"peerDependencies": {
|
|
266
394
|
"hast-util-from-parse5": "8.0.3",
|
|
267
395
|
"hast-util-to-mdast": "10.1.2",
|
|
268
396
|
"mdast-util-to-markdown": "2.1.2",
|
|
269
397
|
"mdast-util-gfm-table": "2.0.0",
|
|
270
|
-
"parse5": "7.3.0"
|
|
398
|
+
"parse5": "7.3.0",
|
|
399
|
+
"kysely": "^0.29.6"
|
|
271
400
|
},
|
|
272
401
|
"peerDependenciesMeta": {
|
|
273
402
|
"hast-util-from-parse5": {
|
|
@@ -284,6 +413,9 @@
|
|
|
284
413
|
},
|
|
285
414
|
"parse5": {
|
|
286
415
|
"optional": true
|
|
416
|
+
},
|
|
417
|
+
"kysely": {
|
|
418
|
+
"optional": true
|
|
287
419
|
}
|
|
288
420
|
},
|
|
289
421
|
"scripts": {
|