@agimon-ai/po-spreadsheet 0.0.0-stage → 0.0.1-alpha.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 ADDED
@@ -0,0 +1,149 @@
1
+ License text copyright © 2017 MariaDB Corporation Ab, All Rights Reserved.
2
+ "Business Source License" is a trademark of MariaDB Corporation Ab.
3
+
4
+ Parameters
5
+
6
+ Licensor: Agimon Pty Ltd
7
+ Licensed Work: Po, the software in the Po source repository and the
8
+ packages released from it, in each version released by
9
+ the Licensor.
10
+ The Licensed Work is (c) 2026 Agimon Pty Ltd.
11
+ Material identified as third-party in the "Third-party
12
+ components" section at the end of this file or in a
13
+ NOTICE file, and any package or directory whose own
14
+ license file grants a different license, is not part of
15
+ the Licensed Work and remains under its own license.
16
+ Additional Use Grant: You may make production use of the Licensed Work if
17
+ your use is Eligible Use. "Eligible Use" is production use that falls
18
+ within at least one of the following:
19
+
20
+ (a) Personal Use. Use by an individual for their own personal purposes,
21
+ and not on behalf of, or for the benefit of, an employer, client, or
22
+ other Organization. Use by an individual in the course of employment
23
+ or engagement by an Organization is use by that Organization.
24
+
25
+ (b) Small Organization Use. Use by or on behalf of an Organization whose
26
+ Annual Revenue is less than USD 1,000,000.
27
+
28
+ (c) Non-profit, Education and Research Use. Use, regardless of Annual
29
+ Revenue, by (i) an Organization registered or recognized as a
30
+ non-profit or charitable organization under the laws of its
31
+ jurisdiction, for its non-profit purposes; (ii) an accredited school,
32
+ college, or university, for teaching, learning, or academic research;
33
+ or (iii) a publicly funded research institution, for its research.
34
+
35
+ (d) Service Provider Use. Use by a consultant, contractor, agency, or other
36
+ service provider, regardless of its own Annual Revenue, solely to
37
+ build, deploy, host, operate, or support the Licensed Work for a client
38
+ whose own use would be Eligible Use under (a), (b), or (c). A service
39
+ provider's use for its own purposes is Eligible Use only if the service
40
+ provider itself qualifies under (b) or (c).
41
+
42
+
43
+ Hosted services. Offering the Licensed Work to third parties as a hosted
44
+ or managed service whose primary value is the Licensed Work is Eligible
45
+ Use only if each such third party's own use would be Eligible Use.
46
+
47
+ Definitions. "Organization" means any company, partnership, sole
48
+ proprietorship, trust, association, government body, or other entity, and
49
+ includes an individual acting in a business or professional capacity.
50
+ "Affiliate" means any entity that directly or indirectly controls, is
51
+ controlled by, or is under common control with an Organization, where
52
+ "control" means ownership of more than 50% of the voting interests of an
53
+ entity or the power to direct its management and policies by contract or
54
+ otherwise. "Annual Revenue" means the total gross revenue of an
55
+ Organization and all of its Affiliates combined, from all sources and
56
+ whether or not related to the Licensed Work, for its most recently
57
+ completed fiscal year, or, if it has not completed a fiscal year, for the
58
+ twelve months before the use (or since its formation, if shorter),
59
+ converted into US dollars at the average exchange rate for that period.
60
+ Proceeds of equity or debt financing are not revenue.
61
+
62
+ Threshold. If an Organization stops qualifying under (b), its existing
63
+ production use remains Eligible Use for 90 days after it stops
64
+ qualifying, after which it must obtain a commercial license or stop
65
+ production use. Use that was Eligible Use when it occurred never requires
66
+ a commercial license after the fact.
67
+ Change Date: Four years from the date a version of the Licensed Work
68
+ is first publicly released by the Licensor.
69
+ Change License: Apache License, Version 2.0
70
+
71
+ For information about alternative licensing arrangements for the Licensed
72
+ Work, please visit: https://agimon.ai/licensing
73
+
74
+ Notice
75
+
76
+ The Business Source License (this document, or the "License") is not an Open
77
+ Source license. However, the Licensed Work will eventually be made available
78
+ under an Open Source License, as stated in this License.
79
+
80
+ -----------------------------------------------------------------------------
81
+
82
+ Business Source License 1.1
83
+
84
+ Terms
85
+
86
+ The Licensor hereby grants you the right to copy, modify, create derivative
87
+ works, redistribute, and make non-production use of the Licensed Work. The
88
+ Licensor may make an Additional Use Grant, above, permitting limited
89
+ production use.
90
+
91
+ Effective on the Change Date, or the fourth anniversary of the first publicly
92
+ available distribution of a specific version of the Licensed Work under this
93
+ License, whichever comes first, the Licensor hereby grants you rights under
94
+ the terms of the Change License, and the rights granted in the paragraph
95
+ above terminate.
96
+
97
+ If your use of the Licensed Work does not comply with the requirements
98
+ currently in effect as described in this License, you must purchase a
99
+ commercial license from the Licensor, its affiliated entities, or authorized
100
+ resellers, or you must refrain from using the Licensed Work.
101
+
102
+ All copies of the original and modified Licensed Work, and derivative works
103
+ of the Licensed Work, are subject to this License. This License applies
104
+ separately for each version of the Licensed Work and the Change Date may vary
105
+ for each version of the Licensed Work released by Licensor.
106
+
107
+ You must conspicuously display this License on each original or modified copy
108
+ of the Licensed Work. If you receive the Licensed Work in original or
109
+ modified form from a third party, the terms and conditions set forth in this
110
+ License apply to your use of that work.
111
+
112
+ Any use of the Licensed Work in violation of this License will automatically
113
+ terminate your rights under this License for the current and all other
114
+ versions of the Licensed Work.
115
+
116
+ This License does not grant you any right in any trademark or logo of
117
+ Licensor or its affiliates (provided that you may use a trademark or logo of
118
+ Licensor as expressly required by this License).
119
+
120
+ TO THE EXTENT PERMITTED BY APPLICABLE LAW, THE LICENSED WORK IS PROVIDED ON
121
+ AN “AS IS” BASIS. LICENSOR HEREBY DISCLAIMS ALL WARRANTIES AND CONDITIONS,
122
+ EXPRESS OR IMPLIED, INCLUDING (WITHOUT LIMITATION) WARRANTIES OF
123
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT, AND
124
+ TITLE.
125
+
126
+ MariaDB hereby grants you permission to use this License’s text to license
127
+ your works, and to refer to it using the trademark “Business Source License”,
128
+ as long as you comply with the Covenants of Licensor below.
129
+
130
+ Covenants of Licensor
131
+
132
+ In consideration of the right to use this License’s text and the “Business
133
+ Source License” name and trademark, Licensor covenants to MariaDB, and to all
134
+ other recipients of the licensed work to be provided by Licensor:
135
+
136
+ 1. To specify as the Change License the GPL Version 2.0 or any later version,
137
+ or a license that is compatible with GPL Version 2.0 or a later version,
138
+ where “compatible” means that software provided under the Change License can
139
+ be included in a program with software provided under GPL Version 2.0 or a
140
+ later version. Licensor may specify additional Change Licenses without
141
+ limitation.
142
+
143
+ 2. To either: (a) specify an additional grant of rights to use that does not
144
+ impose any additional restriction on the right granted in this License, as
145
+ the Additional Use Grant; or (b) insert the text “None”.
146
+
147
+ 3. To specify a Change Date.
148
+
149
+ 4. Not to modify this License in any other way.
package/README.md CHANGED
@@ -1,3 +1,20 @@
1
- # Temporary Holding Version
1
+ # Spreadsheet canvas
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
+ Opening an `.xlsx` file in Author shows it as a workbook canvas backed by GridCraft, a spreadsheet engine compiled to WASM (`@agimon-ai/gridcraft-wasm`) and run on the Po server. People edit cells and formulas in place, select cells, whole columns or rows (drag, shift-click, shift+arrows), resize columns and rows by dragging header edges, copy and paste tab-separated text, insert and delete rows and columns, add sheets and undo (Cmd/Ctrl+Z); Author's Region and Comment tools mark cells for feedback. On the phone the same canvas edits one cell at a time through a cell field, with the row, column, sheet, undo and consent actions. Agents get the same edits as Author canvas tools, fenced by the workbook revision, and as the `spreadsheet` code-mode namespace without a canvas open; both go through the session's one workbook API. Protected sheets are read-only for both. A workbook the built-in XLSX reader refuses still opens in the canvas.
4
+
5
+ Every change to a workspace file saves to it, only while the file still has the SHA-256 Po last read or wrote, through the same root-bound replace Author's own saves use. A workbook holding parts the engine may simplify (charts, comments, macros and anything else outside a plain workbook) asks once, in the canvas, before its first write. Artifacts stay read-only, as in Author: their edits live in the open canvas and leave through **Download copy**. CSV stays with Author's built-in view.
6
+
7
+ ## Use it
8
+
9
+ The `spreadsheet` layer is on in the `copilot` preset. Add `spreadsheet` to another preset's layers to turn it on there; a server reads preset layers only when it starts.
10
+
11
+ In this repository, run `pnpm --filter @agimon-ai/po-spreadsheet build`, then `po sync --test`, and restart the test host. `pnpm --filter @agimon-ai/po-spreadsheet test` runs the API against the real engine.
12
+
13
+ The engine is built from the `po-wasm` crate in the GridCraft fork (`vuongngo/gridcraft`) and published by its `po-wasm-v*` tag. Its licences and notices ship inside that package.
14
+
15
+ ## Limits
16
+
17
+ - GridCraft runs in one worker thread per session, behind a 25 MiB file cap. A call over 10 seconds, a WASM trap or a crash stops the worker; open workbooks are dropped and reopen from disk, so unsaved artifact or unconfirmed edits are lost. Linear memory is capped at 1 GiB at link time. Before GridCraft sees a file, Po checks the ZIP with Author's limits (4,096 parts, 100 MiB expanded, ratio 100 per part, every part inflated against its declared size) and refuses unsafe part names, encryption and ZIP64.
18
+ - A workbook stays open in memory, at most four per session; an artifact's or an unconfirmed workbook's unsaved edits leave with it when it is closed or evicted.
19
+ - Hidden rows and columns show at a minimum size rather than collapsing. Fill handles, cut, merged cells and styles beyond bold are not drawn.
20
+ - The native canvas builds and passes the phone shell's module check but has not run on a device; Resize and Region/Comment are web only. No edge build exists, so Cloudflare-hosted sessions do not get the canvas.
@@ -0,0 +1,150 @@
1
+ Object.defineProperties(exports, {
2
+ __esModule: { value: true },
3
+ [Symbol.toStringTag]: { value: "Module" }
4
+ });
5
+ let _agimon_ai_po_core_apiContracts = require("@agimon-ai/po-core/apiContracts");
6
+ let typebox = require("typebox");
7
+ //#region src/schemas/apiContracts.ts
8
+ const Text = typebox.Type.String();
9
+ const Cell = typebox.Type.Object({
10
+ text: Text,
11
+ input: Text,
12
+ numeric: typebox.Type.Boolean(),
13
+ bold: typebox.Type.Boolean()
14
+ });
15
+ const View = typebox.Type.Object({
16
+ sheets: typebox.Type.Array(typebox.Type.Object({
17
+ name: Text,
18
+ protected: typebox.Type.Boolean()
19
+ })),
20
+ sheet: typebox.Type.Object({
21
+ name: Text,
22
+ protected: typebox.Type.Boolean(),
23
+ widths: typebox.Type.Array(typebox.Type.Number()),
24
+ heights: typebox.Type.Array(typebox.Type.Number()),
25
+ rows: typebox.Type.Array(typebox.Type.Array(typebox.Type.Union([Cell, typebox.Type.Null()])))
26
+ }),
27
+ revision: typebox.Type.Integer({ minimum: 0 }),
28
+ file: typebox.Type.Object({
29
+ state: typebox.Type.Union([
30
+ typebox.Type.Literal("saved"),
31
+ typebox.Type.Literal("consent"),
32
+ typebox.Type.Literal("readOnly")
33
+ ]),
34
+ lossyParts: typebox.Type.Array(Text)
35
+ })
36
+ });
37
+ const Line = {
38
+ at: typebox.Type.Integer({ minimum: 1 }),
39
+ count: typebox.Type.Optional(typebox.Type.Integer({ minimum: 1 }))
40
+ };
41
+ const Edit = typebox.Type.Union([
42
+ typebox.Type.Object({
43
+ kind: typebox.Type.Literal("setCell"),
44
+ cell: Text,
45
+ input: Text
46
+ }),
47
+ typebox.Type.Object({
48
+ kind: typebox.Type.Union([
49
+ "insertRows",
50
+ "deleteRows",
51
+ "insertColumns",
52
+ "deleteColumns"
53
+ ].map((kind) => typebox.Type.Literal(kind))),
54
+ ...Line
55
+ }),
56
+ typebox.Type.Object({
57
+ kind: typebox.Type.Union([typebox.Type.Literal("columnWidth"), typebox.Type.Literal("rowHeight")]),
58
+ ...Line,
59
+ size: typebox.Type.Number({ minimum: 0 })
60
+ }),
61
+ typebox.Type.Object({
62
+ kind: typebox.Type.Literal("addSheet"),
63
+ name: Text
64
+ }),
65
+ typebox.Type.Object({ kind: typebox.Type.Literal("undo") })
66
+ ]);
67
+ /** A workspace-relative path, or `artifact:<relative>` for the session's artifacts. */
68
+ const Path = {
69
+ name: "path",
70
+ in: "query",
71
+ required: true,
72
+ schema: Text
73
+ };
74
+ const json = (schema) => ({
75
+ required: true,
76
+ contentType: "application/json",
77
+ schema
78
+ });
79
+ const route = {
80
+ scope: "session",
81
+ basePath: "spreadsheet",
82
+ authentication: "owner"
83
+ };
84
+ const apiContracts = (0, _agimon_ai_po_core_apiContracts.defineApiContract)({
85
+ version: 1,
86
+ http: [
87
+ {
88
+ ...route,
89
+ id: "spreadsheet.view",
90
+ path: "/workbook",
91
+ method: "GET",
92
+ description: "Open an .xlsx workbook and read one sheet; the first sheet when `sheet` is empty.",
93
+ parameters: [Path, {
94
+ name: "sheet",
95
+ in: "query",
96
+ required: false,
97
+ schema: Text
98
+ }],
99
+ responses: (0, _agimon_ai_po_core_apiContracts.jsonApiResponses)(View)
100
+ },
101
+ {
102
+ ...route,
103
+ id: "spreadsheet.edit",
104
+ path: "/workbook/edit",
105
+ method: "POST",
106
+ description: "Apply up to 500 edits in order and save them, fenced by the file SHA-256 and the optional revision. Protected sheets refuse every edit.",
107
+ body: json(typebox.Type.Object({
108
+ path: Text,
109
+ sheet: Text,
110
+ revision: typebox.Type.Optional(typebox.Type.Integer({ minimum: 0 })),
111
+ edits: typebox.Type.Array(Edit, {
112
+ minItems: 1,
113
+ maxItems: 500
114
+ })
115
+ })),
116
+ responses: (0, _agimon_ai_po_core_apiContracts.jsonApiResponses)(View)
117
+ },
118
+ {
119
+ ...route,
120
+ id: "spreadsheet.consent",
121
+ path: "/workbook/consent",
122
+ method: "POST",
123
+ description: "Record that the person agreed to save a workbook the engine may simplify, then save it.",
124
+ body: json(typebox.Type.Object({
125
+ path: Text,
126
+ sheet: Text
127
+ })),
128
+ responses: (0, _agimon_ai_po_core_apiContracts.jsonApiResponses)(View)
129
+ },
130
+ {
131
+ ...route,
132
+ id: "spreadsheet.download",
133
+ path: "/workbook/download",
134
+ method: "GET",
135
+ description: "Export the open workbook, edits included, as base64 XLSX bytes.",
136
+ parameters: [Path],
137
+ responses: (0, _agimon_ai_po_core_apiContracts.jsonApiResponses)(typebox.Type.Object({
138
+ name: Text,
139
+ xlsx: Text
140
+ }))
141
+ }
142
+ ],
143
+ sockets: [],
144
+ dynamic: []
145
+ });
146
+ //#endregion
147
+ exports.apiContracts = apiContracts;
148
+ exports.default = apiContracts;
149
+
150
+ //# sourceMappingURL=apiContracts.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"apiContracts.cjs","names":["Type","defineApiContract","jsonApiResponses"],"sources":["../src/schemas/apiContracts.ts"],"sourcesContent":["import { defineApiContract, jsonApiResponses } from '@agimon-ai/po-core/apiContracts';\nimport { Type } from 'typebox';\n\nconst Text = Type.String();\nconst Cell = Type.Object({ text: Text, input: Text, numeric: Type.Boolean(), bold: Type.Boolean() });\nconst View = Type.Object({\n sheets: Type.Array(Type.Object({ name: Text, protected: Type.Boolean() })),\n sheet: Type.Object({\n name: Text,\n protected: Type.Boolean(),\n widths: Type.Array(Type.Number()),\n heights: Type.Array(Type.Number()),\n rows: Type.Array(Type.Array(Type.Union([Cell, Type.Null()]))),\n }),\n revision: Type.Integer({ minimum: 0 }),\n file: Type.Object({\n state: Type.Union([Type.Literal('saved'), Type.Literal('consent'), Type.Literal('readOnly')]),\n lossyParts: Type.Array(Text),\n }),\n});\nconst Line = { at: Type.Integer({ minimum: 1 }), count: Type.Optional(Type.Integer({ minimum: 1 })) };\nconst Edit = Type.Union([\n Type.Object({ kind: Type.Literal('setCell'), cell: Text, input: Text }),\n Type.Object({\n kind: Type.Union(['insertRows', 'deleteRows', 'insertColumns', 'deleteColumns'].map((kind) => Type.Literal(kind))),\n ...Line,\n }),\n Type.Object({\n kind: Type.Union([Type.Literal('columnWidth'), Type.Literal('rowHeight')]),\n ...Line,\n size: Type.Number({ minimum: 0 }),\n }),\n Type.Object({ kind: Type.Literal('addSheet'), name: Text }),\n Type.Object({ kind: Type.Literal('undo') }),\n]);\n/** A workspace-relative path, or `artifact:<relative>` for the session's artifacts. */\nconst Path = { name: 'path', in: 'query' as const, required: true, schema: Text };\nconst json = (schema: object) => ({ required: true, contentType: 'application/json', schema });\nconst route = {\n scope: 'session' as const,\n basePath: 'spreadsheet',\n authentication: 'owner' as const,\n};\n\nexport const apiContracts = defineApiContract({\n version: 1,\n http: [\n {\n ...route,\n id: 'spreadsheet.view',\n path: '/workbook',\n method: 'GET',\n description: 'Open an .xlsx workbook and read one sheet; the first sheet when `sheet` is empty.',\n parameters: [Path, { name: 'sheet', in: 'query', required: false, schema: Text }],\n responses: jsonApiResponses(View),\n },\n {\n ...route,\n id: 'spreadsheet.edit',\n path: '/workbook/edit',\n method: 'POST',\n description:\n 'Apply up to 500 edits in order and save them, fenced by the file SHA-256 and the optional revision. Protected sheets refuse every edit.',\n body: json(\n Type.Object({\n path: Text,\n sheet: Text,\n revision: Type.Optional(Type.Integer({ minimum: 0 })),\n edits: Type.Array(Edit, { minItems: 1, maxItems: 500 }),\n }),\n ),\n responses: jsonApiResponses(View),\n },\n {\n ...route,\n id: 'spreadsheet.consent',\n path: '/workbook/consent',\n method: 'POST',\n description: 'Record that the person agreed to save a workbook the engine may simplify, then save it.',\n body: json(Type.Object({ path: Text, sheet: Text })),\n responses: jsonApiResponses(View),\n },\n {\n ...route,\n id: 'spreadsheet.download',\n path: '/workbook/download',\n method: 'GET',\n description: 'Export the open workbook, edits included, as base64 XLSX bytes.',\n parameters: [Path],\n responses: jsonApiResponses(Type.Object({ name: Text, xlsx: Text })),\n },\n ],\n sockets: [],\n dynamic: [],\n});\n"],"mappings":";;;;;;;AAGA,MAAM,OAAOA,QAAAA,KAAK,OAAO;AACzB,MAAM,OAAOA,QAAAA,KAAK,OAAO;CAAE,MAAM;CAAM,OAAO;CAAM,SAASA,QAAAA,KAAK,QAAQ;CAAG,MAAMA,QAAAA,KAAK,QAAQ;AAAE,CAAC;AACnG,MAAM,OAAOA,QAAAA,KAAK,OAAO;CACvB,QAAQA,QAAAA,KAAK,MAAMA,QAAAA,KAAK,OAAO;EAAE,MAAM;EAAM,WAAWA,QAAAA,KAAK,QAAQ;CAAE,CAAC,CAAC;CACzE,OAAOA,QAAAA,KAAK,OAAO;EACjB,MAAM;EACN,WAAWA,QAAAA,KAAK,QAAQ;EACxB,QAAQA,QAAAA,KAAK,MAAMA,QAAAA,KAAK,OAAO,CAAC;EAChC,SAASA,QAAAA,KAAK,MAAMA,QAAAA,KAAK,OAAO,CAAC;EACjC,MAAMA,QAAAA,KAAK,MAAMA,QAAAA,KAAK,MAAMA,QAAAA,KAAK,MAAM,CAAC,MAAMA,QAAAA,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC;CAC9D,CAAC;CACD,UAAUA,QAAAA,KAAK,QAAQ,EAAE,SAAS,EAAE,CAAC;CACrC,MAAMA,QAAAA,KAAK,OAAO;EAChB,OAAOA,QAAAA,KAAK,MAAM;GAACA,QAAAA,KAAK,QAAQ,OAAO;G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BAAA,GAAeC,gCAAAA,kBAAAA,CAAkB;CAC5C,SAAS;CACT,MAAM;EACJ;GACE,GAAG;GACH,IAAI;GACJ,MAAM;GACN,QAAQ;GACR,aAAa;GACb,YAAY,CAAC,MAAM;IAAE,MAAM;IAAS,IAAI;IAAS,UAAU;IAAO,QAAQ;GAAK,CAAC;GAChF,YAAA,GAAWC,gCAAAA,iBAAAA,CAAiB,IAAI;EAClC;EACA;GACE,GAAG;GACH,IAAI;GACJ,MAAM;GACN,QAAQ;GACR,aACE;GACF,MAAM,KACJF,QAAAA,KAAK,OAAO;IACV,MAAM;IACN,OAAO;IACP,UAAUA,QAAAA,KAAK,SAASA,QAAAA,KAAK,QAAQ,EAAE,SAAS,EAAE,CAAC,CAAC;IACpD,OAAOA,QAAAA,KAAK,MAAM,MAAM;KAAE,UAAU;KAAG,UAAU;IAAI,CAAC;GACxD,CAAC,CACH;GACA,YAAA,GAAWE,gCAAAA,iBAAAA,CAAiB,IAAI;EAClC;EACA;GACE,GAAG;GACH,IAAI;GACJ,MAAM;GACN,QAAQ;GACR,aAAa;GACb,MAAM,KAAKF,QAAAA,KAAK,OAAO;IAAE,MAAM;IAAM,OAAO;GAAK,CAAC,CAAC;GACnD,YAAA,GAAWE,gCAAAA,iBAAAA,CAAiB,IAAI;EAClC;EACA;GACE,GAAG;GACH,IAAI;GACJ,MAAM;GACN,QAAQ;GACR,aAAa;GACb,YAAY,CAAC,IAAI;GACjB,YAAA,GAAWA,gCAAAA,iBAAAA,CAAiBF,QAAAA,KAAK,OAAO;IAAE,MAAM;IAAM,MAAM;GAAK,CAAC,CAAC;EACrE;CACF;CACA,SAAS,CAAC;CACV,SAAS,CAAC;AACZ,CAAC"}
@@ -0,0 +1,52 @@
1
+ //#region src/schemas/apiContracts.d.ts
2
+ export declare const apiContracts: {
3
+ version: 1;
4
+ protocols?: Record<string, string> | undefined;
5
+ schemas?: Record<string, boolean | object> | undefined;
6
+ http: {
7
+ id: string;
8
+ scope: "host" | "session" | "workspace";
9
+ basePath?: string | undefined;
10
+ path: string;
11
+ method: "DELETE" | "GET" | "HEAD" | "OPTIONS" | "PATCH" | "POST" | "PUT";
12
+ description: string;
13
+ availability?: string | undefined;
14
+ authentication: "device" | "none" | "owner";
15
+ parameters?: {
16
+ name: string;
17
+ in: "header" | "path" | "query";
18
+ required: boolean;
19
+ schema: boolean | object;
20
+ }[] | undefined;
21
+ body?: {
22
+ contentType: string;
23
+ contentTypes?: string[] | undefined;
24
+ required: boolean;
25
+ schema: boolean | object;
26
+ } | undefined;
27
+ responses: Record<string, {
28
+ description: string;
29
+ contentType?: string | undefined;
30
+ schema?: boolean | object | undefined;
31
+ events?: Record<string, boolean | object> | undefined;
32
+ }>;
33
+ }[];
34
+ sockets: {
35
+ id: string;
36
+ scope: "host" | "session" | "workspace";
37
+ description: string;
38
+ availability?: string | undefined;
39
+ service: string;
40
+ member: string;
41
+ direction: "client-to-server" | "server-to-client";
42
+ kind: "channel" | "method" | "state";
43
+ input: boolean | object;
44
+ output?: boolean | object | undefined;
45
+ errors?: boolean | object | undefined;
46
+ }[];
47
+ dynamic: string[];
48
+ gaps?: string[] | undefined;
49
+ };
50
+ //#endregion
51
+ export { apiContracts as default };
52
+ //# sourceMappingURL=apiContracts.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"apiContracts.d.mts","names":[],"sources":["../src/schemas/apiContracts.ts"],"mappings":";qBA4Ca"}
@@ -0,0 +1,145 @@
1
+ import { defineApiContract, jsonApiResponses } from "@agimon-ai/po-core/apiContracts";
2
+ import { Type } from "typebox";
3
+ //#region src/schemas/apiContracts.ts
4
+ const Text = Type.String();
5
+ const Cell = Type.Object({
6
+ text: Text,
7
+ input: Text,
8
+ numeric: Type.Boolean(),
9
+ bold: Type.Boolean()
10
+ });
11
+ const View = Type.Object({
12
+ sheets: Type.Array(Type.Object({
13
+ name: Text,
14
+ protected: Type.Boolean()
15
+ })),
16
+ sheet: Type.Object({
17
+ name: Text,
18
+ protected: Type.Boolean(),
19
+ widths: Type.Array(Type.Number()),
20
+ heights: Type.Array(Type.Number()),
21
+ rows: Type.Array(Type.Array(Type.Union([Cell, Type.Null()])))
22
+ }),
23
+ revision: Type.Integer({ minimum: 0 }),
24
+ file: Type.Object({
25
+ state: Type.Union([
26
+ Type.Literal("saved"),
27
+ Type.Literal("consent"),
28
+ Type.Literal("readOnly")
29
+ ]),
30
+ lossyParts: Type.Array(Text)
31
+ })
32
+ });
33
+ const Line = {
34
+ at: Type.Integer({ minimum: 1 }),
35
+ count: Type.Optional(Type.Integer({ minimum: 1 }))
36
+ };
37
+ const Edit = Type.Union([
38
+ Type.Object({
39
+ kind: Type.Literal("setCell"),
40
+ cell: Text,
41
+ input: Text
42
+ }),
43
+ Type.Object({
44
+ kind: Type.Union([
45
+ "insertRows",
46
+ "deleteRows",
47
+ "insertColumns",
48
+ "deleteColumns"
49
+ ].map((kind) => Type.Literal(kind))),
50
+ ...Line
51
+ }),
52
+ Type.Object({
53
+ kind: Type.Union([Type.Literal("columnWidth"), Type.Literal("rowHeight")]),
54
+ ...Line,
55
+ size: Type.Number({ minimum: 0 })
56
+ }),
57
+ Type.Object({
58
+ kind: Type.Literal("addSheet"),
59
+ name: Text
60
+ }),
61
+ Type.Object({ kind: Type.Literal("undo") })
62
+ ]);
63
+ /** A workspace-relative path, or `artifact:<relative>` for the session's artifacts. */
64
+ const Path = {
65
+ name: "path",
66
+ in: "query",
67
+ required: true,
68
+ schema: Text
69
+ };
70
+ const json = (schema) => ({
71
+ required: true,
72
+ contentType: "application/json",
73
+ schema
74
+ });
75
+ const route = {
76
+ scope: "session",
77
+ basePath: "spreadsheet",
78
+ authentication: "owner"
79
+ };
80
+ const apiContracts = defineApiContract({
81
+ version: 1,
82
+ http: [
83
+ {
84
+ ...route,
85
+ id: "spreadsheet.view",
86
+ path: "/workbook",
87
+ method: "GET",
88
+ description: "Open an .xlsx workbook and read one sheet; the first sheet when `sheet` is empty.",
89
+ parameters: [Path, {
90
+ name: "sheet",
91
+ in: "query",
92
+ required: false,
93
+ schema: Text
94
+ }],
95
+ responses: jsonApiResponses(View)
96
+ },
97
+ {
98
+ ...route,
99
+ id: "spreadsheet.edit",
100
+ path: "/workbook/edit",
101
+ method: "POST",
102
+ description: "Apply up to 500 edits in order and save them, fenced by the file SHA-256 and the optional revision. Protected sheets refuse every edit.",
103
+ body: json(Type.Object({
104
+ path: Text,
105
+ sheet: Text,
106
+ revision: Type.Optional(Type.Integer({ minimum: 0 })),
107
+ edits: Type.Array(Edit, {
108
+ minItems: 1,
109
+ maxItems: 500
110
+ })
111
+ })),
112
+ responses: jsonApiResponses(View)
113
+ },
114
+ {
115
+ ...route,
116
+ id: "spreadsheet.consent",
117
+ path: "/workbook/consent",
118
+ method: "POST",
119
+ description: "Record that the person agreed to save a workbook the engine may simplify, then save it.",
120
+ body: json(Type.Object({
121
+ path: Text,
122
+ sheet: Text
123
+ })),
124
+ responses: jsonApiResponses(View)
125
+ },
126
+ {
127
+ ...route,
128
+ id: "spreadsheet.download",
129
+ path: "/workbook/download",
130
+ method: "GET",
131
+ description: "Export the open workbook, edits included, as base64 XLSX bytes.",
132
+ parameters: [Path],
133
+ responses: jsonApiResponses(Type.Object({
134
+ name: Text,
135
+ xlsx: Text
136
+ }))
137
+ }
138
+ ],
139
+ sockets: [],
140
+ dynamic: []
141
+ });
142
+ //#endregion
143
+ export { apiContracts, apiContracts as default };
144
+
145
+ //# sourceMappingURL=apiContracts.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"apiContracts.mjs","names":[],"sources":["../src/schemas/apiContracts.ts"],"sourcesContent":["import { defineApiContract, jsonApiResponses } from '@agimon-ai/po-core/apiContracts';\nimport { Type } from 'typebox';\n\nconst Text = Type.String();\nconst Cell = Type.Object({ text: Text, input: Text, numeric: Type.Boolean(), bold: Type.Boolean() });\nconst View = Type.Object({\n sheets: Type.Array(Type.Object({ name: Text, protected: Type.Boolean() })),\n sheet: Type.Object({\n name: Text,\n protected: Type.Boolean(),\n widths: Type.Array(Type.Number()),\n heights: Type.Array(Type.Number()),\n rows: Type.Array(Type.Array(Type.Union([Cell, Type.Null()]))),\n }),\n revision: Type.Integer({ minimum: 0 }),\n file: Type.Object({\n state: Type.Union([Type.Literal('saved'), Type.Literal('consent'), Type.Literal('readOnly')]),\n lossyParts: Type.Array(Text),\n }),\n});\nconst Line = { at: Type.Integer({ minimum: 1 }), count: Type.Optional(Type.Integer({ minimum: 1 })) };\nconst Edit = Type.Union([\n Type.Object({ kind: Type.Literal('setCell'), cell: Text, input: Text }),\n Type.Object({\n kind: Type.Union(['insertRows', 'deleteRows', 'insertColumns', 'deleteColumns'].map((kind) => Type.Literal(kind))),\n ...Line,\n }),\n Type.Object({\n kind: Type.Union([Type.Literal('columnWidth'), Type.Literal('rowHeight')]),\n ...Line,\n size: Type.Number({ minimum: 0 }),\n }),\n Type.Object({ kind: Type.Literal('addSheet'), name: Text }),\n Type.Object({ kind: Type.Literal('undo') }),\n]);\n/** A workspace-relative path, or `artifact:<relative>` for the session's artifacts. */\nconst Path = { name: 'path', in: 'query' as const, required: true, schema: Text };\nconst json = (schema: object) => ({ required: true, contentType: 'application/json', schema });\nconst route = {\n scope: 'session' as const,\n basePath: 'spreadsheet',\n authentication: 'owner' as const,\n};\n\nexport const apiContracts = defineApiContract({\n version: 1,\n http: [\n {\n ...route,\n id: 'spreadsheet.view',\n path: '/workbook',\n method: 'GET',\n description: 'Open an .xlsx workbook and read one sheet; the first sheet when `sheet` is empty.',\n parameters: [Path, { name: 'sheet', in: 'query', required: false, schema: Text }],\n responses: jsonApiResponses(View),\n },\n {\n ...route,\n id: 'spreadsheet.edit',\n path: '/workbook/edit',\n method: 'POST',\n description:\n 'Apply up to 500 edits in order and save them, fenced by the file SHA-256 and the optional revision. Protected sheets refuse every edit.',\n body: json(\n Type.Object({\n path: Text,\n sheet: Text,\n revision: Type.Optional(Type.Integer({ minimum: 0 })),\n edits: Type.Array(Edit, { minItems: 1, maxItems: 500 }),\n }),\n ),\n responses: jsonApiResponses(View),\n },\n {\n ...route,\n id: 'spreadsheet.consent',\n path: '/workbook/consent',\n method: 'POST',\n description: 'Record that the person agreed to save a workbook the engine may simplify, then save it.',\n body: json(Type.Object({ path: Text, sheet: Text })),\n responses: jsonApiResponses(View),\n },\n {\n ...route,\n id: 'spreadsheet.download',\n path: '/workbook/download',\n method: 'GET',\n description: 'Export the open workbook, edits included, as base64 XLSX bytes.',\n parameters: [Path],\n responses: jsonApiResponses(Type.Object({ name: Text, xlsx: Text })),\n },\n ],\n sockets: [],\n dynamic: [],\n});\n"],"mappings":";;;AAGA,MAAM,OAAO,KAAK,OAAO;AACzB,MAAM,OAAO,KAAK,OAAO;CAAE,MAAM;CAAM,OAAO;CAAM,SAAS,KAAK,QAAQ;CAAG,MAAM,KAAK,QAAQ;AAAE,CAAC;AACnG,MAAM,OAAO,KAAK,OAAO;CACvB,QAAQ,KAAK,MAAM,KAAK,OAAO;EAAE,MAAM;EAAM,WAAW,KAAK,QAAQ;CAAE,CAAC,CAAC;CACzE,OAAO,KAAK,OAAO;EACjB,MAAM;EACN,WAAW,KAAK,QAAQ;EACxB,QAAQ,KAAK,MAAM,KAAK,OAAO,CAAC;EAChC,SAAS,KAAK,MAAM,KAAK,OAAO,CAAC;EACjC,MAAM,KAAK,MAAM,KAAK,MAAM,KAAK,MAAM,CAAC,MAAM,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC;CAC9D,CAAC;CACD,UAAU,KAAK,QAAQ,EAAE,SAAS,EAAE,CAAC;CACrC,MAAM,KAAK,OAAO;EAChB,OAAO,KAAK,MAAM;GAAC,KAAK,QAAQ,OAAO;GAAG,KAAK,QAAQ,SAAS;GAAG,KAAK,QAAQ,UAAU;EAAC,CAAC;EAC5F,YAAY,KAAK,MAAM,IAAI;CAC7B,CAAC;AACH,CAAC;AACD,MAAM,OAAO;CAAE,IAAI,KAAK,QAAQ,EAAE,SAAS,EAAE,CAAC;CAAG,OAAO,KAAK,SAAS,KAAK,QAAQ,EA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