@anthusai/papyrus 5.130.0-next.1 → 5.130.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/amplify/agents/admin-policy-grant.feature +20 -0
- package/amplify/agents/admin-policy-grant.js +31 -0
- package/amplify/agents/admin-policy-grant.ts +35 -0
- package/amplify/agents/pieces.js +11 -0
- package/amplify/agents/pieces.ts +13 -0
- package/amplify/agents/schedule-group.js +75 -0
- package/amplify/agents/schedule-group.ts +82 -0
- package/amplify/agents/stack.js +27 -0
- package/amplify/agents/stack.ts +53 -0
- package/amplify/agents/wake-queue.js +121 -0
- package/amplify/agents/wake-queue.ts +138 -0
- package/amplify/data/resource.js +25 -0
- package/amplify/data/resource.ts +25 -0
- package/amplify/data/schema.js +27 -1
- package/amplify/data/schema.ts +27 -1
- package/amplify/functions/announcements/schema.js +86 -0
- package/amplify/functions/announcements/schema.ts +86 -0
- package/amplify/functions/assignment-action/handler.ts +4 -0
- package/amplify/functions/automation-view/schema.js +8 -1
- package/amplify/functions/automation-view/schema.ts +8 -1
- package/amplify/functions/automation-view/wire.js +7 -11
- package/amplify/functions/automation-view/wire.ts +7 -14
- package/amplify/functions/localization-dispatch/handler.py +4 -3
- package/amplify/functions/localization-dispatch/wire.js +6 -5
- package/amplify/functions/localization-dispatch/wire.ts +6 -5
- package/amplify/functions/model-attachment-upload/handler.ts +4 -0
- package/amplify/functions/model-attachment-upload/rules.js +2 -0
- package/amplify/functions/model-attachment-upload/rules.ts +2 -0
- package/amplify/functions/procedure-action/handler.ts +44 -27
- package/amplify/functions/procedure-action/wake-key.js +48 -0
- package/amplify/functions/procedure-action/wake-key.ts +49 -0
- package/amplify/site-backend.js +12 -2
- package/amplify/site-backend.ts +16 -2
- package/components/automation-panel.tsx +6 -0
- package/components/automation-view.tsx +6 -4
- package/components/newsroom-ops-overview.tsx +2 -0
- package/components/today-panel.tsx +43 -0
- package/components/today-view.tsx +171 -0
- package/infra/agent-sync.test.js +34 -0
- package/infra/agent-sync.test.ts +35 -0
- package/infra/build-specs.js +21 -0
- package/infra/build-specs.ts +25 -0
- package/infra/ci-gate.test.js +1 -1
- package/infra/ci-gate.test.ts +1 -1
- package/infra/procedure-sync.test.js +48 -0
- package/infra/procedure-sync.test.ts +50 -0
- package/lib/automation-fixture.ts +14 -9
- package/lib/automation-overview.ts +18 -5
- package/lib/guidelines/writing-guidelines-admin.ts +1 -1
- package/lib/images/operations.generated.ts +72 -42
- package/lib/tenant-keys.js +1 -0
- package/lib/tenant-keys.ts +1 -0
- package/lib/today-client.ts +34 -0
- package/lib/today-fixture.ts +52 -0
- package/lib/today-overview.ts +111 -0
- package/package.json +6 -1
- package/routes.manifest.json +1 -1
|
@@ -41,6 +41,7 @@ export type ImageOperationName =
|
|
|
41
41
|
| "announcements_settings_show"
|
|
42
42
|
| "announcements_settings_set"
|
|
43
43
|
| "announcements_account_status"
|
|
44
|
+
| "ratings_set"
|
|
44
45
|
;
|
|
45
46
|
|
|
46
47
|
export type ImageErrorCode =
|
|
@@ -49,6 +50,7 @@ export type ImageErrorCode =
|
|
|
49
50
|
| "not_implemented"
|
|
50
51
|
| "not_authorized"
|
|
51
52
|
| "human_required"
|
|
53
|
+
| "blocked"
|
|
52
54
|
| "set_needs_person"
|
|
53
55
|
| "not_found"
|
|
54
56
|
| "constraint_conflict"
|
|
@@ -839,6 +841,8 @@ export type GuidelinesGetResult = {
|
|
|
839
841
|
language?: string;
|
|
840
842
|
/** A guideline document of that kind: schemaVersion and the fields the kind allows. */
|
|
841
843
|
document: Record<string, unknown>;
|
|
844
|
+
/** Guideline files by path, such as plain-claims/GUIDELINE.md: the exact text of each file of the set. Writing guidelines are stored as this set. */
|
|
845
|
+
files?: Record<string, unknown>;
|
|
842
846
|
itemId: string;
|
|
843
847
|
versionNumber: number;
|
|
844
848
|
contentHash: string;
|
|
@@ -893,7 +897,9 @@ export type GuidelinesDiffInput = {
|
|
|
893
897
|
/** A language overlay (en, es, es-419, zh-Hans ...): only what is particular to that language, laid over the guidelines every language shares. Leave it out for the shared guidelines. */
|
|
894
898
|
language?: string;
|
|
895
899
|
/** A guideline document of that kind: schemaVersion and the fields the kind allows. */
|
|
896
|
-
document
|
|
900
|
+
document?: Record<string, unknown>;
|
|
901
|
+
/** Guideline files by path, such as plain-claims/GUIDELINE.md: the exact text of each file of the set. Writing guidelines are stored as this set. */
|
|
902
|
+
files?: Record<string, unknown>;
|
|
897
903
|
};
|
|
898
904
|
|
|
899
905
|
export type GuidelinesDiffResult = {
|
|
@@ -907,6 +913,10 @@ export type GuidelinesDiffResult = {
|
|
|
907
913
|
}[];
|
|
908
914
|
constraintChanges: Record<string, unknown>[];
|
|
909
915
|
wouldCreateVersion: number;
|
|
916
|
+
fileChanges?: ({
|
|
917
|
+
path: string;
|
|
918
|
+
change: "added" | "changed" | "removed";
|
|
919
|
+
})[];
|
|
910
920
|
};
|
|
911
921
|
|
|
912
922
|
/** Save a guideline document as the next version of its kind and scope. */
|
|
@@ -918,7 +928,9 @@ export type GuidelinesSaveInput = {
|
|
|
918
928
|
/** A language overlay (en, es, es-419, zh-Hans ...): only what is particular to that language, laid over the guidelines every language shares. Leave it out for the shared guidelines. */
|
|
919
929
|
language?: string;
|
|
920
930
|
/** A guideline document of that kind: schemaVersion and the fields the kind allows. */
|
|
921
|
-
document
|
|
931
|
+
document?: Record<string, unknown>;
|
|
932
|
+
/** Guideline files by path, such as plain-claims/GUIDELINE.md: the exact text of each file of the set. Writing guidelines are stored as this set. */
|
|
933
|
+
files?: Record<string, unknown>;
|
|
922
934
|
/** Why, in plain words. It is recorded with who and when. */
|
|
923
935
|
reason: string;
|
|
924
936
|
/** The current version id of that guideline lineage when you read it (guidelines_get returns it as expectedCurrentVersionId), or none for the first save. */
|
|
@@ -1164,6 +1176,22 @@ export type AnnouncementsAccountStatusResult = {
|
|
|
1164
1176
|
pricesAsOf?: string;
|
|
1165
1177
|
};
|
|
1166
1178
|
|
|
1179
|
+
/** Give a Story a star rating, 1 to 5. An agent may give only three or four stars, and only to a Story nobody has rated. */
|
|
1180
|
+
export type RatingsSetInput = {
|
|
1181
|
+
/** The lineage id of the Story. */
|
|
1182
|
+
story: string;
|
|
1183
|
+
/** The rating, 1 to 5. An agent may only give 3 or 4. */
|
|
1184
|
+
stars: number;
|
|
1185
|
+
};
|
|
1186
|
+
|
|
1187
|
+
export type RatingsSetResult = {
|
|
1188
|
+
lineageId: string;
|
|
1189
|
+
/** The rating before this one: 0 when the Story had none. */
|
|
1190
|
+
previous?: number;
|
|
1191
|
+
stars: number;
|
|
1192
|
+
ratedBy?: string;
|
|
1193
|
+
};
|
|
1194
|
+
|
|
1167
1195
|
export interface ImageOperations {
|
|
1168
1196
|
image_profile_get: { input: ImageProfileGetInput; result: ImageProfileGetResult };
|
|
1169
1197
|
image_profile_resolve: { input: ImageProfileResolveInput; result: ImageProfileResolveResult };
|
|
@@ -1203,56 +1231,58 @@ export interface ImageOperations {
|
|
|
1203
1231
|
announcements_settings_show: { input: AnnouncementsSettingsShowInput; result: AnnouncementsSettingsShowResult };
|
|
1204
1232
|
announcements_settings_set: { input: AnnouncementsSettingsSetInput; result: AnnouncementsSettingsSetResult };
|
|
1205
1233
|
announcements_account_status: { input: AnnouncementsAccountStatusInput; result: AnnouncementsAccountStatusResult };
|
|
1234
|
+
ratings_set: { input: RatingsSetInput; result: RatingsSetResult };
|
|
1206
1235
|
}
|
|
1207
1236
|
|
|
1208
1237
|
/** What each operation is, for the transport: read operations are queries, write and spend operations are mutations. */
|
|
1209
1238
|
export const IMAGE_OPERATIONS = {
|
|
1210
|
-
image_profile_get: { effect: "read", agentAllowed: true, group: "images", command: "papyrus images profile get" },
|
|
1211
|
-
image_profile_resolve: { effect: "read", agentAllowed: true, group: "images", command: "papyrus images profile resolve" },
|
|
1212
|
-
image_profile_diff: { effect: "read", agentAllowed: true, group: "images", command: "papyrus images profile diff" },
|
|
1213
|
-
image_profile_save: { effect: "write", agentAllowed: true, group: "images", command: "papyrus images profile save" },
|
|
1214
|
-
image_profile_history: { effect: "read", agentAllowed: true, group: "images", command: "papyrus images profile history" },
|
|
1215
|
-
image_profile_init: { effect: "read", agentAllowed: true, group: "images", command: "papyrus images profile init" },
|
|
1216
|
-
image_profile_example_add: { effect: "write", agentAllowed: true, group: "images", command: "papyrus images profile example add" },
|
|
1217
|
-
image_profile_example_remove: { effect: "write", agentAllowed: true, group: "images", command: "papyrus images profile example remove" },
|
|
1218
|
-
image_capabilities: { effect: "read", agentAllowed: true, group: "images", command: "papyrus images capabilities" },
|
|
1219
|
-
image_brief_draft: { effect: "read", agentAllowed: true, group: "images", command: "papyrus images brief" },
|
|
1220
|
-
image_prompt_preview: { effect: "read", agentAllowed: true, group: "images", command: "papyrus images prompt" },
|
|
1221
|
-
image_search: { effect: "read", agentAllowed: true, group: "images", command: "papyrus images search" },
|
|
1222
|
-
image_generate: { effect: "spend", agentAllowed: true, group: "images", command: "papyrus images generate" },
|
|
1223
|
-
image_figure_add: { effect: "write", agentAllowed: true, group: "images", command: "papyrus images figure add" },
|
|
1224
|
-
image_round_get: { effect: "read", agentAllowed: true, group: "images", command: "papyrus images round" },
|
|
1225
|
-
image_candidate_get: { effect: "read", agentAllowed: true, group: "images", command: "papyrus images show" },
|
|
1226
|
-
image_list: { effect: "read", agentAllowed: true, group: "images", command: "papyrus images list" },
|
|
1227
|
-
image_retry: { effect: "spend", agentAllowed: true, group: "images", command: "papyrus images retry" },
|
|
1228
|
-
image_iterate: { effect: "spend", agentAllowed: true, group: "images", command: "papyrus images iterate" },
|
|
1229
|
-
image_select: { effect: "write", agentAllowed: true, group: "images", command: "papyrus images select" },
|
|
1230
|
-
image_unapply: { effect: "write", agentAllowed: true, group: "images", command: "papyrus images unapply" },
|
|
1231
|
-
image_review: { effect: "write", agentAllowed: false, group: "images", command: "papyrus images review" },
|
|
1232
|
-
image_review_queue: { effect: "read", agentAllowed: true, group: "images", command: "papyrus images review-queue" },
|
|
1233
|
-
image_apply: { effect: "write", agentAllowed: true, group: "images", command: "papyrus images apply" },
|
|
1234
|
-
image_discard: { effect: "write", agentAllowed: true, group: "images", command: "papyrus images discard" },
|
|
1235
|
-
guidelines_get: { effect: "read", agentAllowed: true, group: "guidelines", command: "papyrus guidelines show" },
|
|
1236
|
-
guidelines_resolve: { effect: "read", agentAllowed: true, group: "guidelines", command: "papyrus guidelines resolve" },
|
|
1237
|
-
guidelines_diff: { effect: "read", agentAllowed: true, group: "guidelines", command: "papyrus guidelines diff" },
|
|
1238
|
-
guidelines_save: { effect: "write", agentAllowed: true, group: "guidelines", command: "papyrus guidelines save" },
|
|
1239
|
-
guidelines_history: { effect: "read", agentAllowed: true, group: "guidelines", command: "papyrus guidelines history" },
|
|
1240
|
-
announcements_list: { effect: "read", agentAllowed: true, group: "announcements", command: "papyrus announcements list" },
|
|
1241
|
-
announcements_show: { effect: "read", agentAllowed: true, group: "announcements", command: "papyrus announcements show" },
|
|
1242
|
-
announcements_dry_run: { effect: "read", agentAllowed: true, group: "announcements", command: "papyrus announcements dry-run" },
|
|
1243
|
-
announcements_pause: { effect: "write", agentAllowed: true, group: "announcements", command: "papyrus announcements pause" },
|
|
1244
|
-
announcements_resume: { effect: "write", agentAllowed:
|
|
1245
|
-
announcements_settings_show: { effect: "read", agentAllowed: true, group: "announcements", command: "papyrus announcements settings show" },
|
|
1246
|
-
announcements_settings_set: { effect: "write", agentAllowed: false, group: "announcements", command: "papyrus announcements settings set" },
|
|
1247
|
-
announcements_account_status: { effect: "read", agentAllowed: true, group: "announcements", command: "papyrus announcements account status" },
|
|
1239
|
+
image_profile_get: { effect: "read", agentAllowed: true, agentRung: "observe", agentRefusal: "human_required", group: "images", command: "papyrus images profile get" },
|
|
1240
|
+
image_profile_resolve: { effect: "read", agentAllowed: true, agentRung: "observe", agentRefusal: "human_required", group: "images", command: "papyrus images profile resolve" },
|
|
1241
|
+
image_profile_diff: { effect: "read", agentAllowed: true, agentRung: "observe", agentRefusal: "human_required", group: "images", command: "papyrus images profile diff" },
|
|
1242
|
+
image_profile_save: { effect: "write", agentAllowed: true, agentRung: "prepare", agentRefusal: "human_required", group: "images", command: "papyrus images profile save" },
|
|
1243
|
+
image_profile_history: { effect: "read", agentAllowed: true, agentRung: "observe", agentRefusal: "human_required", group: "images", command: "papyrus images profile history" },
|
|
1244
|
+
image_profile_init: { effect: "read", agentAllowed: true, agentRung: "observe", agentRefusal: "human_required", group: "images", command: "papyrus images profile init" },
|
|
1245
|
+
image_profile_example_add: { effect: "write", agentAllowed: true, agentRung: "prepare", agentRefusal: "human_required", group: "images", command: "papyrus images profile example add" },
|
|
1246
|
+
image_profile_example_remove: { effect: "write", agentAllowed: true, agentRung: "prepare", agentRefusal: "human_required", group: "images", command: "papyrus images profile example remove" },
|
|
1247
|
+
image_capabilities: { effect: "read", agentAllowed: true, agentRung: "observe", agentRefusal: "human_required", group: "images", command: "papyrus images capabilities" },
|
|
1248
|
+
image_brief_draft: { effect: "read", agentAllowed: true, agentRung: "observe", agentRefusal: "human_required", group: "images", command: "papyrus images brief" },
|
|
1249
|
+
image_prompt_preview: { effect: "read", agentAllowed: true, agentRung: "observe", agentRefusal: "human_required", group: "images", command: "papyrus images prompt" },
|
|
1250
|
+
image_search: { effect: "read", agentAllowed: true, agentRung: "observe", agentRefusal: "human_required", group: "images", command: "papyrus images search" },
|
|
1251
|
+
image_generate: { effect: "spend", agentAllowed: true, agentRung: "draft", agentRefusal: "human_required", group: "images", command: "papyrus images generate" },
|
|
1252
|
+
image_figure_add: { effect: "write", agentAllowed: true, agentRung: "draft", agentRefusal: "human_required", group: "images", command: "papyrus images figure add" },
|
|
1253
|
+
image_round_get: { effect: "read", agentAllowed: true, agentRung: "observe", agentRefusal: "human_required", group: "images", command: "papyrus images round" },
|
|
1254
|
+
image_candidate_get: { effect: "read", agentAllowed: true, agentRung: "observe", agentRefusal: "human_required", group: "images", command: "papyrus images show" },
|
|
1255
|
+
image_list: { effect: "read", agentAllowed: true, agentRung: "observe", agentRefusal: "human_required", group: "images", command: "papyrus images list" },
|
|
1256
|
+
image_retry: { effect: "spend", agentAllowed: true, agentRung: "draft", agentRefusal: "human_required", group: "images", command: "papyrus images retry" },
|
|
1257
|
+
image_iterate: { effect: "spend", agentAllowed: true, agentRung: "draft", agentRefusal: "human_required", group: "images", command: "papyrus images iterate" },
|
|
1258
|
+
image_select: { effect: "write", agentAllowed: true, agentRung: "draft", agentRefusal: "human_required", group: "images", command: "papyrus images select" },
|
|
1259
|
+
image_unapply: { effect: "write", agentAllowed: true, agentRung: "draft", agentRefusal: "human_required", group: "images", command: "papyrus images unapply" },
|
|
1260
|
+
image_review: { effect: "write", agentAllowed: false, agentRung: "person", agentRefusal: "human_required", group: "images", command: "papyrus images review" },
|
|
1261
|
+
image_review_queue: { effect: "read", agentAllowed: true, agentRung: "observe", agentRefusal: "human_required", group: "images", command: "papyrus images review-queue" },
|
|
1262
|
+
image_apply: { effect: "write", agentAllowed: true, agentRung: "draft", agentRefusal: "human_required", group: "images", command: "papyrus images apply" },
|
|
1263
|
+
image_discard: { effect: "write", agentAllowed: true, agentRung: "draft", agentRefusal: "human_required", group: "images", command: "papyrus images discard" },
|
|
1264
|
+
guidelines_get: { effect: "read", agentAllowed: true, agentRung: "observe", agentRefusal: "human_required", group: "guidelines", command: "papyrus guidelines show" },
|
|
1265
|
+
guidelines_resolve: { effect: "read", agentAllowed: true, agentRung: "observe", agentRefusal: "human_required", group: "guidelines", command: "papyrus guidelines resolve" },
|
|
1266
|
+
guidelines_diff: { effect: "read", agentAllowed: true, agentRung: "observe", agentRefusal: "human_required", group: "guidelines", command: "papyrus guidelines diff" },
|
|
1267
|
+
guidelines_save: { effect: "write", agentAllowed: true, agentRung: "prepare", agentRefusal: "human_required", group: "guidelines", command: "papyrus guidelines save" },
|
|
1268
|
+
guidelines_history: { effect: "read", agentAllowed: true, agentRung: "observe", agentRefusal: "human_required", group: "guidelines", command: "papyrus guidelines history" },
|
|
1269
|
+
announcements_list: { effect: "read", agentAllowed: true, agentRung: "observe", agentRefusal: "human_required", group: "announcements", command: "papyrus announcements list" },
|
|
1270
|
+
announcements_show: { effect: "read", agentAllowed: true, agentRung: "observe", agentRefusal: "human_required", group: "announcements", command: "papyrus announcements show" },
|
|
1271
|
+
announcements_dry_run: { effect: "read", agentAllowed: true, agentRung: "observe", agentRefusal: "human_required", group: "announcements", command: "papyrus announcements dry-run" },
|
|
1272
|
+
announcements_pause: { effect: "write", agentAllowed: true, agentRung: "propose", agentRefusal: "human_required", group: "announcements", command: "papyrus announcements pause" },
|
|
1273
|
+
announcements_resume: { effect: "write", agentAllowed: false, agentRung: "person", agentRefusal: "human_required", group: "announcements", command: "papyrus announcements resume" },
|
|
1274
|
+
announcements_settings_show: { effect: "read", agentAllowed: true, agentRung: "observe", agentRefusal: "human_required", group: "announcements", command: "papyrus announcements settings show" },
|
|
1275
|
+
announcements_settings_set: { effect: "write", agentAllowed: false, agentRung: "person", agentRefusal: "blocked", group: "announcements", command: "papyrus announcements settings set" },
|
|
1276
|
+
announcements_account_status: { effect: "read", agentAllowed: true, agentRung: "observe", agentRefusal: "human_required", group: "announcements", command: "papyrus announcements account status" },
|
|
1277
|
+
ratings_set: { effect: "write", agentAllowed: true, agentRung: "draft", agentRefusal: "human_required", group: "ratings", command: "papyrus ratings set" },
|
|
1248
1278
|
} as const;
|
|
1249
1279
|
|
|
1250
|
-
/** `group` says which door: images go through imageRead and imageWrite, guidelines through guidelinesRead and guidelinesWrite; announcements have no door yet (the console reads and writes their models directly). */
|
|
1280
|
+
/** `group` says which door: images go through imageRead and imageWrite, guidelines through guidelinesRead and guidelinesWrite; announcements and ratings have no door yet (the console reads and writes their models directly). */
|
|
1251
1281
|
export type ImageTransport = (request: {
|
|
1252
1282
|
op: ImageOperationName;
|
|
1253
1283
|
input: unknown;
|
|
1254
1284
|
effect: "read" | "write" | "spend";
|
|
1255
|
-
group: "images" | "guidelines" | "announcements";
|
|
1285
|
+
group: "images" | "guidelines" | "announcements" | "ratings";
|
|
1256
1286
|
}) => Promise<unknown>;
|
|
1257
1287
|
|
|
1258
1288
|
export async function callImageOperation<Name extends ImageOperationName>(
|
package/lib/tenant-keys.js
CHANGED
|
@@ -19,6 +19,7 @@ export const TENANT_FIELD_MODELS = new Set([
|
|
|
19
19
|
"EditorialPolicy", "EditorialCheckSettings", "EditorialFeedback", "EditorialCheckRun", "Proposal", "ReaderProfile",
|
|
20
20
|
"ReaderHandle", "ReaderVote", "ReaderFlag", "ReaderComment", "ReaderSubmission", "ReaderReport", "ModerationAction",
|
|
21
21
|
"SignupEntry", "LocalizationRequest", "EntityLabel",
|
|
22
|
+
"AnnouncementDecision", "Delivery",
|
|
22
23
|
]);
|
|
23
24
|
const TENANT_KEY_SEPARATOR = "#";
|
|
24
25
|
const TENANT_ID_PATTERN = /^[a-z0-9][a-z0-9-]{0,62}$/;
|
package/lib/tenant-keys.ts
CHANGED
|
@@ -23,6 +23,7 @@ export const TENANT_FIELD_MODELS: ReadonlySet<string> = new Set([
|
|
|
23
23
|
"EditorialPolicy", "EditorialCheckSettings", "EditorialFeedback", "EditorialCheckRun", "Proposal", "ReaderProfile",
|
|
24
24
|
"ReaderHandle", "ReaderVote", "ReaderFlag", "ReaderComment", "ReaderSubmission", "ReaderReport", "ModerationAction",
|
|
25
25
|
"SignupEntry", "LocalizationRequest", "EntityLabel",
|
|
26
|
+
"AnnouncementDecision", "Delivery",
|
|
26
27
|
]);
|
|
27
28
|
|
|
28
29
|
const TENANT_KEY_SEPARATOR = "#";
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { generateClient } from "aws-amplify/data";
|
|
4
|
+
import type { TodayResult } from "./today-overview";
|
|
5
|
+
|
|
6
|
+
type GraphQLResult = { data?: { todayOverview?: unknown }; errors?: { message?: string; errorType?: string }[] };
|
|
7
|
+
|
|
8
|
+
/** The viewer's own time zone, so "today" is the viewer's day. Null when the browser does not say. */
|
|
9
|
+
export function viewerTimeZone(): string | null {
|
|
10
|
+
try {
|
|
11
|
+
return Intl.DateTimeFormat().resolvedOptions().timeZone || null;
|
|
12
|
+
} catch {
|
|
13
|
+
return null;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/** Reads Today through the site's own authenticated API (user pool, editor or admin). The function behind the query reads by index. */
|
|
18
|
+
export async function loadTodayOverview(timeZone: string | null = viewerTimeZone()): Promise<TodayResult> {
|
|
19
|
+
const client = generateClient({ authMode: "userPool" });
|
|
20
|
+
let result: GraphQLResult;
|
|
21
|
+
try {
|
|
22
|
+
result = (await client.graphql({
|
|
23
|
+
query: `query TodayOverview($day: String, $timeZone: String) { todayOverview(day: $day, timeZone: $timeZone) }`,
|
|
24
|
+
variables: { day: null, timeZone },
|
|
25
|
+
})) as GraphQLResult;
|
|
26
|
+
} catch (error) {
|
|
27
|
+
result = (error && typeof error === "object" && "errors" in error ? error : { errors: [{ message: "failed" }] }) as GraphQLResult;
|
|
28
|
+
}
|
|
29
|
+
const refused = result.errors?.some((entry) => /unauthorized|not authorized|forbidden/i.test(`${entry.errorType ?? ""} ${entry.message ?? ""}`));
|
|
30
|
+
if (refused) return { error: "forbidden" };
|
|
31
|
+
if (result.errors?.length || result.data?.todayOverview === undefined || result.data.todayOverview === null) return { state: "unavailable" };
|
|
32
|
+
const raw = result.data.todayOverview;
|
|
33
|
+
return (typeof raw === "string" ? JSON.parse(raw) : raw) as TodayResult;
|
|
34
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import type { TodayCounts, TodayOverview, TodayRow, TodayRun } from "./today-overview";
|
|
2
|
+
|
|
3
|
+
const none: TodayCounts = { acted: 0, nothing: 0, asked: 0, failed: 0, unknown: 0, notFinished: 0, beforeOutcomes: 0 };
|
|
4
|
+
|
|
5
|
+
function run(id: string, at: string, fields: Partial<TodayRun>): TodayRun {
|
|
6
|
+
return {
|
|
7
|
+
runId: id, procedureKey: "example.procedure", automationId: null, requestedAt: at, finishedAt: null, runStatus: "completed", outcome: "acted",
|
|
8
|
+
outcomeReason: null, outcomeShown: "✓ Did it", rung: null, subjectKind: null, subjectId: null, costUsd: null, error: null, ...fields,
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
const rate: TodayRow = {
|
|
13
|
+
key: "responsibility:rate", kind: "responsibility", title: "Rate and curate", counts: { ...none, acted: 6, nothing: 1, asked: 1 },
|
|
14
|
+
reasons: { nothing: { not_rated: 1 }, asked: { needs_review: 1 } }, automationIds: ["rate.new-references"], costUsd: 0.02, costKnownRuns: 8, costUnknownRuns: 0,
|
|
15
|
+
runs: [
|
|
16
|
+
...[1, 2, 3, 4].map((n) => run(`run-r0${n}`, `2026-11-16T1${n}:00:00.000Z`, { automationId: "rate.new-references", costUsd: 0.0025 })),
|
|
17
|
+
run("run-r1", "2026-11-16T14:05:00.000Z", { automationId: "rate.new-references", costUsd: 0.0025 }),
|
|
18
|
+
run("run-r2", "2026-11-16T15:10:00.000Z", { automationId: "rate.new-references", outcome: "nothing", outcomeReason: "not_rated", outcomeShown: "– Nothing to do (not_rated)", costUsd: 0 }),
|
|
19
|
+
run("run-r3", "2026-11-16T16:20:00.000Z", { automationId: "rate.new-references", outcome: "asked", outcomeReason: "needs_review", outcomeShown: "? Asked (needs_review)", costUsd: 0.0025 }),
|
|
20
|
+
run("run-r4", "2026-11-16T16:40:00.000Z", { automationId: "rate.new-references", costUsd: 0.0025 }),
|
|
21
|
+
],
|
|
22
|
+
};
|
|
23
|
+
const translate: TodayRow = {
|
|
24
|
+
key: "responsibility:translate", kind: "responsibility", title: "Translate", counts: { ...none, acted: 2, failed: 1, unknown: 1 },
|
|
25
|
+
reasons: { failed: { timed_out: 1 }, unknown: { no_result_recorded: 1 } }, automationIds: [], costUsd: 0.41, costKnownRuns: 3, costUnknownRuns: 1,
|
|
26
|
+
runs: [
|
|
27
|
+
run("run-t1", "2026-11-16T13:00:00.000Z", { costUsd: 0.25 }),
|
|
28
|
+
run("run-t2", "2026-11-16T13:30:00.000Z", { runStatus: "failed", outcome: "failed", outcomeReason: "timed_out", outcomeShown: "✗ Failed (timed_out)", costUsd: 0.16, error: "timed out after 840 s" }),
|
|
29
|
+
run("run-t0", "2026-11-16T12:30:00.000Z", { costUsd: 0 }),
|
|
30
|
+
run("run-t3", "2026-11-16T14:30:00.000Z", { runStatus: "failed", outcome: "unknown", outcomeReason: "no_result_recorded", outcomeShown: "! Outcome unknown (no_result_recorded)" }),
|
|
31
|
+
],
|
|
32
|
+
};
|
|
33
|
+
const announce: TodayRow = {
|
|
34
|
+
key: "responsibility:announce", kind: "responsibility", title: "Announce", counts: { ...none, nothing: 3 },
|
|
35
|
+
reasons: { nothing: { not_rated: 2, under_channel_bar: 1 } }, automationIds: ["announce.releases"], costUsd: 0, costKnownRuns: 3, costUnknownRuns: 0,
|
|
36
|
+
runs: [
|
|
37
|
+
run("run-a1", "2026-11-16T12:00:00.000Z", { automationId: "announce.releases", outcome: "nothing", outcomeReason: "not_rated", outcomeShown: "– Nothing to do (not_rated)", costUsd: 0 }),
|
|
38
|
+
run("run-a2", "2026-11-16T13:00:00.000Z", { automationId: "announce.releases", outcome: "nothing", outcomeReason: "not_rated", outcomeShown: "– Nothing to do (not_rated)", costUsd: 0 }),
|
|
39
|
+
run("run-a3", "2026-11-16T14:00:00.000Z", { automationId: "announce.releases", outcome: "nothing", outcomeReason: "under_channel_bar", outcomeShown: "– Nothing to do (under_channel_bar)", costUsd: 0 }),
|
|
40
|
+
],
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
/** A realistic Today for tests and the `?demo=1` newsroom. */
|
|
44
|
+
export const FIXTURE_TODAY: TodayOverview = {
|
|
45
|
+
state: "ready", asOf: "2026-11-16T17:00:00.000Z", day: "2026-11-16", timeZone: "America/New_York", start: "2026-11-16T05:00:00.000Z", end: "2026-11-17T05:00:00.000Z",
|
|
46
|
+
rows: [announce, rate, translate],
|
|
47
|
+
didNotRun: [
|
|
48
|
+
{ automationId: "digest.weekly", title: "Weekly digest", state: "Did not run", whyCode: "disabled", why: "Disabled: the router starts nothing for a disabled automation" },
|
|
49
|
+
{ automationId: "newsletter.daily", title: "Daily summary", state: "Did not run", whyCode: "no_wake", why: "Nothing woke it today" },
|
|
50
|
+
],
|
|
51
|
+
totals: { runs: 15, counts: { ...none, acted: 8, nothing: 4, asked: 1, failed: 1, unknown: 1 }, costUsd: 0.43, costKnownRuns: 14, costUnknownRuns: 1 },
|
|
52
|
+
};
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
/** Shapes and wording for Today: what ran in one day, what it decided to do nothing about, and what it cost (PPY-5bcf42).
|
|
2
|
+
* src/papyrus_content/today.py produces them; the words match what `papyrus today` prints. */
|
|
3
|
+
import { getNewsroomNavHref } from "./newsroom-nav";
|
|
4
|
+
|
|
5
|
+
export type TodayOutcome = "acted" | "nothing" | "asked" | "failed" | "unknown";
|
|
6
|
+
export type TodayCountKey = TodayOutcome | "notFinished" | "beforeOutcomes";
|
|
7
|
+
export type TodayCounts = Record<TodayCountKey, number>;
|
|
8
|
+
|
|
9
|
+
export type TodayRun = {
|
|
10
|
+
runId: string | null;
|
|
11
|
+
procedureKey: string | null;
|
|
12
|
+
automationId: string | null;
|
|
13
|
+
requestedAt: string | null;
|
|
14
|
+
finishedAt: string | null;
|
|
15
|
+
runStatus: string | null;
|
|
16
|
+
outcome: TodayOutcome | null;
|
|
17
|
+
outcomeReason: string | null;
|
|
18
|
+
/** The outcome in words with its mark, as the command line prints it. */
|
|
19
|
+
outcomeShown: string;
|
|
20
|
+
rung: string | null;
|
|
21
|
+
subjectKind: string | null;
|
|
22
|
+
subjectId: string | null;
|
|
23
|
+
costUsd: number | null;
|
|
24
|
+
error: string | null;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export type TodayCosts = { costUsd: number; costKnownRuns: number; costUnknownRuns: number };
|
|
28
|
+
|
|
29
|
+
export type TodayRow = TodayCosts & {
|
|
30
|
+
key: string;
|
|
31
|
+
kind: "responsibility" | "automation" | "procedure";
|
|
32
|
+
title: string;
|
|
33
|
+
counts: TodayCounts;
|
|
34
|
+
/** Outcome to reason code to how many runs. */
|
|
35
|
+
reasons: Partial<Record<TodayOutcome, Record<string, number>>>;
|
|
36
|
+
automationIds: string[];
|
|
37
|
+
runs: TodayRun[];
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
export type TodayDidNotRun = { automationId: string; title: string; state: "Did not run"; whyCode: "disabled" | "unsupported" | "no_wake"; why: string };
|
|
41
|
+
|
|
42
|
+
export type TodayOverview = {
|
|
43
|
+
state: "ready";
|
|
44
|
+
asOf: string;
|
|
45
|
+
day: string;
|
|
46
|
+
timeZone: string;
|
|
47
|
+
start: string;
|
|
48
|
+
end: string;
|
|
49
|
+
rows: TodayRow[];
|
|
50
|
+
didNotRun: TodayDidNotRun[];
|
|
51
|
+
totals: TodayCosts & { runs: number; counts: TodayCounts };
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
export type TodayResult = TodayOverview | { state: "unavailable" } | { error: "forbidden" | "bad_request"; message?: string };
|
|
55
|
+
|
|
56
|
+
/** Each outcome's words, in the order Today lists them. The mark beside them is a Lucide icon (components/today-view.tsx). */
|
|
57
|
+
export const OUTCOME_WORDS: Record<TodayOutcome, string> = {
|
|
58
|
+
acted: "Did it",
|
|
59
|
+
nothing: "Nothing to do",
|
|
60
|
+
asked: "Asked",
|
|
61
|
+
failed: "Failed",
|
|
62
|
+
unknown: "Outcome unknown",
|
|
63
|
+
};
|
|
64
|
+
export const OTHER_WORDS: Record<"notFinished" | "beforeOutcomes", string> = {
|
|
65
|
+
notFinished: "Not finished yet",
|
|
66
|
+
beforeOutcomes: "Recorded before outcomes",
|
|
67
|
+
};
|
|
68
|
+
export const OUTCOME_ORDER: TodayOutcome[] = ["acted", "nothing", "asked", "failed", "unknown"];
|
|
69
|
+
export const OTHER_ORDER: ("notFinished" | "beforeOutcomes")[] = ["notFinished", "beforeOutcomes"];
|
|
70
|
+
|
|
71
|
+
export function countWords(key: TodayCountKey): string {
|
|
72
|
+
return key in OUTCOME_WORDS ? OUTCOME_WORDS[key as TodayOutcome] : OTHER_WORDS[key as "notFinished" | "beforeOutcomes"];
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export function dollars(value: number): string {
|
|
76
|
+
return value === 0 || value >= 0.01 ? `$${value.toFixed(2)}` : `$${value.toFixed(4)}`;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export function runsText(count: number): string {
|
|
80
|
+
return `${count} run${count === 1 ? "" : "s"}`;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/** "$0.41", with how many runs recorded no cost when some did not. A run without a recorded cost is never counted as free. */
|
|
84
|
+
export function costText(costs: TodayCosts): string {
|
|
85
|
+
const { costKnownRuns: known, costUnknownRuns: unknown } = costs;
|
|
86
|
+
if (!known && !unknown) return "no runs";
|
|
87
|
+
if (!known) return `cost unknown for ${runsText(unknown)}`;
|
|
88
|
+
return unknown ? `${dollars(costs.costUsd)} (cost unknown for ${runsText(unknown)})` : dollars(costs.costUsd);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
export function reasonsText(reasons: Record<string, number>): string {
|
|
92
|
+
return Object.entries(reasons).sort(([a], [b]) => a.localeCompare(b)).map(([code, count]) => `${count} ${code}`).join(", ");
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
const WEEKDAYS = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"];
|
|
96
|
+
const MONTHS = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
|
|
97
|
+
|
|
98
|
+
/** "Monday 16 November 2026" for a YYYY-MM-DD day, in English whatever the viewer's locale, and in UTC so no time zone can move it. */
|
|
99
|
+
export function dayTitle(day: string): string {
|
|
100
|
+
const date = new Date(`${day}T12:00:00Z`);
|
|
101
|
+
if (!/^\d{4}-\d{2}-\d{2}$/.test(day) || Number.isNaN(date.getTime())) return day;
|
|
102
|
+
return `${WEEKDAYS[date.getUTCDay()]} ${date.getUTCDate()} ${MONTHS[date.getUTCMonth()]} ${date.getUTCFullYear()}`;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/** The Automation page, with one automation's runs open when the line names one. */
|
|
106
|
+
export function automationsHref(automationId: string | null, demo?: boolean): string {
|
|
107
|
+
const base = getNewsroomNavHref("/newsroom/administration/automations", demo);
|
|
108
|
+
return automationId ? `${base}${base.includes("?") ? "&" : "?"}automation=${encodeURIComponent(automationId)}` : base;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
export const REFRESH_MILLISECONDS = 5 * 60 * 1000;
|
package/package.json
CHANGED
|
@@ -211,6 +211,8 @@
|
|
|
211
211
|
"./components/story-schedule-badge": "./components/story-schedule-badge.tsx",
|
|
212
212
|
"./components/story-schedule-card": "./components/story-schedule-card.tsx",
|
|
213
213
|
"./components/story-schedule-panel": "./components/story-schedule-panel.tsx",
|
|
214
|
+
"./components/today-panel": "./components/today-panel.tsx",
|
|
215
|
+
"./components/today-view": "./components/today-view.tsx",
|
|
214
216
|
"./components/topic-steering-workspace": "./components/topic-steering-workspace.tsx",
|
|
215
217
|
"./components/ui/auto-grow-textarea": "./components/ui/auto-grow-textarea.tsx",
|
|
216
218
|
"./components/ui/badge": "./components/ui/badge.tsx",
|
|
@@ -503,6 +505,9 @@
|
|
|
503
505
|
"./lib/test-editor-override": "./lib/test-editor-override.ts",
|
|
504
506
|
"./lib/text-columns": "./lib/text-columns.ts",
|
|
505
507
|
"./lib/themed-image": "./lib/themed-image.ts",
|
|
508
|
+
"./lib/today-client": "./lib/today-client.ts",
|
|
509
|
+
"./lib/today-fixture": "./lib/today-fixture.ts",
|
|
510
|
+
"./lib/today-overview": "./lib/today-overview.ts",
|
|
506
511
|
"./lib/use-reference-predictions": "./lib/use-reference-predictions.ts",
|
|
507
512
|
"./lib/use-reference-review-data": "./lib/use-reference-review-data.ts",
|
|
508
513
|
"./lib/utils": "./lib/utils.ts",
|
|
@@ -640,7 +645,7 @@
|
|
|
640
645
|
"optional": true
|
|
641
646
|
}
|
|
642
647
|
},
|
|
643
|
-
"version": "5.130.0
|
|
648
|
+
"version": "5.130.0",
|
|
644
649
|
"dependencies": {
|
|
645
650
|
"@aws-amplify/adapter-nextjs": "^1.7.3",
|
|
646
651
|
"@aws-crypto/sha256-js": "5.2.0",
|
package/routes.manifest.json
CHANGED