@astrosheep/square 0.3.105 → 0.4.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 (143) hide show
  1. package/dist/activity-feed.js +1 -1
  2. package/dist/artifact-store.d.ts +41 -0
  3. package/dist/artifact-store.js +272 -0
  4. package/dist/artifact.d.ts +8 -12
  5. package/dist/artifact.js +66 -343
  6. package/dist/attention-presentation.d.ts +33 -7
  7. package/dist/attention-presentation.js +33 -69
  8. package/dist/boundary-presentation.d.ts +0 -2
  9. package/dist/boundary-presentation.js +17 -22
  10. package/dist/catch-decisions.d.ts +2 -2
  11. package/dist/catch-decisions.js +14 -4
  12. package/dist/catch-selection.d.ts +8 -0
  13. package/dist/catch-selection.js +5 -0
  14. package/dist/channel-artifact.d.ts +10 -0
  15. package/dist/channel-artifact.js +55 -0
  16. package/dist/channel-delivery.d.ts +11 -0
  17. package/dist/channel-delivery.js +51 -0
  18. package/dist/channel-domain.d.ts +3 -0
  19. package/dist/channel-domain.js +83 -0
  20. package/dist/channel-facade.d.ts +76 -0
  21. package/dist/channel-facade.js +1 -0
  22. package/dist/channel-internal.d.ts +126 -0
  23. package/dist/channel-internal.js +440 -0
  24. package/dist/channel-metadata.d.ts +11 -0
  25. package/dist/channel-metadata.js +1 -0
  26. package/dist/channel-ports.d.ts +241 -0
  27. package/dist/channel-ports.js +1 -0
  28. package/dist/channel-presentation.d.ts +17 -0
  29. package/dist/channel-presentation.js +22 -0
  30. package/dist/channel-sqlite-schema.d.ts +13 -0
  31. package/dist/channel-sqlite-schema.js +81 -0
  32. package/dist/channel-transport.d.ts +62 -0
  33. package/dist/channel-transport.js +1 -0
  34. package/dist/channel-values.d.ts +27 -0
  35. package/dist/channel-values.js +90 -0
  36. package/dist/channel.d.ts +31 -21
  37. package/dist/channel.js +42 -74
  38. package/dist/claude-delivery-status.js +1 -1
  39. package/dist/claude-delivery.d.ts +2 -5
  40. package/dist/claude-delivery.js +56 -103
  41. package/dist/claude-mod.js +4 -4
  42. package/dist/claude-transport.d.ts +5 -0
  43. package/dist/claude-transport.js +58 -0
  44. package/dist/cli/context.d.ts +2 -2
  45. package/dist/cli/context.js +0 -1
  46. package/dist/cli/maintenance-commands.d.ts +0 -4
  47. package/dist/cli/maintenance-commands.js +2 -29
  48. package/dist/cli/program.js +1 -1
  49. package/dist/cli/registry.js +1 -2
  50. package/dist/codex-address.d.ts +1 -1
  51. package/dist/codex-queue.d.ts +2 -2
  52. package/dist/codex-queue.js +1 -3
  53. package/dist/decisions.js +3 -3
  54. package/dist/delivery-deferral.d.ts +9 -18
  55. package/dist/delivery-deferral.js +4 -4
  56. package/dist/delivery-health.d.ts +4 -4
  57. package/dist/delivery-health.js +11 -11
  58. package/dist/delivery-operations.d.ts +15 -2
  59. package/dist/delivery-operations.js +60 -30
  60. package/dist/delivery.d.ts +44 -33
  61. package/dist/delivery.js +49 -75
  62. package/dist/help.js +1 -6
  63. package/dist/http-delivery.d.ts +2 -2
  64. package/dist/http-delivery.js +2 -4
  65. package/dist/inbox.d.ts +10 -18
  66. package/dist/inbox.js +44 -53
  67. package/dist/index.d.ts +1 -1
  68. package/dist/index.js +1 -1
  69. package/dist/mcp.d.ts +2 -1
  70. package/dist/mcp.js +40 -70
  71. package/dist/message.d.ts +7 -0
  72. package/dist/message.js +23 -0
  73. package/dist/model.d.ts +41 -77
  74. package/dist/model.js +7 -139
  75. package/dist/neutral.d.ts +72 -0
  76. package/dist/neutral.js +27 -0
  77. package/dist/notifications.d.ts +2 -8
  78. package/dist/notifications.js +15 -50
  79. package/dist/operation-presentation.d.ts +1 -2
  80. package/dist/operation-presentation.js +1 -7
  81. package/dist/owner.d.ts +2 -2
  82. package/dist/owner.js +1 -1
  83. package/dist/paseo-delivery.d.ts +1 -1
  84. package/dist/paseo-delivery.js +2 -4
  85. package/dist/paseo-timeline.js +1 -0
  86. package/dist/plugins/opencode/delivery.js +27 -42
  87. package/dist/ports.d.ts +46 -168
  88. package/dist/presentation-operations.d.ts +1 -14
  89. package/dist/presentation-operations.js +16 -16
  90. package/dist/presentation.d.ts +5 -5
  91. package/dist/presentation.js +1 -0
  92. package/dist/runtime.js +2 -2
  93. package/dist/search.js +1 -1
  94. package/dist/sqlite-channel.d.ts +15 -0
  95. package/dist/sqlite-channel.js +600 -0
  96. package/dist/sqlite-framing.d.ts +8 -0
  97. package/dist/sqlite-framing.js +31 -0
  98. package/dist/sqlite-square.d.ts +12 -13
  99. package/dist/sqlite-square.js +192 -248
  100. package/dist/sqlite-values.d.ts +21 -0
  101. package/dist/sqlite-values.js +78 -0
  102. package/dist/square-api.d.ts +1 -1
  103. package/dist/square-api.js +1 -1
  104. package/dist/square-core.d.ts +1 -1
  105. package/dist/square-domain.d.ts +21 -7
  106. package/dist/square-domain.js +93 -94
  107. package/dist/square-facade.d.ts +12 -66
  108. package/dist/square-index.d.ts +1 -1
  109. package/dist/square-index.js +1 -1
  110. package/dist/square-location.d.ts +6 -1
  111. package/dist/square-location.js +1 -1
  112. package/dist/square-receive.d.ts +2 -3
  113. package/dist/square-sqlite.d.ts +45 -44
  114. package/dist/square-sqlite.js +308 -764
  115. package/dist/square-tools.d.ts +8 -0
  116. package/dist/square-tools.js +39 -0
  117. package/dist/views.d.ts +6 -6
  118. package/dist/views.js +15 -9
  119. package/dist/wake-preview.d.ts +7 -0
  120. package/dist/wake-preview.js +15 -0
  121. package/dist/wake-sink.d.ts +2 -2
  122. package/dist/wake-sink.js +1 -1
  123. package/dist/wake-transports.d.ts +7 -0
  124. package/dist/wake-transports.js +42 -0
  125. package/guides/claude-native.md +13 -10
  126. package/guides/codex-delivery.md +3 -1
  127. package/guides/participant-ownership.md +1 -1
  128. package/guides/row-runtime-delivery-evidence.md +2 -0
  129. package/guides/row-storage-design.md +19 -44
  130. package/guides/square-api.md +137 -60
  131. package/package.json +3 -3
  132. package/plugins/claude/.claude-plugin/plugin.json +1 -1
  133. package/plugins/claude/types.d.ts +1 -1
  134. package/plugins/codex/.codex-plugin/plugin.json +1 -1
  135. package/plugins/opencode/delivery.ts +28 -41
  136. package/plugins/pi/square-pi.js +28 -51
  137. package/dist/square-legacy-framing.d.ts +0 -11
  138. package/dist/square-legacy-framing.js +0 -64
  139. package/dist/square-migration-host-ledger.d.ts +0 -26
  140. package/dist/square-migration-host-ledger.js +0 -169
  141. package/dist/square-migration.d.ts +0 -30
  142. package/dist/square-migration.js +0 -599
  143. package/guides/migration.md +0 -156
@@ -1,6 +1,5 @@
1
- import type { AudienceRoute } from './attention.js';
2
- import type { StoredAct } from './model.js';
1
+ import type { DirectedNotificationRoute, HydratedAct } from './model.js';
3
2
  import type { DirectedFilter, SquareRead } from './ports.js';
4
3
  import type { ReceiveRead } from './receive.js';
5
4
  /** Transaction-local projections only; the artifact still owns indexed selection and bodies. */
6
- export declare function squareReceiveRead(facts: SquareRead): ReceiveRead<number, StoredAct, AudienceRoute, DirectedFilter>;
5
+ export declare function squareReceiveRead(facts: SquareRead): ReceiveRead<number, HydratedAct, DirectedNotificationRoute, DirectedFilter>;
@@ -1,7 +1,12 @@
1
1
  import { type DatabaseSync } from 'node:sqlite';
2
- import { SquareError, type ActivityObservation, type HardCap, type StoredAct, type WatchLease } from './model.js';
3
- import type { SquareHeader, SquareRead, DeliveryClaimInput, DeliveryClaimResult, DeliveryCompletion, DeliveryPreparation } from './ports.js';
4
- import { type LandingWriter } from './square-domain.js';
2
+ import { type ActivityObservation, type HardCap, type Seat, type StoredAct, type HydratedAct, type WatchLease } from './model.js';
3
+ import type { SquareHeader, SquareRead } from './ports.js';
4
+ import type { ChannelWrite, EndpointRef } from './channel-ports.js';
5
+ import type { StoreFormat } from './artifact-store.js';
6
+ export { invalidArtifact } from './sqlite-values.js';
7
+ export { endpointGeneration } from './sqlite-channel.js';
8
+ export declare const APPLICATION_ID = 1397838405;
9
+ export declare const CURRENT_USER_VERSION = 11;
5
10
  /** Explicit import/export DTOs, not a runtime transaction model. */
6
11
  export interface SquareRuntimeState {
7
12
  nextActIndex: number;
@@ -13,56 +18,52 @@ export interface SquareState {
13
18
  throttlePerMinute?: number;
14
19
  preamble: string[];
15
20
  warmup: string[];
16
- acts: StoredAct[];
21
+ acts: HydratedAct[];
17
22
  runtime: SquareRuntimeState;
18
23
  }
19
24
  export declare function emptyRuntimeState(nextActIndex?: number): SquareRuntimeState;
20
- export declare const APPLICATION_ID = 1397838405;
21
- export declare const V2_USER_VERSION = 2;
22
- export declare const V3_USER_VERSION = 3;
23
- export declare const V4_USER_VERSION = 4;
24
- export declare const V5_USER_VERSION = 5;
25
- export declare const V6_USER_VERSION = 6;
26
- export declare const V7_USER_VERSION = 7;
27
- export declare const CURRENT_USER_VERSION = 8;
28
- export declare const V1_SNAPSHOT_TABLE = "square_snapshot";
29
- export interface LegacyFraming {
30
- readonly applicationId: number;
31
- readonly userVersion: number;
32
- readonly journalMode: string;
25
+ /** Agora owns only its allocator/configuration header and social tables; neutral storage owns the revision header. */
26
+ export declare const AGORA_SCHEMA_SQL = "CREATE TABLE square_meta (\n id INTEGER PRIMARY KEY CHECK (id = 1),\n next_act_index INTEGER NOT NULL CHECK (next_act_index BETWEEN 0 AND 9007199254740991),\n hard_cap INTEGER CHECK (hard_cap BETWEEN 1 AND 9007199254740991),\n throttle_per_minute INTEGER CHECK (throttle_per_minute BETWEEN 1 AND 9007199254740991),\n preamble_json TEXT NOT NULL CHECK (json_valid(preamble_json)),\n warmup_json TEXT NOT NULL CHECK (json_valid(warmup_json))\n);\nCREATE TABLE activities (\n act_index INTEGER PRIMARY KEY CHECK (act_index BETWEEN 0 AND 9007199254740991),\n at REAL NOT NULL,\n kind TEXT NOT NULL CHECK (kind IN ('join','done','say','read','listen','ignore','unlisten')),\n actor_json TEXT COLLATE BINARY NOT NULL,\n actor_key_json TEXT COLLATE BINARY NOT NULL,\n reach TEXT CHECK (reach = 'bell'),\n reply_index INTEGER CHECK (reply_index >= 0 AND reply_index < act_index),\n message_index INTEGER CHECK (message_index IS NULL OR message_index BETWEEN 0 AND 9007199254740991),\n payload_json TEXT NOT NULL CHECK (json_valid(payload_json)),\n CHECK ((kind = 'say') = (message_index IS NOT NULL)),\n CHECK (kind = 'say' OR (reach IS NULL AND reply_index IS NULL))\n);\nCREATE INDEX activity_kind_index ON activities(kind, act_index);\nCREATE INDEX activity_actor_index ON activities(actor_key_json, act_index);\nCREATE INDEX activity_say_actor_index ON activities(actor_key_json, act_index) WHERE kind='say';\nCREATE INDEX activity_say_time ON activities(at, act_index) WHERE kind='say';\nCREATE INDEX activity_bell_actor_time ON activities(actor_key_json, at, act_index) WHERE kind='say' AND reach='bell';\nCREATE UNIQUE INDEX activity_message ON activities(message_index) WHERE message_index IS NOT NULL;\nCREATE TABLE participants (\n name_key_json TEXT COLLATE BINARY PRIMARY KEY NOT NULL,\n name_json TEXT NOT NULL,\n first_index INTEGER NOT NULL UNIQUE,\n joined INTEGER NOT NULL CHECK (joined IN (0,1)),\n done INTEGER NOT NULL CHECK (done IN (0,1)),\n say_count INTEGER NOT NULL CHECK (say_count >= 0),\n last_active_at REAL,\n last_join_index INTEGER,\n CHECK (NOT (joined=1 AND done=1))\n) WITHOUT ROWID;\nCREATE TABLE attention (\n listener_key_json TEXT COLLATE BINARY NOT NULL,\n target_key_json TEXT COLLATE BINARY NOT NULL,\n target_json TEXT NOT NULL,\n kind TEXT NOT NULL CHECK (kind IN ('listen','ignore')),\n since_index INTEGER NOT NULL,\n PRIMARY KEY (listener_key_json, target_key_json)\n) WITHOUT ROWID;\nCREATE INDEX attention_target ON attention(target_key_json, kind, listener_key_json);\nCREATE TABLE landed_audience (\n act_index INTEGER NOT NULL,\n recipient_key_json TEXT COLLATE BINARY NOT NULL,\n recipient_order INTEGER NOT NULL CHECK (recipient_order >= 0),\n reason TEXT NOT NULL CHECK (reason IN ('mention','reply','attention','bell')),\n PRIMARY KEY (act_index, recipient_key_json),\n UNIQUE (act_index, recipient_order)\n) WITHOUT ROWID;\nCREATE INDEX audience_recipient ON landed_audience(recipient_key_json, act_index);";
27
+ export interface AgoraConfig {
28
+ readonly hardCap?: number | null;
29
+ readonly throttlePerMinute?: number;
30
+ readonly preamble?: readonly string[];
31
+ readonly warmup?: readonly string[];
32
+ }
33
+ export declare function initializeAgoraSqlite(db: DatabaseSync, configuration?: AgoraConfig): void;
34
+ export declare function resetAgoraSqlite(db: DatabaseSync): void;
35
+ /** The lower schema is supplied by the composition root; Agora never defines Channel tables. */
36
+ export interface LowerSchema {
37
+ readonly schemaSql: string;
38
+ initialize(db: DatabaseSync): void;
39
+ reset(db: DatabaseSync): void;
33
40
  }
34
- /**
35
- * Read-only legacy framing: application id, format version, journal mode and the
36
- * exact owned snapshot schema. It decodes no snapshot payload, writes no pragma
37
- * and runs no DDL, so ordinary open can establish ownership before requiring
38
- * migration. Anything else is unrelated or unsupported, not repaired.
39
- */
40
- export declare function validateLegacyFraming(database: DatabaseSync, applicationId: number, location?: string): LegacyFraming;
41
- export declare const ACTIVITIES_TABLE_SQL = "CREATE TABLE activities (\n act_index INTEGER PRIMARY KEY CHECK (act_index BETWEEN 0 AND 9007199254740991),\n at REAL NOT NULL,\n kind TEXT NOT NULL CHECK (kind IN ('join','done','say','read','listen','ignore','unlisten')),\n actor_json TEXT COLLATE BINARY NOT NULL,\n actor_key_json TEXT COLLATE BINARY NOT NULL,\n reach TEXT CHECK (reach = 'bell'),\n reply_index INTEGER CHECK (reply_index >= 0 AND reply_index < act_index),\n payload_json TEXT NOT NULL CHECK (json_valid(payload_json)),\n CHECK (kind = 'say' OR (reach IS NULL AND reply_index IS NULL))\n);";
42
- export declare const ACTIVITY_INDEXES_SQL: readonly ["CREATE INDEX activity_kind_index ON activities(kind, act_index)", "CREATE INDEX activity_actor_index ON activities(actor_key_json, act_index)", "CREATE INDEX activity_say_actor_index ON activities(actor_key_json, act_index) WHERE kind='say'", "CREATE INDEX activity_say_time ON activities(at, act_index) WHERE kind='say'", "CREATE INDEX activity_bell_actor_time ON activities(actor_key_json, at, act_index) WHERE kind='say' AND reach='bell'"];
43
- export declare const DELIVERY_DEFERRALS_SQL = "CREATE TABLE delivery_deferrals (\n participant_key_json TEXT COLLATE BINARY NOT NULL,\n participant_json TEXT NOT NULL,\n generation_json TEXT NOT NULL,\n deferral_id_json TEXT NOT NULL,\n match_json TEXT NOT NULL CHECK (json_valid(match_json)),\n expires_at REAL NOT NULL,\n PRIMARY KEY (participant_key_json,generation_json,deferral_id_json)\n) WITHOUT ROWID;\nCREATE INDEX delivery_deferral_expiry ON delivery_deferrals(participant_key_json,generation_json,expires_at);";
44
- export declare const SCHEMA_SQL: string;
45
- export declare const FORMAT7_SCHEMA_SQL: string;
46
- export declare const FORMAT6_SCHEMA_SQL: string;
47
- export declare const FORMAT5_SCHEMA_SQL: string;
48
- export declare const FORMAT4_SCHEMA_SQL: string;
49
- export declare function invalidArtifact(detail: string): SquareError;
41
+ /** Explicit full-Square framing and reset, composed from the neutral store and the supplied Channel schema. */
42
+ export declare function squareStoreFormat(lower: LowerSchema, resetStorage: (db: DatabaseSync) => void): StoreFormat;
43
+ /** A persisted upper activity. A say is a relation: it may not carry content and must name its message. */
50
44
  export declare function validateStoredActivity(value: unknown): StoredAct;
45
+ /** The explicit upper projection of a stored say onto its authoritative message content. */
46
+ export declare function validateHydratedActivity(value: unknown): HydratedAct;
51
47
  export declare function validateWatchLease(value: unknown): WatchLease;
52
- export declare function validateRowFraming(db: DatabaseSync, version: 2 | 3 | 4 | 5 | 6 | 7 | 8, location?: string): void;
53
- export declare function validateSqliteHeader(db: DatabaseSync, location?: string): SquareHeader;
54
- export interface SqliteDriver extends SquareRead, LandingWriter {
48
+ export declare function readSquareHeader(db: DatabaseSync): SquareHeader;
49
+ export interface SqliteDriver extends SquareRead {
50
+ readonly channel: ChannelWrite;
51
+ storeSeat(seat: Seat): boolean;
52
+ removeSeat(seat: EndpointRef): boolean;
53
+ applyLanding(effect: import('./square-domain.js').LandingEffect): void;
55
54
  readonly changed: boolean;
56
55
  readonly deliveryChanged: boolean;
57
- claimDelivery(input: DeliveryClaimInput): DeliveryClaimResult;
58
- prepareDelivery(input: DeliveryPreparation): boolean;
59
- completeDelivery(input: DeliveryCompletion): boolean;
56
+ /** Explicit import replay: one message for every say, then the activity/audience facts. */
57
+ importLanding(activity: HydratedAct): StoredAct;
60
58
  }
61
- export declare function createSqliteDriver(db: DatabaseSync): SqliteDriver;
62
- /** Explicit import only. Caller owns transaction, legacy validation and format publication. */
63
- export declare function initializeSqlite(db: DatabaseSync, state: SquareState, revision?: number): void;
59
+ export declare function createSqliteDriver(db: DatabaseSync, channelDriver?: ChannelWrite & {
60
+ readonly changed: boolean;
61
+ readonly deliveryChanged: boolean;
62
+ }): SqliteDriver;
63
+ /** Explicit import replay. Caller owns the transaction and format publication. */
64
+ export declare function initializeSqlite(db: DatabaseSync, state: SquareState, revision: number, lower: LowerSchema): void;
64
65
  export declare function exportSqliteState(db: DatabaseSync): SquareState;
65
- /** Full read-only integrity inspection, including maintained-index replay comparison. */
66
- export declare function inspectSqlite(db: DatabaseSync): {
66
+ /** Read-only integrity inspection; maintained-index replay runs when the lower schema is supplied. */
67
+ export declare function inspectSqlite(db: DatabaseSync, lower?: LowerSchema): {
67
68
  standingCount: number;
68
69
  };