@company-semantics/contracts 92.0.0 → 93.0.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.
Files changed (61) hide show
  1. package/package.json +9 -9
  2. package/src/action-items/README.md +12 -4
  3. package/src/action-items/schemas.ts +10 -0
  4. package/src/affordances/README.md +52 -1
  5. package/src/affordances/__tests__/README.md +10 -1
  6. package/src/affordances/__tests__/affordances.test.ts +13 -1
  7. package/src/affordances/__tests__/catalog-wave.test.ts +237 -0
  8. package/src/affordances/affordance.ts +56 -4
  9. package/src/affordances/args.ts +44 -1
  10. package/src/affordances/available.ts +59 -0
  11. package/src/affordances/coverage.ts +51 -0
  12. package/src/affordances/ids.ts +28 -0
  13. package/src/affordances/index.ts +17 -0
  14. package/src/api/README.md +1 -0
  15. package/src/api/generated-spec-hash.ts +2 -2
  16. package/src/api/generated.ts +397 -1
  17. package/src/api/primitives.ts +13 -0
  18. package/src/billing/README.md +1 -0
  19. package/src/billing/refusals.ts +12 -0
  20. package/src/message-parts/README.md +5 -0
  21. package/src/message-parts/affordance-offer.ts +44 -0
  22. package/src/message-parts/index.ts +7 -0
  23. package/src/message-parts/types.ts +7 -1
  24. package/src/message-parts/wire.ts +18 -0
  25. package/src/notifications/README.md +17 -3
  26. package/src/notifications/__tests__/README.md +4 -0
  27. package/src/notifications/__tests__/__snapshots__/render-snapshot.test.ts.snap +27 -25
  28. package/src/notifications/__tests__/fixtures.ts +7 -1
  29. package/src/notifications/__tests__/grounded-ctas.test.ts +103 -0
  30. package/src/notifications/__tests__/render-snapshot.test.ts +1 -1
  31. package/src/notifications/content.ts +9 -0
  32. package/src/notifications/kinds/billing-auto-recharge-failed.ts +4 -2
  33. package/src/notifications/kinds/billing-payment-past-due.ts +2 -0
  34. package/src/notifications/kinds/billing-suspended.ts +2 -0
  35. package/src/notifications/kinds/chat-shared.ts +10 -3
  36. package/src/notifications/kinds/company-md-access-approved.ts +13 -6
  37. package/src/notifications/kinds/share-granted.ts +1 -1
  38. package/src/notifications/kinds/unit-owner-granted.ts +9 -2
  39. package/src/notifications/payloads.ts +6 -0
  40. package/src/proactive/README.md +18 -2
  41. package/src/proactive/__tests__/README.md +11 -1
  42. package/src/proactive/__tests__/chat-templates.test.ts +7 -6
  43. package/src/proactive/__tests__/proactive-offers.test.ts +124 -0
  44. package/src/proactive/__tests__/vocabulary.test.ts +1 -1
  45. package/src/proactive/composer.ts +11 -0
  46. package/src/proactive/templates/README.md +11 -3
  47. package/src/proactive/templates/billing-auto-recharge-failed.ts +1 -0
  48. package/src/proactive/templates/billing-balance-exhausted.ts +2 -6
  49. package/src/proactive/templates/billing-payment-past-due.ts +1 -0
  50. package/src/proactive/templates/billing-subscription-canceled.ts +1 -5
  51. package/src/proactive/templates/billing-suspended.ts +1 -0
  52. package/src/proactive/templates/morning-brief.ts +1 -0
  53. package/src/proactive/templates/org-became-shared.ts +4 -3
  54. package/src/proactive/templates/source-sync-review-ready.ts +3 -8
  55. package/src/proactive/templates/workflow-needs-attention.ts +1 -0
  56. package/src/rate-limit/README.md +27 -1
  57. package/src/rate-limit/__tests__/README.md +23 -0
  58. package/src/rate-limit/__tests__/rate-limited-error.test.ts +53 -0
  59. package/src/rate-limit/index.ts +33 -0
  60. package/src/root-exports/agent-runtime.ts +14 -2
  61. package/src/root-exports/delivery.ts +15 -0
@@ -0,0 +1,53 @@
1
+ import { describe, expect, it } from "vitest";
2
+
3
+ import * as root from "../../index";
4
+ import {
5
+ RATE_LIMITED_ERROR_CODE,
6
+ RateLimitedErrorResponseSchema,
7
+ } from "../index";
8
+
9
+ const body = (fields: Record<string, unknown>) => ({
10
+ error: "RATE_LIMIT_EXCEEDED",
11
+ message: "Too many requests.",
12
+ ...fields,
13
+ });
14
+
15
+ describe("the rate-limited error envelope", () => {
16
+ it("a rate-limited body states when the window resets, or null", () => {
17
+ expect(
18
+ RateLimitedErrorResponseSchema.safeParse(body({ retryAfterSeconds: 30 }))
19
+ .success,
20
+ ).toBe(true);
21
+ expect(
22
+ RateLimitedErrorResponseSchema.safeParse(
23
+ body({ retryAfterSeconds: null }),
24
+ ).success,
25
+ ).toBe(true);
26
+ });
27
+
28
+ it("refuses a rate-limited body without retryAfterSeconds", () => {
29
+ expect(RateLimitedErrorResponseSchema.safeParse(body({})).success).toBe(
30
+ false,
31
+ );
32
+ expect(
33
+ RateLimitedErrorResponseSchema.safeParse(body({ retryAfterSeconds: -1 }))
34
+ .success,
35
+ ).toBe(false);
36
+ });
37
+
38
+ it("refuses any other code", () => {
39
+ expect(
40
+ RateLimitedErrorResponseSchema.safeParse(
41
+ body({ error: "FORBIDDEN", retryAfterSeconds: 3 }),
42
+ ).success,
43
+ ).toBe(false);
44
+ expect(RATE_LIMITED_ERROR_CODE).toBe("RATE_LIMIT_EXCEEDED");
45
+ });
46
+
47
+ it("is reachable from the package root", () => {
48
+ expect(root.RateLimitedErrorResponseSchema).toBe(
49
+ RateLimitedErrorResponseSchema,
50
+ );
51
+ expect(root.RATE_LIMITED_ERROR_CODE).toBe(RATE_LIMITED_ERROR_CODE);
52
+ });
53
+ });
@@ -1,3 +1,5 @@
1
+ import { z } from "zod";
2
+
1
3
  /**
2
4
  * Rate limiting vocabulary types.
3
5
  * @see PRD-00012 for foundational implementation
@@ -21,3 +23,34 @@ export interface RateLimitResult {
21
23
  remaining: number;
22
24
  resetAt: number;
23
25
  }
26
+
27
+ // =============================================================================
28
+ // The rate-limited error envelope (owner ruling 2026-10-06: retry prose is
29
+ // FACTS ONLY; control ADR affordance-system)
30
+ // =============================================================================
31
+
32
+ /** The error code every rate-limited response carries. */
33
+ export const RATE_LIMITED_ERROR_CODE = "RATE_LIMIT_EXCEEDED" as const;
34
+
35
+ /**
36
+ * A 429 body, exactly as backend's shared limiter sends it
37
+ * (`{ error: 'RATE_LIMIT_EXCEEDED', scope?, message }`), plus the one fact a
38
+ * client needs to say when the window resets.
39
+ *
40
+ * `retryAfterSeconds` mirrors the `Retry-After` header: whole seconds until the
41
+ * window resets, or null when the limiter cannot say. It is a FACT, so the
42
+ * message states it ("Too many requests. Available in 30s.") and never
43
+ * tells the reader to retry; a retry control, if a surface has one, is that
44
+ * surface's own control label.
45
+ */
46
+ export const RateLimitedErrorResponseSchema = z
47
+ .object({
48
+ error: z.literal(RATE_LIMITED_ERROR_CODE),
49
+ scope: z.enum(["email", "ip", "global"]).optional(),
50
+ message: z.string(),
51
+ retryAfterSeconds: z.number().int().nonnegative().nullable(),
52
+ })
53
+ .strict();
54
+ export type RateLimitedErrorResponse = z.infer<
55
+ typeof RateLimitedErrorResponseSchema
56
+ >;
@@ -97,6 +97,10 @@ export type {
97
97
  WorkflowOutcomeData,
98
98
  WorkflowOutcomePart,
99
99
  WorkflowOutcomeDataPart,
100
+ // Affordance offer types (non-governed, the frozen offer on a pushed chat, control ADR affordance-system)
101
+ AffordanceOfferData,
102
+ AffordanceOfferPart,
103
+ AffordanceOfferDataPart,
100
104
  // Execution result types (Phase 5)
101
105
  ExecutionArtifactStatus,
102
106
  ExecutionResultSummary,
@@ -213,5 +217,13 @@ export type {
213
217
 
214
218
  // Rate limit domain types
215
219
  // @see PRD-00013 for contracts integration
216
- export type { RateLimitConfig, RateLimitResult } from "../rate-limit/index";
217
- export { RateLimitTier } from "../rate-limit/index";
220
+ export type {
221
+ RateLimitConfig,
222
+ RateLimitResult,
223
+ RateLimitedErrorResponse,
224
+ } from "../rate-limit/index";
225
+ export {
226
+ RATE_LIMITED_ERROR_CODE,
227
+ RateLimitTier,
228
+ RateLimitedErrorResponseSchema,
229
+ } from "../rate-limit/index";
@@ -299,13 +299,24 @@ export {
299
299
  AFFORDANCE_UNAVAILABLE_REASONS,
300
300
  AffordanceAvailabilityIdSchema,
301
301
  AffordanceAvailabilitySchema,
302
+ AffordanceCoverageSchema,
302
303
  AffordanceIdSchema,
303
304
  AffordanceSchema,
305
+ AvailableAffordanceSchema,
306
+ AvailableAffordancesSchema,
307
+ ChatOpenArgsSchema,
308
+ CompanyMdDocArgsSchema,
309
+ ExecutionOpenArgsSchema,
304
310
  MAX_OFFERED_AFFORDANCES,
311
+ NO_AFFORDANCE_REASONS,
305
312
  NO_ARG_AFFORDANCE_IDS,
313
+ NoAffordanceReasonSchema,
306
314
  OfferedAffordanceSchema,
315
+ OrgStructureOpenReviewArgsSchema,
307
316
  PROJECTED_AFFORDANCE_IDS,
308
317
  ReviewOpenArgsSchema,
318
+ SourceSyncOpenUpdateArgsSchema,
319
+ TeamOpenArgsSchema,
309
320
  sameAffordances,
310
321
  } from "../affordances/index";
311
322
 
@@ -315,8 +326,12 @@ export type {
315
326
  AffordanceAvailability,
316
327
  AffordanceAvailabilityId,
317
328
  AffordanceBindingKind,
329
+ AffordanceCoverage,
318
330
  AffordanceId,
319
331
  AffordanceUnavailableReason,
332
+ AvailableAffordance,
333
+ AvailableAffordances,
334
+ NoAffordanceReason,
320
335
  OfferedAffordance,
321
336
  ProjectedAffordanceId,
322
337
  } from "../affordances/index";