@arbidocs/blocks 0.5.198 → 0.5.200
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/dist/{ConnectedCallDock-CJTL2FDV.cjs → ConnectedCallDock-UCNWTCTS.cjs} +23 -23
- package/dist/{ConnectedCallDock-CJTL2FDV.cjs.map → ConnectedCallDock-UCNWTCTS.cjs.map} +1 -1
- package/dist/{ConnectedCallRoom-DXUZXFZX.cjs → ConnectedCallRoom-BN2EMZ7A.cjs} +16 -16
- package/dist/{ConnectedCallRoom-DXUZXFZX.cjs.map → ConnectedCallRoom-BN2EMZ7A.cjs.map} +1 -1
- package/dist/{ConnectedNativeDocxComparison-FDBAVRFO.cjs → ConnectedNativeDocxComparison-4DTDQQXI.cjs} +15 -15
- package/dist/{ConnectedNativeDocxComparison-FDBAVRFO.cjs.map → ConnectedNativeDocxComparison-4DTDQQXI.cjs.map} +1 -1
- package/dist/{ConnectedPresentation-VGWCLJKM.cjs → ConnectedPresentation-OIMVGUAZ.cjs} +17 -17
- package/dist/{ConnectedPresentation-VGWCLJKM.cjs.map → ConnectedPresentation-OIMVGUAZ.cjs.map} +1 -1
- package/dist/{ConnectedProductionSetDialog-R7FVJ4X7.cjs → ConnectedProductionSetDialog-ENRCLFAF.cjs} +6 -6
- package/dist/{ConnectedProductionSetDialog-R7FVJ4X7.cjs.map → ConnectedProductionSetDialog-ENRCLFAF.cjs.map} +1 -1
- package/dist/{ConnectedSlidesTab-PCJTMD3W.cjs → ConnectedSlidesTab-NSNOGSE7.cjs} +14 -14
- package/dist/{ConnectedSlidesTab-PCJTMD3W.cjs.map → ConnectedSlidesTab-NSNOGSE7.cjs.map} +1 -1
- package/dist/{ConnectedStreamedWordArtifact-JET44WCX.cjs → ConnectedStreamedWordArtifact-FHEHPYUO.cjs} +15 -15
- package/dist/{ConnectedStreamedWordArtifact-JET44WCX.cjs.map → ConnectedStreamedWordArtifact-FHEHPYUO.cjs.map} +1 -1
- package/dist/{DocumentReviewCard-CJHMIMSM.cjs → DocumentReviewCard-XCEFFM2E.cjs} +16 -16
- package/dist/{DocumentReviewCard-CJHMIMSM.cjs.map → DocumentReviewCard-XCEFFM2E.cjs.map} +1 -1
- package/dist/{FilesViewerDialog-NOHWHFKC.cjs → FilesViewerDialog-J4XHAODW.cjs} +51 -51
- package/dist/{FilesViewerDialog-NOHWHFKC.cjs.map → FilesViewerDialog-J4XHAODW.cjs.map} +1 -1
- package/dist/{WorkspaceTableView-XK7L4MU6.cjs → WorkspaceTableView-DIM3XSI7.cjs} +9 -9
- package/dist/{WorkspaceTableView-XK7L4MU6.cjs.map → WorkspaceTableView-DIM3XSI7.cjs.map} +1 -1
- package/dist/agents/index.cjs +445 -428
- package/dist/agents/tasks/TaskComposer.js +4 -3
- package/dist/agents/tasks/TaskComposer.js.map +2 -2
- package/dist/agents/tasks/WorkflowComposer.d.ts +1 -1
- package/dist/agents/tasks/WorkflowComposer.js +5 -4
- package/dist/agents/tasks/WorkflowComposer.js.map +2 -2
- package/dist/agents/tasks/index.d.ts +1 -1
- package/dist/agents/tasks/index.js +9 -1
- package/dist/agents/tasks/index.js.map +2 -2
- package/dist/agents/tasks/taskComposerTypes.d.ts +20 -3
- package/dist/agents/tasks/taskComposerTypes.js +25 -4
- package/dist/agents/tasks/taskComposerTypes.js.map +2 -2
- package/dist/agents/tasks/taskRequest.d.ts +5 -4
- package/dist/agents/tasks/taskRequest.js +9 -2
- package/dist/agents/tasks/taskRequest.js.map +2 -2
- package/dist/agents/workflows/planSteps.js +6 -3
- package/dist/agents/workflows/planSteps.js.map +2 -2
- package/dist/{ai-RIR36YJR.cjs → ai-BUYAHCUP.cjs} +37 -27
- package/dist/ai-BUYAHCUP.cjs.map +1 -0
- package/dist/auth/index.cjs +12 -12
- package/dist/calls/index.cjs +125 -125
- package/dist/chat/AssistantDock.d.ts +2 -2
- package/dist/chat/AssistantDock.js +3 -1
- package/dist/chat/AssistantDock.js.map +2 -2
- package/dist/chat/ChatPage.d.ts +1 -1
- package/dist/chat/ChatPage.js +19 -1
- package/dist/chat/ChatPage.js.map +2 -2
- package/dist/chat/chat-page-types.d.ts +12 -0
- package/dist/chat/chat-page-types.js.map +2 -2
- package/dist/chat/index.cjs +29 -29
- package/dist/{chunk-V4362YKU.cjs → chunk-2A3LUSU6.cjs} +4 -4
- package/dist/{chunk-V4362YKU.cjs.map → chunk-2A3LUSU6.cjs.map} +1 -1
- package/dist/{chunk-RIGCKOUY.cjs → chunk-2GSNYENP.cjs} +4 -4
- package/dist/{chunk-RIGCKOUY.cjs.map → chunk-2GSNYENP.cjs.map} +1 -1
- package/dist/{chunk-QFSFTO7I.cjs → chunk-2NAYUIT4.cjs} +153 -4
- package/dist/chunk-2NAYUIT4.cjs.map +1 -0
- package/dist/{chunk-OVUI43LB.cjs → chunk-33DJDPVL.cjs} +4 -4
- package/dist/{chunk-OVUI43LB.cjs.map → chunk-33DJDPVL.cjs.map} +1 -1
- package/dist/{chunk-4N2IKS6V.cjs → chunk-3IYVFQO7.cjs} +118 -79
- package/dist/chunk-3IYVFQO7.cjs.map +1 -0
- package/dist/{chunk-5OD6DRG7.cjs → chunk-3P6KGC46.cjs} +3 -3
- package/dist/{chunk-5OD6DRG7.cjs.map → chunk-3P6KGC46.cjs.map} +1 -1
- package/dist/{chunk-ZMGPE43A.cjs → chunk-3V7IAS52.cjs} +6 -6
- package/dist/{chunk-ZMGPE43A.cjs.map → chunk-3V7IAS52.cjs.map} +1 -1
- package/dist/{chunk-OGQXIFIL.cjs → chunk-4IDPBMZQ.cjs} +8 -8
- package/dist/{chunk-OGQXIFIL.cjs.map → chunk-4IDPBMZQ.cjs.map} +1 -1
- package/dist/{chunk-T44BYZNJ.cjs → chunk-4SPLVRCR.cjs} +3 -3
- package/dist/{chunk-T44BYZNJ.cjs.map → chunk-4SPLVRCR.cjs.map} +1 -1
- package/dist/{chunk-PIM7D4BJ.cjs → chunk-55DGUHLE.cjs} +4 -4
- package/dist/{chunk-PIM7D4BJ.cjs.map → chunk-55DGUHLE.cjs.map} +1 -1
- package/dist/{chunk-QPSLGOIH.cjs → chunk-ADICO4AG.cjs} +4 -4
- package/dist/{chunk-QPSLGOIH.cjs.map → chunk-ADICO4AG.cjs.map} +1 -1
- package/dist/{chunk-DHDIFLU4.cjs → chunk-AJUCQ3A4.cjs} +18 -18
- package/dist/{chunk-DHDIFLU4.cjs.map → chunk-AJUCQ3A4.cjs.map} +1 -1
- package/dist/{chunk-Q6GTI427.cjs → chunk-BLVSAXZR.cjs} +8 -8
- package/dist/{chunk-Q6GTI427.cjs.map → chunk-BLVSAXZR.cjs.map} +1 -1
- package/dist/{chunk-5ISSFIVO.cjs → chunk-CFOI2FTZ.cjs} +5 -5
- package/dist/{chunk-5ISSFIVO.cjs.map → chunk-CFOI2FTZ.cjs.map} +1 -1
- package/dist/{chunk-YKEI4XPI.cjs → chunk-CVJNHZHK.cjs} +25 -25
- package/dist/{chunk-YKEI4XPI.cjs.map → chunk-CVJNHZHK.cjs.map} +1 -1
- package/dist/{chunk-2FB2TP2R.cjs → chunk-D2EU67W3.cjs} +23 -23
- package/dist/{chunk-2FB2TP2R.cjs.map → chunk-D2EU67W3.cjs.map} +1 -1
- package/dist/{chunk-7QFMDMWA.cjs → chunk-DU6LNXN7.cjs} +6 -6
- package/dist/{chunk-7QFMDMWA.cjs.map → chunk-DU6LNXN7.cjs.map} +1 -1
- package/dist/{chunk-GV35U5OG.cjs → chunk-EUY4G2EF.cjs} +223 -632
- package/dist/chunk-EUY4G2EF.cjs.map +1 -0
- package/dist/{chunk-IOGN5UAT.cjs → chunk-FQ365MON.cjs} +11 -557
- package/dist/chunk-FQ365MON.cjs.map +1 -0
- package/dist/{chunk-DEL7BS25.cjs → chunk-IPVRLNOP.cjs} +37 -37
- package/dist/{chunk-DEL7BS25.cjs.map → chunk-IPVRLNOP.cjs.map} +1 -1
- package/dist/{chunk-SZF4CR4O.cjs → chunk-IVZNTOHU.cjs} +6 -6
- package/dist/{chunk-SZF4CR4O.cjs.map → chunk-IVZNTOHU.cjs.map} +1 -1
- package/dist/{chunk-XE3PKEBU.cjs → chunk-J4DOSC7N.cjs} +3 -3
- package/dist/{chunk-XE3PKEBU.cjs.map → chunk-J4DOSC7N.cjs.map} +1 -1
- package/dist/chunk-JPPNI7U2.cjs +561 -0
- package/dist/chunk-JPPNI7U2.cjs.map +1 -0
- package/dist/chunk-JZH7TTW7.cjs +429 -0
- package/dist/chunk-JZH7TTW7.cjs.map +1 -0
- package/dist/{chunk-ZGT6M5C5.cjs → chunk-KE7VBTGB.cjs} +6 -6
- package/dist/{chunk-ZGT6M5C5.cjs.map → chunk-KE7VBTGB.cjs.map} +1 -1
- package/dist/{chunk-SOVYCUML.cjs → chunk-KU5QWNN7.cjs} +10 -10
- package/dist/{chunk-SOVYCUML.cjs.map → chunk-KU5QWNN7.cjs.map} +1 -1
- package/dist/{chunk-XKKY2RF2.cjs → chunk-LBQKFWTB.cjs} +3 -3
- package/dist/{chunk-XKKY2RF2.cjs.map → chunk-LBQKFWTB.cjs.map} +1 -1
- package/dist/{chunk-G7JESVKJ.cjs → chunk-LF5OBP36.cjs} +28 -31
- package/dist/chunk-LF5OBP36.cjs.map +1 -0
- package/dist/{chunk-QTNIFFBJ.cjs → chunk-N53CRS65.cjs} +3 -3
- package/dist/{chunk-QTNIFFBJ.cjs.map → chunk-N53CRS65.cjs.map} +1 -1
- package/dist/{chunk-KD37PODE.cjs → chunk-NEOJMU7F.cjs} +3 -3
- package/dist/{chunk-KD37PODE.cjs.map → chunk-NEOJMU7F.cjs.map} +1 -1
- package/dist/{chunk-SAQ7ZAMK.cjs → chunk-O5QHQ5ML.cjs} +14 -14
- package/dist/{chunk-SAQ7ZAMK.cjs.map → chunk-O5QHQ5ML.cjs.map} +1 -1
- package/dist/{chunk-SI3YRTW4.cjs → chunk-O66HB7KI.cjs} +6 -6
- package/dist/{chunk-SI3YRTW4.cjs.map → chunk-O66HB7KI.cjs.map} +1 -1
- package/dist/{chunk-75UNBJVM.cjs → chunk-OA76PXL7.cjs} +10 -10
- package/dist/{chunk-75UNBJVM.cjs.map → chunk-OA76PXL7.cjs.map} +1 -1
- package/dist/{chunk-R6HGMPF4.cjs → chunk-OQODCEEH.cjs} +9 -9
- package/dist/{chunk-R6HGMPF4.cjs.map → chunk-OQODCEEH.cjs.map} +1 -1
- package/dist/{chunk-XCQDQSZL.cjs → chunk-PCOXZATI.cjs} +7 -3
- package/dist/chunk-PCOXZATI.cjs.map +1 -0
- package/dist/{chunk-CV2YOGBW.cjs → chunk-PHNHOJ7N.cjs} +28 -28
- package/dist/{chunk-CV2YOGBW.cjs.map → chunk-PHNHOJ7N.cjs.map} +1 -1
- package/dist/{chunk-WRYNJNC6.cjs → chunk-PNPZBRDE.cjs} +4 -4
- package/dist/{chunk-WRYNJNC6.cjs.map → chunk-PNPZBRDE.cjs.map} +1 -1
- package/dist/{chunk-AX26HWDZ.cjs → chunk-PSQGJPC3.cjs} +10 -10
- package/dist/{chunk-AX26HWDZ.cjs.map → chunk-PSQGJPC3.cjs.map} +1 -1
- package/dist/{chunk-WFMG5AUF.cjs → chunk-Q4DQR5HP.cjs} +80 -205
- package/dist/chunk-Q4DQR5HP.cjs.map +1 -0
- package/dist/{chunk-MYSWMYQE.cjs → chunk-SDCJV5I3.cjs} +75 -75
- package/dist/{chunk-MYSWMYQE.cjs.map → chunk-SDCJV5I3.cjs.map} +1 -1
- package/dist/{chunk-ZINJWTUD.cjs → chunk-T2IEHV75.cjs} +4 -4
- package/dist/{chunk-ZINJWTUD.cjs.map → chunk-T2IEHV75.cjs.map} +1 -1
- package/dist/{chunk-YI26A7SN.cjs → chunk-TIHTORWL.cjs} +21 -3
- package/dist/chunk-TIHTORWL.cjs.map +1 -0
- package/dist/{chunk-KLEH67QD.cjs → chunk-TPTCTNDE.cjs} +48 -48
- package/dist/{chunk-KLEH67QD.cjs.map → chunk-TPTCTNDE.cjs.map} +1 -1
- package/dist/{chunk-L35JYXOP.cjs → chunk-UF657A36.cjs} +9 -7
- package/dist/chunk-UF657A36.cjs.map +1 -0
- package/dist/chunk-USFM2L6T.cjs +21 -0
- package/dist/chunk-USFM2L6T.cjs.map +1 -0
- package/dist/{chunk-T6KYE3TR.cjs → chunk-WWIWW7IH.cjs} +3 -3
- package/dist/{chunk-T6KYE3TR.cjs.map → chunk-WWIWW7IH.cjs.map} +1 -1
- package/dist/{chunk-QSY2VW7V.cjs → chunk-WXRAU2FF.cjs} +6 -6
- package/dist/{chunk-QSY2VW7V.cjs.map → chunk-WXRAU2FF.cjs.map} +1 -1
- package/dist/{chunk-HUAABZ2C.cjs → chunk-X6EG33C7.cjs} +3 -3
- package/dist/{chunk-HUAABZ2C.cjs.map → chunk-X6EG33C7.cjs.map} +1 -1
- package/dist/{chunk-NZBPVCQ5.cjs → chunk-XW2PSBGE.cjs} +11 -11
- package/dist/{chunk-NZBPVCQ5.cjs.map → chunk-XW2PSBGE.cjs.map} +1 -1
- package/dist/{chunk-GHEKXPES.cjs → chunk-YJN3JWDZ.cjs} +9 -8
- package/dist/chunk-YJN3JWDZ.cjs.map +1 -0
- package/dist/connect/docx.cjs +18 -18
- package/dist/connect/index.cjs +1254 -1251
- package/dist/connect/index.cjs.map +1 -1
- package/dist/connect/viewer.cjs +38 -38
- package/dist/connection/ConnectedWorkflowBuilder.js +8 -9
- package/dist/connection/ConnectedWorkflowBuilder.js.map +2 -2
- package/dist/connection/WorkflowRunThread.js +2 -0
- package/dist/connection/WorkflowRunThread.js.map +2 -2
- package/dist/connection/ai.js +2 -1
- package/dist/connection/ai.js.map +2 -2
- package/dist/connection/renderChatSteps.d.ts +6 -0
- package/dist/connection/renderChatSteps.js +18 -0
- package/dist/connection/renderChatSteps.js.map +7 -0
- package/dist/connection/tasks/ConnectedTaskComposer.js +57 -18
- package/dist/connection/tasks/ConnectedTaskComposer.js.map +2 -2
- package/dist/connection/workflows/useWorkflowTasks.js +14 -17
- package/dist/connection/workflows/useWorkflowTasks.js.map +2 -2
- package/dist/connection/workflows/useWorkflowsPageState.d.ts +6 -0
- package/dist/dashboards/index.cjs +1 -1
- package/dist/databases/index.cjs +71 -71
- package/dist/document-tools/FileShareDialog.js +5 -1
- package/dist/document-tools/FileShareDialog.js.map +2 -2
- package/dist/document-tools/index.cjs +13 -13
- package/dist/document-tools/viewer/SignatureRequestEditor.js +2 -1
- package/dist/document-tools/viewer/SignatureRequestEditor.js.map +2 -2
- package/dist/document-tools/viewer/index.cjs +2 -1
- package/dist/document-tools/viewer/index.cjs.map +1 -1
- package/dist/embed/index.cjs +45 -43
- package/dist/facts/index.cjs +8 -8
- package/dist/files/index.cjs +221 -221
- package/dist/home/index.cjs +9 -9
- package/dist/index.cjs +1819 -1802
- package/dist/index.cjs.map +1 -1
- package/dist/pages/index.cjs +35 -35
- package/dist/settings/index.cjs +135 -135
- package/dist/shell/index.cjs +81 -81
- package/dist/studio/index.cjs +38 -28
- package/dist/studio/index.cjs.map +1 -1
- package/dist/workflow-canvas/TriggerInspector.d.ts +1 -1
- package/dist/workflow-canvas/TriggerInspector.js +4 -3
- package/dist/workflow-canvas/TriggerInspector.js.map +2 -2
- package/dist/workflow-canvas/index.cjs +86 -76
- package/dist/workflow-canvas/index.cjs.map +1 -1
- package/dist/workflow-canvas/trigger.d.ts +3 -2
- package/dist/workflow-canvas/trigger.js +10 -2
- package/dist/workflow-canvas/trigger.js.map +2 -2
- package/dist/workspaces/index.cjs +5 -5
- package/node_modules/@arbidocs/coedit/package.json +1 -1
- package/package.json +5 -5
- package/dist/ai-RIR36YJR.cjs.map +0 -1
- package/dist/chunk-4N2IKS6V.cjs.map +0 -1
- package/dist/chunk-G7JESVKJ.cjs.map +0 -1
- package/dist/chunk-GHEKXPES.cjs.map +0 -1
- package/dist/chunk-GV35U5OG.cjs.map +0 -1
- package/dist/chunk-IOGN5UAT.cjs.map +0 -1
- package/dist/chunk-L35JYXOP.cjs.map +0 -1
- package/dist/chunk-QFSFTO7I.cjs.map +0 -1
- package/dist/chunk-WFMG5AUF.cjs.map +0 -1
- package/dist/chunk-XCQDQSZL.cjs.map +0 -1
- package/dist/chunk-YI26A7SN.cjs.map +0 -1
|
@@ -10,7 +10,24 @@ import type { RecurrenceBuilderProps } from './RecurrenceBuilder';
|
|
|
10
10
|
* it unattended.
|
|
11
11
|
*/
|
|
12
12
|
export type TaskWhen = 'manual' | 'now' | 'once' | 'repeat' | 'event' | 'task';
|
|
13
|
-
|
|
13
|
+
/**
|
|
14
|
+
* What an unattended start may do while nobody is there: ask the owner each run, or run on a timed authorization
|
|
15
|
+
* the owner gives now (7, 30 or 90 days). The assistant never becomes a member of the workspace: the key is held
|
|
16
|
+
* for the workflow alone and sealed into each run, and when the time is up the next run asks again.
|
|
17
|
+
*/
|
|
18
|
+
export type TaskAccessMode = 'ask_each_run' | 'grant_7' | 'grant_30' | 'grant_90';
|
|
19
|
+
/** The timed authorizations offered, in days. */
|
|
20
|
+
export declare const GRANT_DAYS: {
|
|
21
|
+
readonly grant_7: 7;
|
|
22
|
+
readonly grant_30: 30;
|
|
23
|
+
readonly grant_90: 90;
|
|
24
|
+
};
|
|
25
|
+
/** Is this a timed authorization (not "ask each run")? */
|
|
26
|
+
export declare const isGrantAccess: (mode: TaskAccessMode) => mode is keyof typeof GRANT_DAYS;
|
|
27
|
+
/** The authorization length the server is sent for this choice (undefined: ask each run). */
|
|
28
|
+
export declare const accessSecondsFor: (mode: TaskAccessMode) => number | undefined;
|
|
29
|
+
/** A saved workflow's choice: its authorization length, as the closest offered option. */
|
|
30
|
+
export declare function accessModeOf(authMode: string | null | undefined, accessSeconds?: number | null): TaskAccessMode;
|
|
14
31
|
/**
|
|
15
32
|
* Whether the assistant has been given work. Every task has an assistant; `agent` means it was configured
|
|
16
33
|
* to prepare the task (it has an instruction and a start), `me` means it is on standby.
|
|
@@ -187,8 +204,8 @@ export interface TaskComposerProps {
|
|
|
187
204
|
}[];
|
|
188
205
|
/** The plan editor, shown inline when the assistant is configured. Omit when not applicable. */
|
|
189
206
|
goal?: ReactNode | ((values: TaskComposerValues) => ReactNode);
|
|
190
|
-
/**
|
|
191
|
-
|
|
207
|
+
/** Shown under a timed authorization (e.g. until when the workflow is authorized, with renew and revoke). */
|
|
208
|
+
grantedAccess?: ReactNode | ((values: TaskComposerValues) => ReactNode);
|
|
192
209
|
isPending?: boolean;
|
|
193
210
|
/** A plan is being drafted: saving waits for it, or the plan would be dropped. */
|
|
194
211
|
planDrafting?: boolean;
|
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { defaultInputs } from "../workflows/workflow.js";
|
|
3
|
+
const GRANT_DAYS = { grant_7: 7, grant_30: 30, grant_90: 90 };
|
|
4
|
+
const DAY_SECONDS = 24 * 60 * 60;
|
|
5
|
+
const isGrantAccess = (mode) => mode !== "ask_each_run";
|
|
6
|
+
const accessSecondsFor = (mode) => isGrantAccess(mode) ? GRANT_DAYS[mode] * DAY_SECONDS : void 0;
|
|
7
|
+
function accessModeOf(authMode, accessSeconds) {
|
|
8
|
+
if (authMode !== "scheduled_grant") return "ask_each_run";
|
|
9
|
+
const days = (accessSeconds ?? GRANT_DAYS.grant_30 * DAY_SECONDS) / DAY_SECONDS;
|
|
10
|
+
return days <= GRANT_DAYS.grant_7 ? "grant_7" : days <= GRANT_DAYS.grant_30 ? "grant_30" : "grant_90";
|
|
11
|
+
}
|
|
3
12
|
const DEFAULT_TASK_COMPOSER_LABELS = {
|
|
4
13
|
titleNew: "New task",
|
|
5
14
|
titleEdit: "Edit task",
|
|
@@ -82,9 +91,17 @@ const DEFAULT_TASK_COMPOSER_LABELS = {
|
|
|
82
91
|
label: "Ask me each time",
|
|
83
92
|
hint: "When it is due, it waits until you allow it."
|
|
84
93
|
},
|
|
85
|
-
|
|
86
|
-
label: "
|
|
87
|
-
hint: "It
|
|
94
|
+
grant_7: {
|
|
95
|
+
label: "Allowed for 7 days",
|
|
96
|
+
hint: "It can work while you are away for 7 days, then asks again. It never joins the workspace."
|
|
97
|
+
},
|
|
98
|
+
grant_30: {
|
|
99
|
+
label: "Allowed for 30 days",
|
|
100
|
+
hint: "It can work while you are away for 30 days, then asks again. It never joins the workspace."
|
|
101
|
+
},
|
|
102
|
+
grant_90: {
|
|
103
|
+
label: "Allowed for 90 days",
|
|
104
|
+
hint: "It can work while you are away for 90 days, then asks again. It never joins the workspace."
|
|
88
105
|
}
|
|
89
106
|
},
|
|
90
107
|
timezone: "Timezone",
|
|
@@ -123,6 +140,10 @@ function defaultTaskComposerValues(workflows, initial) {
|
|
|
123
140
|
}
|
|
124
141
|
export {
|
|
125
142
|
DEFAULT_TASK_COMPOSER_LABELS,
|
|
126
|
-
|
|
143
|
+
GRANT_DAYS,
|
|
144
|
+
accessModeOf,
|
|
145
|
+
accessSecondsFor,
|
|
146
|
+
defaultTaskComposerValues,
|
|
147
|
+
isGrantAccess
|
|
127
148
|
};
|
|
128
149
|
//# sourceMappingURL=taskComposerTypes.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/agents/tasks/taskComposerTypes.ts"],
|
|
4
|
-
"sourcesContent": ["import type { ReactNode } from 'react'\nimport type { AgentOption } from '../workflows/AgentSelect'\nimport type { SchemaFormLabels } from '../workflows/SchemaForm'\nimport type { WorkflowScopeSource } from '../workflows/WorkflowConfigDialog'\nimport type {\n WorkflowDefinition,\n WorkflowField,\n WorkflowInputs,\n WorkflowScope,\n} from '../workflows/types'\nimport { defaultInputs } from '../workflows/workflow'\nimport type { RecurrenceBuilderProps } from './RecurrenceBuilder'\n\n/**\n * When the assistant starts. `manual` means it only acts when asked (an @mention, or sending work back);\n * `now` starts it at once; `once`, `repeat`, `event` and `task` (after another task is signed off) start\n * it unattended.\n */\nexport type TaskWhen = 'manual' | 'now' | 'once' | 'repeat' | 'event' | 'task'\n\nexport type TaskAccessMode = 'ask_each_run' | 'standing'\n\n/**\n * Whether the assistant has been given work. Every task has an assistant; `agent` means it was configured\n * to prepare the task (it has an instruction and a start), `me` means it is on standby.\n */\nexport type TaskAssignee = 'me' | 'agent'\n\n/** Everything the composer collects. The host maps it onto its API. */\nexport interface TaskComposerValues {\n assignee: TaskAssignee\n workflowId: string\n inputs: WorkflowInputs\n when: TaskWhen\n /** datetime-local value (`once`). */\n runAt: string\n rrule: string\n timezone: string\n eventKind: string\n /** `task`: the id (`con-\u2026`) of the task (conversation) this one waits on. */\n afterTaskId: string\n /** The task this is a sub-task of (`con-\u2026`); `''` = a top-level task. */\n parentTaskId: string\n /** Shared with the workspace's members (like a document); off keeps it private to its owner. */\n shared: boolean\n /** What the task is, in the owner's words. */\n description: string\n /** datetime-local value; empty = no due date. */\n dueAt: string\n /** `''` = the user's own assistant. */\n agentId: string\n /** The task's title. */\n name: string\n /** The owner is always told when the assistant finishes; kept so hosts can map it. */\n notifyOnComplete: boolean\n /** Only asked for tasks the assistant starts unattended. */\n access: TaskAccessMode\n /** A workflow's saved equality filters on its event; carried through an edit unchanged (no control). */\n eventFilter?: Record<string, string | number | boolean> | null\n}\n\nexport interface TaskComposerLabels {\n titleNew: string\n titleEdit: string\n description: string\n titleNewWorkflow: string\n titleRunTemplate: (name: string) => string\n titleEditWorkflow: string\n descriptionWorkflow: string\n workflowNamePlaceholder: string\n createWorkflow: string\n /** The workflow dialog's three required parts, in order, and what is missing from each. */\n whenHeading: string\n whoHeading: string\n /** \"Run as\": the person themself (the default for Run now) or an agent (required for a scheduled run). */\n runAs: string\n runLater: string\n addFilesReason: string\n needDocument: string\n addPlan: string\n hidePlan: string\n /** The toggle when the workflow already has a plan. */\n showPlan: string\n runAsMe: string\n runAsAgentHint: string\n needAgent: string\n runNow: string\n saveWorkflow: string\n needWhat: string\n needRunAt: string\n needRrule: string\n needEvent: string\n needAfterTask: string\n /** The \"More options\" disclosure (name, details, visibility, plan, unattended access). */\n moreOptions: string\n fewerOptions: string\n nameHint: string\n titleLabel: string\n titlePlaceholder: string\n descriptionLabel: string\n descriptionPlaceholder: string\n due: string\n dueNone: string\n dueClear: string\n parentTask: string\n parentTaskNone: string\n visibility: string\n visibilityWorkspace: string\n visibilityPrivate: string\n assistant: string\n assistantStandby: string\n assistantPreparing: (when: string) => string\n configure: string\n configureClose: string\n what: string\n template: string\n whatPlaceholder: string\n plan: string\n planHint: string\n start: string\n whenOptions: Record<TaskWhen, string>\n runAt: string\n /** Shown when the start time is already past: the server refuses it. */\n runAtPast: string\n event: string\n eventPlaceholder: string\n eventHint: ReactNode\n afterTask: string\n afterTaskPlaceholder: string\n which: string\n myAssistant: string\n permission: string\n /** The disclosure that holds who runs it, access, name, owner and visibility. */\n runOptions: string\n /** Its summary line: \"Runs as Assistant \u00B7 ask me each time\". */\n runOptionsSummary: (agent: string, access: string) => string\n permissionHint: string\n accessOptions: Record<TaskAccessMode, { label: string; hint: string }>\n timezone: string\n search: string\n empty: string\n cancel: string\n addTask: string\n addAndStart: string\n addAndSchedule: string\n save: string\n saving: string\n}\n\nexport const DEFAULT_TASK_COMPOSER_LABELS: TaskComposerLabels = {\n titleNew: 'New task',\n titleEdit: 'Edit task',\n description: 'Add a task. Every task has an assistant; configure it to have it prepare the work.',\n titleNewWorkflow: 'New workflow',\n /** The title while a template is picked: \"Run Summarise\". */\n titleRunTemplate: (name: string) => `Run ${name}`,\n titleEditWorkflow: 'Edit workflow',\n descriptionWorkflow:\n 'Run it now, or choose Run later to have it start on a date, repeat, or follow an event.',\n workflowNamePlaceholder: 'Name this workflow',\n createWorkflow: 'Create workflow',\n whenHeading: 'When should it run?',\n whoHeading: 'Which agent runs it?',\n runAs: 'Run as',\n runLater: 'Run later',\n addFilesReason: 'This needs files to work on. Add some, then run it.',\n needDocument: 'Pick or add a document',\n addPlan: 'Add a plan',\n hidePlan: 'Hide the plan',\n showPlan: 'Show the plan',\n runAsMe: 'Me',\n runAsAgentHint:\n 'Nobody is there when a saved workflow runs, so an agent runs it. Your Assistant is the default.',\n needAgent: 'Choose the agent that runs it.',\n runNow: 'Run now',\n saveWorkflow: 'Save workflow',\n needWhat: 'Say what it should do: choose a template and fill it in, or write an instruction.',\n needRunAt: 'Pick the date and time it should run.',\n needRrule: 'Choose how often it repeats.',\n needEvent: 'Say which event starts it.',\n needAfterTask: 'Choose the task it follows.',\n moreOptions: 'More options',\n fewerOptions: 'Fewer options',\n nameHint: 'Leave blank to use the name shown.',\n titleLabel: 'Title',\n titlePlaceholder: 'What needs doing?',\n descriptionLabel: 'Description',\n descriptionPlaceholder: 'Add details (optional)',\n due: 'Due',\n dueNone: 'No date',\n dueClear: 'Clear date',\n parentTask: 'Part of',\n parentTaskNone: 'Nothing (top-level)',\n visibility: 'Visibility',\n visibilityWorkspace: 'Workspace',\n visibilityPrivate: 'Only me',\n assistant: 'Task Assistant',\n assistantStandby: 'On standby. It replies when you @mention it in the task\u2019s thread.',\n assistantPreparing: (when) => `Will work on this task ${when}. You mark it done when it is.`,\n configure: 'Configure',\n configureClose: 'Done',\n what: 'What should it do?',\n template: 'Skill',\n whatPlaceholder: 'Choose\u2026',\n plan: 'Plan',\n planHint: 'The checklist it is held to. You see how it did when it finishes.',\n start: 'Start',\n whenOptions: {\n manual: 'When asked',\n now: 'Now',\n once: 'On a date',\n repeat: 'Repeat',\n event: 'When something happens',\n task: 'After another task',\n },\n runAt: 'Start at',\n runAtPast: 'Pick a time in the future.',\n event: 'Event',\n eventPlaceholder: 'mention',\n eventHint: 'It starts whenever this kind of notification reaches you.',\n afterTask: 'After',\n afterTaskPlaceholder: 'Choose a task\u2026',\n which: 'Assistant',\n myAssistant: 'Mine',\n permission: 'Access',\n runOptions: 'Run options',\n runOptionsSummary: (agent, access) => `Runs as ${agent} \u00B7 ${access.toLowerCase()}`,\n permissionHint:\n 'It starts while you are away, so it needs your permission to use this workspace.',\n accessOptions: {\n ask_each_run: {\n label: 'Ask me each time',\n hint: 'When it is due, it waits until you allow it.',\n },\n standing: {\n label: 'Always allowed',\n hint: 'It joins the workspace and can work while you are away. Only for assistants you trust.',\n },\n },\n timezone: 'Timezone',\n search: 'Search\u2026',\n empty: 'No match.',\n cancel: 'Cancel',\n addTask: 'Add task',\n addAndStart: 'Start now',\n addAndSchedule: 'Schedule',\n save: 'Save changes',\n saving: 'Saving\u2026',\n}\n\nexport interface TaskOption {\n id: string\n name: string\n}\n\nexport interface TaskComposerProps {\n open: boolean\n onOpenChange: (open: boolean) => void\n /**\n * `work` (default) adds a task: \"Now\" starts it at once and any other start saves a workflow.\n * `workflow` is the workflow dialog itself (new or edit): a trigger and an action are required, and\n * the task-only properties (due date, parent) are hidden.\n */\n kind?: 'work' | 'workflow'\n /** Saving a reusable workflow; on-demand creates a recipe rather than starting work. */\n saveOnly?: boolean\n /** Hide the \"Run later\" button (scheduling is off): a workflow can only be started now. */\n hideRunLater?: boolean\n /**\n * Editing an existing task, or a workflow. A task keeps the start and assistant it was created with;\n * a workflow can change both.\n */\n isEdit?: boolean\n /** Workflows the assistant can run. The host includes its \"my own instruction\" entry. */\n workflows: WorkflowDefinition[]\n agents: AgentOption[]\n /** Tasks a new task can be part of, or wait on (`when: 'task'`) \u2014 conversations with a status. */\n tasks?: TaskOption[]\n /**\n * The owner's Assistant (an agent id). A scheduled workflow needs an agent, so switching away from\n * \"Now\" selects this one when \"Run as\" is still the person themself.\n */\n defaultAgentId?: string\n /** Controlled values; omit to let the composer hold them (seeded by `initialValues`). */\n values?: TaskComposerValues\n initialValues?: Partial<TaskComposerValues>\n onValuesChange?: (values: TaskComposerValues) => void\n timezones?: string[]\n /** Supported event triggers, supplied by the host instead of asking users for backend codes. */\n eventOptions?: readonly { id: string; label: string }[]\n eventWorkflowOptions?: readonly { id: string; label: string }[]\n /** The plan editor, shown inline when the assistant is configured. Omit when not applicable. */\n goal?: ReactNode | ((values: TaskComposerValues) => ReactNode)\n /** What \"always allowed\" means for this assistant (e.g. the workspaces it will hold standing access to). */\n standingAccess?: ReactNode | ((values: TaskComposerValues) => ReactNode)\n isPending?: boolean\n /** A plan is being drafted: saving waits for it, or the plan would be dropped. */\n planDrafting?: boolean\n /** The plan already stored (an edit): the toggle offers to show it rather than to add one. */\n hasPlan?: boolean\n onSubmit: (values: TaskComposerValues, options?: { runOnce?: boolean }) => void\n /**\n * The workspace's files behind `scope` fields (the folder/label picker) and a `documents` field (an\n * explicit pick). The host owns the file data; without these those fields render nothing. A scope pick\n * is resolved to explicit file ids on submit (`scopeSource.resolveDocuments`).\n */\n scopeSource?: WorkflowScopeSource\n renderDocuments?: (\n field: WorkflowField,\n value: WorkflowScope,\n onChange: (s: WorkflowScope) => void\n ) => ReactNode\n /** The host's \"Add files\" control, offered instead of the form when a template needs files and there are none. */\n addFilesAction?: ReactNode\n /** Files dropped on the \"add files\" state: the host uploads them. */\n onDropFiles?: (files: File[]) => void\n /** The assistant's workflow input forms: `renderIcon` maps a field option's icon key. */\n renderIcon?: (key: string) => ReactNode\n labels?: Partial<TaskComposerLabels>\n formLabels?: Partial<SchemaFormLabels>\n recurrence?: Pick<RecurrenceBuilderProps, 'testIds' | 'labels'>\n testId?: string\n}\n\nexport function defaultTaskComposerValues(\n workflows: WorkflowDefinition[],\n initial?: Partial<TaskComposerValues>\n): TaskComposerValues {\n const workflowId = initial?.workflowId ?? workflows[0]?.id ?? ''\n const workflow = workflows.find((w) => w.id === workflowId)\n return {\n assignee: 'me',\n workflowId,\n inputs: workflow ? { ...defaultInputs(workflow), ...initial?.inputs } : { ...initial?.inputs },\n when: 'manual',\n runAt: '',\n rrule: '',\n timezone: 'UTC',\n eventKind: 'mention',\n afterTaskId: '',\n parentTaskId: '',\n shared: false,\n description: '',\n dueAt: '',\n agentId: '',\n name: '',\n notifyOnComplete: true,\n access: 'ask_each_run',\n ...initial,\n }\n}\n"],
|
|
5
|
-
"mappings": ";AAUA,SAAS,qBAAqB;
|
|
4
|
+
"sourcesContent": ["import type { ReactNode } from 'react'\nimport type { AgentOption } from '../workflows/AgentSelect'\nimport type { SchemaFormLabels } from '../workflows/SchemaForm'\nimport type { WorkflowScopeSource } from '../workflows/WorkflowConfigDialog'\nimport type {\n WorkflowDefinition,\n WorkflowField,\n WorkflowInputs,\n WorkflowScope,\n} from '../workflows/types'\nimport { defaultInputs } from '../workflows/workflow'\nimport type { RecurrenceBuilderProps } from './RecurrenceBuilder'\n\n/**\n * When the assistant starts. `manual` means it only acts when asked (an @mention, or sending work back);\n * `now` starts it at once; `once`, `repeat`, `event` and `task` (after another task is signed off) start\n * it unattended.\n */\nexport type TaskWhen = 'manual' | 'now' | 'once' | 'repeat' | 'event' | 'task'\n\n/**\n * What an unattended start may do while nobody is there: ask the owner each run, or run on a timed authorization\n * the owner gives now (7, 30 or 90 days). The assistant never becomes a member of the workspace: the key is held\n * for the workflow alone and sealed into each run, and when the time is up the next run asks again.\n */\nexport type TaskAccessMode = 'ask_each_run' | 'grant_7' | 'grant_30' | 'grant_90'\n\n/** The timed authorizations offered, in days. */\nexport const GRANT_DAYS = { grant_7: 7, grant_30: 30, grant_90: 90 } as const\nconst DAY_SECONDS = 24 * 60 * 60\n\n/** Is this a timed authorization (not \"ask each run\")? */\nexport const isGrantAccess = (mode: TaskAccessMode): mode is keyof typeof GRANT_DAYS =>\n mode !== 'ask_each_run'\n\n/** The authorization length the server is sent for this choice (undefined: ask each run). */\nexport const accessSecondsFor = (mode: TaskAccessMode): number | undefined =>\n isGrantAccess(mode) ? GRANT_DAYS[mode] * DAY_SECONDS : undefined\n\n/** A saved workflow's choice: its authorization length, as the closest offered option. */\nexport function accessModeOf(\n authMode: string | null | undefined,\n accessSeconds?: number | null\n): TaskAccessMode {\n if (authMode !== 'scheduled_grant') return 'ask_each_run'\n const days = (accessSeconds ?? GRANT_DAYS.grant_30 * DAY_SECONDS) / DAY_SECONDS\n return days <= GRANT_DAYS.grant_7\n ? 'grant_7'\n : days <= GRANT_DAYS.grant_30\n ? 'grant_30'\n : 'grant_90'\n}\n\n/**\n * Whether the assistant has been given work. Every task has an assistant; `agent` means it was configured\n * to prepare the task (it has an instruction and a start), `me` means it is on standby.\n */\nexport type TaskAssignee = 'me' | 'agent'\n\n/** Everything the composer collects. The host maps it onto its API. */\nexport interface TaskComposerValues {\n assignee: TaskAssignee\n workflowId: string\n inputs: WorkflowInputs\n when: TaskWhen\n /** datetime-local value (`once`). */\n runAt: string\n rrule: string\n timezone: string\n eventKind: string\n /** `task`: the id (`con-\u2026`) of the task (conversation) this one waits on. */\n afterTaskId: string\n /** The task this is a sub-task of (`con-\u2026`); `''` = a top-level task. */\n parentTaskId: string\n /** Shared with the workspace's members (like a document); off keeps it private to its owner. */\n shared: boolean\n /** What the task is, in the owner's words. */\n description: string\n /** datetime-local value; empty = no due date. */\n dueAt: string\n /** `''` = the user's own assistant. */\n agentId: string\n /** The task's title. */\n name: string\n /** The owner is always told when the assistant finishes; kept so hosts can map it. */\n notifyOnComplete: boolean\n /** Only asked for tasks the assistant starts unattended. */\n access: TaskAccessMode\n /** A workflow's saved equality filters on its event; carried through an edit unchanged (no control). */\n eventFilter?: Record<string, string | number | boolean> | null\n}\n\nexport interface TaskComposerLabels {\n titleNew: string\n titleEdit: string\n description: string\n titleNewWorkflow: string\n titleRunTemplate: (name: string) => string\n titleEditWorkflow: string\n descriptionWorkflow: string\n workflowNamePlaceholder: string\n createWorkflow: string\n /** The workflow dialog's three required parts, in order, and what is missing from each. */\n whenHeading: string\n whoHeading: string\n /** \"Run as\": the person themself (the default for Run now) or an agent (required for a scheduled run). */\n runAs: string\n runLater: string\n addFilesReason: string\n needDocument: string\n addPlan: string\n hidePlan: string\n /** The toggle when the workflow already has a plan. */\n showPlan: string\n runAsMe: string\n runAsAgentHint: string\n needAgent: string\n runNow: string\n saveWorkflow: string\n needWhat: string\n needRunAt: string\n needRrule: string\n needEvent: string\n needAfterTask: string\n /** The \"More options\" disclosure (name, details, visibility, plan, unattended access). */\n moreOptions: string\n fewerOptions: string\n nameHint: string\n titleLabel: string\n titlePlaceholder: string\n descriptionLabel: string\n descriptionPlaceholder: string\n due: string\n dueNone: string\n dueClear: string\n parentTask: string\n parentTaskNone: string\n visibility: string\n visibilityWorkspace: string\n visibilityPrivate: string\n assistant: string\n assistantStandby: string\n assistantPreparing: (when: string) => string\n configure: string\n configureClose: string\n what: string\n template: string\n whatPlaceholder: string\n plan: string\n planHint: string\n start: string\n whenOptions: Record<TaskWhen, string>\n runAt: string\n /** Shown when the start time is already past: the server refuses it. */\n runAtPast: string\n event: string\n eventPlaceholder: string\n eventHint: ReactNode\n afterTask: string\n afterTaskPlaceholder: string\n which: string\n myAssistant: string\n permission: string\n /** The disclosure that holds who runs it, access, name, owner and visibility. */\n runOptions: string\n /** Its summary line: \"Runs as Assistant \u00B7 ask me each time\". */\n runOptionsSummary: (agent: string, access: string) => string\n permissionHint: string\n accessOptions: Record<TaskAccessMode, { label: string; hint: string }>\n timezone: string\n search: string\n empty: string\n cancel: string\n addTask: string\n addAndStart: string\n addAndSchedule: string\n save: string\n saving: string\n}\n\nexport const DEFAULT_TASK_COMPOSER_LABELS: TaskComposerLabels = {\n titleNew: 'New task',\n titleEdit: 'Edit task',\n description: 'Add a task. Every task has an assistant; configure it to have it prepare the work.',\n titleNewWorkflow: 'New workflow',\n /** The title while a template is picked: \"Run Summarise\". */\n titleRunTemplate: (name: string) => `Run ${name}`,\n titleEditWorkflow: 'Edit workflow',\n descriptionWorkflow:\n 'Run it now, or choose Run later to have it start on a date, repeat, or follow an event.',\n workflowNamePlaceholder: 'Name this workflow',\n createWorkflow: 'Create workflow',\n whenHeading: 'When should it run?',\n whoHeading: 'Which agent runs it?',\n runAs: 'Run as',\n runLater: 'Run later',\n addFilesReason: 'This needs files to work on. Add some, then run it.',\n needDocument: 'Pick or add a document',\n addPlan: 'Add a plan',\n hidePlan: 'Hide the plan',\n showPlan: 'Show the plan',\n runAsMe: 'Me',\n runAsAgentHint:\n 'Nobody is there when a saved workflow runs, so an agent runs it. Your Assistant is the default.',\n needAgent: 'Choose the agent that runs it.',\n runNow: 'Run now',\n saveWorkflow: 'Save workflow',\n needWhat: 'Say what it should do: choose a template and fill it in, or write an instruction.',\n needRunAt: 'Pick the date and time it should run.',\n needRrule: 'Choose how often it repeats.',\n needEvent: 'Say which event starts it.',\n needAfterTask: 'Choose the task it follows.',\n moreOptions: 'More options',\n fewerOptions: 'Fewer options',\n nameHint: 'Leave blank to use the name shown.',\n titleLabel: 'Title',\n titlePlaceholder: 'What needs doing?',\n descriptionLabel: 'Description',\n descriptionPlaceholder: 'Add details (optional)',\n due: 'Due',\n dueNone: 'No date',\n dueClear: 'Clear date',\n parentTask: 'Part of',\n parentTaskNone: 'Nothing (top-level)',\n visibility: 'Visibility',\n visibilityWorkspace: 'Workspace',\n visibilityPrivate: 'Only me',\n assistant: 'Task Assistant',\n assistantStandby: 'On standby. It replies when you @mention it in the task\u2019s thread.',\n assistantPreparing: (when) => `Will work on this task ${when}. You mark it done when it is.`,\n configure: 'Configure',\n configureClose: 'Done',\n what: 'What should it do?',\n template: 'Skill',\n whatPlaceholder: 'Choose\u2026',\n plan: 'Plan',\n planHint: 'The checklist it is held to. You see how it did when it finishes.',\n start: 'Start',\n whenOptions: {\n manual: 'When asked',\n now: 'Now',\n once: 'On a date',\n repeat: 'Repeat',\n event: 'When something happens',\n task: 'After another task',\n },\n runAt: 'Start at',\n runAtPast: 'Pick a time in the future.',\n event: 'Event',\n eventPlaceholder: 'mention',\n eventHint: 'It starts whenever this kind of notification reaches you.',\n afterTask: 'After',\n afterTaskPlaceholder: 'Choose a task\u2026',\n which: 'Assistant',\n myAssistant: 'Mine',\n permission: 'Access',\n runOptions: 'Run options',\n runOptionsSummary: (agent, access) => `Runs as ${agent} \u00B7 ${access.toLowerCase()}`,\n permissionHint:\n 'It starts while you are away, so it needs your permission to use this workspace.',\n accessOptions: {\n ask_each_run: {\n label: 'Ask me each time',\n hint: 'When it is due, it waits until you allow it.',\n },\n grant_7: {\n label: 'Allowed for 7 days',\n hint: 'It can work while you are away for 7 days, then asks again. It never joins the workspace.',\n },\n grant_30: {\n label: 'Allowed for 30 days',\n hint: 'It can work while you are away for 30 days, then asks again. It never joins the workspace.',\n },\n grant_90: {\n label: 'Allowed for 90 days',\n hint: 'It can work while you are away for 90 days, then asks again. It never joins the workspace.',\n },\n },\n timezone: 'Timezone',\n search: 'Search\u2026',\n empty: 'No match.',\n cancel: 'Cancel',\n addTask: 'Add task',\n addAndStart: 'Start now',\n addAndSchedule: 'Schedule',\n save: 'Save changes',\n saving: 'Saving\u2026',\n}\n\nexport interface TaskOption {\n id: string\n name: string\n}\n\nexport interface TaskComposerProps {\n open: boolean\n onOpenChange: (open: boolean) => void\n /**\n * `work` (default) adds a task: \"Now\" starts it at once and any other start saves a workflow.\n * `workflow` is the workflow dialog itself (new or edit): a trigger and an action are required, and\n * the task-only properties (due date, parent) are hidden.\n */\n kind?: 'work' | 'workflow'\n /** Saving a reusable workflow; on-demand creates a recipe rather than starting work. */\n saveOnly?: boolean\n /** Hide the \"Run later\" button (scheduling is off): a workflow can only be started now. */\n hideRunLater?: boolean\n /**\n * Editing an existing task, or a workflow. A task keeps the start and assistant it was created with;\n * a workflow can change both.\n */\n isEdit?: boolean\n /** Workflows the assistant can run. The host includes its \"my own instruction\" entry. */\n workflows: WorkflowDefinition[]\n agents: AgentOption[]\n /** Tasks a new task can be part of, or wait on (`when: 'task'`) \u2014 conversations with a status. */\n tasks?: TaskOption[]\n /**\n * The owner's Assistant (an agent id). A scheduled workflow needs an agent, so switching away from\n * \"Now\" selects this one when \"Run as\" is still the person themself.\n */\n defaultAgentId?: string\n /** Controlled values; omit to let the composer hold them (seeded by `initialValues`). */\n values?: TaskComposerValues\n initialValues?: Partial<TaskComposerValues>\n onValuesChange?: (values: TaskComposerValues) => void\n timezones?: string[]\n /** Supported event triggers, supplied by the host instead of asking users for backend codes. */\n eventOptions?: readonly { id: string; label: string }[]\n eventWorkflowOptions?: readonly { id: string; label: string }[]\n /** The plan editor, shown inline when the assistant is configured. Omit when not applicable. */\n goal?: ReactNode | ((values: TaskComposerValues) => ReactNode)\n /** Shown under a timed authorization (e.g. until when the workflow is authorized, with renew and revoke). */\n grantedAccess?: ReactNode | ((values: TaskComposerValues) => ReactNode)\n isPending?: boolean\n /** A plan is being drafted: saving waits for it, or the plan would be dropped. */\n planDrafting?: boolean\n /** The plan already stored (an edit): the toggle offers to show it rather than to add one. */\n hasPlan?: boolean\n onSubmit: (values: TaskComposerValues, options?: { runOnce?: boolean }) => void\n /**\n * The workspace's files behind `scope` fields (the folder/label picker) and a `documents` field (an\n * explicit pick). The host owns the file data; without these those fields render nothing. A scope pick\n * is resolved to explicit file ids on submit (`scopeSource.resolveDocuments`).\n */\n scopeSource?: WorkflowScopeSource\n renderDocuments?: (\n field: WorkflowField,\n value: WorkflowScope,\n onChange: (s: WorkflowScope) => void\n ) => ReactNode\n /** The host's \"Add files\" control, offered instead of the form when a template needs files and there are none. */\n addFilesAction?: ReactNode\n /** Files dropped on the \"add files\" state: the host uploads them. */\n onDropFiles?: (files: File[]) => void\n /** The assistant's workflow input forms: `renderIcon` maps a field option's icon key. */\n renderIcon?: (key: string) => ReactNode\n labels?: Partial<TaskComposerLabels>\n formLabels?: Partial<SchemaFormLabels>\n recurrence?: Pick<RecurrenceBuilderProps, 'testIds' | 'labels'>\n testId?: string\n}\n\nexport function defaultTaskComposerValues(\n workflows: WorkflowDefinition[],\n initial?: Partial<TaskComposerValues>\n): TaskComposerValues {\n const workflowId = initial?.workflowId ?? workflows[0]?.id ?? ''\n const workflow = workflows.find((w) => w.id === workflowId)\n return {\n assignee: 'me',\n workflowId,\n inputs: workflow ? { ...defaultInputs(workflow), ...initial?.inputs } : { ...initial?.inputs },\n when: 'manual',\n runAt: '',\n rrule: '',\n timezone: 'UTC',\n eventKind: 'mention',\n afterTaskId: '',\n parentTaskId: '',\n shared: false,\n description: '',\n dueAt: '',\n agentId: '',\n name: '',\n notifyOnComplete: true,\n access: 'ask_each_run',\n ...initial,\n }\n}\n"],
|
|
5
|
+
"mappings": ";AAUA,SAAS,qBAAqB;AAkBvB,MAAM,aAAa,EAAE,SAAS,GAAG,UAAU,IAAI,UAAU,GAAG;AACnE,MAAM,cAAc,KAAK,KAAK;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IAAI,EAAE,GAAG,SAAS,OAAO;AAAA,IAC7F,MAAM;AAAA,IACN,OAAO;AAAA,IACP,OAAO;AAAA,IACP,UAAU;AAAA,IACV,WAAW;AAAA,IACX,aAAa;AAAA,IACb,cAAc;AAAA,IACd,QAAQ;AAAA,IACR,aAAa;AAAA,IACb,OAAO;AAAA,IACP,SAAS;AAAA,IACT,MAAM;AAAA,IACN,kBAAkB;AAAA,IAClB,QAAQ;AAAA,IACR,GAAG;AAAA,EACL;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
import type { components } from '@arbidocs/client';
|
|
10
10
|
import { type WorkflowComposeContext } from '../workflows/workflow';
|
|
11
11
|
import type { WorkflowDefinition, WorkflowInputs } from '../workflows/types';
|
|
12
|
-
import type
|
|
12
|
+
import { type TaskComposerValues, type TaskWhen } from './taskComposerTypes';
|
|
13
13
|
import type { MessageMentionRef } from '@arbidocs/react/shell';
|
|
14
14
|
type Schemas = components['schemas'];
|
|
15
15
|
type ConversationResponse = Schemas['ConversationResponse'];
|
|
@@ -20,11 +20,12 @@ type TaskOptions = Schemas['TaskOptions'];
|
|
|
20
20
|
type UpdateConversationRequest = Schemas['UpdateConversationRequest'];
|
|
21
21
|
type UpdateWorkflowRequest = Schemas['UpdateWorkflowRequest'];
|
|
22
22
|
type WorkflowResponse = Schemas['WorkflowResponse'];
|
|
23
|
-
/** The authorization tier of a
|
|
24
|
-
export type TaskAuthMode =
|
|
23
|
+
/** The authorization tier of a workflow's runs. A workflow never keeps permanent access. */
|
|
24
|
+
export type TaskAuthMode = CreateWorkflowRequest['auth_mode'];
|
|
25
25
|
/**
|
|
26
26
|
* The plain-language access choice becomes the backend authorisation tier: run-now work is
|
|
27
|
-
* authorised for that one run
|
|
27
|
+
* authorised for that one run; an unattended workflow either asks each run or runs on a timed
|
|
28
|
+
* authorization (`scheduled_grant`, its length sent as `access_seconds`).
|
|
28
29
|
*/
|
|
29
30
|
export declare function authModeFor(values: Pick<TaskComposerValues, 'when' | 'access'>): TaskAuthMode;
|
|
30
31
|
/** `datetime-local` value (no zone) to an ISO instant. Throws on an empty or invalid value. */
|
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { composeWorkflowPrompt } from "../workflows/workflow.js";
|
|
3
|
+
import {
|
|
4
|
+
accessModeOf,
|
|
5
|
+
accessSecondsFor
|
|
6
|
+
} from "./taskComposerTypes.js";
|
|
3
7
|
function authModeFor(values) {
|
|
4
8
|
if (values.when === "now" || values.when === "manual") return "run_now_temp";
|
|
5
|
-
return values.access
|
|
9
|
+
return accessSecondsFor(values.access) ? "scheduled_grant" : "scheduled_require_auth";
|
|
6
10
|
}
|
|
11
|
+
const accessFields = (values) => authModeFor(values) === "scheduled_grant" ? { access_seconds: accessSecondsFor(values.access) } : {};
|
|
7
12
|
function localInputToIso(local) {
|
|
8
13
|
const d = new Date(local);
|
|
9
14
|
if (!local || Number.isNaN(d.getTime())) throw new Error("Pick a valid date and time.");
|
|
@@ -169,6 +174,7 @@ function composerToWorkflowRequest({ workflow, values, plan, documentTitles }, w
|
|
|
169
174
|
skill_inputs: fields.skill_inputs,
|
|
170
175
|
agent_ext_id: values.agentId || null,
|
|
171
176
|
auth_mode: authModeFor(values),
|
|
177
|
+
...accessFields(values),
|
|
172
178
|
workspace_ext_id: workspaceId,
|
|
173
179
|
// The plan grades every run of a free-instruction workflow (a skill's run is not a goal run).
|
|
174
180
|
...fields.skill_ref === null && fields.prompt && plan ? { plan } : {}
|
|
@@ -212,6 +218,7 @@ function composerToWorkflowUpdate({
|
|
|
212
218
|
skill_inputs: fields.skill_inputs,
|
|
213
219
|
agent_ext_id: values.agentId || null,
|
|
214
220
|
auth_mode: authModeFor(values),
|
|
221
|
+
...accessFields(values),
|
|
215
222
|
// Omission preserves the plan; explicit null removes a stored free-instruction plan.
|
|
216
223
|
...fields.skill_ref === null && fields.prompt && plan !== void 0 ? { plan } : {}
|
|
217
224
|
};
|
|
@@ -255,7 +262,7 @@ function workflowToComposerValues(workflow, workflows) {
|
|
|
255
262
|
description: workflow.description ?? "",
|
|
256
263
|
agentId: workflow.agent_ext_id ?? "",
|
|
257
264
|
name: workflow.name,
|
|
258
|
-
access: workflow.auth_mode
|
|
265
|
+
access: accessModeOf(workflow.auth_mode, workflow.access_seconds)
|
|
259
266
|
};
|
|
260
267
|
if (workflow.action) {
|
|
261
268
|
const definition = workflows.definitions?.find(
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/agents/tasks/taskRequest.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * TaskComposer values to API requests (and back): the pure mapping every host would write the same\n * way. No SDK call is made here; hand the result to the hooks from `@arbidocs/react`.\n *\n * \"Now\" (or a plain to-do) creates work: a conversation with a status (`useCreateWork`). Any other\n * start (a date, a repeat, an event, after another task) saves a workflow (`useCreateWorkflow`) that\n * creates the work when it fires.\n */\nimport type { components } from '@arbidocs/client'\nimport { composeWorkflowPrompt, type WorkflowComposeContext } from '../workflows/workflow'\nimport type { WorkflowDefinition, WorkflowInputs } from '../workflows/types'\nimport type { TaskComposerValues, TaskWhen } from './taskComposerTypes'\nimport type { MessageMentionRef } from '@arbidocs/react/shell'\n\ntype Schemas = components['schemas']\ntype ConversationResponse = Schemas['ConversationResponse']\ntype CreateWorkRequest = Schemas['CreateWorkRequest']\ntype CreateWorkflowRequest = Schemas['CreateWorkflowRequest']\ntype TaskPlan = Schemas['TaskPlan']\ntype TaskOptions = Schemas['TaskOptions']\ntype UpdateConversationRequest = Schemas['UpdateConversationRequest']\ntype UpdateWorkflowRequest = Schemas['UpdateWorkflowRequest']\ntype WorkflowResponse = Schemas['WorkflowResponse']\n\n/** The authorization tier of a run (the same three values for work and for workflows). */\nexport type TaskAuthMode = CreateWorkRequest['auth_mode']\n\n/**\n * The plain-language access choice becomes the backend authorisation tier: run-now work is\n * authorised for that one run, a workflow either keeps standing access or asks each run.\n */\nexport function authModeFor(values: Pick<TaskComposerValues, 'when' | 'access'>): TaskAuthMode {\n if (values.when === 'now' || values.when === 'manual') return 'run_now_temp'\n return values.access === 'standing' ? 'scheduled_permanent' : 'scheduled_require_auth'\n}\n\n/** `datetime-local` value (no zone) to an ISO instant. Throws on an empty or invalid value. */\nexport function localInputToIso(local: string): string {\n const d = new Date(local)\n if (!local || Number.isNaN(d.getTime())) throw new Error('Pick a valid date and time.')\n return d.toISOString()\n}\n\n/** An ISO instant to the `datetime-local` value the composer edits; empty for none or invalid. */\nexport function isoToLocalInput(iso: string | null | undefined): string {\n if (!iso) return ''\n const d = new Date(iso)\n if (Number.isNaN(d.getTime())) return ''\n return new Date(d.getTime() - d.getTimezoneOffset() * 60000).toISOString().slice(0, 16)\n}\n\nexport interface WorkflowTaskFields {\n /** The title of the work or the name of the workflow. */\n name: string\n action?: Schemas['DocumentAutomationAction']\n prompt: string\n skill_ref: string | null\n /** The skill's saved inputs (only for a skill). */\n skill_inputs: WorkflowInputs | null\n}\n\n/** How many words of an instruction a derived name keeps. */\nexport const DERIVED_NAME_WORDS = 6\n\n/** The first `count` words of a text, with an ellipsis when there is more; empty for blank text. */\nexport function firstWords(text: string, count = DERIVED_NAME_WORDS): string {\n const words = text.trim().split(/\\s+/).filter(Boolean)\n if (words.length <= count) return words.join(' ')\n return `${words.slice(0, count).join(' ')}\u2026`\n}\n\n/**\n * The name a workflow (or task) gets when its owner types none: the template's title or, for a template\n * that is a free-text instruction or reminder (its form is just an `instruction` or `message`), the\n * first few words of what was written, falling back to the title while it is still blank.\n */\nexport function deriveWorkflowName(workflow: WorkflowDefinition, inputs: WorkflowInputs): string {\n for (const field of ['instruction', 'message']) {\n if (workflow.inputs.some((i) => i.name === field)) {\n const written = inputs[field]\n return (typeof written === 'string' && firstWords(written)) || workflow.title\n }\n }\n return workflow.title\n}\n\n/**\n * How a workflow definition becomes an action:\n * - `options.agent === false` is a reminder: the composed text is the title and there is no prompt or\n * skill (the backend makes a to-do and notifies the owner);\n * - a definition with a `skill` runs that skill, its `args` input being the arguments;\n * - anything else is an agent prompt, the composed workflow prompt.\n * `name` (typed by the user) wins over the derived one (see {@link deriveWorkflowName}).\n */\n/** Does any input name files (an explicit pick, or a resolved scope)? Those bind the run. */\nconst hasDocumentInputs = (inputs: WorkflowInputs): boolean =>\n Object.values(inputs).some(\n (v) =>\n v !== null &&\n typeof v === 'object' &&\n Array.isArray((v as { documents?: unknown }).documents) &&\n ((v as { documents: unknown[] }).documents.length ?? 0) > 0\n )\n\nexport function workflowTaskFields(\n workflow: WorkflowDefinition,\n inputs: WorkflowInputs,\n name?: string,\n context?: WorkflowComposeContext\n): WorkflowTaskFields {\n if (workflow.documentAction) {\n const scope =\n inputs.scope && typeof inputs.scope === 'object' ? inputs.scope : { labels: [], folders: [] }\n return {\n name: name?.trim() || workflow.title,\n prompt: '',\n skill_ref: null,\n skill_inputs: inputs,\n action: {\n type: workflow.documentAction,\n documents: {\n doc_ext_ids: scope.documents ?? [],\n label_ext_ids: scope.labels ?? [],\n latest: inputs.latest === true,\n },\n tag_ext_ids: typeof inputs.output === 'string' && inputs.output ? [inputs.output] : [],\n overwrite: inputs.overwrite === true,\n },\n }\n }\n for (const value of Object.values(inputs)) {\n if (!value || typeof value !== 'object') continue\n const scope = value as { documents?: unknown[]; folders?: unknown[]; labels?: unknown[] }\n if (\n Array.isArray(scope.documents) &&\n !scope.documents.length &&\n ((scope.folders?.length ?? 0) > 0 || (scope.labels?.length ?? 0) > 0)\n ) {\n throw new Error(\n 'The selected file scope has no documents. Choose a scope containing files before running.'\n )\n }\n }\n const typed = name?.trim()\n if (workflow.options?.agent === false) {\n const message = composeWorkflowPrompt(workflow, inputs, context)\n return { name: typed || message, prompt: '', skill_ref: null, skill_inputs: null }\n }\n const derived = typed || deriveWorkflowName(workflow, inputs)\n if (workflow.skill) {\n return {\n name: derived,\n prompt: typeof inputs.args === 'string' ? inputs.args.trim() : '',\n skill_ref: workflow.skill,\n skill_inputs: inputs,\n }\n }\n return {\n name: derived,\n prompt: composeWorkflowPrompt(workflow, inputs, context),\n skill_ref: null,\n // The files a run is bound to travel in the saved inputs, whatever the template: the server binds\n // the run to the ids listed under any input's `documents`.\n skill_inputs: hasDocumentInputs(inputs) ? inputs : null,\n }\n}\n\n/** Does this workflow need a workspace to run (everything except a plain reminder)? */\nexport const isAgenticWorkflow = (workflow: WorkflowDefinition): boolean =>\n workflow.options?.agent !== false\n\nexport interface TaskRequestContext {\n /** File names for the prompt's wording (\"the document <name>\"), by file id. */\n documentTitles?: Record<string, string>\n workflow: WorkflowDefinition\n values: TaskComposerValues\n /** The goal checklist drafted for agent work, if any. */\n plan?: TaskPlan | null\n}\n\n/** Does this composer submission create work straight away (rather than save a workflow)? */\nexport const createsWork = (values: Pick<TaskComposerValues, 'assignee' | 'when'>): boolean =>\n values.assignee === 'me' || values.when === 'now' || values.when === 'manual'\n\n/**\n * The create-work request: a plain to-do (a title, no agent) or agent work that starts now. Agent work\n * throws when there is no workspace open.\n */\nexport function composerToWorkRequest(\n { workflow, values, plan, documentTitles }: TaskRequestContext,\n workspaceId: string | undefined\n): CreateWorkRequest {\n const common = {\n description: values.description.trim(),\n due_at: values.dueAt ? localInputToIso(values.dueAt) : null,\n parent_conversation_ext_id: values.parentTaskId || null,\n shared: values.shared,\n }\n // A task for me is a plain to-do: a title, no prompt and no agent (`auth_mode` is required, and only\n // matters for a run).\n if (values.assignee === 'me') {\n return { ...common, title: values.name.trim(), auth_mode: 'run_now_temp' }\n }\n const fields = workflowTaskFields(workflow, values.inputs, values.name, { documentTitles })\n if (isAgenticWorkflow(workflow) && !workspaceId) {\n throw new Error('Open a workspace to run an agent task.')\n }\n return {\n ...common,\n title: fields.name,\n prompt: fields.prompt || null,\n skill_ref: fields.skill_ref,\n ...(fields.skill_inputs ? { skill_inputs: fields.skill_inputs } : {}),\n agent_ext_id: values.agentId || null,\n auth_mode: 'run_now_temp',\n ...(fields.skill_ref === null && fields.prompt && plan ? { plan } : {}),\n }\n}\n\n/**\n * Run now is a plain assistant query that carries `task` options: the thread it starts becomes a task\n * (generating, then open again). The query is the person's own run, so there is no agent and no\n * access tier. The host turns this into a `POST /v1/responses` body.\n */\nexport interface TaskQuery {\n /** The message sent: the prompt, or `/skill-name arguments` for a skill. */\n input: string\n workspaceId: string\n /** Files the run is bound to (the ids under any input's `documents`). */\n docIds: string[]\n /** People @mentioned in the prompt: the server shares the thread with them and notifies them. */\n mentions?: MessageMentionRef[]\n task: TaskOptions\n}\n\n/** A thread to start: a task's query, or (no `task`) a plain conversation. */\nexport type ThreadQuery = Omit<TaskQuery, 'task'> & { task?: TaskOptions }\n\n/** The ids of the files a form's inputs name (an explicit pick, or a resolved scope), without repeats. */\nexport function inputDocumentIds(inputs: WorkflowInputs): string[] {\n const ids = new Set<string>()\n for (const v of Object.values(inputs)) {\n const docs =\n v !== null && typeof v === 'object' ? (v as { documents?: unknown }).documents : null\n if (Array.isArray(docs)) for (const d of docs) if (typeof d === 'string') ids.add(d)\n }\n return [...ids]\n}\n\n/** The query that runs agent work now (a prompt or a skill) as the person asking. Throws without a workspace. */\nexport function composerToTaskQuery(\n { workflow, values, plan, documentTitles }: TaskRequestContext,\n workspaceId: string | undefined\n): TaskQuery {\n if (!workspaceId) throw new Error('Open a workspace to run an agent task.')\n const fields = workflowTaskFields(workflow, values.inputs, values.name, { documentTitles })\n const input = fields.skill_ref\n ? `/${fields.skill_ref}${fields.prompt ? ` ${fields.prompt}` : ''}`\n : fields.prompt\n return {\n input,\n workspaceId,\n docIds: inputDocumentIds(values.inputs),\n task: {\n title: fields.name,\n description: values.description.trim(),\n due_at: values.dueAt ? localInputToIso(values.dueAt) : null,\n parent_conversation_ext_id: values.parentTaskId || null,\n shared: values.shared,\n ...(fields.skill_ref === null && fields.prompt && plan ? { plan } : {}),\n },\n }\n}\n\n/** The fields shared by creating and updating a workflow: the trigger. Others stay `null` on an update. */\nfunction workflowTrigger(values: TaskComposerValues, clearOthers: boolean) {\n const none = clearOthers ? null : undefined\n return {\n rrule: values.when === 'repeat' ? values.rrule.trim() : none,\n run_at: values.when === 'once' ? localInputToIso(values.runAt) : none,\n event_kind: values.when === 'event' ? values.eventKind.trim() : none,\n event_filter: values.when === 'event' ? (values.eventFilter ?? none) : none,\n after_conversation_ext_id: values.when === 'task' ? values.afterTaskId : none,\n // Saving a run-now template creates an on-demand workflow; other triggers clear it.\n on_demand: values.when === 'now' || values.when === 'manual',\n }\n}\n\nconst withoutUndefined = <T extends object>(o: T): T =>\n Object.fromEntries(Object.entries(o).filter(([, v]) => v !== undefined)) as T\n\n/**\n * The create-workflow request: exactly one trigger (a date, a repeat, an event, or another task being\n * done) and the action it runs. An agent workflow throws when there is no workspace open.\n */\nexport function composerToWorkflowRequest(\n { workflow, values, plan, documentTitles }: TaskRequestContext,\n workspaceId: string | undefined\n): CreateWorkflowRequest {\n const fields = workflowTaskFields(workflow, values.inputs, values.name, { documentTitles })\n // A workflow belongs to a workspace, a reminder included.\n if (!workspaceId) throw new Error('Open a workspace to save a workflow.')\n return withoutUndefined({\n name: fields.name,\n description: values.description.trim(),\n active: true,\n shared: values.shared,\n timezone: values.timezone,\n ...workflowTrigger(values, false),\n ...(fields.action ? { action: fields.action } : {}),\n prompt: fields.prompt,\n skill_ref: fields.skill_ref,\n skill_inputs: fields.skill_inputs,\n agent_ext_id: values.agentId || null,\n auth_mode: authModeFor(values),\n workspace_ext_id: workspaceId,\n // The plan grades every run of a free-instruction workflow (a skill's run is not a goal run).\n ...(fields.skill_ref === null && fields.prompt && plan ? { plan } : {}),\n })\n}\n\n/** What a composer submission asks the host to do. */\nexport type ComposerCreate =\n | { kind: 'work'; body: CreateWorkRequest }\n | { kind: 'query'; query: TaskQuery }\n | { kind: 'workflow'; body: CreateWorkflowRequest }\n\n/**\n * Route a submission: agent work now is an assistant query, a plain to-do or reminder creates work,\n * every other start creates a workflow.\n * `forceWorkflow` is for the workflow dialog, where even a reminder is saved as a workflow.\n */\nexport function taskComposerToCreateRequest(\n ctx: TaskRequestContext,\n workspaceId: string | undefined,\n forceWorkflow = false\n): ComposerCreate {\n if (forceWorkflow || ctx.workflow.documentAction || !createsWork(ctx.values)) {\n return { kind: 'workflow', body: composerToWorkflowRequest(ctx, workspaceId) }\n }\n // A to-do for me, or a reminder, is a plain task; agent work run now is an assistant query.\n return ctx.values.assignee === 'me' || !isAgenticWorkflow(ctx.workflow)\n ? { kind: 'work', body: composerToWorkRequest(ctx, workspaceId) }\n : { kind: 'query', query: composerToTaskQuery(ctx, workspaceId) }\n}\n\n/**\n * The patch for editing a task (`PATCH /v1/conversation/{id}`): title, description, due date, parent\n * (`null` detaches) and sharing. What the agent was told to do stays as created.\n */\nexport function taskComposerToUpdateRequest({\n values,\n plan,\n}: TaskRequestContext): UpdateConversationRequest {\n return {\n title: values.name.trim(),\n description: values.description.trim(),\n due_at: values.dueAt ? localInputToIso(values.dueAt) : null,\n shared: values.shared,\n parent_conversation_ext_id: values.parentTaskId || null,\n ...(plan !== undefined ? { plan } : {}),\n }\n}\n\n/** The patch for editing a workflow: name, trigger (the other triggers are cleared) and action. */\nexport function composerToWorkflowUpdate({\n workflow,\n values,\n plan,\n documentTitles,\n}: TaskRequestContext): UpdateWorkflowRequest {\n const fields = workflowTaskFields(workflow, values.inputs, values.name, { documentTitles })\n return {\n name: fields.name,\n description: values.description.trim(),\n shared: values.shared,\n timezone: values.timezone,\n ...workflowTrigger(values, true),\n action: fields.action ?? null,\n prompt: fields.prompt,\n skill_ref: fields.skill_ref,\n skill_inputs: fields.skill_inputs,\n agent_ext_id: values.agentId || null,\n auth_mode: authModeFor(values),\n // Omission preserves the plan; explicit null removes a stored free-instruction plan.\n ...(fields.skill_ref === null && fields.prompt && plan !== undefined ? { plan } : {}),\n }\n}\n\n/** Does the task need the owner to authorise workspace access before it can run? */\nexport const taskNeedsAccess = (\n task: Pick<ConversationResponse, 'pending_auth_request_id'>\n): boolean => !!task.pending_auth_request_id\n\nexport interface TaskValuesWorkflows {\n /** The workflow that stands for an instruction task (its first input is `instruction`). */\n customWorkflowId: string\n /** The workflow that stands for a reminder (its first input is `message`). */\n reminderWorkflowId: string\n /** The definitions a saved skill can be matched to (by `skill`), to restore a skill workflow's form. */\n definitions?: WorkflowDefinition[]\n}\n\n/** What an existing task (a conversation with a status) looks like when reopened in the composer. */\nexport function taskToComposerValues(\n task: ConversationResponse,\n workflows: TaskValuesWorkflows\n): Partial<TaskComposerValues> {\n const forMe = !task.agent_ext_id && !task.skill_ref && !task.has_agent_action\n return {\n assignee: forMe ? 'me' : 'agent',\n workflowId: forMe ? workflows.reminderWorkflowId : workflows.customWorkflowId,\n inputs: {},\n when: 'now',\n parentTaskId: task.parent_conversation_ext_id ?? '',\n shared: task.is_shared ?? true,\n description: task.description ?? '',\n dueAt: isoToLocalInput(task.due_at),\n agentId: task.agent_ext_id ?? '',\n name: task.title ?? '',\n }\n}\n\n/** Which start a saved workflow has. */\nexport function workflowWhen(workflow: WorkflowResponse): TaskWhen {\n if (workflow.on_demand) return 'now'\n if (workflow.after_conversation_ext_id) return 'task'\n if (workflow.event_kind) return 'event'\n if (workflow.rrule) return 'repeat'\n return workflow.run_at ? 'once' : 'now'\n}\n\n/** What an existing workflow looks like when reopened in the workflow dialog. */\nexport function workflowToComposerValues(\n workflow: WorkflowResponse,\n workflows: TaskValuesWorkflows\n): Partial<TaskComposerValues> {\n const reminder = !workflow.prompt && !workflow.skill_ref\n const skill = workflow.skill_ref\n ? workflows.definitions?.find((d) => d.skill === workflow.skill_ref)\n : undefined\n const base = {\n assignee: 'agent' as const,\n when: workflowWhen(workflow),\n runAt: isoToLocalInput(workflow.run_at),\n rrule: workflow.rrule ?? '',\n timezone: workflow.timezone,\n eventKind: workflow.event_kind ?? 'mention',\n eventFilter: (workflow.event_filter ?? null) as TaskComposerValues['eventFilter'],\n afterTaskId: workflow.after_conversation_ext_id ?? '',\n shared: workflow.shared,\n description: workflow.description ?? '',\n agentId: workflow.agent_ext_id ?? '',\n name: workflow.name,\n access:\n workflow.auth_mode === 'scheduled_permanent'\n ? ('standing' as const)\n : ('ask_each_run' as const),\n }\n if (workflow.action) {\n const definition = workflows.definitions?.find(\n (d) => d.documentAction === workflow.action?.type\n )\n return {\n ...base,\n workflowId: definition?.id ?? workflows.customWorkflowId,\n inputs: {\n scope: {\n folders: [],\n labels: workflow.action.documents?.label_ext_ids ?? [],\n documents: workflow.action.documents?.doc_ext_ids ?? [],\n },\n output: workflow.action.tag_ext_ids?.[0] ?? '',\n overwrite: workflow.action.overwrite ?? false,\n latest: workflow.action.documents?.latest ?? false,\n },\n }\n }\n if (skill) {\n return {\n ...base,\n workflowId: skill.id,\n inputs: (workflow.skill_inputs as WorkflowInputs | null | undefined) ?? {\n args: workflow.prompt,\n },\n }\n }\n return reminder\n ? { ...base, workflowId: workflows.reminderWorkflowId, inputs: { message: workflow.name } }\n : {\n ...base,\n // A name made from the instruction follows it when the instruction is edited.\n name: workflow.name === firstWords(workflow.prompt ?? '') ? '' : workflow.name,\n workflowId: workflows.customWorkflowId,\n inputs: {\n ...((workflow.skill_inputs as WorkflowInputs | null | undefined) ?? {}),\n instruction: workflow.prompt,\n },\n }\n}\n\n/** What the New task dialog collects: a prompt, who sees it, and optional task details. */\nexport interface NewThreadValues {\n /** What to ask or get done: the first message, which the assistant answers. The title is made from it. */\n prompt: string\n /** A name instead of the generated one. Optional. */\n title: string\n /** Shared with the workspace's members (the default), or private to its creator. */\n shared: boolean\n /** datetime-local value; empty = none. A task field. */\n dueAt: string\n /** The task this is a sub-task of (`con-\u2026`); `''` = none. A task field. */\n parentId: string\n /** Whether the assistant starts on the prompt now. Off: it is a to-do, tracked and not run. */\n assistant: boolean\n}\n\nexport const EMPTY_NEW_THREAD: NewThreadValues = {\n prompt: '',\n title: '',\n shared: false,\n dueAt: '',\n parentId: '',\n assistant: true,\n}\n\n/** Is any task detail filled in (the dialog opens its details when one is preset)? */\nexport const hasTaskFields = (v: NewThreadValues): boolean => Boolean(v.dueAt || v.parentId)\n\n/** A new task: the prompt as the first message (the assistant answers it) and the task's options. */\nexport interface NewThreadRequest {\n input: string\n shared: boolean\n task: TaskOptions\n /** False: nothing is asked of the assistant: the host adds a plain to-do from `todo`. */\n startAssistant: boolean\n /** The to-do to add when `startAssistant` is false: a title and the rest of what the person wrote. */\n todo?: { title: string; description: string }\n}\n\n/** The first line of a prompt, kept to a title's length. */\nexport function titleFromPrompt(prompt: string, max = 80): string {\n const first = prompt.trim().split('\\n')[0].trim()\n return first.length > max ? `${first.slice(0, max - 1).trimEnd()}\u2026` : first\n}\n\n/**\n * The request for a New task submission. Every ask is a task, so the options always ride along; the due\n * date and parent are only set when filled in. The title is only sent when the person wrote one;\n * otherwise the server names the task from the prompt. With the assistant switched off nothing is run: it\n * is a to-do.\n */\nexport function newThreadToRequest(values: NewThreadValues): NewThreadRequest {\n const input = values.prompt.trim()\n const title = values.title.trim()\n const task: TaskOptions = {\n ...(title ? { title } : {}),\n due_at: values.dueAt ? localInputToIso(values.dueAt) : null,\n parent_conversation_ext_id: values.parentId || null,\n shared: values.shared,\n }\n if (!values.assistant) {\n const name = title || titleFromPrompt(input)\n return {\n input,\n shared: values.shared,\n task,\n startAssistant: false,\n todo: { title: name, description: input === name ? '' : input },\n }\n }\n return { input, shared: values.shared, task, startAssistant: true }\n}\n"],
|
|
5
|
-
"mappings": ";AASA,SAAS,6BAA0D;
|
|
4
|
+
"sourcesContent": ["/**\n * TaskComposer values to API requests (and back): the pure mapping every host would write the same\n * way. No SDK call is made here; hand the result to the hooks from `@arbidocs/react`.\n *\n * \"Now\" (or a plain to-do) creates work: a conversation with a status (`useCreateWork`). Any other\n * start (a date, a repeat, an event, after another task) saves a workflow (`useCreateWorkflow`) that\n * creates the work when it fires.\n */\nimport type { components } from '@arbidocs/client'\nimport { composeWorkflowPrompt, type WorkflowComposeContext } from '../workflows/workflow'\nimport type { WorkflowDefinition, WorkflowInputs } from '../workflows/types'\nimport {\n accessModeOf,\n accessSecondsFor,\n type TaskComposerValues,\n type TaskWhen,\n} from './taskComposerTypes'\nimport type { MessageMentionRef } from '@arbidocs/react/shell'\n\ntype Schemas = components['schemas']\ntype ConversationResponse = Schemas['ConversationResponse']\ntype CreateWorkRequest = Schemas['CreateWorkRequest']\ntype CreateWorkflowRequest = Schemas['CreateWorkflowRequest']\ntype TaskPlan = Schemas['TaskPlan']\ntype TaskOptions = Schemas['TaskOptions']\ntype UpdateConversationRequest = Schemas['UpdateConversationRequest']\ntype UpdateWorkflowRequest = Schemas['UpdateWorkflowRequest']\ntype WorkflowResponse = Schemas['WorkflowResponse']\n\n/** The authorization tier of a workflow's runs. A workflow never keeps permanent access. */\nexport type TaskAuthMode = CreateWorkflowRequest['auth_mode']\n\n/**\n * The plain-language access choice becomes the backend authorisation tier: run-now work is\n * authorised for that one run; an unattended workflow either asks each run or runs on a timed\n * authorization (`scheduled_grant`, its length sent as `access_seconds`).\n */\nexport function authModeFor(values: Pick<TaskComposerValues, 'when' | 'access'>): TaskAuthMode {\n if (values.when === 'now' || values.when === 'manual') return 'run_now_temp'\n return accessSecondsFor(values.access) ? 'scheduled_grant' : 'scheduled_require_auth'\n}\n\n/** The authorization length to send with a timed workflow (nothing for any other choice). */\nconst accessFields = (values: Pick<TaskComposerValues, 'when' | 'access'>) =>\n authModeFor(values) === 'scheduled_grant'\n ? { access_seconds: accessSecondsFor(values.access) }\n : {}\n\n/** `datetime-local` value (no zone) to an ISO instant. Throws on an empty or invalid value. */\nexport function localInputToIso(local: string): string {\n const d = new Date(local)\n if (!local || Number.isNaN(d.getTime())) throw new Error('Pick a valid date and time.')\n return d.toISOString()\n}\n\n/** An ISO instant to the `datetime-local` value the composer edits; empty for none or invalid. */\nexport function isoToLocalInput(iso: string | null | undefined): string {\n if (!iso) return ''\n const d = new Date(iso)\n if (Number.isNaN(d.getTime())) return ''\n return new Date(d.getTime() - d.getTimezoneOffset() * 60000).toISOString().slice(0, 16)\n}\n\nexport interface WorkflowTaskFields {\n /** The title of the work or the name of the workflow. */\n name: string\n action?: Schemas['DocumentAutomationAction']\n prompt: string\n skill_ref: string | null\n /** The skill's saved inputs (only for a skill). */\n skill_inputs: WorkflowInputs | null\n}\n\n/** How many words of an instruction a derived name keeps. */\nexport const DERIVED_NAME_WORDS = 6\n\n/** The first `count` words of a text, with an ellipsis when there is more; empty for blank text. */\nexport function firstWords(text: string, count = DERIVED_NAME_WORDS): string {\n const words = text.trim().split(/\\s+/).filter(Boolean)\n if (words.length <= count) return words.join(' ')\n return `${words.slice(0, count).join(' ')}\u2026`\n}\n\n/**\n * The name a workflow (or task) gets when its owner types none: the template's title or, for a template\n * that is a free-text instruction or reminder (its form is just an `instruction` or `message`), the\n * first few words of what was written, falling back to the title while it is still blank.\n */\nexport function deriveWorkflowName(workflow: WorkflowDefinition, inputs: WorkflowInputs): string {\n for (const field of ['instruction', 'message']) {\n if (workflow.inputs.some((i) => i.name === field)) {\n const written = inputs[field]\n return (typeof written === 'string' && firstWords(written)) || workflow.title\n }\n }\n return workflow.title\n}\n\n/**\n * How a workflow definition becomes an action:\n * - `options.agent === false` is a reminder: the composed text is the title and there is no prompt or\n * skill (the backend makes a to-do and notifies the owner);\n * - a definition with a `skill` runs that skill, its `args` input being the arguments;\n * - anything else is an agent prompt, the composed workflow prompt.\n * `name` (typed by the user) wins over the derived one (see {@link deriveWorkflowName}).\n */\n/** Does any input name files (an explicit pick, or a resolved scope)? Those bind the run. */\nconst hasDocumentInputs = (inputs: WorkflowInputs): boolean =>\n Object.values(inputs).some(\n (v) =>\n v !== null &&\n typeof v === 'object' &&\n Array.isArray((v as { documents?: unknown }).documents) &&\n ((v as { documents: unknown[] }).documents.length ?? 0) > 0\n )\n\nexport function workflowTaskFields(\n workflow: WorkflowDefinition,\n inputs: WorkflowInputs,\n name?: string,\n context?: WorkflowComposeContext\n): WorkflowTaskFields {\n if (workflow.documentAction) {\n const scope =\n inputs.scope && typeof inputs.scope === 'object' ? inputs.scope : { labels: [], folders: [] }\n return {\n name: name?.trim() || workflow.title,\n prompt: '',\n skill_ref: null,\n skill_inputs: inputs,\n action: {\n type: workflow.documentAction,\n documents: {\n doc_ext_ids: scope.documents ?? [],\n label_ext_ids: scope.labels ?? [],\n latest: inputs.latest === true,\n },\n tag_ext_ids: typeof inputs.output === 'string' && inputs.output ? [inputs.output] : [],\n overwrite: inputs.overwrite === true,\n },\n }\n }\n for (const value of Object.values(inputs)) {\n if (!value || typeof value !== 'object') continue\n const scope = value as { documents?: unknown[]; folders?: unknown[]; labels?: unknown[] }\n if (\n Array.isArray(scope.documents) &&\n !scope.documents.length &&\n ((scope.folders?.length ?? 0) > 0 || (scope.labels?.length ?? 0) > 0)\n ) {\n throw new Error(\n 'The selected file scope has no documents. Choose a scope containing files before running.'\n )\n }\n }\n const typed = name?.trim()\n if (workflow.options?.agent === false) {\n const message = composeWorkflowPrompt(workflow, inputs, context)\n return { name: typed || message, prompt: '', skill_ref: null, skill_inputs: null }\n }\n const derived = typed || deriveWorkflowName(workflow, inputs)\n if (workflow.skill) {\n return {\n name: derived,\n prompt: typeof inputs.args === 'string' ? inputs.args.trim() : '',\n skill_ref: workflow.skill,\n skill_inputs: inputs,\n }\n }\n return {\n name: derived,\n prompt: composeWorkflowPrompt(workflow, inputs, context),\n skill_ref: null,\n // The files a run is bound to travel in the saved inputs, whatever the template: the server binds\n // the run to the ids listed under any input's `documents`.\n skill_inputs: hasDocumentInputs(inputs) ? inputs : null,\n }\n}\n\n/** Does this workflow need a workspace to run (everything except a plain reminder)? */\nexport const isAgenticWorkflow = (workflow: WorkflowDefinition): boolean =>\n workflow.options?.agent !== false\n\nexport interface TaskRequestContext {\n /** File names for the prompt's wording (\"the document <name>\"), by file id. */\n documentTitles?: Record<string, string>\n workflow: WorkflowDefinition\n values: TaskComposerValues\n /** The goal checklist drafted for agent work, if any. */\n plan?: TaskPlan | null\n}\n\n/** Does this composer submission create work straight away (rather than save a workflow)? */\nexport const createsWork = (values: Pick<TaskComposerValues, 'assignee' | 'when'>): boolean =>\n values.assignee === 'me' || values.when === 'now' || values.when === 'manual'\n\n/**\n * The create-work request: a plain to-do (a title, no agent) or agent work that starts now. Agent work\n * throws when there is no workspace open.\n */\nexport function composerToWorkRequest(\n { workflow, values, plan, documentTitles }: TaskRequestContext,\n workspaceId: string | undefined\n): CreateWorkRequest {\n const common = {\n description: values.description.trim(),\n due_at: values.dueAt ? localInputToIso(values.dueAt) : null,\n parent_conversation_ext_id: values.parentTaskId || null,\n shared: values.shared,\n }\n // A task for me is a plain to-do: a title, no prompt and no agent (`auth_mode` is required, and only\n // matters for a run).\n if (values.assignee === 'me') {\n return { ...common, title: values.name.trim(), auth_mode: 'run_now_temp' }\n }\n const fields = workflowTaskFields(workflow, values.inputs, values.name, { documentTitles })\n if (isAgenticWorkflow(workflow) && !workspaceId) {\n throw new Error('Open a workspace to run an agent task.')\n }\n return {\n ...common,\n title: fields.name,\n prompt: fields.prompt || null,\n skill_ref: fields.skill_ref,\n ...(fields.skill_inputs ? { skill_inputs: fields.skill_inputs } : {}),\n agent_ext_id: values.agentId || null,\n auth_mode: 'run_now_temp',\n ...(fields.skill_ref === null && fields.prompt && plan ? { plan } : {}),\n }\n}\n\n/**\n * Run now is a plain assistant query that carries `task` options: the thread it starts becomes a task\n * (generating, then open again). The query is the person's own run, so there is no agent and no\n * access tier. The host turns this into a `POST /v1/responses` body.\n */\nexport interface TaskQuery {\n /** The message sent: the prompt, or `/skill-name arguments` for a skill. */\n input: string\n workspaceId: string\n /** Files the run is bound to (the ids under any input's `documents`). */\n docIds: string[]\n /** People @mentioned in the prompt: the server shares the thread with them and notifies them. */\n mentions?: MessageMentionRef[]\n task: TaskOptions\n}\n\n/** A thread to start: a task's query, or (no `task`) a plain conversation. */\nexport type ThreadQuery = Omit<TaskQuery, 'task'> & { task?: TaskOptions }\n\n/** The ids of the files a form's inputs name (an explicit pick, or a resolved scope), without repeats. */\nexport function inputDocumentIds(inputs: WorkflowInputs): string[] {\n const ids = new Set<string>()\n for (const v of Object.values(inputs)) {\n const docs =\n v !== null && typeof v === 'object' ? (v as { documents?: unknown }).documents : null\n if (Array.isArray(docs)) for (const d of docs) if (typeof d === 'string') ids.add(d)\n }\n return [...ids]\n}\n\n/** The query that runs agent work now (a prompt or a skill) as the person asking. Throws without a workspace. */\nexport function composerToTaskQuery(\n { workflow, values, plan, documentTitles }: TaskRequestContext,\n workspaceId: string | undefined\n): TaskQuery {\n if (!workspaceId) throw new Error('Open a workspace to run an agent task.')\n const fields = workflowTaskFields(workflow, values.inputs, values.name, { documentTitles })\n const input = fields.skill_ref\n ? `/${fields.skill_ref}${fields.prompt ? ` ${fields.prompt}` : ''}`\n : fields.prompt\n return {\n input,\n workspaceId,\n docIds: inputDocumentIds(values.inputs),\n task: {\n title: fields.name,\n description: values.description.trim(),\n due_at: values.dueAt ? localInputToIso(values.dueAt) : null,\n parent_conversation_ext_id: values.parentTaskId || null,\n shared: values.shared,\n ...(fields.skill_ref === null && fields.prompt && plan ? { plan } : {}),\n },\n }\n}\n\n/** The fields shared by creating and updating a workflow: the trigger. Others stay `null` on an update. */\nfunction workflowTrigger(values: TaskComposerValues, clearOthers: boolean) {\n const none = clearOthers ? null : undefined\n return {\n rrule: values.when === 'repeat' ? values.rrule.trim() : none,\n run_at: values.when === 'once' ? localInputToIso(values.runAt) : none,\n event_kind: values.when === 'event' ? values.eventKind.trim() : none,\n event_filter: values.when === 'event' ? (values.eventFilter ?? none) : none,\n after_conversation_ext_id: values.when === 'task' ? values.afterTaskId : none,\n // Saving a run-now template creates an on-demand workflow; other triggers clear it.\n on_demand: values.when === 'now' || values.when === 'manual',\n }\n}\n\nconst withoutUndefined = <T extends object>(o: T): T =>\n Object.fromEntries(Object.entries(o).filter(([, v]) => v !== undefined)) as T\n\n/**\n * The create-workflow request: exactly one trigger (a date, a repeat, an event, or another task being\n * done) and the action it runs. An agent workflow throws when there is no workspace open.\n */\nexport function composerToWorkflowRequest(\n { workflow, values, plan, documentTitles }: TaskRequestContext,\n workspaceId: string | undefined\n): CreateWorkflowRequest {\n const fields = workflowTaskFields(workflow, values.inputs, values.name, { documentTitles })\n // A workflow belongs to a workspace, a reminder included.\n if (!workspaceId) throw new Error('Open a workspace to save a workflow.')\n return withoutUndefined({\n name: fields.name,\n description: values.description.trim(),\n active: true,\n shared: values.shared,\n timezone: values.timezone,\n ...workflowTrigger(values, false),\n ...(fields.action ? { action: fields.action } : {}),\n prompt: fields.prompt,\n skill_ref: fields.skill_ref,\n skill_inputs: fields.skill_inputs,\n agent_ext_id: values.agentId || null,\n auth_mode: authModeFor(values),\n ...accessFields(values),\n workspace_ext_id: workspaceId,\n // The plan grades every run of a free-instruction workflow (a skill's run is not a goal run).\n ...(fields.skill_ref === null && fields.prompt && plan ? { plan } : {}),\n })\n}\n\n/** What a composer submission asks the host to do. */\nexport type ComposerCreate =\n | { kind: 'work'; body: CreateWorkRequest }\n | { kind: 'query'; query: TaskQuery }\n | { kind: 'workflow'; body: CreateWorkflowRequest }\n\n/**\n * Route a submission: agent work now is an assistant query, a plain to-do or reminder creates work,\n * every other start creates a workflow.\n * `forceWorkflow` is for the workflow dialog, where even a reminder is saved as a workflow.\n */\nexport function taskComposerToCreateRequest(\n ctx: TaskRequestContext,\n workspaceId: string | undefined,\n forceWorkflow = false\n): ComposerCreate {\n if (forceWorkflow || ctx.workflow.documentAction || !createsWork(ctx.values)) {\n return { kind: 'workflow', body: composerToWorkflowRequest(ctx, workspaceId) }\n }\n // A to-do for me, or a reminder, is a plain task; agent work run now is an assistant query.\n return ctx.values.assignee === 'me' || !isAgenticWorkflow(ctx.workflow)\n ? { kind: 'work', body: composerToWorkRequest(ctx, workspaceId) }\n : { kind: 'query', query: composerToTaskQuery(ctx, workspaceId) }\n}\n\n/**\n * The patch for editing a task (`PATCH /v1/conversation/{id}`): title, description, due date, parent\n * (`null` detaches) and sharing. What the agent was told to do stays as created.\n */\nexport function taskComposerToUpdateRequest({\n values,\n plan,\n}: TaskRequestContext): UpdateConversationRequest {\n return {\n title: values.name.trim(),\n description: values.description.trim(),\n due_at: values.dueAt ? localInputToIso(values.dueAt) : null,\n shared: values.shared,\n parent_conversation_ext_id: values.parentTaskId || null,\n ...(plan !== undefined ? { plan } : {}),\n }\n}\n\n/** The patch for editing a workflow: name, trigger (the other triggers are cleared) and action. */\nexport function composerToWorkflowUpdate({\n workflow,\n values,\n plan,\n documentTitles,\n}: TaskRequestContext): UpdateWorkflowRequest {\n const fields = workflowTaskFields(workflow, values.inputs, values.name, { documentTitles })\n return {\n name: fields.name,\n description: values.description.trim(),\n shared: values.shared,\n timezone: values.timezone,\n ...workflowTrigger(values, true),\n action: fields.action ?? null,\n prompt: fields.prompt,\n skill_ref: fields.skill_ref,\n skill_inputs: fields.skill_inputs,\n agent_ext_id: values.agentId || null,\n auth_mode: authModeFor(values),\n ...accessFields(values),\n // Omission preserves the plan; explicit null removes a stored free-instruction plan.\n ...(fields.skill_ref === null && fields.prompt && plan !== undefined ? { plan } : {}),\n }\n}\n\n/** Does the task need the owner to authorise workspace access before it can run? */\nexport const taskNeedsAccess = (\n task: Pick<ConversationResponse, 'pending_auth_request_id'>\n): boolean => !!task.pending_auth_request_id\n\nexport interface TaskValuesWorkflows {\n /** The workflow that stands for an instruction task (its first input is `instruction`). */\n customWorkflowId: string\n /** The workflow that stands for a reminder (its first input is `message`). */\n reminderWorkflowId: string\n /** The definitions a saved skill can be matched to (by `skill`), to restore a skill workflow's form. */\n definitions?: WorkflowDefinition[]\n}\n\n/** What an existing task (a conversation with a status) looks like when reopened in the composer. */\nexport function taskToComposerValues(\n task: ConversationResponse,\n workflows: TaskValuesWorkflows\n): Partial<TaskComposerValues> {\n const forMe = !task.agent_ext_id && !task.skill_ref && !task.has_agent_action\n return {\n assignee: forMe ? 'me' : 'agent',\n workflowId: forMe ? workflows.reminderWorkflowId : workflows.customWorkflowId,\n inputs: {},\n when: 'now',\n parentTaskId: task.parent_conversation_ext_id ?? '',\n shared: task.is_shared ?? true,\n description: task.description ?? '',\n dueAt: isoToLocalInput(task.due_at),\n agentId: task.agent_ext_id ?? '',\n name: task.title ?? '',\n }\n}\n\n/** Which start a saved workflow has. */\nexport function workflowWhen(workflow: WorkflowResponse): TaskWhen {\n if (workflow.on_demand) return 'now'\n if (workflow.after_conversation_ext_id) return 'task'\n if (workflow.event_kind) return 'event'\n if (workflow.rrule) return 'repeat'\n return workflow.run_at ? 'once' : 'now'\n}\n\n/** What an existing workflow looks like when reopened in the workflow dialog. */\nexport function workflowToComposerValues(\n workflow: WorkflowResponse,\n workflows: TaskValuesWorkflows\n): Partial<TaskComposerValues> {\n const reminder = !workflow.prompt && !workflow.skill_ref\n const skill = workflow.skill_ref\n ? workflows.definitions?.find((d) => d.skill === workflow.skill_ref)\n : undefined\n const base = {\n assignee: 'agent' as const,\n when: workflowWhen(workflow),\n runAt: isoToLocalInput(workflow.run_at),\n rrule: workflow.rrule ?? '',\n timezone: workflow.timezone,\n eventKind: workflow.event_kind ?? 'mention',\n eventFilter: (workflow.event_filter ?? null) as TaskComposerValues['eventFilter'],\n afterTaskId: workflow.after_conversation_ext_id ?? '',\n shared: workflow.shared,\n description: workflow.description ?? '',\n agentId: workflow.agent_ext_id ?? '',\n name: workflow.name,\n access: accessModeOf(workflow.auth_mode, workflow.access_seconds),\n }\n if (workflow.action) {\n const definition = workflows.definitions?.find(\n (d) => d.documentAction === workflow.action?.type\n )\n return {\n ...base,\n workflowId: definition?.id ?? workflows.customWorkflowId,\n inputs: {\n scope: {\n folders: [],\n labels: workflow.action.documents?.label_ext_ids ?? [],\n documents: workflow.action.documents?.doc_ext_ids ?? [],\n },\n output: workflow.action.tag_ext_ids?.[0] ?? '',\n overwrite: workflow.action.overwrite ?? false,\n latest: workflow.action.documents?.latest ?? false,\n },\n }\n }\n if (skill) {\n return {\n ...base,\n workflowId: skill.id,\n inputs: (workflow.skill_inputs as WorkflowInputs | null | undefined) ?? {\n args: workflow.prompt,\n },\n }\n }\n return reminder\n ? { ...base, workflowId: workflows.reminderWorkflowId, inputs: { message: workflow.name } }\n : {\n ...base,\n // A name made from the instruction follows it when the instruction is edited.\n name: workflow.name === firstWords(workflow.prompt ?? '') ? '' : workflow.name,\n workflowId: workflows.customWorkflowId,\n inputs: {\n ...((workflow.skill_inputs as WorkflowInputs | null | undefined) ?? {}),\n instruction: workflow.prompt,\n },\n }\n}\n\n/** What the New task dialog collects: a prompt, who sees it, and optional task details. */\nexport interface NewThreadValues {\n /** What to ask or get done: the first message, which the assistant answers. The title is made from it. */\n prompt: string\n /** A name instead of the generated one. Optional. */\n title: string\n /** Shared with the workspace's members (the default), or private to its creator. */\n shared: boolean\n /** datetime-local value; empty = none. A task field. */\n dueAt: string\n /** The task this is a sub-task of (`con-\u2026`); `''` = none. A task field. */\n parentId: string\n /** Whether the assistant starts on the prompt now. Off: it is a to-do, tracked and not run. */\n assistant: boolean\n}\n\nexport const EMPTY_NEW_THREAD: NewThreadValues = {\n prompt: '',\n title: '',\n shared: false,\n dueAt: '',\n parentId: '',\n assistant: true,\n}\n\n/** Is any task detail filled in (the dialog opens its details when one is preset)? */\nexport const hasTaskFields = (v: NewThreadValues): boolean => Boolean(v.dueAt || v.parentId)\n\n/** A new task: the prompt as the first message (the assistant answers it) and the task's options. */\nexport interface NewThreadRequest {\n input: string\n shared: boolean\n task: TaskOptions\n /** False: nothing is asked of the assistant: the host adds a plain to-do from `todo`. */\n startAssistant: boolean\n /** The to-do to add when `startAssistant` is false: a title and the rest of what the person wrote. */\n todo?: { title: string; description: string }\n}\n\n/** The first line of a prompt, kept to a title's length. */\nexport function titleFromPrompt(prompt: string, max = 80): string {\n const first = prompt.trim().split('\\n')[0].trim()\n return first.length > max ? `${first.slice(0, max - 1).trimEnd()}\u2026` : first\n}\n\n/**\n * The request for a New task submission. Every ask is a task, so the options always ride along; the due\n * date and parent are only set when filled in. The title is only sent when the person wrote one;\n * otherwise the server names the task from the prompt. With the assistant switched off nothing is run: it\n * is a to-do.\n */\nexport function newThreadToRequest(values: NewThreadValues): NewThreadRequest {\n const input = values.prompt.trim()\n const title = values.title.trim()\n const task: TaskOptions = {\n ...(title ? { title } : {}),\n due_at: values.dueAt ? localInputToIso(values.dueAt) : null,\n parent_conversation_ext_id: values.parentId || null,\n shared: values.shared,\n }\n if (!values.assistant) {\n const name = title || titleFromPrompt(input)\n return {\n input,\n shared: values.shared,\n task,\n startAssistant: false,\n todo: { title: name, description: input === name ? '' : input },\n }\n }\n return { input, shared: values.shared, task, startAssistant: true }\n}\n"],
|
|
5
|
+
"mappings": ";AASA,SAAS,6BAA0D;AAEnE;AAAA,EACE;AAAA,EACA;AAAA,OAGK;AAqBA,SAAS,YAAY,QAAmE;AAC7F,MAAI,OAAO,SAAS,SAAS,OAAO,SAAS,SAAU,QAAO;AAC9D,SAAO,iBAAiB,OAAO,MAAM,IAAI,oBAAoB;AAC/D;AAGA,MAAM,eAAe,CAAC,WACpB,YAAY,MAAM,MAAM,oBACpB,EAAE,gBAAgB,iBAAiB,OAAO,MAAM,EAAE,IAClD,CAAC;AAGA,SAAS,gBAAgB,OAAuB;AACrD,QAAM,IAAI,IAAI,KAAK,KAAK;AACxB,MAAI,CAAC,SAAS,OAAO,MAAM,EAAE,QAAQ,CAAC,EAAG,OAAM,IAAI,MAAM,6BAA6B;AACtF,SAAO,EAAE,YAAY;AACvB;AAGO,SAAS,gBAAgB,KAAwC;AACtE,MAAI,CAAC,IAAK,QAAO;AACjB,QAAM,IAAI,IAAI,KAAK,GAAG;AACtB,MAAI,OAAO,MAAM,EAAE,QAAQ,CAAC,EAAG,QAAO;AACtC,SAAO,IAAI,KAAK,EAAE,QAAQ,IAAI,EAAE,kBAAkB,IAAI,GAAK,EAAE,YAAY,EAAE,MAAM,GAAG,EAAE;AACxF;AAaO,MAAM,qBAAqB;AAG3B,SAAS,WAAW,MAAc,QAAQ,oBAA4B;AAC3E,QAAM,QAAQ,KAAK,KAAK,EAAE,MAAM,KAAK,EAAE,OAAO,OAAO;AACrD,MAAI,MAAM,UAAU,MAAO,QAAO,MAAM,KAAK,GAAG;AAChD,SAAO,GAAG,MAA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gBAAgB,KAAK;AACpE;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -37,9 +37,8 @@ const fromDocRefs = (refs) => (refs ?? []).flatMap((r) => {
|
|
|
37
37
|
return ref ? [ref] : [];
|
|
38
38
|
});
|
|
39
39
|
function toPlanSigner(s) {
|
|
40
|
-
const flag = s.requireIdentityVerification ? { require_identity_verification: true } : {};
|
|
41
40
|
const who = "email" in s ? { email: s.email } : toPlanAssignee(s);
|
|
42
|
-
return { ...who,
|
|
41
|
+
return { ...who, require_identity_verification: !!s.requireIdentityVerification };
|
|
43
42
|
}
|
|
44
43
|
function fromPlanSigner(s) {
|
|
45
44
|
const raw = s;
|
|
@@ -57,6 +56,8 @@ function toPlanAction(a) {
|
|
|
57
56
|
// refuses it, and the builder says so before saving (`stepConfigProblems`).
|
|
58
57
|
document: a.document ? toPlanDocumentRef(a.document) : "",
|
|
59
58
|
signers: a.signers.map(toPlanSigner),
|
|
59
|
+
// The builder asks for verification per signer; the step-wide flag (every signer) stays off.
|
|
60
|
+
require_identity_verification: false,
|
|
60
61
|
...a.message?.trim() ? { message: a.message.trim() } : {},
|
|
61
62
|
...a.expiresAfterHours ? { expires_after_hours: a.expiresAfterHours } : {}
|
|
62
63
|
};
|
|
@@ -110,9 +111,11 @@ function fromPlanAction(a) {
|
|
|
110
111
|
return {
|
|
111
112
|
type: "sign",
|
|
112
113
|
document: fromPlanDocumentRef(a.document),
|
|
114
|
+
// A step-wide flag (every signer verifies) is shown on each signer, where the builder keeps it.
|
|
113
115
|
signers: (a.signers ?? []).flatMap((s) => {
|
|
114
116
|
const one = fromPlanSigner(s);
|
|
115
|
-
|
|
117
|
+
if (!one) return [];
|
|
118
|
+
return a.require_identity_verification ? [{ ...one, requireIdentityVerification: true }] : [one];
|
|
116
119
|
}),
|
|
117
120
|
...a.message ? { message: a.message } : {},
|
|
118
121
|
...a.expires_after_hours ? { expiresAfterHours: a.expires_after_hours } : {}
|