aimeat 2.5.0 → 2.6.0
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/dist/.env.example +33 -0
- package/dist/build-stamp.json +13 -0
- package/dist/locales/en.json +166 -3
- package/dist/locales/fi.json +166 -3
- package/dist/public/components/VoiceRecorder.js +116 -0
- package/dist/public/connection-done.html +53 -0
- package/dist/public/css/components/voice-recorder.css +66 -0
- package/dist/public/css/views/inbox.css +41 -0
- package/dist/public/css/views/profile.css +171 -95
- package/dist/public/js/services/audio-recorder.js +171 -0
- package/dist/public/js/services/messages.js +21 -2
- package/dist/public/spa.html +3 -0
- package/dist/public/views/profile/access-tab/connections.js +264 -0
- package/dist/public/views/profile/access-tab.js +2 -0
- package/dist/public/views/profile/inbox-tab/components.js +60 -10
- package/dist/public/views/profile/inbox-tab/helpers.js +33 -0
- package/dist/public/views/profile/inbox-tab/panels.js +6 -1
- package/dist/public/views/profile/inbox-tab/use-voice.js +50 -0
- package/dist/public/views/profile/inbox-tab/voice-parts.js +111 -0
- package/dist/public/views/profile/inbox-tab.js +18 -24
- package/dist/public/views/profile/openrouter/budget-panel.js +224 -0
- package/dist/public/views/profile/openrouter/model-picker.js +150 -0
- package/dist/public/views/profile/openrouter/pricing.js +139 -0
- package/dist/public/views/profile/openrouter-settings.js +425 -488
- package/dist/scripts/build-sdk-libs.d.ts.map +1 -1
- package/dist/scripts/build-sdk-libs.js +1 -0
- package/dist/scripts/build-sdk-libs.js.map +1 -1
- package/dist/scripts/check-ai-disclosure.d.ts.map +1 -1
- package/dist/scripts/check-ai-disclosure.js +65 -0
- package/dist/scripts/check-ai-disclosure.js.map +1 -1
- package/dist/src/cli/connect/ai-provenance-carry.d.ts +54 -3
- package/dist/src/cli/connect/ai-provenance-carry.d.ts.map +1 -1
- package/dist/src/cli/connect/ai-provenance-carry.js +84 -12
- package/dist/src/cli/connect/ai-provenance-carry.js.map +1 -1
- package/dist/src/cli/connect/api-client.d.ts +11 -0
- package/dist/src/cli/connect/api-client.d.ts.map +1 -1
- package/dist/src/cli/connect/api-client.js +2 -0
- package/dist/src/cli/connect/api-client.js.map +1 -1
- package/dist/src/cli/connect/mcp/local-server.d.ts.map +1 -1
- package/dist/src/cli/connect/mcp/local-server.js +11 -0
- package/dist/src/cli/connect/mcp/local-server.js.map +1 -1
- package/dist/src/cli/connect/mcp/tools/apps.d.ts +1 -0
- package/dist/src/cli/connect/mcp/tools/apps.d.ts.map +1 -1
- package/dist/src/cli/connect/mcp/tools/apps.js +3 -2
- package/dist/src/cli/connect/mcp/tools/apps.js.map +1 -1
- package/dist/src/cli/connect/mcp/tools/core.d.ts +2 -0
- package/dist/src/cli/connect/mcp/tools/core.d.ts.map +1 -1
- package/dist/src/cli/connect/mcp/tools/core.js +5 -2
- package/dist/src/cli/connect/mcp/tools/core.js.map +1 -1
- package/dist/src/cli/connect/mcp/tools/knowledge.d.ts +1 -0
- package/dist/src/cli/connect/mcp/tools/knowledge.d.ts.map +1 -1
- package/dist/src/cli/connect/mcp/tools/knowledge.js +3 -2
- package/dist/src/cli/connect/mcp/tools/knowledge.js.map +1 -1
- package/dist/src/config-types.d.ts +14 -0
- package/dist/src/config-types.d.ts.map +1 -1
- package/dist/src/config.d.ts.map +1 -1
- package/dist/src/config.js +10 -0
- package/dist/src/config.js.map +1 -1
- package/dist/src/generated/api-types.d.ts +969 -4
- package/dist/src/generated/api-types.d.ts.map +1 -1
- package/dist/src/mcp/ai-provenance-input.d.ts +33 -0
- package/dist/src/mcp/ai-provenance-input.d.ts.map +1 -1
- package/dist/src/mcp/ai-provenance-input.js +36 -0
- package/dist/src/mcp/ai-provenance-input.js.map +1 -1
- package/dist/src/mcp/apps.d.ts +7 -0
- package/dist/src/mcp/apps.d.ts.map +1 -1
- package/dist/src/mcp/apps.js +20 -2
- package/dist/src/mcp/apps.js.map +1 -1
- package/dist/src/models/ai-provenance-schemas.d.ts +7 -1
- package/dist/src/models/ai-provenance-schemas.d.ts.map +1 -1
- package/dist/src/models/ai-provenance-schemas.js +11 -1
- package/dist/src/models/ai-provenance-schemas.js.map +1 -1
- package/dist/src/models/connection-schemas.d.ts +203 -0
- package/dist/src/models/connection-schemas.d.ts.map +1 -0
- package/dist/src/models/connection-schemas.js +33 -0
- package/dist/src/models/connection-schemas.js.map +1 -0
- package/dist/src/models/message-schemas.d.ts +40 -0
- package/dist/src/models/message-schemas.d.ts.map +1 -1
- package/dist/src/models/message-schemas.js +23 -0
- package/dist/src/models/message-schemas.js.map +1 -1
- package/dist/src/routes/ai-provenance.d.ts +6 -0
- package/dist/src/routes/ai-provenance.d.ts.map +1 -1
- package/dist/src/routes/ai-provenance.js +34 -1
- package/dist/src/routes/ai-provenance.js.map +1 -1
- package/dist/src/routes/ai.d.ts +5 -0
- package/dist/src/routes/ai.d.ts.map +1 -1
- package/dist/src/routes/ai.js +83 -0
- package/dist/src/routes/ai.js.map +1 -1
- package/dist/src/routes/app-grants.d.ts.map +1 -1
- package/dist/src/routes/app-grants.js +4 -0
- package/dist/src/routes/app-grants.js.map +1 -1
- package/dist/src/routes/apps/drafts.d.ts +3 -0
- package/dist/src/routes/apps/drafts.d.ts.map +1 -1
- package/dist/src/routes/apps/drafts.js +13 -0
- package/dist/src/routes/apps/drafts.js.map +1 -1
- package/dist/src/routes/apps/publish.d.ts +5 -0
- package/dist/src/routes/apps/publish.d.ts.map +1 -1
- package/dist/src/routes/apps/publish.js +21 -5
- package/dist/src/routes/apps/publish.js.map +1 -1
- package/dist/src/routes/connections.d.ts +35 -0
- package/dist/src/routes/connections.d.ts.map +1 -0
- package/dist/src/routes/connections.js +406 -0
- package/dist/src/routes/connections.js.map +1 -0
- package/dist/src/routes/libs.js +1 -1
- package/dist/src/routes/libs.js.map +1 -1
- package/dist/src/routes/messages.d.ts +5 -0
- package/dist/src/routes/messages.d.ts.map +1 -1
- package/dist/src/routes/messages.js +92 -0
- package/dist/src/routes/messages.js.map +1 -1
- package/dist/src/routes/openrouter.d.ts +6 -1
- package/dist/src/routes/openrouter.d.ts.map +1 -1
- package/dist/src/routes/openrouter.js +37 -7
- package/dist/src/routes/openrouter.js.map +1 -1
- package/dist/src/routes/upload.d.ts +5 -0
- package/dist/src/routes/upload.d.ts.map +1 -1
- package/dist/src/routes/upload.js +32 -0
- package/dist/src/routes/upload.js.map +1 -1
- package/dist/src/server-bootstrap/routes-loader.d.ts.map +1 -1
- package/dist/src/server-bootstrap/routes-loader.js +2 -0
- package/dist/src/server-bootstrap/routes-loader.js.map +1 -1
- package/dist/src/services/ai-completion.d.ts +48 -0
- package/dist/src/services/ai-completion.d.ts.map +1 -1
- package/dist/src/services/ai-completion.js +112 -72
- package/dist/src/services/ai-completion.js.map +1 -1
- package/dist/src/services/ai-disclosure.d.ts +6 -0
- package/dist/src/services/ai-disclosure.d.ts.map +1 -1
- package/dist/src/services/ai-disclosure.js +20 -2
- package/dist/src/services/ai-disclosure.js.map +1 -1
- package/dist/src/services/ai-provenance-page.d.ts +59 -0
- package/dist/src/services/ai-provenance-page.d.ts.map +1 -0
- package/dist/src/services/ai-provenance-page.js +185 -0
- package/dist/src/services/ai-provenance-page.js.map +1 -0
- package/dist/src/services/ai-provenance.d.ts +6 -0
- package/dist/src/services/ai-provenance.d.ts.map +1 -1
- package/dist/src/services/ai-provenance.js +5 -0
- package/dist/src/services/ai-provenance.js.map +1 -1
- package/dist/src/services/ai-transcription.d.ts +66 -0
- package/dist/src/services/ai-transcription.d.ts.map +1 -0
- package/dist/src/services/ai-transcription.js +90 -0
- package/dist/src/services/ai-transcription.js.map +1 -0
- package/dist/src/services/app-publish.d.ts.map +1 -1
- package/dist/src/services/app-publish.js +16 -1
- package/dist/src/services/app-publish.js.map +1 -1
- package/dist/src/services/build-app-prompt.d.ts.map +1 -1
- package/dist/src/services/build-app-prompt.js +2 -1
- package/dist/src/services/build-app-prompt.js.map +1 -1
- package/dist/src/services/connections/attach.d.ts +62 -0
- package/dist/src/services/connections/attach.d.ts.map +1 -0
- package/dist/src/services/connections/attach.js +168 -0
- package/dist/src/services/connections/attach.js.map +1 -0
- package/dist/src/services/connections/credential.d.ts +39 -0
- package/dist/src/services/connections/credential.d.ts.map +1 -0
- package/dist/src/services/connections/credential.js +66 -0
- package/dist/src/services/connections/credential.js.map +1 -0
- package/dist/src/services/connections/instance.d.ts +65 -0
- package/dist/src/services/connections/instance.d.ts.map +1 -0
- package/dist/src/services/connections/instance.js +144 -0
- package/dist/src/services/connections/instance.js.map +1 -0
- package/dist/src/services/connections/oauth.d.ts +77 -0
- package/dist/src/services/connections/oauth.d.ts.map +1 -0
- package/dist/src/services/connections/oauth.js +290 -0
- package/dist/src/services/connections/oauth.js.map +1 -0
- package/dist/src/services/connections/providers.d.ts +118 -0
- package/dist/src/services/connections/providers.d.ts.map +1 -0
- package/dist/src/services/connections/providers.js +260 -0
- package/dist/src/services/connections/providers.js.map +1 -0
- package/dist/src/services/connections/publish-gate.d.ts +103 -0
- package/dist/src/services/connections/publish-gate.d.ts.map +1 -0
- package/dist/src/services/connections/publish-gate.js +0 -0
- package/dist/src/services/connections/publish-gate.js.map +1 -0
- package/dist/src/services/connections/publish.d.ts +60 -0
- package/dist/src/services/connections/publish.d.ts.map +1 -0
- package/dist/src/services/connections/publish.js +340 -0
- package/dist/src/services/connections/publish.js.map +1 -0
- package/dist/src/services/connections/refresh.d.ts +55 -0
- package/dist/src/services/connections/refresh.d.ts.map +1 -0
- package/dist/src/services/connections/refresh.js +307 -0
- package/dist/src/services/connections/refresh.js.map +1 -0
- package/dist/src/services/message-send.d.ts.map +1 -1
- package/dist/src/services/message-send.js +16 -2
- package/dist/src/services/message-send.js.map +1 -1
- package/dist/src/services/openrouter.d.ts +67 -1
- package/dist/src/services/openrouter.d.ts.map +1 -1
- package/dist/src/services/openrouter.js +102 -11
- package/dist/src/services/openrouter.js.map +1 -1
- package/dist/src/services/upload-token.d.ts +5 -1
- package/dist/src/services/upload-token.d.ts.map +1 -1
- package/dist/src/services/upload-token.js +13 -1
- package/dist/src/services/upload-token.js.map +1 -1
- package/dist/src/services/workflow/engine-util.d.ts +18 -0
- package/dist/src/services/workflow/engine-util.d.ts.map +1 -1
- package/dist/src/services/workflow/engine-util.js +27 -0
- package/dist/src/services/workflow/engine-util.js.map +1 -1
- package/dist/src/services/workflow/engine.d.ts.map +1 -1
- package/dist/src/services/workflow/engine.js +4 -2
- package/dist/src/services/workflow/engine.js.map +1 -1
- package/dist/src/storage/interface.d.ts +2 -1
- package/dist/src/storage/interface.d.ts.map +1 -1
- package/dist/src/storage/providers/postgres-kysely/db-types.d.ts +65 -0
- package/dist/src/storage/providers/postgres-kysely/db-types.d.ts.map +1 -1
- package/dist/src/storage/providers/postgres-kysely/index.d.ts.map +1 -1
- package/dist/src/storage/providers/postgres-kysely/index.js +2 -1
- package/dist/src/storage/providers/postgres-kysely/index.js.map +1 -1
- package/dist/src/storage/providers/postgres-kysely/methods/connections.d.ts +44 -0
- package/dist/src/storage/providers/postgres-kysely/methods/connections.d.ts.map +1 -0
- package/dist/src/storage/providers/postgres-kysely/methods/connections.js +308 -0
- package/dist/src/storage/providers/postgres-kysely/methods/connections.js.map +1 -0
- package/dist/src/storage/providers/postgres-kysely/methods/node-infra.d.ts.map +1 -1
- package/dist/src/storage/providers/postgres-kysely/methods/node-infra.js +4 -2
- package/dist/src/storage/providers/postgres-kysely/methods/node-infra.js.map +1 -1
- package/dist/src/storage/providers/postgres-kysely/migrations/0021_connections.sql +116 -0
- package/dist/src/storage/providers/postgres-kysely/migrations/0022_provider_clients.sql +36 -0
- package/dist/src/storage/providers/postgres-kysely/migrations/0023_nonce_payload.sql +13 -0
- package/dist/src/storage/providers/sqlite/index.d.ts.map +1 -1
- package/dist/src/storage/providers/sqlite/index.js +2 -1
- package/dist/src/storage/providers/sqlite/index.js.map +1 -1
- package/dist/src/storage/providers/sqlite/methods/community.d.ts.map +1 -1
- package/dist/src/storage/providers/sqlite/methods/community.js +2 -1
- package/dist/src/storage/providers/sqlite/methods/community.js.map +1 -1
- package/dist/src/storage/providers/sqlite/methods/connections.d.ts +60 -0
- package/dist/src/storage/providers/sqlite/methods/connections.d.ts.map +1 -0
- package/dist/src/storage/providers/sqlite/methods/connections.js +287 -0
- package/dist/src/storage/providers/sqlite/methods/connections.js.map +1 -0
- package/dist/src/storage/providers/sqlite/schema-tables-1.d.ts.map +1 -1
- package/dist/src/storage/providers/sqlite/schema-tables-1.js +4 -0
- package/dist/src/storage/providers/sqlite/schema-tables-1.js.map +1 -1
- package/dist/src/storage/providers/sqlite/schema-tables-3.d.ts.map +1 -1
- package/dist/src/storage/providers/sqlite/schema-tables-3.js +106 -0
- package/dist/src/storage/providers/sqlite/schema-tables-3.js.map +1 -1
- package/dist/src/storage/providers/sqlite/schema.d.ts.map +1 -1
- package/dist/src/storage/providers/sqlite/schema.js +2 -0
- package/dist/src/storage/providers/sqlite/schema.js.map +1 -1
- package/dist/src/storage/repositories/connection.repository.d.ts +124 -0
- package/dist/src/storage/repositories/connection.repository.d.ts.map +1 -0
- package/dist/src/storage/repositories/connection.repository.js +2 -0
- package/dist/src/storage/repositories/connection.repository.js.map +1 -0
- package/dist/src/storage/types/agents-messaging.d.ts +19 -0
- package/dist/src/storage/types/agents-messaging.d.ts.map +1 -1
- package/dist/src/storage/types/agents-messaging.js.map +1 -1
- package/dist/src/storage/types/auth.d.ts +8 -1
- package/dist/src/storage/types/auth.d.ts.map +1 -1
- package/dist/src/utils/build-stamp.d.ts +56 -0
- package/dist/src/utils/build-stamp.d.ts.map +1 -0
- package/dist/src/utils/build-stamp.js +142 -0
- package/dist/src/utils/build-stamp.js.map +1 -0
- package/dist/src/utils/messaging.d.ts +14 -0
- package/dist/src/utils/messaging.d.ts.map +1 -1
- package/dist/src/utils/messaging.js +0 -0
- package/dist/src/utils/messaging.js.map +1 -1
- package/dist/static/sdk-libs/connect/index.js +199 -0
- package/dist/static/sdk-libs/connect/notes.js +47 -0
- package/dist/static/sdk-libs/connect/panel.js +238 -0
- package/dist/static/sdk-libs/data/index.js +63 -11
- package/dist/static/sdk-libs/dist/aimeat-connect.js +357 -0
- package/dist/static/sdk-libs/dist/aimeat-data.js +40 -9
- package/package.json +2 -2
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file connection-schemas.ts
|
|
3
|
+
* @description Types for outbound connections (TARGET-057, aimeat-connect): a principal's own
|
|
4
|
+
* account at an EXTERNAL service, held by the node so nothing else has to hold it.
|
|
5
|
+
*
|
|
6
|
+
* The distinction this file exists to keep straight is the one the first spec draft got wrong.
|
|
7
|
+
* `principal` is WHOEVER CONNECTED THE ACCOUNT, which in a multi-user app is the app's USER, not
|
|
8
|
+
* the app's owner. The field is deliberately not called `owner`: that word already means the
|
|
9
|
+
* account layer in AIMEAT, and reusing it here produced a model that could not carry a multi-user
|
|
10
|
+
* app at all. See design doc-t057-modes.
|
|
11
|
+
*
|
|
12
|
+
* Two modes, and the second one is not a later addition:
|
|
13
|
+
* - `personal` — the user connected their own account; only they use it.
|
|
14
|
+
* - `shared` — an app owner connected a channel and DELEGATED a named action over it. The
|
|
15
|
+
* delegation, not the connection, is what an app calls. Its constraints
|
|
16
|
+
* (per-user cap, moderation, attribution) change the schema, which is why both
|
|
17
|
+
* modes ship together.
|
|
18
|
+
*
|
|
19
|
+
* The credential itself never appears in this file's read shapes. `ConnectionRecord.credential`
|
|
20
|
+
* is ciphertext (`iv:tag:ct` from services/encryption.ts) and `PublicConnection` is what an app
|
|
21
|
+
* is allowed to see.
|
|
22
|
+
* @structure
|
|
23
|
+
* - ConnectionMode / ConnectionStatus / CredentialShape — the three enums
|
|
24
|
+
* - ConnectionRecord — the stored row, credential encrypted
|
|
25
|
+
* - PublicConnection — the app-facing projection (K1: no scopes, no expiry)
|
|
26
|
+
* - DelegationRecord — shared-mode only: one named action with fixed parameters
|
|
27
|
+
* - PublishAttempt — idempotency key + attribution + quota accounting, written BEFORE the attempt
|
|
28
|
+
* @usage import type { ConnectionRecord } from '../models/connection-schemas.js';
|
|
29
|
+
* @version-history
|
|
30
|
+
* v1.0.0 — 2026-08-02 — TARGET-057 Phase 1.
|
|
31
|
+
*/
|
|
32
|
+
/** Whose account it is and who may act through it. See doc-t057-modes. */
|
|
33
|
+
export type ConnectionMode = 'personal' | 'shared';
|
|
34
|
+
/**
|
|
35
|
+
* `needs_reauth` is a user-visible state, not an error. It is what a failed refresh or a
|
|
36
|
+
* provider-side revocation resolves to, and scheduled work parks on it rather than retrying.
|
|
37
|
+
*/
|
|
38
|
+
export type ConnectionStatus = 'active' | 'needs_reauth' | 'revoked';
|
|
39
|
+
/**
|
|
40
|
+
* How the stored credential is renewed. The store records the shape rather than assuming it —
|
|
41
|
+
* designing around `oauth2` alone produces a store that cannot hold a Bluesky app password or a
|
|
42
|
+
* Telegram bot token, and that failure only shows up at the third provider.
|
|
43
|
+
*/
|
|
44
|
+
export type CredentialShape =
|
|
45
|
+
/** Authorization code + PKCE, access + refresh. Mastodon, Google/YouTube, Meta, TikTok, LinkedIn. */
|
|
46
|
+
'oauth2'
|
|
47
|
+
/** Long-lived, never renewed; revoked at the provider. Telegram bot token, Bluesky app password. */
|
|
48
|
+
| 'static'
|
|
49
|
+
/** Renewed by the provider's own protocol, not OAuth2's. AT Proto refreshJwt. */
|
|
50
|
+
| 'session';
|
|
51
|
+
/** Decrypted credential payload. Interpreted per `shape`; never leaves the node. */
|
|
52
|
+
export interface ConnectionCredential {
|
|
53
|
+
shape: CredentialShape;
|
|
54
|
+
/** oauth2/session: the token used on a call. static: the whole secret. */
|
|
55
|
+
accessToken: string;
|
|
56
|
+
/** oauth2/session only. Absent for `static`. */
|
|
57
|
+
refreshToken?: string;
|
|
58
|
+
/** Anything provider-specific the recipe needs back (Bluesky DID, Telegram chat id, ...). */
|
|
59
|
+
extra?: Record<string, string>;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* One account at one provider. `principal` + `provider` + `externalId` is the natural key: the same
|
|
63
|
+
* person may hold several accounts at one provider, and `externalId` is what stops the same account
|
|
64
|
+
* being connected twice as two rows.
|
|
65
|
+
*/
|
|
66
|
+
export interface ConnectionRecord {
|
|
67
|
+
id: string;
|
|
68
|
+
/** GHII of whoever connected it. Always via resolveIdentity(), never req.auth!.sub. */
|
|
69
|
+
principal: string;
|
|
70
|
+
mode: ConnectionMode;
|
|
71
|
+
/** Registry key, never free text. */
|
|
72
|
+
provider: string;
|
|
73
|
+
/**
|
|
74
|
+
* Only set when the provider is not a single endpoint (Mastodon). The value comes from the user,
|
|
75
|
+
* so it is validated and normalised on write and every call to it goes through safeFetch.
|
|
76
|
+
*/
|
|
77
|
+
instance: string | null;
|
|
78
|
+
/** What the user sees, e.g. `@jouni@mastodon.social`. Fetched from the provider, never typed. */
|
|
79
|
+
accountLabel: string;
|
|
80
|
+
/** The provider's own id for the account. Dedupe key; not shown. */
|
|
81
|
+
externalId: string;
|
|
82
|
+
/** Ciphertext `iv:tag:ct` of a JSON ConnectionCredential. Never in any response. */
|
|
83
|
+
credential: string;
|
|
84
|
+
credentialShape: CredentialShape;
|
|
85
|
+
/** Provider's own scope vocabulary. Never exposed to an app (K1). */
|
|
86
|
+
scopes: string[];
|
|
87
|
+
/** null is a valid state, not a bug: some providers issue tokens that do not expire. */
|
|
88
|
+
expiresAt: string | null;
|
|
89
|
+
status: ConnectionStatus;
|
|
90
|
+
lastOkAt: string | null;
|
|
91
|
+
/** Why it stopped working, in words a person can act on. */
|
|
92
|
+
lastError: string | null;
|
|
93
|
+
createdAt: string;
|
|
94
|
+
updatedAt: string;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* What an app is allowed to see (decision K1). Enough to name the account in a picker and to show
|
|
98
|
+
* that it needs attention; not enough to reason about the provider's scope vocabulary, whose
|
|
99
|
+
* meaning an app cannot know. Capability questions go through a `can(capability)` ask instead.
|
|
100
|
+
*/
|
|
101
|
+
export interface PublicConnection {
|
|
102
|
+
id: string;
|
|
103
|
+
provider: string;
|
|
104
|
+
mode: ConnectionMode;
|
|
105
|
+
accountLabel: string;
|
|
106
|
+
status: ConnectionStatus;
|
|
107
|
+
}
|
|
108
|
+
/** Whether a publish waits for the channel owner before it leaves the node. */
|
|
109
|
+
export type ModerationMode = 'hold' | 'auto';
|
|
110
|
+
/**
|
|
111
|
+
* Shared mode only: ONE named action over one connection, with the parameters the app may not
|
|
112
|
+
* choose already decided.
|
|
113
|
+
*
|
|
114
|
+
* The point of the indirection is that an app calls the delegation, never the connection. It cannot
|
|
115
|
+
* retarget the channel, the visibility or the playlist because those are not its parameters. A
|
|
116
|
+
* delegation is a narrow errand, not a power of attorney over the owner's account.
|
|
117
|
+
*/
|
|
118
|
+
export interface DelegationRecord {
|
|
119
|
+
id: string;
|
|
120
|
+
connectionId: string;
|
|
121
|
+
/** The app this errand is for. One delegation per (connection, app, action). */
|
|
122
|
+
appId: string;
|
|
123
|
+
/** Recipe-defined, e.g. `publish-video`. */
|
|
124
|
+
action: string;
|
|
125
|
+
/** Parameters the app may NOT override. Merged over whatever the app sends. */
|
|
126
|
+
fixed: Record<string, unknown>;
|
|
127
|
+
/**
|
|
128
|
+
* Per-publisher ceiling, keyed on the publisher's GHII — which is only possible because a shared
|
|
129
|
+
* publish requires an identified user. Without it one publisher drains a provider quota that is
|
|
130
|
+
* shared by everyone: YouTube's daily allowance is per project, not per user.
|
|
131
|
+
*/
|
|
132
|
+
perUserLimit: {
|
|
133
|
+
count: number;
|
|
134
|
+
windowHours: number;
|
|
135
|
+
} | null;
|
|
136
|
+
moderation: ModerationMode;
|
|
137
|
+
/** The one-gesture stop. Flipping this halts every publisher at once. */
|
|
138
|
+
enabled: boolean;
|
|
139
|
+
createdAt: string;
|
|
140
|
+
updatedAt: string;
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* A publish, written BEFORE it is attempted.
|
|
144
|
+
*
|
|
145
|
+
* That order is the whole point. A retry that races a slow success publishes the video twice, and
|
|
146
|
+
* this repository has produced that same family of bug three times already (ORIGAMI's applyDirect
|
|
147
|
+
* among them). The idempotency key makes the second attempt return the first one's outcome instead
|
|
148
|
+
* of doing the work again.
|
|
149
|
+
*
|
|
150
|
+
* It doubles as the attribution record — a shared channel's owner has to be able to say which of
|
|
151
|
+
* their app's users caused a given post — and as the quota ledger.
|
|
152
|
+
*/
|
|
153
|
+
export interface PublishAttempt {
|
|
154
|
+
id: string;
|
|
155
|
+
/**
|
|
156
|
+
* sha256 over principal + storageKey + connectionId + caption. Deterministic, so a retry computes
|
|
157
|
+
* the same key without having to remember anything.
|
|
158
|
+
*/
|
|
159
|
+
idempotencyKey: string;
|
|
160
|
+
/** WHO published. In shared mode this is the app's user, not the connection's principal. */
|
|
161
|
+
publisher: string;
|
|
162
|
+
connectionId: string;
|
|
163
|
+
/** null for a personal-mode publish. */
|
|
164
|
+
delegationId: string | null;
|
|
165
|
+
storageKey: string;
|
|
166
|
+
status: PublishStatus;
|
|
167
|
+
/** Provider's id for the published item, once there is one. */
|
|
168
|
+
externalRef: string | null;
|
|
169
|
+
/** Rejection reason as the provider gave it, for translating into something a person can act on. */
|
|
170
|
+
error: string | null;
|
|
171
|
+
createdAt: string;
|
|
172
|
+
updatedAt: string;
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* `held` is moderation, `queued` is a full shared quota. Both are honest waiting states rather than
|
|
176
|
+
* failures, and neither is retried as if it were one. `rejected` is the provider refusing the
|
|
177
|
+
* content — permanent, and never retried automatically.
|
|
178
|
+
*/
|
|
179
|
+
export type PublishStatus = 'in_flight' | 'held' | 'queued' | 'done' | 'failed' | 'rejected';
|
|
180
|
+
/**
|
|
181
|
+
* The client registration this node holds AT one provider instance.
|
|
182
|
+
*
|
|
183
|
+
* Not the user's token, and not `.env` either. It is the third secret in this feature: an
|
|
184
|
+
* instance-scoped provider (Mastodon) issues client credentials PER INSTANCE, and since there is no
|
|
185
|
+
* way to know which instance the next user arrives from, they cannot be configuration. The node
|
|
186
|
+
* registers itself on first contact and remembers the result so the second user from that instance
|
|
187
|
+
* reuses it.
|
|
188
|
+
*
|
|
189
|
+
* `clientSecret` is ciphertext. It is not personal data, but a table that stores a secret in the
|
|
190
|
+
* clear teaches the next table to do the same.
|
|
191
|
+
*/
|
|
192
|
+
export interface ProviderClientRecord {
|
|
193
|
+
id: string;
|
|
194
|
+
provider: string;
|
|
195
|
+
/** Instance origin, normalised and validated: it comes from a user, so it is an SSRF vector. */
|
|
196
|
+
instance: string;
|
|
197
|
+
clientId: string;
|
|
198
|
+
clientSecret: string;
|
|
199
|
+
registeredAt: string;
|
|
200
|
+
}
|
|
201
|
+
/** Rows a caller may set when opening an attempt; the rest is the store's business. */
|
|
202
|
+
export type NewPublishAttempt = Pick<PublishAttempt, 'id' | 'idempotencyKey' | 'publisher' | 'connectionId' | 'delegationId' | 'storageKey' | 'status'>;
|
|
203
|
+
//# sourceMappingURL=connection-schemas.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"connection-schemas.d.ts","sourceRoot":"","sources":["../../../src/models/connection-schemas.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAEH,0EAA0E;AAC1E,MAAM,MAAM,cAAc,GAAG,UAAU,GAAG,QAAQ,CAAC;AAEnD;;;GAGG;AACH,MAAM,MAAM,gBAAgB,GAAG,QAAQ,GAAG,cAAc,GAAG,SAAS,CAAC;AAErE;;;;GAIG;AACH,MAAM,MAAM,eAAe;AACzB,qGAAqG;AACnG,QAAQ;AACV,oGAAoG;GAClG,QAAQ;AACV,iFAAiF;GAC/E,SAAS,CAAC;AAEd,oFAAoF;AACpF,MAAM,WAAW,oBAAoB;IACnC,KAAK,EAAE,eAAe,CAAC;IACvB,0EAA0E;IAC1E,WAAW,EAAE,MAAM,CAAC;IACpB,gDAAgD;IAChD,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,6FAA6F;IAC7F,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAChC;AAED;;;;GAIG;AACH,MAAM,WAAW,gBA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,GAAG,YAAY,GAAG,QAAQ,CAClG,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file connection-schemas.ts
|
|
3
|
+
* @description Types for outbound connections (TARGET-057, aimeat-connect): a principal's own
|
|
4
|
+
* account at an EXTERNAL service, held by the node so nothing else has to hold it.
|
|
5
|
+
*
|
|
6
|
+
* The distinction this file exists to keep straight is the one the first spec draft got wrong.
|
|
7
|
+
* `principal` is WHOEVER CONNECTED THE ACCOUNT, which in a multi-user app is the app's USER, not
|
|
8
|
+
* the app's owner. The field is deliberately not called `owner`: that word already means the
|
|
9
|
+
* account layer in AIMEAT, and reusing it here produced a model that could not carry a multi-user
|
|
10
|
+
* app at all. See design doc-t057-modes.
|
|
11
|
+
*
|
|
12
|
+
* Two modes, and the second one is not a later addition:
|
|
13
|
+
* - `personal` — the user connected their own account; only they use it.
|
|
14
|
+
* - `shared` — an app owner connected a channel and DELEGATED a named action over it. The
|
|
15
|
+
* delegation, not the connection, is what an app calls. Its constraints
|
|
16
|
+
* (per-user cap, moderation, attribution) change the schema, which is why both
|
|
17
|
+
* modes ship together.
|
|
18
|
+
*
|
|
19
|
+
* The credential itself never appears in this file's read shapes. `ConnectionRecord.credential`
|
|
20
|
+
* is ciphertext (`iv:tag:ct` from services/encryption.ts) and `PublicConnection` is what an app
|
|
21
|
+
* is allowed to see.
|
|
22
|
+
* @structure
|
|
23
|
+
* - ConnectionMode / ConnectionStatus / CredentialShape — the three enums
|
|
24
|
+
* - ConnectionRecord — the stored row, credential encrypted
|
|
25
|
+
* - PublicConnection — the app-facing projection (K1: no scopes, no expiry)
|
|
26
|
+
* - DelegationRecord — shared-mode only: one named action with fixed parameters
|
|
27
|
+
* - PublishAttempt — idempotency key + attribution + quota accounting, written BEFORE the attempt
|
|
28
|
+
* @usage import type { ConnectionRecord } from '../models/connection-schemas.js';
|
|
29
|
+
* @version-history
|
|
30
|
+
* v1.0.0 — 2026-08-02 — TARGET-057 Phase 1.
|
|
31
|
+
*/
|
|
32
|
+
export {};
|
|
33
|
+
//# sourceMappingURL=connection-schemas.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"connection-schemas.js","sourceRoot":"","sources":["../../../src/models/connection-schemas.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG"}
|
|
@@ -9,6 +9,10 @@
|
|
|
9
9
|
* @version-history
|
|
10
10
|
* Text limits raised — 2026-07-30 — prompts/labels to 10 000 and bodies to 200 000.
|
|
11
11
|
* v1.0.0 -- 2026-06-16 -- Initial creation for user-to-user messaging (layer 2: local messaging).
|
|
12
|
+
* v1.2.0 -- 2026-08-01 -- Voice messages: an attachment may carry `duration_seconds` and a
|
|
13
|
+
* `transcript`. Both are optional and additive, but the schema HAD to learn them — zod strips
|
|
14
|
+
* unknown keys, so a sender's transcript would otherwise have vanished silently between the
|
|
15
|
+
* request body and the stored record.
|
|
12
16
|
* v1.1.0 -- 2026-06-23 -- Interactive messages: InteractivePayloadSchema + `interactive` on send.
|
|
13
17
|
*/
|
|
14
18
|
import { z } from 'zod';
|
|
@@ -31,6 +35,18 @@ export declare const MessageAttachmentInputSchema: z.ZodObject<{
|
|
|
31
35
|
name: z.ZodOptional<z.ZodString>;
|
|
32
36
|
inline: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
33
37
|
id: z.ZodOptional<z.ZodString>;
|
|
38
|
+
duration_seconds: z.ZodOptional<z.ZodNumber>;
|
|
39
|
+
transcript: z.ZodOptional<z.ZodObject<{
|
|
40
|
+
text: z.ZodString;
|
|
41
|
+
by: z.ZodOptional<z.ZodEnum<{
|
|
42
|
+
sender: "sender";
|
|
43
|
+
recipient: "recipient";
|
|
44
|
+
}>>;
|
|
45
|
+
model: z.ZodOptional<z.ZodString>;
|
|
46
|
+
lang: z.ZodOptional<z.ZodString>;
|
|
47
|
+
seconds: z.ZodOptional<z.ZodNumber>;
|
|
48
|
+
at: z.ZodOptional<z.ZodString>;
|
|
49
|
+
}, z.core.$strip>>;
|
|
34
50
|
}, z.core.$strip>;
|
|
35
51
|
/** One selectable option in an interactive question. */
|
|
36
52
|
export declare const InteractiveOptionSchema: z.ZodObject<{
|
|
@@ -103,6 +119,18 @@ export declare const MessageSendSchema: z.ZodObject<{
|
|
|
103
119
|
name: z.ZodOptional<z.ZodString>;
|
|
104
120
|
inline: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
105
121
|
id: z.ZodOptional<z.ZodString>;
|
|
122
|
+
duration_seconds: z.ZodOptional<z.ZodNumber>;
|
|
123
|
+
transcript: z.ZodOptional<z.ZodObject<{
|
|
124
|
+
text: z.ZodString;
|
|
125
|
+
by: z.ZodOptional<z.ZodEnum<{
|
|
126
|
+
sender: "sender";
|
|
127
|
+
recipient: "recipient";
|
|
128
|
+
}>>;
|
|
129
|
+
model: z.ZodOptional<z.ZodString>;
|
|
130
|
+
lang: z.ZodOptional<z.ZodString>;
|
|
131
|
+
seconds: z.ZodOptional<z.ZodNumber>;
|
|
132
|
+
at: z.ZodOptional<z.ZodString>;
|
|
133
|
+
}, z.core.$strip>>;
|
|
106
134
|
}, z.core.$strip>>>;
|
|
107
135
|
interactive: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
108
136
|
role: z.ZodLiteral<"questions">;
|
|
@@ -158,6 +186,18 @@ export declare const BroadcastSendSchema: z.ZodObject<{
|
|
|
158
186
|
name: z.ZodOptional<z.ZodString>;
|
|
159
187
|
inline: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
160
188
|
id: z.ZodOptional<z.ZodString>;
|
|
189
|
+
duration_seconds: z.ZodOptional<z.ZodNumber>;
|
|
190
|
+
transcript: z.ZodOptional<z.ZodObject<{
|
|
191
|
+
text: z.ZodString;
|
|
192
|
+
by: z.ZodOptional<z.ZodEnum<{
|
|
193
|
+
sender: "sender";
|
|
194
|
+
recipient: "recipient";
|
|
195
|
+
}>>;
|
|
196
|
+
model: z.ZodOptional<z.ZodString>;
|
|
197
|
+
lang: z.ZodOptional<z.ZodString>;
|
|
198
|
+
seconds: z.ZodOptional<z.ZodNumber>;
|
|
199
|
+
at: z.ZodOptional<z.ZodString>;
|
|
200
|
+
}, z.core.$strip>>;
|
|
161
201
|
}, z.core.$strip>>>;
|
|
162
202
|
interactive: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
163
203
|
role: z.ZodLiteral<"questions">;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"message-schemas.d.ts","sourceRoot":"","sources":["../../../src/models/message-schemas.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"message-schemas.d.ts","sourceRoot":"","sources":["../../../src/models/message-schemas.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;;;;GAKG;AACH,eAAO,MAAM,4BAA4B;;;;;;;;;;;;;;;;;;;;;;;;;iBA2BvC,CAAC;AAIH,wDAAwD;AACxD,eAAO,MAAM,uBAAuB;;;iBAGlC,CAAC;AAEH,wEAAwE;AACxE,eAAO,MAAM,yBAAyB;;;;;;;;;;;iBAQpC,CAAC;AAEH,kGAAkG;AAClG,eAAO,MAAM,uBAAuB;;;iBAGlC,CAAC;AAEH;;;GAGG;AACH,eAAO,MAAM,wBAAwB;;;;;;;;;;;;;;;;;;;;;;;;2BAanC,CAAC;AAEH,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAiB7B,CAAC;AAIF;;uEAEuE;AACvE,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAc/B,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAC;AACjE,MAAM,MAAM,sBAAsB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,4BAA4B,CAAC,CAAC;AAClF,MAAM,MAAM,uBAAuB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,wBAAwB,CAAC,CAAC;AAC/E,MAAM,MAAM,wBAAwB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,yBAAyB,CAAC,CAAC;AACjF,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC"}
|
|
@@ -9,6 +9,10 @@
|
|
|
9
9
|
* @version-history
|
|
10
10
|
* Text limits raised — 2026-07-30 — prompts/labels to 10 000 and bodies to 200 000.
|
|
11
11
|
* v1.0.0 -- 2026-06-16 -- Initial creation for user-to-user messaging (layer 2: local messaging).
|
|
12
|
+
* v1.2.0 -- 2026-08-01 -- Voice messages: an attachment may carry `duration_seconds` and a
|
|
13
|
+
* `transcript`. Both are optional and additive, but the schema HAD to learn them — zod strips
|
|
14
|
+
* unknown keys, so a sender's transcript would otherwise have vanished silently between the
|
|
15
|
+
* request body and the stored record.
|
|
12
16
|
* v1.1.0 -- 2026-06-23 -- Interactive messages: InteractivePayloadSchema + `interactive` on send.
|
|
13
17
|
*/
|
|
14
18
|
import { z } from 'zod';
|
|
@@ -26,6 +30,25 @@ export const MessageAttachmentInputSchema = z.object({
|
|
|
26
30
|
name: z.string().max(256).optional(),
|
|
27
31
|
inline: z.boolean().optional().default(false),
|
|
28
32
|
id: z.string().min(1).max(64).optional(),
|
|
33
|
+
/** Playing length of an audio/video attachment, measured by the sender's browser. Lets a thread
|
|
34
|
+
* show "0:14" before any bytes are fetched. */
|
|
35
|
+
duration_seconds: z.number().nonnegative().max(86_400).optional(),
|
|
36
|
+
/**
|
|
37
|
+
* A transcript the SENDER attached. It travels with the message, so the recipient reads a voice
|
|
38
|
+
* message without paying for their own transcription.
|
|
39
|
+
*
|
|
40
|
+
* `by` is accepted here only because the shape is shared with the stored record; the send path
|
|
41
|
+
* overwrites it with 'sender'. A recipient's own transcript never arrives over the wire — it is
|
|
42
|
+
* written to their own copy of the message and nowhere else.
|
|
43
|
+
*/
|
|
44
|
+
transcript: z.object({
|
|
45
|
+
text: z.string().max(20_000),
|
|
46
|
+
by: z.enum(['sender', 'recipient']).optional(),
|
|
47
|
+
model: z.string().max(128).optional(),
|
|
48
|
+
lang: z.string().max(16).optional(),
|
|
49
|
+
seconds: z.number().nonnegative().max(86_400).optional(),
|
|
50
|
+
at: z.string().max(40).optional(),
|
|
51
|
+
}).optional(),
|
|
29
52
|
});
|
|
30
53
|
// ── Interactive messages (federated AskUserQuestion) ──
|
|
31
54
|
/** One selectable option in an interactive question. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"message-schemas.js","sourceRoot":"","sources":["../../../src/models/message-schemas.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"message-schemas.js","sourceRoot":"","sources":["../../../src/models/message-schemas.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;;;;GAKG;AACH,MAAM,CAAC,MAAM,4BAA4B,GAAG,CAAC,CAAC,MAAM,CAAC;IACnD,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC;IACvC,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC;IAChC,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,WAAW,EAAE;IACpC,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;IACjD,IAAI,EAAE,CAAC,CAAC,MAA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
|
|
|
34
34
|
* import { aiProvenanceRouter } from './routes/ai-provenance.js';
|
|
35
35
|
* app.use(aiProvenanceRouter(config, storage));
|
|
36
36
|
* @version-history
|
|
37
|
+
* v1.3.0 — 2026-08-02 — GET /v1/provenance/:id is content-negotiated. A visible AI label's
|
|
38
|
+
* "how this was made" link lands here, so a PERSON arrives — and the route answered
|
|
39
|
+
* application/json to everyone, leaving the correction procedure it offers stranded in
|
|
40
|
+
* `next_actions`. A browser now gets services/ai-provenance-page.ts; everything else is
|
|
41
|
+
* unchanged. The identical-404 rule is carried over: the HTML variant takes no argument
|
|
42
|
+
* about the record, so it has nothing to differ on.
|
|
37
43
|
* v1.2.0 — 2026-08-01 — TARGET-058 Phase 3. A declaration that attaches to a memory key
|
|
38
44
|
* pre-renders its disclosure block against THAT key's visibility instead of the private default,
|
|
39
45
|
* so a record attached to a public key stops claiming no label is owed.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ai-provenance.d.ts","sourceRoot":"","sources":["../../../src/routes/ai-provenance.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"ai-provenance.d.ts","sourceRoot":"","sources":["../../../src/routes/ai-provenance.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgDG;AACH,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAGjC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AACjD,OAAO,KAAK,EAAE,OAAO,EAAyB,MAAM,yBAAyB,CAAC;AA+C9E,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,YAAY,EAAE,OAAO,EAAE,OAAO,GAAG,MAAM,CAkNjF"}
|
|
@@ -34,6 +34,12 @@
|
|
|
34
34
|
* import { aiProvenanceRouter } from './routes/ai-provenance.js';
|
|
35
35
|
* app.use(aiProvenanceRouter(config, storage));
|
|
36
36
|
* @version-history
|
|
37
|
+
* v1.3.0 — 2026-08-02 — GET /v1/provenance/:id is content-negotiated. A visible AI label's
|
|
38
|
+
* "how this was made" link lands here, so a PERSON arrives — and the route answered
|
|
39
|
+
* application/json to everyone, leaving the correction procedure it offers stranded in
|
|
40
|
+
* `next_actions`. A browser now gets services/ai-provenance-page.ts; everything else is
|
|
41
|
+
* unchanged. The identical-404 rule is carried over: the HTML variant takes no argument
|
|
42
|
+
* about the record, so it has nothing to differ on.
|
|
37
43
|
* v1.2.0 — 2026-08-01 — TARGET-058 Phase 3. A declaration that attaches to a memory key
|
|
38
44
|
* pre-renders its disclosure block against THAT key's visibility instead of the private default,
|
|
39
45
|
* so a record attached to a public key stops claiming no label is owed.
|
|
@@ -49,6 +55,9 @@ import { success, error } from '../middleware/envelope.js';
|
|
|
49
55
|
import { resolveIdentity, ownerGhiiOf } from '../utils/gaii.js';
|
|
50
56
|
import { AI_PROVENANCE_LEVELS, AI_PROVENANCE_METHODS, AI_HUMAN_INVOLVEMENT, AI_UPSTREAM_MARKS, AiProvenanceSourceSchema, CONTENT_HASH_PATTERN, aiProvenanceJsonSchema, AI_PROVENANCE_SCHEMA_PATH, } from '../models/ai-provenance-schemas.js';
|
|
51
57
|
import { mintProvenance, projectForDetail, publiclyResolvable } from '../services/ai-provenance.js';
|
|
58
|
+
import { prefersHtmlPage } from '../services/markdown-negotiation.js';
|
|
59
|
+
import { provenancePage, provenanceNotFoundPage } from '../services/ai-provenance-page.js';
|
|
60
|
+
import { detectLocale } from '../i18n.js';
|
|
52
61
|
/**
|
|
53
62
|
* What a principal may DECLARE about content it produced elsewhere. Note what is absent: `spec`,
|
|
54
63
|
* `generatedAt` defaults, `attestation` and `disclosure` are the service's to fill, and there is no
|
|
@@ -156,11 +165,35 @@ export function aiProvenanceRouter(config, storage) {
|
|
|
156
165
|
// anything public points at it. Publishing the content makes this resolve; unpublishing takes
|
|
157
166
|
// it straight back to the 404 below, with nothing to remember to do.
|
|
158
167
|
const isPublic = !!row && !isOwner && (await publiclyResolvable(storage, [row.id])).has(row.id);
|
|
168
|
+
// A person may be reading this: the visible label's "details" link lands here. Negotiated the
|
|
169
|
+
// same way /v1/ai-transparency does — only a client that ranks text/html ABOVE application/json
|
|
170
|
+
// gets the page, which is what a browser does and what curl, fetch() and agents do not.
|
|
171
|
+
const asPage = prefersHtmlPage(req);
|
|
172
|
+
res.vary('Accept');
|
|
159
173
|
// ONE 404 for all of "no such record", "not yours" and "its content is not public". Different
|
|
160
|
-
// answers here would turn this endpoint into an oracle for which ids exist on this node
|
|
174
|
+
// answers here would turn this endpoint into an oracle for which ids exist on this node — and
|
|
175
|
+
// the HTML branch has to be equally uninformative or it reopens what this closed. Same status,
|
|
176
|
+
// same single code path, no variant that says more.
|
|
161
177
|
if (!row || (!isPublic && !isOwner)) {
|
|
178
|
+
if (asPage) {
|
|
179
|
+
return res.status(404).type('html').send(provenanceNotFoundPage({
|
|
180
|
+
baseUrl: config.baseUrl, locale: detectLocale(req.headers['accept-language']),
|
|
181
|
+
}));
|
|
182
|
+
}
|
|
162
183
|
return res.status(404).json(error(config.nodeId, 'NOT_FOUND', 'No such provenance record.'));
|
|
163
184
|
}
|
|
185
|
+
// `serve(row, isOwner)` FIRST, then render: the page shows exactly what the JSON would have
|
|
186
|
+
// served this caller. Rendering from the raw row would widen the owner projection in the one
|
|
187
|
+
// format nobody diffs.
|
|
188
|
+
if (asPage) {
|
|
189
|
+
// `.provenance` off the SAME projection the JSON branch sends — not `row.record`. One
|
|
190
|
+
// expression decides what this caller may see, in both formats.
|
|
191
|
+
return res.type('html').send(provenancePage(serve(row, isOwner).provenance, {
|
|
192
|
+
baseUrl: config.baseUrl,
|
|
193
|
+
locale: detectLocale(req.headers['accept-language']),
|
|
194
|
+
recordUrl: `${config.baseUrl.replace(/\/+$/, '')}/v1/provenance/${row.id}`,
|
|
195
|
+
}));
|
|
196
|
+
}
|
|
164
197
|
// The correction procedure, offered where a person actually arrives: a visible label's "details"
|
|
165
198
|
// link lands here, so this is the one page where somebody who thinks a label is wrong or missing
|
|
166
199
|
// already has the identifier in front of them (Code of Practice Section 2, Commitment 2).
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ai-provenance.js","sourceRoot":"","sources":["../../../src/routes/ai-provenance.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"ai-provenance.js","sourceRoot":"","sources":["../../../src/routes/ai-provenance.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgDG;AACH,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAEjC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAClE,OAAO,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC;AACxD,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,2BAA2B,CAAC;AAC3D,OAAO,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAChE,OAAO,EACL,oBAAoB,EAAE,qBAAqB,EAAE,oBAAoB,EAAE,iBAAiB,EACpF,wBAAwB,EAAE,oBAAoB,EAAE,sBAAsB,EAAE,yBAAyB,GAClG,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AACpG,OAAO,EAAE,eAAe,EAAE,MAAM,qCAAqC,CAAC;AACtE,OAAO,EAAE,cAAc,EAAE,sBAAsB,EAAE,MAAM,mCAAmC,CAAC;AAC3F,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAG1C;;;;GAIG;AACH,MAAM,uBAAuB,GAAG,CAAC,CAAC,MAAM,CAAC;IACvC,KAAK,EAAE,CAAC,CAAC,IAAI,CAAC,oBAAoB,CAAC;IACnC,gBAAgB,EAAE,CAAC,CAAC,IAAI,CAAC,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AM,OAAO,CAAC,SAAS,CAAC,EAAE,GAAG,QAAQ,EAAE,cAAc,EAAE,GAAG,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC;YACxG,CAAC;QACH,CAAC;QAED,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,GAAG,EAAE,IAAI,CAAC,EAAE;YAC5D,EAAE,WAAW,EAAE,qBAAqB,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,EAAE,kBAAkB,GAAG,CAAC,EAAE,EAAE,EAAE;YACtF,GAAG,CAAC,GAAG,CAAC,WAAW;gBACjB,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,4BAA4B,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,EAAE,0BAA0B,GAAG,CAAC,WAAW,CAAC,OAAO,CAAC,SAAS,EAAE,EAAE,CAAC,EAAE,EAAE,CAAC;gBACzI,CAAC,CAAC,EAAE,CAAC;SACR,CAAC,CAAC,CAAC;IACN,CAAC,CAAC,CAAC;IAEL,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
package/dist/src/routes/ai.d.ts
CHANGED
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
* this router is a thin HTTP wrapper + the owner-only settings/usage endpoints.
|
|
9
9
|
* @structure
|
|
10
10
|
* - POST /v1/ai/complete — owner or any token with ai:use scope, runs one completion
|
|
11
|
+
* - POST /v1/ai/transcribe — same gate, speech-to-text over a stored (or inline) audio file
|
|
11
12
|
* - GET /v1/ai/available — owner or ai:use token, boolean "is AI configured?" probe
|
|
12
13
|
* - GET /v1/ai/usage — owner-only, today's spend per-app breakdown
|
|
13
14
|
* - GET /v1/ai/usage/history — owner-only, per-day spend series + 24h/7d/30d rollups (charts)
|
|
@@ -28,6 +29,10 @@
|
|
|
28
29
|
* GET /v1/ai/available so such apps can gate their UI without owner-only settings.
|
|
29
30
|
* v1.4.0 — 2026-07-05 — Add GET /v1/ai/usage/history (owner per-day series + rollups) and
|
|
30
31
|
* GET /v1/admin/ai-usage (operator cross-user aggregate) backing the AI-spend charts.
|
|
32
|
+
* v1.6.0 — 2026-08-01 — POST /v1/ai/transcribe: speech-to-text on the owner's own key, behind the
|
|
33
|
+
* same gate, the same daily budget and the same usage ledger as completions. Audio comes from a
|
|
34
|
+
* storage key resolved against the CALLER's namespace (an inline base64 fallback is capped hard),
|
|
35
|
+
* so the endpoint cannot be pointed at another account's files.
|
|
31
36
|
* v1.5.0 — 2026-08-01 — TARGET-058: /v1/ai/complete carries the minted provenance record in
|
|
32
37
|
* `meta.provenance` and in the AI-Disclosure / Link response headers. The `data` shape is
|
|
33
38
|
* untouched, so nothing that reads `content` changes.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ai.d.ts","sourceRoot":"","sources":["../../../src/routes/ai.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"ai.d.ts","sourceRoot":"","sources":["../../../src/routes/ai.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACH,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAEjC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AACjD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAiBvD,wBAAgB,QAAQ,CAAC,MAAM,EAAE,YAAY,EAAE,OAAO,EAAE,OAAO,GAAG,MAAM,CAiTvE"}
|