@jsb188/mday 1.1.10 → 1.1.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +105 -54
- package/src/constants/agentDoc.ts +12 -0
- package/src/constants/agentMemory.ts +154 -0
- package/src/constants/aiChat.ts +5 -0
- package/src/constants/campaign.ts +127 -0
- package/src/constants/dataTable.ts +35 -9
- package/src/constants/dataTableFieldTypes.generated.ts +63 -0
- package/src/constants/docAccess.ts +32 -0
- package/src/constants/email.ts +20 -4
- package/src/constants/fieldDoc.ts +34 -0
- package/src/constants/graphqlReactivity.ts +113 -0
- package/src/constants/integration.ts +8 -9
- package/src/constants/log.ts +7 -410
- package/src/constants/logActivityGroupColors.generated.ts +19 -0
- package/src/constants/logTaxonomy.generated.ts +1103 -0
- package/src/constants/noteDoc.ts +77 -0
- package/src/constants/organization.ts +13 -15
- package/src/constants/pageRoute.ts +23 -0
- package/src/constants/schedule.ts +220 -0
- package/src/constants/scheduleRuleTemplateSeed.ts +138 -0
- package/src/constants/scheduleRuleTemplates.generated.ts +145 -0
- package/src/constants/sheet.ts +154 -6
- package/src/constants/sheetRegionSources.generated.ts +578 -0
- package/src/constants/square.ts +6 -6
- package/src/constants/storage.ts +56 -7
- package/src/constants/usage.ts +79 -0
- package/src/schemas/editLogEntry.ts +1010 -777
- package/src/schemas/fieldDocsQuery.ts +12 -0
- package/src/schemas/inboundContact.ts +60 -55
- package/src/schemas/logsQuery.ts +55 -49
- package/src/schemas/organization.ts +49 -46
- package/src/types/account.d.ts +4 -1
- package/src/types/agentDoc.d.ts +64 -0
- package/src/types/agentMemory.d.ts +74 -0
- package/src/types/campaign.d.ts +683 -0
- package/src/types/dataTable.d.ts +175 -256
- package/src/types/docAccess.d.ts +96 -0
- package/src/types/email.d.ts +83 -12
- package/src/types/fieldDoc.d.ts +273 -0
- package/src/types/inboundContact.d.ts +2 -1
- package/src/types/log.d.ts +209 -341
- package/src/types/noteDoc.d.ts +86 -0
- package/src/types/organization.d.ts +83 -40
- package/src/types/pageRoute.d.ts +48 -0
- package/src/types/schedule.d.ts +391 -0
- package/src/types/sheet.d.ts +862 -30
- package/src/types/storage.d.ts +206 -125
- package/src/types/usage.d.ts +106 -0
- package/src/types/workflow.d.ts +149 -18
- package/src/utils/agentDoc.ts +109 -0
- package/src/utils/aiChat.ts +26 -0
- package/src/utils/campaign.ts +741 -0
- package/src/utils/campaignFormEditor.ts +871 -0
- package/src/utils/dataTable.ts +425 -410
- package/src/utils/dataTableFieldTypeRegistry.ts +105 -0
- package/src/utils/dataTableRealtimeAuthority.ts +209 -0
- package/src/utils/dataTableRealtimeSelection.ts +134 -0
- package/src/utils/dataTableRowDocument.ts +508 -0
- package/src/utils/dataTableSource.ts +230 -0
- package/src/utils/docAccess.ts +383 -0
- package/src/utils/documentName.ts +53 -0
- package/src/utils/email.ts +112 -53
- package/src/utils/fieldDoc.ts +113 -0
- package/src/utils/log.ts +169 -176
- package/src/utils/logRegistryValue.ts +90 -0
- package/src/utils/logStoreRead.ts +266 -0
- package/src/utils/logTaxonomy.ts +76 -0
- package/src/utils/logTaxonomyDisplay.ts +439 -0
- package/src/utils/noteDoc.ts +827 -0
- package/src/utils/organization.ts +510 -91
- package/src/utils/pageRoute.ts +71 -0
- package/src/utils/schedule.ts +799 -0
- package/src/utils/scheduleEvaluation.ts +1994 -0
- package/src/utils/scheduleICS.ts +246 -0
- package/src/utils/scheduleRuleTemplates.ts +188 -0
- package/src/utils/sheet.ts +4842 -39
- package/src/utils/sheetAxisMove.ts +830 -0
- package/src/utils/sheetBootstrap.ts +1769 -0
- package/src/utils/sheetCommand.ts +423 -0
- package/src/utils/sheetExport.ts +238 -0
- package/src/utils/sheetFormulaEvaluation.ts +914 -0
- package/src/utils/sheetFormulaEvaluator.ts +852 -0
- package/src/utils/sheetJournal.ts +78 -0
- package/src/utils/sheetNumberFormat.ts +1211 -0
- package/src/utils/sheetRegion.ts +374 -0
- package/src/utils/sheetRegionFilter.ts +1259 -0
- package/src/utils/sheetRegionSourceRegistry.ts +594 -0
- package/src/utils/sheetSequence.ts +148 -0
- package/src/utils/sheetSnapshot.ts +992 -0
- package/src/utils/sheetStructureEdit.ts +1284 -0
- package/src/utils/square.ts +22 -12
- package/src/utils/storage.ts +152 -0
- package/src/utils/table-route.ts +127 -11
- package/src/utils/workflow.ts +191 -23
- package/tests/dataTableFieldTypeRegistry.test.ts +110 -0
- package/tests/docAccess.test.ts +525 -0
- package/tests/editLogEntry.test.ts +112 -0
- package/tests/noteDoc.test.ts +669 -0
- package/tests/schedule.test.ts +693 -0
- package/tests/scheduleEvaluation.test.ts +1970 -0
- package/tests/scheduleICS.test.ts +208 -0
- package/tests/scheduleRuleTemplates.test.ts +176 -0
- package/tests/scheduleSweepInvariants.test.ts +428 -0
- package/tests/sheetAxisMove.test.ts +343 -0
- package/tests/sheetFormulaEvaluator.test.ts +575 -0
- package/tests/sheetRegionFilter.test.ts +1135 -0
- package/tests/sheetSequence.test.ts +41 -0
- package/tests/sheetStructureEdit.test.ts +82 -0
- package/tsconfig.json +10 -10
- package/vitest.config.ts +8 -0
- package/src/constants/log-activityTexts.ts +0 -235
- package/src/constants/product.ts +0 -42
- package/src/constants/report.ts +0 -44
- package/src/schemas/productsQuery.ts +0 -53
- package/src/schemas/reportsQuery.ts +0 -20
- package/src/types/product.d.ts +0 -84
- package/src/types/report.d.ts +0 -290
- package/src/utils/product-calEvent.ts +0 -455
- package/src/utils/report.ts +0 -158
package/src/types/workflow.d.ts
CHANGED
|
@@ -1,15 +1,40 @@
|
|
|
1
1
|
import type { LabelAndValue } from '@jsb188/app/types/other.d.ts';
|
|
2
2
|
import type { BuildSingleTextLine } from '@jsb188/app/utils/string.ts';
|
|
3
|
-
import type {
|
|
4
|
-
import type { OrganizationData
|
|
5
|
-
import type {
|
|
3
|
+
import type { DataTableData, DataTableGQL } from '../types/dataTable.d.ts';
|
|
4
|
+
import type { OrganizationData } from '../types/organization.d.ts';
|
|
5
|
+
import type {
|
|
6
|
+
WORKFLOW_KIND_ENUMS,
|
|
7
|
+
WORKFLOW_LIFECYCLE_STATUS_ENUMS,
|
|
8
|
+
WORKFLOW_RUN_STATUS_ENUMS,
|
|
9
|
+
WORKFLOW_TRIGGER_TYPE_ENUMS,
|
|
10
|
+
WORKFLOW_WAIT_CHANNEL_ENUMS,
|
|
11
|
+
} from '@jsb188/app/constants/agent.ts';
|
|
6
12
|
|
|
7
13
|
/**
|
|
8
14
|
* Enums
|
|
9
15
|
*/
|
|
10
16
|
|
|
11
17
|
export type WorkflowStatusEnum = (typeof WORKFLOW_RUN_STATUS_ENUMS)[number];
|
|
18
|
+
export type WorkflowLifecycleStatusEnum =
|
|
19
|
+
(typeof WORKFLOW_LIFECYCLE_STATUS_ENUMS)[number];
|
|
20
|
+
export type WorkflowKindEnum = (typeof WORKFLOW_KIND_ENUMS)[number];
|
|
21
|
+
export type WorkflowTriggerTypeEnum =
|
|
22
|
+
(typeof WORKFLOW_TRIGGER_TYPE_ENUMS)[number];
|
|
23
|
+
export type WorkflowWaitChannelEnum =
|
|
24
|
+
(typeof WORKFLOW_WAIT_CHANNEL_ENUMS)[number];
|
|
12
25
|
|
|
26
|
+
/**
|
|
27
|
+
* Workflow/reminder recipient; accountId for system users,
|
|
28
|
+
* raw phone/email only for external one-time reminders
|
|
29
|
+
*/
|
|
30
|
+
|
|
31
|
+
export interface WorkflowRecipient {
|
|
32
|
+
accountId?: number | bigint | string | null;
|
|
33
|
+
name?: string | null; // Display name; attached from account profiles, never stored
|
|
34
|
+
phone?: string | null;
|
|
35
|
+
email?: string | null;
|
|
36
|
+
channels: WorkflowWaitChannelEnum[];
|
|
37
|
+
}
|
|
13
38
|
/**
|
|
14
39
|
* Workflow prompt instructions
|
|
15
40
|
*/
|
|
@@ -42,10 +67,17 @@ export interface WorkflowData {
|
|
|
42
67
|
id: number | bigint;
|
|
43
68
|
organizationId: number | bigint;
|
|
44
69
|
org?: OrganizationData; // Included if query joined with organization table
|
|
45
|
-
|
|
70
|
+
fieldDocId: number | bigint | null;
|
|
71
|
+
dataTables?: Array<
|
|
72
|
+
Pick<DataTableData, 'id' | 'name' | 'title' | 'description' | 'deletedAt'>
|
|
73
|
+
>;
|
|
46
74
|
|
|
47
|
-
|
|
48
|
-
|
|
75
|
+
kind: WorkflowKindEnum;
|
|
76
|
+
triggerType: WorkflowTriggerTypeEnum;
|
|
77
|
+
logTypes: string[] | null; // Registry group keys; any matching key triggers the workflow
|
|
78
|
+
|
|
79
|
+
accountId: number | bigint | null; // Creator; set for reminders
|
|
80
|
+
recipients: WorkflowRecipient[] | null;
|
|
49
81
|
|
|
50
82
|
title: string;
|
|
51
83
|
instructions?: null | WorkflowPrompts;
|
|
@@ -55,11 +87,11 @@ export interface WorkflowData {
|
|
|
55
87
|
active: boolean;
|
|
56
88
|
values: Partial<{
|
|
57
89
|
model: 'advanced' | 'standard' | 'basic' | 'lesser' | 'smallest';
|
|
58
|
-
effort: '
|
|
90
|
+
effort: 'none' | 'low' | 'medium' | 'high';
|
|
59
91
|
verbosity: 'low' | 'medium' | 'high';
|
|
60
92
|
steps: WorkflowStep[];
|
|
61
93
|
requireDataTables?: boolean;
|
|
62
|
-
|
|
94
|
+
deliveryMode: 'SIMPLE' | 'AGENTIC'; // Reminders only; SIMPLE sends without an agentic run
|
|
63
95
|
config: Record<string, string | number | boolean | null> & {
|
|
64
96
|
endTime: string; // HHMM format
|
|
65
97
|
};
|
|
@@ -69,6 +101,47 @@ export interface WorkflowData {
|
|
|
69
101
|
nextAt: Date | null;
|
|
70
102
|
createdAt: Date;
|
|
71
103
|
updatedAt: Date;
|
|
104
|
+
|
|
105
|
+
latestRun?: WorkflowRunData | null; // Attached from workflow_runs by list/emit helpers, never stored
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Workflow template data object (visibility defaults for org workflows)
|
|
110
|
+
*/
|
|
111
|
+
|
|
112
|
+
export interface WorkflowTemplateData {
|
|
113
|
+
__table: 'workflow_templates';
|
|
114
|
+
|
|
115
|
+
id: number | bigint;
|
|
116
|
+
fieldDocId: number | bigint | null;
|
|
117
|
+
visibleForLogTypes: string[] | null; // Registry group keys; NULL = retired, offered to no one
|
|
118
|
+
title: string;
|
|
119
|
+
instructions?: null | WorkflowPrompts;
|
|
120
|
+
schedule: string | null;
|
|
121
|
+
scheduleInterval: number;
|
|
122
|
+
active: boolean;
|
|
123
|
+
defaults: WorkflowData['values'] | null;
|
|
124
|
+
createdAt: Date;
|
|
125
|
+
updatedAt: Date;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* Workflow run wait data object; a paused run waiting for a person's reply
|
|
130
|
+
*/
|
|
131
|
+
|
|
132
|
+
export interface WorkflowRunWaitData {
|
|
133
|
+
__table: 'workflow_run_waits';
|
|
134
|
+
|
|
135
|
+
id: number | bigint;
|
|
136
|
+
workflowRunId: number | bigint;
|
|
137
|
+
channel: WorkflowWaitChannelEnum;
|
|
138
|
+
address: string; // Normalized international phone or lowercased email
|
|
139
|
+
accountId: number | bigint | null;
|
|
140
|
+
question: string | null;
|
|
141
|
+
expiresAt: Date | null;
|
|
142
|
+
resolvedAt: Date | null;
|
|
143
|
+
replyText: string | null;
|
|
144
|
+
createdAt: Date;
|
|
72
145
|
}
|
|
73
146
|
|
|
74
147
|
/**
|
|
@@ -81,19 +154,21 @@ export interface WorkflowRunData {
|
|
|
81
154
|
id: number | bigint;
|
|
82
155
|
workflowId: number | bigint;
|
|
83
156
|
logId: number | bigint | null;
|
|
84
|
-
|
|
157
|
+
fieldDocSubmissionId?: number | bigint | null;
|
|
85
158
|
runKey: string;
|
|
86
159
|
iterations: number;
|
|
87
|
-
values:
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
}>;
|
|
160
|
+
values: null | Partial<{
|
|
161
|
+
progressReport: string;
|
|
162
|
+
eventInput: string;
|
|
163
|
+
}>;
|
|
92
164
|
message: string | null;
|
|
93
165
|
status: WorkflowStatusEnum;
|
|
94
166
|
scheduledDate: Date | null;
|
|
95
167
|
followUpAt: Date | null;
|
|
96
168
|
activityAt: Date;
|
|
169
|
+
claimToken?: string | null; // atomic consumer-claim token; see claimWorkflowRun()
|
|
170
|
+
claimedAt?: Date | null; // atomic consumer-claim token; see claimWorkflowRun()
|
|
171
|
+
activeWait?: WorkflowRunWaitData | null; // Attached from workflow_run_waits, never stored
|
|
97
172
|
}
|
|
98
173
|
|
|
99
174
|
/**
|
|
@@ -120,7 +195,7 @@ export interface WorkflowDataTableRecordWriteData {
|
|
|
120
195
|
workflowId: number | bigint;
|
|
121
196
|
workflowRunId?: number | bigint | null;
|
|
122
197
|
logId?: number | bigint | null;
|
|
123
|
-
|
|
198
|
+
fieldDocSubmissionId?: number | bigint | null;
|
|
124
199
|
dataTableId: number | bigint;
|
|
125
200
|
dataTableRowId?: number | bigint | null;
|
|
126
201
|
status: 'CREATED' | 'UPDATED' | 'SKIPPED' | 'FAILED';
|
|
@@ -130,6 +205,34 @@ export interface WorkflowDataTableRecordWriteData {
|
|
|
130
205
|
updatedAt: Date;
|
|
131
206
|
}
|
|
132
207
|
|
|
208
|
+
/**
|
|
209
|
+
* Workflow run wait GraphQL data
|
|
210
|
+
*/
|
|
211
|
+
|
|
212
|
+
export interface WorkflowRunWaitGQL {
|
|
213
|
+
id: string;
|
|
214
|
+
workflowRunId: string;
|
|
215
|
+
name: string | null;
|
|
216
|
+
phone: string | null;
|
|
217
|
+
email: string | null;
|
|
218
|
+
channel: WorkflowWaitChannelEnum;
|
|
219
|
+
expiresAt: string | null;
|
|
220
|
+
resolvedAt: string | null;
|
|
221
|
+
createdAt: string;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
/**
|
|
225
|
+
* Workflow recipient GraphQL data
|
|
226
|
+
*/
|
|
227
|
+
|
|
228
|
+
export interface WorkflowRecipientGQL {
|
|
229
|
+
accountId: string | null;
|
|
230
|
+
name: string | null;
|
|
231
|
+
phone: string | null;
|
|
232
|
+
email: string | null;
|
|
233
|
+
channels: WorkflowWaitChannelEnum[];
|
|
234
|
+
}
|
|
235
|
+
|
|
133
236
|
export interface WorkflowRunGQL {
|
|
134
237
|
__deleted?: boolean;
|
|
135
238
|
|
|
@@ -144,6 +247,24 @@ export interface WorkflowRunGQL {
|
|
|
144
247
|
scheduledDate: string | null;
|
|
145
248
|
followUpAt: string | null;
|
|
146
249
|
activityAt: string;
|
|
250
|
+
activeWait?: WorkflowRunWaitGQL | null;
|
|
251
|
+
workflow?: Pick<WorkflowGQL, 'id' | 'kind' | 'title'> | null;
|
|
252
|
+
cursor?: string;
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
/**
|
|
256
|
+
* Workflow list query filters (GraphQL input shapes)
|
|
257
|
+
*/
|
|
258
|
+
|
|
259
|
+
export interface WorkflowsFilterGQL {
|
|
260
|
+
kind?: WorkflowKindEnum | null;
|
|
261
|
+
startDate?: number | string | null;
|
|
262
|
+
endDate?: number | string | null;
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
export interface WorkflowRunsFilterGQL extends WorkflowsFilterGQL {
|
|
266
|
+
workflowId?: string | null;
|
|
267
|
+
statuses?: WorkflowStatusEnum[] | null;
|
|
147
268
|
}
|
|
148
269
|
|
|
149
270
|
/**
|
|
@@ -155,10 +276,19 @@ export interface WorkflowGQL {
|
|
|
155
276
|
|
|
156
277
|
id: string;
|
|
157
278
|
organizationId: string;
|
|
158
|
-
|
|
279
|
+
fieldDocId: string | null;
|
|
280
|
+
dataTables?: Array<
|
|
281
|
+
Pick<DataTableGQL, 'id' | 'name' | 'title' | 'description' | 'deletedAt'>
|
|
282
|
+
>;
|
|
283
|
+
|
|
284
|
+
kind: WorkflowKindEnum;
|
|
285
|
+
triggerType: WorkflowTriggerTypeEnum;
|
|
286
|
+
logTypes: string[] | null;
|
|
159
287
|
|
|
160
|
-
|
|
161
|
-
|
|
288
|
+
accountId: string | null;
|
|
289
|
+
recipients: WorkflowRecipientGQL[] | null;
|
|
290
|
+
latestRun?: WorkflowRunGQL | null;
|
|
291
|
+
cursor?: string;
|
|
162
292
|
|
|
163
293
|
title: string;
|
|
164
294
|
steps: LabelAndValue[];
|
|
@@ -166,6 +296,7 @@ export interface WorkflowGQL {
|
|
|
166
296
|
schedule: string | null;
|
|
167
297
|
scheduleInterval: number;
|
|
168
298
|
active: boolean;
|
|
299
|
+
status?: WorkflowLifecycleStatusEnum | null; // Derived on the server; never stored
|
|
169
300
|
|
|
170
301
|
startedAt: string | null;
|
|
171
302
|
nextAt: string | null;
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { AGENT_DOC_SURFACE_ENUMS } from '../constants/agentDoc.ts';
|
|
2
|
+
import type {
|
|
3
|
+
AgentDocSettingsObj,
|
|
4
|
+
AgentDocSurfaceEnum,
|
|
5
|
+
} from '../types/agentDoc.d.ts';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Check whether one value is a valid agent doc surface.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
export function isValidAgentDocSurface(
|
|
12
|
+
value: unknown,
|
|
13
|
+
): value is AgentDocSurfaceEnum {
|
|
14
|
+
return AGENT_DOC_SURFACE_ENUMS.includes(value as AgentDocSurfaceEnum);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Sanitize one agent doc settings object into the closed vocabulary stored
|
|
19
|
+
* in the agent_docs "settings" JSONB. Unknown keys are dropped, booleans are
|
|
20
|
+
* coerced strictly (only literal true is kept, so absent and false collapse
|
|
21
|
+
* to the same default), surfaces are validated and deduplicated, and
|
|
22
|
+
* "reviewBy" must be a parseable date string.
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
export function sanitizeAgentDocSettings(
|
|
26
|
+
settings?: Partial<AgentDocSettingsObj> | null,
|
|
27
|
+
): AgentDocSettingsObj {
|
|
28
|
+
const sanitized: AgentDocSettingsObj = {};
|
|
29
|
+
|
|
30
|
+
if (settings?.aiCannotEdit === true) {
|
|
31
|
+
sanitized.aiCannotEdit = true;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
if (settings?.aiCannotRead === true) {
|
|
35
|
+
sanitized.aiCannotRead = true;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
if (settings?.pinned === true) {
|
|
39
|
+
sanitized.pinned = true;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
if (Array.isArray(settings?.hiddenSurfaces)) {
|
|
43
|
+
const surfaces = [
|
|
44
|
+
...new Set(settings.hiddenSurfaces.filter(isValidAgentDocSurface)),
|
|
45
|
+
];
|
|
46
|
+
if (surfaces.length) {
|
|
47
|
+
sanitized.hiddenSurfaces = surfaces;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
if (
|
|
52
|
+
typeof settings?.reviewBy === 'string' &&
|
|
53
|
+
settings.reviewBy &&
|
|
54
|
+
!isNaN(Date.parse(settings.reviewBy))
|
|
55
|
+
) {
|
|
56
|
+
sanitized.reviewBy = settings.reviewBy;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
return sanitized;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Check whether agents on one surface may read one agent doc.
|
|
64
|
+
*/
|
|
65
|
+
|
|
66
|
+
export function isAgentDocReadableBySurface(
|
|
67
|
+
settings: AgentDocSettingsObj | null | undefined,
|
|
68
|
+
surface: AgentDocSurfaceEnum,
|
|
69
|
+
): boolean {
|
|
70
|
+
if (settings?.aiCannotRead) {
|
|
71
|
+
return false;
|
|
72
|
+
}
|
|
73
|
+
return !settings?.hiddenSurfaces?.includes(surface);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Check whether agents on one surface may modify one agent doc. An
|
|
78
|
+
* unreadable document is never writable.
|
|
79
|
+
*/
|
|
80
|
+
|
|
81
|
+
export function isAgentDocWritableByAgent(
|
|
82
|
+
settings: AgentDocSettingsObj | null | undefined,
|
|
83
|
+
surface: AgentDocSurfaceEnum,
|
|
84
|
+
): boolean {
|
|
85
|
+
if (settings?.aiCannotEdit) {
|
|
86
|
+
return false;
|
|
87
|
+
}
|
|
88
|
+
return isAgentDocReadableBySurface(settings, surface);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Check whether one agent doc is past its review date. Stale documents stay
|
|
93
|
+
* readable; agent tools annotate them so the model verifies with a human
|
|
94
|
+
* instead of silently trusting outdated rules.
|
|
95
|
+
*/
|
|
96
|
+
|
|
97
|
+
export function isAgentDocStale(
|
|
98
|
+
settings: AgentDocSettingsObj | null | undefined,
|
|
99
|
+
now: Date | number = Date.now(),
|
|
100
|
+
): boolean {
|
|
101
|
+
if (!settings?.reviewBy) {
|
|
102
|
+
return false;
|
|
103
|
+
}
|
|
104
|
+
const reviewBy = Date.parse(settings.reviewBy);
|
|
105
|
+
return (
|
|
106
|
+
!isNaN(reviewBy) &&
|
|
107
|
+
reviewBy < (typeof now === 'number' ? now : now.getTime())
|
|
108
|
+
);
|
|
109
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Return whether an incoming automatic chat fragment predates the current
|
|
3
|
+
* user-managed summary. User-managed summaries are terminal, so a fragment
|
|
4
|
+
* reporting the automatic state can never be newer once this flag is true.
|
|
5
|
+
*/
|
|
6
|
+
export function isStaleAutomaticAIChatFragment(
|
|
7
|
+
currentData: unknown,
|
|
8
|
+
nextData: unknown,
|
|
9
|
+
) {
|
|
10
|
+
if (
|
|
11
|
+
!currentData ||
|
|
12
|
+
typeof currentData !== 'object' ||
|
|
13
|
+
!nextData ||
|
|
14
|
+
typeof nextData !== 'object'
|
|
15
|
+
) {
|
|
16
|
+
return false;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const currentAIChat = currentData as Record<string, unknown>;
|
|
20
|
+
const nextAIChat = nextData as Record<string, unknown>;
|
|
21
|
+
|
|
22
|
+
return (
|
|
23
|
+
currentAIChat.userManagedSummary === true &&
|
|
24
|
+
nextAIChat.userManagedSummary === false
|
|
25
|
+
);
|
|
26
|
+
}
|