@aithos/sdk 0.1.0-alpha.5 → 0.1.0-alpha.51
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/README.md +245 -7
- package/dist/src/apps.d.ts +224 -0
- package/dist/src/apps.js +432 -0
- package/dist/src/assets.d.ts +209 -0
- package/dist/src/assets.js +534 -0
- package/dist/src/auth-api.d.ts +219 -0
- package/dist/src/auth-api.js +248 -0
- package/dist/src/auth.d.ts +543 -0
- package/dist/src/auth.js +937 -31
- package/dist/src/compute.d.ts +464 -6
- package/dist/src/compute.js +746 -20
- package/dist/src/data-schema-contacts-v1.d.ts +14 -0
- package/dist/src/data-schema-contacts-v1.js +28 -0
- package/dist/src/data.d.ts +342 -0
- package/dist/src/data.js +1002 -0
- package/dist/src/endpoints.d.ts +25 -0
- package/dist/src/endpoints.js +7 -0
- package/dist/src/ethos.d.ts +85 -0
- package/dist/src/ethos.js +463 -7
- package/dist/src/index.d.ts +17 -6
- package/dist/src/index.js +25 -3
- package/dist/src/internal/delegate-bundle.js +7 -2
- package/dist/src/internal/envelope.d.ts +93 -0
- package/dist/src/internal/envelope.js +59 -0
- package/dist/src/mandates.d.ts +111 -2
- package/dist/src/mandates.js +150 -7
- package/dist/src/react/AithosAsset.d.ts +66 -0
- package/dist/src/react/AithosAsset.js +67 -0
- package/dist/src/react/context.d.ts +29 -0
- package/dist/src/react/context.js +31 -0
- package/dist/src/react/index.d.ts +29 -0
- package/dist/src/react/index.js +31 -0
- package/dist/src/react/use-aithos-asset.d.ts +39 -0
- package/dist/src/react/use-aithos-asset.js +118 -0
- package/dist/src/react/use-transcribe-pending.d.ts +21 -0
- package/dist/src/react/use-transcribe-pending.js +47 -0
- package/dist/src/sdk.d.ts +10 -0
- package/dist/src/sdk.js +22 -0
- package/dist/src/transcribe-resilience.d.ts +57 -0
- package/dist/src/transcribe-resilience.js +203 -0
- package/dist/src/web.d.ts +279 -0
- package/dist/src/web.js +186 -0
- package/dist/test/auth-j3.test.js +32 -1
- package/dist/test/canonical-conformance.test.d.ts +2 -0
- package/dist/test/canonical-conformance.test.js +86 -0
- package/dist/test/compute-delegate-path.test.d.ts +2 -0
- package/dist/test/compute-delegate-path.test.js +183 -0
- package/dist/test/compute.test.js +4 -0
- package/dist/test/endpoints.test.js +30 -1
- package/dist/test/envelope-core-conformance.test.d.ts +2 -0
- package/dist/test/envelope-core-conformance.test.js +75 -0
- package/dist/test/envelope.test.d.ts +2 -0
- package/dist/test/envelope.test.js +318 -0
- package/dist/test/ethos-first-edition.test.d.ts +2 -0
- package/dist/test/ethos-first-edition.test.js +371 -0
- package/dist/test/mandates-compute.test.d.ts +2 -0
- package/dist/test/mandates-compute.test.js +256 -0
- package/dist/test/sdk.test.js +11 -2
- package/dist/test/signup-bootstrap.test.d.ts +2 -0
- package/dist/test/signup-bootstrap.test.js +311 -0
- package/dist/test/transcribe-invoke.test.d.ts +2 -0
- package/dist/test/transcribe-invoke.test.js +204 -0
- package/dist/test/transcribe.test.d.ts +2 -0
- package/dist/test/transcribe.test.js +186 -0
- package/dist/test/web.test.d.ts +2 -0
- package/dist/test/web.test.js +270 -0
- package/package.json +20 -3
package/dist/src/endpoints.d.ts
CHANGED
|
@@ -10,11 +10,36 @@ export interface AithosSdkEndpoints {
|
|
|
10
10
|
* suffixes a fixed path to it.
|
|
11
11
|
*/
|
|
12
12
|
readonly wallet: string;
|
|
13
|
+
/**
|
|
14
|
+
* Web extractor proxy base URL — `aithos.web_extract`. Default
|
|
15
|
+
* `https://extract.aithos.be`. Same JSON-RPC + signed-envelope shape
|
|
16
|
+
* as the compute proxy, distinct audience so a mandate can hold one
|
|
17
|
+
* scope without the other.
|
|
18
|
+
*/
|
|
19
|
+
readonly web: string;
|
|
20
|
+
/**
|
|
21
|
+
* Data PDS base URL — the `aithos.data.*` sub-protocol Personal Data Store.
|
|
22
|
+
* Default `https://pds.aithos.be`. Previously every app had to pass a raw
|
|
23
|
+
* `execute-api` URL to `createDataClient`; this centralizes it on the vanity
|
|
24
|
+
* domain (CloudFront-fronted, same as the other surfaces). Used by
|
|
25
|
+
* `createDataClient` / `createDelegateDataClient` / `createAppendDataClient`.
|
|
26
|
+
* Override for self-hosting or staging.
|
|
27
|
+
*/
|
|
28
|
+
readonly pds: string;
|
|
29
|
+
/**
|
|
30
|
+
* Assets PDS base URL — the assets sub-protocol. This is a **separate** API
|
|
31
|
+
* Gateway from the data PDS (it exposes the same `/mcp/primitives/...` paths,
|
|
32
|
+
* so it needs its own host). Default `https://assets.aithos.be`. Used by
|
|
33
|
+
* `createAssetsClient`. Override for self-hosting or staging.
|
|
34
|
+
*/
|
|
35
|
+
readonly assets: string;
|
|
13
36
|
}
|
|
14
37
|
/** Production defaults. */
|
|
15
38
|
export declare const DEFAULT_SDK_ENDPOINTS: AithosSdkEndpoints;
|
|
16
39
|
/** Compose the full compute-invoke URL: `${compute}/v1/invoke`. */
|
|
17
40
|
export declare function computeInvokeUrl(endpoints: AithosSdkEndpoints): string;
|
|
41
|
+
/** Compose the full web-extract URL: `${web}/v1/invoke`. */
|
|
42
|
+
export declare function webInvokeUrl(endpoints: AithosSdkEndpoints): string;
|
|
18
43
|
/** Compose the full top-up-checkout URL: `${wallet}/v1/wallet/topup/checkout`. */
|
|
19
44
|
export declare function walletTopupCheckoutUrl(endpoints: AithosSdkEndpoints): string;
|
|
20
45
|
/**
|
package/dist/src/endpoints.js
CHANGED
|
@@ -4,11 +4,18 @@
|
|
|
4
4
|
export const DEFAULT_SDK_ENDPOINTS = {
|
|
5
5
|
compute: "https://compute.aithos.be",
|
|
6
6
|
wallet: "https://wallet.aithos.be",
|
|
7
|
+
web: "https://extract.aithos.be",
|
|
8
|
+
pds: "https://pds.aithos.be",
|
|
9
|
+
assets: "https://assets.aithos.be",
|
|
7
10
|
};
|
|
8
11
|
/** Compose the full compute-invoke URL: `${compute}/v1/invoke`. */
|
|
9
12
|
export function computeInvokeUrl(endpoints) {
|
|
10
13
|
return `${trimSlash(endpoints.compute)}/v1/invoke`;
|
|
11
14
|
}
|
|
15
|
+
/** Compose the full web-extract URL: `${web}/v1/invoke`. */
|
|
16
|
+
export function webInvokeUrl(endpoints) {
|
|
17
|
+
return `${trimSlash(endpoints.web)}/v1/invoke`;
|
|
18
|
+
}
|
|
12
19
|
/** Compose the full top-up-checkout URL: `${wallet}/v1/wallet/topup/checkout`. */
|
|
13
20
|
export function walletTopupCheckoutUrl(endpoints) {
|
|
14
21
|
return `${trimSlash(endpoints.wallet)}/v1/wallet/topup/checkout`;
|
package/dist/src/ethos.d.ts
CHANGED
|
@@ -71,6 +71,44 @@ export declare class EthosClient {
|
|
|
71
71
|
* so the next read picks up the fresh edition.
|
|
72
72
|
*/
|
|
73
73
|
publish(): Promise<PublishResult>;
|
|
74
|
+
/**
|
|
75
|
+
* Idempotently ensure the subject's Ethos has at least one published
|
|
76
|
+
* edition. Required because a **delegate** cannot bootstrap a first
|
|
77
|
+
* edition (the first edition's manifest is signed with the owner's
|
|
78
|
+
* public-sphere key, which delegates do not have). Without an initial
|
|
79
|
+
* owner-published edition, subsequent delegate writes via
|
|
80
|
+
* {@link publish} fail with `not found: edition for did:…`.
|
|
81
|
+
*
|
|
82
|
+
* Semantics:
|
|
83
|
+
* - If an edition already exists (owner OR delegate OR anonymous mode),
|
|
84
|
+
* this is a NO-OP and returns `{ alreadyInitialized: true }`.
|
|
85
|
+
* - If no edition exists AND the actor is the owner, this stages and
|
|
86
|
+
* publishes a height=1 edition containing a single sentinel section
|
|
87
|
+
* `aithos-init` in the `public` zone, then returns
|
|
88
|
+
* `{ alreadyInitialized: false, editionHeight: 1 }`. Any previously
|
|
89
|
+
* staged mutations on this client are preserved and NOT auto-flushed.
|
|
90
|
+
* - If no edition exists AND the actor is NOT the owner (delegate or
|
|
91
|
+
* anonymous), throws `ethos_bootstrap_not_owner` — only the owner
|
|
92
|
+
* can sign a first edition.
|
|
93
|
+
*
|
|
94
|
+
* Call site: typically the owner's dashboard, right after sign-in and
|
|
95
|
+
* before any delegate-mode write (e.g. before triggering a backend
|
|
96
|
+
* worker that holds a mandate). Idempotent ⇒ safe to call on every
|
|
97
|
+
* mount.
|
|
98
|
+
*
|
|
99
|
+
* Implementation note: this routes through {@link #publishFirstEditionOwner}
|
|
100
|
+
* which the SDK already uses internally when {@link publish} detects a
|
|
101
|
+
* fresh Ethos with staged owner mutations. ensureInitialized() exposes
|
|
102
|
+
* the same code path as an explicit primitive, so the caller doesn't
|
|
103
|
+
* need to stage a mutation just to trigger first-edition logic.
|
|
104
|
+
*/
|
|
105
|
+
ensureInitialized(): Promise<{
|
|
106
|
+
alreadyInitialized: true;
|
|
107
|
+
} | {
|
|
108
|
+
alreadyInitialized: false;
|
|
109
|
+
editionHeight: number;
|
|
110
|
+
manifestHash: string;
|
|
111
|
+
}>;
|
|
74
112
|
_readZone(zone: ZoneName): Promise<readonly Section[]>;
|
|
75
113
|
_stageAdd(zone: ZoneName, input: AddSectionInput): void;
|
|
76
114
|
_stageUpdate(zone: ZoneName, sectionId: string, patch: UpdateSectionPatch): void;
|
|
@@ -85,6 +123,53 @@ export declare class EthosZone {
|
|
|
85
123
|
addSection(input: AddSectionInput): void;
|
|
86
124
|
updateSection(sectionId: string, patch: UpdateSectionPatch): void;
|
|
87
125
|
deleteSection(sectionId: string): void;
|
|
126
|
+
/**
|
|
127
|
+
* Return every section in this zone whose `title` is exactly `title`.
|
|
128
|
+
*
|
|
129
|
+
* Match is exact and case-sensitive. The result is always an array — it
|
|
130
|
+
* may be empty (no match), have one element (the typical case), or have
|
|
131
|
+
* more than one element when the author has happened to publish two
|
|
132
|
+
* sections with the same title. Section titles are not required by the
|
|
133
|
+
* protocol to be unique within a zone.
|
|
134
|
+
*
|
|
135
|
+
* The order of returned sections is the zone's authored order
|
|
136
|
+
* (`sections()` ordering, spec §2.5.2).
|
|
137
|
+
*
|
|
138
|
+
* @param title Section title to look up — exact, case-sensitive.
|
|
139
|
+
*/
|
|
140
|
+
findSectionsByTitle(title: string): Promise<readonly Section[]>;
|
|
141
|
+
/**
|
|
142
|
+
* Stage an update for **every** section in this zone whose `title`
|
|
143
|
+
* matches `title` exactly. Returns the list of section IDs that were
|
|
144
|
+
* staged — empty when nothing matched.
|
|
145
|
+
*
|
|
146
|
+
* Apply with `client.publish()` like any other staged mutation. The
|
|
147
|
+
* staged entries are identical to what `updateSection(id, patch)` would
|
|
148
|
+
* produce, one per matched section, so `pendingChanges()` /
|
|
149
|
+
* `discard()` behave normally.
|
|
150
|
+
*
|
|
151
|
+
* Note: this method does NOT throw when there is no match — it returns
|
|
152
|
+
* `[]`. That's intentional: callers driven by an LLM frequently want to
|
|
153
|
+
* upsert (try update, then fall back to add) and shouldn't have to
|
|
154
|
+
* catch.
|
|
155
|
+
*
|
|
156
|
+
* @param title Section title to look up — exact, case-sensitive.
|
|
157
|
+
* @param patch Same patch shape accepted by `updateSection`.
|
|
158
|
+
* @returns Array of `section.id` strings whose updates were staged.
|
|
159
|
+
*/
|
|
160
|
+
updateSectionsByTitle(title: string, patch: UpdateSectionPatch): Promise<readonly string[]>;
|
|
161
|
+
/**
|
|
162
|
+
* Stage a delete for **every** section in this zone whose `title`
|
|
163
|
+
* matches `title` exactly. Returns the list of section IDs that were
|
|
164
|
+
* staged — empty when nothing matched.
|
|
165
|
+
*
|
|
166
|
+
* Same semantics as {@link updateSectionsByTitle}: silent on no-match,
|
|
167
|
+
* apply with `client.publish()`.
|
|
168
|
+
*
|
|
169
|
+
* @param title Section title to look up — exact, case-sensitive.
|
|
170
|
+
* @returns Array of `section.id` strings whose deletes were staged.
|
|
171
|
+
*/
|
|
172
|
+
deleteSectionsByTitle(title: string): Promise<readonly string[]>;
|
|
88
173
|
}
|
|
89
174
|
export interface EthosNamespaceDeps {
|
|
90
175
|
readonly auth: AithosAuth;
|