@agimon-ai/po-author 0.0.0-alpha.20 → 0.0.0-alpha.22

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 CHANGED
@@ -1,21 +1,149 @@
1
- MIT License
2
-
3
- Copyright (c) 2026 Vuong Ngo
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
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.
@@ -1,7 +1,7 @@
1
1
  import { apiResponse, createApiClient, defineApiRoutes, defineChannelFile, defineDockFace, defineFileLinks, defineFill, defineGlobalStore, defineLeaderBinding, defineMinorModeFile, defineSessionStore, defineSlotFile, defineToolRenderer, defineWebLifecycle, defineWebPlugin, sessionApiAddress, toolResultTextLines } from "@agimon-ai/po-core/web";
2
2
  import { Store } from "@tanstack/store";
3
3
  import { useStore } from "@tanstack/react-store";
4
- import { useEffect, useRef, useState } from "react";
4
+ import { useEffect, useLayoutEffect, useRef, useState } from "react";
5
5
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
6
6
  import { Button, CodeEditor, Dot, FileIcon, Markdown, MediaPreview, MessageItem, MessageItemBody, MessageItemHeader, MessageItemStatus, MessageLines, SparklesIcon, StatusBadge, TrashIcon, collapseLines, toolTone } from "@agimon-ai/po-web-components";
7
7
  import { sealedTransport } from "@agimon-ai/po-web-security/browser";
@@ -2458,6 +2458,11 @@ function authorSessionFileUrl(sessionId, path) {
2458
2458
  if (path.startsWith("artifact:")) return artifactApi.session(sessionId).content.url({ query: { path: path.slice(9) } });
2459
2459
  return api.session(sessionId).file.url({ query: { path } });
2460
2460
  }
2461
+ /** The file name a person sees: the last path segment, without the `artifact:` scheme. */
2462
+ function authorFileName(path) {
2463
+ const local = path.startsWith("artifact:") ? path.slice(9) : path;
2464
+ return local.split("/").at(-1) ?? local;
2465
+ }
2461
2466
  /**
2462
2467
  * po-artifact's read route, which owns the session artifact folder's guards.
2463
2468
  * Browser code cannot import that package, so its one raw route is restated.
@@ -2502,7 +2507,7 @@ async function loadAuthorDocument(sessionId, path, signal) {
2502
2507
  return {
2503
2508
  path,
2504
2509
  kind,
2505
- title: path.split("/").at(-1) ?? path,
2510
+ title: authorFileName(path),
2506
2511
  structuredFormat: format,
2507
2512
  fragments: parsed.fragments,
2508
2513
  ...csvDialect === void 0 ? {} : { csvDialect },
@@ -2515,7 +2520,7 @@ async function loadAuthorDocument(sessionId, path, signal) {
2515
2520
  return {
2516
2521
  path,
2517
2522
  kind,
2518
- title: path.split("/").at(-1) ?? path,
2523
+ title: authorFileName(path),
2519
2524
  ...content === void 0 ? {} : { content },
2520
2525
  ...mediaUrl === void 0 ? {} : { mediaUrl },
2521
2526
  ...sourceSha256 === void 0 ? {} : { sourceSha256 }
@@ -3175,7 +3180,35 @@ function AuthorMediaView({ sessionId, document: source, activeTool, displayedReg
3175
3180
  const pointers = useRef(/* @__PURE__ */ new Map());
3176
3181
  const pan = useRef(void 0);
3177
3182
  const pinch = useRef(void 0);
3183
+ const frame = useRef(null);
3184
+ const zoomAnchor = useRef(void 0);
3178
3185
  const [zoom, setZoom] = useState(1);
3186
+ const zoomTo = (requested, at) => {
3187
+ const next = Math.min(8, Math.max(.25, requested));
3188
+ if (next === zoom) return;
3189
+ const view = host.current?.getBoundingClientRect();
3190
+ const bounds = frame.current?.getBoundingClientRect();
3191
+ if (view && bounds && bounds.width > 0 && bounds.height > 0) {
3192
+ const x = at?.x ?? view.left + view.width / 2;
3193
+ const y = at?.y ?? view.top + view.height / 2;
3194
+ zoomAnchor.current = {
3195
+ x,
3196
+ y,
3197
+ fx: (x - bounds.left) / bounds.width,
3198
+ fy: (y - bounds.top) / bounds.height
3199
+ };
3200
+ }
3201
+ setZoom(next);
3202
+ };
3203
+ useLayoutEffect(() => {
3204
+ const anchor = zoomAnchor.current;
3205
+ zoomAnchor.current = void 0;
3206
+ const container = host.current;
3207
+ const bounds = frame.current?.getBoundingClientRect();
3208
+ if (!anchor || !container || !bounds) return;
3209
+ container.scrollLeft += bounds.left + anchor.fx * bounds.width - anchor.x;
3210
+ container.scrollTop += bounds.top + anchor.fy * bounds.height - anchor.y;
3211
+ }, [zoom]);
3179
3212
  const [stroke, setStroke] = useState();
3180
3213
  const [pdfPlane, setPdfPlane] = useState();
3181
3214
  const [playback, setPlayback] = useState({
@@ -3194,6 +3227,7 @@ function AuthorMediaView({ sessionId, document: source, activeTool, displayedReg
3194
3227
  pan.current = void 0;
3195
3228
  setStroke(void 0);
3196
3229
  setSelection(void 0);
3230
+ zoomAnchor.current = void 0;
3197
3231
  setZoom(1);
3198
3232
  }, [
3199
3233
  source.path,
@@ -3485,7 +3519,10 @@ function AuthorMediaView({ sessionId, document: source, activeTool, displayedReg
3485
3519
  if (pinch.current !== void 0 && pointers.current.size >= 2) {
3486
3520
  const [a, b] = [...pointers.current.values()];
3487
3521
  const distance = Math.hypot(a.x - b.x, a.y - b.y);
3488
- if (pinch.current.distance > 0) setZoom(Math.min(8, Math.max(1, pinch.current.zoom * distance / pinch.current.distance)));
3522
+ if (pinch.current.distance > 0) zoomTo(pinch.current.zoom * distance / pinch.current.distance, {
3523
+ x: (a.x + b.x) / 2,
3524
+ y: (a.y + b.y) / 2
3525
+ });
3489
3526
  return;
3490
3527
  }
3491
3528
  if (pan.current !== void 0 && activeTool === "pan") {
@@ -3597,15 +3634,16 @@ function AuthorMediaView({ sessionId, document: source, activeTool, displayedReg
3597
3634
  },
3598
3635
  children: [/* @__PURE__ */ jsx("div", {
3599
3636
  ref: host,
3600
- className: "flex min-h-0 flex-1 flex-col overflow-auto bg-po-deep/50 p-6",
3637
+ className: "@container flex min-h-0 flex-1 flex-col overflow-auto bg-po-deep/50 p-6",
3601
3638
  children: /* @__PURE__ */ jsxs("div", {
3602
- className: "m-auto flex max-w-full flex-col items-center gap-3",
3639
+ className: "m-auto flex max-w-full flex-col items-center-safe gap-3",
3603
3640
  children: [
3604
3641
  mediaUrl === void 0 ? /* @__PURE__ */ jsx("p", {
3605
3642
  className: "text-po-dim",
3606
3643
  children: error === void 0 ? "Loading media..." : "Media unavailable."
3607
3644
  }) : source.kind === "image" ? /* @__PURE__ */ jsxs("div", {
3608
- className: "relative inline-block max-w-full shadow-sm ring-1 ring-po-border-soft",
3645
+ ref: frame,
3646
+ className: "relative w-max max-w-[100cqw] shadow-sm ring-1 ring-po-border-soft",
3609
3647
  style: {
3610
3648
  zoom,
3611
3649
  touchAction: activeTool === "select" ? "auto" : "none"
@@ -3646,7 +3684,8 @@ function AuthorMediaView({ sessionId, document: source, activeTool, displayedReg
3646
3684
  })
3647
3685
  ]
3648
3686
  }) : /* @__PURE__ */ jsxs("div", {
3649
- className: "relative w-fit max-w-full shadow-sm ring-1 ring-po-border-soft",
3687
+ ref: frame,
3688
+ className: "relative w-max max-w-[100cqw] shadow-sm ring-1 ring-po-border-soft",
3650
3689
  style: {
3651
3690
  zoom,
3652
3691
  touchAction: activeTool === "select" ? "auto" : "none"
@@ -3765,7 +3804,7 @@ function AuthorMediaView({ sessionId, document: source, activeTool, displayedReg
3765
3804
  variant: "ghost",
3766
3805
  "aria-label": "Zoom out",
3767
3806
  className: "min-h-11 min-w-11 rounded-r-none [@media(pointer:fine)]:min-h-8",
3768
- onClick: () => setZoom((current) => Math.max(1, current / 1.5)),
3807
+ onClick: () => zoomTo(zoom / 1.5),
3769
3808
  children: "−"
3770
3809
  }),
3771
3810
  /* @__PURE__ */ jsxs("output", {
@@ -3777,7 +3816,7 @@ function AuthorMediaView({ sessionId, document: source, activeTool, displayedReg
3777
3816
  variant: "ghost",
3778
3817
  "aria-label": "Zoom in",
3779
3818
  className: "min-h-11 min-w-11 rounded-l-none [@media(pointer:fine)]:min-h-8",
3780
- onClick: () => setZoom((current) => Math.min(8, current * 1.5)),
3819
+ onClick: () => zoomTo(zoom * 1.5),
3781
3820
  children: "+"
3782
3821
  })
3783
3822
  ]
@@ -3787,6 +3826,7 @@ function AuthorMediaView({ sessionId, document: source, activeTool, displayedReg
3787
3826
  "aria-label": "Fit canvas",
3788
3827
  className: "min-h-11 [@media(pointer:fine)]:min-h-8",
3789
3828
  onClick: () => {
3829
+ zoomAnchor.current = void 0;
3790
3830
  setZoom(1);
3791
3831
  if (host.current) {
3792
3832
  host.current.scrollLeft = 0;
@@ -4300,13 +4340,13 @@ function authorFileTab(path, preferredAlias) {
4300
4340
  const normalized = normalizeAuthorPath(path);
4301
4341
  return {
4302
4342
  id: tabId(normalized),
4303
- label: preferredAlias === void 0 ? normalized.split("/").at(-1) ?? normalized : `${preferredAlias} · ${normalized.split("/").at(-1) ?? normalized}`,
4343
+ label: preferredAlias === void 0 ? authorFileName(normalized) : `${preferredAlias} · ${authorFileName(normalized)}`,
4304
4344
  retainComposer: true,
4305
4345
  composerContext(sessionId) {
4306
4346
  const key = authorDocumentKey(sessionId, normalized);
4307
4347
  const documentPath = canvasPaths.state[key] ?? normalized;
4308
4348
  const alias = canvasAliases.state[key];
4309
- const name = documentPath.split("/").at(-1) ?? documentPath;
4349
+ const name = authorFileName(documentPath);
4310
4350
  return {
4311
4351
  kind: "author-document",
4312
4352
  source: "author",