@anthusai/papyrus 5.136.0-next.1 → 5.136.0-next.3

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.
@@ -9,7 +9,7 @@ import { FEED_STREAM_VIEW, FEED_TABLES, tableStream } from "./stream-readers.js"
9
9
  import { setModelKeyParameter } from "./model-key.js";
10
10
  import { allowWakeSending } from "./wake-queue.js";
11
11
  /**
12
- * The change feeds for Reference, ReviewRequest, Message, LocalizationRequest and Delivery (docs/design/always-on-agents-architecture.md, slice B3, PPY-9b9e64):
12
+ * The change feeds for Reference, ReviewRequest, Message, LocalizationRequest, Delivery and Assignment (docs/design/always-on-agents-architecture.md, slice B3, PPY-9b9e64):
13
13
  * one function that turns each change to a row of those tables into one wake per listening agent on the site's wake queue. All the logic is
14
14
  * src/papyrus_content/change_feeds.py (the normalized change and the wake are the Item feed's, src/papyrus_content/item_change_feed.py); the handler is
15
15
  * amplify/functions/change-feed/handler.py. One function, not one per table: the feeds share every line of code and all they differ in is the table of the stream
@@ -48,8 +48,10 @@ export const CHANGE_FEED_FILTERS = {
48
48
  Message: { eventName: ["INSERT"], dynamodb: { NewImage: { messageKind: { S: ["comment"] } } } },
49
49
  LocalizationRequest: { eventName: ["INSERT", "MODIFY"], dynamodb: { NewImage: { state: { S: ["wanted"] } } } },
50
50
  Delivery: { eventName: ["INSERT", "MODIFY"] },
51
+ // Only the Assignments that are requests between responsibilities (type `responsibility.<agent>`, src/papyrus_content/handoff_records.py); the other kinds run by their own executors.
52
+ Assignment: { eventName: ["INSERT", "MODIFY"], dynamodb: { NewImage: { assignmentTypeKey: { S: [{ prefix: "responsibility." }] } } } },
51
53
  };
52
- /** The streams of every feed table the schema has. The Reference, Message and LocalizationRequest streams are the readers' own where they exist; ReviewRequest and Delivery had none. */
54
+ /** The streams of every feed table the schema has. The Reference, Message and LocalizationRequest streams are the readers' own where they exist; ReviewRequest, Delivery and Assignment had none. */
53
55
  export function enableFeedStreams(backend) {
54
56
  const streams = {};
55
57
  for (const table of FEED_TABLES) {
@@ -12,7 +12,7 @@ import { allowWakeSending } from "./wake-queue";
12
12
  import type { AgentPiece } from "./stack";
13
13
 
14
14
  /**
15
- * The change feeds for Reference, ReviewRequest, Message, LocalizationRequest and Delivery (docs/design/always-on-agents-architecture.md, slice B3, PPY-9b9e64):
15
+ * The change feeds for Reference, ReviewRequest, Message, LocalizationRequest, Delivery and Assignment (docs/design/always-on-agents-architecture.md, slice B3, PPY-9b9e64):
16
16
  * one function that turns each change to a row of those tables into one wake per listening agent on the site's wake queue. All the logic is
17
17
  * src/papyrus_content/change_feeds.py (the normalized change and the wake are the Item feed's, src/papyrus_content/item_change_feed.py); the handler is
18
18
  * amplify/functions/change-feed/handler.py. One function, not one per table: the feeds share every line of code and all they differ in is the table of the stream
@@ -53,6 +53,8 @@ export const CHANGE_FEED_FILTERS: Record<FeedTable, Record<string, unknown>> = {
53
53
  Message: { eventName: ["INSERT"], dynamodb: { NewImage: { messageKind: { S: ["comment"] } } } },
54
54
  LocalizationRequest: { eventName: ["INSERT", "MODIFY"], dynamodb: { NewImage: { state: { S: ["wanted"] } } } },
55
55
  Delivery: { eventName: ["INSERT", "MODIFY"] },
56
+ // Only the Assignments that are requests between responsibilities (type `responsibility.<agent>`, src/papyrus_content/handoff_records.py); the other kinds run by their own executors.
57
+ Assignment: { eventName: ["INSERT", "MODIFY"], dynamodb: { NewImage: { assignmentTypeKey: { S: [{ prefix: "responsibility." }] } } } },
56
58
  };
57
59
 
58
60
  /** The streams the stack switched on or found: a table's stream ARN, only for a table the site's schema has. */
@@ -70,7 +72,7 @@ export type ChangeFeedsSource = {
70
72
  openAiKeyParameter?: string;
71
73
  };
72
74
 
73
- /** The streams of every feed table the schema has. The Reference, Message and LocalizationRequest streams are the readers' own where they exist; ReviewRequest and Delivery had none. */
75
+ /** The streams of every feed table the schema has. The Reference, Message and LocalizationRequest streams are the readers' own where they exist; ReviewRequest, Delivery and Assignment had none. */
74
76
  export function enableFeedStreams(backend: any): FeedStreams {
75
77
  const streams: FeedStreams = {};
76
78
  for (const table of FEED_TABLES) {
@@ -6,6 +6,7 @@ import { pythonLambdaCode } from "../functions/shared/python-bundle.js";
6
6
  import { connectToSiteApi } from "../site-api-access.js";
7
7
  import { tableStream } from "./stream-readers.js";
8
8
  import { setModelKeyParameter } from "./model-key.js";
9
+ import { allowFollowUpTimers } from "./schedule-group.js";
9
10
  import { allowWakeSending } from "./wake-queue.js";
10
11
  /**
11
12
  * The Item change feed (docs/design/always-on-agents-architecture.md, slice B2, PPY-8a374e): a DynamoDB stream consumer on the Item table that turns each
@@ -17,12 +18,23 @@ import { allowWakeSending } from "./wake-queue.js";
17
18
  * `enableItemStream` (the Item table had no stream and no reader before this; it holds one reader now, the feed).
18
19
  *
19
20
  * What the function may do, and nothing else: read the Item stream; read the site's `SiteDocument` rows through its own site's API (`getSiteDocument`: the live
20
- * version of the listener index) and that one document's objects in the site's bucket (`tenants/<tenant>/site/listeners/`); look up and send to its own
21
- * site's wake queue. It reads no table, receives and deletes no wake, and calls no model.
21
+ * version of the listener index and of the agent policy) and those two documents' objects in the site's bucket (`tenants/<tenant>/site/listeners/` and
22
+ * `.../agents/`); look up and send to its own site's wake queue; set and clear follow-up timers for paid steps that wait for quiet (`follow-up-*` entries in its
23
+ * site's schedule group, slice B5); and, for the loop guard (slice B7), read a Story's versions, write the loop count on its current version and raise the one hard-gate
24
+ * review request, all through its own site's API. It reads no table, receives and deletes no wake, and calls no model.
22
25
  */
23
26
  export const ITEM_STREAM_VIEW = dynamodb.StreamViewType.NEW_AND_OLD_IMAGES;
24
- export const ITEM_FEED_API_FIELDS = ["Query/fields/getSiteDocument"];
27
+ /** `getSiteDocument`: the listener index and the agent policy. The gate (PPY-67e3cd, PPY-4e7e8b) reads a Story's versions and keeps its loop count on the current one, and raises the hard gate once. */
28
+ export const ITEM_FEED_API_FIELDS = [
29
+ "Query/fields/getSiteDocument",
30
+ "Query/fields/listItemsByLineageAndVersion",
31
+ "Query/fields/getItem",
32
+ "Mutation/fields/updateItem",
33
+ "Query/fields/getReviewRequest",
34
+ "Mutation/fields/createReviewRequest",
35
+ ];
25
36
  export const LISTENER_INDEX_KIND = "listeners";
37
+ export const AGENT_POLICY_KIND = "agents";
26
38
  const STREAM_READ_ACTIONS = ["dynamodb:DescribeStream", "dynamodb:GetRecords", "dynamodb:GetShardIterator", "dynamodb:ListStreams"];
27
39
  /**
28
40
  * Switches on the Item table's stream, with both images (the feed compares them to tell a board move from any other update), and returns its ARN.
@@ -67,9 +79,12 @@ export function itemChangeFeedPiece(brandId, source) {
67
79
  feed.addToRolePolicy(new PolicyStatement({
68
80
  effect: Effect.ALLOW,
69
81
  actions: ["s3:GetObject"],
70
- resources: [`${source.bucketArn}/tenants/${source.tenantId}/site/${LISTENER_INDEX_KIND}/*`],
82
+ resources: [LISTENER_INDEX_KIND, AGENT_POLICY_KIND].map((kind) => `${source.bucketArn}/tenants/${source.tenantId}/site/${kind}/*`),
71
83
  }));
72
84
  allowWakeSending(feed, brandId);
85
+ allowFollowUpTimers(feed, brandId);
86
+ feed.addEnvironment("PAPYRUS_AWS_ACCOUNT_ID", stack.account);
87
+ feed.addEnvironment("PAPYRUS_AWS_PARTITION", stack.partition);
73
88
  feed.addToRolePolicy(new PolicyStatement({ effect: Effect.ALLOW, actions: STREAM_READ_ACTIONS, resources: [source.streamArn] }));
74
89
  new CfnEventSourceMapping(scope, "ItemStreamMapping", {
75
90
  eventSourceArn: source.streamArn,
@@ -7,6 +7,7 @@ import { pythonLambdaCode } from "../functions/shared/python-bundle";
7
7
  import { connectToSiteApi } from "../site-api-access";
8
8
  import { tableStream } from "./stream-readers";
9
9
  import { setModelKeyParameter } from "./model-key";
10
+ import { allowFollowUpTimers } from "./schedule-group";
10
11
  import { allowWakeSending } from "./wake-queue";
11
12
  import type { AgentPiece } from "./stack";
12
13
 
@@ -20,13 +21,24 @@ import type { AgentPiece } from "./stack";
20
21
  * `enableItemStream` (the Item table had no stream and no reader before this; it holds one reader now, the feed).
21
22
  *
22
23
  * What the function may do, and nothing else: read the Item stream; read the site's `SiteDocument` rows through its own site's API (`getSiteDocument`: the live
23
- * version of the listener index) and that one document's objects in the site's bucket (`tenants/<tenant>/site/listeners/`); look up and send to its own
24
- * site's wake queue. It reads no table, receives and deletes no wake, and calls no model.
24
+ * version of the listener index and of the agent policy) and those two documents' objects in the site's bucket (`tenants/<tenant>/site/listeners/` and
25
+ * `.../agents/`); look up and send to its own site's wake queue; set and clear follow-up timers for paid steps that wait for quiet (`follow-up-*` entries in its
26
+ * site's schedule group, slice B5); and, for the loop guard (slice B7), read a Story's versions, write the loop count on its current version and raise the one hard-gate
27
+ * review request, all through its own site's API. It reads no table, receives and deletes no wake, and calls no model.
25
28
  */
26
29
 
27
30
  export const ITEM_STREAM_VIEW = dynamodb.StreamViewType.NEW_AND_OLD_IMAGES;
28
- export const ITEM_FEED_API_FIELDS = ["Query/fields/getSiteDocument"];
31
+ /** `getSiteDocument`: the listener index and the agent policy. The gate (PPY-67e3cd, PPY-4e7e8b) reads a Story's versions and keeps its loop count on the current one, and raises the hard gate once. */
32
+ export const ITEM_FEED_API_FIELDS = [
33
+ "Query/fields/getSiteDocument",
34
+ "Query/fields/listItemsByLineageAndVersion",
35
+ "Query/fields/getItem",
36
+ "Mutation/fields/updateItem",
37
+ "Query/fields/getReviewRequest",
38
+ "Mutation/fields/createReviewRequest",
39
+ ];
29
40
  export const LISTENER_INDEX_KIND = "listeners";
41
+ export const AGENT_POLICY_KIND = "agents";
30
42
  const STREAM_READ_ACTIONS = ["dynamodb:DescribeStream", "dynamodb:GetRecords", "dynamodb:GetShardIterator", "dynamodb:ListStreams"];
31
43
 
32
44
  /** What the feed needs from the rest of the site's backend. Absent for a backend that cannot run it (a shared stack, which acts for no one tenant). */
@@ -92,10 +104,13 @@ export function itemChangeFeedPiece(brandId: string, source: ItemChangeFeedSourc
92
104
  new PolicyStatement({
93
105
  effect: Effect.ALLOW,
94
106
  actions: ["s3:GetObject"],
95
- resources: [`${source.bucketArn}/tenants/${source.tenantId}/site/${LISTENER_INDEX_KIND}/*`],
107
+ resources: [LISTENER_INDEX_KIND, AGENT_POLICY_KIND].map((kind) => `${source.bucketArn}/tenants/${source.tenantId}/site/${kind}/*`),
96
108
  }),
97
109
  );
98
110
  allowWakeSending(feed, brandId);
111
+ allowFollowUpTimers(feed, brandId);
112
+ feed.addEnvironment("PAPYRUS_AWS_ACCOUNT_ID", stack.account);
113
+ feed.addEnvironment("PAPYRUS_AWS_PARTITION", stack.partition);
99
114
  feed.addToRolePolicy(new PolicyStatement({ effect: Effect.ALLOW, actions: STREAM_READ_ACTIONS, resources: [source.streamArn] }));
100
115
  new CfnEventSourceMapping(scope, "ItemStreamMapping", {
101
116
  eventSourceArn: source.streamArn,
@@ -14,7 +14,7 @@ import * as dynamodb from "aws-cdk-lib/aws-dynamodb";
14
14
  * This is a finding about readers that exist today, not something this fixes for them: the readers are named here only so the rule and the test can count them.
15
15
  */
16
16
  /** The tables the change feeds of slice B3 cover (the Item table's feed is its own function, amplify/agents/item-change-feed.ts). */
17
- export const FEED_TABLES = ["Reference", "ReviewRequest", "Message", "LocalizationRequest", "Delivery"];
17
+ export const FEED_TABLES = ["Reference", "ReviewRequest", "Message", "LocalizationRequest", "Delivery", "Assignment"];
18
18
  export const MAX_STREAM_READERS = 2;
19
19
  /** Every stream reader that is not a change feed: the table it reads. */
20
20
  export const STREAM_READER_TABLES = {
@@ -16,7 +16,7 @@ import * as dynamodb from "aws-cdk-lib/aws-dynamodb";
16
16
  */
17
17
 
18
18
  /** The tables the change feeds of slice B3 cover (the Item table's feed is its own function, amplify/agents/item-change-feed.ts). */
19
- export const FEED_TABLES = ["Reference", "ReviewRequest", "Message", "LocalizationRequest", "Delivery"] as const;
19
+ export const FEED_TABLES = ["Reference", "ReviewRequest", "Message", "LocalizationRequest", "Delivery", "Assignment"] as const;
20
20
  export type FeedTable = (typeof FEED_TABLES)[number];
21
21
 
22
22
  export const MAX_STREAM_READERS = 2;
@@ -2,7 +2,7 @@
2
2
 
3
3
  All the logic is ``papyrus_content.item_change_feed``. This file decodes nothing itself: it builds the collaborators with the function's own role: the
4
4
  site's listener index (``agent_listeners.ListenerIndex`` over the site store: one point read of the live version, the body from S3 only when the version
5
- moved) and the site's wake queue (``agent_wakes.wake_sender``). Nothing here lists a table.
5
+ moved) and the site's wake queue (``agent_wakes.wake_sender``). Nothing here lists a table. Between the changes and the queue stands the wake gate (``wake_gate.py``): a paid step waits for quiet on a follow-up timer, a person's change clears the loop count, and an agent that reaches the limit raises one hard gate.
6
6
 
7
7
  A batch is processed in order. A record whose wakes cannot all be put on the queue is reported as failed, and Lambda retries from it; every wake key is the same on
8
8
  the retry, so what was already sent starts nothing twice. Records that are no change (a version marked superseded, a card's counts refreshed) cost nothing.
@@ -34,13 +34,46 @@ def listener_index(site) -> Any:
34
34
  return _INDEX
35
35
 
36
36
 
37
- def handler(event: dict[str, Any], context: Any = None, *, index=None, send=None, environment=None) -> dict[str, Any]:
37
+ _CLIENT: Any = None
38
+
39
+
40
+ def site_client(site) -> Any:
41
+ global _CLIENT
42
+ if _CLIENT is None:
43
+ from papyrus_content.graphql_authoring import PapyrusGraphQLAuthoringClient
44
+
45
+ os.environ.setdefault("PAPYRUS_GRAPHQL_AUTH", "iam") # the function's own role signs the calls
46
+ _CLIENT = PapyrusGraphQLAuthoringClient(endpoint=site.appsync_endpoint)
47
+ return _CLIENT
48
+
49
+
50
+ def wake_gate(site, environment) -> Any:
51
+ """The gate between the feed and the queue (PPY-67e3cd, PPY-4e7e8b): the agent policy's window and loop limit, the site's follow-up timers, the Story's counter and the hard gate."""
52
+ import boto3
53
+
54
+ from papyrus_content import wake_gate as gate
55
+ from papyrus_content.agent_policy import AgentPolicyStore
56
+ from papyrus_content.agent_policy.run_gate import SiteCatalogue
57
+ from papyrus_content.follow_up_timers import FollowUpTimers
58
+ from papyrus_content.site_store import SiteStore
59
+
60
+ client = site_client(site)
61
+ store = AgentPolicyStore(SiteStore(boto3.client("s3"), site.site_bucket, SiteCatalogue(client)))
62
+ timers = FollowUpTimers.for_site(site.publication_id, account=environment["PAPYRUS_AWS_ACCOUNT_ID"], region=environment["AWS_REGION"],
63
+ partition=environment.get("PAPYRUS_AWS_PARTITION") or "aws")
64
+ return gate.WakeGate(policy=lambda: store.read(site.tenant_id).document, timers=timers, chain=gate.StoryChain(client),
65
+ review=lambda **found: gate.raise_loop_review(client, **found))
66
+
67
+
68
+ def handler(event: dict[str, Any], context: Any = None, *, index=None, send=None, environment=None, gate=None) -> dict[str, Any]:
38
69
  from papyrus_content import item_change_feed
39
70
  from papyrus_content.agent_wakes import wake_sender
40
71
  from papyrus_content.localize.dispatch import decode_image
41
72
 
42
- site = item_change_feed.Site.from_environment(environment if environment is not None else os.environ)
73
+ environment = os.environ if environment is None else environment
74
+ site = item_change_feed.Site.from_environment(environment)
43
75
  result = item_change_feed.handle(event.get("Records", []), decode=decode_image, listeners=lambda: (index or listener_index(site)).document(),
44
- send=send or wake_sender(), site=site)
76
+ send=send or wake_sender(), site=site,
77
+ gate=gate or (wake_gate(site, environment) if event.get("Records") else None))
45
78
  print(json.dumps({"event": "papyrus_item_change_feed", "records": len(event.get("Records", [])), "wakesSent": result["wakesSent"], "failed": len(result["batchItemFailures"])}))
46
79
  return {"batchItemFailures": result["batchItemFailures"]}
@@ -22,7 +22,7 @@ const THEME_KEYS = [
22
22
  ];
23
23
  const KNOWN_KEYS = new Set([
24
24
  "name", "siteId", "siteOrigin", "basePath", "computeRoleArn", "sendingDomain", "fromAddress", "fromName", "theme", "lists",
25
- "configurationSet", "eventTopicName", "itemUrlStyle",
25
+ "configurationSet", "eventTopicName", "itemUrlStyle", "floorStars",
26
26
  ]);
27
27
  const LIST_KEYS = {
28
28
  roundup: ["id", "name", "description", "kind", "schedule", "issueType", "archivePath"],
@@ -98,6 +98,13 @@ function stringList(raw, label) {
98
98
  fail(`${label} must be a list of 1 to 50 names`);
99
99
  return [...new Set(raw.map((entry, index) => text(entry, `${label}[${index}]`, 80)))];
100
100
  }
101
+ export function floorStars(raw) {
102
+ if (raw === undefined)
103
+ return undefined;
104
+ if (typeof raw !== "number" || !Number.isInteger(raw) || raw < 1 || raw > 5)
105
+ fail("floorStars must be a whole number from 1 to 5");
106
+ return raw;
107
+ }
101
108
  export function itemUrlStyle(raw) {
102
109
  if (raw === undefined)
103
110
  return "html";
@@ -233,6 +240,7 @@ export function resolveNewsletterConfig(request) {
233
240
  theme: resolveTheme(raw.theme),
234
241
  lists,
235
242
  itemUrlStyle: itemUrlStyle(raw.itemUrlStyle),
243
+ ...(raw.floorStars === undefined ? {} : { floorStars: floorStars(raw.floorStars) }),
236
244
  configurationSet: matching(raw.configurationSet, "configurationSet", SES_NAME, "an SES configuration set name", `papyrus-${siteId}`),
237
245
  eventTopicName: matching(raw.eventTopicName, "eventTopicName", SES_NAME, "an SNS topic name", `papyrus-newsletter-events-${siteId}`),
238
246
  };
@@ -89,6 +89,8 @@ export type NewsletterConfig = {
89
89
  lists: NewsletterList[];
90
90
  /** How the site addresses its item pages (`urls.style` in projection.json): roundup drafts link to published items with it. */
91
91
  itemUrlStyle: ItemUrlStyle;
92
+ /** The site's quality floor (`quality.floorStars` in projection.json, 1 to 5): a roundup draft takes only Stories rated at least this. Absent: no floor. Keep it equal to the site's. */
93
+ floorStars?: number;
92
94
  /** `papyrus-<siteId>` unless overridden. */
93
95
  configurationSet: string;
94
96
  /** `papyrus-newsletter-events-<siteId>` unless overridden. */
@@ -97,7 +99,7 @@ export type NewsletterConfig = {
97
99
 
98
100
  const KNOWN_KEYS = new Set([
99
101
  "name", "siteId", "siteOrigin", "basePath", "computeRoleArn", "sendingDomain", "fromAddress", "fromName", "theme", "lists",
100
- "configurationSet", "eventTopicName", "itemUrlStyle",
102
+ "configurationSet", "eventTopicName", "itemUrlStyle", "floorStars",
101
103
  ]);
102
104
  const LIST_KEYS = {
103
105
  roundup: ["id", "name", "description", "kind", "schedule", "issueType", "archivePath"],
@@ -170,6 +172,12 @@ function stringList(raw: unknown, label: string): string[] | undefined {
170
172
  return [...new Set(raw.map((entry, index) => text(entry, `${label}[${index}]`, 80)))];
171
173
  }
172
174
 
175
+ export function floorStars(raw: unknown): number | undefined {
176
+ if (raw === undefined) return undefined;
177
+ if (typeof raw !== "number" || !Number.isInteger(raw) || raw < 1 || raw > 5) fail("floorStars must be a whole number from 1 to 5");
178
+ return raw;
179
+ }
180
+
173
181
  export function itemUrlStyle(raw: unknown): ItemUrlStyle {
174
182
  if (raw === undefined) return "html";
175
183
  if (typeof raw !== "string" || !(ITEM_URL_STYLES as readonly string[]).includes(raw)) fail(`itemUrlStyle must be one of ${ITEM_URL_STYLES.join(", ")}`);
@@ -293,6 +301,7 @@ export function resolveNewsletterConfig(request: PluginRequest): NewsletterConfi
293
301
  theme: resolveTheme(raw.theme),
294
302
  lists,
295
303
  itemUrlStyle: itemUrlStyle(raw.itemUrlStyle),
304
+ ...(raw.floorStars === undefined ? {} : { floorStars: floorStars(raw.floorStars) }),
296
305
  configurationSet: matching(raw.configurationSet, "configurationSet", SES_NAME, "an SES configuration set name", `papyrus-${siteId}`),
297
306
  eventTopicName: matching(raw.eventTopicName, "eventTopicName", SES_NAME, "an SNS topic name", `papyrus-newsletter-events-${siteId}`),
298
307
  };
@@ -71,6 +71,7 @@ export function newsletterEnvironment(config, tableName, keyParameter) {
71
71
  FROM_NAME: config.fromName,
72
72
  CONFIGURATION_SET: config.configurationSet,
73
73
  ITEM_URL_STYLE: config.itemUrlStyle,
74
+ ...(config.floorStars === undefined ? {} : { FLOOR_STARS: String(config.floorStars) }),
74
75
  LISTS_JSON: JSON.stringify(config.lists.map((list) => ({
75
76
  id: list.id,
76
77
  name: list.name,
@@ -84,6 +84,7 @@ export function newsletterEnvironment(config: NewsletterConfig, tableName: strin
84
84
  FROM_NAME: config.fromName,
85
85
  CONFIGURATION_SET: config.configurationSet,
86
86
  ITEM_URL_STYLE: config.itemUrlStyle,
87
+ ...(config.floorStars === undefined ? {} : { FLOOR_STARS: String(config.floorStars) }),
87
88
  LISTS_JSON: JSON.stringify(
88
89
  config.lists.map((list) => ({
89
90
  id: list.id,
@@ -55,6 +55,7 @@ export type ImageOperationName =
55
55
  | "announcements_recent"
56
56
  | "announcements_explain"
57
57
  | "ratings_set"
58
+ | "handoffs_request"
58
59
  ;
59
60
 
60
61
  export type ImageErrorCode =
@@ -1589,6 +1590,26 @@ export type RatingsSetResult = {
1589
1590
  ratedBy?: string;
1590
1591
  };
1591
1592
 
1593
+ /** Ask another responsibility for one piece of work on a Story. It appears on the Story as an Assignment that says who asked and why, and wakes the responsible agent once. */
1594
+ export type HandoffsRequestInput = {
1595
+ /** The lineage id of the Story. */
1596
+ story: string;
1597
+ /** The responsibility asked, as the agent catalogue names it, such as research. */
1598
+ responsibility: string;
1599
+ /** What is needed and why, in plain words. It is the Assignment's brief and what the responsible agent reads. */
1600
+ why: string;
1601
+ };
1602
+
1603
+ export type HandoffsRequestResult = {
1604
+ assignmentId: string;
1605
+ responsibility: string;
1606
+ story: string;
1607
+ status: string;
1608
+ askedBy: string;
1609
+ /** False when the same ask was already made: nothing new was written and nobody is woken again. */
1610
+ created: boolean;
1611
+ };
1612
+
1592
1613
  export interface ImageOperations {
1593
1614
  image_profile_get: { input: ImageProfileGetInput; result: ImageProfileGetResult };
1594
1615
  image_profile_resolve: { input: ImageProfileResolveInput; result: ImageProfileResolveResult };
@@ -1642,6 +1663,7 @@ export interface ImageOperations {
1642
1663
  announcements_recent: { input: AnnouncementsRecentInput; result: AnnouncementsRecentResult };
1643
1664
  announcements_explain: { input: AnnouncementsExplainInput; result: AnnouncementsExplainResult };
1644
1665
  ratings_set: { input: RatingsSetInput; result: RatingsSetResult };
1666
+ handoffs_request: { input: HandoffsRequestInput; result: HandoffsRequestResult };
1645
1667
  }
1646
1668
 
1647
1669
  /** What each operation is, for the transport: read operations are queries, write and spend operations are mutations. */
@@ -1698,14 +1720,15 @@ export const IMAGE_OPERATIONS = {
1698
1720
  announcements_recent: { effect: "read", agentAllowed: true, agentRung: "observe", agentRefusal: "human_required", group: "announcements", command: "papyrus announcements recent" },
1699
1721
  announcements_explain: { effect: "read", agentAllowed: true, agentRung: "observe", agentRefusal: "human_required", group: "announcements", command: "papyrus announcements explain" },
1700
1722
  ratings_set: { effect: "write", agentAllowed: true, agentRung: "draft", agentRefusal: "human_required", group: "ratings", command: "papyrus ratings set" },
1723
+ handoffs_request: { effect: "write", agentAllowed: true, agentRung: "propose", agentRefusal: "human_required", group: "handoffs", command: "papyrus handoffs request" },
1701
1724
  } as const;
1702
1725
 
1703
- /** `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). */
1726
+ /** `group` says which door: images go through imageRead and imageWrite, guidelines through guidelinesRead and guidelinesWrite; announcements, ratings and handoffs have no door yet (the console reads and writes their models directly). */
1704
1727
  export type ImageTransport = (request: {
1705
1728
  op: ImageOperationName;
1706
1729
  input: unknown;
1707
1730
  effect: "read" | "write" | "spend";
1708
- group: "images" | "guidelines" | "announcements" | "ratings";
1731
+ group: "images" | "guidelines" | "announcements" | "ratings" | "handoffs";
1709
1732
  }) => Promise<unknown>;
1710
1733
 
1711
1734
  export async function callImageOperation<Name extends ImageOperationName>(
package/package.json CHANGED
@@ -650,7 +650,7 @@
650
650
  "optional": true
651
651
  }
652
652
  },
653
- "version": "5.136.0-next.1",
653
+ "version": "5.136.0-next.3",
654
654
  "dependencies": {
655
655
  "@aws-amplify/adapter-nextjs": "^1.7.3",
656
656
  "@aws-crypto/sha256-js": "5.2.0",
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "5.136.0-next.1",
2
+ "version": "5.136.0-next.3",
3
3
  "routes": [
4
4
  {
5
5
  "file": "app/%5F_preview/[[...path]]/route.ts",