@aithos/sdk 0.1.0-alpha.5 → 0.1.0-alpha.50

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (67) hide show
  1. package/README.md +245 -7
  2. package/dist/src/apps.d.ts +224 -0
  3. package/dist/src/apps.js +432 -0
  4. package/dist/src/assets.d.ts +208 -0
  5. package/dist/src/assets.js +534 -0
  6. package/dist/src/auth-api.d.ts +219 -0
  7. package/dist/src/auth-api.js +248 -0
  8. package/dist/src/auth.d.ts +543 -0
  9. package/dist/src/auth.js +937 -31
  10. package/dist/src/compute.d.ts +464 -6
  11. package/dist/src/compute.js +746 -20
  12. package/dist/src/data-schema-contacts-v1.d.ts +14 -0
  13. package/dist/src/data-schema-contacts-v1.js +28 -0
  14. package/dist/src/data.d.ts +342 -0
  15. package/dist/src/data.js +1002 -0
  16. package/dist/src/endpoints.d.ts +18 -0
  17. package/dist/src/endpoints.js +6 -0
  18. package/dist/src/ethos.d.ts +85 -0
  19. package/dist/src/ethos.js +463 -7
  20. package/dist/src/index.d.ts +17 -6
  21. package/dist/src/index.js +25 -3
  22. package/dist/src/internal/delegate-bundle.js +7 -2
  23. package/dist/src/internal/envelope.d.ts +93 -0
  24. package/dist/src/internal/envelope.js +59 -0
  25. package/dist/src/mandates.d.ts +111 -2
  26. package/dist/src/mandates.js +150 -7
  27. package/dist/src/react/AithosAsset.d.ts +66 -0
  28. package/dist/src/react/AithosAsset.js +67 -0
  29. package/dist/src/react/context.d.ts +29 -0
  30. package/dist/src/react/context.js +31 -0
  31. package/dist/src/react/index.d.ts +29 -0
  32. package/dist/src/react/index.js +31 -0
  33. package/dist/src/react/use-aithos-asset.d.ts +39 -0
  34. package/dist/src/react/use-aithos-asset.js +118 -0
  35. package/dist/src/react/use-transcribe-pending.d.ts +21 -0
  36. package/dist/src/react/use-transcribe-pending.js +47 -0
  37. package/dist/src/sdk.d.ts +10 -0
  38. package/dist/src/sdk.js +22 -0
  39. package/dist/src/transcribe-resilience.d.ts +57 -0
  40. package/dist/src/transcribe-resilience.js +203 -0
  41. package/dist/src/web.d.ts +279 -0
  42. package/dist/src/web.js +186 -0
  43. package/dist/test/auth-j3.test.js +32 -1
  44. package/dist/test/canonical-conformance.test.d.ts +2 -0
  45. package/dist/test/canonical-conformance.test.js +86 -0
  46. package/dist/test/compute-delegate-path.test.d.ts +2 -0
  47. package/dist/test/compute-delegate-path.test.js +183 -0
  48. package/dist/test/compute.test.js +4 -0
  49. package/dist/test/endpoints.test.js +25 -1
  50. package/dist/test/envelope-core-conformance.test.d.ts +2 -0
  51. package/dist/test/envelope-core-conformance.test.js +75 -0
  52. package/dist/test/envelope.test.d.ts +2 -0
  53. package/dist/test/envelope.test.js +318 -0
  54. package/dist/test/ethos-first-edition.test.d.ts +2 -0
  55. package/dist/test/ethos-first-edition.test.js +371 -0
  56. package/dist/test/mandates-compute.test.d.ts +2 -0
  57. package/dist/test/mandates-compute.test.js +256 -0
  58. package/dist/test/sdk.test.js +10 -2
  59. package/dist/test/signup-bootstrap.test.d.ts +2 -0
  60. package/dist/test/signup-bootstrap.test.js +311 -0
  61. package/dist/test/transcribe-invoke.test.d.ts +2 -0
  62. package/dist/test/transcribe-invoke.test.js +204 -0
  63. package/dist/test/transcribe.test.d.ts +2 -0
  64. package/dist/test/transcribe.test.js +186 -0
  65. package/dist/test/web.test.d.ts +2 -0
  66. package/dist/test/web.test.js +270 -0
  67. package/package.json +20 -3
@@ -10,11 +10,29 @@ 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
+ * Personal Data Store base URL — the `aithos.data.*` sub-protocol PDS
22
+ * (and the assets sub-protocol, which shares the same host). Default
23
+ * `https://pds.aithos.be`. Previously every app had to pass a raw
24
+ * `execute-api` URL to `createDataClient` / `createAssetsClient`; this
25
+ * centralizes it on the vanity domain (CloudFront-fronted, same as the
26
+ * other surfaces). Override for self-hosting or staging.
27
+ */
28
+ readonly pds: string;
13
29
  }
14
30
  /** Production defaults. */
15
31
  export declare const DEFAULT_SDK_ENDPOINTS: AithosSdkEndpoints;
16
32
  /** Compose the full compute-invoke URL: `${compute}/v1/invoke`. */
17
33
  export declare function computeInvokeUrl(endpoints: AithosSdkEndpoints): string;
34
+ /** Compose the full web-extract URL: `${web}/v1/invoke`. */
35
+ export declare function webInvokeUrl(endpoints: AithosSdkEndpoints): string;
18
36
  /** Compose the full top-up-checkout URL: `${wallet}/v1/wallet/topup/checkout`. */
19
37
  export declare function walletTopupCheckoutUrl(endpoints: AithosSdkEndpoints): string;
20
38
  /**
@@ -4,11 +4,17 @@
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",
7
9
  };
8
10
  /** Compose the full compute-invoke URL: `${compute}/v1/invoke`. */
9
11
  export function computeInvokeUrl(endpoints) {
10
12
  return `${trimSlash(endpoints.compute)}/v1/invoke`;
11
13
  }
14
+ /** Compose the full web-extract URL: `${web}/v1/invoke`. */
15
+ export function webInvokeUrl(endpoints) {
16
+ return `${trimSlash(endpoints.web)}/v1/invoke`;
17
+ }
12
18
  /** Compose the full top-up-checkout URL: `${wallet}/v1/wallet/topup/checkout`. */
13
19
  export function walletTopupCheckoutUrl(endpoints) {
14
20
  return `${trimSlash(endpoints.wallet)}/v1/wallet/topup/checkout`;
@@ -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;