@jini-ai/integrations 0.6.19 → 0.7.1

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.
Files changed (67) hide show
  1. package/CHANGELOG.md +48 -0
  2. package/dist/api-connections/access-token.js +4 -14
  3. package/dist/api-connections/account-actions.d.ts +6 -1
  4. package/dist/api-connections/attempt-state.d.ts +2 -2
  5. package/dist/api-connections/attempt-state.js +10 -11
  6. package/dist/api-connections/authorization.js +13 -20
  7. package/dist/api-connections/budgets.d.ts +91 -0
  8. package/dist/api-connections/budgets.js +87 -0
  9. package/dist/api-connections/byo-client.d.ts +38 -0
  10. package/dist/api-connections/byo-client.js +28 -0
  11. package/dist/api-connections/connect.d.ts +87 -0
  12. package/dist/api-connections/connect.js +143 -0
  13. package/dist/api-connections/declarations.d.ts +68 -0
  14. package/dist/api-connections/declarations.js +178 -0
  15. package/dist/api-connections/deps.d.ts +4 -1
  16. package/dist/api-connections/descriptor.d.ts +15 -0
  17. package/dist/api-connections/descriptor.js +1 -5
  18. package/dist/api-connections/finish-authorization.d.ts +1 -1
  19. package/dist/api-connections/hook-http.d.ts +20 -0
  20. package/dist/api-connections/hook-http.js +27 -0
  21. package/dist/api-connections/host-ports.d.ts +244 -0
  22. package/dist/api-connections/host-ports.js +2 -0
  23. package/dist/api-connections/host.d.ts +81 -0
  24. package/dist/api-connections/host.js +320 -0
  25. package/dist/api-connections/hosted-mcp/contracts.d.ts +291 -0
  26. package/dist/api-connections/hosted-mcp/contracts.js +2 -0
  27. package/dist/api-connections/hosted-mcp/index.d.ts +5 -0
  28. package/dist/api-connections/hosted-mcp/index.js +3 -0
  29. package/dist/api-connections/hosted-mcp/shared-sign-in.d.ts +167 -0
  30. package/dist/api-connections/hosted-mcp/shared-sign-in.js +293 -0
  31. package/dist/api-connections/hosted-mcp/sign-in.d.ts +25 -0
  32. package/dist/api-connections/hosted-mcp/sign-in.js +889 -0
  33. package/dist/api-connections/hosted-sign-in.d.ts +48 -0
  34. package/dist/api-connections/hosted-sign-in.js +51 -0
  35. package/dist/api-connections/index.d.ts +23 -1
  36. package/dist/api-connections/index.js +15 -0
  37. package/dist/api-connections/install-credential.d.ts +1 -1
  38. package/dist/api-connections/oauth-capabilities.d.ts +63 -0
  39. package/dist/api-connections/oauth-capabilities.js +2 -0
  40. package/dist/api-connections/ports.d.ts +1 -1
  41. package/dist/api-connections/request-checks.d.ts +11 -1
  42. package/dist/api-connections/request-checks.js +2 -3
  43. package/dist/api-connections/shared.d.ts +79 -0
  44. package/dist/api-connections/shared.js +106 -0
  45. package/dist/api-connections/token-store/record.d.ts +2 -2
  46. package/dist/api-connections/token-store/vault-token-store.d.ts +30 -4
  47. package/dist/api-connections/token-store/vault-token-store.js +1 -4
  48. package/dist/credentialed-http/sets/host.d.ts +146 -0
  49. package/dist/credentialed-http/sets/host.js +2 -0
  50. package/dist/credentialed-http/sets/index.d.ts +24 -0
  51. package/dist/credentialed-http/sets/index.js +24 -0
  52. package/dist/credentialed-http/sets/store.d.ts +193 -0
  53. package/dist/credentialed-http/sets/store.js +489 -0
  54. package/dist/credentialed-http/sets/vault-repo.d.ts +81 -0
  55. package/dist/credentialed-http/sets/vault-repo.js +147 -0
  56. package/dist/credentialed-http/tools/credential-copy-tool.d.ts +34 -0
  57. package/dist/credentialed-http/tools/credential-copy-tool.js +132 -0
  58. package/dist/credentialed-http/tools/credential-tool-host.d.ts +152 -0
  59. package/dist/credentialed-http/tools/credential-tool-host.js +2 -0
  60. package/dist/credentialed-http/tools/credential-tool-operations.d.ts +370 -0
  61. package/dist/credentialed-http/tools/credential-tool-operations.js +2 -0
  62. package/dist/credentialed-http/tools/index.d.ts +7 -0
  63. package/dist/credentialed-http/tools/index.js +4 -0
  64. package/dist/credentialed-http/tools/tool-registrations.d.ts +55 -0
  65. package/dist/credentialed-http/tools/tool-registrations.js +729 -0
  66. package/dist/webhooks/signing.js +2 -1
  67. package/package.json +34 -11
@@ -0,0 +1,147 @@
1
+ /**
2
+ * @file Credential-set repository over a host-supplied vault. Owner, metadata parser, label order
3
+ * and canonical errors are required host inputs (`CredentialSetVaultPolicy`); nothing here names a
4
+ * product owner. Rows keep their stored kind, so legacy envelopes keep authenticating.
5
+ * Provenance: moved unchanged (EXTRACT-S8 C1 move) from the first host's credential-set seam file
6
+ * `sets/vault-repo.ts` at its commit 43a0e5d4; earlier history lives in that host's repository.
7
+ */
8
+ /** @agent-note Exact expected vault context for a credential-set row: the trusted host owner, null
9
+ * principal and binding. `kind` defaults to the unified `vendor` kind; pass `custom` only for a
10
+ * legacy row being read or rewritten under its own stored kind. */
11
+ export function credentialSetVaultScope({ workspaceId, id, kind = "vendor", ownerKey }, _options = {}) {
12
+ return { workspaceId, kind, ownerKey, principalId: null, binding: null,
13
+ ...(id === undefined ? {} : { id }) };
14
+ }
15
+ function isCustomCredentialRow({ row }, _options = {}) {
16
+ return row.kind === "custom" || (row.kind === "vendor" && row.meta.credentialType === "custom");
17
+ }
18
+ /**
19
+ * @agent-note Converts one vault row into a credential-set record, rejecting any row outside the
20
+ * trusted ownership with the canonical `context` error and a row without an envelope with
21
+ * `invalid-record`. Username belongs exclusively to metadata after normalization; no sealed fallback
22
+ * can resurrect an explicit clear. The private envelope/revision are attached non-enumerable and
23
+ * never become a public summary field.
24
+ */
25
+ export function credentialSetVaultRecord({ row, expectedRevision, policy }, _options = {}) {
26
+ const wrongOwner = !isCustomCredentialRow({ row }) || row.ownerKey !== policy.ownerKey;
27
+ if (wrongOwner || row.principalId !== null || row.binding !== null || row.provider !== null) {
28
+ throw policy.vaultErrors.create({ code: "context" });
29
+ }
30
+ const meta = policy.parseMeta({ kind: row.kind, meta: row.meta, provider: row.provider });
31
+ if (!row.sealed)
32
+ throw policy.vaultErrors.create({ code: "invalid-record" });
33
+ const record = { workspaceId: row.workspaceId, id: row.id, label: row.label,
34
+ category: meta.category, baseUrl: meta.baseUrl,
35
+ worksFor: meta.worksFor, additionalHosts: meta.additionalHosts, ...(meta.username == null ? {} : { username: meta.username }),
36
+ sealed: row.sealed, createdAt: row.createdAt, updatedAt: row.updatedAt };
37
+ Object.defineProperty(record, "vaultRecord", { value: { ...row, meta } });
38
+ if (expectedRevision !== undefined)
39
+ Object.defineProperty(record, "vaultExpectedRevision", { value: expectedRevision });
40
+ return record;
41
+ }
42
+ /**
43
+ * @agent-note Fixed owner/provider scope keeps labels unique across the workspace in both adapters.
44
+ * Every write is one CAS `put`/`delete` on the SAME `vault` passed in (`repo.vault === vault`); no
45
+ * write path opens a sealed envelope. `findRowByLabel`, when supplied, must be the vault's own
46
+ * indexed, authorization-preserving lookup.
47
+ */
48
+ export class CredentialSetVaultRepo {
49
+ vault;
50
+ project;
51
+ findByLabel;
52
+ /** @param optional.project The project store this site's rows fall back to. */
53
+ constructor({ vault, policy }, optional = {}) {
54
+ this.vault = vault;
55
+ Object.defineProperty(this, "policy", { value: policy });
56
+ const findRowByLabel = optional.findRowByLabel;
57
+ if (findRowByLabel)
58
+ this.findByLabel = async (input) => {
59
+ const row = await findRowByLabel(input);
60
+ return row && isCustomCredentialRow({ row }) ? credentialSetVaultRecord({ row, policy }) : null;
61
+ };
62
+ if (optional.project)
63
+ this.project = optional.project;
64
+ }
65
+ async findById(input) {
66
+ const row = await this.vault.find(input);
67
+ if (!row || !isCustomCredentialRow({ row }))
68
+ return null;
69
+ return credentialSetVaultRecord({ row, policy: this.policy });
70
+ }
71
+ async listByWorkspace(input) {
72
+ const ownerKey = this.policy.ownerKey;
73
+ // Label order, as before the vault (the label index drove the scan); the vault lists by id.
74
+ const unified = await this.vault.list(credentialSetVaultScope({ ...input, ownerKey }));
75
+ // This is a read bridge, not a kind rewrite: the stored kind still authenticates old envelopes.
76
+ const legacy = await this.vault.list(credentialSetVaultScope({ ...input, kind: "custom", ownerKey }));
77
+ return [...unified.filter(row => row.meta.credentialType === "custom"), ...legacy].sort((a, b) => this.policy.compareLabels(a, b))
78
+ .map(row => credentialSetVaultRecord({ row, policy: this.policy }));
79
+ }
80
+ async insert(record) { await this.write({ record, expectedRevision: null }); }
81
+ async update(record) {
82
+ if (record.vaultExpectedRevision !== undefined) {
83
+ await this.write({ record, expectedRevision: record.vaultExpectedRevision });
84
+ return;
85
+ }
86
+ const existing = await this.findById(record);
87
+ if (!existing)
88
+ return;
89
+ await this.write({ record, expectedRevision: existing.vaultRecord.revision,
90
+ existing: existing.vaultRecord });
91
+ }
92
+ /** Prepared records carry the caller's CAS; sealed DTO compatibility preserves hints only when
93
+ * the envelope is unchanged. Label conflicts keep the host's historical raw UNIQUE error contract.
94
+ */
95
+ async write({ record, expectedRevision, existing }, _options = {}) {
96
+ const policy = this.policy;
97
+ const prepared = preparedVaultRow({ record, policy });
98
+ const row = prepared ?? compatibilityVaultRow({ record, expectedRevision, policy, ...(existing ? { existing } : {}) });
99
+ try {
100
+ await this.vault.put({ record: row, expectedRevision });
101
+ }
102
+ catch (error) {
103
+ if (policy.vaultErrors.codeOf(error) === "conflict" && (await this.listByWorkspace(record)).some(other => other.id !== record.id && other.label === record.label)) {
104
+ throw policy.labelConflict({});
105
+ }
106
+ throw error;
107
+ }
108
+ }
109
+ async delete(input) {
110
+ const row = await this.findById(input);
111
+ if (row)
112
+ await this.vault.delete({ ...input, expectedRevision: row.vaultRecord.revision });
113
+ }
114
+ }
115
+ function compatibilityVaultRow({ record, expectedRevision, existing, policy }, _options = {}) {
116
+ const kind = existing?.kind === "custom" ? "custom" : "vendor";
117
+ return { ...credentialSetVaultScope({ ...record, kind, ownerKey: policy.ownerKey }), id: record.id, provider: null, label: record.label,
118
+ sealed: record.sealed, isDefault: existing?.isDefault ?? false, revision: (expectedRevision ?? 0) + 1,
119
+ ...compatibilityTokenHints({ record, ...(existing ? { existing } : {}) }),
120
+ meta: compatibilityVaultMeta({ record, kind, policy, ...(existing ? { existing } : {}) }),
121
+ createdAt: existing?.createdAt ?? record.createdAt, updatedAt: record.updatedAt };
122
+ }
123
+ function compatibilityVaultMeta({ record, existing, kind, policy }, _options = {}) {
124
+ return policy.parseMeta({ kind, meta: { ...existing?.meta, credentialType: "custom",
125
+ worksFor: [...(record.worksFor ?? existing?.meta.worksFor ?? [])],
126
+ category: record.category, baseUrl: record.baseUrl,
127
+ additionalHosts: [...record.additionalHosts], username: record.username ?? null } });
128
+ }
129
+ function compatibilityTokenHints({ record, existing }, _options = {}) {
130
+ const sealed = existing?.sealed;
131
+ let unchanged = false;
132
+ if (sealed != null) {
133
+ const sameContent = sealed.keyId === record.sealed.keyId && sealed.ciphertext === record.sealed.ciphertext;
134
+ unchanged = sameContent && sealed.nonce === record.sealed.nonce && sealed.alg === record.sealed.alg;
135
+ }
136
+ return { last4: unchanged ? existing.last4 : null, tokenLength: unchanged ? existing.tokenLength : null };
137
+ }
138
+ function preparedVaultRow({ record, policy }, _options = {}) {
139
+ const prepared = record.vaultExpectedRevision === undefined ? undefined : record.vaultRecord;
140
+ if (prepared) {
141
+ credentialSetVaultRecord({ row: prepared, policy });
142
+ if (prepared.workspaceId !== record.workspaceId || prepared.id !== record.id)
143
+ throw policy.vaultErrors.create({ code: "context" });
144
+ }
145
+ return prepared;
146
+ }
147
+ //# sourceMappingURL=vault-repo.js.map
@@ -0,0 +1,34 @@
1
+ import type { LegacyToolAuthorizeFn, ToolHandler, SurfaceExchangeStore, ToolRegistration } from "@jini-ai/core";
2
+ import type { InstanceAuthorizeFn } from "@jini-ai/core/gated-mutations";
3
+ import type { CredentialCopyProjectKeysPort, CredentialCopyToolHost } from "./credential-tool-host.js";
4
+ /**
5
+ * What the saved-key card needs from its host, besides the host inputs.
6
+ */
7
+ /** @agent-note ownerPrincipalId must identify the trusted installation owner before its inventory is opened. */
8
+ export interface CredentialCopyRequired {
9
+ readonly workspaceId: string;
10
+ readonly ownerPrincipalId: Promise<string>;
11
+ readonly authorize: LegacyToolAuthorizeFn;
12
+ readonly gatedMutations: {
13
+ gatewayDeps: {
14
+ authorizeInstance?: InstanceAuthorizeFn;
15
+ };
16
+ };
17
+ readonly projectKeys?: CredentialCopyProjectKeysPort;
18
+ }
19
+ /** One human card selects and approves a CMS site grant. Jini owns actor binding, expiry and replay
20
+ * protection. The site is captured by the project-keys port at host composition, never by submitted input.
21
+ * @returns Only the approved reference, or a cancellation result; no owner inventory reaches chat.
22
+ * @complexity O(k) card metadata, k capped by the owner inventory; one grant transaction per approval.
23
+ */
24
+ /** @agent-note The catalog must accept no model input, because key selection happens only inside the held human card. */
25
+ export declare function createCredentialCopyRegistrations({ deps, surfaces, host }: {
26
+ deps: CredentialCopyRequired;
27
+ surfaces: {
28
+ readonly surfaceExchanges: SurfaceExchangeStore;
29
+ };
30
+ host: CredentialCopyToolHost;
31
+ }, { saveNew }?: {
32
+ saveNew?: ToolHandler;
33
+ }): ToolRegistration[];
34
+ //# sourceMappingURL=credential-copy-tool.d.ts.map
@@ -0,0 +1,132 @@
1
+ import { adaptLegacyAuthorize, requireToolPermission, ToolInputError, SURFACE_EXCHANGE_ID_PARAM, buildDomainRegistrations, indexCatalogById, SURFACE_DISMISSED_PARAM } from "@jini-ai/core";
2
+ /** Require the installation owner's current permissions before inventory and again before grant.
3
+ * @throws ToolInputError for non-owner sessions; RBAC errors propagate without secrets.
4
+ * @complexity O(1), two admission calls per card/open or submission.
5
+ */
6
+ async function admit({ deps, host, principalId, permission = host.vocabulary.ownerPermission }) {
7
+ const owner = host.vocabulary.ownerPermission;
8
+ if (principalId !== await deps.ownerPrincipalId)
9
+ throw new ToolInputError({ message: host.messages.ownerOnly });
10
+ await requireToolPermission({ authorize: adaptLegacyAuthorize({ authorize: deps.authorize }), workspaceId: deps.workspaceId, principalId, permission: owner });
11
+ if (permission !== owner)
12
+ await requireToolPermission({ authorize: adaptLegacyAuthorize({ authorize: deps.authorize }), workspaceId: deps.workspaceId, principalId, permission });
13
+ const instance = deps.gatedMutations.gatewayDeps.authorizeInstance;
14
+ if (instance && !(await instance({ principalId, permission })).allowed) {
15
+ throw new ToolInputError({ message: host.messages.instanceRefused });
16
+ }
17
+ }
18
+ /** Only an offered id can be approved; submitted site ids or other fields cannot widen the grant. */
19
+ function selectedKey({ params, rows, host }) {
20
+ if (Object.keys(params).some(key => !['credentialId', SURFACE_EXCHANGE_ID_PARAM].includes(key))) {
21
+ throw new ToolInputError({ message: host.messages.unexpectedField });
22
+ }
23
+ if (params.credentialId === host.vocabulary.newKeyValue)
24
+ return 'new';
25
+ const row = rows.find(row => row.keyId === params.credentialId);
26
+ if (!row)
27
+ throw new ToolInputError({ message: host.messages.notOffered });
28
+ return row;
29
+ }
30
+ /** Selection and secrets come only from the human card, never model arguments. */
31
+ function validateInput({ input, host }) {
32
+ if (!input || typeof input !== 'object' || Array.isArray(input) || Object.keys(input).length) {
33
+ throw new ToolInputError({ message: host.messages.inputNotEmpty });
34
+ }
35
+ }
36
+ /** Each declined outcome carries a reason code the model can act on, with the host's words. */
37
+ function declined({ reason, host }) {
38
+ const { outcomes } = host.messages;
39
+ const message = reason === 'dismissed' ? outcomes.dismissed : reason === 'interrupted' ? outcomes.interrupted : outcomes.nothingToPick;
40
+ return { granted: false, reason, message };
41
+ }
42
+ /** Locked keys are named on the card with what to do, grouped by reason; they are never selectable.
43
+ * @complexity O(k) over the offered rows. */
44
+ function lockedDetails({ rows, host }) {
45
+ const byReason = new Map();
46
+ for (const row of rows)
47
+ if (row.locked)
48
+ byReason.set(row.locked, [...(byReason.get(row.locked) ?? []), row.name]);
49
+ return [...byReason].map(([reason, names]) => ({ label: host.messages.lockedLabel({ names }), value: reason }));
50
+ }
51
+ /** The fallback uses the normal secret card and the same successful-save attachment owner. */
52
+ async function normalKeyCard({ ctx, options, deps, host, saveNew }) {
53
+ const result = await saveNew({ ...ctx, input: {} }, options);
54
+ ctx.signal.throwIfAborted();
55
+ await admit({ deps, host, principalId: ctx.principal.id });
56
+ return deps.projectKeys ? deps.projectKeys.savedResult({ result }) : result;
57
+ }
58
+ /** One human card selects and approves a CMS site grant. Jini owns actor binding, expiry and replay
59
+ * protection. The site is captured by the project-keys port at host composition, never by submitted input.
60
+ * @returns Only the approved reference, or a cancellation result; no owner inventory reaches chat.
61
+ * @complexity O(k) card metadata, k capped by the owner inventory; one grant transaction per approval.
62
+ */
63
+ /** @agent-note The catalog must accept no model input, because key selection happens only inside the held human card. */
64
+ export function createCredentialCopyRegistrations({ deps, surfaces, host }, { saveNew } = {}) {
65
+ const { toolId } = host.vocabulary;
66
+ return buildDomainRegistrations({ metadata: host.metadata, domain: host.vocabulary.domain,
67
+ catalogModule: host.vocabulary.catalogModule, catalog: indexCatalogById({ catalog: host.catalog }),
68
+ derivedRisk: host.derivedRisk, handlers: { [toolId]: async (ctx, options = {}) => {
69
+ validateInput({ input: ctx.input, host });
70
+ await admit({ deps, host, principalId: ctx.principal.id });
71
+ ctx.signal.throwIfAborted();
72
+ const projectKeys = deps.projectKeys;
73
+ if (!projectKeys) {
74
+ if (saveNew)
75
+ return normalKeyCard({ ctx, options, deps, host, saveNew });
76
+ throw new ToolInputError({ message: host.messages.keysUnavailable });
77
+ }
78
+ if (!options.emitSurface)
79
+ throw new ToolInputError({ message: host.messages.needsInteractive });
80
+ const rows = await projectKeys.listChoices({});
81
+ const exchange = surfaces.surfaceExchanges.open({ binding: { toolId, principalId: ctx.principal.id, channel: 'mcp-ui' }, emit: options.emitSurface });
82
+ const uri = `ui://${host.cardIdentity.uriNamespace}/${host.vocabulary.cardPath}/${exchange.id}`;
83
+ const abort = () => exchange.close({});
84
+ ctx.signal.addEventListener('abort', abort, { once: true });
85
+ if (ctx.signal.aborted)
86
+ abort();
87
+ try {
88
+ const { messages } = host;
89
+ const available = rows.filter(row => !row.locked);
90
+ const result = await host.protocol.askThenReport({ exchange,
91
+ confirmationEmission: { channel: 'mcp-ui', payload: { resource: host.protocol.buildFormSurface({ uri,
92
+ title: messages.cardTitle, details: [{ label: messages.siteLabel, value: projectKeys.site?.name ?? messages.siteFallback }, ...lockedDetails({ rows, host })],
93
+ // A site key is added to Shared Keys on approval; the host's description says so, the owner is approving it.
94
+ description: available.length ? messages.cardDescription : messages.emptyCardDescription,
95
+ fields: [{ kind: 'enum', name: 'credentialId', label: messages.fieldLabel, required: true, placeholder: messages.fieldPlaceholder,
96
+ options: [...available.map(row => ({ value: row.keyId, label: row.name })), { value: host.vocabulary.newKeyValue, label: messages.newKeyLabel }] }],
97
+ // Keys and OAuth accounts stay in the owner store; shared OAuth keeps its original sign-in account and client.
98
+ // The label fits both a saved key and Enter a new key, which goes on to the normal key card.
99
+ // Start compact; Jini's shared bridge fits the body on load and content changes.
100
+ preferredFrameSize: ['100%', '1px'],
101
+ submitLabel: messages.submitLabel, toolName: toolId,
102
+ baseParams: { [SURFACE_EXCHANGE_ID_PARAM]: exchange.id },
103
+ cancel: { label: messages.cancelLabel, toolName: toolId, params: { [SURFACE_EXCHANGE_ID_PARAM]: exchange.id, [SURFACE_DISMISSED_PARAM]: true } },
104
+ }) } },
105
+ handle: async (answer) => {
106
+ if (answer.status !== 'received' || ctx.signal.aborted)
107
+ return { result: declined({ reason: 'interrupted', host }) };
108
+ if (answer.params[SURFACE_DISMISSED_PARAM] === true)
109
+ return { result: declined({ reason: available.length ? 'dismissed' : 'nothing-to-pick', host }) };
110
+ const row = selectedKey({ params: answer.params, rows: available, host });
111
+ if (row === 'new') {
112
+ await admit({ deps, host, principalId: ctx.principal.id });
113
+ return { result: { granted: false, newKey: true } };
114
+ }
115
+ await admit({ deps, host, principalId: ctx.principal.id, permission: await projectKeys.permissionFor({ keyId: row.keyId }) });
116
+ ctx.signal.throwIfAborted();
117
+ // Re-resolution inside use refuses entries deleted while the person was reading the card.
118
+ // A key picked from another site gets its Shared Keys id here; that id is what the model receives.
119
+ const used = await projectKeys.use({ keyId: row.keyId, use: true });
120
+ return { result: { granted: true, credentialId: used.keyId } };
121
+ } });
122
+ if (result.newKey && saveNew)
123
+ return normalKeyCard({ ctx, options, deps, host, saveNew });
124
+ return result;
125
+ }
126
+ finally {
127
+ ctx.signal.removeEventListener('abort', abort);
128
+ exchange.close({});
129
+ }
130
+ } } });
131
+ }
132
+ //# sourceMappingURL=credential-copy-tool.js.map
@@ -0,0 +1,152 @@
1
+ /**
2
+ * @file Host inputs the credential tools need: vocabulary, card identity and card helpers.
3
+ *
4
+ * Types only. These are the contracts a second host fulfils when it wires the custom-credential
5
+ * and saved-key tools; the host binds its values beside each old entry. Nothing here has a
6
+ * default: every permission, id, path, namespace, app and sentence is supplied by the host.
7
+ */
8
+ import type { AgentToolDefinition, DerivedRiskByToolId, SurfaceAskThenReport, ToolMetadataById } from '@jini-ai/core';
9
+ import type { SurfaceCardApp, SurfaceCardFormSpec, SurfaceCardsPort } from '@jini-ai/core/contracts/cards';
10
+ import type { CredentialedRequestPort, SourceControlWritePort } from '@jini-ai/core/contracts/credentials';
11
+ /**
12
+ * Who the cards belong to.
13
+ *
14
+ */
15
+ /** @agent-note Keep the URI namespace stable between opening and answering a card, because a namespace change rejects its answer. */
16
+ export interface CredentialCardIdentity {
17
+ readonly uriNamespace: string;
18
+ readonly appNames: {
19
+ readonly create: SurfaceCardApp;
20
+ readonly createOutcome: SurfaceCardApp;
21
+ readonly setToken: SurfaceCardApp;
22
+ readonly setTokenOutcome: SurfaceCardApp;
23
+ };
24
+ }
25
+ /**
26
+ * The registration vocabulary of the custom-credential tools.
27
+ *
28
+ */
29
+ /** @agent-note Read permission gates list and verify, write permission gates requests and edits, and catalog names must match operations.ids and reviewed metadata. */
30
+ export interface CustomCredentialToolVocabulary {
31
+ readonly domain: string;
32
+ readonly entityType: string;
33
+ readonly permissions: {
34
+ readonly read: string;
35
+ readonly write: string;
36
+ };
37
+ readonly catalogModule: string;
38
+ readonly metadata: ToolMetadataById;
39
+ /** @agent-note Catalog schemas use no input for list, label for verify, label/username for username edits, label/method/url/headers/body for requests, and label/owner/repo/branch/commitMessage/files for file writes. */
40
+ readonly catalog: ReadonlyMap<string, AgentToolDefinition>;
41
+ }
42
+ /** Everything a host supplies to `createCredentialToolRegistrations`/`createCredentialSaveHandlers`.
43
+ */
44
+ export interface CustomCredentialToolHost {
45
+ readonly vocabulary: CustomCredentialToolVocabulary;
46
+ readonly cardIdentity: CredentialCardIdentity;
47
+ }
48
+ /**
49
+ * The secret-card functions the API credential save handlers open their key cards with.
50
+ */
51
+ /** @agent-note Use the SAME answer-route exchange store and replace the form URI with its outcome only after persistence completes. */
52
+ export interface CustomCredentialSecretCards {
53
+ readonly defineSecretCardTool: SurfaceCardsPort["defineSecretCardTool"];
54
+ readonly askThenReport: SurfaceAskThenReport;
55
+ }
56
+ /**
57
+ * The two credential ports `createCredentialToolRegistrations` calls instead of reaching for
58
+ * host request or provider functions itself.
59
+ *
60
+ */
61
+ /** @agent-note resolveTarget never decrypts and runs before a dialog; file writes build once from saved metadata, validate before decrypting, and commit once on the SAME provider object with the EXACT plan, while Aborted → no commit. */
62
+ export interface CustomCredentialToolPorts {
63
+ readonly credentialedRequest: CredentialedRequestPort;
64
+ readonly sourceControlWrite: SourceControlWritePort;
65
+ }
66
+ /**
67
+ * The project-key operations the saved-key card uses. Captured by the host for one site.
68
+ *
69
+ */
70
+ /** @agent-note Offer only the human inventory returned by listChoices, recheck the chosen key permission after the answer, and re-resolve a revoked or deleted key before use. */
71
+ export interface CredentialCopyProjectKeysPort {
72
+ readonly site?: {
73
+ readonly name: string;
74
+ };
75
+ /** Every key the owner may pick, including keys saved on other sites; `locked` (plain words: why and what to do) rows are shown but never selectable. */
76
+ listChoices(required: Record<string, never>, optional?: Record<string, never>): Promise<readonly {
77
+ readonly keyId: string;
78
+ readonly name: string;
79
+ readonly locked?: string;
80
+ }[]>;
81
+ permissionFor(required: {
82
+ keyId: string;
83
+ }, optional?: Record<string, never>): Promise<string>;
84
+ /** Returns the id the site now uses: a key picked from another site gets a new shared id, and that id is what the model receives. */
85
+ use(required: {
86
+ keyId: string;
87
+ use: boolean;
88
+ }, optional?: Record<string, never>): Promise<{
89
+ readonly keyId: string;
90
+ }>;
91
+ savedResult(required: {
92
+ result: unknown;
93
+ }, optional?: Record<string, never>): Promise<unknown>;
94
+ }
95
+ /** The saved-key card's words. Host text: no generic fallback exists.
96
+ */
97
+ /** @agent-note Messages may name rejected input keys but must never reflect submitted secret values. */
98
+ export interface CredentialCopyMessages {
99
+ readonly ownerOnly: string;
100
+ readonly instanceRefused: string;
101
+ readonly unexpectedField: string;
102
+ readonly notOffered: string;
103
+ readonly inputNotEmpty: string;
104
+ readonly keysUnavailable: string;
105
+ readonly needsInteractive: string;
106
+ readonly cardTitle: string;
107
+ readonly siteLabel: string;
108
+ readonly siteFallback: string;
109
+ readonly cardDescription: string;
110
+ /** Shown instead of `cardDescription` when no key can be picked. */
111
+ readonly emptyCardDescription: string;
112
+ /** Detail label naming the locked keys that share one reason; the reason is the detail value. */
113
+ readonly lockedLabel: (required: {
114
+ names: readonly string[];
115
+ }) => string;
116
+ /** Model-facing text for each `{granted:false, reason}` outcome. */
117
+ readonly outcomes: {
118
+ readonly dismissed: string;
119
+ readonly interrupted: string;
120
+ readonly nothingToPick: string;
121
+ };
122
+ readonly fieldLabel: string;
123
+ readonly fieldPlaceholder: string;
124
+ readonly newKeyLabel: string;
125
+ readonly submitLabel: string;
126
+ readonly cancelLabel: string;
127
+ }
128
+ /**
129
+ * Everything a host supplies to `createCredentialCopyRegistrations`.
130
+ *
131
+ */
132
+ /** @agent-note newKeyValue must not be a possible key id, and its protocol must use the SAME actor-bound exchange store as the answer route. */
133
+ export interface CredentialCopyToolHost<Resource = unknown> {
134
+ readonly vocabulary: {
135
+ readonly toolId: string;
136
+ readonly domain: string;
137
+ readonly catalogModule: string;
138
+ readonly ownerPermission: string;
139
+ readonly newKeyValue: string;
140
+ readonly cardPath: string;
141
+ };
142
+ readonly cardIdentity: Pick<CredentialCardIdentity, 'uriNamespace'>;
143
+ readonly catalog: readonly AgentToolDefinition[];
144
+ readonly metadata: ToolMetadataById;
145
+ readonly derivedRisk: DerivedRiskByToolId;
146
+ readonly messages: CredentialCopyMessages;
147
+ readonly protocol: {
148
+ readonly askThenReport: SurfaceAskThenReport;
149
+ readonly buildFormSurface: (spec: SurfaceCardFormSpec) => Resource;
150
+ };
151
+ }
152
+ //# sourceMappingURL=credential-tool-host.d.ts.map
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=credential-tool-host.js.map