@k2b/cloud 0.38.0 → 0.39.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/package.json +6 -3
- package/scripts/build-canvas-workers.ts +109 -29
- package/scripts/build.ts +3 -5
- package/src/_internal/app-path.ts +25 -0
- package/src/_internal/app-presentation.ts +4 -0
- package/src/_internal/canvas-worker.ts +5 -3
- package/src/_internal/define-app.ts +28 -2
- package/src/_internal/panel-cookie.ts +39 -0
- package/src/_internal/registry-validation.ts +21 -26
- package/src/_internal/runtime-context.ts +1 -0
- package/src/access/PermissionEditor.browser-harness.tsx +57 -38
- package/src/access/PermissionEditor.tsx +30 -5
- package/src/access/ResourceApiKeys.tsx +5 -1
- package/src/ai/approval-routes.ts +5 -2
- package/src/ai/approvals.ts +139 -28
- package/src/ai/browser.ts +10 -0
- package/src/ai/chat/action-sentences.ts +1 -44
- package/src/ai/chat/turn-view.tsx +35 -3
- package/src/ai/chat/view-block.tsx +7 -2
- package/src/ai/chat-task-contracts.ts +28 -3
- package/src/ai/chat-task-reasons-migrate.ts +68 -0
- package/src/ai/chat-task-reasons.ts +92 -0
- package/src/ai/chat-tasks.ts +396 -66
- package/src/ai/index.ts +12 -0
- package/src/ai/migrate.ts +28 -2
- package/src/ai/request-context.ts +7 -1
- package/src/ai/routes.ts +27 -1
- package/src/ai/runtime.ts +12 -27
- package/src/ai/store.ts +5 -3
- package/src/ai/timeline.ts +9 -1
- package/src/ai/tool-wording.ts +45 -0
- package/src/ai/turn-abort.ts +33 -0
- package/src/ai/types.ts +12 -1
- package/src/api/admin-core-settings.ts +190 -139
- package/src/api/admin-outgoing-mail.ts +4 -2
- package/src/api/app-approval.ts +9 -2
- package/src/api/approvals.ts +1 -1
- package/src/api/index.ts +2 -1
- package/src/browser/CloudResourceSearch.tsx +10 -6
- package/src/browser/app-approval.ts +7 -2
- package/src/browser/composer-catalog.ts +103 -0
- package/src/browser/composer-insert-messages.ts +31 -0
- package/src/browser/composer-insert.ts +150 -0
- package/src/browser/panel-messages.ts +24 -0
- package/src/browser/panel-slot.ts +354 -0
- package/src/browser/panel.ts +28 -0
- package/src/browser/resource-picker.tsx +12 -1
- package/src/contracts/app-approval.ts +49 -9
- package/src/contracts/app.ts +14 -0
- package/src/contracts/registry.ts +3 -1
- package/src/contracts/shared.ts +2 -0
- package/src/server/services/access.ts +5 -1
- package/src/services/accounts/posix.ts +2 -1
- package/src/services/app-approval.ts +158 -38
- package/src/services/approvals/device.ts +2 -0
- package/src/services/index.ts +21 -3
- package/src/services/notifications/browser.ts +16 -5
- package/src/services/pdf/image-protocol.ts +135 -0
- package/src/services/pdf/image-variants.ts +124 -0
- package/src/services/pdf/image-worker.ts +31 -0
- package/src/services/pdf/image.ts +109 -0
- package/src/services/pdf/index.ts +9 -0
- package/src/services/settings/api.ts +11 -6
- package/src/services/settings/app.ts +5 -4
- package/src/services/settings/core-settings.ts +4 -3
- package/src/services/settings/index.ts +19 -17
- package/src/services/settings/namespace.ts +2 -1
- package/src/services/settings/store.ts +83 -11
- package/src/shared/ai-platform-prompt.ts +1 -1
- package/src/shared/app-presentation.ts +1 -0
- package/src/shared/redirect.ts +12 -0
- package/src/ssr/CloudShell.island.tsx +86 -9
- package/src/ssr/Layout.tsx +42 -9
- package/src/ssr/LayoutHeader.tsx +15 -9
- package/src/ssr/LayoutHelp.tsx +1 -1
- package/src/ssr/LayoutRail.tsx +2 -2
- package/src/ssr/LayoutTabBar.tsx +29 -0
- package/src/ssr/PanelLayout.tsx +27 -0
- package/src/ssr/PanelRuntime.island.tsx +87 -0
- package/src/ssr/PanelSlot.tsx +108 -0
- package/src/ssr/PanelTrigger.tsx +49 -0
- package/src/ssr/ShellRuntime.island.tsx +60 -5
- package/src/ssr/app-appearance.ts +3 -2
- package/src/ssr/app-color.ts +100 -0
- package/src/ssr/app-launchpad.tsx +18 -1
- package/src/ssr/app-navigation.ts +15 -0
- package/src/ssr/compact-shell.baseline.json +5270 -0
- package/src/ssr/compact-shell.browser-harness.ts +431 -0
- package/src/ssr/index.ts +3 -0
- package/src/ssr/panel-slot.browser-harness.tsx +110 -0
- package/src/ssr/platform-messages.ts +30 -0
- package/src/ssr/rail-navigation.ts +44 -0
- package/src/ssr/shell-data.tsx +4 -0
- package/src/ssr/shell-shortcuts.ts +13 -2
- package/src/styles/effects.css +3 -2
- package/src/styles/global.css +269 -55
- package/src/styles/panel.css +373 -0
- package/src/styles/tokens.css +23 -6
- package/src/styles/utilities-navigation.css +5 -21
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { dates, i18n } from "@k2b/stdlib";
|
|
2
|
+
import { canonicalLocale } from "../shared/locale";
|
|
3
|
+
|
|
4
|
+
export const CHAT_TASK_REASON_CODES = ["paused", "chat_archived", "owner_inactive", "failed", "rights_changed", "needs_approval"] as const;
|
|
5
|
+
export type ChatTaskReasonCode = (typeof CHAT_TASK_REASON_CODES)[number];
|
|
6
|
+
export type ChatTaskReason = { code: ChatTaskReasonCode; at: string; action?: string };
|
|
7
|
+
|
|
8
|
+
export const chatTaskReasonState = (code: ChatTaskReasonCode): "paused" | "needs_attention" => {
|
|
9
|
+
switch (code) {
|
|
10
|
+
case "paused":
|
|
11
|
+
case "chat_archived":
|
|
12
|
+
case "owner_inactive":
|
|
13
|
+
return "paused";
|
|
14
|
+
case "failed":
|
|
15
|
+
case "rights_changed":
|
|
16
|
+
case "needs_approval":
|
|
17
|
+
return "needs_attention";
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
const messages = i18n.define({
|
|
22
|
+
baseLocale: "en",
|
|
23
|
+
messages: {
|
|
24
|
+
en: {
|
|
25
|
+
paused: ({ time }: { time: string }) => `Paused by you on ${time}. What happens meanwhile is not caught up automatically.`,
|
|
26
|
+
chat_archived: "Paused because the chat is archived.",
|
|
27
|
+
owner_inactive: "Paused because the account is inactive.",
|
|
28
|
+
failed: "The last run failed.",
|
|
29
|
+
rights_changed: "What it may do changed. Please confirm again.",
|
|
30
|
+
needs_approval: ({ action }: { action?: string }) =>
|
|
31
|
+
`${action ? `Tried to ${action}. ` : ""}That needs your approval every time, and routines never ask.`,
|
|
32
|
+
stopped: ({ list }: { list: string }) =>
|
|
33
|
+
list
|
|
34
|
+
? `Stopped while the routine was running. Already done: ${list}. Nothing was undone.`
|
|
35
|
+
: "Stopped while the routine was running. Nothing was undone.",
|
|
36
|
+
},
|
|
37
|
+
de: {
|
|
38
|
+
paused: ({ time }) => `Von dir pausiert am ${time}. Was in der Pause passiert, wird nicht von selbst nachgeholt.`,
|
|
39
|
+
chat_archived: "Pausiert, weil der Chat archiviert ist.",
|
|
40
|
+
owner_inactive: "Pausiert, weil das Konto inaktiv ist.",
|
|
41
|
+
failed: "Der letzte Lauf ist fehlgeschlagen.",
|
|
42
|
+
rights_changed: "Was sie darf, hat sich geändert. Bitte neu bestätigen.",
|
|
43
|
+
needs_approval: ({ action }) => `${action ? `Wollte ${action}. ` : ""}Das macht der Assistant nur mit dir, und Routinen fragen nie.`,
|
|
44
|
+
stopped: ({ list }) =>
|
|
45
|
+
list
|
|
46
|
+
? `Angehalten, während die Routine lief. Schon erledigt: ${list}. Nichts wurde rückgängig gemacht.`
|
|
47
|
+
: "Angehalten, während die Routine lief. Nichts wurde rückgängig gemacht.",
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* A one-time routine resumes only before its time: a run at that time already happened or was stopped, and what was
|
|
54
|
+
* missed in a pause is not caught up. It needs a new time first.
|
|
55
|
+
*/
|
|
56
|
+
export const chatTaskNeedsNewTime = (
|
|
57
|
+
task: {
|
|
58
|
+
state: "active" | "paused" | "completed" | "needs_attention";
|
|
59
|
+
schedule: { kind: "once"; runAt: string } | { kind: "cron"; cron: string };
|
|
60
|
+
},
|
|
61
|
+
now: Date = new Date(),
|
|
62
|
+
): boolean =>
|
|
63
|
+
task.state !== "active" &&
|
|
64
|
+
task.schedule.kind === "once" &&
|
|
65
|
+
(task.state === "needs_attention" || Date.parse(task.schedule.runAt) <= now.getTime());
|
|
66
|
+
|
|
67
|
+
export const chatTaskLocale = (taskLocale: string | null | undefined, appLocale?: string | null): string =>
|
|
68
|
+
canonicalLocale(taskLocale) ?? canonicalLocale(appLocale) ?? "en";
|
|
69
|
+
|
|
70
|
+
export const chatTaskReasonSentence = (reason: ChatTaskReason, context: { locale: string; timeZone: string }): string => {
|
|
71
|
+
const t = messages.resolve([context.locale]).t;
|
|
72
|
+
// The record is exhaustive: a new reason must have a sentence in both catalogs.
|
|
73
|
+
const sentences: Record<ChatTaskReasonCode, () => string> = {
|
|
74
|
+
paused: () => t.paused({ time: dates.formatDateTime(reason.at, context) }),
|
|
75
|
+
chat_archived: () => t.chat_archived,
|
|
76
|
+
owner_inactive: () => t.owner_inactive,
|
|
77
|
+
failed: () => t.failed,
|
|
78
|
+
rights_changed: () => t.rights_changed,
|
|
79
|
+
needs_approval: () => t.needs_approval({ action: reason.action }),
|
|
80
|
+
};
|
|
81
|
+
return sentences[reason.code]();
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
// A scan from the end instead of /[.!?]+$/, which backtracks quadratically on long runs of punctuation.
|
|
85
|
+
const withoutClosingPunctuation = (text: string): string => {
|
|
86
|
+
let end = text.length;
|
|
87
|
+
while (end > 0 && ".!?".includes(text[end - 1]!)) end -= 1;
|
|
88
|
+
return text.slice(0, end);
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
export const chatTaskStopSentence = (done: readonly string[], locale: string): string =>
|
|
92
|
+
messages.resolve([locale]).t.stopped({ list: done.map(withoutClosingPunctuation).join("; ") });
|