@jini-ai/integrations 0.7.2 → 0.7.3-next.2

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 (143) hide show
  1. package/CHANGELOG.md +2 -2
  2. package/README.md +1 -0
  3. package/dist/api-connections/access-token.js +4 -4
  4. package/dist/api-connections/account-actions.d.ts +10 -4
  5. package/dist/api-connections/account-actions.js +13 -13
  6. package/dist/api-connections/attempt-state.d.ts +11 -5
  7. package/dist/api-connections/attempt-state.js +4 -4
  8. package/dist/api-connections/authorization.d.ts +7 -3
  9. package/dist/api-connections/authorization.js +18 -18
  10. package/dist/api-connections/finish-authorization.d.ts +8 -4
  11. package/dist/api-connections/finish-authorization.js +9 -9
  12. package/dist/api-connections/host.d.ts +30 -32
  13. package/dist/api-connections/host.js +232 -205
  14. package/dist/api-connections/hosted-mcp/contracts.d.ts +1 -1
  15. package/dist/api-connections/hosted-mcp/oauth-row-writes.d.ts +50 -0
  16. package/dist/api-connections/hosted-mcp/oauth-row-writes.js +38 -0
  17. package/dist/api-connections/hosted-mcp/shared-sign-in.d.ts +40 -40
  18. package/dist/api-connections/hosted-mcp/shared-sign-in.js +98 -22
  19. package/dist/api-connections/hosted-mcp/sign-in-configuration.d.ts +29 -0
  20. package/dist/api-connections/hosted-mcp/sign-in-configuration.js +127 -0
  21. package/dist/api-connections/hosted-mcp/sign-in-discovery.d.ts +72 -0
  22. package/dist/api-connections/hosted-mcp/sign-in-discovery.js +131 -0
  23. package/dist/api-connections/hosted-mcp/sign-in-flow.d.ts +42 -0
  24. package/dist/api-connections/hosted-mcp/sign-in-flow.js +50 -0
  25. package/dist/api-connections/hosted-mcp/sign-in-provider.d.ts +103 -0
  26. package/dist/api-connections/hosted-mcp/sign-in-provider.js +142 -0
  27. package/dist/api-connections/hosted-mcp/sign-in-status.d.ts +19 -0
  28. package/dist/api-connections/hosted-mcp/sign-in-status.js +143 -0
  29. package/dist/api-connections/hosted-mcp/sign-in.d.ts +2 -9
  30. package/dist/api-connections/hosted-mcp/sign-in.js +219 -770
  31. package/dist/api-connections/index.js +1 -1
  32. package/dist/api-connections/install-credential.d.ts +4 -2
  33. package/dist/api-connections/install-credential.js +7 -7
  34. package/dist/api-connections/records.d.ts +17 -5
  35. package/dist/api-connections/records.js +5 -5
  36. package/dist/api-connections/request-checks.d.ts +29 -9
  37. package/dist/api-connections/request-checks.js +13 -13
  38. package/dist/api-connections/service.d.ts +1 -1
  39. package/dist/api-connections/service.js +6 -6
  40. package/dist/api-connections/status.d.ts +3 -1
  41. package/dist/api-connections/status.js +3 -3
  42. package/dist/api-connections/token-store/errors.d.ts +3 -1
  43. package/dist/api-connections/token-store/errors.js +1 -1
  44. package/dist/api-connections/token-store/vault-token-store.js +186 -173
  45. package/dist/args.d.ts +4 -1
  46. package/dist/args.js +1 -1
  47. package/dist/credentialed-http/credentialed-request.d.ts +5 -5
  48. package/dist/credentialed-http/credentialed-request.js +8 -8
  49. package/dist/credentialed-http/response-redaction.d.ts +18 -4
  50. package/dist/credentialed-http/response-redaction.js +7 -7
  51. package/dist/credentialed-http/sets/vault-repo.js +5 -1
  52. package/dist/credentialed-http/tools/credential-copy-tool.js +20 -15
  53. package/dist/credentialed-http/tools/tool-registrations.js +272 -249
  54. package/dist/media-providers/catalog.d.ts +1 -0
  55. package/dist/media-providers/catalog.js +1 -0
  56. package/dist/media-providers/dispatch/async-operation-store.d.ts +6 -4
  57. package/dist/media-providers/dispatch/async-operation-store.js +100 -88
  58. package/dist/media-providers/dispatch/context.js +1 -1
  59. package/dist/media-providers/dispatch/engine.d.ts +5 -1
  60. package/dist/media-providers/dispatch/engine.js +2 -2
  61. package/dist/media-providers/dispatch/index.d.ts +1 -1
  62. package/dist/media-providers/dispatch/index.js +1 -1
  63. package/dist/media-providers/dispatch/node.d.ts +1 -1
  64. package/dist/media-providers/dispatch/node.js +1 -1
  65. package/dist/media-providers/dispatch/openai-compatible.d.ts +50 -11
  66. package/dist/media-providers/dispatch/openai-compatible.js +21 -17
  67. package/dist/media-providers/dispatch/operation-runtime.js +18 -18
  68. package/dist/media-providers/dispatch/outbound.d.ts +2 -2
  69. package/dist/media-providers/dispatch/outbound.js +1 -1
  70. package/dist/media-providers/dispatch/polling-adapter.d.ts +1 -1
  71. package/dist/media-providers/dispatch/providers/aihubmix-shared.d.ts +20 -6
  72. package/dist/media-providers/dispatch/providers/aihubmix-shared.js +8 -8
  73. package/dist/media-providers/dispatch/providers/aihubmix.js +12 -12
  74. package/dist/media-providers/dispatch/providers/custom-image.js +4 -4
  75. package/dist/media-providers/dispatch/providers/fishaudio.js +2 -9
  76. package/dist/media-providers/dispatch/providers/grok.js +5 -19
  77. package/dist/media-providers/dispatch/providers/imagerouter-video-async.js +22 -20
  78. package/dist/media-providers/dispatch/providers/imagerouter.js +7 -21
  79. package/dist/media-providers/dispatch/providers/minimax.js +2 -9
  80. package/dist/media-providers/dispatch/providers/nanobanana.js +2 -2
  81. package/dist/media-providers/dispatch/providers/openai.js +6 -6
  82. package/dist/media-providers/dispatch/providers/openrouter.js +4 -4
  83. package/dist/media-providers/dispatch/providers/senseaudio.js +5 -19
  84. package/dist/media-providers/dispatch/providers/volcengine.js +5 -12
  85. package/dist/media-providers/dispatch/response-parsers.js +3 -3
  86. package/dist/media-providers/dispatch/sqlite-async-operation-store.d.ts +1 -1
  87. package/dist/media-providers/dispatch/sqlite-async-operation-store.js +31 -5
  88. package/dist/media-providers/dispatch/ssrf-guard.js +5 -12
  89. package/dist/media-providers/dispatch/stub.js +2 -2
  90. package/dist/media-providers/dispatch/vendor-adapter.js +2 -2
  91. package/dist/media-providers/image-model-ids.d.ts +36 -0
  92. package/dist/media-providers/image-model-ids.js +24 -0
  93. package/dist/media-providers/sqlite-driver.adapter.d.ts +1 -1
  94. package/dist/media-providers/sqlite-task-store.d.ts +2 -2
  95. package/dist/media-providers/sqlite-task-store.js +31 -4
  96. package/dist/media-providers/task-lifecycle.d.ts +17 -4
  97. package/dist/media-providers/task-lifecycle.js +4 -4
  98. package/dist/media-providers/task-store.js +28 -24
  99. package/dist/media-providers/ui-defaults.d.ts +7 -0
  100. package/dist/media-providers/ui-defaults.js +11 -17
  101. package/dist/saved-requests/types.d.ts +1 -1
  102. package/dist/webhooks/delivery.js +31 -27
  103. package/dist/webhooks/ports.d.ts +4 -1
  104. package/dist/webhooks/subscriptions.d.ts +7 -2
  105. package/dist/webhooks/subscriptions.js +30 -37
  106. package/dist/webhooks/tools/agent-tools.d.ts +82 -0
  107. package/dist/webhooks/tools/agent-tools.js +120 -0
  108. package/dist/webhooks/tools/index.d.ts +7 -0
  109. package/dist/webhooks/tools/index.js +5 -0
  110. package/dist/webhooks/tools/tool-handlers.d.ts +22 -0
  111. package/dist/webhooks/tools/tool-handlers.js +154 -0
  112. package/dist/webhooks/tools/tool-handlers.types.d.ts +64 -0
  113. package/dist/webhooks/tools/tool-handlers.types.js +2 -0
  114. package/dist/webhooks/tools/tool-registrations.d.ts +35 -0
  115. package/dist/webhooks/tools/tool-registrations.js +95 -0
  116. package/dist/webhooks/tools/tool-views.d.ts +62 -0
  117. package/dist/webhooks/tools/tool-views.js +50 -0
  118. package/dist/webhooks/types.d.ts +2 -0
  119. package/dist/webhooks/worker.d.ts +7 -4
  120. package/dist/webhooks/worker.js +22 -20
  121. package/package.json +17 -19
  122. package/dist/composio/bounded-data.d.ts +0 -36
  123. package/dist/composio/bounded-data.js +0 -181
  124. package/dist/composio/catalog.d.ts +0 -147
  125. package/dist/composio/catalog.js +0 -126
  126. package/dist/composio/composio-config.d.ts +0 -42
  127. package/dist/composio/composio-config.js +0 -145
  128. package/dist/composio/composio-descriptions.d.ts +0 -16
  129. package/dist/composio/composio-descriptions.js +0 -766
  130. package/dist/composio/composio.d.ts +0 -364
  131. package/dist/composio/composio.js +0 -1902
  132. package/dist/composio/errors.d.ts +0 -15
  133. package/dist/composio/errors.js +0 -16
  134. package/dist/composio/file-lock.d.ts +0 -13
  135. package/dist/composio/file-lock.js +0 -92
  136. package/dist/composio/index.d.ts +0 -18
  137. package/dist/composio/index.js +0 -7
  138. package/dist/composio/json-schema.d.ts +0 -93
  139. package/dist/composio/json-schema.js +0 -498
  140. package/dist/composio/output-protection.d.ts +0 -32
  141. package/dist/composio/output-protection.js +0 -105
  142. package/dist/composio/service.d.ts +0 -181
  143. package/dist/composio/service.js +0 -758
@@ -0,0 +1,64 @@
1
+ import type { HumanConfirmer, SurfaceExchangeStore, ToolExecutionContext, ToolExecutionOptions, ToolHandler } from "@jini-ai/core";
2
+ import type { AuthorizeFn } from "@jini-ai/core/contracts/events";
3
+ import type { OriginRegistryPort } from "@jini-ai/core/contracts/server/verified-origin";
4
+ import type { Clock } from "@jini-ai/core/primitives";
5
+ import type { WebhookDeliveryRepoPort, WebhookSubscriptionRepoPort } from "../ports.js";
6
+ import type { WebhookSubscriptionRecord } from "../types.js";
7
+ /** The confirmation surface store the delete's held-open dialog is raised through. */
8
+ export interface WebhooksToolSurfaces {
9
+ readonly surfaceExchanges: SurfaceExchangeStore;
10
+ }
11
+ /** What the delete's preparation step freezes for the human to confirm. */
12
+ export interface WebhooksDeletePrepared {
13
+ subscriptionId: string;
14
+ existing: WebhookSubscriptionRecord;
15
+ }
16
+ /**
17
+ * The steps of the confirmation-gated delete, as the host's approval handler runs them. The host
18
+ * owns the dialog (wording, transport, batching); the package owns what is prepared, what runs
19
+ * after a confirm and what the model is told when the human did not confirm.
20
+ */
21
+ export interface WebhooksDeleteSteps {
22
+ surfaces: WebhooksToolSurfaces;
23
+ prepare: (required: {
24
+ ctx: ToolExecutionContext;
25
+ }, optional: ToolExecutionOptions) => Promise<WebhooksDeletePrepared>;
26
+ run: (required: {
27
+ ctx: ToolExecutionContext;
28
+ prepared: WebhooksDeletePrepared;
29
+ confirmer: HumanConfirmer;
30
+ choice?: string;
31
+ }, optional: ToolExecutionOptions) => Promise<unknown>;
32
+ declined: (required: {
33
+ reason: "declined" | "expired" | "abandoned";
34
+ prepared?: WebhooksDeletePrepared;
35
+ }) => unknown;
36
+ }
37
+ /** The model-facing result of a confirmation the human declined, let expire or abandoned. */
38
+ export type WebhooksNotConfirmedResult = (outcome: {
39
+ confirmed: false;
40
+ reason: "declined" | "expired" | "abandoned";
41
+ }) => {
42
+ cancelled: boolean;
43
+ reason?: "expired" | "abandoned";
44
+ note: string;
45
+ };
46
+ /**
47
+ * The deps the webhook tool handlers read, owned by the package side. The host's route deps
48
+ * (`IntegrationsToolDeps`) satisfy it through the binding in `buildWebhooksRegistrations`: the
49
+ * clock is converted to epoch milliseconds there and the confirmation machinery is passed in.
50
+ */
51
+ export interface WebhooksPackageToolDeps {
52
+ authorize: AuthorizeFn;
53
+ workspaceId: string;
54
+ clock: Clock;
55
+ idGen: {
56
+ newId(): string;
57
+ };
58
+ webhookSubscriptionRepo: WebhookSubscriptionRepoPort;
59
+ webhookDeliveryRepo: WebhookDeliveryRepoPort;
60
+ originRegistry: OriginRegistryPort;
61
+ confirmDelete: (steps: WebhooksDeleteSteps) => ToolHandler;
62
+ notConfirmedResult: WebhooksNotConfirmedResult;
63
+ }
64
+ //# sourceMappingURL=tool-handlers.types.d.ts.map
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=tool-handlers.types.js.map
@@ -0,0 +1,35 @@
1
+ /**
2
+ * @file Integrations' half of the agent-tool wiring: maps `agent-tools.ts`'s 6 catalog entries onto
3
+ * the list/create/update/pause/delete/deliveries operations the host's admin routes expose, as
4
+ * `ToolRegistration`s. The owner's 2026-10-09 update authorization supersedes that catalog's historical update
5
+ * exclusion; signing-secret rotation/generation/reveal remains excluded.
6
+ *
7
+ * Authorization shape: none of `createSubscription`/`pauseSubscription`/`deleteSubscription`
8
+ * (`../subscriptions.ts`) accept an `authorize` dependency at all — `WebhookSubscriptionDeps` has no
9
+ * such field, so the domain functions never gate themselves. Every admin route therefore calls
10
+ * `authorize()` inline as its own first line (subscription mutations are a direct feature call, not
11
+ * routed through a command gateway), and every handler (`tool-handlers.ts`) does the same via the
12
+ * kit's `requireToolPermission`.
13
+ *
14
+ * The host binds its search vocabulary and approval policy afterwards with `withToolMetadata`.
15
+ */
16
+ import { type AgentToolSideEffect, type HostReadVocabulary, type ToolRegistration } from "@jini-ai/core";
17
+ import type { WebhooksPackageToolDeps, WebhooksToolSurfaces } from "./tool-handlers.types.js";
18
+ /**
19
+ * This wiring layer's OWN risk classification, authored from what each handler below actually
20
+ * calls. See `DerivedRiskByToolId` in the kit for why it is independent of the catalog's own
21
+ * `sideEffects` declaration.
22
+ */
23
+ export declare const webhooksDerivedRisk: ReadonlyMap<string, AgentToolSideEffect>;
24
+ /**
25
+ * The webhook tool registrations over the package-side deps: handlers, authored risk map and the
26
+ * typed-error mapping. The host's search vocabulary and approval policy are bound afterwards by
27
+ * `buildWebhooksRegistrations`.
28
+ */
29
+ export declare function buildWebhooksToolRegistrations({ deps, surfaces }: {
30
+ deps: WebhooksPackageToolDeps;
31
+ surfaces: WebhooksToolSurfaces;
32
+ }, { hostReads }?: {
33
+ hostReads?: HostReadVocabulary | undefined;
34
+ }): ToolRegistration[];
35
+ //# sourceMappingURL=tool-registrations.d.ts.map
@@ -0,0 +1,95 @@
1
+ /**
2
+ * @file Integrations' half of the agent-tool wiring: maps `agent-tools.ts`'s 6 catalog entries onto
3
+ * the list/create/update/pause/delete/deliveries operations the host's admin routes expose, as
4
+ * `ToolRegistration`s. The owner's 2026-10-09 update authorization supersedes that catalog's historical update
5
+ * exclusion; signing-secret rotation/generation/reveal remains excluded.
6
+ *
7
+ * Authorization shape: none of `createSubscription`/`pauseSubscription`/`deleteSubscription`
8
+ * (`../subscriptions.ts`) accept an `authorize` dependency at all — `WebhookSubscriptionDeps` has no
9
+ * such field, so the domain functions never gate themselves. Every admin route therefore calls
10
+ * `authorize()` inline as its own first line (subscription mutations are a direct feature call, not
11
+ * routed through a command gateway), and every handler (`tool-handlers.ts`) does the same via the
12
+ * kit's `requireToolPermission`.
13
+ *
14
+ * The host binds its search vocabulary and approval policy afterwards with `withToolMetadata`.
15
+ */
16
+ import { ToolPermissionDeniedError, buildDomainRegistrations, indexCatalogById, resolveHostReadRefs, resolveHostReadText, } from "@jini-ai/core";
17
+ import { forbiddenRule, withModelFacingErrors } from "@jini-ai/core/model-facing-tool-errors";
18
+ import { versionConflictRule } from "@jini-ai/core/optimistic-concurrency";
19
+ import { WebhookSubscriptionNotFoundError, WebhookSubscriptionValidationError } from "../subscriptions.js";
20
+ import { getWebhooksAgentToolCatalog } from "./agent-tools.js";
21
+ import { webhooksCreateSubscriptionHandler, webhooksDeleteSubscriptionHandler, webhooksGetDeliveriesHandler, webhooksListSubscriptionsHandler, webhooksPauseSubscriptionHandler, webhooksUpdateSubscriptionHandler, } from "./tool-handlers.js";
22
+ /**
23
+ * This wiring layer's OWN risk classification, authored from what each handler below actually
24
+ * calls. See `DerivedRiskByToolId` in the kit for why it is independent of the catalog's own
25
+ * `sideEffects` declaration.
26
+ */
27
+ export const webhooksDerivedRisk = new Map([
28
+ // -> webhookSubscriptionRepo.listByWorkspace() + webhookDeliveryRepo.listBySubscription() (bounded,
29
+ // per subscription): reads only.
30
+ ["webhooks_list_subscriptions", "none"],
31
+ // -> webhookSubscriptionRepo.findById() + webhookDeliveryRepo.listBySubscription(): reads only.
32
+ ["webhooks_get_deliveries", "none"],
33
+ // -> createSubscription (subscriptions.ts): validates + repo.insert().
34
+ ["webhooks_create_subscription", "mutates-durable-state"],
35
+ // Existing updateSubscription validates replacement fields and the outbound origin before save.
36
+ ["webhooks_update_subscription", "mutates-durable-state"],
37
+ // -> pauseSubscription (subscriptions.ts): status flip + repo.save().
38
+ ["webhooks_pause_subscription", "mutates-durable-state"],
39
+ // -> deleteSubscription (subscriptions.ts): soft-delete status flip + repo.save(). Never
40
+ // row-deletes, but classified `deletes-durable-state` (not `mutates-durable-state`): no
41
+ // un-disable/reactivate path exists anywhere in this domain, so there is no agent-reachable
42
+ // undo — the same standard `content_post_delete` is classified under.
43
+ ["webhooks_delete_subscription", "deletes-durable-state"],
44
+ ]);
45
+ /**
46
+ * The Integrations errors that reach the model with their real reason instead of a redacted
47
+ * `INTERNAL_ERROR` — see `@jini-ai/core/model-facing-tool-errors` for the mechanism and for why
48
+ * this list is an ALLOWLIST rather than a blanket unwrap.
49
+ *
50
+ * Reviewed against this domain's secret handling before listing anything, because Integrations is
51
+ * the one domain in this sweep that holds credential material at all. Nothing on this list can
52
+ * carry it: `WebhookSubscriptionValidationError` is raised only by `subscriptions.ts`'s own
53
+ * label/topics/target_url checks (every construction site interpolates the CALLER's submitted
54
+ * `targetUrl` or nothing at all), and `WebhookSubscriptionNotFoundError` interpolates the caller's
55
+ * own id. The HMAC signing secret is never stored and never named by either class — it is derived
56
+ * at delivery time by `KeyringPort.deriveSigningSecret` and lives entirely in `signing.ts`/
57
+ * `keyring.env.ts`, whose errors (`SiteKeyFileAlreadyExistsError` among them) are deliberately
58
+ * ABSENT here: they are operator/installation faults naming real filesystem paths, exactly the
59
+ * class of internals this allowlist exists to keep redacted.
60
+ *
61
+ * `WebhookDeliveryVetoedError` (`delivery.ts`) is absent for a different reason — it is raised on
62
+ * the OUTBOUND send path, which no tool in this catalog calls, so listing it would be speculative.
63
+ */
64
+ const webhooksModelFacingErrors = ({ hostReads }, _optional = {}) => [
65
+ versionConflictRule({ readToolId: resolveHostReadText({ text: "{{read:webhook_subscription}}" }, { hostReads }) }),
66
+ forbiddenRule({ domainPrefix: "WEBHOOKS", error: ToolPermissionDeniedError }),
67
+ { error: WebhookSubscriptionNotFoundError, code: "WEBHOOKS_SUBSCRIPTION_NOT_FOUND" },
68
+ { error: WebhookSubscriptionValidationError, code: "WEBHOOKS_VALIDATION_FAILED" },
69
+ ];
70
+ /**
71
+ * The webhook tool registrations over the package-side deps: handlers, authored risk map and the
72
+ * typed-error mapping. The host's search vocabulary and approval policy are bound afterwards by
73
+ * `buildWebhooksRegistrations`.
74
+ */
75
+ export function buildWebhooksToolRegistrations({ deps, surfaces }, { hostReads } = {}) {
76
+ const args = { deps, surfaces, hostReads };
77
+ const handlers = {
78
+ webhooks_list_subscriptions: webhooksListSubscriptionsHandler(args),
79
+ webhooks_get_deliveries: webhooksGetDeliveriesHandler(args),
80
+ webhooks_create_subscription: webhooksCreateSubscriptionHandler(args),
81
+ webhooks_update_subscription: webhooksUpdateSubscriptionHandler(args),
82
+ webhooks_pause_subscription: webhooksPauseSubscriptionHandler(args),
83
+ webhooks_delete_subscription: webhooksDeleteSubscriptionHandler(args),
84
+ };
85
+ return buildDomainRegistrations({
86
+ domain: "integrations",
87
+ catalogModule: "webhooks/agent-tools.ts",
88
+ catalog: indexCatalogById({ catalog: resolveHostReadRefs({ value: getWebhooksAgentToolCatalog() }, { hostReads }) }),
89
+ // The whole map at once, so no handler can be the one that forgot — see
90
+ // `withModelFacingErrors`' own doc for why a per-call-site reshape is the defect this avoids.
91
+ handlers: withModelFacingErrors({ handlers, rules: webhooksModelFacingErrors({ hostReads }) }),
92
+ derivedRisk: webhooksDerivedRisk,
93
+ });
94
+ }
95
+ //# sourceMappingURL=tool-registrations.js.map
@@ -0,0 +1,62 @@
1
+ import type { WebhookDeliveryRecord, WebhookSubscriptionRecord } from "../types.js";
2
+ /** Most recent delivery by `createdAt`, computed here rather than assumed from repo return order —
3
+ * `WebhookDeliveryRepoPort.listBySubscription` makes no ordering guarantee (mirrors
4
+ * the host's admin list route's helper of the same name/shape, duplicated
5
+ * rather than imported for the same ports/adapters reason as the constants in `tool-handlers.ts`). */
6
+ export declare function mostRecentDelivery(deliveries: readonly WebhookDeliveryRecord[]): WebhookDeliveryRecord | null;
7
+ /** Model-facing subscription view — drops `ownerPrincipalId`/`createdByPrincipalId`/
8
+ * `createdByPluginId` (attribution internals no wired tool's follow-up call consumes; the same reasoning
9
+ * as every other domain view that drops actor attribution). Never
10
+ * includes a secret value — `WebhookSubscriptionRecord` has no secret field to begin with (see
11
+ * `agent-tools.ts`'s file header). */
12
+ export declare function toSubscriptionToolView({ subscription, lastDelivery }: {
13
+ subscription: WebhookSubscriptionRecord;
14
+ lastDelivery: WebhookDeliveryRecord | null;
15
+ }, _optional?: {}): {
16
+ id: string;
17
+ label: string;
18
+ targetUrl: string;
19
+ topics: string[];
20
+ status: import("../types.js").WebhookSubscriptionStatus;
21
+ secretVersion: number;
22
+ previousSecretVersion: number | null;
23
+ createdAt: string;
24
+ updatedAt: string;
25
+ disabledAt: string | null;
26
+ version: number;
27
+ lastDelivery: {
28
+ id: string;
29
+ subscriptionId: string;
30
+ eventId: string;
31
+ topic: string;
32
+ status: import("../types.js").WebhookDeliveryStatus;
33
+ attempts: number;
34
+ nextAttemptAt: string;
35
+ lastResponseStatus: number | null;
36
+ lastError: string | null;
37
+ signedWithVersion: number | null;
38
+ createdAt: string;
39
+ deliveredAt: string | null;
40
+ deadAt: string | null;
41
+ } | null;
42
+ };
43
+ /** Model-facing delivery view — drops `workspaceId` (redundant: every call is already scoped to
44
+ * the caller's own workspace). */
45
+ export declare function toWebhookDeliveryView({ delivery }: {
46
+ delivery: WebhookDeliveryRecord;
47
+ }, _optional?: {}): {
48
+ id: string;
49
+ subscriptionId: string;
50
+ eventId: string;
51
+ topic: string;
52
+ status: import("../types.js").WebhookDeliveryStatus;
53
+ attempts: number;
54
+ nextAttemptAt: string;
55
+ lastResponseStatus: number | null;
56
+ lastError: string | null;
57
+ signedWithVersion: number | null;
58
+ createdAt: string;
59
+ deliveredAt: string | null;
60
+ deadAt: string | null;
61
+ };
62
+ //# sourceMappingURL=tool-views.d.ts.map
@@ -0,0 +1,50 @@
1
+ /** Most recent delivery by `createdAt`, computed here rather than assumed from repo return order —
2
+ * `WebhookDeliveryRepoPort.listBySubscription` makes no ordering guarantee (mirrors
3
+ * the host's admin list route's helper of the same name/shape, duplicated
4
+ * rather than imported for the same ports/adapters reason as the constants in `tool-handlers.ts`). */
5
+ export function mostRecentDelivery(deliveries) {
6
+ if (deliveries.length === 0)
7
+ return null;
8
+ return deliveries.reduce((latest, candidate) => (candidate.createdAt > latest.createdAt ? candidate : latest));
9
+ }
10
+ /** Model-facing subscription view — drops `ownerPrincipalId`/`createdByPrincipalId`/
11
+ * `createdByPluginId` (attribution internals no wired tool's follow-up call consumes; the same reasoning
12
+ * as every other domain view that drops actor attribution). Never
13
+ * includes a secret value — `WebhookSubscriptionRecord` has no secret field to begin with (see
14
+ * `agent-tools.ts`'s file header). */
15
+ export function toSubscriptionToolView({ subscription, lastDelivery }, _optional = {}) {
16
+ return {
17
+ id: subscription.id,
18
+ label: subscription.label,
19
+ targetUrl: subscription.targetUrl,
20
+ topics: [...subscription.topics],
21
+ status: subscription.status,
22
+ secretVersion: subscription.secretVersion,
23
+ previousSecretVersion: subscription.previousSecretVersion,
24
+ createdAt: subscription.createdAt,
25
+ updatedAt: subscription.updatedAt,
26
+ disabledAt: subscription.disabledAt,
27
+ version: subscription.version,
28
+ lastDelivery: lastDelivery ? toWebhookDeliveryView({ delivery: lastDelivery }) : null,
29
+ };
30
+ }
31
+ /** Model-facing delivery view — drops `workspaceId` (redundant: every call is already scoped to
32
+ * the caller's own workspace). */
33
+ export function toWebhookDeliveryView({ delivery }, _optional = {}) {
34
+ return {
35
+ id: delivery.id,
36
+ subscriptionId: delivery.subscriptionId,
37
+ eventId: delivery.eventId,
38
+ topic: delivery.topic,
39
+ status: delivery.status,
40
+ attempts: delivery.attempts,
41
+ nextAttemptAt: delivery.nextAttemptAt,
42
+ lastResponseStatus: delivery.lastResponseStatus,
43
+ lastError: delivery.lastError,
44
+ signedWithVersion: delivery.signedWithVersion,
45
+ createdAt: delivery.createdAt,
46
+ deliveredAt: delivery.deliveredAt,
47
+ deadAt: delivery.deadAt,
48
+ };
49
+ }
50
+ //# sourceMappingURL=tool-views.js.map
@@ -25,6 +25,8 @@ export interface WebhookSubscriptionRecord {
25
25
  createdByPluginId: string | null;
26
26
  createdAt: ISODateTime;
27
27
  updatedAt: ISODateTime;
28
+ /** Optimistic concurrency counter for subscription edits. */
29
+ version: number;
28
30
  disabledAt: ISODateTime | null;
29
31
  }
30
32
  /** pending -> delivering -> delivered | failed; retryable failures become eligible again after
@@ -7,6 +7,7 @@
7
7
  * Single flight: a tick that finds the previous one still running does nothing, so a slow receiver
8
8
  * (up to the per-request total deadline times the batch) never stacks claims on top of each other.
9
9
  */
10
+ import { type Logger } from '@jini-ai/core/primitives';
10
11
  /** Idle wait between ticks. Short enough that a delivery leaves within seconds, long enough that
11
12
  * an idle site costs one indexed `SELECT` per interval. */
12
13
  export declare const WEBHOOK_DELIVERY_INTERVAL_MS = 15000;
@@ -55,17 +56,19 @@ export interface WebhookDeliveryWorkerOptional {
55
56
  stopGraceMs?: number;
56
57
  scheduler?: WebhookDeliveryScheduler;
57
58
  log?: (line: string) => void;
59
+ report?: Pick<Logger, 'error' | 'warn'>;
58
60
  }
59
61
  /** The abort reason a running pass sees; recorded as the interrupted attempt's error. */
60
62
  export declare class WebhookDeliveryWorkerStoppedError extends Error {
61
63
  constructor();
62
64
  }
63
65
  /**
64
- * One log line for a failed tick: the error's name, message (URLs removed, length capped) and
65
- * `code`. Never the error object itself, its `cause`, stack or extra fields: a repo or transport
66
- * error can carry a receiver URL with credentials, request headers or a payload.
66
+ * One log line for a failed tick: fixed words plus the error's class and an approved code
67
+ * (`describeErrorForLog`). Never the message, the error object itself, its `cause` text, stack or
68
+ * extra fields: a repo or transport error can carry a receiver URL with credentials, request
69
+ * headers or a payload.
67
70
  *
68
- * @complexity O(message length).
71
+ * @complexity O(1).
69
72
  */
70
73
  export declare function describeWebhookTickError(required: {
71
74
  error: unknown;
@@ -7,6 +7,8 @@
7
7
  * Single flight: a tick that finds the previous one still running does nothing, so a slow receiver
8
8
  * (up to the per-request total deadline times the batch) never stacks claims on top of each other.
9
9
  */
10
+ import { describeErrorForLog } from "@jini-ai/core";
11
+ import { createConsoleLogger } from '@jini-ai/core/primitives';
10
12
  /** Idle wait between ticks. Short enough that a delivery leaves within seconds, long enough that
11
13
  * an idle site costs one indexed `SELECT` per interval. */
12
14
  export const WEBHOOK_DELIVERY_INTERVAL_MS = 15_000;
@@ -20,9 +22,6 @@ export const WEBHOOK_DELIVERY_STOP_GRACE_MS = 1_000;
20
22
  export const WEBHOOK_DELIVERY_FAILED_LINE = "[webhooks] delivery tick failed; retrying after the interval";
21
23
  /** Logged when `stop` gives up waiting on a running tick. */
22
24
  export const WEBHOOK_DELIVERY_STOP_LATE_LINE = "[webhooks] a delivery tick was still running at shutdown; it was abandoned";
23
- const MAX_LOGGED_MESSAGE_CHARS = 200;
24
- /** Bounds the scan of a pathological message before URLs are removed. */
25
- const MAX_SCANNED_MESSAGE_CHARS = 2_000;
26
25
  /** Node timers, unref'd: like the outbox drainer's, the loop must never hold a stopping process open. */
27
26
  export const nodeWebhookDeliveryScheduler = {
28
27
  every: ({ ms, run }) => {
@@ -44,22 +43,15 @@ export class WebhookDeliveryWorkerStoppedError extends Error {
44
43
  }
45
44
  }
46
45
  /**
47
- * One log line for a failed tick: the error's name, message (URLs removed, length capped) and
48
- * `code`. Never the error object itself, its `cause`, stack or extra fields: a repo or transport
49
- * error can carry a receiver URL with credentials, request headers or a payload.
46
+ * One log line for a failed tick: fixed words plus the error's class and an approved code
47
+ * (`describeErrorForLog`). Never the message, the error object itself, its `cause` text, stack or
48
+ * extra fields: a repo or transport error can carry a receiver URL with credentials, request
49
+ * headers or a payload.
50
50
  *
51
- * @complexity O(message length).
51
+ * @complexity O(1).
52
52
  */
53
53
  export function describeWebhookTickError(required, _optional = {}) {
54
- const { error } = required;
55
- if (!(error instanceof Error))
56
- return `${WEBHOOK_DELIVERY_FAILED_LINE}: a non-Error value was thrown`;
57
- // Any space-separated word holding "://" is dropped whole (scheme, userinfo, host, query alike).
58
- const words = error.message.slice(0, MAX_SCANNED_MESSAGE_CHARS).split(" ");
59
- const message = words.map((word) => (word.includes("://") ? "[url]" : word)).join(" ").slice(0, MAX_LOGGED_MESSAGE_CHARS);
60
- const code = error.code;
61
- const codeSuffix = typeof code === "string" || typeof code === "number" ? ` (code ${code})` : "";
62
- return `${WEBHOOK_DELIVERY_FAILED_LINE}: ${error.name}: ${message}${codeSuffix}`;
54
+ return `${WEBHOOK_DELIVERY_FAILED_LINE}: ${describeErrorForLog({ err: required.error })}`;
63
55
  }
64
56
  function assertPositiveFinite(value, name) {
65
57
  if (!(Number.isFinite(value) && value > 0))
@@ -75,7 +67,8 @@ function assertPositiveFinite(value, name) {
75
67
  * @complexity O(1) per tick, beyond `processDue`.
76
68
  */
77
69
  export function startWebhookDeliveryWorker(required, optional = {}) {
78
- const { intervalMs = WEBHOOK_DELIVERY_INTERVAL_MS, stopGraceMs = WEBHOOK_DELIVERY_STOP_GRACE_MS, scheduler = nodeWebhookDeliveryScheduler, log = (line) => console.error(line) } = optional;
70
+ const { intervalMs = WEBHOOK_DELIVERY_INTERVAL_MS, stopGraceMs = WEBHOOK_DELIVERY_STOP_GRACE_MS, scheduler = nodeWebhookDeliveryScheduler, log, report = createConsoleLogger({ prefix: '' }) } = optional;
71
+ const logger = report;
79
72
  assertPositiveFinite(intervalMs, "intervalMs");
80
73
  assertPositiveFinite(stopGraceMs, "stopGraceMs");
81
74
  const controller = new AbortController();
@@ -83,7 +76,12 @@ export function startWebhookDeliveryWorker(required, optional = {}) {
83
76
  const tick = () => {
84
77
  if (controller.signal.aborted)
85
78
  return Promise.resolve();
86
- running ??= required.processDue({ signal: controller.signal }).then(() => undefined, (error) => log(describeWebhookTickError({ error }))).finally(() => { running = undefined; });
79
+ running ??= required.processDue({ signal: controller.signal }).then(() => undefined, (error) => {
80
+ if (log)
81
+ log(describeWebhookTickError({ error }));
82
+ else
83
+ logger.error({ message: WEBHOOK_DELIVERY_FAILED_LINE }, { error });
84
+ }).finally(() => { running = undefined; });
87
85
  return running;
88
86
  };
89
87
  const timer = scheduler.every({ ms: intervalMs, run: () => { void tick(); } });
@@ -97,8 +95,12 @@ export function startWebhookDeliveryWorker(required, optional = {}) {
97
95
  const late = new Promise((resolve) => { grace = scheduler.after({ ms: stopGraceMs, run: () => resolve("late") }); });
98
96
  const outcome = await Promise.race([running, late]);
99
97
  grace.cancel();
100
- if (outcome === "late")
101
- log(WEBHOOK_DELIVERY_STOP_LATE_LINE);
98
+ if (outcome === "late") {
99
+ if (log)
100
+ log(WEBHOOK_DELIVERY_STOP_LATE_LINE);
101
+ else
102
+ logger.warn({ message: WEBHOOK_DELIVERY_STOP_LATE_LINE });
103
+ }
102
104
  };
103
105
  return { tick, stop };
104
106
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jini-ai/integrations",
3
- "version": "0.7.2",
3
+ "version": "0.7.3-next.2",
4
4
  "description": "Third-party vendor integrations and outbound services, each independently importable: media generation, credentialed HTTP and webhooks.",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -22,13 +22,12 @@
22
22
  "./api-connections/hosted-mcp": "node",
23
23
  "./media-providers/node": "node",
24
24
  "./saved-requests": "node",
25
- "./credentialed-http/tools": "node"
25
+ "./credentialed-http/tools": "node",
26
+ "./webhooks/tools": "node"
26
27
  },
27
28
  "optionalPeers": {
28
- "@jini-ai/db": "opt-in: database-backed adapters — Database-backed adapters could not load @jini-ai/db. Install @jini-ai/db to enable this feature, or check its installed version and native binaries.",
29
29
  "better-sqlite3": "opt-in: sqlite storage; import @jini-ai/integrations/media-providers — SQLite storage could not load better-sqlite3. Install better-sqlite3 to enable this feature, or check its installed version and native binaries.",
30
30
  "@jini-ai/platform": "opt-in: platform-backed adapters; import @jini-ai/integrations/media-providers — Platform-backed adapters could not load @jini-ai/platform. Install @jini-ai/platform to enable this feature, or check its installed version and native binaries.",
31
- "@jini-ai/oauth": "opt-in: oauth connections; import @jini-ai/integrations/api-connections — OAuth connections could not load @jini-ai/oauth. Install @jini-ai/oauth to enable this feature, or check its installed version and native binaries.",
32
31
  "@cfworker/json-schema": "opt-in: json schema validation; import @jini-ai/integrations/saved-requests — JSON Schema validation could not load @cfworker/json-schema. Install @cfworker/json-schema to enable this feature, or check its installed version and native binaries."
33
32
  }
34
33
  },
@@ -84,6 +83,11 @@
84
83
  "types": "./dist/credentialed-http/tools/index.d.ts",
85
84
  "import": "./dist/credentialed-http/tools/index.js",
86
85
  "default": "./dist/credentialed-http/tools/index.js"
86
+ },
87
+ "./webhooks/tools": {
88
+ "types": "./dist/webhooks/tools/index.d.ts",
89
+ "import": "./dist/webhooks/tools/index.js",
90
+ "default": "./dist/webhooks/tools/index.js"
87
91
  }
88
92
  },
89
93
  "typesVersions": {
@@ -114,6 +118,9 @@
114
118
  ],
115
119
  "credentialed-http/tools": [
116
120
  "./dist/credentialed-http/tools/index.d.ts"
121
+ ],
122
+ "webhooks/tools": [
123
+ "./dist/webhooks/tools/index.d.ts"
117
124
  ]
118
125
  }
119
126
  },
@@ -134,38 +141,29 @@
134
141
  "registry": "https://registry.npmjs.org"
135
142
  },
136
143
  "dependencies": {
137
- "@jini-ai/core": "^0.7.2"
144
+ "@jini-ai/core": "^0.7.3-next.2"
138
145
  },
139
146
  "peerDependencies": {
140
- "@jini-ai/db": "^0.7.0",
141
147
  "better-sqlite3": "^13.0.0",
142
- "@jini-ai/platform": "^0.7.0",
143
- "@jini-ai/oauth": "^0.7.0",
148
+ "@jini-ai/platform": "^0.7.3-next.2",
144
149
  "@cfworker/json-schema": "^4.1.1"
145
150
  },
146
151
  "devDependencies": {
147
152
  "@types/better-sqlite3": "^7.6.11",
148
153
  "better-sqlite3": "^13.0.0",
149
- "@vitest/coverage-v8": "^2.1.9",
154
+ "@vitest/coverage-v8": "^3.2.6",
150
155
  "@cfworker/json-schema": "^4.1.1",
151
- "@jini-ai/db": "^0.7.2",
152
- "@jini-ai/platform": "0.7.2",
153
- "@jini-ai/oauth": "0.7.2",
154
- "@jini-ai/core": "0.7.2"
156
+ "@jini-ai/platform": "0.7.3-next.2",
157
+ "@jini-ai/core": "0.7.3-next.2",
158
+ "@jini-ai/oauth": "0.7.3-next.2"
155
159
  },
156
160
  "peerDependenciesMeta": {
157
- "@jini-ai/db": {
158
- "optional": true
159
- },
160
161
  "better-sqlite3": {
161
162
  "optional": true
162
163
  },
163
164
  "@jini-ai/platform": {
164
165
  "optional": true
165
166
  },
166
- "@jini-ai/oauth": {
167
- "optional": true
168
- },
169
167
  "@cfworker/json-schema": {
170
168
  "optional": true
171
169
  }
@@ -1,36 +0,0 @@
1
- import type { JsonValue } from '@jini-ai/protocol';
2
- export declare const COMPOSIO_MAX_RESPONSE_BYTES: number;
3
- export declare const COMPOSIO_MAX_ERROR_RESPONSE_BYTES: number;
4
- export declare const COMPOSIO_MAX_CACHE_BYTES: number;
5
- export declare const COMPOSIO_MAX_SECRET_STORE_BYTES: number;
6
- export interface JsonStructureLimits {
7
- maxDepth: number;
8
- maxNodes: number;
9
- maxArrayItems: number;
10
- maxObjectKeys: number;
11
- maxStringBytes: number;
12
- }
13
- export declare const COMPOSIO_REMOTE_JSON_LIMITS: JsonStructureLimits;
14
- export declare class BoundedDataError extends Error {
15
- constructor(message: string);
16
- }
17
- /** Reads at most `maxBytes` from a response body before allocating/decoding it. */
18
- export declare function readBoundedResponseText(response: Response, maxBytes: number, label?: string): Promise<string>;
19
- /** Reads and parses a response body only after its byte size is bounded. */
20
- export declare function readBoundedResponseJson(response: Response, maxBytes?: number, label?: string): Promise<unknown>;
21
- /** Reads a local UTF-8 file without allowing it to grow past `maxBytes`. */
22
- export declare function readBoundedUtf8File(filePath: string, maxBytes: number): string;
23
- /**
24
- * Opens a secret-bearing regular file without following its final symlink,
25
- * enforces owner-only mode on the opened inode, and reads it within a byte cap.
26
- *
27
- * @complexity Time: O(n). Space: O(n), where n is capped by `maxBytes`.
28
- * @overallScore 100/100
29
- */
30
- export declare function readPrivateBoundedUtf8File(filePath: string, maxBytes: number): string;
31
- /**
32
- * Converts an unknown value into JSON while enforcing depth, node, collection,
33
- * and string bounds before recursive copies are allocated.
34
- */
35
- export declare function toStructurallyBoundedJsonValue(value: unknown, limits?: JsonStructureLimits): JsonValue;
36
- //# sourceMappingURL=bounded-data.d.ts.map