@sift-wiki/conductor 0.2.0-beta.1 → 0.2.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 (95) hide show
  1. package/dist/adapters/claudeAgent.js +1 -0
  2. package/dist/adapters/claudeAgent.js.map +1 -1
  3. package/dist/adapters/codexAgent.js +1 -0
  4. package/dist/adapters/codexAgent.js.map +1 -1
  5. package/dist/adapters/fakeAgent.js +1 -0
  6. package/dist/adapters/fakeAgent.js.map +1 -1
  7. package/dist/adapters/httpAgent.js +1 -0
  8. package/dist/adapters/httpAgent.js.map +1 -1
  9. package/dist/adapters/processAgent.js +4 -0
  10. package/dist/adapters/processAgent.js.map +1 -1
  11. package/dist/adapters/provider/runProvider.js +4 -0
  12. package/dist/adapters/provider/runProvider.js.map +1 -1
  13. package/dist/adapters/provider/store.js +3 -4
  14. package/dist/adapters/provider/store.js.map +1 -1
  15. package/dist/adapters/types.d.ts +9 -0
  16. package/dist/cli.d.ts +6 -0
  17. package/dist/cli.js +16 -4
  18. package/dist/cli.js.map +1 -1
  19. package/dist/conductorClient.d.ts +56 -19
  20. package/dist/conductorClient.js +91 -40
  21. package/dist/conductorClient.js.map +1 -1
  22. package/dist/config.js +4 -5
  23. package/dist/config.js.map +1 -1
  24. package/dist/daemon.d.ts +19 -6
  25. package/dist/daemon.js +199 -121
  26. package/dist/daemon.js.map +1 -1
  27. package/dist/desktop/app/controller.d.ts +1 -1
  28. package/dist/desktop/app/runtimeController.d.ts +7 -0
  29. package/dist/desktop/app/runtimeController.js +12 -1
  30. package/dist/desktop/app/runtimeController.js.map +1 -1
  31. package/dist/localApi/contracts.d.ts +15 -4
  32. package/dist/localApi/contracts.js +19 -1
  33. package/dist/localApi/contracts.js.map +1 -1
  34. package/dist/localApi/recovery.d.ts +66 -0
  35. package/dist/localApi/recovery.js +118 -0
  36. package/dist/localApi/recovery.js.map +1 -0
  37. package/dist/localApi/server.js +3 -1
  38. package/dist/localApi/server.js.map +1 -1
  39. package/dist/localApp/service.js +16 -4
  40. package/dist/localApp/service.js.map +1 -1
  41. package/dist/protocol/fenced.d.ts +135 -0
  42. package/dist/protocol/fenced.js +142 -0
  43. package/dist/protocol/fenced.js.map +1 -0
  44. package/dist/redaction.js +2 -0
  45. package/dist/redaction.js.map +1 -1
  46. package/dist/runtime/atomicFile.d.ts +6 -0
  47. package/dist/runtime/atomicFile.js +78 -0
  48. package/dist/runtime/atomicFile.js.map +1 -0
  49. package/dist/runtime/daemonCapabilities.d.ts +7 -0
  50. package/dist/runtime/daemonCapabilities.js +24 -0
  51. package/dist/runtime/daemonCapabilities.js.map +1 -0
  52. package/dist/runtime/eventOutbox.d.ts +100 -0
  53. package/dist/runtime/eventOutbox.js +206 -0
  54. package/dist/runtime/eventOutbox.js.map +1 -0
  55. package/dist/runtime/executionJournal.d.ts +102 -0
  56. package/dist/runtime/executionJournal.js +209 -0
  57. package/dist/runtime/executionJournal.js.map +1 -0
  58. package/dist/runtime/executionSafety.d.ts +76 -0
  59. package/dist/runtime/executionSafety.js +207 -0
  60. package/dist/runtime/executionSafety.js.map +1 -0
  61. package/dist/runtime/fencedExecutionState.d.ts +43 -0
  62. package/dist/runtime/fencedExecutionState.js +158 -0
  63. package/dist/runtime/fencedExecutionState.js.map +1 -0
  64. package/dist/runtime/leaseManager.d.ts +38 -0
  65. package/dist/runtime/leaseManager.js +102 -0
  66. package/dist/runtime/leaseManager.js.map +1 -0
  67. package/dist/runtime/localRunQueue.d.ts +1 -1
  68. package/dist/runtime/localRunQueue.js +8 -0
  69. package/dist/runtime/localRunQueue.js.map +1 -1
  70. package/dist/runtime/localSessionCache.d.ts +1 -1
  71. package/dist/runtime/localSessionCache.js.map +1 -1
  72. package/dist/runtime/process.d.ts +13 -1
  73. package/dist/runtime/process.js +39 -9
  74. package/dist/runtime/process.js.map +1 -1
  75. package/dist/runtime/recoveryCoordinator.d.ts +19 -0
  76. package/dist/runtime/recoveryCoordinator.js +183 -0
  77. package/dist/runtime/recoveryCoordinator.js.map +1 -0
  78. package/dist/runtime/runtimeLock.d.ts +33 -0
  79. package/dist/runtime/runtimeLock.js +140 -0
  80. package/dist/runtime/runtimeLock.js.map +1 -0
  81. package/dist/runtime/runtimeService.d.ts +6 -1
  82. package/dist/runtime/runtimeService.js +54 -20
  83. package/dist/runtime/runtimeService.js.map +1 -1
  84. package/dist/runtime/taskExecution.d.ts +4 -0
  85. package/dist/runtime/taskExecution.js +32 -12
  86. package/dist/runtime/taskExecution.js.map +1 -1
  87. package/dist/types.d.ts +28 -13
  88. package/dist/version.d.ts +1 -1
  89. package/dist/version.js +1 -1
  90. package/dist/version.js.map +1 -1
  91. package/dist/workTypes.d.ts +5 -5
  92. package/dist-web/assets/index-SwT063kc.js +72 -0
  93. package/dist-web/index.html +2 -2
  94. package/package.json +1 -1
  95. package/dist-web/assets/index-D5X9InfE.js +0 -72
@@ -0,0 +1,135 @@
1
+ import { z } from "zod";
2
+ import type { JsonObject } from "../types.js";
3
+ export declare const FENCED_ATTEMPTS_CAPABILITY = "fenced-attempts-v1";
4
+ export declare const attemptAuthoritySchema: z.ZodObject<{
5
+ attemptId: z.ZodString;
6
+ leaseGeneration: z.ZodNumber;
7
+ leaseExpiresAt: z.ZodISODateTime;
8
+ mustStopAt: z.ZodISODateTime;
9
+ }, z.core.$strict>;
10
+ export declare const attemptAuthorityFenceSchema: z.ZodObject<{
11
+ attemptId: z.ZodString;
12
+ leaseGeneration: z.ZodNumber;
13
+ }, z.core.$strict>;
14
+ export declare const clientEventIdentitySchema: z.ZodObject<{
15
+ clientEventId: z.ZodString;
16
+ clientSequence: z.ZodNumber;
17
+ }, z.core.$strict>;
18
+ export declare const reconciliationDecisionSchema: z.ZodEnum<{
19
+ resume: "resume";
20
+ stop: "stop";
21
+ superseded: "superseded";
22
+ already_terminal: "already_terminal";
23
+ retry_as_new_attempt: "retry_as_new_attempt";
24
+ }>;
25
+ export declare const reconcileAttemptRequestSchema: z.ZodObject<{
26
+ attemptId: z.ZodString;
27
+ leaseGeneration: z.ZodNumber;
28
+ lastAcknowledgedClientSequence: z.ZodNumber;
29
+ providerResumeSupported: z.ZodBoolean;
30
+ supervisedProcessRunning: z.ZodBoolean;
31
+ terminalResult: z.ZodOptional<z.ZodObject<{
32
+ disposition: z.ZodEnum<{
33
+ cancelled: "cancelled";
34
+ completed: "completed";
35
+ failed: "failed";
36
+ }>;
37
+ summary: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
38
+ }, z.core.$strict>>;
39
+ }, z.core.$strict>;
40
+ export declare const reconcileAttemptResponseSchema: z.ZodObject<{
41
+ decision: z.ZodEnum<{
42
+ resume: "resume";
43
+ stop: "stop";
44
+ superseded: "superseded";
45
+ already_terminal: "already_terminal";
46
+ retry_as_new_attempt: "retry_as_new_attempt";
47
+ }>;
48
+ authority: z.ZodOptional<z.ZodObject<{
49
+ attemptId: z.ZodString;
50
+ leaseGeneration: z.ZodNumber;
51
+ leaseExpiresAt: z.ZodISODateTime;
52
+ mustStopAt: z.ZodISODateTime;
53
+ }, z.core.$strict>>;
54
+ lastAcknowledgedClientSequence: z.ZodNumber;
55
+ canonicalStatus: z.ZodString;
56
+ cancellationRequested: z.ZodBoolean;
57
+ reason: z.ZodOptional<z.ZodString>;
58
+ }, z.core.$strip>;
59
+ export declare const settlementResultSchema: z.ZodObject<{
60
+ attemptId: z.ZodString;
61
+ idempotencyKey: z.ZodString;
62
+ disposition: z.ZodEnum<{
63
+ cancelled: "cancelled";
64
+ completed: "completed";
65
+ failed: "failed";
66
+ }>;
67
+ payloadDigest: z.ZodString;
68
+ terminalAt: z.ZodISODateTime;
69
+ repeated: z.ZodBoolean;
70
+ }, z.core.$strict>;
71
+ export declare const fencedSettlementResponseSchema: z.ZodObject<{
72
+ job: z.ZodObject<{
73
+ id: z.ZodString;
74
+ status: z.ZodEnum<{
75
+ cancelled: "cancelled";
76
+ completed: "completed";
77
+ failed: "failed";
78
+ }>;
79
+ }, z.core.$loose>;
80
+ settlement: z.ZodObject<{
81
+ attemptId: z.ZodString;
82
+ idempotencyKey: z.ZodString;
83
+ disposition: z.ZodEnum<{
84
+ cancelled: "cancelled";
85
+ completed: "completed";
86
+ failed: "failed";
87
+ }>;
88
+ payloadDigest: z.ZodString;
89
+ terminalAt: z.ZodISODateTime;
90
+ repeated: z.ZodBoolean;
91
+ }, z.core.$strict>;
92
+ }, z.core.$strict>;
93
+ export declare const eventAcknowledgementSchema: z.ZodObject<{
94
+ eventId: z.ZodString;
95
+ attemptId: z.ZodString;
96
+ clientEventId: z.ZodString;
97
+ clientSequence: z.ZodNumber;
98
+ acknowledgedClientSequence: z.ZodNumber;
99
+ serverSequence: z.ZodNumber;
100
+ repeated: z.ZodBoolean;
101
+ }, z.core.$strict>;
102
+ export declare const lateResultRequestSchema: z.ZodObject<{
103
+ idempotencyKey: z.ZodString;
104
+ summary: z.ZodRecord<z.ZodString, z.ZodUnknown>;
105
+ artifactId: z.ZodOptional<z.ZodString>;
106
+ brainRecordId: z.ZodOptional<z.ZodString>;
107
+ }, z.core.$strict>;
108
+ export declare const lateResultResponseSchema: z.ZodObject<{
109
+ lateResult: z.ZodObject<{
110
+ id: z.ZodString;
111
+ attemptId: z.ZodString;
112
+ reviewStatus: z.ZodLiteral<"pending">;
113
+ }, z.core.$loose>;
114
+ repeated: z.ZodBoolean;
115
+ }, z.core.$strict>;
116
+ export type AttemptAuthority = z.infer<typeof attemptAuthoritySchema>;
117
+ export type AttemptAuthorityFence = z.infer<typeof attemptAuthorityFenceSchema>;
118
+ export type ClientEventIdentity = z.infer<typeof clientEventIdentitySchema>;
119
+ export type ReconciliationDecision = z.infer<typeof reconciliationDecisionSchema>;
120
+ export type ReconcileAttemptRequest = z.infer<typeof reconcileAttemptRequestSchema>;
121
+ export type ReconcileAttemptResponse = z.infer<typeof reconcileAttemptResponseSchema>;
122
+ export type EventAcknowledgement = z.infer<typeof eventAcknowledgementSchema>;
123
+ export type FencedSettlementResponse = z.infer<typeof fencedSettlementResponseSchema>;
124
+ export type LateResultRequest = z.input<typeof lateResultRequestSchema>;
125
+ export type LateResultResponse = z.infer<typeof lateResultResponseSchema>;
126
+ export type AttemptMutationOptions = {
127
+ authority?: AttemptAuthorityFence | undefined;
128
+ idempotencyKey?: string | undefined;
129
+ };
130
+ export type ApiFailureDisposition = "retryable" | "authentication" | "authority_lost" | "conflict" | "invalid_request";
131
+ export declare function classifyApiFailure(status: number, code: string): ApiFailureDisposition;
132
+ export declare function fencedMutationBody<T extends JsonObject>(body: T, options?: AttemptMutationOptions): T & Partial<AttemptAuthorityFence & {
133
+ idempotencyKey: string;
134
+ }>;
135
+ export declare function authorityFence(authority: AttemptAuthorityFence): AttemptAuthorityFence;
@@ -0,0 +1,142 @@
1
+ import { z } from "zod";
2
+ export const FENCED_ATTEMPTS_CAPABILITY = "fenced-attempts-v1";
3
+ export const attemptAuthoritySchema = z.object({
4
+ attemptId: z.string().min(1),
5
+ leaseGeneration: z.number().int().positive(),
6
+ leaseExpiresAt: z.iso.datetime(),
7
+ mustStopAt: z.iso.datetime(),
8
+ }).strict();
9
+ export const attemptAuthorityFenceSchema = attemptAuthoritySchema.pick({
10
+ attemptId: true,
11
+ leaseGeneration: true,
12
+ }).strict();
13
+ export const clientEventIdentitySchema = z.object({
14
+ clientEventId: z.string().min(1).max(200),
15
+ clientSequence: z.number().int().positive(),
16
+ }).strict();
17
+ export const reconciliationDecisionSchema = z.enum([
18
+ "resume",
19
+ "stop",
20
+ "superseded",
21
+ "already_terminal",
22
+ "retry_as_new_attempt",
23
+ ]);
24
+ export const reconcileAttemptRequestSchema = z.object({
25
+ attemptId: z.string().min(1),
26
+ leaseGeneration: z.number().int().positive(),
27
+ lastAcknowledgedClientSequence: z.number().int().nonnegative(),
28
+ providerResumeSupported: z.boolean(),
29
+ supervisedProcessRunning: z.boolean(),
30
+ terminalResult: z.object({
31
+ disposition: z.enum(["completed", "failed", "cancelled"]),
32
+ summary: z.record(z.string(), z.unknown()).optional(),
33
+ }).strict().optional(),
34
+ }).strict();
35
+ export const reconcileAttemptResponseSchema = z.object({
36
+ decision: reconciliationDecisionSchema,
37
+ authority: attemptAuthoritySchema.optional(),
38
+ lastAcknowledgedClientSequence: z.number().int().nonnegative(),
39
+ canonicalStatus: z.string().min(1),
40
+ cancellationRequested: z.boolean(),
41
+ reason: z.string().min(1).max(1_000).optional(),
42
+ }).superRefine((value, context) => {
43
+ if ((value.decision === "resume" || value.decision === "retry_as_new_attempt") &&
44
+ value.authority === undefined) {
45
+ context.addIssue({
46
+ code: "custom",
47
+ message: value.decision === "resume"
48
+ ? "A resume reconciliation decision requires refreshed authority."
49
+ : "A retry-as-new-attempt decision requires replacement authority.",
50
+ path: ["authority"],
51
+ });
52
+ }
53
+ if (value.decision !== "resume" &&
54
+ value.decision !== "retry_as_new_attempt" &&
55
+ value.authority !== undefined) {
56
+ context.addIssue({
57
+ code: "custom",
58
+ message: "Only a resume or retry-as-new-attempt decision may grant authority.",
59
+ path: ["authority"],
60
+ });
61
+ }
62
+ });
63
+ export const settlementResultSchema = z.object({
64
+ attemptId: z.string().min(1),
65
+ idempotencyKey: z.string().min(1).max(200),
66
+ disposition: z.enum(["completed", "failed", "cancelled"]),
67
+ payloadDigest: z.string().min(1),
68
+ terminalAt: z.iso.datetime(),
69
+ repeated: z.boolean(),
70
+ }).strict();
71
+ export const fencedSettlementResponseSchema = z.object({
72
+ job: z.looseObject({
73
+ id: z.string().min(1),
74
+ status: z.enum(["completed", "failed", "cancelled"]),
75
+ }),
76
+ settlement: settlementResultSchema,
77
+ }).strict();
78
+ export const eventAcknowledgementSchema = z.object({
79
+ eventId: z.string().min(1),
80
+ attemptId: z.string().min(1),
81
+ clientEventId: z.string().min(1).max(200),
82
+ clientSequence: z.number().int().positive(),
83
+ acknowledgedClientSequence: z.number().int().nonnegative(),
84
+ serverSequence: z.number().int().positive(),
85
+ repeated: z.boolean(),
86
+ }).strict();
87
+ export const lateResultRequestSchema = z.object({
88
+ idempotencyKey: z.string().min(1).max(200),
89
+ summary: z.record(z.string(), z.unknown()),
90
+ artifactId: z.string().min(1).optional(),
91
+ brainRecordId: z.string().min(1).optional(),
92
+ }).strict();
93
+ export const lateResultResponseSchema = z.object({
94
+ lateResult: z.object({
95
+ id: z.string().min(1),
96
+ attemptId: z.string().min(1),
97
+ reviewStatus: z.literal("pending"),
98
+ }).loose(),
99
+ repeated: z.boolean(),
100
+ }).strict();
101
+ const AUTHORITY_ERROR_CODES = new Set([
102
+ "stale_attempt",
103
+ "stale_generation",
104
+ "authority_expired",
105
+ "deadline_exceeded",
106
+ "run_cancelled",
107
+ "attempt_superseded",
108
+ "already_terminal",
109
+ ]);
110
+ export function classifyApiFailure(status, code) {
111
+ if (status === 0 || status === 408 || status === 425 || status === 429 || status >= 500) {
112
+ return "retryable";
113
+ }
114
+ if (status === 401 || status === 403) {
115
+ return "authentication";
116
+ }
117
+ if (AUTHORITY_ERROR_CODES.has(code)) {
118
+ return "authority_lost";
119
+ }
120
+ if (status === 409) {
121
+ return "conflict";
122
+ }
123
+ return "invalid_request";
124
+ }
125
+ export function fencedMutationBody(body, options) {
126
+ return {
127
+ ...body,
128
+ ...(options?.authority === undefined
129
+ ? {}
130
+ : authorityFence(options.authority)),
131
+ ...(options?.idempotencyKey === undefined
132
+ ? {}
133
+ : { idempotencyKey: z.string().min(1).max(200).parse(options.idempotencyKey) }),
134
+ };
135
+ }
136
+ export function authorityFence(authority) {
137
+ return attemptAuthorityFenceSchema.parse({
138
+ attemptId: authority.attemptId,
139
+ leaseGeneration: authority.leaseGeneration,
140
+ });
141
+ }
142
+ //# sourceMappingURL=fenced.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fenced.js","sourceRoot":"","sources":["../../src/protocol/fenced.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,MAAM,CAAC,MAAM,0BAA0B,GAAG,oBAAoB,CAAC;AAE/D,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAA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AAC;QACtC,GAAG,CAAC,OAAO,EAAE,cAAc,KAAK,SAAS;YACvC,CAAC,CAAC,EAAE;YACJ,CAAC,CAAC,EAAE,cAAc,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,cAAc,CAAC,EAAE,CAAC;KAClF,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,SAAgC;IAC7D,OAAO,2BAA2B,CAAC,KAAK,CAAC;QACvC,SAAS,EAAE,SAAS,CAAC,SAAS;QAC9B,eAAe,EAAE,SAAS,CAAC,eAAe;KAC3C,CAAC,CAAC;AACL,CAAC"}
package/dist/redaction.js CHANGED
@@ -1,5 +1,6 @@
1
1
  const CONDUCTOR_CREDENTIAL_PATTERN = /sift_conductor_([^:\s]+):([^\s]+)/gu;
2
2
  const PAIRING_CODE_PATTERN = /\bSC-[A-Za-z0-9_-]+\b/gu;
3
+ const PROVIDER_SECRET_PATTERN = /\b(?:sk-[A-Za-z0-9_-]{8,}|gh[pousr]_[A-Za-z0-9_-]{8,})\b/gu;
3
4
  const HOME_PATH_PATTERNS = [
4
5
  {
5
6
  regex: /\/Users\/([^/\\\s]+)/gu,
@@ -17,6 +18,7 @@ const HOME_PATH_PATTERNS = [
17
18
  export function redactSecrets(input) {
18
19
  let redacted = input.replace(CONDUCTOR_CREDENTIAL_PATTERN, "sift_conductor_$1:<redacted>");
19
20
  redacted = redacted.replace(PAIRING_CODE_PATTERN, "SC-<redacted>");
21
+ redacted = redacted.replace(PROVIDER_SECRET_PATTERN, "<provider-secret-redacted>");
20
22
  for (const pattern of HOME_PATH_PATTERNS) {
21
23
  redacted = redacted.replace(pattern.regex, pattern.replace);
22
24
  }
@@ -1 +1 @@
1
- {"version":3,"file":"redaction.js","sourceRoot":"","sources":["../src/redaction.ts"],"names":[],"mappings":"AAAA,MAAM,4BAA4B,GAAG,qCAAqC,CA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M,UAAU,gBAAgB,CAAC,UAAkB;IACjD,OAAO,aAAa,CAAC,UAAU,CAAC,CAAC;AACnC,CAAC;AAED,SAAS,eAAe,CAAC,KAAa;IACpC,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACvB,OAAO,GAAG,CAAC;IACb,CAAC;IACD,OAAO,GAAG,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,GAAG,GAAG,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;AAC7E,CAAC"}
@@ -0,0 +1,6 @@
1
+ export type AtomicWriteOptions = {
2
+ backup?: boolean | undefined;
3
+ writeTemporary?: ((filePath: string, contents: string) => Promise<void>) | undefined;
4
+ };
5
+ export declare function atomicWriteOwnerOnly(filePath: string, contents: string, options?: AtomicWriteOptions): Promise<void>;
6
+ export declare function isNodeError(error: unknown): error is NodeJS.ErrnoException;
@@ -0,0 +1,78 @@
1
+ import { randomUUID } from "node:crypto";
2
+ import { chmod, mkdir, open, readFile, rename, rm, } from "node:fs/promises";
3
+ import path from "node:path";
4
+ export async function atomicWriteOwnerOnly(filePath, contents, options = {}) {
5
+ const directory = path.dirname(filePath);
6
+ await mkdir(directory, { recursive: true, mode: 0o700 });
7
+ await chmod(directory, 0o700);
8
+ if (options.backup === true) {
9
+ const previous = await readOptional(filePath);
10
+ if (previous !== undefined) {
11
+ await replaceFile(`${filePath}.last-good`, previous, options.writeTemporary);
12
+ }
13
+ }
14
+ await replaceFile(filePath, contents, options.writeTemporary);
15
+ }
16
+ async function replaceFile(filePath, contents, writeTemporary) {
17
+ const temporaryPath = `${filePath}.${String(process.pid)}.${randomUUID()}.tmp`;
18
+ try {
19
+ if (writeTemporary === undefined) {
20
+ await writeAndSync(temporaryPath, contents);
21
+ }
22
+ else {
23
+ await writeTemporary(temporaryPath, contents);
24
+ await chmod(temporaryPath, 0o600);
25
+ }
26
+ await rename(temporaryPath, filePath);
27
+ await chmod(filePath, 0o600);
28
+ await syncDirectory(path.dirname(filePath));
29
+ }
30
+ catch (error) {
31
+ await rm(temporaryPath, { force: true }).catch(() => undefined);
32
+ throw error;
33
+ }
34
+ }
35
+ async function writeAndSync(filePath, contents) {
36
+ let handle;
37
+ try {
38
+ handle = await open(filePath, "wx", 0o600);
39
+ await handle.writeFile(contents, "utf8");
40
+ await handle.sync();
41
+ }
42
+ finally {
43
+ await handle?.close();
44
+ }
45
+ }
46
+ async function syncDirectory(directory) {
47
+ let handle;
48
+ try {
49
+ handle = await open(directory, "r");
50
+ await handle.sync();
51
+ }
52
+ catch (error) {
53
+ if (!ignorableDirectorySyncError(error))
54
+ throw error;
55
+ }
56
+ finally {
57
+ await handle?.close();
58
+ }
59
+ }
60
+ async function readOptional(filePath) {
61
+ try {
62
+ return await readFile(filePath, "utf8");
63
+ }
64
+ catch (error) {
65
+ if (isNodeError(error) && error.code === "ENOENT")
66
+ return undefined;
67
+ throw error;
68
+ }
69
+ }
70
+ function ignorableDirectorySyncError(error) {
71
+ if (!isNodeError(error))
72
+ return false;
73
+ return error.code === "EINVAL" || error.code === "EISDIR" || error.code === "EPERM";
74
+ }
75
+ export function isNodeError(error) {
76
+ return error instanceof Error && "code" in error;
77
+ }
78
+ //# sourceMappingURL=atomicFile.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"atomicFile.js","sourceRoot":"","sources":["../../src/runtime/atomicFile.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EACL,KAAK,EACL,KAAK,EACL,IAAI,EACJ,QAAQ,EACR,MAAM,EACN,EAAE,GAEH,MAAM,kBAAkB,CAAC;AAC1B,OAAO,IAAI,MAAM,WAAW,CAAC;AAO7B,MAAM,CAAC,KAAK,UAAU,oBAAoB,CACxC,QAAgB,EAChB,QAAgB,EAChB,UAA8B,EAAE;IAEhC,MAAM,SAAS,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CAAC;AAED,SAAS,2BAA2B,CAAC,KAAc;IACjD,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC;IACtC,OAAO,KAAK,CAAC,IAAI,KAAK,QAAQ,IAAI,KAAK,CAAC,IAAI,KAAK,QAAQ,IAAI,KAAK,CAAC,IAAI,KAAK,OAAO,CAAC;AACtF,CAAC;AAED,MAAM,UAAU,WAAW,CAAC,KAAc;IACxC,OAAO,KAAK,YAAY,KAAK,IAAI,MAAM,IAAI,KAAK,CAAC;AACnD,CAAC"}
@@ -0,0 +1,7 @@
1
+ import type { LocalAgentAdapter } from "../adapters/types.js";
2
+ import type { ConductorAgentAdvertisement, JsonObject } from "../types.js";
3
+ export type ReadyAdapter = LocalAgentAdapter & {
4
+ readinessMetadata: JsonObject;
5
+ };
6
+ export declare function daemonCapabilities(adapters: LocalAgentAdapter[]): JsonObject;
7
+ export declare function advertiseAdapters(adapters: ReadyAdapter[]): ConductorAgentAdvertisement[];
@@ -0,0 +1,24 @@
1
+ import { FENCED_ATTEMPTS_CAPABILITY } from "../protocol/fenced.js";
2
+ import { processTreeTerminationCapability } from "./process.js";
3
+ export function daemonCapabilities(adapters) {
4
+ return {
5
+ platform: process.platform,
6
+ adapters: adapters.map((adapter) => adapter.adapterType),
7
+ [FENCED_ATTEMPTS_CAPABILITY]: true,
8
+ processTreeTermination: processTreeTerminationCapability(),
9
+ };
10
+ }
11
+ export function advertiseAdapters(adapters) {
12
+ return adapters.map((adapter) => ({
13
+ localKey: adapter.localKey,
14
+ displayName: adapter.displayName,
15
+ adapterType: adapter.adapterType,
16
+ status: "active",
17
+ capabilities: {
18
+ ...adapter.capabilities,
19
+ ...adapter.readinessMetadata,
20
+ resumeSupport: adapter.resumeSupport ?? "none",
21
+ },
22
+ }));
23
+ }
24
+ //# sourceMappingURL=daemonCapabilities.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"daemonCapabilities.js","sourceRoot":"","sources":["../../src/runtime/daemonCapabilities.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,0BAA0B,EAAE,MAAM,uBAAuB,CAAC;AAEnE,OAAO,EAAE,gCAAgC,EAAE,MAAM,cAAc,CAAC;AAIhE,MAAM,UAAU,kBAAkB,CAAC,QAA6B;IAC9D,OAAO;QACL,QAAQ,EAAE,OAAO,CAAC,QAAQ;QAC1B,QAAQ,EAAE,QAAQ,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,WAAW,CAAC;QACxD,CAAC,0BAA0B,CAAC,EAAE,IAAI;QAClC,sBAAsB,EAAE,gCAAgC,EAAE;KAC3D,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,iBAAiB,CAAC,QAAwB;IACxD,OAAO,QAAQ,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;QAChC,QAAQ,EAAE,OAAO,CAAC,QAAQ;QAC1B,WAAW,EAAE,OAAO,CAAC,WAAW;QAChC,WAAW,EAAE,OAAO,CAAC,WAAW;QAChC,MAAM,EAAE,QAAQ;QAChB,YAAY,EAAE;YACZ,GAAG,OAAO,CAAC,YAAY;YACvB,GAAG,OAAO,CAAC,iBAAiB;YAC5B,aAAa,EAAE,OAAO,CAAC,aAAa,IAAI,MAAM;SAC/C;KACF,CAAC,CAAC,CAAC;AACN,CAAC"}
@@ -0,0 +1,100 @@
1
+ import { z } from "zod";
2
+ import type { RunEventInput } from "../types.js";
3
+ import { type AtomicWriteOptions } from "./atomicFile.js";
4
+ export declare const OUTBOX_SCHEMA_VERSION = 1;
5
+ declare const outboxEntrySchema: z.ZodObject<{
6
+ clientEventId: z.ZodString;
7
+ clientSequence: z.ZodNumber;
8
+ attemptId: z.ZodString;
9
+ runId: z.ZodString;
10
+ authority: z.ZodObject<{
11
+ attemptId: z.ZodString;
12
+ leaseGeneration: z.ZodNumber;
13
+ }, z.core.$strict>;
14
+ event: z.ZodObject<{
15
+ eventType: z.ZodEnum<{
16
+ cancelled: "cancelled";
17
+ completed: "completed";
18
+ failed: "failed";
19
+ health: "health";
20
+ progress: "progress";
21
+ log: "log";
22
+ artifact: "artifact";
23
+ approval_requested: "approval_requested";
24
+ }>;
25
+ payload: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
26
+ occurredAt: z.ZodOptional<z.ZodISODateTime>;
27
+ }, z.core.$strict>;
28
+ attempts: z.ZodNumber;
29
+ enqueuedAt: z.ZodNumber;
30
+ nextAttemptAt: z.ZodNumber;
31
+ lastErrorMessage: z.ZodOptional<z.ZodString>;
32
+ }, z.core.$strict>;
33
+ declare const outboxFileSchema: z.ZodObject<{
34
+ schemaVersion: z.ZodLiteral<1>;
35
+ entries: z.ZodArray<z.ZodObject<{
36
+ clientEventId: z.ZodString;
37
+ clientSequence: z.ZodNumber;
38
+ attemptId: z.ZodString;
39
+ runId: z.ZodString;
40
+ authority: z.ZodObject<{
41
+ attemptId: z.ZodString;
42
+ leaseGeneration: z.ZodNumber;
43
+ }, z.core.$strict>;
44
+ event: z.ZodObject<{
45
+ eventType: z.ZodEnum<{
46
+ cancelled: "cancelled";
47
+ completed: "completed";
48
+ failed: "failed";
49
+ health: "health";
50
+ progress: "progress";
51
+ log: "log";
52
+ artifact: "artifact";
53
+ approval_requested: "approval_requested";
54
+ }>;
55
+ payload: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
56
+ occurredAt: z.ZodOptional<z.ZodISODateTime>;
57
+ }, z.core.$strict>;
58
+ attempts: z.ZodNumber;
59
+ enqueuedAt: z.ZodNumber;
60
+ nextAttemptAt: z.ZodNumber;
61
+ lastErrorMessage: z.ZodOptional<z.ZodString>;
62
+ }, z.core.$strict>>;
63
+ updatedAt: z.ZodISODateTime;
64
+ }, z.core.$strict>;
65
+ export type DurableRunEvent = z.infer<typeof outboxEntrySchema>;
66
+ export type EventOutboxSnapshot = z.infer<typeof outboxFileSchema>;
67
+ export declare class DurableEventOutbox {
68
+ readonly path: string;
69
+ private readonly options;
70
+ private loaded;
71
+ private snapshot;
72
+ constructor(path?: string, options?: AtomicWriteOptions & {
73
+ maxEntries?: number | undefined;
74
+ nowMs?: (() => number) | undefined;
75
+ createId?: (() => string) | undefined;
76
+ });
77
+ enqueue(input: {
78
+ attemptId: string;
79
+ runId: string;
80
+ authority: DurableRunEvent["authority"];
81
+ clientSequence: number;
82
+ event: RunEventInput;
83
+ error?: unknown;
84
+ }): Promise<DurableRunEvent>;
85
+ due(nowMs?: number): Promise<DurableRunEvent[]>;
86
+ acknowledge(attemptId: string, acknowledgedClientSequence: number): Promise<void>;
87
+ discardAttempt(attemptId: string): Promise<void>;
88
+ listAttempt(attemptId: string): Promise<DurableRunEvent[]>;
89
+ recordFailure(clientEventId: string, error: unknown, nextAttemptAt: number): Promise<void>;
90
+ stats(): Promise<{
91
+ retainedEntries: number;
92
+ lastClientSequence: number;
93
+ }>;
94
+ private load;
95
+ private persist;
96
+ private nowMs;
97
+ private createId;
98
+ }
99
+ export declare function defaultEventOutboxPath(env?: NodeJS.ProcessEnv): string;
100
+ export {};