@cogitator-ai/bridge 0.0.0-stage → 0.3.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 (106) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +330 -2
  3. package/dist/adapter.d.ts +123 -0
  4. package/dist/adapter.d.ts.map +1 -0
  5. package/dist/adapter.js +2 -0
  6. package/dist/adapter.js.map +1 -0
  7. package/dist/adapters/claude.d.ts +90 -0
  8. package/dist/adapters/claude.d.ts.map +1 -0
  9. package/dist/adapters/claude.js +359 -0
  10. package/dist/adapters/claude.js.map +1 -0
  11. package/dist/adapters/codex.d.ts +58 -0
  12. package/dist/adapters/codex.d.ts.map +1 -0
  13. package/dist/adapters/codex.js +330 -0
  14. package/dist/adapters/codex.js.map +1 -0
  15. package/dist/adapters/exec.d.ts +57 -0
  16. package/dist/adapters/exec.d.ts.map +1 -0
  17. package/dist/adapters/exec.js +149 -0
  18. package/dist/adapters/exec.js.map +1 -0
  19. package/dist/adapters/hosted.d.ts +168 -0
  20. package/dist/adapters/hosted.d.ts.map +1 -0
  21. package/dist/adapters/hosted.js +361 -0
  22. package/dist/adapters/hosted.js.map +1 -0
  23. package/dist/client.d.ts +81 -0
  24. package/dist/client.d.ts.map +1 -0
  25. package/dist/client.js +216 -0
  26. package/dist/client.js.map +1 -0
  27. package/dist/dispatcher.d.ts +296 -0
  28. package/dist/dispatcher.d.ts.map +1 -0
  29. package/dist/dispatcher.js +1524 -0
  30. package/dist/dispatcher.js.map +1 -0
  31. package/dist/errors.d.ts +10 -0
  32. package/dist/errors.d.ts.map +1 -0
  33. package/dist/errors.js +16 -0
  34. package/dist/errors.js.map +1 -0
  35. package/dist/guards.d.ts +36 -0
  36. package/dist/guards.d.ts.map +1 -0
  37. package/dist/guards.js +85 -0
  38. package/dist/guards.js.map +1 -0
  39. package/dist/host.d.ts +49 -0
  40. package/dist/host.d.ts.map +1 -0
  41. package/dist/host.js +150 -0
  42. package/dist/host.js.map +1 -0
  43. package/dist/index.d.ts +50 -0
  44. package/dist/index.d.ts.map +1 -0
  45. package/dist/index.js +32 -0
  46. package/dist/index.js.map +1 -0
  47. package/dist/inputs.d.ts +184 -0
  48. package/dist/inputs.d.ts.map +1 -0
  49. package/dist/inputs.js +116 -0
  50. package/dist/inputs.js.map +1 -0
  51. package/dist/job-record.d.ts +47 -0
  52. package/dist/job-record.d.ts.map +1 -0
  53. package/dist/job-record.js +65 -0
  54. package/dist/job-record.js.map +1 -0
  55. package/dist/letters.d.ts +49 -0
  56. package/dist/letters.d.ts.map +1 -0
  57. package/dist/letters.js +96 -0
  58. package/dist/letters.js.map +1 -0
  59. package/dist/paths.d.ts +38 -0
  60. package/dist/paths.d.ts.map +1 -0
  61. package/dist/paths.js +149 -0
  62. package/dist/paths.js.map +1 -0
  63. package/dist/protocol.d.ts +83 -0
  64. package/dist/protocol.d.ts.map +1 -0
  65. package/dist/protocol.js +71 -0
  66. package/dist/protocol.js.map +1 -0
  67. package/dist/registry.d.ts +62 -0
  68. package/dist/registry.d.ts.map +1 -0
  69. package/dist/registry.js +185 -0
  70. package/dist/registry.js.map +1 -0
  71. package/dist/server.d.ts +31 -0
  72. package/dist/server.d.ts.map +1 -0
  73. package/dist/server.js +254 -0
  74. package/dist/server.js.map +1 -0
  75. package/dist/store/sqlite.d.ts +56 -0
  76. package/dist/store/sqlite.d.ts.map +1 -0
  77. package/dist/store/sqlite.js +737 -0
  78. package/dist/store/sqlite.js.map +1 -0
  79. package/dist/store/store.d.ts +128 -0
  80. package/dist/store/store.d.ts.map +1 -0
  81. package/dist/store/store.js +2 -0
  82. package/dist/store/store.js.map +1 -0
  83. package/dist/testing/conformance.d.ts +65 -0
  84. package/dist/testing/conformance.d.ts.map +1 -0
  85. package/dist/testing/conformance.js +217 -0
  86. package/dist/testing/conformance.js.map +1 -0
  87. package/dist/testing/fake-harnesses.d.ts +101 -0
  88. package/dist/testing/fake-harnesses.d.ts.map +1 -0
  89. package/dist/testing/fake-harnesses.js +291 -0
  90. package/dist/testing/fake-harnesses.js.map +1 -0
  91. package/dist/testing/index.d.ts +5 -0
  92. package/dist/testing/index.d.ts.map +1 -0
  93. package/dist/testing/index.js +3 -0
  94. package/dist/testing/index.js.map +1 -0
  95. package/dist/types.d.ts +286 -0
  96. package/dist/types.d.ts.map +1 -0
  97. package/dist/types.js +132 -0
  98. package/dist/types.js.map +1 -0
  99. package/dist/waiter.d.ts +36 -0
  100. package/dist/waiter.d.ts.map +1 -0
  101. package/dist/waiter.js +92 -0
  102. package/dist/waiter.js.map +1 -0
  103. package/fakes/claude.mjs +450 -0
  104. package/fakes/codex.mjs +391 -0
  105. package/fakes/lib.mjs +507 -0
  106. package/package.json +76 -3
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAUnD,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAG3C,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAGtD,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAG1C,OAAO,EACL,iBAAiB,EACjB,cAAc,EACd,oBAAoB,EACpB,uBAAuB,GACxB,MAAM,eAAe,CAAC;AAGvB,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAGzD,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAG1D,OAAO,EACL,cAAc,EACd,WAAW,EACX,mBAAmB,EACnB,WAAW,EACX,gBAAgB,EAChB,cAAc,EACd,aAAa,EACb,cAAc,EACd,cAAc,GACf,MAAM,eAAe,CAAC;AAGvB,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AACzD,OAAO,EAAE,kBAAkB,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAEzE,OAAO,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAU3D,OAAO,EAAE,iBAAiB,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAe7E,OAAO,EACL,cAAc,EACd,aAAa,EACb,cAAc,EACd,eAAe,EACf,SAAS,EACT,cAAc,EACd,UAAU,EACV,YAAY,EACZ,eAAe,GAChB,MAAM,YAAY,CAAC;AAmCpB,OAAO,EACL,eAAe,EACf,sBAAsB,EACtB,iBAAiB,EACjB,WAAW,EACX,iBAAiB,EACjB,cAAc,EACd,iBAAiB,GAClB,MAAM,sBAAsB,CAAC;AAO9B,OAAO,EAAE,sBAAsB,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAE3F,OAAO,EACL,eAAe,EACf,iBAAiB,EACjB,aAAa,EACb,gBAAgB,GACjB,MAAM,sBAAsB,CAAC;AAgB9B,OAAO,EAAE,mBAAmB,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAErE,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC"}
@@ -0,0 +1,184 @@
1
+ import { z } from 'zod';
2
+ import { type BridgeJob, type JobBudget, type JobCheck, type Letter, type LetterKind, type RenderedLetter, type ReportOutcome } from './types.js';
3
+ /** An id a sender may give its letter, so sending it again does not deliver it twice. */
4
+ export declare const LetterIdSchema: z.ZodString;
5
+ export declare const CreateJobInputSchema: z.ZodObject<{
6
+ to: z.ZodString;
7
+ body: z.ZodString;
8
+ title: z.ZodOptional<z.ZodString>;
9
+ cwd: z.ZodOptional<z.ZodString>;
10
+ checks: z.ZodOptional<z.ZodArray<z.ZodObject<{
11
+ name: z.ZodOptional<z.ZodString>;
12
+ command: z.ZodString;
13
+ cwd: z.ZodOptional<z.ZodString>;
14
+ timeoutMs: z.ZodOptional<z.ZodNumber>;
15
+ }, z.core.$strip>>>;
16
+ budget: z.ZodOptional<z.ZodObject<{
17
+ letters: z.ZodOptional<z.ZodNumber>;
18
+ durationMs: z.ZodOptional<z.ZodNumber>;
19
+ replyTimeoutMs: z.ZodOptional<z.ZodNumber>;
20
+ }, z.core.$strip>>;
21
+ parent: z.ZodOptional<z.ZodNumber>;
22
+ letterId: z.ZodOptional<z.ZodString>;
23
+ }, z.core.$strict>;
24
+ /** What an agent says to hand a job over. */
25
+ export interface CreateJobInput {
26
+ /** Who gets the job: an agent's name, or a harness word such as `codex` or `claude:reviewer` */
27
+ to: string;
28
+ /** The job itself: what to do, and what done looks like */
29
+ body: string;
30
+ /** A short name of the job, the first line of the body by default */
31
+ title?: string;
32
+ /**
33
+ * The folder the job is done in, the caller's by default. Relative to the caller's folder,
34
+ * and always inside the caller's project
35
+ */
36
+ cwd?: string;
37
+ checks?: JobCheck[];
38
+ budget?: Partial<JobBudget>;
39
+ /** The job this one is part of, when the caller carries out several */
40
+ parent?: number;
41
+ /** The id of the job's first letter: creating a job with the same id again changes nothing */
42
+ letterId?: string;
43
+ }
44
+ export declare const SendLetterInputSchema: z.ZodObject<{
45
+ job: z.ZodNumber;
46
+ kind: z.ZodEnum<{
47
+ question: "question";
48
+ answer: "answer";
49
+ report: "report";
50
+ note: "note";
51
+ permission: "permission";
52
+ }>;
53
+ body: z.ZodString;
54
+ id: z.ZodOptional<z.ZodString>;
55
+ inReplyTo: z.ZodOptional<z.ZodString>;
56
+ outcome: z.ZodOptional<z.ZodEnum<{
57
+ completed: "completed";
58
+ failed: "failed";
59
+ }>>;
60
+ }, z.core.$strict>;
61
+ /** A letter on a job that exists. The job's own first letter is written by `createJob`. */
62
+ export interface SendLetterInput {
63
+ job: number;
64
+ kind: Exclude<LetterKind, 'task'>;
65
+ body: string;
66
+ /** Sending a letter with the same id again changes nothing */
67
+ id?: string;
68
+ /** The letter this one answers. An `answer` finds the open question itself when there is one */
69
+ inReplyTo?: string;
70
+ /** Of a report: `completed` by default */
71
+ outcome?: ReportOutcome;
72
+ }
73
+ export interface CreateJobResult {
74
+ job: BridgeJob;
75
+ letter: Letter;
76
+ /** True when the job was created before with the same `letterId`, and nothing changed now */
77
+ duplicate: boolean;
78
+ }
79
+ export interface SendLetterResult {
80
+ letter: Letter;
81
+ job: BridgeJob;
82
+ /** True when the letter was sent before with the same id, and nothing changed now */
83
+ duplicate: boolean;
84
+ }
85
+ /** How many letters one call to the inbox returns when it names no limit. */
86
+ export declare const DEFAULT_INBOX_LIMIT = 20;
87
+ /** How many jobs, letters or journal entries one call returns when it names no limit. */
88
+ export declare const DEFAULT_LIST_LIMIT = 200;
89
+ export declare const InboxInputSchema: z.ZodObject<{
90
+ job: z.ZodOptional<z.ZodNumber>;
91
+ peek: z.ZodOptional<z.ZodBoolean>;
92
+ unhandled: z.ZodOptional<z.ZodBoolean>;
93
+ limit: z.ZodOptional<z.ZodNumber>;
94
+ afterSeq: z.ZodOptional<z.ZodNumber>;
95
+ }, z.core.$strict>;
96
+ export interface InboxInput {
97
+ /** Only the letters of one job */
98
+ job?: number;
99
+ /** Look without taking: the letters stay as they are */
100
+ peek?: boolean;
101
+ /** Also the letters taken before and not answered or dismissed since */
102
+ unhandled?: boolean;
103
+ /** The most letters to return, 20 by default and 100 at most. The rest wait for the next call */
104
+ limit?: number;
105
+ /** Only letters accepted after this one, to look further than one call returns */
106
+ afterSeq?: number;
107
+ }
108
+ /** How long a call waits for mail when it names no time. */
109
+ export declare const DEFAULT_WAIT_MS: number;
110
+ /** The longest one call waits for mail. */
111
+ export declare const MAX_WAIT_MS: number;
112
+ export declare const WaitInputSchema: z.ZodObject<{
113
+ timeoutMs: z.ZodOptional<z.ZodNumber>;
114
+ limit: z.ZodOptional<z.ZodNumber>;
115
+ }, z.core.$strict>;
116
+ export interface WaitInput {
117
+ /** How long to wait for a letter, 10 minutes by default and a day at most */
118
+ timeoutMs?: number;
119
+ /** The most letters to return, 20 by default and 100 at most */
120
+ limit?: number;
121
+ }
122
+ /**
123
+ * Why a wait ended: `letters` came, the time ran out (`timeout`), another waiter of the same
124
+ * session took its place (`replaced`), or the dispatcher or the connection closed (`closed`)
125
+ */
126
+ export type WaitEnd = 'letters' | 'timeout' | 'replaced' | 'closed';
127
+ export interface WaitResult {
128
+ /** The letters queued for the session, oldest first. Empty unless `reason` is `letters` */
129
+ letters: RenderedLetter[];
130
+ reason: WaitEnd;
131
+ }
132
+ export declare const DeliveredInputSchema: z.ZodObject<{
133
+ letters: z.ZodArray<z.ZodString>;
134
+ }, z.core.$strict>;
135
+ export declare const JobsFilterSchema: z.ZodObject<{
136
+ states: z.ZodOptional<z.ZodArray<z.ZodEnum<{
137
+ [x: string]: string;
138
+ }>>>;
139
+ from: z.ZodOptional<z.ZodString>;
140
+ to: z.ZodOptional<z.ZodString>;
141
+ party: z.ZodOptional<z.ZodString>;
142
+ project: z.ZodOptional<z.ZodString>;
143
+ parent: z.ZodOptional<z.ZodNumber>;
144
+ deadlineBy: z.ZodOptional<z.ZodNumber>;
145
+ createdSince: z.ZodOptional<z.ZodNumber>;
146
+ limit: z.ZodOptional<z.ZodNumber>;
147
+ }, z.core.$strict>;
148
+ export declare const AgentsFilterSchema: z.ZodObject<{
149
+ project: z.ZodOptional<z.ZodString>;
150
+ harness: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>>;
151
+ statuses: z.ZodOptional<z.ZodArray<z.ZodEnum<{
152
+ starting: "starting";
153
+ active: "active";
154
+ gone: "gone";
155
+ }>>>;
156
+ seenBefore: z.ZodOptional<z.ZodNumber>;
157
+ }, z.core.$strict>;
158
+ export declare const LettersFilterSchema: z.ZodObject<{
159
+ job: z.ZodOptional<z.ZodNumber>;
160
+ from: z.ZodOptional<z.ZodString>;
161
+ to: z.ZodOptional<z.ZodString>;
162
+ states: z.ZodOptional<z.ZodArray<z.ZodEnum<{
163
+ [x: string]: string;
164
+ }>>>;
165
+ kinds: z.ZodOptional<z.ZodArray<z.ZodEnum<{
166
+ [x: string]: string;
167
+ }>>>;
168
+ afterSeq: z.ZodOptional<z.ZodNumber>;
169
+ replyDueBy: z.ZodOptional<z.ZodNumber>;
170
+ attemptsBelow: z.ZodOptional<z.ZodNumber>;
171
+ limit: z.ZodOptional<z.ZodNumber>;
172
+ newestFirst: z.ZodOptional<z.ZodBoolean>;
173
+ }, z.core.$strict>;
174
+ export declare const JournalQuerySchema: z.ZodObject<{
175
+ afterSeq: z.ZodOptional<z.ZodNumber>;
176
+ job: z.ZodOptional<z.ZodNumber>;
177
+ limit: z.ZodOptional<z.ZodNumber>;
178
+ tail: z.ZodOptional<z.ZodNumber>;
179
+ }, z.core.$strict>;
180
+ export declare const VerificationInputSchema: z.ZodObject<{
181
+ verified: z.ZodBoolean;
182
+ summary: z.ZodOptional<z.ZodString>;
183
+ }, z.core.$strict>;
184
+ //# sourceMappingURL=inputs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"inputs.d.ts","sourceRoot":"","sources":["../src/inputs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAML,KAAK,SAAS,EACd,KAAK,SAAS,EACd,KAAK,QAAQ,EACb,KAAK,MAAM,EACX,KAAK,UAAU,EACf,KAAK,cAAc,EACnB,KAAK,aAAa,EACnB,MAAM,YAAY,CAAC;AAEpB,yFAAyF;AACzF,eAAO,MAAM,cAAc,aAK+D,CAAC;AAa3F,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;kBAY/B,CAAC;AAEH,6CAA6C;AAC7C,MAAM,WAAW,cAAc;IAC7B,gGAAgG;IAChG,EAAE,EAAE,MAAM,CAAC;IACX,2DAA2D;IAC3D,IAAI,EAAE,MAAM,CAAC;IACb,qEAAqE;IACrE,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;OAGG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,QAAQ,EAAE,CAAC;IACpB,MAAM,CAAC,EAAE,OAAO,CAAC,SAAS,CAAC,CAAC;IAC5B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CAAC;AAE3C,2CAA2C;AAC3C,eAAO,MAAM,WAAW,QAAiB,CAAC;AAE1C,eAAO,MAAM,eAAe;;;kBAG1B,CAAC;AAEH,MAAM,WAAW,SAAS;IACxB,6EAA6E;IAC7E,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,gEAAgE;IAChE,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;;GAGG;AACH,MAAM,MAAM,OAAO,GAAG,SAAS,GAAG,SAAS,GAAG,UAAU,GAAG,QAAQ,CAAC;AAEpE,MAAM,WAAW,UAAU;IACzB,2FAA2F;IAC3F,OAAO,EAAE,cAAc,EAAE,CAAC;IAC1B,MAAM,EAAE,OAAO,CAAC;CACjB;AAED,eAAO,MAAM,oBAAoB;;kBAE/B,CAAC;AAEH,eAAO,MAAM,gBAAgB;;;;;;;;;;;;kBAU3B,CAAC;AAEH,eAAO,MAAM,kBAAkB;;;;;;;;;kBAW7B,CAAC;AAEH,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;kBAW9B,CAAC;AAEH,eAAO,MAAM,kBAAkB;;;;;kBAK7B,CAAC;AAEH,eAAO,MAAM,uBAAuB;;;kBAGlC,CAAC"}
package/dist/inputs.js ADDED
@@ -0,0 +1,116 @@
1
+ import { z } from 'zod';
2
+ import { harnessOfAlias } from './registry.js';
3
+ import { DELIVERY_STATES, JOB_STATES, JobBudgetSchema, JobCheckSchema, LETTER_KINDS, } from './types.js';
4
+ /** An id a sender may give its letter, so sending it again does not deliver it twice. */
5
+ export const LetterIdSchema = z
6
+ .string()
7
+ .trim()
8
+ .min(1)
9
+ .max(128)
10
+ .regex(/^[A-Za-z0-9._:-]+$/, 'A letter id takes letters, digits, ".", "_", ":" and "-"');
11
+ const JobNumberSchema = z.number().int().positive();
12
+ const NO_CONTROL = /^[^\p{Cc}]*$/u;
13
+ /**
14
+ * A NUL character cannot be handed to a harness: no command line argument holds one, so a
15
+ * letter with it would never leave the queue.
16
+ */
17
+ const withoutNul = (text) => !text.includes('\0');
18
+ const NUL_REFUSED = 'The text has a NUL character, which no harness takes';
19
+ export const CreateJobInputSchema = z.strictObject({
20
+ to: z.string().trim().min(1).max(512).regex(NO_CONTROL, 'An address is one line'),
21
+ body: z
22
+ .string()
23
+ .refine((body) => body.trim().length > 0, 'The job needs a description')
24
+ .refine(withoutNul, NUL_REFUSED),
25
+ title: z.string().trim().min(1).max(200).regex(NO_CONTROL, 'A title is one line').optional(),
26
+ cwd: z.string().min(1).max(4096).optional(),
27
+ checks: z.array(JobCheckSchema).max(50).optional(),
28
+ budget: JobBudgetSchema.partial().optional(),
29
+ parent: JobNumberSchema.optional(),
30
+ letterId: LetterIdSchema.optional(),
31
+ });
32
+ const SENDABLE_KINDS = LETTER_KINDS.filter((kind) => kind !== 'task');
33
+ export const SendLetterInputSchema = z
34
+ .strictObject({
35
+ job: JobNumberSchema,
36
+ kind: z.enum(SENDABLE_KINDS),
37
+ body: z
38
+ .string()
39
+ .refine((body) => body.trim().length > 0, 'The letter is empty')
40
+ .refine(withoutNul, NUL_REFUSED),
41
+ id: LetterIdSchema.optional(),
42
+ inReplyTo: LetterIdSchema.optional(),
43
+ outcome: z.enum(['completed', 'failed']).optional(),
44
+ })
45
+ .refine((input) => input.outcome === undefined || input.kind === 'report', {
46
+ message: 'Only a report has an outcome',
47
+ path: ['outcome'],
48
+ });
49
+ /** How many letters one call to the inbox returns when it names no limit. */
50
+ export const DEFAULT_INBOX_LIMIT = 20;
51
+ /** How many jobs, letters or journal entries one call returns when it names no limit. */
52
+ export const DEFAULT_LIST_LIMIT = 200;
53
+ export const InboxInputSchema = z.strictObject({
54
+ job: JobNumberSchema.optional(),
55
+ peek: z.boolean().optional(),
56
+ unhandled: z.boolean().optional(),
57
+ limit: z.number().int().positive().max(100).optional(),
58
+ afterSeq: z.number().int().nonnegative().optional(),
59
+ });
60
+ /** How long a call waits for mail when it names no time. */
61
+ export const DEFAULT_WAIT_MS = 10 * 60_000;
62
+ /** The longest one call waits for mail. */
63
+ export const MAX_WAIT_MS = 24 * 3_600_000;
64
+ export const WaitInputSchema = z.strictObject({
65
+ timeoutMs: z.number().int().positive().max(MAX_WAIT_MS).optional(),
66
+ limit: z.number().int().positive().max(100).optional(),
67
+ });
68
+ export const DeliveredInputSchema = z.strictObject({
69
+ letters: z.array(LetterIdSchema).min(1).max(100),
70
+ });
71
+ export const JobsFilterSchema = z.strictObject({
72
+ states: z.array(z.enum(JOB_STATES)).optional(),
73
+ from: z.string().optional(),
74
+ to: z.string().optional(),
75
+ party: z.string().optional(),
76
+ project: z.string().optional(),
77
+ parent: JobNumberSchema.optional(),
78
+ deadlineBy: z.number().int().nonnegative().optional(),
79
+ createdSince: z.number().int().nonnegative().optional(),
80
+ limit: z.number().int().positive().max(1000).optional(),
81
+ });
82
+ export const AgentsFilterSchema = z.strictObject({
83
+ project: z.string().optional(),
84
+ harness: z
85
+ .string()
86
+ .trim()
87
+ .min(1)
88
+ .max(64)
89
+ .transform((harness) => harnessOfAlias(harness))
90
+ .optional(),
91
+ statuses: z.array(z.enum(['starting', 'active', 'gone'])).optional(),
92
+ seenBefore: z.number().int().nonnegative().optional(),
93
+ });
94
+ export const LettersFilterSchema = z.strictObject({
95
+ job: JobNumberSchema.optional(),
96
+ from: z.string().optional(),
97
+ to: z.string().optional(),
98
+ states: z.array(z.enum(DELIVERY_STATES)).optional(),
99
+ kinds: z.array(z.enum(LETTER_KINDS)).optional(),
100
+ afterSeq: z.number().int().nonnegative().optional(),
101
+ replyDueBy: z.number().int().nonnegative().optional(),
102
+ attemptsBelow: z.number().int().nonnegative().optional(),
103
+ limit: z.number().int().positive().max(1000).optional(),
104
+ newestFirst: z.boolean().optional(),
105
+ });
106
+ export const JournalQuerySchema = z.strictObject({
107
+ afterSeq: z.number().int().nonnegative().optional(),
108
+ job: JobNumberSchema.optional(),
109
+ limit: z.number().int().positive().max(5000).optional(),
110
+ tail: z.number().int().positive().max(5000).optional(),
111
+ });
112
+ export const VerificationInputSchema = z.strictObject({
113
+ verified: z.boolean(),
114
+ summary: z.string().max(20_000).optional(),
115
+ });
116
+ //# sourceMappingURL=inputs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"inputs.js","sourceRoot":"","sources":["../src/inputs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EACL,eAAe,EACf,UAAU,EACV,eAAe,EACf,cAAc,EACd,YAAY,GAQb,MAAM,YAAY,CAAC;AAEpB,yFAAyF;AACzF,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC;KAC5B,MAAM,EAAE;KACR,IAAI,EAAE;KACN,GAAG,CAAC,CAAC,CAAC;KACN,GAAG,CAAC,GAAG,CAAC;KACR,KAAK,CAAC,oBAAoB,EAAE,0DAA0D,CAAC,CAAC;AAE3F,MAAM,eAAe,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE,CAAC;AAEpD,MAAM,UAAU,GAAG,eAAe,CAAC;AAEnC;;;GAGG;AACH,MAAM,UAAU,GAAG,CAAC,IAAY,EAAW,EAAE,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;AACnE,MAAM,WAAW,GAAG,sDAAsD,CAAC;AAE3E,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,CAAC,YAAY,CAAC;IACjD,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,UAAU,EAAE,wBAAwB,CAAC;IACjF,IAAI,EAAE,CAAC;SACJ,MAAM,EAAE;SACR,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,MAAM,GAAG,CAAC,EAAE,6BAA6B,CAAC;SACvE,MAAM,C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M,EAAE,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE;IACvD,WAAW,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE;CACpC,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,CAAC,YAAY,CAAC;IAC/C,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,WAAW,EAAE,CAAC,QAAQ,EAAE;IACnD,GAAG,EAAE,eAAe,CAAC,QAAQ,EAAE;IAC/B,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE;IACvD,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE;CACvD,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAAC,CAAC,YAAY,CAAC;IACpD,QAAQ,EAAE,CAAC,CAAC,OAAO,EAAE;IACrB,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,QAAQ,EAAE;CAC3C,CAAC,CAAC"}
@@ -0,0 +1,47 @@
1
+ import { z } from 'zod';
2
+ import type { A2ATask } from '@cogitator-ai/a2a';
3
+ import { type BridgeJob, type BridgeJobRecord, type JobState } from './types.js';
4
+ /** The record of a job as it lies in the metadata of its A2A task. */
5
+ export declare const BridgeJobRecordSchema: z.ZodObject<{
6
+ number: z.ZodNumber;
7
+ title: z.ZodString;
8
+ from: z.ZodString;
9
+ to: z.ZodString;
10
+ project: z.ZodString;
11
+ cwd: z.ZodString;
12
+ worktree: z.ZodOptional<z.ZodString>;
13
+ checks: z.ZodArray<z.ZodObject<{
14
+ name: z.ZodOptional<z.ZodString>;
15
+ command: z.ZodString;
16
+ cwd: z.ZodOptional<z.ZodString>;
17
+ timeoutMs: z.ZodOptional<z.ZodNumber>;
18
+ }, z.core.$strip>>;
19
+ budget: z.ZodObject<{
20
+ letters: z.ZodNumber;
21
+ durationMs: z.ZodNumber;
22
+ replyTimeoutMs: z.ZodNumber;
23
+ }, z.core.$strip>;
24
+ lettersUsed: z.ZodNumber;
25
+ depth: z.ZodNumber;
26
+ parent: z.ZodOptional<z.ZodNumber>;
27
+ createdAt: z.ZodString;
28
+ deadlineAt: z.ZodString;
29
+ reason: z.ZodOptional<z.ZodString>;
30
+ verification: z.ZodOptional<z.ZodObject<{
31
+ verified: z.ZodBoolean;
32
+ checkedAt: z.ZodString;
33
+ summary: z.ZodOptional<z.ZodString>;
34
+ }, z.core.$strip>>;
35
+ }, z.core.$strip>;
36
+ /** The bridge's record of the job a task is, or undefined for a task that is not a job. */
37
+ export declare function jobRecordOf(task: Pick<A2ATask, 'metadata'>): BridgeJobRecord | undefined;
38
+ /**
39
+ * The state of a job from the state of its task. A task of the bridge only takes the states of
40
+ * {@link JobState}: `rejected` and anything else a foreign writer left read as `failed`, and a
41
+ * task waiting for credentials (`auth-required`) as waiting for input.
42
+ */
43
+ export declare function jobStateOf(task: Pick<A2ATask, 'status'>): JobState;
44
+ /** The job a task is, or undefined for a task that is not a job. */
45
+ export declare function jobOf(task: A2ATask): BridgeJob | undefined;
46
+ export declare function isFinishedJobState(state: JobState): boolean;
47
+ //# sourceMappingURL=job-record.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"job-record.d.ts","sourceRoot":"","sources":["../src/job-record.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAEjD,OAAO,EAKL,KAAK,SAAS,EACd,KAAK,eAAe,EACpB,KAAK,QAAQ,EACd,MAAM,YAAY,CAAC;AAQpB,sEAAsE;AACtE,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAiBhC,CAAC;AAEH,2FAA2F;AAC3F,wBAAgB,WAAW,CAAC,IAAI,EAAE,IAAI,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,eAAe,GAAG,SAAS,CAKxF;AAMD;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,IAAI,CAAC,OAAO,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAIlE;AAED,oEAAoE;AACpE,wBAAgB,KAAK,CAAC,IAAI,EAAE,OAAO,GAAG,SAAS,GAAG,SAAS,CAS1D;AAED,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,QAAQ,GAAG,OAAO,CAE3D"}
@@ -0,0 +1,65 @@
1
+ import { z } from 'zod';
2
+ import { taskTime } from '@cogitator-ai/a2a';
3
+ import { BRIDGE_JOB_KEY, JOB_STATES, JobBudgetSchema, JobCheckSchema, } from './types.js';
4
+ const JobVerificationSchema = z.object({
5
+ verified: z.boolean(),
6
+ checkedAt: z.string(),
7
+ summary: z.string().optional(),
8
+ });
9
+ /** The record of a job as it lies in the metadata of its A2A task. */
10
+ export const BridgeJobRecordSchema = z.object({
11
+ number: z.number().int().positive(),
12
+ title: z.string(),
13
+ from: z.string(),
14
+ to: z.string(),
15
+ project: z.string(),
16
+ cwd: z.string(),
17
+ worktree: z.string().optional(),
18
+ checks: z.array(JobCheckSchema),
19
+ budget: JobBudgetSchema,
20
+ lettersUsed: z.number().int().nonnegative(),
21
+ depth: z.number().int().positive(),
22
+ parent: z.number().int().positive().optional(),
23
+ createdAt: z.string(),
24
+ deadlineAt: z.string(),
25
+ reason: z.string().optional(),
26
+ verification: JobVerificationSchema.optional(),
27
+ });
28
+ /** The bridge's record of the job a task is, or undefined for a task that is not a job. */
29
+ export function jobRecordOf(task) {
30
+ const raw = task.metadata?.[BRIDGE_JOB_KEY];
31
+ if (raw === undefined)
32
+ return undefined;
33
+ const parsed = BridgeJobRecordSchema.safeParse(raw);
34
+ return parsed.success ? parsed.data : undefined;
35
+ }
36
+ function isJobState(state) {
37
+ return JOB_STATES.includes(state);
38
+ }
39
+ /**
40
+ * The state of a job from the state of its task. A task of the bridge only takes the states of
41
+ * {@link JobState}: `rejected` and anything else a foreign writer left read as `failed`, and a
42
+ * task waiting for credentials (`auth-required`) as waiting for input.
43
+ */
44
+ export function jobStateOf(task) {
45
+ const state = task.status.state;
46
+ if (isJobState(state))
47
+ return state;
48
+ return state === 'auth-required' ? 'input-required' : 'failed';
49
+ }
50
+ /** The job a task is, or undefined for a task that is not a job. */
51
+ export function jobOf(task) {
52
+ const record = jobRecordOf(task);
53
+ if (!record)
54
+ return undefined;
55
+ return {
56
+ ...record,
57
+ taskId: task.id,
58
+ state: jobStateOf(task),
59
+ updatedAt: new Date(taskTime(task)).toISOString(),
60
+ };
61
+ }
62
+ export function isFinishedJobState(state) {
63
+ return state === 'completed' || state === 'failed' || state === 'canceled';
64
+ }
65
+ //# sourceMappingURL=job-record.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"job-record.js","sourceRoot":"","sources":["../src/job-record.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EACL,cAAc,EACd,UAAU,EACV,eAAe,EACf,cAAc,GAIf,MAAM,YAAY,CAAC;AAEpB,MAAM,qBAAqB,GAAG,CAAC,CAAC,MAAM,CAAC;IACrC,QAAQ,EAAE,CAAC,CAAC,OAAO,EAAE;IACrB,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE;IACrB,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;CAC/B,CAAC,CAAC;AAEH,sEAAsE;AACtE,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC5C,M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S,CAAC;AAClD,CAAC;AAED,SAAS,UAAU,CAAC,KAAa;IAC/B,OAAQ,UAAgC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;AAC3D,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,UAAU,CAAC,IAA6B;IACtD,MAAM,KAAK,GAAG,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC;IAChC,IAAI,UAAU,CAAC,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC;IACpC,OAAO,KAAK,KAAK,eAAe,CAAC,CAAC,CAAC,gBAAgB,CAAC,CAAC,CAAC,QAAQ,CAAC;AACjE,CAAC;AAED,oEAAoE;AACpE,MAAM,UAAU,KAAK,CAAC,IAAa;IACjC,MAAM,MAAM,GAAG,WAAW,CAAC,IAAI,CAAC,CAAC;IACjC,IAAI,CAAC,MAAM;QAAE,OAAO,SAAS,CAAC;IAC9B,OAAO;QACL,GAAG,MAAM;QACT,MAAM,EAAE,IAAI,CAAC,EAAE;QACf,KAAK,EAAE,UAAU,CAAC,IAAI,CAAC;QACvB,SAAS,EAAE,IAAI,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,WAAW,EAAE;KAClD,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,kBAAkB,CAAC,KAAe;IAChD,OAAO,KAAK,KAAK,WAAW,IAAI,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,UAAU,CAAC;AAC7E,CAAC"}
@@ -0,0 +1,49 @@
1
+ import { type BridgeJob, type Letter, type LetterKind, type RenderedLetter } from './types.js';
2
+ /** What the bridge waits for after a letter: its recipient taking it, an answer, or nothing. */
3
+ export type LetterExpectation = 'pickup' | 'reply' | 'none';
4
+ export declare function expectationOf(kind: LetterKind): LetterExpectation;
5
+ export declare function newLetterId(): string;
6
+ /**
7
+ * The text on one line: runs of spaces, line breaks and control characters become one space, and
8
+ * characters that are not shown but change how text is drawn (direction overrides, zero-width
9
+ * signs) are dropped.
10
+ */
11
+ export declare function oneLine(text: string): string;
12
+ /** The first line of a body, cut to fit a title. */
13
+ export declare function titleOf(body: string): string;
14
+ /** What every signature line starts with. No other line of a letter may start with it. */
15
+ export declare const SIGNATURE_MARK = "[agent bridge]";
16
+ /**
17
+ * Text written by an agent, set apart as a quote: every line starts with `> `. The bridge quotes
18
+ * what it repeats in its own notes, so words of an agent never read as words of the bridge.
19
+ */
20
+ export declare function quoted(text: string): string;
21
+ /**
22
+ * The line every letter starts with for its recipient: which job it belongs to, what it is, who
23
+ * wrote it and to whom. In a harness window a letter looks like a message of the person at the
24
+ * keyboard, so the line also says it is not one. The title cannot add fields to the line: its
25
+ * line breaks, double quotes and `|` are replaced.
26
+ */
27
+ export declare function signatureOf(letter: Pick<Letter, 'id' | 'kind' | 'from' | 'to' | 'job'>, job: Pick<BridgeJob, 'title'>): string;
28
+ /**
29
+ * The letter as its recipient sees it: the signature line, then the body. Only the first line is
30
+ * a signature: a line of the body that starts like one is quoted, so a body cannot pass for a
31
+ * second letter. Lines are told apart by every kind of line break, and come out separated by
32
+ * a plain one.
33
+ */
34
+ export declare function renderLetter(letter: Letter, job: Pick<BridgeJob, 'title'>): RenderedLetter;
35
+ /**
36
+ * A letter's text for the history of the A2A task under its job: all of a short one, the start
37
+ * of a long one with where the rest is. The letters themselves are kept whole in the store, and
38
+ * a task that carried every body would be rewritten in full on each letter.
39
+ */
40
+ export declare function forHistory(body: string, letterId: string): string;
41
+ /** A body with the differences that do not change what it says removed. */
42
+ export declare function normalizeBody(body: string): string;
43
+ /**
44
+ * Whether a letter says what the one before it in the same direction said. Two letters that
45
+ * reply to different letters are not a repeat, whatever their words: the same "yes" may answer
46
+ * two questions.
47
+ */
48
+ export declare function repeats(previous: Pick<Letter, 'kind' | 'body' | 'inReplyTo'> | undefined, kind: LetterKind, body: string, inReplyTo?: string): boolean;
49
+ //# sourceMappingURL=letters.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"letters.d.ts","sourceRoot":"","sources":["../src/letters.ts"],"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GAAG,SAAS,EACjE,IAAI,EAAE,UAAU,EAChB,IAAI,EAAE,MAAM,EACZ,SAAS,CAAC,EAAE,MAAM,GACjB,OAAO,CAMT"}
@@ -0,0 +1,96 @@
1
+ import { randomUUID } from 'node:crypto';
2
+ import { BRIDGE_SENDER, } from './types.js';
3
+ export function expectationOf(kind) {
4
+ if (kind === 'task')
5
+ return 'pickup';
6
+ if (kind === 'question' || kind === 'permission')
7
+ return 'reply';
8
+ return 'none';
9
+ }
10
+ export function newLetterId() {
11
+ return `ltr_${randomUUID()}`;
12
+ }
13
+ const TITLE_LENGTH = 80;
14
+ /** Every way a text can start a new line, for a reader that draws any of them as one. */
15
+ const LINE_BREAK = /\r\n|[\n\r\u0085\u2028\u2029]/u;
16
+ /**
17
+ * The text on one line: runs of spaces, line breaks and control characters become one space, and
18
+ * characters that are not shown but change how text is drawn (direction overrides, zero-width
19
+ * signs) are dropped.
20
+ */
21
+ export function oneLine(text) {
22
+ return text
23
+ .replace(/\p{Cf}+/gu, '')
24
+ .replace(/[\s\p{Cc}\u2028\u2029]+/gu, ' ')
25
+ .trim();
26
+ }
27
+ /** The lines of a text, whatever it breaks them with. */
28
+ function linesOf(text) {
29
+ return text.split(LINE_BREAK);
30
+ }
31
+ /** The first line of a body, cut to fit a title. */
32
+ export function titleOf(body) {
33
+ const line = oneLine(body.trim().split('\n', 1)[0] ?? '');
34
+ return line.length > TITLE_LENGTH ? `${line.slice(0, TITLE_LENGTH - 3)}...` : line;
35
+ }
36
+ /** What every signature line starts with. No other line of a letter may start with it. */
37
+ export const SIGNATURE_MARK = '[agent bridge]';
38
+ /**
39
+ * Text written by an agent, set apart as a quote: every line starts with `> `. The bridge quotes
40
+ * what it repeats in its own notes, so words of an agent never read as words of the bridge.
41
+ */
42
+ export function quoted(text) {
43
+ return linesOf(text)
44
+ .map((line) => `> ${line}`)
45
+ .join('\n');
46
+ }
47
+ /**
48
+ * The line every letter starts with for its recipient: which job it belongs to, what it is, who
49
+ * wrote it and to whom. In a harness window a letter looks like a message of the person at the
50
+ * keyboard, so the line also says it is not one. The title cannot add fields to the line: its
51
+ * line breaks, double quotes and `|` are replaced.
52
+ */
53
+ export function signatureOf(letter, job) {
54
+ const sender = letter.from === BRIDGE_SENDER ? 'the bridge' : letter.from;
55
+ const title = oneLine(job.title).replaceAll('"', "'").replaceAll('|', '/');
56
+ return `${SIGNATURE_MARK} job #${letter.job} "${title}" | ${letter.kind} from ${sender} to ${letter.to} | letter ${letter.id} | not typed by the user`;
57
+ }
58
+ /**
59
+ * The letter as its recipient sees it: the signature line, then the body. Only the first line is
60
+ * a signature: a line of the body that starts like one is quoted, so a body cannot pass for a
61
+ * second letter. Lines are told apart by every kind of line break, and come out separated by
62
+ * a plain one.
63
+ */
64
+ export function renderLetter(letter, job) {
65
+ const body = linesOf(letter.body)
66
+ .map((line) => line.replace(/^[\s\p{Cf}\p{Cc}]+/u, '').startsWith(SIGNATURE_MARK) ? `> ${line}` : line)
67
+ .join('\n');
68
+ return { ...letter, text: `${signatureOf(letter, job)}\n${body}` };
69
+ }
70
+ /** How much of a letter the history of the A2A task under a job keeps. */
71
+ const HISTORY_LENGTH = 4_000;
72
+ /**
73
+ * A letter's text for the history of the A2A task under its job: all of a short one, the start
74
+ * of a long one with where the rest is. The letters themselves are kept whole in the store, and
75
+ * a task that carried every body would be rewritten in full on each letter.
76
+ */
77
+ export function forHistory(body, letterId) {
78
+ if (body.length <= HISTORY_LENGTH)
79
+ return body;
80
+ return `${body.slice(0, HISTORY_LENGTH)}\n[cut here, the whole text is in the letter ${letterId} of the bridge]`;
81
+ }
82
+ /** A body with the differences that do not change what it says removed. */
83
+ export function normalizeBody(body) {
84
+ return oneLine(body).toLowerCase();
85
+ }
86
+ /**
87
+ * Whether a letter says what the one before it in the same direction said. Two letters that
88
+ * reply to different letters are not a repeat, whatever their words: the same "yes" may answer
89
+ * two questions.
90
+ */
91
+ export function repeats(previous, kind, body, inReplyTo) {
92
+ return (previous?.kind === kind &&
93
+ previous.inReplyTo === inReplyTo &&
94
+ normalizeBody(previous.body) === normalizeBody(body));
95
+ }
96
+ //# sourceMappingURL=letters.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"letters.js","sourceRoot":"","sources":["../src/letters.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EACL,aAAa,GAKd,MAAM,YAAY,CAAC;AAKpB,MAAM,UAAU,aAAa,CAAC,IAAgB;IAC5C,IAAI,IAAI,KAAK,MAAM;QAAE,OAAO,QAAQ,CAAC;IACrC,IAAI,IAAI,KAAK,UAAU,IAAI,IAAI,KAAK,YAAY;QAAE,OAAO,OAAO,CAAC;IACjE,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,MAAM,UAAU,WAAW;IACzB,OAAO,OAAO,UAAU,EAAE,EAAE,CAAC;AAC/B,CAAC;AAED,MAAM,YAAY,GAAG,EAAE,CAAC;AAExB,yFAAyF;AACzF,MAAM,UAAU,GAAG,gCAAgC,CAAC;AAEpD;;;;GAIG;AACH,MAAM,UAAU,OAAO,CAAC,IAAY;IAClC,OAAO,IAAI;SACR,OAAO,CAAC,WAAW,EAAE,EAAE,CAAC;SACxB,OAAO,CAAC,2BAA2B,EAAE,GAAG,CAAC;SACzC,IAAI,EAAE,CAAC;AACZ,CAAC;AAED,yDAAyD;AACzD,SAAS,OAAO,CAAC,IAAY;IAC3B,OAAO,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;AAChC,CAAC;AAED,oDAAoD;AACpD,MAAM,UAAU,OAAO,CAAC,IAAY;IAClC,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;IAC1D,OAAO,IAAI,CAAC,MAAM,GAAG,YAAY,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,EAA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GAAG,MAAM,EAAE,IAAI,EAAE,GAAG,WAAW,CAAC,MAAM,EAAE,GAAG,CAAC,KAAK,IAAI,EAAE,EAAE,CAAC;AACrE,CAAC;AAED,0EAA0E;AAC1E,MAAM,cAAc,GAAG,KAAK,CAAC;AAE7B;;;;GAIG;AACH,MAAM,UAAU,UAAU,CAAC,IAAY,EAAE,QAAgB;IACvD,IAAI,IAAI,CAAC,MAAM,IAAI,cAAc;QAAE,OAAO,IAAI,CAAC;IAC/C,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,cAAc,CAAC,gDAAgD,QAAQ,iBAAiB,CAAC;AACnH,CAAC;AAED,2EAA2E;AAC3E,MAAM,UAAU,aAAa,CAAC,IAAY;IACxC,OAAO,OAAO,CAAC,IAAI,CAAC,CAAC,WAAW,EAAE,CAAC;AACrC,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,OAAO,CACrB,QAAiE,EACjE,IAAgB,EAChB,IAAY,EACZ,SAAkB;IAElB,OAAO,CACL,QAAQ,EAAE,IAAI,KAAK,IAAI;QACvB,QAAQ,CAAC,SAAS,KAAK,SAAS;QAChC,aAAa,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,aAAa,CAAC,IAAI,CAAC,CACrD,CAAC;AACJ,CAAC"}
@@ -0,0 +1,38 @@
1
+ /** Where the bridge of this machine keeps its files. */
2
+ export interface BridgePaths {
3
+ home: string;
4
+ database: string;
5
+ /** A unix socket path, or the name of a named pipe on Windows */
6
+ socket: string;
7
+ }
8
+ export interface BridgePathsOptions {
9
+ /** The folder of the files: `COGITATOR_BRIDGE_HOME` by default, else `~/.cogitator/bridge` */
10
+ home?: string;
11
+ env?: NodeJS.ProcessEnv;
12
+ platform?: NodeJS.Platform;
13
+ }
14
+ /**
15
+ * The files of the bridge: one folder per machine, shared by every project, so the sessions of
16
+ * all of them meet in one place.
17
+ */
18
+ export declare function bridgePaths(options?: BridgePathsOptions): BridgePaths;
19
+ /**
20
+ * One spelling for a folder however it was reached: absolute, and with the symlinks of as much
21
+ * of it as exists resolved, so `/tmp/app` and `/private/tmp/app` are the same project, and a
22
+ * folder not made yet inside either is inside both.
23
+ */
24
+ export declare function canonicalPath(path: string): string;
25
+ /** Whether `path` is `folder` or lies inside it. */
26
+ export declare function isInside(folder: string, path: string): boolean;
27
+ /**
28
+ * The checkout `cwd` is in: the nearest folder up the tree with a `.git`, the main checkout or a
29
+ * linked worktree alike. `cwd` itself when no folder up the tree is a repository.
30
+ */
31
+ export declare function findCheckoutRoot(cwd: string): string;
32
+ /**
33
+ * The root of the project `cwd` is in: the nearest folder up the tree with a `.git`, and for a
34
+ * linked git worktree the main checkout it belongs to, so every worktree of a repository is one
35
+ * project. `cwd` itself when no folder up the tree is a repository.
36
+ */
37
+ export declare function findProjectRoot(cwd: string): string;
38
+ //# sourceMappingURL=paths.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"paths.d.ts","sourceRoot":"","sources":["../src/paths.ts"],"names":[],"mappings":"AAKA,wDAAwD;AACxD,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,iEAAiE;IACjE,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,kBAAkB;IACjC,8FAA8F;IAC9F,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,GAAG,CAAC,EAAE,MAAM,CAAC,UAAU,CAAC;IACxB,QAAQ,CAAC,EAAE,MAAM,CAAC,QAAQ,CAAC;CAC5B;AAkBD;;;GAGG;AACH,wBAAgB,WAAW,CAAC,OAAO,GAAE,kBAAuB,GAAG,WAAW,CAazE;AAwDD;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAWlD;AAED,oDAAoD;AACpD,wBAAgB,QAAQ,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAI9D;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAMpD;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAQnD"}