@k9o/extensions 0.0.0-stage → 1.1.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/LICENSE +201 -0
- package/NOTICE +4 -0
- package/README.md +95 -2
- package/dist/chunk-72WCKHWA.js +21 -0
- package/dist/chunk-72WCKHWA.js.map +1 -0
- package/dist/chunk-MIBROCBJ.js +24 -0
- package/dist/chunk-MIBROCBJ.js.map +1 -0
- package/dist/extensions/cairn.d.ts +64 -0
- package/dist/extensions/cairn.js +7 -0
- package/dist/extensions/cairn.js.map +1 -0
- package/dist/extensions/paperless.d.ts +37 -0
- package/dist/extensions/paperless.js +7 -0
- package/dist/extensions/paperless.js.map +1 -0
- package/dist/index.d.ts +61 -0
- package/dist/index.js +35 -0
- package/dist/index.js.map +1 -0
- package/package.json +45 -4
- package/src/extensions/cairn.ts +66 -0
- package/src/extensions/paperless.ts +59 -0
- package/src/index.ts +85 -0
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
package/README.md
CHANGED
|
@@ -1,3 +1,96 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @k9o/extensions
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Typed bindings for Kilimanjaro platform extensions, resolved by slug with `k9o.extension(slug)`.
|
|
4
|
+
|
|
5
|
+
## Contents
|
|
6
|
+
|
|
7
|
+
- [Install](#install)
|
|
8
|
+
- [Quick start](#quick-start)
|
|
9
|
+
- [Current limitations](#current-limitations)
|
|
10
|
+
- [Using through @k9o/core](#using-through-k9ocore)
|
|
11
|
+
- [Appendix](#appendix)
|
|
12
|
+
|
|
13
|
+
## Install
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
npm install @k9o/extensions
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
bun add @k9o/extensions
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
pnpm add @k9o/extensions
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Requires TypeScript 5.6+ for the bundled types. See [Requirements](#requirements).
|
|
28
|
+
|
|
29
|
+
## Quick start
|
|
30
|
+
|
|
31
|
+
```ts
|
|
32
|
+
import { k9o } from "@k9o/extensions";
|
|
33
|
+
|
|
34
|
+
const cairn = k9o.extension("cairn");
|
|
35
|
+
|
|
36
|
+
async function createTasksCollection() {
|
|
37
|
+
return cairn.collections.create({ name: "tasks", dimension: 3, metric: "cosine" });
|
|
38
|
+
}
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
- The returned object is typed for the slug you pass.
|
|
42
|
+
- An unknown slug is a compile-time error, and it also throws an `Error` at runtime.
|
|
43
|
+
- See [Methods by extension](#methods-by-extension) for what each extension offers.
|
|
44
|
+
|
|
45
|
+
## Current limitations
|
|
46
|
+
|
|
47
|
+
- In this release the bindings define the typed contract only.
|
|
48
|
+
- Calling a method rejects with an `Error` saying the runtime is not implemented.
|
|
49
|
+
- No request is sent to the platform.
|
|
50
|
+
- Until method dispatch is available, call extensions over HTTP.
|
|
51
|
+
|
|
52
|
+
## Using through @k9o/core
|
|
53
|
+
|
|
54
|
+
`@k9o/core` exposes the same factory as `client.extensions.extension(slug)`.
|
|
55
|
+
|
|
56
|
+
## Appendix
|
|
57
|
+
|
|
58
|
+
### Requirements
|
|
59
|
+
|
|
60
|
+
| Requirement | Version |
|
|
61
|
+
| --- | --- |
|
|
62
|
+
| TypeScript | 5.6 or newer |
|
|
63
|
+
|
|
64
|
+
### Methods by extension
|
|
65
|
+
|
|
66
|
+
| Extension | Method | What it does |
|
|
67
|
+
| --- | --- | --- |
|
|
68
|
+
| `paperless` | `documents.uploadAndOcr({ buffer, filename, language? })` | Uploads a document and returns its OCR text. |
|
|
69
|
+
| `paperless` | `workspace.init()` | Initializes the workspace. |
|
|
70
|
+
| `cairn` | `collections.create({ name, dimension, metric? })` | Creates a collection. |
|
|
71
|
+
| `cairn` | `collections.list()` | Lists collections. |
|
|
72
|
+
| `cairn` | `vectors.upsert({ collection, records })` | Inserts or updates vectors. |
|
|
73
|
+
| `cairn` | `vectors.query({ collection, embedding, topK?, filter? })` | Finds the nearest vectors. |
|
|
74
|
+
| `cairn` | `vectors.delete({ collection, ids })` | Deletes vectors by id. |
|
|
75
|
+
|
|
76
|
+
### Imports
|
|
77
|
+
|
|
78
|
+
| Import | What it gives you |
|
|
79
|
+
| --- | --- |
|
|
80
|
+
| `@k9o/extensions` | `k9o`, plus the types `ExtensionSlug`, `Extension`, `PaperlessExtension`, `CairnExtension`. |
|
|
81
|
+
| `@k9o/extensions/paperless` | The paperless binding. |
|
|
82
|
+
| `@k9o/extensions/cairn` | The cairn binding. |
|
|
83
|
+
|
|
84
|
+
### Related packages
|
|
85
|
+
|
|
86
|
+
| Package | What it does |
|
|
87
|
+
| --- | --- |
|
|
88
|
+
| `@k9o/core` | The full platform client. |
|
|
89
|
+
| `@k9o/gate` | End-user identity and JWT verification. |
|
|
90
|
+
| `@k9o/kibo` | Vault and key operations. |
|
|
91
|
+
|
|
92
|
+
Platform apex: https://api.k9o.io. Documentation: https://kilimanjaro.dev.
|
|
93
|
+
|
|
94
|
+
## License
|
|
95
|
+
|
|
96
|
+
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/extensions.`
|
|
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-72WCKHWA.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/extensions/paperless.ts"],"sourcesContent":["/**\n * `paperless` extension typed binding — Paperless: AI Workflows extension\n * (Trailblazer class). Brand-absorbed from\n * Formelo Inc. \"Paperless: AI Workflows\" (existing App Store product).\n *\n * The typed contract is available now. Per-method runtime calls are not implemented yet and reject\n * 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/** Workflow-init response envelope (v1 BFF guide-not-binding per\n * paperless v2.1 spec +; version: 2 envelope marker required). */\nexport type WorkspaceInitResponse = {\n version: 2;\n // Shape past `version` is BFF-author-flexible (by design);\n // mobile client consumes whatever\n // shape the BFF emits as long as the version marker is present.\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/extensions.`,\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":";AA0CA,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,24 @@
|
|
|
1
|
+
// src/extensions/cairn.ts
|
|
2
|
+
var stub = (op) => {
|
|
3
|
+
return () => Promise.reject(
|
|
4
|
+
new Error(
|
|
5
|
+
`cairn.${op} is not available yet: the extension runtime is not implemented in this version of @k9o/extensions.`
|
|
6
|
+
)
|
|
7
|
+
);
|
|
8
|
+
};
|
|
9
|
+
var cairnExtension = {
|
|
10
|
+
vectors: {
|
|
11
|
+
upsert: stub("vectors.upsert"),
|
|
12
|
+
query: stub("vectors.query"),
|
|
13
|
+
delete: stub("vectors.delete")
|
|
14
|
+
},
|
|
15
|
+
collections: {
|
|
16
|
+
create: stub("collections.create"),
|
|
17
|
+
list: stub("collections.list")
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export {
|
|
22
|
+
cairnExtension
|
|
23
|
+
};
|
|
24
|
+
//# sourceMappingURL=chunk-MIBROCBJ.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/extensions/cairn.ts"],"sourcesContent":["/**\n * `cairn` extension typed binding — Cairn: vector store / knowledge-base\n * extension (Trailblazer class). Surface stripped\n * of SQL Studio ops (SQL is core platform; canonical home is the Console\n * query-studio surface).\n *\n * The typed contract is available now. Per-method runtime calls are not implemented yet and reject\n * with an error that says so.\n */\n\n/** Vector record shape for upsert. */\nexport type VectorRecord = {\n id: string;\n embedding: number[];\n metadata?: Record<string, unknown>;\n};\n\n/** Query-result shape from semantic search. */\nexport type QueryResult = {\n id: string;\n score: number;\n metadata: Record<string, unknown> | null;\n};\n\n/** Typed binding interface for the `cairn` extension. */\nexport interface CairnExtension {\n vectors: {\n upsert(params: { collection: string; records: VectorRecord[] }): Promise<{ upserted: number }>;\n query(params: {\n collection: string;\n embedding: number[];\n topK?: number;\n filter?: Record<string, unknown>;\n }): Promise<QueryResult[]>;\n delete(params: { collection: string; ids: string[] }): Promise<{ deleted: number }>;\n };\n collections: {\n create(params: { name: string; dimension: number; metric?: \"cosine\" | \"euclidean\" | \"dot\" }): Promise<{\n name: string;\n dimension: number;\n }>;\n list(): Promise<{ collections: { name: string; dimension: number; count: number }[] }>;\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 `cairn.${op} is not available yet: the extension runtime is not implemented in this version of @k9o/extensions.`,\n ),\n );\n};\n\nexport const cairnExtension: CairnExtension = {\n vectors: {\n upsert: stub(\"vectors.upsert\") as CairnExtension[\"vectors\"][\"upsert\"],\n query: stub(\"vectors.query\") as CairnExtension[\"vectors\"][\"query\"],\n delete: stub(\"vectors.delete\") as CairnExtension[\"vectors\"][\"delete\"],\n },\n collections: {\n create: stub(\"collections.create\") as CairnExtension[\"collections\"][\"create\"],\n list: stub(\"collections.list\") as CairnExtension[\"collections\"][\"list\"],\n },\n};\n"],"mappings":";AA8CA,IAAM,OAAO,CAAC,OAAuC;AACnD,SAAO,MACL,QAAQ;AAAA,IACN,IAAI;AAAA,MACF,SAAS,EAAE;AAAA,IACb;AAAA,EACF;AACJ;AAEO,IAAM,iBAAiC;AAAA,EAC5C,SAAS;AAAA,IACP,QAAQ,KAAK,gBAAgB;AAAA,IAC7B,OAAO,KAAK,eAAe;AAAA,IAC3B,QAAQ,KAAK,gBAAgB;AAAA,EAC/B;AAAA,EACA,aAAa;AAAA,IACX,QAAQ,KAAK,oBAAoB;AAAA,IACjC,MAAM,KAAK,kBAAkB;AAAA,EAC/B;AACF;","names":[]}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `cairn` extension typed binding — Cairn: vector store / knowledge-base
|
|
3
|
+
* extension (Trailblazer class). Surface stripped
|
|
4
|
+
* of SQL Studio ops (SQL is core platform; canonical home is the Console
|
|
5
|
+
* query-studio surface).
|
|
6
|
+
*
|
|
7
|
+
* The typed contract is available now. Per-method runtime calls are not implemented yet and reject
|
|
8
|
+
* with an error that says so.
|
|
9
|
+
*/
|
|
10
|
+
/** Vector record shape for upsert. */
|
|
11
|
+
type VectorRecord = {
|
|
12
|
+
id: string;
|
|
13
|
+
embedding: number[];
|
|
14
|
+
metadata?: Record<string, unknown>;
|
|
15
|
+
};
|
|
16
|
+
/** Query-result shape from semantic search. */
|
|
17
|
+
type QueryResult = {
|
|
18
|
+
id: string;
|
|
19
|
+
score: number;
|
|
20
|
+
metadata: Record<string, unknown> | null;
|
|
21
|
+
};
|
|
22
|
+
/** Typed binding interface for the `cairn` extension. */
|
|
23
|
+
interface CairnExtension {
|
|
24
|
+
vectors: {
|
|
25
|
+
upsert(params: {
|
|
26
|
+
collection: string;
|
|
27
|
+
records: VectorRecord[];
|
|
28
|
+
}): Promise<{
|
|
29
|
+
upserted: number;
|
|
30
|
+
}>;
|
|
31
|
+
query(params: {
|
|
32
|
+
collection: string;
|
|
33
|
+
embedding: number[];
|
|
34
|
+
topK?: number;
|
|
35
|
+
filter?: Record<string, unknown>;
|
|
36
|
+
}): Promise<QueryResult[]>;
|
|
37
|
+
delete(params: {
|
|
38
|
+
collection: string;
|
|
39
|
+
ids: string[];
|
|
40
|
+
}): Promise<{
|
|
41
|
+
deleted: number;
|
|
42
|
+
}>;
|
|
43
|
+
};
|
|
44
|
+
collections: {
|
|
45
|
+
create(params: {
|
|
46
|
+
name: string;
|
|
47
|
+
dimension: number;
|
|
48
|
+
metric?: "cosine" | "euclidean" | "dot";
|
|
49
|
+
}): Promise<{
|
|
50
|
+
name: string;
|
|
51
|
+
dimension: number;
|
|
52
|
+
}>;
|
|
53
|
+
list(): Promise<{
|
|
54
|
+
collections: {
|
|
55
|
+
name: string;
|
|
56
|
+
dimension: number;
|
|
57
|
+
count: number;
|
|
58
|
+
}[];
|
|
59
|
+
}>;
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
declare const cairnExtension: CairnExtension;
|
|
63
|
+
|
|
64
|
+
export { type CairnExtension, type QueryResult, type VectorRecord, cairnExtension };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `paperless` extension typed binding — Paperless: AI Workflows extension
|
|
3
|
+
* (Trailblazer class). Brand-absorbed from
|
|
4
|
+
* Formelo Inc. "Paperless: AI Workflows" (existing App Store product).
|
|
5
|
+
*
|
|
6
|
+
* The typed contract is available now. Per-method runtime calls are not implemented yet and reject
|
|
7
|
+
* with an error that says so.
|
|
8
|
+
*/
|
|
9
|
+
/** Document upload + OCR result shape. */
|
|
10
|
+
type UploadAndOcrResult = {
|
|
11
|
+
documentId: string;
|
|
12
|
+
ocrText: string;
|
|
13
|
+
pages: number;
|
|
14
|
+
language: string | null;
|
|
15
|
+
};
|
|
16
|
+
/** Workflow-init response envelope (v1 BFF guide-not-binding per
|
|
17
|
+
* paperless v2.1 spec +; version: 2 envelope marker required). */
|
|
18
|
+
type WorkspaceInitResponse = {
|
|
19
|
+
version: 2;
|
|
20
|
+
[key: string]: unknown;
|
|
21
|
+
};
|
|
22
|
+
/** Typed binding interface for the `paperless` extension. */
|
|
23
|
+
interface PaperlessExtension {
|
|
24
|
+
documents: {
|
|
25
|
+
uploadAndOcr(params: {
|
|
26
|
+
buffer: Uint8Array | ArrayBuffer;
|
|
27
|
+
filename: string;
|
|
28
|
+
language?: string;
|
|
29
|
+
}): Promise<UploadAndOcrResult>;
|
|
30
|
+
};
|
|
31
|
+
workspace: {
|
|
32
|
+
init(): Promise<WorkspaceInitResponse>;
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
declare const paperlessExtension: PaperlessExtension;
|
|
36
|
+
|
|
37
|
+
export { type PaperlessExtension, type UploadAndOcrResult, type WorkspaceInitResponse, paperlessExtension };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { PaperlessExtension } from './extensions/paperless.js';
|
|
2
|
+
import { CairnExtension } from './extensions/cairn.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* `@k9o/extensions` — Kilimanjaro extensions consumption SDK.
|
|
6
|
+
*
|
|
7
|
+
* Hosts the `k9o.extension(slug)` typed Stack-SDK factory
|
|
8
|
+
* (installation-instance pattern PREFERRED; namespace-by-slug REJECTED; generic-invoke
|
|
9
|
+
* DROPPED for typing concern).
|
|
10
|
+
*
|
|
11
|
+
* Consumption surface (canonical TypeScript reference; per-language
|
|
12
|
+
* equivalents land in 7 server SDKs at codegen time + 4 mobile SDKs at
|
|
13
|
+
* hand-author time):
|
|
14
|
+
*
|
|
15
|
+
* ```typescript
|
|
16
|
+
* import { k9o } from "@k9o/extensions";
|
|
17
|
+
*
|
|
18
|
+
* const paperless = k9o.extension("paperless");
|
|
19
|
+
* const result = await paperless.documents.uploadAndOcr({ buffer, filename });
|
|
20
|
+
*
|
|
21
|
+
* const cairn = k9o.extension("cairn");
|
|
22
|
+
* await cairn.vectors.upsert({ collection: "knowledge", records: [...] });
|
|
23
|
+
* ```
|
|
24
|
+
*
|
|
25
|
+
* Trailblazer / Anchor / Keystone class extensions ship typed bindings
|
|
26
|
+
* baked into this package at publish time (this file's `extensions/`
|
|
27
|
+
* directory). Circuit-class long-tail extensions use the install-time
|
|
28
|
+
* `k9o codegen` tool (v2.x) to emit local `@k9o/extensions-types/<slug>`
|
|
29
|
+
* modules; raw HTTP / vendor SDK fallback also available.
|
|
30
|
+
*
|
|
31
|
+
* Sibling of `@k9o/gate` (Identity-Aware Kernel; Auth0-parity surface)
|
|
32
|
+
* and future `@k9o/kibo` (data / compute pillar) per 3-pillar brand
|
|
33
|
+
* architecture. Each pillar package is independently importable; there
|
|
34
|
+
* is no umbrella package — customers compose by importing each pillar
|
|
35
|
+
* directly.
|
|
36
|
+
*/
|
|
37
|
+
|
|
38
|
+
/** Union of all baked-in Trailblazer / Anchor / Keystone class extension
|
|
39
|
+
* slugs shipped with this package distribution. Circuit-class slugs are
|
|
40
|
+
* NOT in this union; they resolve at install-time via the `k9o codegen`
|
|
41
|
+
* tool (v2.x scope). */
|
|
42
|
+
type ExtensionSlug = "paperless" | "cairn";
|
|
43
|
+
/** Mapped type resolving a slug to its baked typed-binding interface.
|
|
44
|
+
* Template literal lookup; compile-time resolution. */
|
|
45
|
+
type Extension<S extends ExtensionSlug> = S extends "paperless" ? PaperlessExtension : S extends "cairn" ? CairnExtension : never;
|
|
46
|
+
/** The `k9o` namespace surfacing the extension factory. v2.x may extend
|
|
47
|
+
* this with additional extensions-domain helpers; at v2 launch only
|
|
48
|
+
* the `extension(slug)` factory is exposed. */
|
|
49
|
+
declare const k9o: {
|
|
50
|
+
/** Resolve a typed extension instance by slug. The returned value is
|
|
51
|
+
* the per-extension typed-binding interface (e.g. `Extension<"paperless">`
|
|
52
|
+
* = `PaperlessExtension` with `documents.uploadAndOcr(...)` etc.).
|
|
53
|
+
*
|
|
54
|
+
* Throws `Error` at runtime if the slug is not in the baked-in
|
|
55
|
+
* Trailblazer / Anchor / Keystone catalogue. (Circuit-class consumers
|
|
56
|
+
* use the install-time `k9o codegen` tool to add their slug to the
|
|
57
|
+
* union + registry locally.) */
|
|
58
|
+
readonly extension: <S extends ExtensionSlug>(slug: S) => Extension<S>;
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
export { CairnExtension, type Extension, type ExtensionSlug, PaperlessExtension, k9o };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import {
|
|
2
|
+
cairnExtension
|
|
3
|
+
} from "./chunk-MIBROCBJ.js";
|
|
4
|
+
import {
|
|
5
|
+
paperlessExtension
|
|
6
|
+
} from "./chunk-72WCKHWA.js";
|
|
7
|
+
|
|
8
|
+
// src/index.ts
|
|
9
|
+
var REGISTRY = {
|
|
10
|
+
paperless: paperlessExtension,
|
|
11
|
+
cairn: cairnExtension
|
|
12
|
+
};
|
|
13
|
+
var k9o = {
|
|
14
|
+
/** Resolve a typed extension instance by slug. The returned value is
|
|
15
|
+
* the per-extension typed-binding interface (e.g. `Extension<"paperless">`
|
|
16
|
+
* = `PaperlessExtension` with `documents.uploadAndOcr(...)` etc.).
|
|
17
|
+
*
|
|
18
|
+
* Throws `Error` at runtime if the slug is not in the baked-in
|
|
19
|
+
* Trailblazer / Anchor / Keystone catalogue. (Circuit-class consumers
|
|
20
|
+
* use the install-time `k9o codegen` tool to add their slug to the
|
|
21
|
+
* union + registry locally.) */
|
|
22
|
+
extension(slug) {
|
|
23
|
+
const bound = REGISTRY[slug];
|
|
24
|
+
if (bound === void 0) {
|
|
25
|
+
throw new Error(
|
|
26
|
+
`Extension "${slug}" not found in @k9o/extensions baked-in catalogue. Trailblazer / Anchor / Keystone class extensions ship typed bindings at SDK publish time; Circuit-class extensions require running \`k9o codegen\` after enable.`
|
|
27
|
+
);
|
|
28
|
+
}
|
|
29
|
+
return bound;
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
export {
|
|
33
|
+
k9o
|
|
34
|
+
};
|
|
35
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["/**\n * `@k9o/extensions` — Kilimanjaro extensions consumption SDK.\n *\n * Hosts the `k9o.extension(slug)` typed Stack-SDK factory\n * (installation-instance pattern PREFERRED; namespace-by-slug REJECTED; generic-invoke\n * DROPPED for typing concern).\n *\n * Consumption surface (canonical TypeScript reference; per-language\n * equivalents land in 7 server SDKs at codegen time + 4 mobile SDKs at\n * hand-author time):\n *\n * ```typescript\n * import { k9o } from \"@k9o/extensions\";\n *\n * const paperless = k9o.extension(\"paperless\");\n * const result = await paperless.documents.uploadAndOcr({ buffer, filename });\n *\n * const cairn = k9o.extension(\"cairn\");\n * await cairn.vectors.upsert({ collection: \"knowledge\", records: [...] });\n * ```\n *\n * Trailblazer / Anchor / Keystone class extensions ship typed bindings\n * baked into this package at publish time (this file's `extensions/`\n * directory). Circuit-class long-tail extensions use the install-time\n * `k9o codegen` tool (v2.x) to emit local `@k9o/extensions-types/<slug>`\n * modules; raw HTTP / vendor SDK fallback also available.\n *\n * Sibling of `@k9o/gate` (Identity-Aware Kernel; Auth0-parity surface)\n * and future `@k9o/kibo` (data / compute pillar) per 3-pillar brand\n * architecture. Each pillar package is independently importable; there\n * is no umbrella package — customers compose by importing each pillar\n * directly.\n */\n\nimport { paperlessExtension, type PaperlessExtension } from \"./extensions/paperless.ts\";\nimport { cairnExtension, type CairnExtension } from \"./extensions/cairn.ts\";\n\n/** Union of all baked-in Trailblazer / Anchor / Keystone class extension\n * slugs shipped with this package distribution. Circuit-class slugs are\n * NOT in this union; they resolve at install-time via the `k9o codegen`\n * tool (v2.x scope). */\nexport type ExtensionSlug = \"paperless\" | \"cairn\";\n\n/** Mapped type resolving a slug to its baked typed-binding interface.\n * Template literal lookup; compile-time resolution. */\nexport type Extension<S extends ExtensionSlug> = S extends \"paperless\"\n ? PaperlessExtension\n : S extends \"cairn\"\n ? CairnExtension\n : never;\n\n/** Runtime dispatcher map. Indexed by slug; returns the bound factory. */\nconst REGISTRY: { readonly [K in ExtensionSlug]: Extension<K> } = {\n paperless: paperlessExtension,\n cairn: cairnExtension,\n};\n\n/** The `k9o` namespace surfacing the extension factory. v2.x may extend\n * this with additional extensions-domain helpers; at v2 launch only\n * the `extension(slug)` factory is exposed. */\nexport const k9o = {\n /** Resolve a typed extension instance by slug. The returned value is\n * the per-extension typed-binding interface (e.g. `Extension<\"paperless\">`\n * = `PaperlessExtension` with `documents.uploadAndOcr(...)` etc.).\n *\n * Throws `Error` at runtime if the slug is not in the baked-in\n * Trailblazer / Anchor / Keystone catalogue. (Circuit-class consumers\n * use the install-time `k9o codegen` tool to add their slug to the\n * union + registry locally.) */\n extension<S extends ExtensionSlug>(slug: S): Extension<S> {\n const bound = REGISTRY[slug];\n if (bound === undefined) {\n throw new Error(\n `Extension \"${slug}\" not found in @k9o/extensions baked-in catalogue. ` +\n `Trailblazer / Anchor / Keystone class extensions ship typed bindings ` +\n `at SDK publish time; Circuit-class extensions require running ` +\n `\\`k9o codegen\\` after enable.`,\n );\n }\n return bound;\n },\n} as const;\n\nexport type { PaperlessExtension } from \"./extensions/paperless.ts\";\nexport type { CairnExtension } from \"./extensions/cairn.ts\";\n"],"mappings":";;;;;;;;AAoDA,IAAM,WAA4D;AAAA,EAChE,WAAW;AAAA,EACX,OAAO;AACT;AAKO,IAAM,MAAM;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASjB,UAAmC,MAAuB;AACxD,UAAM,QAAQ,SAAS,IAAI;AAC3B,QAAI,UAAU,QAAW;AACvB,YAAM,IAAI;AAAA,QACR,cAAc,IAAI;AAAA,MAIpB;AAAA,IACF;AACA,WAAO;AAAA,EACT;AACF;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,47 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@k9o/extensions",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "1.1.0",
|
|
4
|
+
"description": "Kilimanjaro extensions consumption SDK — k9o.extension(slug) typed Stack-SDK factory. Sibling of @k9o/gate (Identity-Aware Kernel) and future @k9o/kibo (data/compute pillar) per 3-pillar brand architecture.",
|
|
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
|
+
"./cairn": {
|
|
20
|
+
"types": "./dist/extensions/cairn.d.ts",
|
|
21
|
+
"import": "./dist/extensions/cairn.js",
|
|
22
|
+
"default": "./dist/extensions/cairn.js"
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
"files": [
|
|
26
|
+
"src",
|
|
27
|
+
"LICENSE",
|
|
28
|
+
"NOTICE",
|
|
29
|
+
"README.md",
|
|
30
|
+
"CHANGELOG.md",
|
|
31
|
+
"dist"
|
|
32
|
+
],
|
|
33
|
+
"license": "Apache-2.0",
|
|
34
|
+
"publishConfig": {
|
|
35
|
+
"access": "public"
|
|
36
|
+
},
|
|
37
|
+
"repository": {
|
|
38
|
+
"type": "git",
|
|
39
|
+
"url": "https://github.com/k9o-dev",
|
|
40
|
+
"directory": "packages/extensions"
|
|
41
|
+
},
|
|
42
|
+
"devDependencies": {
|
|
43
|
+
"bun-types": "^1.1.0",
|
|
44
|
+
"typescript": "^5.6.0"
|
|
45
|
+
},
|
|
46
|
+
"module": "./dist/index.js"
|
|
47
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `cairn` extension typed binding — Cairn: vector store / knowledge-base
|
|
3
|
+
* extension (Trailblazer class). Surface stripped
|
|
4
|
+
* of SQL Studio ops (SQL is core platform; canonical home is the Console
|
|
5
|
+
* query-studio surface).
|
|
6
|
+
*
|
|
7
|
+
* The typed contract is available now. Per-method runtime calls are not implemented yet and reject
|
|
8
|
+
* with an error that says so.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
/** Vector record shape for upsert. */
|
|
12
|
+
export type VectorRecord = {
|
|
13
|
+
id: string;
|
|
14
|
+
embedding: number[];
|
|
15
|
+
metadata?: Record<string, unknown>;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
/** Query-result shape from semantic search. */
|
|
19
|
+
export type QueryResult = {
|
|
20
|
+
id: string;
|
|
21
|
+
score: number;
|
|
22
|
+
metadata: Record<string, unknown> | null;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
/** Typed binding interface for the `cairn` extension. */
|
|
26
|
+
export interface CairnExtension {
|
|
27
|
+
vectors: {
|
|
28
|
+
upsert(params: { collection: string; records: VectorRecord[] }): Promise<{ upserted: number }>;
|
|
29
|
+
query(params: {
|
|
30
|
+
collection: string;
|
|
31
|
+
embedding: number[];
|
|
32
|
+
topK?: number;
|
|
33
|
+
filter?: Record<string, unknown>;
|
|
34
|
+
}): Promise<QueryResult[]>;
|
|
35
|
+
delete(params: { collection: string; ids: string[] }): Promise<{ deleted: number }>;
|
|
36
|
+
};
|
|
37
|
+
collections: {
|
|
38
|
+
create(params: { name: string; dimension: number; metric?: "cosine" | "euclidean" | "dot" }): Promise<{
|
|
39
|
+
name: string;
|
|
40
|
+
dimension: number;
|
|
41
|
+
}>;
|
|
42
|
+
list(): Promise<{ collections: { name: string; dimension: number; count: number }[] }>;
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/** Runtime stub: every method rejects until per-method runtime calls are implemented. */
|
|
47
|
+
const stub = (op: string): (() => Promise<never>) => {
|
|
48
|
+
return (): Promise<never> =>
|
|
49
|
+
Promise.reject(
|
|
50
|
+
new Error(
|
|
51
|
+
`cairn.${op} is not available yet: the extension runtime is not implemented in this version of @k9o/extensions.`,
|
|
52
|
+
),
|
|
53
|
+
);
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
export const cairnExtension: CairnExtension = {
|
|
57
|
+
vectors: {
|
|
58
|
+
upsert: stub("vectors.upsert") as CairnExtension["vectors"]["upsert"],
|
|
59
|
+
query: stub("vectors.query") as CairnExtension["vectors"]["query"],
|
|
60
|
+
delete: stub("vectors.delete") as CairnExtension["vectors"]["delete"],
|
|
61
|
+
},
|
|
62
|
+
collections: {
|
|
63
|
+
create: stub("collections.create") as CairnExtension["collections"]["create"],
|
|
64
|
+
list: stub("collections.list") as CairnExtension["collections"]["list"],
|
|
65
|
+
},
|
|
66
|
+
};
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `paperless` extension typed binding — Paperless: AI Workflows extension
|
|
3
|
+
* (Trailblazer class). Brand-absorbed from
|
|
4
|
+
* Formelo Inc. "Paperless: AI Workflows" (existing App Store product).
|
|
5
|
+
*
|
|
6
|
+
* The typed contract is available now. Per-method runtime calls are not implemented yet and reject
|
|
7
|
+
* with an error that says so.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
/** Document upload + OCR result shape. */
|
|
11
|
+
export type UploadAndOcrResult = {
|
|
12
|
+
documentId: string;
|
|
13
|
+
ocrText: string;
|
|
14
|
+
pages: number;
|
|
15
|
+
language: string | null;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
/** Workflow-init response envelope (v1 BFF guide-not-binding per
|
|
19
|
+
* paperless v2.1 spec +; version: 2 envelope marker required). */
|
|
20
|
+
export type WorkspaceInitResponse = {
|
|
21
|
+
version: 2;
|
|
22
|
+
// Shape past `version` is BFF-author-flexible (by design);
|
|
23
|
+
// mobile client consumes whatever
|
|
24
|
+
// shape the BFF emits as long as the version marker is present.
|
|
25
|
+
[key: string]: unknown;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
/** Typed binding interface for the `paperless` extension. */
|
|
29
|
+
export interface PaperlessExtension {
|
|
30
|
+
documents: {
|
|
31
|
+
uploadAndOcr(params: {
|
|
32
|
+
buffer: Uint8Array | ArrayBuffer;
|
|
33
|
+
filename: string;
|
|
34
|
+
language?: string;
|
|
35
|
+
}): Promise<UploadAndOcrResult>;
|
|
36
|
+
};
|
|
37
|
+
workspace: {
|
|
38
|
+
init(): Promise<WorkspaceInitResponse>;
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/** Runtime stub: every method rejects until per-method runtime calls are implemented. */
|
|
43
|
+
const stub = (op: string): (() => Promise<never>) => {
|
|
44
|
+
return (): Promise<never> =>
|
|
45
|
+
Promise.reject(
|
|
46
|
+
new Error(
|
|
47
|
+
`paperless.${op} is not available yet: the extension runtime is not implemented in this version of @k9o/extensions.`,
|
|
48
|
+
),
|
|
49
|
+
);
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
export const paperlessExtension: PaperlessExtension = {
|
|
53
|
+
documents: {
|
|
54
|
+
uploadAndOcr: stub("documents.uploadAndOcr") as PaperlessExtension["documents"]["uploadAndOcr"],
|
|
55
|
+
},
|
|
56
|
+
workspace: {
|
|
57
|
+
init: stub("workspace.init") as PaperlessExtension["workspace"]["init"],
|
|
58
|
+
},
|
|
59
|
+
};
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@k9o/extensions` — Kilimanjaro extensions consumption SDK.
|
|
3
|
+
*
|
|
4
|
+
* Hosts the `k9o.extension(slug)` typed Stack-SDK factory
|
|
5
|
+
* (installation-instance pattern PREFERRED; namespace-by-slug REJECTED; generic-invoke
|
|
6
|
+
* DROPPED for typing concern).
|
|
7
|
+
*
|
|
8
|
+
* Consumption surface (canonical TypeScript reference; per-language
|
|
9
|
+
* equivalents land in 7 server SDKs at codegen time + 4 mobile SDKs at
|
|
10
|
+
* hand-author time):
|
|
11
|
+
*
|
|
12
|
+
* ```typescript
|
|
13
|
+
* import { k9o } from "@k9o/extensions";
|
|
14
|
+
*
|
|
15
|
+
* const paperless = k9o.extension("paperless");
|
|
16
|
+
* const result = await paperless.documents.uploadAndOcr({ buffer, filename });
|
|
17
|
+
*
|
|
18
|
+
* const cairn = k9o.extension("cairn");
|
|
19
|
+
* await cairn.vectors.upsert({ collection: "knowledge", records: [...] });
|
|
20
|
+
* ```
|
|
21
|
+
*
|
|
22
|
+
* Trailblazer / Anchor / Keystone class extensions ship typed bindings
|
|
23
|
+
* baked into this package at publish time (this file's `extensions/`
|
|
24
|
+
* directory). Circuit-class long-tail extensions use the install-time
|
|
25
|
+
* `k9o codegen` tool (v2.x) to emit local `@k9o/extensions-types/<slug>`
|
|
26
|
+
* modules; raw HTTP / vendor SDK fallback also available.
|
|
27
|
+
*
|
|
28
|
+
* Sibling of `@k9o/gate` (Identity-Aware Kernel; Auth0-parity surface)
|
|
29
|
+
* and future `@k9o/kibo` (data / compute pillar) per 3-pillar brand
|
|
30
|
+
* architecture. Each pillar package is independently importable; there
|
|
31
|
+
* is no umbrella package — customers compose by importing each pillar
|
|
32
|
+
* directly.
|
|
33
|
+
*/
|
|
34
|
+
|
|
35
|
+
import { paperlessExtension, type PaperlessExtension } from "./extensions/paperless.ts";
|
|
36
|
+
import { cairnExtension, type CairnExtension } from "./extensions/cairn.ts";
|
|
37
|
+
|
|
38
|
+
/** Union of all baked-in Trailblazer / Anchor / Keystone class extension
|
|
39
|
+
* slugs shipped with this package distribution. Circuit-class slugs are
|
|
40
|
+
* NOT in this union; they resolve at install-time via the `k9o codegen`
|
|
41
|
+
* tool (v2.x scope). */
|
|
42
|
+
export type ExtensionSlug = "paperless" | "cairn";
|
|
43
|
+
|
|
44
|
+
/** Mapped type resolving a slug to its baked typed-binding interface.
|
|
45
|
+
* Template literal lookup; compile-time resolution. */
|
|
46
|
+
export type Extension<S extends ExtensionSlug> = S extends "paperless"
|
|
47
|
+
? PaperlessExtension
|
|
48
|
+
: S extends "cairn"
|
|
49
|
+
? CairnExtension
|
|
50
|
+
: never;
|
|
51
|
+
|
|
52
|
+
/** Runtime dispatcher map. Indexed by slug; returns the bound factory. */
|
|
53
|
+
const REGISTRY: { readonly [K in ExtensionSlug]: Extension<K> } = {
|
|
54
|
+
paperless: paperlessExtension,
|
|
55
|
+
cairn: cairnExtension,
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
/** The `k9o` namespace surfacing the extension factory. v2.x may extend
|
|
59
|
+
* this with additional extensions-domain helpers; at v2 launch only
|
|
60
|
+
* the `extension(slug)` factory is exposed. */
|
|
61
|
+
export const k9o = {
|
|
62
|
+
/** Resolve a typed extension instance by slug. The returned value is
|
|
63
|
+
* the per-extension typed-binding interface (e.g. `Extension<"paperless">`
|
|
64
|
+
* = `PaperlessExtension` with `documents.uploadAndOcr(...)` etc.).
|
|
65
|
+
*
|
|
66
|
+
* Throws `Error` at runtime if the slug is not in the baked-in
|
|
67
|
+
* Trailblazer / Anchor / Keystone catalogue. (Circuit-class consumers
|
|
68
|
+
* use the install-time `k9o codegen` tool to add their slug to the
|
|
69
|
+
* union + registry locally.) */
|
|
70
|
+
extension<S extends ExtensionSlug>(slug: S): Extension<S> {
|
|
71
|
+
const bound = REGISTRY[slug];
|
|
72
|
+
if (bound === undefined) {
|
|
73
|
+
throw new Error(
|
|
74
|
+
`Extension "${slug}" not found in @k9o/extensions baked-in catalogue. ` +
|
|
75
|
+
`Trailblazer / Anchor / Keystone class extensions ship typed bindings ` +
|
|
76
|
+
`at SDK publish time; Circuit-class extensions require running ` +
|
|
77
|
+
`\`k9o codegen\` after enable.`,
|
|
78
|
+
);
|
|
79
|
+
}
|
|
80
|
+
return bound;
|
|
81
|
+
},
|
|
82
|
+
} as const;
|
|
83
|
+
|
|
84
|
+
export type { PaperlessExtension } from "./extensions/paperless.ts";
|
|
85
|
+
export type { CairnExtension } from "./extensions/cairn.ts";
|