@roll-agent/core 0.7.0 → 0.8.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.
@@ -17,16 +17,19 @@ export declare const BrowserSecurityDiagnosticSchema: z.ZodObject<{
17
17
  maxPageContentBytes: z.ZodNumber;
18
18
  maxSnapshotNodes: z.ZodNumber;
19
19
  actionPolicy: z.ZodEnum<["log", "deny", "confirm"]>;
20
+ foregroundPolicy: z.ZodDefault<z.ZodEnum<["when-minimized", "always", "never"]>>;
20
21
  }, "strip", z.ZodTypeAny, {
21
22
  domainAllowlist: string[];
22
23
  maxPageContentBytes: number;
23
24
  maxSnapshotNodes: number;
24
25
  actionPolicy: "log" | "deny" | "confirm";
26
+ foregroundPolicy: "never" | "when-minimized" | "always";
25
27
  }, {
26
28
  domainAllowlist: string[];
27
29
  maxPageContentBytes: number;
28
30
  maxSnapshotNodes: number;
29
31
  actionPolicy: "log" | "deny" | "confirm";
32
+ foregroundPolicy?: "never" | "when-minimized" | "always" | undefined;
30
33
  }>;
31
34
  export declare const BrowserUseToolPolicyDiagnosticSchema: z.ZodObject<{
32
35
  approvalTtlMs: z.ZodNumber;
@@ -58,6 +61,88 @@ export declare const BrowserUsePolicyWarningDiagnosticSchema: z.ZodObject<{
58
61
  code: string;
59
62
  message: string;
60
63
  }>;
64
+ export declare const BrowserInstanceStatusDiagnosticSchema: z.ZodObject<{
65
+ id: z.ZodString;
66
+ platform: z.ZodOptional<z.ZodEnum<["zhipin", "yupao"]>>;
67
+ mode: z.ZodEnum<["managed-cdp", "remote-cdp", "existing-session"]>;
68
+ cdp: z.ZodObject<{
69
+ endpoint: z.ZodString;
70
+ port: z.ZodOptional<z.ZodNumber>;
71
+ versionReachable: z.ZodBoolean;
72
+ listReachable: z.ZodBoolean;
73
+ }, "strip", z.ZodTypeAny, {
74
+ endpoint: string;
75
+ versionReachable: boolean;
76
+ listReachable: boolean;
77
+ port?: number | undefined;
78
+ }, {
79
+ endpoint: string;
80
+ versionReachable: boolean;
81
+ listReachable: boolean;
82
+ port?: number | undefined;
83
+ }>;
84
+ profile: z.ZodObject<{
85
+ userDataDir: z.ZodOptional<z.ZodString>;
86
+ exists: z.ZodBoolean;
87
+ writable: z.ZodBoolean;
88
+ }, "strip", z.ZodTypeAny, {
89
+ exists: boolean;
90
+ writable: boolean;
91
+ userDataDir?: string | undefined;
92
+ }, {
93
+ exists: boolean;
94
+ writable: boolean;
95
+ userDataDir?: string | undefined;
96
+ }>;
97
+ tracking: z.ZodObject<{
98
+ source: z.ZodEnum<["instance", "default-env", "missing"]>;
99
+ agentIdFingerprint: z.ZodOptional<z.ZodString>;
100
+ }, "strip", z.ZodTypeAny, {
101
+ source: "instance" | "missing" | "default-env";
102
+ agentIdFingerprint?: string | undefined;
103
+ }, {
104
+ source: "instance" | "missing" | "default-env";
105
+ agentIdFingerprint?: string | undefined;
106
+ }>;
107
+ }, "strip", z.ZodTypeAny, {
108
+ mode: "managed-cdp" | "remote-cdp" | "existing-session";
109
+ id: string;
110
+ cdp: {
111
+ endpoint: string;
112
+ versionReachable: boolean;
113
+ listReachable: boolean;
114
+ port?: number | undefined;
115
+ };
116
+ profile: {
117
+ exists: boolean;
118
+ writable: boolean;
119
+ userDataDir?: string | undefined;
120
+ };
121
+ tracking: {
122
+ source: "instance" | "missing" | "default-env";
123
+ agentIdFingerprint?: string | undefined;
124
+ };
125
+ platform?: "zhipin" | "yupao" | undefined;
126
+ }, {
127
+ mode: "managed-cdp" | "remote-cdp" | "existing-session";
128
+ id: string;
129
+ cdp: {
130
+ endpoint: string;
131
+ versionReachable: boolean;
132
+ listReachable: boolean;
133
+ port?: number | undefined;
134
+ };
135
+ profile: {
136
+ exists: boolean;
137
+ writable: boolean;
138
+ userDataDir?: string | undefined;
139
+ };
140
+ tracking: {
141
+ source: "instance" | "missing" | "default-env";
142
+ agentIdFingerprint?: string | undefined;
143
+ };
144
+ platform?: "zhipin" | "yupao" | undefined;
145
+ }>;
61
146
  export declare const AgentRuntimeEnvDiagnosticPayloadSchema: z.ZodObject<{
62
147
  effectiveEnvSources: z.ZodRecord<z.ZodString, z.ZodObject<{
63
148
  present: z.ZodBoolean;
@@ -74,16 +159,19 @@ export declare const AgentRuntimeEnvDiagnosticPayloadSchema: z.ZodObject<{
74
159
  maxPageContentBytes: z.ZodNumber;
75
160
  maxSnapshotNodes: z.ZodNumber;
76
161
  actionPolicy: z.ZodEnum<["log", "deny", "confirm"]>;
162
+ foregroundPolicy: z.ZodDefault<z.ZodEnum<["when-minimized", "always", "never"]>>;
77
163
  }, "strip", z.ZodTypeAny, {
78
164
  domainAllowlist: string[];
79
165
  maxPageContentBytes: number;
80
166
  maxSnapshotNodes: number;
81
167
  actionPolicy: "log" | "deny" | "confirm";
168
+ foregroundPolicy: "never" | "when-minimized" | "always";
82
169
  }, {
83
170
  domainAllowlist: string[];
84
171
  maxPageContentBytes: number;
85
172
  maxSnapshotNodes: number;
86
173
  actionPolicy: "log" | "deny" | "confirm";
174
+ foregroundPolicy?: "never" | "when-minimized" | "always" | undefined;
87
175
  }>>;
88
176
  toolPolicy: z.ZodOptional<z.ZodObject<{
89
177
  approvalTtlMs: z.ZodNumber;
@@ -115,16 +203,121 @@ export declare const AgentRuntimeEnvDiagnosticPayloadSchema: z.ZodObject<{
115
203
  code: string;
116
204
  message: string;
117
205
  }>, "many">>;
206
+ defaultInstanceId: z.ZodOptional<z.ZodString>;
207
+ primaryInstanceId: z.ZodOptional<z.ZodString>;
208
+ instances: z.ZodOptional<z.ZodArray<z.ZodObject<{
209
+ id: z.ZodString;
210
+ platform: z.ZodOptional<z.ZodEnum<["zhipin", "yupao"]>>;
211
+ mode: z.ZodEnum<["managed-cdp", "remote-cdp", "existing-session"]>;
212
+ cdp: z.ZodObject<{
213
+ endpoint: z.ZodString;
214
+ port: z.ZodOptional<z.ZodNumber>;
215
+ versionReachable: z.ZodBoolean;
216
+ listReachable: z.ZodBoolean;
217
+ }, "strip", z.ZodTypeAny, {
218
+ endpoint: string;
219
+ versionReachable: boolean;
220
+ listReachable: boolean;
221
+ port?: number | undefined;
222
+ }, {
223
+ endpoint: string;
224
+ versionReachable: boolean;
225
+ listReachable: boolean;
226
+ port?: number | undefined;
227
+ }>;
228
+ profile: z.ZodObject<{
229
+ userDataDir: z.ZodOptional<z.ZodString>;
230
+ exists: z.ZodBoolean;
231
+ writable: z.ZodBoolean;
232
+ }, "strip", z.ZodTypeAny, {
233
+ exists: boolean;
234
+ writable: boolean;
235
+ userDataDir?: string | undefined;
236
+ }, {
237
+ exists: boolean;
238
+ writable: boolean;
239
+ userDataDir?: string | undefined;
240
+ }>;
241
+ tracking: z.ZodObject<{
242
+ source: z.ZodEnum<["instance", "default-env", "missing"]>;
243
+ agentIdFingerprint: z.ZodOptional<z.ZodString>;
244
+ }, "strip", z.ZodTypeAny, {
245
+ source: "instance" | "missing" | "default-env";
246
+ agentIdFingerprint?: string | undefined;
247
+ }, {
248
+ source: "instance" | "missing" | "default-env";
249
+ agentIdFingerprint?: string | undefined;
250
+ }>;
251
+ }, "strip", z.ZodTypeAny, {
252
+ mode: "managed-cdp" | "remote-cdp" | "existing-session";
253
+ id: string;
254
+ cdp: {
255
+ endpoint: string;
256
+ versionReachable: boolean;
257
+ listReachable: boolean;
258
+ port?: number | undefined;
259
+ };
260
+ profile: {
261
+ exists: boolean;
262
+ writable: boolean;
263
+ userDataDir?: string | undefined;
264
+ };
265
+ tracking: {
266
+ source: "instance" | "missing" | "default-env";
267
+ agentIdFingerprint?: string | undefined;
268
+ };
269
+ platform?: "zhipin" | "yupao" | undefined;
270
+ }, {
271
+ mode: "managed-cdp" | "remote-cdp" | "existing-session";
272
+ id: string;
273
+ cdp: {
274
+ endpoint: string;
275
+ versionReachable: boolean;
276
+ listReachable: boolean;
277
+ port?: number | undefined;
278
+ };
279
+ profile: {
280
+ exists: boolean;
281
+ writable: boolean;
282
+ userDataDir?: string | undefined;
283
+ };
284
+ tracking: {
285
+ source: "instance" | "missing" | "default-env";
286
+ agentIdFingerprint?: string | undefined;
287
+ };
288
+ platform?: "zhipin" | "yupao" | undefined;
289
+ }>, "many">>;
118
290
  }, "strip", z.ZodTypeAny, {
119
291
  effectiveEnvSources: Record<string, {
120
292
  present: boolean;
121
293
  fingerprint?: string | undefined;
122
294
  }>;
295
+ instances?: {
296
+ mode: "managed-cdp" | "remote-cdp" | "existing-session";
297
+ id: string;
298
+ cdp: {
299
+ endpoint: string;
300
+ versionReachable: boolean;
301
+ listReachable: boolean;
302
+ port?: number | undefined;
303
+ };
304
+ profile: {
305
+ exists: boolean;
306
+ writable: boolean;
307
+ userDataDir?: string | undefined;
308
+ };
309
+ tracking: {
310
+ source: "instance" | "missing" | "default-env";
311
+ agentIdFingerprint?: string | undefined;
312
+ };
313
+ platform?: "zhipin" | "yupao" | undefined;
314
+ }[] | undefined;
123
315
  security?: {
124
316
  domainAllowlist: string[];
125
317
  maxPageContentBytes: number;
126
318
  maxSnapshotNodes: number;
127
319
  actionPolicy: "log" | "deny" | "confirm";
320
+ foregroundPolicy: "never" | "when-minimized" | "always";
128
321
  } | undefined;
129
322
  toolPolicy?: {
130
323
  tools: Record<string, {
@@ -136,16 +329,39 @@ export declare const AgentRuntimeEnvDiagnosticPayloadSchema: z.ZodObject<{
136
329
  code: string;
137
330
  message: string;
138
331
  }[] | undefined;
332
+ defaultInstanceId?: string | undefined;
333
+ primaryInstanceId?: string | undefined;
139
334
  }, {
140
335
  effectiveEnvSources: Record<string, {
141
336
  present: boolean;
142
337
  fingerprint?: string | undefined;
143
338
  }>;
339
+ instances?: {
340
+ mode: "managed-cdp" | "remote-cdp" | "existing-session";
341
+ id: string;
342
+ cdp: {
343
+ endpoint: string;
344
+ versionReachable: boolean;
345
+ listReachable: boolean;
346
+ port?: number | undefined;
347
+ };
348
+ profile: {
349
+ exists: boolean;
350
+ writable: boolean;
351
+ userDataDir?: string | undefined;
352
+ };
353
+ tracking: {
354
+ source: "instance" | "missing" | "default-env";
355
+ agentIdFingerprint?: string | undefined;
356
+ };
357
+ platform?: "zhipin" | "yupao" | undefined;
358
+ }[] | undefined;
144
359
  security?: {
145
360
  domainAllowlist: string[];
146
361
  maxPageContentBytes: number;
147
362
  maxSnapshotNodes: number;
148
363
  actionPolicy: "log" | "deny" | "confirm";
364
+ foregroundPolicy?: "never" | "when-minimized" | "always" | undefined;
149
365
  } | undefined;
150
366
  toolPolicy?: {
151
367
  tools: Record<string, {
@@ -157,11 +373,14 @@ export declare const AgentRuntimeEnvDiagnosticPayloadSchema: z.ZodObject<{
157
373
  code: string;
158
374
  message: string;
159
375
  }[] | undefined;
376
+ defaultInstanceId?: string | undefined;
377
+ primaryInstanceId?: string | undefined;
160
378
  }>;
161
379
  export type AgentRuntimeEnvDiagnosticPayload = z.infer<typeof AgentRuntimeEnvDiagnosticPayloadSchema>;
162
380
  export type BrowserSecurityDiagnostic = z.infer<typeof BrowserSecurityDiagnosticSchema>;
163
381
  export type BrowserUseToolPolicyDiagnostic = z.infer<typeof BrowserUseToolPolicyDiagnosticSchema>;
164
382
  export type BrowserUsePolicyWarningDiagnostic = z.infer<typeof BrowserUsePolicyWarningDiagnosticSchema>;
383
+ export type BrowserInstanceStatusDiagnostic = z.infer<typeof BrowserInstanceStatusDiagnosticSchema>;
165
384
  export type AgentRuntimeEnvInspection = {
166
385
  readonly status: "verified";
167
386
  readonly toolName: DiagnosticToolName;
@@ -1 +1 @@
1
- import{createHash as e}from"node:crypto";import{z as n}from"zod";export const DIAGNOSTIC_TOOL_CANDIDATES=["diagnostic_status","browser_status"];const t=new Set(DIAGNOSTIC_TOOL_CANDIDATES),i=/^[0-9a-f]{8}$/;export const EffectiveEnvSourceSchema=n.object({present:n.boolean(),fingerprint:n.string().regex(i).optional()});export const BrowserSecurityDiagnosticSchema=n.object({domainAllowlist:n.array(n.string()),maxPageContentBytes:n.number(),maxSnapshotNodes:n.number(),actionPolicy:n.enum(["log","deny","confirm"])});export const BrowserUseToolPolicyDiagnosticSchema=n.object({approvalTtlMs:n.number(),tools:n.record(n.object({policy:n.enum(["log","deny","confirm"])}))});export const BrowserUsePolicyWarningDiagnosticSchema=n.object({code:n.string(),message:n.string()});export const AgentRuntimeEnvDiagnosticPayloadSchema=n.object({effectiveEnvSources:n.record(EffectiveEnvSourceSchema),security:BrowserSecurityDiagnosticSchema.optional(),toolPolicy:BrowserUseToolPolicyDiagnosticSchema.optional(),policyWarnings:n.array(BrowserUsePolicyWarningDiagnosticSchema).optional()});export function shouldSkipRuntimeReadinessForTool(e){return t.has(e)}export function inspectAgentRuntimeEnvRequirements(e,n,t){const i=e.items.map(e=>{const i=n?.[e.name],r=void 0!==i;if("unverified"===t.status)return{...e,configuredInAgentsEnv:r,runtime:{verified:!1,reason:t.reason,message:t.message}};const o=t.payload.effectiveEnvSources[e.name];return o?.present?{...e,configuredInAgentsEnv:r,runtime:{verified:!0,present:!0,...void 0!==o.fingerprint?{fingerprint:o.fingerprint}:{},matchesAgentsEnv:void 0!==i&&void 0!==o.fingerprint&&s(i)===o.fingerprint}}:{...e,configuredInAgentsEnv:r,runtime:{verified:!0,present:!1}}});return{items:i,inspection:t,missingRequired:i.filter(e=>e.required&&r(e)),ephemeralItems:i.filter(o)}}export function summarizeAgentRuntimeEnvReport(e){if(e.missingRequired.length>0){const n=c(e.missingRequired);return"verified"===e.inspection.status?{status:"fail",message:`运行态缺失: ${n}`}:{status:"fail",message:`${a(e)};${e.inspection.message}`}}if(e.ephemeralItems.length>0)return{status:"warn",message:`运行态漂移: ${c(e.ephemeralItems)}`};if("verified"===e.inspection.status)return{status:"ok",message:`声明的必填项已在运行态生效(${e.inspection.toolName})`};const n=e.items.filter(e=>e.required&&"process.env"===e.source);return n.length>0?{status:"warn",message:`依赖当前 shell 环境: ${c(n)};${e.inspection.message}`}:"diagnostic-tool-unavailable"===e.inspection.reason?{status:"ok",message:`声明的必填项已满足(${e.inspection.message})`}:{status:"warn",message:`声明的必填项已满足;${e.inspection.message}`}}export function formatAgentEnvDeclarationSource(e){switch(e.source){case"agents.env":return"已配置于 agents.env";case"process.env":return"仅当前 shell 环境";case"default":return`默认值 (${e.default})`;case"missing":return"缺失"}}export function formatAgentRuntimeVerification(e){return"verified"===e.inspection.status?`已验证(${e.inspection.toolName})`:`未校验(${e.inspection.message})`}export function formatAgentEnvRuntimeStatus(e){if(e.runtime.verified)return e.runtime.present?e.runtime.matchesAgentsEnv?"✓ from yaml (stable)":e.configuredInAgentsEnv?"⚠ differs from yaml (ephemeral)":"⚠ from shell (ephemeral)":"default"===e.source?"未设置(使用默认值)":"process.env"===e.source?"✗ 当前运行 agent 未看到该变量":"✗ missing"}function s(n){return e("sha256").update(n).digest("hex").slice(0,8)}function r(e){return e.runtime.verified?!e.runtime.present&&"default"!==e.source:"missing"===e.source}function o(e){return e.runtime.verified&&e.runtime.present&&!e.runtime.matchesAgentsEnv}function a(e){return`缺少必填项: ${c(e.missingRequired)}`}function c(e){return e.map(e=>e.name).join(", ")}
1
+ import{createHash as e}from"node:crypto";import{z as n}from"zod";export const DIAGNOSTIC_TOOL_CANDIDATES=["diagnostic_status","browser_status"];const t=new Set(DIAGNOSTIC_TOOL_CANDIDATES),i=/^[0-9a-f]{8}$/;export const EffectiveEnvSourceSchema=n.object({present:n.boolean(),fingerprint:n.string().regex(i).optional()});export const BrowserSecurityDiagnosticSchema=n.object({domainAllowlist:n.array(n.string()),maxPageContentBytes:n.number(),maxSnapshotNodes:n.number(),actionPolicy:n.enum(["log","deny","confirm"]),foregroundPolicy:n.enum(["when-minimized","always","never"]).default("when-minimized")});export const BrowserUseToolPolicyDiagnosticSchema=n.object({approvalTtlMs:n.number(),tools:n.record(n.object({policy:n.enum(["log","deny","confirm"])}))});export const BrowserUsePolicyWarningDiagnosticSchema=n.object({code:n.string(),message:n.string()});export const BrowserInstanceStatusDiagnosticSchema=n.object({id:n.string(),platform:n.enum(["zhipin","yupao"]).optional(),mode:n.enum(["managed-cdp","remote-cdp","existing-session"]),cdp:n.object({endpoint:n.string(),port:n.number().int().min(1).max(65535).optional(),versionReachable:n.boolean(),listReachable:n.boolean()}),profile:n.object({userDataDir:n.string().optional(),exists:n.boolean(),writable:n.boolean()}),tracking:n.object({source:n.enum(["instance","default-env","missing"]),agentIdFingerprint:n.string().regex(i).optional()})});export const AgentRuntimeEnvDiagnosticPayloadSchema=n.object({effectiveEnvSources:n.record(EffectiveEnvSourceSchema),security:BrowserSecurityDiagnosticSchema.optional(),toolPolicy:BrowserUseToolPolicyDiagnosticSchema.optional(),policyWarnings:n.array(BrowserUsePolicyWarningDiagnosticSchema).optional(),defaultInstanceId:n.string().optional(),primaryInstanceId:n.string().optional(),instances:n.array(BrowserInstanceStatusDiagnosticSchema).optional()});export function shouldSkipRuntimeReadinessForTool(e){return t.has(e)}export function inspectAgentRuntimeEnvRequirements(e,n,t){const i=e.items.map(e=>{const i=n?.[e.name],r=void 0!==i;if("unverified"===t.status)return{...e,configuredInAgentsEnv:r,runtime:{verified:!1,reason:t.reason,message:t.message}};const o=t.payload.effectiveEnvSources[e.name];return o?.present?{...e,configuredInAgentsEnv:r,runtime:{verified:!0,present:!0,...void 0!==o.fingerprint?{fingerprint:o.fingerprint}:{},matchesAgentsEnv:void 0!==i&&void 0!==o.fingerprint&&s(i)===o.fingerprint}}:{...e,configuredInAgentsEnv:r,runtime:{verified:!0,present:!1}}});return{items:i,inspection:t,missingRequired:i.filter(e=>e.required&&r(e)),ephemeralItems:i.filter(o)}}export function summarizeAgentRuntimeEnvReport(e){if(e.missingRequired.length>0){const n=c(e.missingRequired);return"verified"===e.inspection.status?{status:"fail",message:`运行态缺失: ${n}`}:{status:"fail",message:`${a(e)};${e.inspection.message}`}}if(e.ephemeralItems.length>0)return{status:"warn",message:`运行态漂移: ${c(e.ephemeralItems)}`};if("verified"===e.inspection.status)return{status:"ok",message:`声明的必填项已在运行态生效(${e.inspection.toolName})`};const n=e.items.filter(e=>e.required&&"process.env"===e.source);return n.length>0?{status:"warn",message:`依赖当前 shell 环境: ${c(n)};${e.inspection.message}`}:"diagnostic-tool-unavailable"===e.inspection.reason?{status:"ok",message:`声明的必填项已满足(${e.inspection.message})`}:{status:"warn",message:`声明的必填项已满足;${e.inspection.message}`}}export function formatAgentEnvDeclarationSource(e){switch(e.source){case"agents.env":return"已配置于 agents.env";case"process.env":return"仅当前 shell 环境";case"default":return`默认值 (${e.default})`;case"missing":return"缺失"}}export function formatAgentRuntimeVerification(e){return"verified"===e.inspection.status?`已验证(${e.inspection.toolName})`:`未校验(${e.inspection.message})`}export function formatAgentEnvRuntimeStatus(e){if(e.runtime.verified)return e.runtime.present?e.runtime.matchesAgentsEnv?"✓ from yaml (stable)":e.configuredInAgentsEnv?"⚠ differs from yaml (ephemeral)":"⚠ from shell (ephemeral)":"default"===e.source?"未设置(使用默认值)":"process.env"===e.source?"✗ 当前运行 agent 未看到该变量":"✗ missing"}function s(n){return e("sha256").update(n).digest("hex").slice(0,8)}function r(e){return e.runtime.verified?!e.runtime.present&&"default"!==e.source:"missing"===e.source}function o(e){return e.runtime.verified&&e.runtime.present&&!e.runtime.matchesAgentsEnv}function a(e){return`缺少必填项: ${c(e.missingRequired)}`}function c(e){return e.map(e=>e.name).join(", ")}