@k9o/extension-client 0.0.0-stage → 1.5.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/CHANGELOG.md ADDED
@@ -0,0 +1,15 @@
1
+ # @k9o/extension-client — Changelog
2
+
3
+ ## 1.5.0 (unreleased)
4
+
5
+ ### Changed
6
+
7
+ - The package is renamed from `@k9o/extensions` to `@k9o/extension-client`, so its name says its job: calling an installed extension by slug. `k9o.extension(slug)` in `@k9o/core` is unchanged. The runtime package for writing an extension is `@k9o/extension-runtime`.
8
+
9
+ ### Removed
10
+
11
+ - The `cairn` binding, its `./cairn` import and the `CairnExtension` type. The extension it described has been retired. `ExtensionSlug` is now `"paperless"`.
12
+
13
+ ### Changed
14
+
15
+ - README and package description rewritten to describe what the package contains.
package/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/NOTICE ADDED
@@ -0,0 +1,4 @@
1
+ Kilimanjaro SDK
2
+ Copyright 2026 Formelo Inc.
3
+
4
+ This product is licensed under the Apache License, Version 2.0 (see LICENSE).
package/README.md CHANGED
@@ -1,3 +1,146 @@
1
- # Temporary Holding Version
1
+ # @k9o/extension-client
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Official extensions client for [Kilimanjaro](#54-about-kilimanjaro).
4
+
5
+ Typed bindings for platform extensions, resolved by slug with `k9o.extension(slug)`. The bindings define the typed contract for each extension's methods. Calls are not served yet: every method rejects with an error before any request is sent. To write an extension, use [`@k9o/extension-runtime`](https://www.npmjs.com/package/@k9o/extension-runtime).
6
+
7
+ ## Contents
8
+
9
+ **A. Get started**
10
+
11
+ 1. [Links](#1-links)
12
+ 2. [Install](#2-install)
13
+ 3. [Quick start](#3-quick-start)
14
+ - 3.1 [When a method is not available yet](#31-when-a-method-is-not-available-yet)
15
+
16
+ **B. Use extensions**
17
+
18
+ 4. [Using through @k9o/core](#4-using-through-k9ocore)
19
+
20
+ **C. Reference**
21
+
22
+ 5. [Appendix](#5-appendix)
23
+ - 5.1 [Find extensions](#51-find-extensions)
24
+ - 5.2 [Imports](#52-imports)
25
+ - 5.3 [Related packages](#53-related-packages)
26
+ - 5.4 [About Kilimanjaro](#54-about-kilimanjaro)
27
+ 6. [License](#6-license)
28
+
29
+ ## A. Get started
30
+
31
+ ### 1. Links
32
+
33
+ - Website: <https://kilimanjaro.dev>
34
+ - Documentation / Developer Hub: <https://docs.kilimanjaro.dev>
35
+ - API: <https://api.k9o.io>
36
+ - Console: <https://console.k9o.io>
37
+ - Open source
38
+ - Platform: <https://github.com/k9o-platform>
39
+ - Community: <https://github.com/k9o-community>
40
+
41
+ ### 2. Install
42
+
43
+ ```bash
44
+ npm install @k9o/extension-client
45
+ ```
46
+
47
+ ```bash
48
+ bun add @k9o/extension-client
49
+ ```
50
+
51
+ ```bash
52
+ pnpm add @k9o/extension-client
53
+ ```
54
+
55
+ Requires TypeScript 5.6 or newer for the bundled types.
56
+
57
+ ### 3. Quick start
58
+
59
+ Resolve a binding by slug, then call its methods. For example, sending a WhatsApp message through an installed extension (illustrative):
60
+
61
+ ```ts
62
+ import { k9o } from "@k9o/extension-client";
63
+
64
+ const whatsapp = k9o.extension("whatsapp");
65
+
66
+ const message = await whatsapp.messages.send({
67
+ to: "+255700000000",
68
+ text: "Your order has shipped.",
69
+ });
70
+
71
+ console.log(message.id);
72
+ ```
73
+
74
+ ```text
75
+ wamid.HBgLMjU1NzAwMDAwMDAVAgARGBI5
76
+ ```
77
+
78
+ The returned object is typed for the extension you name, and an unknown slug is a compile-time error. Calls are not served yet; see [When a method is not available yet](#31-when-a-method-is-not-available-yet).
79
+
80
+ #### 3.1 When a method is not available yet
81
+
82
+ Every method rejects with an `Error` before any request is sent:
83
+
84
+ ```ts
85
+ const stripe = k9o.extension("stripe");
86
+
87
+ try {
88
+ await stripe.invalidMethod.init();
89
+ } catch (error) {
90
+ console.log(`Output: ${error instanceof Error ? error.message : error}`);
91
+ }
92
+ ```
93
+
94
+ ```text
95
+ Output: stripe.invalidMethod.init is not available yet: the extension runtime is not implemented in this version of @k9o/extension-client.
96
+ ```
97
+
98
+ An unknown slug also throws an `Error` at runtime. Each extension's methods are documented in [Find extensions](#51-find-extensions).
99
+
100
+ ## B. Use extensions
101
+
102
+ ### 4. Using through @k9o/core
103
+
104
+ `@k9o/core` exposes the same factory as `k9o.extensions.extension(slug)`.
105
+
106
+ ## C. Reference
107
+
108
+ ### 5. Appendix
109
+
110
+ #### 5.1 Find extensions
111
+
112
+ Extensions and their documentation are published in the community: <https://github.com/k9o-community/>. Each extension lists its methods there.
113
+
114
+ #### 5.2 Imports
115
+
116
+ | Import | What it gives you |
117
+ | --- | --- |
118
+ | `@k9o/extension-client` | `k9o`, plus the types `ExtensionSlug` and `Extension`. |
119
+ | `@k9o/extension-client/<slug>` | One extension's binding and types, for example `@k9o/extension-client/paperless`. |
120
+
121
+ #### 5.3 Related packages
122
+
123
+ | Package | What it does |
124
+ | --- | --- |
125
+ | `@k9o/extension-runtime` | The runtime client for writing an extension. |
126
+ | `@k9o/extension-manifest` | Declaring an extension's manifest. |
127
+ | `@k9o/core` | The full platform client. |
128
+ | `@k9o/gate` | End-user identity and JWT verification. |
129
+ | `@k9o/kibo` | Vault and key operations. |
130
+
131
+ #### 5.4 About Kilimanjaro
132
+
133
+ Kilimanjaro is a modular developer platform for building secure enterprise applications. You define AI agents, functions and data pipelines
134
+ on the platform. The SDKs let you deploy and invoke them, read and write your data, publish to and subscribe to streams, sign users in, and
135
+ encrypt with keys you hold.
136
+
137
+ It provides four building blocks:
138
+
139
+ - **Keep**: AI security and governance. Guardrails and policy for the agents you run.
140
+ - **Pulse**: data intelligence and real-time stream processing. Streams, analytics and live feeds.
141
+ - **Gate**: customer identity and access management. Sign-in and sessions, and automatic data scoping so a signed-in user reaches only their own data.
142
+ - **Kibo**: cryptographic keys and secrets management. Client-side encryption with keys you hold, and a secrets vault.
143
+
144
+ ### 6. License
145
+
146
+ Apache-2.0 © Formelo Inc. See `LICENSE` and `NOTICE`.
@@ -0,0 +1,21 @@
1
+ // src/extensions/paperless.ts
2
+ var stub = (op) => {
3
+ return () => Promise.reject(
4
+ new Error(
5
+ `paperless.${op} is not available yet: the extension runtime is not implemented in this version of @k9o/extension-client.`
6
+ )
7
+ );
8
+ };
9
+ var paperlessExtension = {
10
+ documents: {
11
+ uploadAndOcr: stub("documents.uploadAndOcr")
12
+ },
13
+ workspace: {
14
+ init: stub("workspace.init")
15
+ }
16
+ };
17
+
18
+ export {
19
+ paperlessExtension
20
+ };
21
+ //# sourceMappingURL=chunk-6WZDBPXA.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/extensions/paperless.ts"],"sourcesContent":["/**\n * The `paperless` extension's typed binding: document upload with OCR, and workspace initialisation.\n *\n * The typed contract is available now. Calls are not served yet: every method rejects with an error that says so.\n */\n\n/** Document upload + OCR result shape. */\nexport type UploadAndOcrResult = {\n documentId: string;\n ocrText: string;\n pages: number;\n language: string | null;\n};\n\n/** The workspace-init response. The `version: 2` marker is required; the rest of the shape is set by the extension. */\nexport type WorkspaceInitResponse = {\n version: 2;\n [key: string]: unknown;\n};\n\n/** Typed binding interface for the `paperless` extension. */\nexport interface PaperlessExtension {\n documents: {\n uploadAndOcr(params: {\n buffer: Uint8Array | ArrayBuffer;\n filename: string;\n language?: string;\n }): Promise<UploadAndOcrResult>;\n };\n workspace: {\n init(): Promise<WorkspaceInitResponse>;\n };\n}\n\n/** Runtime stub: every method rejects until per-method runtime calls are implemented. */\nconst stub = (op: string): (() => Promise<never>) => {\n return (): Promise<never> =>\n Promise.reject(\n new Error(\n `paperless.${op} is not available yet: the extension runtime is not implemented in this version of @k9o/extension-client.`,\n ),\n );\n};\n\nexport const paperlessExtension: PaperlessExtension = {\n documents: {\n uploadAndOcr: stub(\"documents.uploadAndOcr\") as PaperlessExtension[\"documents\"][\"uploadAndOcr\"],\n },\n workspace: {\n init: stub(\"workspace.init\") as PaperlessExtension[\"workspace\"][\"init\"],\n },\n};\n"],"mappings":";AAmCA,IAAM,OAAO,CAAC,OAAuC;AACnD,SAAO,MACL,QAAQ;AAAA,IACN,IAAI;AAAA,MACF,aAAa,EAAE;AAAA,IACjB;AAAA,EACF;AACJ;AAEO,IAAM,qBAAyC;AAAA,EACpD,WAAW;AAAA,IACT,cAAc,KAAK,wBAAwB;AAAA,EAC7C;AAAA,EACA,WAAW;AAAA,IACT,MAAM,KAAK,gBAAgB;AAAA,EAC7B;AACF;","names":[]}
@@ -0,0 +1,33 @@
1
+ /**
2
+ * The `paperless` extension's typed binding: document upload with OCR, and workspace initialisation.
3
+ *
4
+ * The typed contract is available now. Calls are not served yet: every method rejects with an error that says so.
5
+ */
6
+ /** Document upload + OCR result shape. */
7
+ type UploadAndOcrResult = {
8
+ documentId: string;
9
+ ocrText: string;
10
+ pages: number;
11
+ language: string | null;
12
+ };
13
+ /** The workspace-init response. The `version: 2` marker is required; the rest of the shape is set by the extension. */
14
+ type WorkspaceInitResponse = {
15
+ version: 2;
16
+ [key: string]: unknown;
17
+ };
18
+ /** Typed binding interface for the `paperless` extension. */
19
+ interface PaperlessExtension {
20
+ documents: {
21
+ uploadAndOcr(params: {
22
+ buffer: Uint8Array | ArrayBuffer;
23
+ filename: string;
24
+ language?: string;
25
+ }): Promise<UploadAndOcrResult>;
26
+ };
27
+ workspace: {
28
+ init(): Promise<WorkspaceInitResponse>;
29
+ };
30
+ }
31
+ declare const paperlessExtension: PaperlessExtension;
32
+
33
+ export { type PaperlessExtension, type UploadAndOcrResult, type WorkspaceInitResponse, paperlessExtension };
@@ -0,0 +1,7 @@
1
+ import {
2
+ paperlessExtension
3
+ } from "../chunk-6WZDBPXA.js";
4
+ export {
5
+ paperlessExtension
6
+ };
7
+ //# sourceMappingURL=paperless.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -0,0 +1,28 @@
1
+ import { PaperlessExtension } from './extensions/paperless.js';
2
+
3
+ /**
4
+ * `@k9o/extension-client` — typed bindings for Kilimanjaro platform extensions.
5
+ *
6
+ * `k9o.extension(slug)` returns the typed binding for an extension, resolved by slug:
7
+ *
8
+ * ```typescript
9
+ * import { k9o } from "@k9o/extension-client";
10
+ *
11
+ * const paperless = k9o.extension("paperless");
12
+ * const result = await paperless.documents.uploadAndOcr({ buffer, filename });
13
+ * ```
14
+ *
15
+ * The bindings define the typed contract. Calls are not served yet: every method rejects with an error before any
16
+ * request is sent. To write an extension, use `@k9o/extension-runtime`.
17
+ */
18
+
19
+ /** The slugs of the extensions this package has typed bindings for. */
20
+ type ExtensionSlug = "paperless";
21
+ /** The typed binding for a slug. */
22
+ type Extension<S extends ExtensionSlug> = S extends "paperless" ? PaperlessExtension : never;
23
+ declare const k9o: {
24
+ /** The typed binding for an extension, resolved by slug (for example `paperless`). Throws an `Error` for a slug this package has no binding for. */
25
+ readonly extension: <S extends ExtensionSlug>(slug: S) => Extension<S>;
26
+ };
27
+
28
+ export { type Extension, type ExtensionSlug, PaperlessExtension, k9o };
package/dist/index.js ADDED
@@ -0,0 +1,22 @@
1
+ import {
2
+ paperlessExtension
3
+ } from "./chunk-6WZDBPXA.js";
4
+
5
+ // src/index.ts
6
+ var REGISTRY = {
7
+ paperless: paperlessExtension
8
+ };
9
+ var k9o = {
10
+ /** The typed binding for an extension, resolved by slug (for example `paperless`). Throws an `Error` for a slug this package has no binding for. */
11
+ extension(slug) {
12
+ const bound = REGISTRY[slug];
13
+ if (bound === void 0) {
14
+ throw new Error(`Extension "${slug}" not found in @k9o/extension-client baked-in catalogue.`);
15
+ }
16
+ return bound;
17
+ }
18
+ };
19
+ export {
20
+ k9o
21
+ };
22
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["/**\n * `@k9o/extension-client` — typed bindings for Kilimanjaro platform extensions.\n *\n * `k9o.extension(slug)` returns the typed binding for an extension, resolved by slug:\n *\n * ```typescript\n * import { k9o } from \"@k9o/extension-client\";\n *\n * const paperless = k9o.extension(\"paperless\");\n * const result = await paperless.documents.uploadAndOcr({ buffer, filename });\n * ```\n *\n * The bindings define the typed contract. Calls are not served yet: every method rejects with an error before any\n * request is sent. To write an extension, use `@k9o/extension-runtime`.\n */\n\nimport { paperlessExtension, type PaperlessExtension } from \"./extensions/paperless.ts\";\n\n/** The slugs of the extensions this package has typed bindings for. */\nexport type ExtensionSlug = \"paperless\";\n\n/** The typed binding for a slug. */\nexport type Extension<S extends ExtensionSlug> = S extends \"paperless\" ? PaperlessExtension : never;\n\nconst REGISTRY: { readonly [K in ExtensionSlug]: Extension<K> } = {\n paperless: paperlessExtension,\n};\n\nexport const k9o = {\n /** The typed binding for an extension, resolved by slug (for example `paperless`). Throws an `Error` for a slug this package has no binding for. */\n extension<S extends ExtensionSlug>(slug: S): Extension<S> {\n const bound = REGISTRY[slug];\n if (bound === undefined) {\n throw new Error(`Extension \"${slug}\" not found in @k9o/extension-client baked-in catalogue.`);\n }\n return bound;\n },\n} as const;\n\nexport type { PaperlessExtension } from \"./extensions/paperless.ts\";\n"],"mappings":";;;;;AAwBA,IAAM,WAA4D;AAAA,EAChE,WAAW;AACb;AAEO,IAAM,MAAM;AAAA;AAAA,EAEjB,UAAmC,MAAuB;AACxD,UAAM,QAAQ,SAAS,IAAI;AAC3B,QAAI,UAAU,QAAW;AACvB,YAAM,IAAI,MAAM,cAAc,IAAI,0DAA0D;AAAA,IAC9F;AACA,WAAO;AAAA,EACT;AACF;","names":[]}
package/package.json CHANGED
@@ -1,6 +1,43 @@
1
1
  {
2
2
  "name": "@k9o/extension-client",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "1.5.0",
4
+ "description": "Typed bindings for Kilimanjaro platform extensions, resolved by slug with k9o.extension(slug).",
5
+ "type": "module",
6
+ "main": "./dist/index.js",
7
+ "types": "./dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "import": "./dist/index.js",
12
+ "default": "./dist/index.js"
13
+ },
14
+ "./paperless": {
15
+ "types": "./dist/extensions/paperless.d.ts",
16
+ "import": "./dist/extensions/paperless.js",
17
+ "default": "./dist/extensions/paperless.js"
18
+ }
19
+ },
20
+ "files": [
21
+ "src",
22
+ "LICENSE",
23
+ "NOTICE",
24
+ "README.md",
25
+ "CHANGELOG.md",
26
+ "dist"
27
+ ],
28
+ "license": "Apache-2.0",
29
+ "homepage": "https://kilimanjaro.dev",
30
+ "publishConfig": {
31
+ "access": "public"
32
+ },
33
+ "repository": {
34
+ "type": "git",
35
+ "url": "https://github.com/k9o-platform",
36
+ "directory": "packages/extensions"
37
+ },
38
+ "devDependencies": {
39
+ "bun-types": "^1.1.0",
40
+ "typescript": "^5.6.0"
41
+ },
42
+ "module": "./dist/index.js"
43
+ }
@@ -0,0 +1,52 @@
1
+ /**
2
+ * The `paperless` extension's typed binding: document upload with OCR, and workspace initialisation.
3
+ *
4
+ * The typed contract is available now. Calls are not served yet: every method rejects with an error that says so.
5
+ */
6
+
7
+ /** Document upload + OCR result shape. */
8
+ export type UploadAndOcrResult = {
9
+ documentId: string;
10
+ ocrText: string;
11
+ pages: number;
12
+ language: string | null;
13
+ };
14
+
15
+ /** The workspace-init response. The `version: 2` marker is required; the rest of the shape is set by the extension. */
16
+ export type WorkspaceInitResponse = {
17
+ version: 2;
18
+ [key: string]: unknown;
19
+ };
20
+
21
+ /** Typed binding interface for the `paperless` extension. */
22
+ export interface PaperlessExtension {
23
+ documents: {
24
+ uploadAndOcr(params: {
25
+ buffer: Uint8Array | ArrayBuffer;
26
+ filename: string;
27
+ language?: string;
28
+ }): Promise<UploadAndOcrResult>;
29
+ };
30
+ workspace: {
31
+ init(): Promise<WorkspaceInitResponse>;
32
+ };
33
+ }
34
+
35
+ /** Runtime stub: every method rejects until per-method runtime calls are implemented. */
36
+ const stub = (op: string): (() => Promise<never>) => {
37
+ return (): Promise<never> =>
38
+ Promise.reject(
39
+ new Error(
40
+ `paperless.${op} is not available yet: the extension runtime is not implemented in this version of @k9o/extension-client.`,
41
+ ),
42
+ );
43
+ };
44
+
45
+ export const paperlessExtension: PaperlessExtension = {
46
+ documents: {
47
+ uploadAndOcr: stub("documents.uploadAndOcr") as PaperlessExtension["documents"]["uploadAndOcr"],
48
+ },
49
+ workspace: {
50
+ init: stub("workspace.init") as PaperlessExtension["workspace"]["init"],
51
+ },
52
+ };
package/src/index.ts ADDED
@@ -0,0 +1,40 @@
1
+ /**
2
+ * `@k9o/extension-client` — typed bindings for Kilimanjaro platform extensions.
3
+ *
4
+ * `k9o.extension(slug)` returns the typed binding for an extension, resolved by slug:
5
+ *
6
+ * ```typescript
7
+ * import { k9o } from "@k9o/extension-client";
8
+ *
9
+ * const paperless = k9o.extension("paperless");
10
+ * const result = await paperless.documents.uploadAndOcr({ buffer, filename });
11
+ * ```
12
+ *
13
+ * The bindings define the typed contract. Calls are not served yet: every method rejects with an error before any
14
+ * request is sent. To write an extension, use `@k9o/extension-runtime`.
15
+ */
16
+
17
+ import { paperlessExtension, type PaperlessExtension } from "./extensions/paperless.ts";
18
+
19
+ /** The slugs of the extensions this package has typed bindings for. */
20
+ export type ExtensionSlug = "paperless";
21
+
22
+ /** The typed binding for a slug. */
23
+ export type Extension<S extends ExtensionSlug> = S extends "paperless" ? PaperlessExtension : never;
24
+
25
+ const REGISTRY: { readonly [K in ExtensionSlug]: Extension<K> } = {
26
+ paperless: paperlessExtension,
27
+ };
28
+
29
+ export const k9o = {
30
+ /** The typed binding for an extension, resolved by slug (for example `paperless`). Throws an `Error` for a slug this package has no binding for. */
31
+ extension<S extends ExtensionSlug>(slug: S): Extension<S> {
32
+ const bound = REGISTRY[slug];
33
+ if (bound === undefined) {
34
+ throw new Error(`Extension "${slug}" not found in @k9o/extension-client baked-in catalogue.`);
35
+ }
36
+ return bound;
37
+ },
38
+ } as const;
39
+
40
+ export type { PaperlessExtension } from "./extensions/paperless.ts";