vibeusage 0.3.0 → 0.3.2

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 (127) hide show
  1. package/README.md +19 -11
  2. package/README.zh-CN.md +10 -8
  3. package/node_modules/@insforge/sdk/LICENSE +201 -201
  4. package/node_modules/@insforge/sdk/README.md +326 -259
  5. package/node_modules/@insforge/sdk/dist/index.d.mts +377 -182
  6. package/node_modules/@insforge/sdk/dist/index.d.ts +377 -182
  7. package/node_modules/@insforge/sdk/dist/index.js +1172 -677
  8. package/node_modules/@insforge/sdk/dist/index.js.map +1 -1
  9. package/node_modules/@insforge/sdk/dist/index.mjs +1171 -677
  10. package/node_modules/@insforge/sdk/dist/index.mjs.map +1 -1
  11. package/node_modules/@insforge/sdk/package.json +68 -68
  12. package/node_modules/@insforge/shared-schemas/dist/ai-api.schema.d.ts +1120 -43
  13. package/node_modules/@insforge/shared-schemas/dist/ai-api.schema.d.ts.map +1 -1
  14. package/node_modules/@insforge/shared-schemas/dist/ai-api.schema.js +179 -5
  15. package/node_modules/@insforge/shared-schemas/dist/ai-api.schema.js.map +1 -1
  16. package/node_modules/@insforge/shared-schemas/dist/ai.schema.d.ts +25 -25
  17. package/node_modules/@insforge/shared-schemas/dist/ai.schema.d.ts.map +1 -1
  18. package/node_modules/@insforge/shared-schemas/dist/ai.schema.js +2 -2
  19. package/node_modules/@insforge/shared-schemas/dist/ai.schema.js.map +1 -1
  20. package/node_modules/@insforge/shared-schemas/dist/auth-api.schema.d.ts +197 -51
  21. package/node_modules/@insforge/shared-schemas/dist/auth-api.schema.d.ts.map +1 -1
  22. package/node_modules/@insforge/shared-schemas/dist/auth-api.schema.js +87 -23
  23. package/node_modules/@insforge/shared-schemas/dist/auth-api.schema.js.map +1 -1
  24. package/node_modules/@insforge/shared-schemas/dist/auth.schema.d.ts +32 -3
  25. package/node_modules/@insforge/shared-schemas/dist/auth.schema.d.ts.map +1 -1
  26. package/node_modules/@insforge/shared-schemas/dist/auth.schema.js +21 -3
  27. package/node_modules/@insforge/shared-schemas/dist/auth.schema.js.map +1 -1
  28. package/node_modules/@insforge/shared-schemas/dist/cloud-events.schema.d.ts +380 -0
  29. package/node_modules/@insforge/shared-schemas/dist/cloud-events.schema.d.ts.map +1 -1
  30. package/node_modules/@insforge/shared-schemas/dist/cloud-events.schema.js +74 -0
  31. package/node_modules/@insforge/shared-schemas/dist/cloud-events.schema.js.map +1 -1
  32. package/node_modules/@insforge/shared-schemas/dist/database-api.schema.d.ts +13 -13
  33. package/node_modules/@insforge/shared-schemas/dist/database-api.schema.js +1 -1
  34. package/node_modules/@insforge/shared-schemas/dist/database-api.schema.js.map +1 -1
  35. package/node_modules/@insforge/shared-schemas/dist/deployments-api.schema.d.ts +735 -0
  36. package/node_modules/@insforge/shared-schemas/dist/deployments-api.schema.d.ts.map +1 -0
  37. package/node_modules/@insforge/shared-schemas/dist/deployments-api.schema.js +209 -0
  38. package/node_modules/@insforge/shared-schemas/dist/deployments-api.schema.js.map +1 -0
  39. package/node_modules/@insforge/shared-schemas/dist/deployments.schema.d.ts +37 -0
  40. package/node_modules/@insforge/shared-schemas/dist/deployments.schema.d.ts.map +1 -0
  41. package/node_modules/@insforge/shared-schemas/dist/deployments.schema.js +25 -0
  42. package/node_modules/@insforge/shared-schemas/dist/deployments.schema.js.map +1 -0
  43. package/node_modules/@insforge/shared-schemas/dist/docs.schema.d.ts +5 -1
  44. package/node_modules/@insforge/shared-schemas/dist/docs.schema.d.ts.map +1 -1
  45. package/node_modules/@insforge/shared-schemas/dist/docs.schema.js +34 -4
  46. package/node_modules/@insforge/shared-schemas/dist/docs.schema.js.map +1 -1
  47. package/node_modules/@insforge/shared-schemas/dist/email-api.schema.js +1 -1
  48. package/node_modules/@insforge/shared-schemas/dist/email-api.schema.js.map +1 -1
  49. package/node_modules/@insforge/shared-schemas/dist/functions-api.schema.d.ts +186 -6
  50. package/node_modules/@insforge/shared-schemas/dist/functions-api.schema.d.ts.map +1 -1
  51. package/node_modules/@insforge/shared-schemas/dist/functions-api.schema.js +21 -2
  52. package/node_modules/@insforge/shared-schemas/dist/functions-api.schema.js.map +1 -1
  53. package/node_modules/@insforge/shared-schemas/dist/functions.schema.d.ts +5 -5
  54. package/node_modules/@insforge/shared-schemas/dist/functions.schema.js +1 -1
  55. package/node_modules/@insforge/shared-schemas/dist/functions.schema.js.map +1 -1
  56. package/node_modules/@insforge/shared-schemas/dist/index.d.ts +24 -18
  57. package/node_modules/@insforge/shared-schemas/dist/index.d.ts.map +1 -1
  58. package/node_modules/@insforge/shared-schemas/dist/index.js +24 -18
  59. package/node_modules/@insforge/shared-schemas/dist/index.js.map +1 -1
  60. package/node_modules/@insforge/shared-schemas/dist/logs-api.schema.js +1 -1
  61. package/node_modules/@insforge/shared-schemas/dist/logs-api.schema.js.map +1 -1
  62. package/node_modules/@insforge/shared-schemas/dist/logs.schema.d.ts +43 -0
  63. package/node_modules/@insforge/shared-schemas/dist/logs.schema.d.ts.map +1 -1
  64. package/node_modules/@insforge/shared-schemas/dist/logs.schema.js +11 -0
  65. package/node_modules/@insforge/shared-schemas/dist/logs.schema.js.map +1 -1
  66. package/node_modules/@insforge/shared-schemas/dist/metadata.schema.d.ts +229 -172
  67. package/node_modules/@insforge/shared-schemas/dist/metadata.schema.d.ts.map +1 -1
  68. package/node_modules/@insforge/shared-schemas/dist/metadata.schema.js +27 -7
  69. package/node_modules/@insforge/shared-schemas/dist/metadata.schema.js.map +1 -1
  70. package/node_modules/@insforge/shared-schemas/dist/rate-limit-api.schema.d.ts +51 -0
  71. package/node_modules/@insforge/shared-schemas/dist/rate-limit-api.schema.d.ts.map +1 -0
  72. package/node_modules/@insforge/shared-schemas/dist/rate-limit-api.schema.js +31 -0
  73. package/node_modules/@insforge/shared-schemas/dist/rate-limit-api.schema.js.map +1 -0
  74. package/node_modules/@insforge/shared-schemas/dist/rate-limit.schema.d.ts +31 -0
  75. package/node_modules/@insforge/shared-schemas/dist/rate-limit.schema.d.ts.map +1 -0
  76. package/node_modules/@insforge/shared-schemas/dist/rate-limit.schema.js +12 -0
  77. package/node_modules/@insforge/shared-schemas/dist/rate-limit.schema.js.map +1 -0
  78. package/node_modules/@insforge/shared-schemas/dist/realtime-api.schema.d.ts +39 -20
  79. package/node_modules/@insforge/shared-schemas/dist/realtime-api.schema.d.ts.map +1 -1
  80. package/node_modules/@insforge/shared-schemas/dist/realtime-api.schema.js +5 -1
  81. package/node_modules/@insforge/shared-schemas/dist/realtime-api.schema.js.map +1 -1
  82. package/node_modules/@insforge/shared-schemas/dist/realtime.schema.d.ts +12 -4
  83. package/node_modules/@insforge/shared-schemas/dist/realtime.schema.d.ts.map +1 -1
  84. package/node_modules/@insforge/shared-schemas/dist/realtime.schema.js +6 -0
  85. package/node_modules/@insforge/shared-schemas/dist/realtime.schema.js.map +1 -1
  86. package/node_modules/@insforge/shared-schemas/dist/schedules-api.schema.d.ts +287 -0
  87. package/node_modules/@insforge/shared-schemas/dist/schedules-api.schema.d.ts.map +1 -0
  88. package/node_modules/@insforge/shared-schemas/dist/schedules-api.schema.js +81 -0
  89. package/node_modules/@insforge/shared-schemas/dist/schedules-api.schema.js.map +1 -0
  90. package/node_modules/@insforge/shared-schemas/dist/schedules.schema.d.ts +77 -0
  91. package/node_modules/@insforge/shared-schemas/dist/schedules.schema.d.ts.map +1 -0
  92. package/node_modules/@insforge/shared-schemas/dist/schedules.schema.js +36 -0
  93. package/node_modules/@insforge/shared-schemas/dist/schedules.schema.js.map +1 -0
  94. package/node_modules/@insforge/shared-schemas/dist/secrets-api.schema.d.ts +113 -0
  95. package/node_modules/@insforge/shared-schemas/dist/secrets-api.schema.d.ts.map +1 -0
  96. package/node_modules/@insforge/shared-schemas/dist/secrets-api.schema.js +31 -0
  97. package/node_modules/@insforge/shared-schemas/dist/secrets-api.schema.js.map +1 -0
  98. package/node_modules/@insforge/shared-schemas/dist/secrets.schema.d.ts +31 -0
  99. package/node_modules/@insforge/shared-schemas/dist/secrets.schema.d.ts.map +1 -0
  100. package/node_modules/@insforge/shared-schemas/dist/secrets.schema.js +13 -0
  101. package/node_modules/@insforge/shared-schemas/dist/secrets.schema.js.map +1 -0
  102. package/node_modules/@insforge/shared-schemas/dist/storage-api.schema.d.ts +27 -2
  103. package/node_modules/@insforge/shared-schemas/dist/storage-api.schema.d.ts.map +1 -1
  104. package/node_modules/@insforge/shared-schemas/dist/storage-api.schema.js +9 -1
  105. package/node_modules/@insforge/shared-schemas/dist/storage-api.schema.js.map +1 -1
  106. package/node_modules/@insforge/shared-schemas/dist/storage.schema.d.ts +17 -0
  107. package/node_modules/@insforge/shared-schemas/dist/storage.schema.d.ts.map +1 -1
  108. package/node_modules/@insforge/shared-schemas/dist/storage.schema.js +6 -0
  109. package/node_modules/@insforge/shared-schemas/dist/storage.schema.js.map +1 -1
  110. package/node_modules/@insforge/shared-schemas/package.json +2 -1
  111. package/package.json +2 -2
  112. package/src/commands/status.js +22 -5
  113. package/src/commands/sync.js +100 -197
  114. package/src/commands/uninstall.js +0 -11
  115. package/src/lib/diagnostics.js +34 -9
  116. package/src/lib/doctor.js +24 -15
  117. package/src/lib/insforge-client.js +13 -9
  118. package/src/lib/integrations/context.js +0 -6
  119. package/src/lib/integrations/index.js +0 -2
  120. package/src/lib/openclaw-session-plugin.js +48 -138
  121. package/src/lib/openclaw-usage-ledger.js +237 -0
  122. package/src/lib/opencode-sqlite.js +113 -0
  123. package/src/lib/opencode-usage-audit.js +3 -2
  124. package/src/lib/rollout.js +229 -153
  125. package/src/lib/vibeusage-api.js +2 -2
  126. package/src/lib/integrations/openclaw-legacy.js +0 -123
  127. package/src/lib/openclaw-hook.js +0 -420
@@ -0,0 +1,31 @@
1
+ import { z } from 'zod';
2
+ export declare const secretSchema: z.ZodObject<{
3
+ id: z.ZodString;
4
+ key: z.ZodString;
5
+ isActive: z.ZodBoolean;
6
+ isReserved: z.ZodBoolean;
7
+ lastUsedAt: z.ZodNullable<z.ZodString>;
8
+ expiresAt: z.ZodNullable<z.ZodString>;
9
+ createdAt: z.ZodString;
10
+ updatedAt: z.ZodString;
11
+ }, "strip", z.ZodTypeAny, {
12
+ id: string;
13
+ createdAt: string;
14
+ updatedAt: string;
15
+ key: string;
16
+ expiresAt: string | null;
17
+ isActive: boolean;
18
+ isReserved: boolean;
19
+ lastUsedAt: string | null;
20
+ }, {
21
+ id: string;
22
+ createdAt: string;
23
+ updatedAt: string;
24
+ key: string;
25
+ expiresAt: string | null;
26
+ isActive: boolean;
27
+ isReserved: boolean;
28
+ lastUsedAt: string | null;
29
+ }>;
30
+ export type SecretSchema = z.infer<typeof secretSchema>;
31
+ //# sourceMappingURL=secrets.schema.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"secrets.schema.d.ts","sourceRoot":"","sources":["../src/secrets.schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;EASvB,CAAC;AAEH,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,YAAY,CAAC,CAAC"}
@@ -0,0 +1,13 @@
1
+ import { z } from 'zod';
2
+ // Secret metadata (without value - for listing)
3
+ export const secretSchema = z.object({
4
+ id: z.string(),
5
+ key: z.string(),
6
+ isActive: z.boolean(),
7
+ isReserved: z.boolean(),
8
+ lastUsedAt: z.string().nullable(),
9
+ expiresAt: z.string().nullable(),
10
+ createdAt: z.string(),
11
+ updatedAt: z.string(),
12
+ });
13
+ //# sourceMappingURL=secrets.schema.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"secrets.schema.js","sourceRoot":"","sources":["../src/secrets.schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,gDAAgD;AAChD,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,CAAC,MAAM,CAAC;IACnC,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE;IACd,GAAG,EAAE,CAAC,CAAC,MAAM,EAAE;IACf,QAAQ,EAAE,CAAC,CAAC,OAAO,EAAE;IACrB,UAAU,EAAE,CAAC,CAAC,OAAO,EAAE;IACvB,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IACjC,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAChC,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE;IACrB,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE;CACtB,CAAC,CAAC"}
@@ -104,16 +104,16 @@ export declare const uploadStrategyResponseSchema: z.ZodObject<{
104
104
  expiresAt: z.ZodOptional<z.ZodDate>;
105
105
  }, "strip", z.ZodTypeAny, {
106
106
  key: string;
107
- method: "presigned" | "direct";
108
107
  uploadUrl: string;
108
+ method: "presigned" | "direct";
109
109
  confirmRequired: boolean;
110
110
  expiresAt?: Date | undefined;
111
111
  fields?: Record<string, string> | undefined;
112
112
  confirmUrl?: string | undefined;
113
113
  }, {
114
114
  key: string;
115
- method: "presigned" | "direct";
116
115
  uploadUrl: string;
116
+ method: "presigned" | "direct";
117
117
  confirmRequired: boolean;
118
118
  expiresAt?: Date | undefined;
119
119
  fields?: Record<string, string> | undefined;
@@ -155,6 +155,29 @@ export declare const confirmUploadRequestSchema: z.ZodObject<{
155
155
  contentType?: string | undefined;
156
156
  etag?: string | undefined;
157
157
  }>;
158
+ export declare const updateStorageConfigRequestSchema: z.ZodObject<{
159
+ maxFileSizeMb: z.ZodNumber;
160
+ }, "strip", z.ZodTypeAny, {
161
+ maxFileSizeMb: number;
162
+ }, {
163
+ maxFileSizeMb: number;
164
+ }>;
165
+ export declare const getStorageConfigResponseSchema: z.ZodObject<{
166
+ id: z.ZodString;
167
+ maxFileSizeMb: z.ZodNumber;
168
+ createdAt: z.ZodString;
169
+ updatedAt: z.ZodString;
170
+ }, "strip", z.ZodTypeAny, {
171
+ id: string;
172
+ createdAt: string;
173
+ updatedAt: string;
174
+ maxFileSizeMb: number;
175
+ }, {
176
+ id: string;
177
+ createdAt: string;
178
+ updatedAt: string;
179
+ maxFileSizeMb: number;
180
+ }>;
158
181
  export type CreateBucketRequest = z.infer<typeof createBucketRequestSchema>;
159
182
  export type UpdateBucketRequest = z.infer<typeof updateBucketRequestSchema>;
160
183
  export type ListObjectsResponseSchema = z.infer<typeof listObjectsResponseSchema>;
@@ -163,4 +186,6 @@ export type UploadStrategyResponse = z.infer<typeof uploadStrategyResponseSchema
163
186
  export type DownloadStrategyRequest = z.infer<typeof downloadStrategyRequestSchema>;
164
187
  export type DownloadStrategyResponse = z.infer<typeof downloadStrategyResponseSchema>;
165
188
  export type ConfirmUploadRequest = z.infer<typeof confirmUploadRequestSchema>;
189
+ export type UpdateStorageConfigRequest = z.infer<typeof updateStorageConfigRequestSchema>;
190
+ export type GetStorageConfigResponse = z.infer<typeof getStorageConfigResponseSchema>;
166
191
  //# sourceMappingURL=storage-api.schema.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"storage-api.schema.d.ts","sourceRoot":"","sources":["../src/storage-api.schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,eAAO,MAAM,yBAAyB;;;;;;;;;EAGpC,CAAC;AAEH,eAAO,MAAM,yBAAyB;;;;;;EAEpC,CAAC;AAEH,eAAO,MAAM,yBAAyB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAOpC,CAAC;AAGH,eAAO,MAAM,2BAA2B;;;;;;;;;;;;EAItC,CAAC;AAEH,eAAO,MAAM,4BAA4B;;;;;;;;;;;;;;;;;;;;;;;;EAQvC,CAAC;AAGH,eAAO,MAAM,6BAA6B;;;;;;EAExC,CAAC;AAEH,eAAO,MAAM,8BAA8B;;;;;;;;;;;;;;;EAKzC,CAAC;AAGH,eAAO,MAAM,0BAA0B;;;;;;;;;;;;EAI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CAAC;AAGH,eAAO,MAAM,0BAA0B;;;;;;;;;;;;EAIrC,CAAC;AAEH,eAAO,MAAM,gCAAgC;;;;;;EAM3C,CAAC;AAEH,eAAO,MAAM,8BAA8B;;;;;;;;;;;;;;;EAAsB,CAAC;AAElE,MAAM,MAAM,mBAAmB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,yBAAyB,CAAC,CAAC;AAC5E,MAAM,MAAM,mBAAmB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,yBAAyB,CAAC,CAAC;AAC5E,MAAM,MAAM,yBAAyB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,yBAAyB,CAAC,CAAC;AAClF,MAAM,MAAM,qBAAqB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,2BAA2B,CAAC,CAAC;AAChF,MAAM,MAAM,sBAAsB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,4BAA4B,CAAC,CAAC;AAClF,MAAM,MAAM,uBAAuB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,6BAA6B,CAAC,CAAC;AACpF,MAAM,MAAM,wBAAwB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,8BAA8B,CAAC,CAAC;AACtF,MAAM,MAAM,oBAAoB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,0BAA0B,CAAC,CAAC;AAC9E,MAAM,MAAM,0BAA0B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gCAAgC,CAAC,CAAC;AAC1F,MAAM,MAAM,wBAAwB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,8BAA8B,CAAC,CAAC"}
@@ -1,5 +1,5 @@
1
1
  import { z } from 'zod';
2
- import { storageFileSchema } from './storage.schema';
2
+ import { storageConfigSchema, storageFileSchema } from './storage.schema.js';
3
3
  export const createBucketRequestSchema = z.object({
4
4
  bucketName: z.string().min(1, 'Bucket name cannot be empty'),
5
5
  isPublic: z.boolean().default(true),
@@ -46,4 +46,12 @@ export const confirmUploadRequestSchema = z.object({
46
46
  contentType: z.string().optional(),
47
47
  etag: z.string().optional(),
48
48
  });
49
+ export const updateStorageConfigRequestSchema = z.object({
50
+ maxFileSizeMb: z
51
+ .number()
52
+ .int()
53
+ .min(1, 'Must be at least 1 MB')
54
+ .max(200, 'Must be at most 200 MB'),
55
+ });
56
+ export const getStorageConfigResponseSchema = storageConfigSchema;
49
57
  //# sourceMappingURL=storage-api.schema.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"storage-api.schema.js","sourceRoot":"","sources":["../src/storage-api.schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAErD,MAAM,CAAC,MAAM,yBAAyB,GAAG,CAAC,CAAC,MAAM,CAAC;IAChD,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,EAAE,6BAA6B,CAAC;IAC5D,QAAQ,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC;CACpC,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,yBAAyB,GAAG,CAAC,CAAC,MAAM,CAAC;IAChD,QAAQ,EAAE,CAAC,CAAC,OAAO,EAAE;CACtB,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,yBAAyB,GAAG,CAAC,CAAC,MAAM,CAAC;IAChD,OAAO,EAAE,CAAC,CAAC,KAAK,CAAC,iBAAiB,CAAC;IACnC,UAAU,EAAE,CAAC,CAAC,MAAM,CAAC;QACnB,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE;QAClB,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE;QACjB,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE;KAClB,CAAC;CACH,CAAC,CAAC;AAEH,0BAA0B;AAC1B,MAAM,CAAC,MAAM,2BAA2B,GAAG,CAAC,CAAC,MAAM,CAAC;IAClD,QAAQ,EAAE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AM,EAAE,CAAC,CAAC,QAAQ,EAAE;CACzC,CAAC,CAAC;AAEH,wBAAwB;AACxB,MAAM,CAAC,MAAM,0BAA0B,GAAG,CAAC,CAAC,MAAM,CAAC;IACjD,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE;IAChB,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAClC,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;CAC5B,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,gCAAgC,GAAG,CAAC,CAAC,MAAM,CAAC;IACvD,aAAa,EAAE,CAAC;SACb,MAAM,EAAE;SACR,GAAG,EAAE;SACL,GAAG,CAAC,CAAC,EAAE,uBAAuB,CAAC;SAC/B,GAAG,CAAC,GAAG,EAAE,wBAAwB,CAAC;CACtC,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,8BAA8B,GAAG,mBAAmB,CAAC"}
@@ -34,6 +34,23 @@ export declare const storageBucketSchema: z.ZodObject<{
34
34
  name: string;
35
35
  public: boolean;
36
36
  }>;
37
+ export declare const storageConfigSchema: z.ZodObject<{
38
+ id: z.ZodString;
39
+ maxFileSizeMb: z.ZodNumber;
40
+ createdAt: z.ZodString;
41
+ updatedAt: z.ZodString;
42
+ }, "strip", z.ZodTypeAny, {
43
+ id: string;
44
+ createdAt: string;
45
+ updatedAt: string;
46
+ maxFileSizeMb: number;
47
+ }, {
48
+ id: string;
49
+ createdAt: string;
50
+ updatedAt: string;
51
+ maxFileSizeMb: number;
52
+ }>;
37
53
  export type StorageFileSchema = z.infer<typeof storageFileSchema>;
38
54
  export type StorageBucketSchema = z.infer<typeof storageBucketSchema>;
55
+ export type StorageConfigSchema = z.infer<typeof storageConfigSchema>;
39
56
  //# sourceMappingURL=storage.schema.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"storage.schema.d.ts","sourceRoot":"","sources":["../src/storage.schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;EAO5B,CAAC;AAEH,eAAO,MAAM,mBAAmB;;;;;;;;;;;;EAI9B,CAAC;AAEH,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAC;AAClE,MAAM,MAAM,mBAAmB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC"}
1
+ {"version":3,"file":"storage.schema.d.ts","sourceRoot":"","sources":["../src/storage.schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;EAO5B,CAAC;AAEH,eAAO,MAAM,mBAAmB;;;;;;;;;;;;EAI9B,CAAC;AAEH,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;EAK9B,CAAC;AAEH,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAC;AAClE,MAAM,MAAM,mBAAmB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC;AACtE,MAAM,MAAM,mBAAmB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC"}
@@ -12,4 +12,10 @@ export const storageBucketSchema = z.object({
12
12
  public: z.boolean(),
13
13
  createdAt: z.string(),
14
14
  });
15
+ export const storageConfigSchema = z.object({
16
+ id: z.string().uuid(),
17
+ maxFileSizeMb: z.number().int().positive(),
18
+ createdAt: z.string(),
19
+ updatedAt: z.string(),
20
+ });
15
21
  //# sourceMappingURL=storage.schema.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"storage.schema.js","sourceRoot":"","sources":["../src/storage.schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAA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tB,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC1C,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE;IACrB,aAAa,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE;IAC1C,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE;IACrB,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE;CACtB,CAAC,CAAC"}
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@insforge/shared-schemas",
3
- "version": "1.1.35",
3
+ "version": "1.1.47",
4
4
  "author": "Insforge",
5
5
  "description": "Shared TypeScript schemas for InsForge frontend and backend",
6
6
  "license": "Apache-2.0",
@@ -20,6 +20,7 @@
20
20
  "scripts": {
21
21
  "build": "tsc",
22
22
  "typecheck": "tsc --noEmit",
23
+ "prepare": "npm run build",
23
24
  "prepublishOnly": "npm run build"
24
25
  },
25
26
  "dependencies": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vibeusage",
3
- "version": "0.3.0",
3
+ "version": "0.3.2",
4
4
  "description": "Codex CLI token usage tracker (macOS-first, notify-driven).",
5
5
  "license": "MIT",
6
6
  "bin": {
@@ -41,7 +41,7 @@
41
41
  "validate:ui-hardcode": "node scripts/ops/validate-ui-hardcode.cjs"
42
42
  },
43
43
  "dependencies": {
44
- "@insforge/sdk": "^1.0.4"
44
+ "@insforge/sdk": "1.2.2"
45
45
  },
46
46
  "devDependencies": {
47
47
  "@sourcegraph/scip-typescript": "^0.3.6",
@@ -28,6 +28,9 @@ async function cmdStatus(argv = []) {
28
28
  const throttlePath = path.join(trackerDir, "sync.throttle");
29
29
  const uploadThrottlePath = path.join(trackerDir, "upload.throttle.json");
30
30
  const autoRetryPath = path.join(trackerDir, "auto.retry.json");
31
+ const xdgDataHome = process.env.XDG_DATA_HOME || path.join(home, ".local", "share");
32
+ const opencodeHome = process.env.OPENCODE_HOME || path.join(xdgDataHome, "opencode");
33
+ const opencodeDbPath = path.join(opencodeHome, "opencode.db");
31
34
 
32
35
  const config = await readJson(configPath);
33
36
  const cursors = await readJson(cursorsPath);
@@ -78,7 +81,15 @@ async function cmdStatus(argv = []) {
78
81
  const geminiProbe = probeByName.get("gemini");
79
82
  const opencodeProbe = probeByName.get("opencode");
80
83
  const openclawSessionProbe = probeByName.get("openclaw-session");
81
- const openclawLegacyProbe = probeByName.get("openclaw-legacy");
84
+ const opencodeDbPresent = Boolean((await safeStat(opencodeDbPath))?.isFile?.());
85
+ const opencodeSqliteState =
86
+ cursors?.opencodeSqlite && typeof cursors.opencodeSqlite === "object"
87
+ ? cursors.opencodeSqlite
88
+ : {};
89
+ const opencodeSqliteReader =
90
+ typeof opencodeSqliteState.lastStatus === "string" && opencodeSqliteState.lastStatus.trim()
91
+ ? opencodeSqliteState.lastStatus.trim()
92
+ : "never_checked";
82
93
 
83
94
  process.stdout.write(
84
95
  [
@@ -100,14 +111,12 @@ async function cmdStatus(argv = []) {
100
111
  `- Claude hooks: ${renderIntegrationStatus(descriptors.get("claude"), claudeProbe)}`,
101
112
  `- Gemini hooks: ${renderIntegrationStatus(descriptors.get("gemini"), geminiProbe)}`,
102
113
  `- Opencode plugin: ${renderIntegrationStatus(descriptors.get("opencode"), opencodeProbe)}`,
114
+ `- OpenCode SQLite DB: ${opencodeDbPresent ? "present" : "missing"}`,
115
+ `- OpenCode SQLite reader: ${opencodeSqliteReader}`,
103
116
  `- OpenClaw session plugin: ${renderIntegrationStatus(
104
117
  descriptors.get("openclaw-session"),
105
118
  openclawSessionProbe,
106
119
  )}`,
107
- `- OpenClaw hook (legacy): ${renderIntegrationStatus(
108
- descriptors.get("openclaw-legacy"),
109
- openclawLegacyProbe,
110
- )}`,
111
120
  ...subscriptionLines,
112
121
  "",
113
122
  ]
@@ -181,6 +190,14 @@ async function safeStatSize(p) {
181
190
  }
182
191
  }
183
192
 
193
+ async function safeStat(p) {
194
+ try {
195
+ return await fs.stat(p);
196
+ } catch (_e) {
197
+ return null;
198
+ }
199
+ }
200
+
184
201
  async function safeReadText(p) {
185
202
  try {
186
203
  return await fs.readFile(p, "utf8");
@@ -13,9 +13,15 @@ const {
13
13
  parseClaudeIncremental,
14
14
  parseGeminiIncremental,
15
15
  parseOpencodeIncremental,
16
- parseOpenclawIncremental,
16
+ normalizeHourlyState,
17
+ getHourlyBucket,
18
+ addTotals,
19
+ bucketKey,
20
+ enqueueTouchedBuckets,
21
+ toUtcHalfHourStart,
17
22
  } = require("../lib/rollout");
18
23
  const { drainQueueToCloud } = require("../lib/uploader");
24
+ const { readOpenclawUsageLedger } = require("../lib/openclaw-usage-ledger");
19
25
  const { collectLocalSubscriptions } = require("../lib/subscriptions");
20
26
  const { createProgress, renderBar, formatNumber, formatBytes } = require("../lib/progress");
21
27
  const { syncHeartbeat } = require("../lib/vibeusage-api");
@@ -68,13 +74,7 @@ async function cmdSync(argv) {
68
74
  const xdgDataHome = process.env.XDG_DATA_HOME || path.join(home, ".local", "share");
69
75
  const opencodeHome = process.env.OPENCODE_HOME || path.join(xdgDataHome, "opencode");
70
76
  const opencodeStorageDir = path.join(opencodeHome, "storage");
71
-
72
- // OpenClaw session-plugin integration: allow a plugin-triggered sync to request incremental parsing
73
- // for a single session jsonl. We still parse all regular sources so model/source attribution stays
74
- // complete (e.g. Kimi sessions).
75
- const openclawSignal = opts.fromOpenclaw
76
- ? resolveOpenclawSignal({ home, env: process.env })
77
- : null;
77
+ const opencodeDbPath = path.join(opencodeHome, "opencode.db");
78
78
 
79
79
  const sources = [
80
80
  { source: "codex", sessionsDir: path.join(codexHome, "sessions") },
@@ -92,10 +92,6 @@ async function cmdSync(argv) {
92
92
  }
93
93
  }
94
94
 
95
- const openclawFiles = openclawSignal?.sessionFile
96
- ? [{ path: openclawSignal.sessionFile, source: "openclaw" }]
97
- : [];
98
-
99
95
  if (progress?.enabled) {
100
96
  progress.start(
101
97
  `Parsing ${renderBar(0)} 0/${formatNumber(rolloutFiles.length)} files | buckets 0`,
@@ -118,28 +114,13 @@ async function cmdSync(argv) {
118
114
  },
119
115
  });
120
116
 
121
- let openclawResult = { filesProcessed: 0, eventsAggregated: 0, bucketsQueued: 0 };
122
- if (openclawFiles.length > 0) {
123
- // Only runs when explicitly triggered by OpenClaw session-plugin events.
124
- openclawResult = await parseOpenclawIncremental({
125
- sessionFiles: openclawFiles,
126
- cursors,
127
- queuePath,
128
- projectQueuePath,
129
- source: "openclaw",
130
- });
131
- }
132
-
133
- const openclawFallback = await applyOpenclawTotalsFallback({
134
- trackerDir,
135
- signal: openclawSignal,
136
- cursors,
137
- queuePath,
138
- projectQueuePath,
139
- });
140
- openclawResult.filesProcessed += openclawFallback.filesProcessed;
141
- openclawResult.eventsAggregated += openclawFallback.eventsAggregated;
142
- openclawResult.bucketsQueued += openclawFallback.bucketsQueued;
117
+ const openclawResult = opts.fromOpenclaw
118
+ ? await parseOpenclawSanitizedLedger({
119
+ trackerDir,
120
+ cursors,
121
+ queuePath,
122
+ })
123
+ : { filesProcessed: 0, eventsAggregated: 0, bucketsQueued: 0 };
143
124
 
144
125
  const claudeFiles = await listClaudeProjectFiles(claudeProjectsDir);
145
126
  let claudeResult = { filesProcessed: 0, eventsAggregated: 0, bucketsQueued: 0 };
@@ -195,29 +176,28 @@ async function cmdSync(argv) {
195
176
 
196
177
  const opencodeFiles = await listOpencodeMessageFiles(opencodeStorageDir);
197
178
  let opencodeResult = { filesProcessed: 0, eventsAggregated: 0, bucketsQueued: 0 };
198
- if (opencodeFiles.length > 0) {
199
- if (progress?.enabled) {
200
- progress.start(
201
- `Parsing Opencode ${renderBar(0)} 0/${formatNumber(opencodeFiles.length)} files | buckets 0`,
202
- );
203
- }
204
- opencodeResult = await parseOpencodeIncremental({
205
- messageFiles: opencodeFiles,
206
- cursors,
207
- queuePath,
208
- projectQueuePath,
209
- onProgress: (p) => {
210
- if (!progress?.enabled) return;
211
- const pct = p.total > 0 ? p.index / p.total : 1;
212
- progress.update(
213
- `Parsing Opencode ${renderBar(pct)} ${formatNumber(p.index)}/${formatNumber(
214
- p.total,
215
- )} files | buckets ${formatNumber(p.bucketsQueued)}`,
216
- );
217
- },
218
- source: "opencode",
219
- });
179
+ if (progress?.enabled && opencodeFiles.length > 0) {
180
+ progress.start(
181
+ `Parsing Opencode ${renderBar(0)} 0/${formatNumber(opencodeFiles.length)} files | buckets 0`,
182
+ );
220
183
  }
184
+ opencodeResult = await parseOpencodeIncremental({
185
+ messageFiles: opencodeFiles,
186
+ opencodeDbPath,
187
+ cursors,
188
+ queuePath,
189
+ projectQueuePath,
190
+ onProgress: (p) => {
191
+ if (!progress?.enabled) return;
192
+ const pct = p.total > 0 ? p.index / p.total : 1;
193
+ progress.update(
194
+ `Parsing Opencode ${renderBar(pct)} ${formatNumber(p.index)}/${formatNumber(
195
+ p.total,
196
+ )} files | buckets ${formatNumber(p.bucketsQueued)}`,
197
+ );
198
+ },
199
+ source: "opencode",
200
+ });
221
201
 
222
202
  if (cursors?.projectHourly?.projects && projectQueuePath && projectQueueStatePath) {
223
203
  for (const [projectKey, meta] of Object.entries(cursors.projectHourly.projects)) {
@@ -415,6 +395,17 @@ async function cmdSync(argv) {
415
395
  .filter(Boolean)
416
396
  .join("\n"),
417
397
  );
398
+ if (
399
+ opencodeResult.sqliteStatus === "missing-sqlite3" ||
400
+ opencodeResult.sqliteStatus === "query-failed"
401
+ ) {
402
+ const reason = opencodeResult.sqliteErrorCode
403
+ ? `${opencodeResult.sqliteStatus} (${opencodeResult.sqliteErrorCode})`
404
+ : opencodeResult.sqliteStatus;
405
+ process.stderr.write(
406
+ `Warning: OpenCode usage may be incomplete because the SQLite reader is ${reason}. Run \`vibeusage doctor\` for details.\n`,
407
+ );
408
+ }
418
409
  }
419
410
  } finally {
420
411
  progress?.stop();
@@ -445,153 +436,65 @@ function parseArgs(argv) {
445
436
 
446
437
  module.exports = { cmdSync };
447
438
 
448
- function normalizeString(value) {
449
- if (typeof value !== "string") return null;
450
- const trimmed = value.trim();
451
- return trimmed.length > 0 ? trimmed : null;
452
- }
453
-
454
- function resolveOpenclawSignal({ home, env } = {}) {
455
- if (!env) return null;
456
-
457
- const agentId = normalizeString(env.VIBEUSAGE_OPENCLAW_AGENT_ID);
458
- const sessionId = normalizeString(env.VIBEUSAGE_OPENCLAW_PREV_SESSION_ID);
459
- if (!agentId || !sessionId) return null;
460
-
461
- const openclawHome =
462
- normalizeString(env.VIBEUSAGE_OPENCLAW_HOME) || path.join(home || os.homedir(), ".openclaw");
463
- const sessionFile = path.join(openclawHome, "agents", agentId, "sessions", `${sessionId}.jsonl`);
464
-
465
- const prevTotals = {
466
- totalTokens: normalizeNonNegativeInt(env.VIBEUSAGE_OPENCLAW_PREV_TOTAL_TOKENS),
467
- inputTokens: normalizeNonNegativeInt(env.VIBEUSAGE_OPENCLAW_PREV_INPUT_TOKENS),
468
- outputTokens: normalizeNonNegativeInt(env.VIBEUSAGE_OPENCLAW_PREV_OUTPUT_TOKENS),
469
- model: normalizeString(env.VIBEUSAGE_OPENCLAW_PREV_MODEL),
470
- updatedAt: normalizeIsoOrEpoch(env.VIBEUSAGE_OPENCLAW_PREV_UPDATED_AT),
471
- };
472
-
473
- return {
474
- agentId,
475
- sessionId,
476
- sessionKey: normalizeString(env.VIBEUSAGE_OPENCLAW_SESSION_KEY),
477
- openclawHome,
478
- sessionFile,
479
- prevTotals,
480
- };
481
- }
439
+ async function parseOpenclawSanitizedLedger({ trackerDir, cursors, queuePath }) {
440
+ const ledgerCursor =
441
+ cursors?.openclawLedger && typeof cursors.openclawLedger === "object"
442
+ ? cursors.openclawLedger
443
+ : {};
444
+ const offset = Math.max(0, Number(ledgerCursor.offset || 0));
445
+ const { events, endOffset } = await readOpenclawUsageLedger({ trackerDir, offset });
446
+
447
+ const hourlyState = normalizeHourlyState(cursors?.hourly);
448
+ const touchedBuckets = new Set();
449
+ let eventsAggregated = 0;
450
+
451
+ for (const event of events) {
452
+ if (!event || typeof event !== "object") continue;
453
+ const bucketStart = toUtcHalfHourStart(event.emittedAt);
454
+ if (!bucketStart) continue;
455
+
456
+ const model =
457
+ typeof event.model === "string" && event.model.trim() ? event.model.trim() : "unknown";
458
+ const source =
459
+ typeof event.source === "string" && event.source.trim() ? event.source.trim() : "openclaw";
460
+ const delta = {
461
+ input_tokens: Math.max(0, Number(event.inputTokens || 0)),
462
+ cached_input_tokens: Math.max(0, Number(event.cachedInputTokens || 0)),
463
+ output_tokens: Math.max(0, Number(event.outputTokens || 0)),
464
+ reasoning_output_tokens: Math.max(0, Number(event.reasoningOutputTokens || 0)),
465
+ total_tokens: Math.max(0, Number(event.totalTokens || 0)),
466
+ };
467
+
468
+ if (
469
+ delta.input_tokens === 0 &&
470
+ delta.cached_input_tokens === 0 &&
471
+ delta.output_tokens === 0 &&
472
+ delta.reasoning_output_tokens === 0 &&
473
+ delta.total_tokens === 0
474
+ ) {
475
+ continue;
476
+ }
482
477
 
483
- async function applyOpenclawTotalsFallback({
484
- trackerDir,
485
- signal,
486
- cursors,
487
- queuePath,
488
- projectQueuePath,
489
- }) {
490
- const totalTokens = Number(signal?.prevTotals?.totalTokens || 0);
491
- if (!trackerDir || !signal || totalTokens <= 0) {
492
- return { filesProcessed: 0, eventsAggregated: 0, bucketsQueued: 0 };
478
+ const bucket = getHourlyBucket(hourlyState, source, model, bucketStart);
479
+ addTotals(bucket.totals, delta);
480
+ touchedBuckets.add(bucketKey(source, model, bucketStart));
481
+ eventsAggregated += 1;
493
482
  }
494
483
 
495
- const sessionKey = `${signal.agentId}:${signal.sessionId}`;
496
- const statePath = path.join(trackerDir, "openclaw.fallback.state.json");
497
- const fallbackFilePath = path.join(trackerDir, "openclaw.fallback.jsonl");
498
- const state = (await readJson(statePath)) || { version: 1, sessions: {} };
499
- const sessions = state.sessions && typeof state.sessions === "object" ? state.sessions : {};
500
- const prev =
501
- sessions[sessionKey] && typeof sessions[sessionKey] === "object" ? sessions[sessionKey] : null;
502
-
503
- const current = {
504
- totalTokens: normalizeNonNegativeInt(signal?.prevTotals?.totalTokens) || 0,
505
- inputTokens: normalizeNonNegativeInt(signal?.prevTotals?.inputTokens) || 0,
506
- outputTokens: normalizeNonNegativeInt(signal?.prevTotals?.outputTokens) || 0,
507
- model: normalizeString(signal?.prevTotals?.model) || "unknown",
508
- updatedAt: normalizeIsoOrEpoch(signal?.prevTotals?.updatedAt) || new Date().toISOString(),
509
- seenAt: new Date().toISOString(),
484
+ const bucketsQueued = await enqueueTouchedBuckets({ queuePath, hourlyState, touchedBuckets });
485
+ hourlyState.updatedAt = new Date().toISOString();
486
+ cursors.hourly = hourlyState;
487
+ cursors.openclawLedger = {
488
+ version: 1,
489
+ offset: endOffset,
490
+ updatedAt: new Date().toISOString(),
510
491
  };
511
492
 
512
- let deltaTotal = current.totalTokens;
513
- let deltaInput = current.inputTokens;
514
- let deltaOutput = current.outputTokens;
515
- if (prev) {
516
- deltaTotal = Math.max(
517
- 0,
518
- current.totalTokens - (normalizeNonNegativeInt(prev.totalTokens) || 0),
519
- );
520
- deltaInput = Math.max(
521
- 0,
522
- current.inputTokens - (normalizeNonNegativeInt(prev.inputTokens) || 0),
523
- );
524
- deltaOutput = Math.max(
525
- 0,
526
- current.outputTokens - (normalizeNonNegativeInt(prev.outputTokens) || 0),
527
- );
528
- }
529
-
530
- if (deltaTotal > 0 && deltaInput + deltaOutput === 0) {
531
- deltaInput = deltaTotal;
532
- }
533
-
534
- sessions[sessionKey] = current;
535
- state.version = 1;
536
- state.sessions = sessions;
537
-
538
- if (deltaTotal <= 0) {
539
- await writeJson(statePath, state);
540
- return { filesProcessed: 0, eventsAggregated: 0, bucketsQueued: 0 };
541
- }
542
-
543
- await ensureDir(path.dirname(fallbackFilePath));
544
- const syntheticMessage = {
545
- type: "message",
546
- timestamp: current.updatedAt,
547
- message: {
548
- role: "assistant",
549
- model: current.model,
550
- usage: {
551
- input: deltaInput,
552
- output: deltaOutput,
553
- cacheRead: 0,
554
- cacheWrite: 0,
555
- totalTokens: deltaTotal,
556
- },
557
- },
493
+ return {
494
+ filesProcessed: endOffset > offset ? 1 : 0,
495
+ eventsAggregated,
496
+ bucketsQueued,
558
497
  };
559
- await fs.appendFile(fallbackFilePath, `${JSON.stringify(syntheticMessage)}\n`, "utf8");
560
- await writeJson(statePath, state);
561
-
562
- return parseOpenclawIncremental({
563
- sessionFiles: [{ path: fallbackFilePath, source: "openclaw" }],
564
- cursors,
565
- queuePath,
566
- projectQueuePath,
567
- source: "openclaw",
568
- });
569
- }
570
-
571
- function normalizeNonNegativeInt(value) {
572
- const n = Number(value);
573
- if (!Number.isFinite(n) || n < 0) return null;
574
- return Math.floor(n);
575
- }
576
-
577
- function normalizeIsoOrEpoch(value) {
578
- if (typeof value === "string") {
579
- const trimmed = value.trim();
580
- if (trimmed.length > 0 && !Number.isNaN(Date.parse(trimmed))) return trimmed;
581
- const numeric = Number(trimmed);
582
- if (Number.isFinite(numeric) && numeric > 0) {
583
- const ms = numeric < 1e12 ? Math.floor(numeric * 1000) : Math.floor(numeric);
584
- const iso = new Date(ms).toISOString();
585
- if (!Number.isNaN(Date.parse(iso))) return iso;
586
- }
587
- }
588
-
589
- const n = Number(value);
590
- if (!Number.isFinite(n) || n <= 0) return null;
591
- const ms = n < 1e12 ? Math.floor(n * 1000) : Math.floor(n);
592
- const dt = new Date(ms);
593
- if (Number.isNaN(dt.getTime())) return null;
594
- return dt.toISOString();
595
498
  }
596
499
 
597
500
  async function safeStatSize(p) {