@jini-ai/core 0.7.3-next.3 → 0.7.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7 -0
- package/dist/batch-tool-inputs.d.ts +3 -3
- package/dist/batch-tool-inputs.js +18 -6
- package/dist/contracts/hosted-mcp/record.d.ts +2 -1
- package/dist/contracts/server/request-body.js +1 -1
- package/dist/contracts/site/cms-media.d.ts +15 -0
- package/dist/contracts/site/external-mcp-tool-ports.d.ts +2 -0
- package/dist/contracts/site/media-tool-ports.d.ts +8 -4
- package/dist/contracts/vault/vendor-credential-sets.d.ts +12 -0
- package/dist/errors/catalog.js +2 -2
- package/dist/records.d.ts +1 -1
- package/dist/records.js +1 -1
- package/dist/redaction-collectors.js +25 -2
- package/dist/redaction-patterns.d.ts +2 -1
- package/dist/redaction-patterns.js +18 -9
- package/dist/redaction.d.ts +5 -0
- package/dist/redaction.js +5 -0
- package/dist/registration-kit.js +7 -4
- package/dist/text/format-timestamp.js +3 -2
- package/dist/tool-metadata/custom-credentials.js +1 -1
- package/dist/tool-metadata/media-generation.d.ts +5 -4
- package/dist/tool-metadata/media-generation.js +5 -4
- package/package.json +52 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
## 0.7.4
|
|
2
|
+
|
|
3
|
+
### Changes
|
|
4
|
+
|
|
5
|
+
- Add shared error reporting, request/reply contracts, settings readers, agent handles, and tool metadata.
|
|
6
|
+
- Add workspace-scoped blob collection and media codec contracts, and preserve trusted actors through mutation and revert authorization.
|
|
7
|
+
|
|
1
8
|
## 0.7.2
|
|
2
9
|
|
|
3
10
|
## 0.7.1
|
|
@@ -75,9 +75,9 @@ export declare function batchOutcomeFor({ output }: {
|
|
|
75
75
|
}, _options?: {}): BatchResult['outcome'] | undefined;
|
|
76
76
|
/**
|
|
77
77
|
* The descriptor a batchable tool publishes: its own schema plus an `items` array, its top-level
|
|
78
|
-
* `required` list retained as metadata and described on required
|
|
79
|
-
* those per item or once at the top level through the declared
|
|
80
|
-
* guidance appended to its description.
|
|
78
|
+
* `required` list enforced for single calls, retained as metadata and described on required
|
|
79
|
+
* properties (a batch call sets those per item or once at the top level through the declared
|
|
80
|
+
* legacy normalization), and batch guidance appended to its description.
|
|
81
81
|
*
|
|
82
82
|
* @param required.descriptor - The tool's registered descriptor.
|
|
83
83
|
* @param required.tool - Its batch settings.
|
|
@@ -57,11 +57,20 @@ function outcomeFor({ failed, total }) {
|
|
|
57
57
|
function isPlainObject(value) {
|
|
58
58
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
59
59
|
}
|
|
60
|
+
/** Single calls keep their requirements; batches may supply shared fields through normalization. */
|
|
61
|
+
function singleCallConstraints({ schema, requiredFields }, _optional = {}) {
|
|
62
|
+
if (requiredFields.length === 0)
|
|
63
|
+
return {};
|
|
64
|
+
// Requiring every field inside each item would reject legacy batches that inherit shared fields.
|
|
65
|
+
return { allOf: [...(schema.allOf ?? []), {
|
|
66
|
+
anyOf: [{ required: ['items'] }, { required: [...requiredFields] }],
|
|
67
|
+
}] };
|
|
68
|
+
}
|
|
60
69
|
/**
|
|
61
70
|
* The descriptor a batchable tool publishes: its own schema plus an `items` array, its top-level
|
|
62
|
-
* `required` list retained as metadata and described on required
|
|
63
|
-
* those per item or once at the top level through the declared
|
|
64
|
-
* guidance appended to its description.
|
|
71
|
+
* `required` list enforced for single calls, retained as metadata and described on required
|
|
72
|
+
* properties (a batch call sets those per item or once at the top level through the declared
|
|
73
|
+
* legacy normalization), and batch guidance appended to its description.
|
|
65
74
|
*
|
|
66
75
|
* @param required.descriptor - The tool's registered descriptor.
|
|
67
76
|
* @param required.tool - Its batch settings.
|
|
@@ -106,7 +115,10 @@ export function batchDescriptorFor({ descriptor, tool }, _optional = {}) {
|
|
|
106
115
|
"Canonical shape: {items:[{...}, ...]} only. Legacy shared top-level fields are normalized into each item; item values win. " +
|
|
107
116
|
singleNeeds +
|
|
108
117
|
"Returns { batch: true, outcome: completed | partial_failure | error, total, succeeded, failed, results: [{ index, ok, result | error }] }; one item's failure does not stop the others.",
|
|
109
|
-
inputSchema: {
|
|
118
|
+
inputSchema: {
|
|
119
|
+
...rest, ...singleCallConstraints({ schema, requiredFields }),
|
|
120
|
+
[BATCH_ITEM_REQUIRED_FIELDS]: [...requiredFields], properties: { ...properties, items },
|
|
121
|
+
},
|
|
110
122
|
};
|
|
111
123
|
}
|
|
112
124
|
/** The domain message without `withSchemaOnRejection`'s appended schema: the text before the
|
|
@@ -141,8 +153,8 @@ async function normalizeBatchItem({ registration, defaults, shared, item }) {
|
|
|
141
153
|
const normalized = await normalizeToolInput({ input, registration });
|
|
142
154
|
return { input: normalized.input, notes: [...layers.flatMap(layer => layer.notes), ...normalized.notes] };
|
|
143
155
|
}
|
|
144
|
-
/**
|
|
145
|
-
*
|
|
156
|
+
/** Enforce single-call requirements from the wrapped tool's own schema at the runtime boundary.
|
|
157
|
+
* Normalize first so repaired spellings and domain aliases satisfy them.
|
|
146
158
|
* @throws ToolInputError with every required name/type when any required value is missing.
|
|
147
159
|
* @complexity O(r) for r required fields, plus the existing normalization; no effects.
|
|
148
160
|
*/
|
|
@@ -148,7 +148,8 @@ export interface ExternalMcpOAuthRuntimePatch {
|
|
|
148
148
|
* than a single-row find/upsert. */
|
|
149
149
|
/** @agent-note Fulfilled by the host (SQL or memory adapter). The store, the sign-in service and the plugin connect seam must receive the SAME repository instance, because sealed envelopes carry private repository context only that repository rebuilds. */
|
|
150
150
|
export interface ExternalMcpServerRepoPort {
|
|
151
|
-
/** @agent-note Workspace-scoped; returns whole saved rows
|
|
151
|
+
/** @agent-note Workspace-scoped; returns whole saved rows in ascending serverId UTF-8 byte
|
|
152
|
+
* order (SQLite BINARY / PostgreSQL C), never views. No insertion-order or locale dependency. */
|
|
152
153
|
listByWorkspaceId(workspaceId: UUID): Promise<ExternalMcpServerRecord[]>;
|
|
153
154
|
/** @agent-note Returns the whole saved row or `null`; at most one row read per call. */
|
|
154
155
|
findByServerId(input: {
|
|
@@ -54,7 +54,7 @@ async function collectBody({ body, maxBytes }) {
|
|
|
54
54
|
return ok({ value: bytes });
|
|
55
55
|
}
|
|
56
56
|
function isJsonContentType(contentType) {
|
|
57
|
-
const mediaType = (contentType ?? '').
|
|
57
|
+
const mediaType = (contentType ?? '').replace(/;[\s\S]*$/, '').trim().toLowerCase();
|
|
58
58
|
return mediaType === 'application/json' || mediaType.endsWith('+json');
|
|
59
59
|
}
|
|
60
60
|
/**
|
|
@@ -268,6 +268,9 @@ export interface AdminMediaDto {
|
|
|
268
268
|
displayFilename: string;
|
|
269
269
|
/** Stable creation principal ID; NULL means unknown legacy/pre-migration attribution. */
|
|
270
270
|
createdBy: string | null;
|
|
271
|
+
/** Sanitized recorded origin, separate from the acting principal and editorial prose. Omitted
|
|
272
|
+
* for legacy/invalid origins; generated model/provider IDs are never inferred from captions. */
|
|
273
|
+
provenance?: MediaProvenance;
|
|
271
274
|
workspaceId: string;
|
|
272
275
|
title: string;
|
|
273
276
|
/** Human-memorable, unique-per-workspace lookup key (2026-09-07) — see `MediaRecord.slug`'s own
|
|
@@ -316,9 +319,21 @@ export interface AdminMediaDto {
|
|
|
316
319
|
videoCodec?: VideoCodec;
|
|
317
320
|
}
|
|
318
321
|
export type MediaConversionNotice = "web-copy-unavailable";
|
|
322
|
+
/** Request outcome, separate from editorial text and production provenance. Hosts localize codes. */
|
|
323
|
+
export type MediaDescriptionCapture = {
|
|
324
|
+
status: "saved";
|
|
325
|
+
} | {
|
|
326
|
+
status: "skipped";
|
|
327
|
+
reason: "description-present" | "not-image" | "private-image" | "inactive";
|
|
328
|
+
} | {
|
|
329
|
+
status: "failed";
|
|
330
|
+
reason: "permission-denied" | "authorization-unavailable" | "version-conflict" | "image-bytes-unavailable" | "description-unavailable" | "invalid-description" | "cancelled" | "conditional-write-unavailable" | "metadata-write-unavailable";
|
|
331
|
+
};
|
|
319
332
|
export type MediaUploadResult<Media> = {
|
|
320
333
|
media: Media;
|
|
321
334
|
conversionNotice?: MediaConversionNotice;
|
|
335
|
+
/** Omitted when the host has not configured automatic description capture. */
|
|
336
|
+
descriptionCapture?: MediaDescriptionCapture;
|
|
322
337
|
};
|
|
323
338
|
/** The single-asset body (update, trash). */
|
|
324
339
|
export interface AdminMediaEnvelope {
|
|
@@ -10,6 +10,8 @@ export interface ExternalMcpToolDeps extends OperatorLocaleDeps {
|
|
|
10
10
|
serverId: string;
|
|
11
11
|
admissionRevision: string;
|
|
12
12
|
}) => readonly string[] | null;
|
|
13
|
+
/** Live saved-server probe: connect, list tools, close; never invoke a remote tool.
|
|
14
|
+
* Test connection refuses when absent. Configuration readiness must never implement this port. */
|
|
13
15
|
externalMcpProbe?: (required: {
|
|
14
16
|
serverId: string;
|
|
15
17
|
}) => Promise<{
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { MediaRecord, MediaProvenance, StagedMediaFile } from "./cms-media.js";
|
|
1
|
+
import type { MediaRecord, MediaProvenance, StagedMediaFile, MediaUploadResult } from "./cms-media.js";
|
|
2
2
|
export interface MediaToolUploadInput {
|
|
3
3
|
workspaceId: string;
|
|
4
4
|
bytes: Uint8Array;
|
|
@@ -26,6 +26,10 @@ export interface ImportedMediaView {
|
|
|
26
26
|
alt: string;
|
|
27
27
|
caption: string;
|
|
28
28
|
credit: string;
|
|
29
|
+
/** Stored description: absent means never described; an empty string is an explicit clear. */
|
|
30
|
+
description?: string | undefined;
|
|
31
|
+
/** Recorded origin, independent of the authenticated creator and editable credit. */
|
|
32
|
+
source?: MediaProvenance | undefined;
|
|
29
33
|
sha256: string;
|
|
30
34
|
status: string;
|
|
31
35
|
version: number;
|
|
@@ -37,9 +41,9 @@ export interface ImportedMediaView {
|
|
|
37
41
|
export interface MediaToolStoragePorts {
|
|
38
42
|
upload(required: {
|
|
39
43
|
input: MediaToolUploadInput;
|
|
40
|
-
}, optional?:
|
|
41
|
-
|
|
42
|
-
}
|
|
44
|
+
}, optional?: {
|
|
45
|
+
signal?: AbortSignal;
|
|
46
|
+
}): Promise<MediaUploadResult<MediaRecord>>;
|
|
43
47
|
recordContentType(required: {
|
|
44
48
|
workspaceId: string;
|
|
45
49
|
sha256: string;
|
|
@@ -71,5 +71,17 @@ export interface VendorCredentialSetRepoPort {
|
|
|
71
71
|
id: string;
|
|
72
72
|
accountLabel: string;
|
|
73
73
|
}): Promise<void>;
|
|
74
|
+
/** Compare and patch atomically against the revision opened by a provider probe. Return the
|
|
75
|
+
* committed basis (unchanged for an identical label), or null for a missing/replaced row.
|
|
76
|
+
* Preserve the envelope, defaults, hints and timestamps. Never retry against a newer revision. */
|
|
77
|
+
updateAccountLabelIfRevision(input: {
|
|
78
|
+
workspaceId: string;
|
|
79
|
+
id: string;
|
|
80
|
+
accountLabel: string;
|
|
81
|
+
expectedRevision: number;
|
|
82
|
+
}): Promise<{
|
|
83
|
+
id: string;
|
|
84
|
+
revision: number;
|
|
85
|
+
} | null>;
|
|
74
86
|
}
|
|
75
87
|
//# sourceMappingURL=vendor-credential-sets.d.ts.map
|
package/dist/errors/catalog.js
CHANGED
|
@@ -141,8 +141,8 @@ export function createErrorCatalog(required, optional = {}) {
|
|
|
141
141
|
...(binding.text.mode === 'fixed' ? { message: binding.text.text } : {}),
|
|
142
142
|
...(binding.guidance === undefined ? {} : { guidance: binding.guidance }),
|
|
143
143
|
})),
|
|
144
|
-
callerSafeRules: ({ scope }) => ruleBindings({ bindings: scopes.get(scope) ?? [] }).filter(binding => binding.text.mode
|
|
145
|
-
error: binding.error,
|
|
144
|
+
callerSafeRules: ({ scope }) => ruleBindings({ bindings: scopes.get(scope) ?? [] }).filter((binding) => binding.text.mode === 'fixed').map(binding => ({
|
|
145
|
+
error: binding.error, message: binding.text.text,
|
|
146
146
|
})),
|
|
147
147
|
describerVocabulary: () => describer,
|
|
148
148
|
sourceSentences: () => source,
|
package/dist/records.d.ts
CHANGED
|
@@ -11,7 +11,7 @@ export declare function isRecord(required: {
|
|
|
11
11
|
/**
|
|
12
12
|
* Accepts non-null, non-array objects, including class instances and null-prototype records.
|
|
13
13
|
* This is a shape check, not plain-object validation or sanitization. Keep `isRecord`'s
|
|
14
|
-
* broader contract
|
|
14
|
+
* broader contract for callers that accept arrays; tool argument records use this narrower check.
|
|
15
15
|
* @param required.value - The untrusted value whose object shape is checked.
|
|
16
16
|
* @complexity O(1) time and space.
|
|
17
17
|
* @example isNonArrayRecord({ value: [] }); // false
|
package/dist/records.js
CHANGED
|
@@ -10,7 +10,7 @@ export function isRecord(required, _optional = {}) {
|
|
|
10
10
|
/**
|
|
11
11
|
* Accepts non-null, non-array objects, including class instances and null-prototype records.
|
|
12
12
|
* This is a shape check, not plain-object validation or sanitization. Keep `isRecord`'s
|
|
13
|
-
* broader contract
|
|
13
|
+
* broader contract for callers that accept arrays; tool argument records use this narrower check.
|
|
14
14
|
* @param required.value - The untrusted value whose object shape is checked.
|
|
15
15
|
* @complexity O(1) time and space.
|
|
16
16
|
* @example isNonArrayRecord({ value: [] }); // false
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { SECRET_SHAPE_PATTERNS } from './secret-shapes.js';
|
|
2
|
-
import { PATTERNS, CATEGORY, CARD_CANDIDATE, API_KEY_HEADER, API_KEY_QUERY, SHORT_BEARER_RE,
|
|
2
|
+
import { PATTERNS, CATEGORY, CARD_CANDIDATE, API_KEY_HEADER, API_KEY_QUERY, SHORT_BEARER_RE, NON_BEARER_AUTH_RE, CUSTOM_AUTH_HEADER_RE, COOKIE_HEADER_RE, PROVIDER_API_KEY_QUERY, URL_CREDENTIALS_RE, SIGNED_QUERY_RE, URL_SECRET_PARAM_RE, LABELED_URL_PARAM_NAME_RE, OPAQUE_TOKEN_RE, NON_SECRET_TOKEN_RE, isMaskedValue } from './redaction-patterns.js';
|
|
3
3
|
import { collectMatches, trailingValue } from './redaction-spans.js';
|
|
4
4
|
import { collectLabeledSecrets, emptyAssignmentRanges, collectEmptyQuotedAssignments } from './redaction-labels.js';
|
|
5
5
|
import { collectExactSecrets } from './redaction-exact-secrets.js';
|
|
@@ -87,6 +87,7 @@ function collectUrlCredentials(pass) {
|
|
|
87
87
|
* before) merge into one span instead of one leaving a credential suffix beside the other's marker. */
|
|
88
88
|
function collectKeyedCredentials(pass) {
|
|
89
89
|
collectApiKeyHeaders(pass);
|
|
90
|
+
collectCustomAuthHeaders(pass);
|
|
90
91
|
collectMatches({ pass, regex: PROVIDER_API_KEY_QUERY, spanOf: trailingValue({ category: CATEGORY.apiKeyQuery, group: 2 }) });
|
|
91
92
|
collectMatches({
|
|
92
93
|
pass, regex: API_KEY_QUERY,
|
|
@@ -103,10 +104,32 @@ function collectKeyedCredentials(pass) {
|
|
|
103
104
|
return { start, end: start + (match[1] ?? '').length, category: CATEGORY.bearerToken };
|
|
104
105
|
},
|
|
105
106
|
});
|
|
106
|
-
collectMatches({ pass, regex:
|
|
107
|
+
collectMatches({ pass, regex: NON_BEARER_AUTH_RE, spanOf: trailingValue({ category: CATEGORY.labeledSecret, group: 1 }) });
|
|
107
108
|
collectMatches({ pass, regex: COOKIE_HEADER_RE, spanOf: trailingValue({ category: CATEGORY.labeledSecret, group: 1 }) });
|
|
108
109
|
collectUrlSecretParams(pass);
|
|
109
110
|
}
|
|
111
|
+
/** Keep quotes and neighboring fields intact when masking a credential-named custom header. */
|
|
112
|
+
function collectCustomAuthHeaders({ text, add }, _optional = {}) {
|
|
113
|
+
const hints = emptyAssignmentRanges({ text });
|
|
114
|
+
collectMatches({
|
|
115
|
+
pass: { text, add }, regex: CUSTOM_AUTH_HEADER_RE,
|
|
116
|
+
spanOf: (match, index) => {
|
|
117
|
+
// An empty quoted hint ends at its own quote; the next field is not its value.
|
|
118
|
+
if (hints.has(index))
|
|
119
|
+
return undefined;
|
|
120
|
+
const value = match[3] ?? '';
|
|
121
|
+
// Scheme collectors own the complete expression; consuming only its first word either
|
|
122
|
+
// hides a readable scheme or leaves a short credential visible after it.
|
|
123
|
+
if (/^(?:Bearer|Basic|Token|ApiKey|Digest)$/i.test(value))
|
|
124
|
+
return undefined;
|
|
125
|
+
if (isMaskedValue({ value }))
|
|
126
|
+
return undefined;
|
|
127
|
+
const end = index + match[0].length;
|
|
128
|
+
const quoted = /^["']/.test(value) ? 1 : 0;
|
|
129
|
+
return { start: end - value.length + quoted, end: end - quoted, category: CATEGORY.labeledSecret };
|
|
130
|
+
},
|
|
131
|
+
});
|
|
132
|
+
}
|
|
110
133
|
/** Header values stop at their quotes; an empty quoted hint cannot borrow the next field.
|
|
111
134
|
* @complexity O(n) over input characters, no I/O. */
|
|
112
135
|
function collectApiKeyHeaders(pass) {
|
|
@@ -43,7 +43,8 @@ export declare const NON_SECRET_TOKEN_RE: RegExp;
|
|
|
43
43
|
export declare const MASK_AWARE_LABELED_SECRET_RE: RegExp;
|
|
44
44
|
export declare const CHAINED_LABEL_RE: RegExp;
|
|
45
45
|
export declare const SHORT_BEARER_RE: RegExp;
|
|
46
|
-
export declare const
|
|
46
|
+
export declare const NON_BEARER_AUTH_RE: RegExp;
|
|
47
|
+
export declare const CUSTOM_AUTH_HEADER_RE: RegExp;
|
|
47
48
|
export declare const COOKIE_HEADER_RE: RegExp;
|
|
48
49
|
export declare const PROVIDER_API_KEY_QUERY: RegExp;
|
|
49
50
|
export declare const URL_CREDENTIALS_RE: RegExp;
|
|
@@ -115,7 +115,7 @@ export const API_KEY_QUERY = /([?&](?:key|api_key|api-key)=)[^&#\s,;"']+/gi;
|
|
|
115
115
|
// correlation ID uses uppercase hex and is meant to reach the model and be quoted to an
|
|
116
116
|
// operator; delegated-tool-calls is the route segment named in delegated tool failures.
|
|
117
117
|
// Matching the ENTIRE run keeps a secret glued onto either spelling redactable.
|
|
118
|
-
const SECRET_LABELS = 'authorization|bearer|api[-_]?key|access[-_]?token|refresh[-_]?token|client[-_]?secret|password|secret|cookie';
|
|
118
|
+
const SECRET_LABELS = 'authorization|bearer|api[-_]?key|access[-_]?token|refresh[-_]?token|id[-_]?token|auth[-_]?token|client[-_]?secret|signing[-_]?secret|webhook[-_]?secret|password|passwd|pwd|secret|cookie';
|
|
119
119
|
// Keep historical URL categories and the bounded sanitizer's vocabulary stable.
|
|
120
120
|
const SERIALIZED_SECRET_LABELS = `${SECRET_LABELS}|x[-_](?:goog[-_])?api[-_]?key|api key|token|set[-_]cookie|private[-_]?key`;
|
|
121
121
|
export const EMPTY_QUOTED_ASSIGNMENT_RE = new RegExp(`\\b(?:${SERIALIZED_SECRET_LABELS})\\s*[:=]\\s*$`, 'i');
|
|
@@ -143,30 +143,39 @@ export const CHAINED_LABEL_RE = new RegExp(`(?:${RUNTIME_SECRET_LABELS})\\b["']?
|
|
|
143
143
|
// The value is read in a lookahead so the scan resumes at it (`Bearer Bearer x` masks both),
|
|
144
144
|
// as the earlier lookbehind form did, without a lookbehind test at every position.
|
|
145
145
|
// Quotes and field delimiters end the value; punctuation such as `!` remains credential text.
|
|
146
|
-
export const SHORT_BEARER_RE = new RegExp(
|
|
147
|
-
|
|
146
|
+
export const SHORT_BEARER_RE = new RegExp(`\\bBearer\\s+["']?(?!${GENERATED_MARKER}(?=$|[\\s"',;<>}]))(?=([^\\s"',;<>}]+))`, 'gi');
|
|
147
|
+
// Digest credentials are a comma-separated parameter list; masking only the first word leaves
|
|
148
|
+
// quoted usernames, nonces and responses in provider failures. Stop before the next header.
|
|
149
|
+
const DIGEST_PARAMETER = `[\\w-]+[ \\t]*=[ \\t]*(?:${QUOTED_SECRET_VALUE}|[^\\s"',;}]+)`;
|
|
150
|
+
const CUSTOM_AUTH_HEADER_NAME = 'x-(?:[a-z0-9]+-)*(?:auth(?:orization)?|key|token|secret|credential)';
|
|
151
|
+
export const NON_BEARER_AUTH_RE = new RegExp(`(?<![\\w-])(?:(?:proxy-)?authorization|${CUSTOM_AUTH_HEADER_NAME})["']?\\s*[:=]\\s*["']?((?:Basic|Token|ApiKey)\\s+[^\\s"',;}]+|Digest[ \\t]+${DIGEST_PARAMETER}(?:,[ \\t]*${DIGEST_PARAMETER})*)`, 'gi');
|
|
152
|
+
// Only credential-named custom headers carry authority; X-Request-Id and other labels stay readable.
|
|
153
|
+
export const CUSTOM_AUTH_HEADER_RE = new RegExp(`(?<![\\w-])(["']?)(${CUSTOM_AUTH_HEADER_NAME})\\1\\s*[:=]\\s*(${QUOTED_SECRET_VALUE}|[^\\s,"';}]+)`, 'gi');
|
|
148
154
|
// Cookie pairs belong to one header value, including pairs after a semicolon and a space.
|
|
149
155
|
export const COOKIE_HEADER_RE = /\bcookie\s*:\s*([^\r\n]+)/gi;
|
|
150
156
|
export const PROVIDER_API_KEY_QUERY = /([?&]key=)([^&\s"']+)/gi;
|
|
151
157
|
// URL userinfo and signed query values have explicit credential context; unlike opaque runs,
|
|
152
158
|
// they are safe to recognize in the conservative policy. Keep scheme/host and query names
|
|
153
159
|
// readable for debugging without exposing credentials that authorize access to the resource.
|
|
154
|
-
// Matching starts at `//` and reads
|
|
160
|
+
// Matching starts at `//` and reads userinfo through the LAST `@` within the authority: unescaped
|
|
161
|
+
// at-signs in a password must not leave its suffix visible. No scheme
|
|
155
162
|
// scan is needed, so a scheme of any length (glued text included) cannot hide its userinfo:
|
|
156
163
|
// an unbounded scheme run rescanned the suffix from every start
|
|
157
164
|
// (`'a.'.repeat(20000)` blocked ~3.6 s), trying a bounded scheme at every position cost ~2 s on
|
|
158
165
|
// 10 MiB of `'eyJ-'`, and a 32-character scheme lookbehind missed longer schemes.
|
|
159
166
|
// The same authority syntax also appears in scheme-relative URLs (`//user:pw@host`).
|
|
160
|
-
export const URL_CREDENTIALS_RE = /\/\/([^/\s
|
|
167
|
+
export const URL_CREDENTIALS_RE = /\/\/([^/\s?#]+)@/g;
|
|
161
168
|
export const SIGNED_QUERY_RE = /([?&](?:signature|sig|x-amz-signature|x-goog-signature|access_token|refresh_token)=)([^&#\s,;"']+)/gi;
|
|
162
169
|
// A secret word must END a name segment (split at . _ - or the name's end): api_key, apiKey,
|
|
163
170
|
// authtoken, X-Amz-Signature and custom.Token-value are masked, while author, keyword, design,
|
|
164
|
-
// signup and page stay readable.
|
|
165
|
-
//
|
|
171
|
+
// signup and page stay readable. Code parameters require an explicit credential name: zipcode
|
|
172
|
+
// and error_code are ordinary diagnostics, while authorization/activation codes grant access.
|
|
173
|
+
// Other names that end in a secret word (monkey) retain the historical policy. Empty values stay.
|
|
166
174
|
// Match through a trailing fragment; field separators (&/;), quotes, parentheses or whitespace end it.
|
|
167
175
|
// Both name runs are bounded so a long separator-free run costs linear time, not quadratic.
|
|
168
|
-
const URL_SECRET_WORDS = 'token|key|secret|signature|sig|
|
|
169
|
-
|
|
176
|
+
const URL_SECRET_WORDS = 'token|key|secret|signature|sig|password|passwd|pwd|auth|authorization|credential';
|
|
177
|
+
const URL_CODE_NAME = '(?:(?:activation|authorization|auth|device|user|recovery)[._-])?code';
|
|
178
|
+
export const URL_SECRET_PARAM_RE = new RegExp(`[?&#;]([\\w.-]{0,128}?(?:${URL_SECRET_WORDS})s?(?=[._=-])[\\w.-]{0,128}|${URL_CODE_NAME})=[^&;\\s"'<>()]+`, 'gi');
|
|
170
179
|
// A parameter the labeled rule already names (password, client_secret, ...) keeps that category.
|
|
171
180
|
export const LABELED_URL_PARAM_NAME_RE = new RegExp(`(?:^|[.-])(?:${SECRET_LABELS})$`, 'i');
|
|
172
181
|
// Only an entire generated marker is already masked. A secret glued onto marker-like text still
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/** Redaction and secret-pattern vocabulary without the core composition/tool barrel. */
|
|
2
|
+
export { redactSecrets, redactSecretsWithCounts } from './redact.js';
|
|
3
|
+
export { SECRET_SHAPE_PATTERNS, PEM_PATTERN_NAME, type SecretShapePattern, } from './secret-shapes.js';
|
|
4
|
+
export { GENERATED_MARKER_RE, LABELED_SECRET_RE, OPAQUE_TOKEN_RE, NON_SECRET_TOKEN_RE, type SecretRedactionPattern, type SecretRedactionOptions, } from './redaction-patterns.js';
|
|
5
|
+
//# sourceMappingURL=redaction.d.ts.map
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/** Redaction and secret-pattern vocabulary without the core composition/tool barrel. */
|
|
2
|
+
export { redactSecrets, redactSecretsWithCounts } from './redact.js';
|
|
3
|
+
export { SECRET_SHAPE_PATTERNS, PEM_PATTERN_NAME, } from './secret-shapes.js';
|
|
4
|
+
export { GENERATED_MARKER_RE, LABELED_SECRET_RE, OPAQUE_TOKEN_RE, NON_SECRET_TOKEN_RE, } from './redaction-patterns.js';
|
|
5
|
+
//# sourceMappingURL=redaction.js.map
|
package/dist/registration-kit.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { isRecord } from "./records.js";
|
|
1
|
+
import { isNonArrayRecord, isRecord } from "./records.js";
|
|
2
2
|
export { isRecord, isNonArrayRecord } from "./records.js";
|
|
3
3
|
/**
|
|
4
4
|
* @file The cross-domain half of the agent-tool wiring split: everything a domain's own
|
|
@@ -106,7 +106,8 @@ export function indexCatalogById(required, _optional = {}) {
|
|
|
106
106
|
export function requireInputRecord(required, _optional = {}) {
|
|
107
107
|
const { input } = required;
|
|
108
108
|
const candidate = { value: input };
|
|
109
|
-
|
|
109
|
+
// Tool arguments follow an object schema; the general isRecord predicate also admits arrays.
|
|
110
|
+
if (!isNonArrayRecord(candidate))
|
|
110
111
|
throw new ToolInputError({ message: "input must be an object" });
|
|
111
112
|
return candidate.value;
|
|
112
113
|
}
|
|
@@ -299,14 +300,16 @@ export async function withSchemaOnRejection(spec, _optional = {}) {
|
|
|
299
300
|
*/
|
|
300
301
|
export function decorateWithSchema(params) {
|
|
301
302
|
const schema = params.catalog.get(params.toolId)?.inputSchema;
|
|
303
|
+
// Domain refusals may already be sentences; append guidance without doubling their punctuation.
|
|
304
|
+
const message = /[.!?]$/.test(params.message) ? params.message : `${params.message}.`;
|
|
302
305
|
// A `ToolInputError`, not a plain `Error`: every rejection reaching here already passed the
|
|
303
306
|
// caller's own `isShapeRejection` predicate — "a DIFFERENT input would fix this" — which is
|
|
304
307
|
// exactly what the marker means. `@jini-ai/daemon`'s `ToolExecutor` reads it off the thrown error
|
|
305
308
|
// to tag the execution result `errorKind: 'validation'` rather than folding it into the same
|
|
306
309
|
// redacted-500 bucket a genuine internal failure gets.
|
|
307
310
|
return new ToolInputError({ message: schema
|
|
308
|
-
? `${
|
|
309
|
-
: `${
|
|
311
|
+
? `${message} ${RETRY_IS_FUTILE} Schema for '${params.toolId}': ${JSON.stringify(schema)}`
|
|
312
|
+
: `${message} ${RETRY_IS_FUTILE}` });
|
|
310
313
|
}
|
|
311
314
|
// ---------------------------------------------------------------------------
|
|
312
315
|
// Build-time gates
|
|
@@ -41,8 +41,9 @@ function formatInZone({ iso, timeZone }, _options = {}) {
|
|
|
41
41
|
const parts = new Intl.DateTimeFormat("en-US", {
|
|
42
42
|
timeZone, year: "numeric", month: "2-digit", day: "2-digit", hour: "2-digit", minute: "2-digit", hourCycle: "h23",
|
|
43
43
|
}).formatToParts(date);
|
|
44
|
-
|
|
45
|
-
|
|
44
|
+
// This formatter requests all five numeric fields for a valid date in en-US.
|
|
45
|
+
const part = Object.fromEntries(parts.map(({ type, value }) => [type, value]));
|
|
46
|
+
return `${part.year}-${part.month}-${part.day} ${part.hour}:${part.minute}`;
|
|
46
47
|
}
|
|
47
48
|
/** Inject 'now' to keep relative-time display deterministic. The fallback wording uses simple
|
|
48
49
|
* English singular/plural templates; hosts can translate them, but this is not full locale pluralization. */
|
|
@@ -19,7 +19,7 @@ export const toolMetadata = {
|
|
|
19
19
|
"credential_save": {
|
|
20
20
|
search: {
|
|
21
21
|
keywords: "credential save connect add create new account api key token set update change rotate replace expired refresh secret human form " +
|
|
22
|
-
"image generation video media provider
|
|
22
|
+
"image generation video media provider repository backup git source control commits " +
|
|
23
23
|
"static publish hosting storage bucket registrar dns third-party " +
|
|
24
24
|
"plugin personal access token pat fallback",
|
|
25
25
|
queries: [
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
/** media-generation registration declarations; shared placement rationale is in the host aggregator.
|
|
1
|
+
/** media-generation registration declarations; shared placement rationale is in the host aggregator.
|
|
2
|
+
* Vocabulary stays vendor-neutral: named providers and models are the registering host's words. */
|
|
2
3
|
export declare const toolMetadata: {
|
|
3
4
|
readonly media_generate_asset: {
|
|
4
5
|
readonly search: {
|
|
5
|
-
readonly keywords: "image images generate generated generating create created ai art artwork draw drawing design logo banner illustration picture
|
|
6
|
+
readonly keywords: "image images generate generated generating create created ai art artwork draw drawing design logo banner illustration picture make making";
|
|
6
7
|
readonly queries: readonly ["Can you generate an image of a red bicycle for me?", "I need a logo — can you create one with AI?", "Generate a hero banner image for the homepage.", "Draw me an illustration of a mountain landscape.", "Can you make an AI image and add it to the media library?"];
|
|
7
8
|
};
|
|
8
9
|
readonly approval: {
|
|
@@ -12,8 +13,8 @@ export declare const toolMetadata: {
|
|
|
12
13
|
};
|
|
13
14
|
readonly media_list_providers: {
|
|
14
15
|
readonly search: {
|
|
15
|
-
readonly keywords: "image generation provider video generation which ai image provider configured set up api key
|
|
16
|
-
readonly queries: readonly ["Which image and video generation providers have a saved connection?", "Can you list the AI media vendors this site knows about?", "Is an
|
|
16
|
+
readonly keywords: "image generation provider video generation which ai image provider configured set up api key available list providers images videos";
|
|
17
|
+
readonly queries: readonly ["Which image and video generation providers have a saved connection?", "Can you list the AI media vendors this site knows about?", "Is an image provider credential configured?", "Which image providers still need their API key?"];
|
|
17
18
|
};
|
|
18
19
|
readonly approval: {
|
|
19
20
|
readonly class: "read";
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
/** media-generation registration declarations; shared placement rationale is in the host aggregator.
|
|
1
|
+
/** media-generation registration declarations; shared placement rationale is in the host aggregator.
|
|
2
|
+
* Vocabulary stays vendor-neutral: named providers and models are the registering host's words. */
|
|
2
3
|
export const toolMetadata = {
|
|
3
4
|
"media_generate_asset": {
|
|
4
5
|
search: {
|
|
5
|
-
keywords: "image images generate generated generating create created ai art artwork draw drawing design logo banner illustration picture
|
|
6
|
+
keywords: "image images generate generated generating create created ai art artwork draw drawing design logo banner illustration picture make making",
|
|
6
7
|
queries: [
|
|
7
8
|
"Can you generate an image of a red bicycle for me?",
|
|
8
9
|
"I need a logo — can you create one with AI?",
|
|
@@ -15,11 +16,11 @@ export const toolMetadata = {
|
|
|
15
16
|
},
|
|
16
17
|
"media_list_providers": {
|
|
17
18
|
search: {
|
|
18
|
-
keywords: "image generation provider video generation which ai image provider configured set up api key
|
|
19
|
+
keywords: "image generation provider video generation which ai image provider configured set up api key available list providers images videos",
|
|
19
20
|
queries: [
|
|
20
21
|
"Which image and video generation providers have a saved connection?",
|
|
21
22
|
"Can you list the AI media vendors this site knows about?",
|
|
22
|
-
"Is an
|
|
23
|
+
"Is an image provider credential configured?",
|
|
23
24
|
"Which image providers still need their API key?",
|
|
24
25
|
],
|
|
25
26
|
},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jini-ai/core",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.4",
|
|
4
4
|
"description": "The Jini kernel: typed DI tokens, pack composition and lifecycle, the tool registry, redaction, and origin/API-token auth primitives. Zero dependencies.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -301,7 +301,14 @@
|
|
|
301
301
|
"./contracts/site/post-revision-lock": "universal",
|
|
302
302
|
"./tool-metadata/media-video-conversion": "universal",
|
|
303
303
|
"./tool-metadata/routines": "universal",
|
|
304
|
-
"./contracts/site/site-serving-gate": "universal"
|
|
304
|
+
"./contracts/site/site-serving-gate": "universal",
|
|
305
|
+
"./tool-input-errors": "universal",
|
|
306
|
+
"./tool-permissions": "universal",
|
|
307
|
+
"./registration-kit": "universal",
|
|
308
|
+
"./host-read-vocabulary": "universal",
|
|
309
|
+
"./redaction": "universal",
|
|
310
|
+
"./origin-validation": "universal",
|
|
311
|
+
"./tool-exposure": "universal"
|
|
305
312
|
},
|
|
306
313
|
"isolation": {
|
|
307
314
|
"entries": {
|
|
@@ -316,7 +323,14 @@
|
|
|
316
323
|
"./contracts/site/post-revision-lock": "core",
|
|
317
324
|
"./tool-metadata/media-video-conversion": "core",
|
|
318
325
|
"./tool-metadata/routines": "core",
|
|
319
|
-
"./contracts/site/site-serving-gate": "core"
|
|
326
|
+
"./contracts/site/site-serving-gate": "core",
|
|
327
|
+
"./tool-input-errors": "core",
|
|
328
|
+
"./tool-permissions": "core",
|
|
329
|
+
"./registration-kit": "core",
|
|
330
|
+
"./host-read-vocabulary": "core",
|
|
331
|
+
"./redaction": "core",
|
|
332
|
+
"./origin-validation": "core",
|
|
333
|
+
"./tool-exposure": "core"
|
|
320
334
|
},
|
|
321
335
|
"domains": {
|
|
322
336
|
"fetch": [
|
|
@@ -1812,6 +1826,41 @@
|
|
|
1812
1826
|
"types": "./dist/contracts/site/site-serving-gate.d.ts",
|
|
1813
1827
|
"import": "./dist/contracts/site/site-serving-gate.js",
|
|
1814
1828
|
"default": "./dist/contracts/site/site-serving-gate.js"
|
|
1829
|
+
},
|
|
1830
|
+
"./tool-input-errors": {
|
|
1831
|
+
"types": "./dist/tool-input-errors.d.ts",
|
|
1832
|
+
"import": "./dist/tool-input-errors.js",
|
|
1833
|
+
"default": "./dist/tool-input-errors.js"
|
|
1834
|
+
},
|
|
1835
|
+
"./tool-permissions": {
|
|
1836
|
+
"types": "./dist/tool-permissions.d.ts",
|
|
1837
|
+
"import": "./dist/tool-permissions.js",
|
|
1838
|
+
"default": "./dist/tool-permissions.js"
|
|
1839
|
+
},
|
|
1840
|
+
"./registration-kit": {
|
|
1841
|
+
"types": "./dist/registration-kit.d.ts",
|
|
1842
|
+
"import": "./dist/registration-kit.js",
|
|
1843
|
+
"default": "./dist/registration-kit.js"
|
|
1844
|
+
},
|
|
1845
|
+
"./host-read-vocabulary": {
|
|
1846
|
+
"types": "./dist/host-read-vocabulary.d.ts",
|
|
1847
|
+
"import": "./dist/host-read-vocabulary.js",
|
|
1848
|
+
"default": "./dist/host-read-vocabulary.js"
|
|
1849
|
+
},
|
|
1850
|
+
"./redaction": {
|
|
1851
|
+
"types": "./dist/redaction.d.ts",
|
|
1852
|
+
"import": "./dist/redaction.js",
|
|
1853
|
+
"default": "./dist/redaction.js"
|
|
1854
|
+
},
|
|
1855
|
+
"./origin-validation": {
|
|
1856
|
+
"types": "./dist/origin-validation.d.ts",
|
|
1857
|
+
"import": "./dist/origin-validation.js",
|
|
1858
|
+
"default": "./dist/origin-validation.js"
|
|
1859
|
+
},
|
|
1860
|
+
"./tool-exposure": {
|
|
1861
|
+
"types": "./dist/tool-exposure.d.ts",
|
|
1862
|
+
"import": "./dist/tool-exposure.js",
|
|
1863
|
+
"default": "./dist/tool-exposure.js"
|
|
1815
1864
|
}
|
|
1816
1865
|
},
|
|
1817
1866
|
"files": [
|