@agentdock/wire 0.0.90 → 0.0.91

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 (136) hide show
  1. package/dist/activityPreferences.js +1 -2
  2. package/dist/agentCapabilities.d.ts +2 -0
  3. package/dist/agentCapabilities.js +1 -199
  4. package/dist/agentCommonEnv.js +1 -20
  5. package/dist/agentInstallGuide.js +1 -81
  6. package/dist/bgTask.js +1 -128
  7. package/dist/checkpointSchemas.d.ts +142 -98
  8. package/dist/checkpointSchemas.js +1 -46
  9. package/dist/controlLevel.js +1 -11
  10. package/dist/edition.js +1 -13
  11. package/dist/envelope.d.ts +5668 -563
  12. package/dist/envelope.js +1 -77
  13. package/dist/errorMessage.js +1 -6
  14. package/dist/events.d.ts +2053 -324
  15. package/dist/events.js +1 -107
  16. package/dist/features.js +1 -123
  17. package/dist/feedback.d.ts +2 -2
  18. package/dist/feedback.js +1 -61
  19. package/dist/fileWhitelist.js +1 -189
  20. package/dist/inboundEvents.d.ts +531 -0
  21. package/dist/inboundEvents.js +1 -0
  22. package/dist/index.d.ts +11 -5
  23. package/dist/index.js +1 -73
  24. package/dist/interactionEvents.d.ts +153 -106
  25. package/dist/interactionEvents.js +1 -111
  26. package/dist/legacyProtocol.d.ts +512 -272
  27. package/dist/legacyProtocol.js +1 -30
  28. package/dist/license.js +1 -28
  29. package/dist/machine.d.ts +108 -62
  30. package/dist/machine.js +1 -66
  31. package/dist/messageMeta.d.ts +34 -28
  32. package/dist/messageMeta.js +1 -60
  33. package/dist/messages.d.ts +34900 -1862
  34. package/dist/messages.js +1 -35
  35. package/dist/notification.d.ts +48 -0
  36. package/dist/notification.js +1 -0
  37. package/dist/ops.d.ts +165 -122
  38. package/dist/ops.js +1 -74
  39. package/dist/pairing.d.ts +4 -4
  40. package/dist/pairing.js +1 -150
  41. package/dist/permissionSubject.js +1 -68
  42. package/dist/protocol.js +1 -7
  43. package/dist/rpc.d.ts +749 -189
  44. package/dist/rpc.js +1 -269
  45. package/dist/scheduledTasks.d.ts +619 -304
  46. package/dist/scheduledTasks.js +1 -188
  47. package/dist/semver.js +1 -60
  48. package/dist/sessionResult.d.ts +31 -17
  49. package/dist/sessionResult.js +1 -23
  50. package/dist/socketEvents.d.ts +7 -0
  51. package/dist/socketEvents.js +1 -55
  52. package/dist/sourceMetadata.d.ts +44 -0
  53. package/dist/sourceMetadata.js +1 -0
  54. package/dist/spawnError.d.ts +21 -17
  55. package/dist/spawnError.js +1 -31
  56. package/dist/stats.d.ts +73 -73
  57. package/dist/stats.js +1 -117
  58. package/dist/sync.d.ts +2165 -819
  59. package/dist/sync.js +1 -99
  60. package/dist/taskResult.js +1 -113
  61. package/dist/telemetry.d.ts +120 -64
  62. package/dist/telemetry.js +1 -115
  63. package/dist/utils.js +1 -2
  64. package/package.json +3 -2
  65. package/dist/activityPreferences.d.ts.map +0 -1
  66. package/dist/activityPreferences.js.map +0 -1
  67. package/dist/agentCapabilities.d.ts.map +0 -1
  68. package/dist/agentCapabilities.js.map +0 -1
  69. package/dist/agentCommonEnv.d.ts.map +0 -1
  70. package/dist/agentCommonEnv.js.map +0 -1
  71. package/dist/agentInstallGuide.d.ts.map +0 -1
  72. package/dist/agentInstallGuide.js.map +0 -1
  73. package/dist/bgTask.d.ts.map +0 -1
  74. package/dist/bgTask.js.map +0 -1
  75. package/dist/checkpointSchemas.d.ts.map +0 -1
  76. package/dist/checkpointSchemas.js.map +0 -1
  77. package/dist/controlLevel.d.ts.map +0 -1
  78. package/dist/controlLevel.js.map +0 -1
  79. package/dist/edition.d.ts.map +0 -1
  80. package/dist/edition.js.map +0 -1
  81. package/dist/envelope.d.ts.map +0 -1
  82. package/dist/envelope.js.map +0 -1
  83. package/dist/errorMessage.d.ts.map +0 -1
  84. package/dist/errorMessage.js.map +0 -1
  85. package/dist/events.d.ts.map +0 -1
  86. package/dist/events.js.map +0 -1
  87. package/dist/features.d.ts.map +0 -1
  88. package/dist/features.js.map +0 -1
  89. package/dist/feedback.d.ts.map +0 -1
  90. package/dist/feedback.js.map +0 -1
  91. package/dist/fileWhitelist.d.ts.map +0 -1
  92. package/dist/fileWhitelist.js.map +0 -1
  93. package/dist/index.d.ts.map +0 -1
  94. package/dist/index.js.map +0 -1
  95. package/dist/interactionEvents.d.ts.map +0 -1
  96. package/dist/interactionEvents.js.map +0 -1
  97. package/dist/legacyProtocol.d.ts.map +0 -1
  98. package/dist/legacyProtocol.js.map +0 -1
  99. package/dist/license.d.ts.map +0 -1
  100. package/dist/license.js.map +0 -1
  101. package/dist/machine.d.ts.map +0 -1
  102. package/dist/machine.js.map +0 -1
  103. package/dist/messageMeta.d.ts.map +0 -1
  104. package/dist/messageMeta.js.map +0 -1
  105. package/dist/messages.d.ts.map +0 -1
  106. package/dist/messages.js.map +0 -1
  107. package/dist/ops.d.ts.map +0 -1
  108. package/dist/ops.js.map +0 -1
  109. package/dist/pairing.d.ts.map +0 -1
  110. package/dist/pairing.js.map +0 -1
  111. package/dist/permissionSubject.d.ts.map +0 -1
  112. package/dist/permissionSubject.js.map +0 -1
  113. package/dist/protocol.d.ts.map +0 -1
  114. package/dist/protocol.js.map +0 -1
  115. package/dist/rpc.d.ts.map +0 -1
  116. package/dist/rpc.js.map +0 -1
  117. package/dist/scheduledTasks.d.ts.map +0 -1
  118. package/dist/scheduledTasks.js.map +0 -1
  119. package/dist/semver.d.ts.map +0 -1
  120. package/dist/semver.js.map +0 -1
  121. package/dist/sessionResult.d.ts.map +0 -1
  122. package/dist/sessionResult.js.map +0 -1
  123. package/dist/socketEvents.d.ts.map +0 -1
  124. package/dist/socketEvents.js.map +0 -1
  125. package/dist/spawnError.d.ts.map +0 -1
  126. package/dist/spawnError.js.map +0 -1
  127. package/dist/stats.d.ts.map +0 -1
  128. package/dist/stats.js.map +0 -1
  129. package/dist/sync.d.ts.map +0 -1
  130. package/dist/sync.js.map +0 -1
  131. package/dist/taskResult.d.ts.map +0 -1
  132. package/dist/taskResult.js.map +0 -1
  133. package/dist/telemetry.d.ts.map +0 -1
  134. package/dist/telemetry.js.map +0 -1
  135. package/dist/utils.d.ts.map +0 -1
  136. package/dist/utils.js.map +0 -1
package/dist/events.js CHANGED
@@ -1,107 +1 @@
1
- /**
2
- * Session event schemas.
3
- *
4
- * Event types: text, service, tool-call-start, tool-call-end,
5
- * file, turn-start, turn-end, start, stop.
6
- */
7
- import { z } from 'zod';
8
- import { SessionQuestionEventSchema, SessionPermissionRequestEventSchema, SessionAnswerEventSchema, SessionPermissionResolvedEventSchema, } from './interactionEvents.js';
9
- export const SessionTextEventSchema = z.object({
10
- t: z.literal('text'),
11
- text: z.string(),
12
- thinking: z.boolean().optional(),
13
- images: z
14
- .array(z.object({
15
- data: z.string(),
16
- mediaType: z.string(),
17
- }))
18
- .optional(),
19
- });
20
- export const SessionServiceEventSchema = z.object({
21
- t: z.literal('service'),
22
- text: z.string(),
23
- });
24
- export const SessionToolCallStartEventSchema = z.object({
25
- t: z.literal('tool-call-start'),
26
- call: z.string(),
27
- name: z.string(),
28
- title: z.string(),
29
- description: z.string(),
30
- args: z.record(z.string(), z.unknown()),
31
- });
32
- export const SessionToolCallEndEventSchema = z.object({
33
- t: z.literal('tool-call-end'),
34
- call: z.string(),
35
- /** Tool output text (may be truncated at source). */
36
- result: z.string().optional(),
37
- /** True when the tool returned an error result. */
38
- error: z.boolean().optional(),
39
- });
40
- export const SessionFileEventSchema = z.object({
41
- t: z.literal('file'),
42
- ref: z.string(),
43
- name: z.string(),
44
- size: z.number(),
45
- image: z
46
- .object({
47
- width: z.number(),
48
- height: z.number(),
49
- thumbhash: z.string(),
50
- })
51
- .optional(),
52
- });
53
- export const SessionTurnStartEventSchema = z.object({
54
- t: z.literal('turn-start'),
55
- });
56
- export const SessionTurnEndStatusSchema = z.enum(['completed', 'failed', 'cancelled']);
57
- /** Token usage stats reported at turn end. */
58
- export const TurnUsageSchema = z.object({
59
- inputTokens: z.number().int().nonnegative(),
60
- outputTokens: z.number().int().nonnegative(),
61
- cacheReadTokens: z.number().int().nonnegative().optional(),
62
- cacheWriteTokens: z.number().int().nonnegative().optional(),
63
- });
64
- export const SessionTurnEndEventSchema = z.object({
65
- t: z.literal('turn-end'),
66
- status: SessionTurnEndStatusSchema,
67
- usage: TurnUsageSchema.optional(),
68
- model: z.string().optional(),
69
- /** Wall-clock duration of the turn in milliseconds (Date.now() diff). */
70
- durationMs: z.number().int().nonnegative().optional(),
71
- });
72
- export const SessionStartEventSchema = z.object({
73
- t: z.literal('start'),
74
- title: z.string().optional(),
75
- /** Claude background task ID for cancellation (RFC-058 Phase 2). */
76
- taskId: z.string().optional(),
77
- });
78
- export const SessionStopEventSchema = z.object({
79
- t: z.literal('stop'),
80
- });
81
- /** User-sent image stored inline in envelope (base64). */
82
- export const SessionImageEventSchema = z.object({
83
- t: z.literal('image'),
84
- /** Base64-encoded image data. */
85
- data: z.string(),
86
- /** MIME type: image/jpeg, image/png, image/gif, image/webp. */
87
- mediaType: z.string(),
88
- });
89
- export const SessionEventSchema = z.discriminatedUnion('t', [
90
- SessionTextEventSchema,
91
- SessionServiceEventSchema,
92
- SessionToolCallStartEventSchema,
93
- SessionToolCallEndEventSchema,
94
- SessionFileEventSchema,
95
- SessionTurnStartEventSchema,
96
- SessionTurnEndEventSchema,
97
- SessionStartEventSchema,
98
- SessionStopEventSchema,
99
- SessionQuestionEventSchema,
100
- SessionPermissionRequestEventSchema,
101
- SessionAnswerEventSchema,
102
- SessionPermissionResolvedEventSchema,
103
- SessionImageEventSchema,
104
- ]);
105
- // Re-export interaction event schemas for convenience
106
- export { SessionQuestionEventSchema, SessionPermissionRequestEventSchema, SessionAnswerEventSchema, SessionPermissionResolvedEventSchema, PermissionActionSchema, ImageAttachmentSchema, } from './interactionEvents.js';
107
- //# sourceMappingURL=events.js.map
1
+ "use strict";import{z as e}from"zod";import{SessionQuestionEventSchema as o,SessionPermissionRequestEventSchema as s,SessionAnswerEventSchema as r,SessionPermissionResolvedEventSchema as a}from"./interactionEvents.js";export const SessionTextEventSchema=e.object({t:e.literal("text"),text:e.string(),thinking:e.boolean().optional(),images:e.array(e.object({data:e.string(),mediaType:e.string()})).optional()}).passthrough(),SessionServiceEventSchema=e.object({t:e.literal("service"),text:e.string()}).passthrough(),SessionToolCallStartEventSchema=e.object({t:e.literal("tool-call-start"),call:e.string(),name:e.string(),title:e.string(),description:e.string(),args:e.record(e.string(),e.unknown())}).passthrough(),SessionToolCallEndEventSchema=e.object({t:e.literal("tool-call-end"),call:e.string(),result:e.string().optional(),error:e.boolean().optional()}).passthrough(),SessionFileEventSchema=e.object({t:e.literal("file"),ref:e.string(),name:e.string(),size:e.number(),image:e.object({width:e.number(),height:e.number(),thumbhash:e.string()}).optional()}).passthrough(),SessionTurnStartEventSchema=e.object({t:e.literal("turn-start")}).passthrough(),SessionTurnEndStatusSchema=e.enum(["completed","failed","cancelled"]),TurnUsageSchema=e.object({inputTokens:e.number().int().nonnegative(),outputTokens:e.number().int().nonnegative(),cacheReadTokens:e.number().int().nonnegative().optional(),cacheWriteTokens:e.number().int().nonnegative().optional()}).passthrough(),SessionTurnEndEventSchema=e.object({t:e.literal("turn-end"),status:SessionTurnEndStatusSchema,usage:TurnUsageSchema.optional(),model:e.string().optional(),durationMs:e.number().int().nonnegative().optional(),compact:e.boolean().optional()}).passthrough(),SessionStartEventSchema=e.object({t:e.literal("start"),title:e.string().optional(),taskId:e.string().optional()}).passthrough(),SessionStopEventSchema=e.object({t:e.literal("stop")}).passthrough(),SessionImageEventSchema=e.object({t:e.literal("image"),data:e.string(),mediaType:e.string()}).passthrough(),SessionContextUsageEventSchema=e.object({t:e.literal("context-usage"),categories:e.array(e.object({name:e.string(),tokens:e.number(),color:e.string()}).passthrough()),totalTokens:e.number(),maxTokens:e.number(),percentage:e.number(),gridRows:e.array(e.array(e.object({color:e.string(),isFilled:e.boolean(),categoryName:e.string(),tokens:e.number(),percentage:e.number(),squareFullness:e.number()}).passthrough())),model:e.string(),memoryFiles:e.array(e.object({path:e.string(),type:e.string(),tokens:e.number()}).passthrough()),mcpTools:e.array(e.object({name:e.string(),serverName:e.string(),tokens:e.number(),isLoaded:e.boolean().optional()}).passthrough()),deferredBuiltinTools:e.array(e.object({name:e.string(),tokens:e.number(),isLoaded:e.boolean()}).passthrough()).optional(),systemTools:e.array(e.object({name:e.string(),tokens:e.number()}).passthrough()).optional(),systemPromptSections:e.array(e.object({name:e.string(),tokens:e.number()}).passthrough()).optional(),agents:e.array(e.object({agentType:e.string(),source:e.string(),tokens:e.number()})),slashCommands:e.object({totalCommands:e.number(),includedCommands:e.number(),tokens:e.number()}).passthrough().optional(),skills:e.object({totalSkills:e.number(),includedSkills:e.number(),tokens:e.number(),skillFrontmatter:e.array(e.record(e.unknown()))}).passthrough().optional(),messageBreakdown:e.object({toolCallTokens:e.number(),toolResultTokens:e.number(),attachmentTokens:e.number(),assistantMessageTokens:e.number(),userMessageTokens:e.number(),redirectedContextTokens:e.number().optional(),unattributedTokens:e.number().optional(),toolCallsByType:e.array(e.object({name:e.string(),callTokens:e.number(),resultTokens:e.number()}).passthrough()).optional(),attachmentsByType:e.array(e.object({name:e.string(),tokens:e.number()}).passthrough()).optional()}).passthrough().optional(),apiUsage:e.object({input_tokens:e.number(),output_tokens:e.number(),cache_creation_input_tokens:e.number(),cache_read_input_tokens:e.number()}).passthrough().nullable()}).passthrough(),SessionCompactBoundaryEventSchema=e.object({t:e.literal("compact-boundary"),trigger:e.enum(["manual","auto"]),preTokens:e.number(),postTokens:e.number().optional(),durationMs:e.number().optional()}).passthrough(),SessionEventSchema=e.discriminatedUnion("t",[SessionTextEventSchema,SessionServiceEventSchema,SessionToolCallStartEventSchema,SessionToolCallEndEventSchema,SessionFileEventSchema,SessionTurnStartEventSchema,SessionTurnEndEventSchema,SessionStartEventSchema,SessionStopEventSchema,o,s,r,a,SessionImageEventSchema,SessionContextUsageEventSchema,SessionCompactBoundaryEventSchema]);export function emptyContextUsageSnapshot(t="",n=0){return{t:"context-usage",categories:[],totalTokens:0,maxTokens:n,percentage:0,gridRows:[],model:t,memoryFiles:[],mcpTools:[],agents:[],apiUsage:null}}export{SessionQuestionEventSchema,SessionPermissionRequestEventSchema,SessionAnswerEventSchema,SessionPermissionResolvedEventSchema,PermissionActionSchema,ImageAttachmentSchema}from"./interactionEvents.js";
package/dist/features.js CHANGED
@@ -1,123 +1 @@
1
- /* Feature availability layer (RFC-035).
2
- *
3
- * Maps high-level features to the RPC methods they require.
4
- * Used by web to determine which features a daemon supports
5
- * based on the methods it has registered.
6
- */
7
- import { satisfiesMin } from './semver.js';
8
- /**
9
- * Registry of all known features and their RPC dependencies.
10
- * Add new entries here when introducing features that require new daemon RPC methods.
11
- */
12
- export const FEATURE_REGISTRY = [
13
- {
14
- id: 'agent-settings',
15
- requiredMethods: ['get-agent-settings', 'set-agent-settings'],
16
- sinceVersion: '0.0.4',
17
- subFeatures: [{ id: 'startup-scripts', sinceVersion: '0.0.30' }],
18
- },
19
- {
20
- id: 'labs-settings',
21
- requiredMethods: ['get-labs-settings', 'set-labs-settings'],
22
- sinceVersion: '0.0.12',
23
- },
24
- {
25
- id: 'history-sync',
26
- requiredMethods: ['backfill-history-session'],
27
- sinceVersion: '0.0.12',
28
- },
29
- {
30
- id: 'check-path',
31
- requiredMethods: ['check-path'],
32
- sinceVersion: '0.0.7',
33
- },
34
- {
35
- id: 'remote-upgrade',
36
- requiredMethods: ['trigger-upgrade'],
37
- sinceVersion: '0.0.30',
38
- },
39
- {
40
- id: 'checkpoint',
41
- requiredMethods: ['checkpoint-list', 'checkpoint-diff', 'checkpoint-rollback'],
42
- sinceVersion: '0.0.30',
43
- subFeatures: [{ id: 'conversation-rollback', sinceVersion: '0.0.32' }],
44
- },
45
- {
46
- id: 'scheduled-tasks',
47
- requiredMethods: ['spawn-session'],
48
- sinceVersion: '0.0.35',
49
- },
50
- {
51
- id: 'auto-upgrade-daemon',
52
- requiredMethods: ['set-auto-upgrade-daemon'],
53
- sinceVersion: '0.0.31',
54
- },
55
- {
56
- id: 'file-upload',
57
- requiredMethods: ['file-relay-receive'],
58
- sinceVersion: '0.0.36',
59
- edition: 'personal',
60
- },
61
- ];
62
- /**
63
- * Check whether a specific feature is available given the set of supported methods.
64
- * A feature is available when ALL its required methods are present.
65
- */
66
- export function isFeatureAvailable(featureId, supportedMethods) {
67
- const feature = FEATURE_REGISTRY.find((f) => f.id === featureId);
68
- if (!feature)
69
- return false;
70
- const methodSet = new Set(supportedMethods);
71
- return feature.requiredMethods.every((m) => methodSet.has(m));
72
- }
73
- /**
74
- * Check whether a sub-feature is available given supported methods and daemon version.
75
- * Requires the parent feature to be available AND the daemon version to satisfy the sub-feature minimum.
76
- */
77
- export function isSubFeatureAvailable(featureId, subFeatureId, supportedMethods, daemonVersion) {
78
- const feature = FEATURE_REGISTRY.find((f) => f.id === featureId);
79
- if (!feature)
80
- return false;
81
- if (!isFeatureAvailable(featureId, supportedMethods))
82
- return false;
83
- const sub = feature.subFeatures?.find((s) => s.id === subFeatureId);
84
- if (!sub)
85
- return false;
86
- if (!daemonVersion || !satisfiesMin(daemonVersion, sub.sinceVersion))
87
- return false;
88
- if (sub.requiredMethods) {
89
- const methodSet = new Set(supportedMethods);
90
- return sub.requiredMethods.every((m) => methodSet.has(m));
91
- }
92
- return true;
93
- }
94
- /** Look up the minimum version required for a sub-feature. */
95
- export function getSubFeatureMinVersion(featureId, subFeatureId) {
96
- const feature = FEATURE_REGISTRY.find((f) => f.id === featureId);
97
- return feature?.subFeatures?.find((s) => s.id === subFeatureId)?.sinceVersion;
98
- }
99
- /**
100
- * Return all features (and sub-features) that are NOT available.
101
- * Sub-features are returned as "parentId/subId" when the parent is available
102
- * but the daemon version is too low for the sub-feature.
103
- */
104
- export function getUnavailableFeatures(supportedMethods, daemonVersion) {
105
- const results = [];
106
- const methodSet = new Set(supportedMethods);
107
- for (const f of FEATURE_REGISTRY) {
108
- if (!f.requiredMethods.every((m) => methodSet.has(m))) {
109
- results.push({ id: f.id, sinceVersion: f.sinceVersion });
110
- }
111
- else if (f.subFeatures && daemonVersion) {
112
- for (const sub of f.subFeatures) {
113
- const versionLocked = !satisfiesMin(daemonVersion, sub.sinceVersion);
114
- const methodsLocked = sub.requiredMethods != null && !sub.requiredMethods.every((m) => methodSet.has(m));
115
- if (versionLocked || methodsLocked) {
116
- results.push({ id: `${f.id}/${sub.id}`, sinceVersion: sub.sinceVersion });
117
- }
118
- }
119
- }
120
- }
121
- return results;
122
- }
123
- //# sourceMappingURL=features.js.map
1
+ "use strict";import{satisfiesMin as u}from"./semver.js";export const FEATURE_REGISTRY=[{id:"agent-settings",requiredMethods:["get-agent-settings","set-agent-settings"],sinceVersion:"0.0.4",subFeatures:[{id:"startup-scripts",sinceVersion:"0.0.30"}]},{id:"labs-settings",requiredMethods:["get-labs-settings","set-labs-settings"],sinceVersion:"0.0.12"},{id:"history-sync",requiredMethods:["backfill-history-session"],sinceVersion:"0.0.12"},{id:"check-path",requiredMethods:["check-path"],sinceVersion:"0.0.7"},{id:"remote-upgrade",requiredMethods:["trigger-upgrade"],sinceVersion:"0.0.30"},{id:"checkpoint",requiredMethods:["checkpoint-list","checkpoint-diff","checkpoint-rollback"],sinceVersion:"0.0.30",subFeatures:[{id:"conversation-rollback",sinceVersion:"0.0.32"}]},{id:"scheduled-tasks",requiredMethods:["spawn-session"],sinceVersion:"0.0.35"},{id:"auto-upgrade-daemon",requiredMethods:["set-auto-upgrade-daemon"],sinceVersion:"0.0.31"},{id:"file-upload",requiredMethods:["file-relay-receive"],sinceVersion:"0.0.36",edition:"personal"},{id:"context-usage",requiredMethods:["get-context-usage"],sinceVersion:"0.0.71"}];export function isFeatureAvailable(r,n){const t=FEATURE_REGISTRY.find(e=>e.id===r);if(!t)return!1;const i=new Set(n);return t.requiredMethods.every(e=>i.has(e))}export function isSubFeatureAvailable(r,n,t,i){const e=FEATURE_REGISTRY.find(o=>o.id===r);if(!e||!isFeatureAvailable(r,t))return!1;const s=e.subFeatures?.find(o=>o.id===n);if(!s||!i||!u(i,s.sinceVersion))return!1;if(s.requiredMethods){const o=new Set(t);return s.requiredMethods.every(d=>o.has(d))}return!0}export function getSubFeatureMinVersion(r,n){return FEATURE_REGISTRY.find(i=>i.id===r)?.subFeatures?.find(i=>i.id===n)?.sinceVersion}export function getUnavailableFeatures(r,n){const t=[],i=new Set(r);for(const e of FEATURE_REGISTRY)if(!e.requiredMethods.every(s=>i.has(s)))t.push({id:e.id,sinceVersion:e.sinceVersion});else if(e.subFeatures&&n)for(const s of e.subFeatures){const o=!u(n,s.sinceVersion),d=s.requiredMethods!=null&&!s.requiredMethods.every(c=>i.has(c));(o||d)&&t.push({id:`${e.id}/${s.id}`,sinceVersion:s.sinceVersion})}return t}
@@ -338,7 +338,7 @@ export declare const CreateFeedbackSchema: z.ZodObject<{
338
338
  actualBehavior?: string | undefined;
339
339
  errorMessages?: string | undefined;
340
340
  }>>;
341
- }, "strip", z.ZodTypeAny, {
341
+ }, "strict", z.ZodTypeAny, {
342
342
  type: "BUG" | "FEATURE" | "OTHER";
343
343
  description: string;
344
344
  deviceInfo: {
@@ -415,7 +415,7 @@ export type CreateFeedback = z.infer<typeof CreateFeedbackSchema>;
415
415
  export declare const UpdateFeedbackSchema: z.ZodObject<{
416
416
  status: z.ZodOptional<z.ZodEnum<["READ", "ARCHIVED"]>>;
417
417
  reply: z.ZodOptional<z.ZodString>;
418
- }, "strip", z.ZodTypeAny, {
418
+ }, "strict", z.ZodTypeAny, {
419
419
  status?: "READ" | "ARCHIVED" | undefined;
420
420
  reply?: string | undefined;
421
421
  }, {
package/dist/feedback.js CHANGED
@@ -1,61 +1 @@
1
- // KNOWN-DEBT: feedback 模块导出类型零消费 + web 侧重复定义 (see docs/ops/KNOWN-DEBT.md)
2
- import { z } from 'zod';
3
- export const FeedbackTypeSchema = z.enum(['BUG', 'FEATURE', 'OTHER']);
4
- export const FeedbackStatusSchema = z.enum(['UNREAD', 'READ', 'ARCHIVED']);
5
- export const RunModeSchema = z.enum([
6
- 'web-session',
7
- 'cli-spawn',
8
- 'cli-run',
9
- 'scheduled',
10
- 'unknown',
11
- ]);
12
- export const RunModesSchema = z.array(RunModeSchema).max(5);
13
- export const BugFieldsSchema = z.object({
14
- reproSteps: z.string().max(2000).optional(),
15
- expectedBehavior: z.string().max(1000).optional(),
16
- actualBehavior: z.string().max(1000).optional(),
17
- errorMessages: z.string().max(2000).optional(),
18
- });
19
- export const SettingsSnapshotSchema = z.object({
20
- browser: z
21
- .object({
22
- userAgent: z.string(),
23
- viewport: z.string(),
24
- language: z.string(),
25
- })
26
- .optional(),
27
- /** Per-machine diagnostics: platform, arch, daemonVersion, availableAgents, agentCliPaths */
28
- machines: z.record(z.string(), z.record(z.unknown())).optional(),
29
- preferences: z.record(z.unknown()).optional(),
30
- labs: z.record(z.unknown()).optional(),
31
- });
32
- export const MachineSnapshotSchema = z.object({
33
- machineId: z.string(),
34
- platform: z.string().optional(),
35
- arch: z.string().optional(),
36
- hostname: z.string().optional(),
37
- daemonVersion: z.string().optional(),
38
- availableAgents: z.array(z.string()).optional(),
39
- agentVersions: z.record(z.string()).optional(),
40
- nodeVersion: z.string().optional(),
41
- });
42
- export const DeviceInfoSchema = z.object({
43
- machines: z.array(MachineSnapshotSchema).optional(),
44
- appVersion: z.string().optional(),
45
- settingsSnapshot: SettingsSnapshotSchema.optional(),
46
- });
47
- export const CreateFeedbackSchema = z.object({
48
- type: FeedbackTypeSchema,
49
- description: z.string().min(0).max(5000),
50
- screenshots: z.array(z.string().max(700_000)).max(3).optional(),
51
- deviceInfo: DeviceInfoSchema,
52
- affectedMachineIds: z.array(z.string()).max(20).optional(),
53
- affectedAgents: z.array(z.string()).max(10).optional(),
54
- runModes: RunModesSchema.optional(),
55
- bugFields: BugFieldsSchema.optional(),
56
- });
57
- export const UpdateFeedbackSchema = z.object({
58
- status: z.enum(['READ', 'ARCHIVED']).optional(),
59
- reply: z.string().min(1).max(5000).optional(),
60
- });
61
- //# sourceMappingURL=feedback.js.map
1
+ "use strict";import{z as o}from"zod";export const FeedbackTypeSchema=o.enum(["BUG","FEATURE","OTHER"]),FeedbackStatusSchema=o.enum(["UNREAD","READ","ARCHIVED"]),RunModeSchema=o.enum(["web-session","cli-spawn","cli-run","scheduled","unknown"]),RunModesSchema=o.array(RunModeSchema).max(5),BugFieldsSchema=o.object({reproSteps:o.string().max(2e3).optional(),expectedBehavior:o.string().max(1e3).optional(),actualBehavior:o.string().max(1e3).optional(),errorMessages:o.string().max(2e3).optional()}),SettingsSnapshotSchema=o.object({browser:o.object({userAgent:o.string(),viewport:o.string(),language:o.string()}).optional(),machines:o.record(o.string(),o.record(o.unknown())).optional(),preferences:o.record(o.unknown()).optional(),labs:o.record(o.unknown()).optional()}),MachineSnapshotSchema=o.object({machineId:o.string(),platform:o.string().optional(),arch:o.string().optional(),hostname:o.string().optional(),daemonVersion:o.string().optional(),availableAgents:o.array(o.string()).optional(),agentVersions:o.record(o.string()).optional(),nodeVersion:o.string().optional()}),DeviceInfoSchema=o.object({machines:o.array(MachineSnapshotSchema).optional(),appVersion:o.string().optional(),settingsSnapshot:SettingsSnapshotSchema.optional()}),CreateFeedbackSchema=o.object({type:FeedbackTypeSchema,description:o.string().min(0).max(5e3),screenshots:o.array(o.string().max(7e5)).max(3).optional(),deviceInfo:DeviceInfoSchema,affectedMachineIds:o.array(o.string()).max(20).optional(),affectedAgents:o.array(o.string()).max(10).optional(),runModes:RunModesSchema.optional(),bugFields:BugFieldsSchema.optional()}).strict(),UpdateFeedbackSchema=o.object({status:o.enum(["READ","ARCHIVED"]).optional(),reply:o.string().min(1).max(5e3).optional()}).strict();
@@ -1,189 +1 @@
1
- /**
2
- * File upload whitelist — single source of truth for personal-edition file
3
- * upload validation, shared across web (PWA client), server (relay preflight),
4
- * and daemon (receiver second-check).
5
- *
6
- * Contains ONLY isomorphic data + pure byte logic (no node:/DOM deps):
7
- * - per-category extension lists and max sizes
8
- * - blocked (executable) extensions
9
- * - magic-byte signatures
10
- * - category resolution + magic-byte verification over Uint8Array
11
- *
12
- * File reading differs per platform (File/FileReader on web, Buffer on
13
- * server/daemon), so callers read the head bytes themselves and pass a
14
- * Uint8Array in. Buffer is a Uint8Array subclass, so `verifyMagicBytes`
15
- * works unchanged on both.
16
- */
17
- /** All file categories in priority order (first match wins in resolveFileCategory). */
18
- const FILE_CATEGORIES = ['text', 'document', 'code', 'image'];
19
- export const TEXT_EXTS = [
20
- '.txt',
21
- '.md',
22
- '.log',
23
- '.csv',
24
- '.json',
25
- '.xml',
26
- '.yaml',
27
- '.yml',
28
- '.toml',
29
- '.env',
30
- ];
31
- export const CODE_EXTS = [
32
- '.ts',
33
- '.tsx',
34
- '.js',
35
- '.jsx',
36
- '.py',
37
- '.rs',
38
- '.go',
39
- '.java',
40
- '.c',
41
- '.cpp',
42
- '.h',
43
- '.css',
44
- '.html',
45
- '.sql',
46
- '.sh',
47
- ];
48
- export const DOC_EXTS = [
49
- '.pdf',
50
- '.doc',
51
- '.docx',
52
- '.xls',
53
- '.xlsx',
54
- '.ppt',
55
- '.pptx',
56
- ];
57
- export const IMG_EXTS = [
58
- '.png',
59
- '.jpg',
60
- '.jpeg',
61
- '.gif',
62
- '.webp',
63
- '.svg',
64
- '.bmp',
65
- ];
66
- /** Per-category max upload size in bytes. */
67
- export const FILE_CATEGORY_MAX_SIZE = {
68
- text: 1 * 1024 * 1024, // 1 MB
69
- document: 2 * 1024 * 1024, // 2 MB
70
- code: 1 * 1024 * 1024, // 1 MB
71
- image: 1 * 1024 * 1024, // 1 MB
72
- };
73
- /** Executable / dangerous extensions — always rejected. */
74
- export const BLOCKED_EXTS = new Set([
75
- '.exe',
76
- '.bat',
77
- '.cmd',
78
- '.msi',
79
- '.dmg',
80
- '.app',
81
- '.com',
82
- '.scr',
83
- ]);
84
- /** All allowed extensions across every category. */
85
- export const ALLOWED_EXTENSIONS = new Set([
86
- ...TEXT_EXTS,
87
- ...CODE_EXTS,
88
- ...DOC_EXTS,
89
- ...IMG_EXTS,
90
- ]);
91
- const CATEGORY_EXTS = {
92
- text: TEXT_EXTS,
93
- code: CODE_EXTS,
94
- document: DOC_EXTS,
95
- image: IMG_EXTS,
96
- };
97
- /**
98
- * Binary magic-byte signatures keyed by extension. `subSig` is checked at an
99
- * offset immediately after `sig` (used by WEBP's RIFF...WEBP layout).
100
- * Text-based formats (text/code/svg) are not here — they use UTF-8 validation.
101
- */
102
- export const FILE_SIGNATURES = {
103
- '.pdf': { sig: [0x25, 0x50, 0x44, 0x46, 0x2d] },
104
- '.doc': { sig: [0xd0, 0xcf, 0x11, 0xe0, 0xa1, 0xb1, 0x1a, 0xe1] },
105
- '.xls': { sig: [0xd0, 0xcf, 0x11, 0xe0, 0xa1, 0xb1, 0x1a, 0xe1] },
106
- '.ppt': { sig: [0xd0, 0xcf, 0x11, 0xe0, 0xa1, 0xb1, 0x1a, 0xe1] },
107
- '.docx': { sig: [0x50, 0x4b, 0x03, 0x04] },
108
- '.xlsx': { sig: [0x50, 0x4b, 0x03, 0x04] },
109
- '.pptx': { sig: [0x50, 0x4b, 0x03, 0x04] },
110
- '.png': { sig: [0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a] },
111
- '.jpg': { sig: [0xff, 0xd8, 0xff] },
112
- '.jpeg': { sig: [0xff, 0xd8, 0xff] },
113
- '.gif': { sig: [0x47, 0x49, 0x46, 0x38] }, // GIF8
114
- '.webp': { sig: [0x52, 0x49, 0x46, 0x46], subSigAt: 8, subSig: [0x57, 0x45, 0x42, 0x50] }, // RIFF....WEBP
115
- '.bmp': { sig: [0x42, 0x4d] }, // BM
116
- };
117
- /** Lowercased extension (including leading dot) or '' if none. */
118
- export function getFileExt(filename) {
119
- const lastDot = filename.lastIndexOf('.');
120
- return lastDot >= 0 ? filename.substring(lastDot).toLowerCase() : '';
121
- }
122
- /**
123
- * Resolve the whitelist category for an extension.
124
- * Returns null for blocked, unknown, or extension-less files.
125
- */
126
- export function resolveFileCategory(ext) {
127
- if (ext === '' || BLOCKED_EXTS.has(ext))
128
- return null;
129
- for (const cat of FILE_CATEGORIES) {
130
- if (CATEGORY_EXTS[cat].includes(ext))
131
- return cat;
132
- }
133
- return null;
134
- }
135
- /** UTF-8 decode without throwing — returns null on invalid bytes. */
136
- function tryUtf8Decode(bytes) {
137
- try {
138
- return new TextDecoder('utf-8', { fatal: true }).decode(bytes);
139
- }
140
- catch {
141
- // SILENT-CATCH-OK: tryUtf8Decode returns null on decode failure, caller handles
142
- return null;
143
- }
144
- }
145
- /** True if the head bytes look like SVG (XML text starting with <?xml/<svg/<!DOCTYPE svg). */
146
- function looksLikeSvg(head) {
147
- const s = tryUtf8Decode(head.subarray(0, Math.min(head.length, 512)));
148
- if (s === null)
149
- return false;
150
- const trimmed = (s.charCodeAt(0) === 0xfeff ? s.slice(1) : s).trimStart();
151
- return (trimmed.startsWith('<?xml') || trimmed.startsWith('<svg') || trimmed.startsWith('<!DOCTYPE svg'));
152
- }
153
- /**
154
- * Verify head bytes match the expected type for `ext`.
155
- * - text/code: valid UTF-8
156
- * - svg: XML text sniff
157
- * - binary formats: magic-byte signature (+ optional sub-signature)
158
- *
159
- * `ext` must already be lowercased (use getFileExt). Buffer is a Uint8Array
160
- * subclass, so server/daemon can pass a Buffer directly.
161
- */
162
- export function verifyMagicBytes(head, ext) {
163
- if (TEXT_EXTS.includes(ext) || CODE_EXTS.includes(ext)) {
164
- return tryUtf8Decode(head) !== null;
165
- }
166
- if (ext === '.svg') {
167
- return looksLikeSvg(head);
168
- }
169
- const rule = FILE_SIGNATURES[ext];
170
- if (!rule)
171
- return false;
172
- if (head.length < rule.sig.length)
173
- return false;
174
- for (let i = 0; i < rule.sig.length; i++) {
175
- if (head[i] !== rule.sig[i])
176
- return false;
177
- }
178
- if (rule.subSig) {
179
- const offset = rule.subSigAt ?? rule.sig.length;
180
- if (head.length < offset + rule.subSig.length)
181
- return false;
182
- for (let i = 0; i < rule.subSig.length; i++) {
183
- if (head[offset + i] !== rule.subSig[i])
184
- return false;
185
- }
186
- }
187
- return true;
188
- }
189
- //# sourceMappingURL=fileWhitelist.js.map
1
+ "use strict";const i=["text","document","code","image"];export const TEXT_EXTS=[".txt",".md",".log",".csv",".json",".xml",".yaml",".yml",".toml",".env"],CODE_EXTS=[".ts",".tsx",".js",".jsx",".py",".rs",".go",".java",".c",".cpp",".h",".css",".html",".sql",".sh"],DOC_EXTS=[".pdf",".doc",".docx",".xls",".xlsx",".ppt",".pptx"],IMG_EXTS=[".png",".jpg",".jpeg",".gif",".webp",".svg",".bmp"],FILE_CATEGORY_MAX_SIZE={text:1048576,document:2097152,code:1048576,image:1048576},BLOCKED_EXTS=new Set([".exe",".bat",".cmd",".msi",".dmg",".app",".com",".scr"]),ALLOWED_EXTENSIONS=new Set([...TEXT_EXTS,...CODE_EXTS,...DOC_EXTS,...IMG_EXTS]);const o={text:TEXT_EXTS,code:CODE_EXTS,document:DOC_EXTS,image:IMG_EXTS};export const FILE_SIGNATURES={".pdf":{sig:[37,80,68,70,45]},".doc":{sig:[208,207,17,224,161,177,26,225]},".xls":{sig:[208,207,17,224,161,177,26,225]},".ppt":{sig:[208,207,17,224,161,177,26,225]},".docx":{sig:[80,75,3,4]},".xlsx":{sig:[80,75,3,4]},".pptx":{sig:[80,75,3,4]},".png":{sig:[137,80,78,71,13,10,26,10]},".jpg":{sig:[255,216,255]},".jpeg":{sig:[255,216,255]},".gif":{sig:[71,73,70,56]},".webp":{sig:[82,73,70,70],subSigAt:8,subSig:[87,69,66,80]},".bmp":{sig:[66,77]}};export function getFileExt(t){const x=t.lastIndexOf(".");return x>=0?t.substring(x).toLowerCase():""}export function resolveFileCategory(t){if(t===""||BLOCKED_EXTS.has(t))return null;for(const x of i)if(o[x].includes(t))return x;return null}function r(t){try{return new TextDecoder("utf-8",{fatal:!0}).decode(t)}catch{return null}}function g(t){const x=r(t.subarray(0,Math.min(t.length,512)));if(x===null)return!1;const e=(x.charCodeAt(0)===65279?x.slice(1):x).trimStart();return e.startsWith("<?xml")||e.startsWith("<svg")||e.startsWith("<!DOCTYPE svg")}export function verifyMagicBytes(t,x){if(TEXT_EXTS.includes(x)||CODE_EXTS.includes(x))return r(t)!==null;if(x===".svg")return g(t);const e=FILE_SIGNATURES[x];if(!e||t.length<e.sig.length)return!1;for(let s=0;s<e.sig.length;s++)if(t[s]!==e.sig[s])return!1;if(e.subSig){const s=e.subSigAt??e.sig.length;if(t.length<s+e.subSig.length)return!1;for(let n=0;n<e.subSig.length;n++)if(t[s+n]!==e.subSig[n])return!1}return!0}