@papert-code/papert-code 0.3.92 → 0.3.94

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 (50) hide show
  1. package/README.md +99 -3
  2. package/dist/chunks/{chunk-G2NP25TN.js → chunk-2MUETKKX.js} +18 -1
  3. package/dist/chunks/{chunk-P4DPKRC2.js → chunk-423NGIST.js} +18 -1
  4. package/dist/chunks/{chunk-OVTXUA3U.js → chunk-4YLWLT76.js} +135 -119
  5. package/dist/chunks/{chunk-3CUI2HDG.js → chunk-5E2G77WW.js} +18 -1
  6. package/dist/chunks/{chunk-VTNP3O6A.js → chunk-6ZOXSA5F.js} +29070 -37288
  7. package/dist/chunks/{chunk-ICOYQZHB.js → chunk-7T4OCWHU.js} +90 -24
  8. package/dist/chunks/{chunk-EM5S27RC.js → chunk-B4UTHNG5.js} +18 -1
  9. package/dist/chunks/chunk-BMT6LRT3.js +52 -0
  10. package/dist/chunks/{chunk-7FXB5MJS.js → chunk-F77EGXST.js} +18 -1
  11. package/dist/chunks/{chunk-FS5UPVZW.js → chunk-FJQLUUKC.js} +18 -1
  12. package/dist/chunks/{chunk-MO6BWZQC.js → chunk-JATIVKZP.js} +72 -6
  13. package/dist/chunks/{chunk-IV6H2XE4.js → chunk-K5KJBM44.js} +19 -2
  14. package/dist/chunks/{chunk-W6O2LWN4.js → chunk-MEXE5SYY.js} +18 -1
  15. package/dist/chunks/{chunk-THDY5NFO.js → chunk-MHFXK3XK.js} +18 -1
  16. package/dist/chunks/{chunk-4HTLIVVR.js → chunk-NCFEMX7E.js} +17 -0
  17. package/dist/chunks/{chunk-2AKGZQ4A.js → chunk-OIA427PZ.js} +24 -5
  18. package/dist/chunks/{devtools-2MFFCPCG.js → devtools-AE6I2IJN.js} +20 -3
  19. package/dist/chunks/{devtools-ITROVIMB.js → devtools-IPZOX54X.js} +20 -3
  20. package/dist/chunks/dist-3BATS3LO.js +24 -0
  21. package/dist/chunks/{en-TX2CGKV3.js → en-N5RDRPST.js} +18 -1
  22. package/dist/chunks/{gemini-7AQ6BAIN.js → gemini-WYRXV2QC.js} +4038 -2484
  23. package/dist/chunks/{getMachineId-bsd-2RCFHEOM.js → getMachineId-bsd-4WX5XJ3I.js} +20 -3
  24. package/dist/chunks/{getMachineId-darwin-BBFRQYU6.js → getMachineId-darwin-URXQ2X3N.js} +20 -3
  25. package/dist/chunks/{getMachineId-linux-UPET74JV.js → getMachineId-linux-4Y2DTNAA.js} +19 -2
  26. package/dist/chunks/{getMachineId-unsupported-VIGKLEW5.js → getMachineId-unsupported-A5RT6P2V.js} +19 -2
  27. package/dist/chunks/{getMachineId-win-AYPIIM5S.js → getMachineId-win-HIFMWK2N.js} +20 -3
  28. package/dist/chunks/{keychain-token-storage-WM6GUOMH.js → keychain-token-storage-EPJEI2HJ.js} +19 -2
  29. package/dist/chunks/node-fetch-HP6CZCEV.js +28 -0
  30. package/dist/chunks/openaiContentGenerator-EAVO6L3Y.js +51 -0
  31. package/dist/chunks/{papertContentGenerator-FYBOOJV3.js → papertContentGenerator-G4SBF3DR.js} +30 -12
  32. package/dist/chunks/papertOAuth2-4I4JYPZW.js +51 -0
  33. package/dist/chunks/pluginSystem-5MM7PDLU.js +26 -0
  34. package/dist/chunks/server-N2U4FF55.js +26 -0
  35. package/dist/chunks/sharedTokenManager-GSQ3FULT.js +31 -0
  36. package/dist/chunks/undici-FJNCTQAO.js +24 -0
  37. package/dist/chunks/{zh-ACGEBTQR.js → zh-S2V7TL6B.js} +18 -1
  38. package/dist/cli.js +25 -17
  39. package/package.json +6 -2
  40. package/dist/chunks/chunk-BR7CCFAR.js +0 -5151
  41. package/dist/chunks/chunk-RMKGXYYI.js +0 -265
  42. package/dist/chunks/dist-L6NNW4TJ.js +0 -7
  43. package/dist/chunks/multipart-parser-IMIWHGMY.js +0 -381
  44. package/dist/chunks/openaiContentGenerator-WFZAEDJG.js +0 -33
  45. package/dist/chunks/papertOAuth2-JNUOPD7M.js +0 -34
  46. package/dist/chunks/pluginSystem-3V7KBDEE.js +0 -9
  47. package/dist/chunks/server-3DEIAIVB.js +0 -9
  48. package/dist/chunks/sharedTokenManager-Z6PG3UKZ.js +0 -14
  49. package/dist/chunks/src-ERBEIN35.js +0 -1445
  50. package/dist/chunks/undici-EPWKVH6H.js +0 -7
@@ -1,5 +1,22 @@
1
1
  // Force strict mode and setup for ESM
2
2
  "use strict";
3
+ const __papertOriginalEmitWarning = process.emitWarning.bind(process);
4
+ process.emitWarning = function patchedEmitWarning(warning, ...args) {
5
+ if (!process.env.PAPERT_SHOW_NODE_DEPRECATIONS) {
6
+ const warningCode =
7
+ (warning && typeof warning === 'object' && 'code' in warning && warning.code) ||
8
+ (args.length > 1 && typeof args[1] === 'string' && args[1]) ||
9
+ (args.length > 0 &&
10
+ args[0] &&
11
+ typeof args[0] === 'object' &&
12
+ 'code' in args[0] &&
13
+ args[0].code);
14
+ if (warningCode === 'DEP0040' || warningCode === 'DEP0169') {
15
+ return;
16
+ }
17
+ }
18
+ return __papertOriginalEmitWarning(warning, ...args);
19
+ };
3
20
  import {
4
21
  ApiError,
5
22
  AuthType,
@@ -97,19 +114,19 @@ import {
97
114
  supportsMultimodalFunctionResponse,
98
115
  tokenLimit,
99
116
  uiTelemetryService
100
- } from "./chunk-VTNP3O6A.js";
117
+ } from "./chunk-6ZOXSA5F.js";
101
118
  import {
102
119
  escape,
103
120
  glob,
104
121
  globStream,
105
122
  globSync
106
- } from "./chunk-EM5S27RC.js";
123
+ } from "./chunk-B4UTHNG5.js";
107
124
  import {
108
125
  require_undici
109
- } from "./chunk-P4DPKRC2.js";
126
+ } from "./chunk-423NGIST.js";
110
127
  import {
111
128
  require_src
112
- } from "./chunk-THDY5NFO.js";
129
+ } from "./chunk-MHFXK3XK.js";
113
130
  import {
114
131
  PAPERT_DIR,
115
132
  getProjectHash,
@@ -119,14 +136,14 @@ import {
119
136
  shortenPath,
120
137
  tildeifyPath,
121
138
  unescapePath
122
- } from "./chunk-IV6H2XE4.js";
139
+ } from "./chunk-K5KJBM44.js";
123
140
  import {
124
141
  FatalConfigError,
125
142
  UnauthorizedError,
126
143
  getErrorMessage,
127
144
  isNodeError,
128
145
  toFriendlyError
129
- } from "./chunk-OVTXUA3U.js";
146
+ } from "./chunk-4YLWLT76.js";
130
147
  import {
131
148
  __commonJS,
132
149
  __esm,
@@ -135,7 +152,7 @@ import {
135
152
  __require,
136
153
  __toESM,
137
154
  init_esbuild_shims
138
- } from "./chunk-4HTLIVVR.js";
155
+ } from "./chunk-NCFEMX7E.js";
139
156
 
140
157
  // node_modules/shell-quote/quote.js
141
158
  var require_quote = __commonJS({
@@ -29260,12 +29277,19 @@ __name(executeToolWithHooks, "executeToolWithHooks");
29260
29277
  async function runSafetyChecks(config2, toolName, toolArgs) {
29261
29278
  if (!config2)
29262
29279
  return null;
29263
- const runner = config2.getSafetyCheckerRunner();
29264
- const rules = config2.getSafetyCheckerRules();
29280
+ const getRunner = config2.getSafetyCheckerRunner;
29281
+ const getRules = config2.getSafetyCheckerRules;
29282
+ const getApprovalMode = config2.getApprovalMode;
29283
+ const isInteractive = config2.isInteractive;
29284
+ if (typeof getRunner !== "function" || typeof getRules !== "function") {
29285
+ return null;
29286
+ }
29287
+ const runner = getRunner.call(config2);
29288
+ const rules = getRules.call(config2);
29265
29289
  if (!runner || rules.length === 0)
29266
29290
  return null;
29267
29291
  const argsString = rules.some((rule) => rule.argsPattern) ? stableStringify(toolArgs) : void 0;
29268
- const approvalMode = config2.getApprovalMode();
29292
+ const approvalMode = typeof getApprovalMode === "function" ? getApprovalMode.call(config2) : "";
29269
29293
  for (const rule of rules) {
29270
29294
  if (!safetyRuleMatches(rule, toolName, argsString, approvalMode)) {
29271
29295
  continue;
@@ -29276,7 +29300,7 @@ async function runSafetyChecks(config2, toolName, toolArgs) {
29276
29300
  continue;
29277
29301
  }
29278
29302
  const reason = result.reason ?? `Safety checker "${rule.checker.name}" blocked execution.`;
29279
- if (result.decision === SafetyCheckDecision.ASK_USER && !config2.isInteractive()) {
29303
+ if (result.decision === SafetyCheckDecision.ASK_USER && (typeof isInteractive === "function" ? !isInteractive.call(config2) : true)) {
29280
29304
  return {
29281
29305
  llmContent: `Safety check requires user confirmation, but this session is non-interactive: ${reason}`,
29282
29306
  returnDisplay: `Safety check requires user confirmation, but this session is non-interactive: ${reason}`,
@@ -49247,7 +49271,7 @@ var IdeClient = class _IdeClient {
49247
49271
  const agent = new import_undici.EnvHttpProxyAgent({
49248
49272
  noProxy: [existingNoProxy, "127.0.0.1"].filter(Boolean).join(",")
49249
49273
  });
49250
- const undiciPromise = import("./undici-EPWKVH6H.js");
49274
+ const undiciPromise = import("./undici-FJNCTQAO.js");
49251
49275
  return async (url2, init) => {
49252
49276
  const { fetch: fetchFn } = await undiciPromise;
49253
49277
  const fetchOptions = {
@@ -67683,14 +67707,29 @@ var PolicyEngine = class {
67683
67707
  this.allowHooks = config2.allowHooks ?? true;
67684
67708
  }
67685
67709
  check(toolCall, serverName) {
67710
+ return this.getDecisionDetails(toolCall, serverName).decision;
67711
+ }
67712
+ getDecisionReason(toolCall, serverName) {
67713
+ return this.getDecisionDetails(toolCall, serverName).reason;
67714
+ }
67715
+ getDecisionDetails(toolCall, serverName) {
67686
67716
  const stringifiedArgs = toolCall.args && this.rules.some((rule) => rule.argsPattern) ? stableStringify(toolCall.args) : void 0;
67687
- for (const rule of this.rules) {
67688
- if (this.ruleMatches(rule, toolCall.name, stringifiedArgs, serverName)) {
67689
- return this.applyNonInteractiveMode(rule.decision);
67690
- }
67717
+ const matchedRule = this.rules.find((rule) => this.ruleMatches(rule, toolCall.name, stringifiedArgs, serverName));
67718
+ if (matchedRule) {
67719
+ const decision = this.applyNonInteractiveMode(matchedRule.decision);
67720
+ const deniedByNonInteractive2 = matchedRule.decision === PolicyDecision.ASK_USER && decision === PolicyDecision.DENY && this.nonInteractive;
67721
+ return {
67722
+ decision,
67723
+ reason: decision === PolicyDecision.DENY ? deniedByNonInteractive2 ? "Interactive confirmation is disabled in non-interactive mode" : this.buildDenyReason(matchedRule) : void 0
67724
+ };
67691
67725
  }
67692
67726
  debugLogger.debug(`[PolicyEngine.check] no matching rule for ${toolCall.name}, using default ${this.defaultDecision}`);
67693
- return this.applyNonInteractiveMode(this.defaultDecision);
67727
+ const fallbackDecision = this.applyNonInteractiveMode(this.defaultDecision);
67728
+ const deniedByNonInteractive = this.defaultDecision === PolicyDecision.ASK_USER && fallbackDecision === PolicyDecision.DENY && this.nonInteractive;
67729
+ return {
67730
+ decision: fallbackDecision,
67731
+ reason: fallbackDecision === PolicyDecision.DENY ? deniedByNonInteractive ? "Interactive confirmation is disabled in non-interactive mode" : "Denied by default policy decision" : void 0
67732
+ };
67694
67733
  }
67695
67734
  checkHook(context) {
67696
67735
  if (!this.allowHooks) {
@@ -67731,6 +67770,22 @@ var PolicyEngine = class {
67731
67770
  }
67732
67771
  return decision;
67733
67772
  }
67773
+ buildDenyReason(rule) {
67774
+ if (rule.reason?.trim()) {
67775
+ return rule.reason;
67776
+ }
67777
+ const parts = [];
67778
+ if (rule.toolName) {
67779
+ parts.push(`tool=${rule.toolName}`);
67780
+ }
67781
+ if (rule.argsPattern) {
67782
+ parts.push(`argsPattern=${rule.argsPattern.source}`);
67783
+ }
67784
+ if (typeof rule.priority === "number") {
67785
+ parts.push(`priority=${rule.priority}`);
67786
+ }
67787
+ return parts.length > 0 ? `Denied by matching policy rule (${parts.join(", ")})` : "Denied by matching policy rule";
67788
+ }
67734
67789
  };
67735
67790
 
67736
67791
  // packages/core/dist/src/safety/checker-runner.js
@@ -68414,14 +68469,17 @@ var MessageBus = class extends EventEmitter3 {
68414
68469
  });
68415
68470
  break;
68416
68471
  case PolicyDecision.DENY:
68472
+ const reason = this.policyEngine.getDecisionReason(message.toolCall, message.serverName);
68417
68473
  this.emitMessage({
68418
68474
  type: MessageBusType.TOOL_POLICY_REJECTION,
68419
- toolCall: message.toolCall
68475
+ toolCall: message.toolCall,
68476
+ ...reason ? { reason } : {}
68420
68477
  });
68421
68478
  this.emitMessage({
68422
68479
  type: MessageBusType.TOOL_CONFIRMATION_RESPONSE,
68423
68480
  correlationId: message.correlationId,
68424
- confirmed: false
68481
+ confirmed: false,
68482
+ ...reason ? { reason } : {}
68425
68483
  });
68426
68484
  break;
68427
68485
  case PolicyDecision.ASK_USER:
@@ -69219,7 +69277,7 @@ var Config = class {
69219
69277
  await this.hookSystem.initialize();
69220
69278
  }
69221
69279
  if (this.enablePlugins) {
69222
- const { PluginSystem } = await import("./pluginSystem-3V7KBDEE.js");
69280
+ const { PluginSystem } = await import("./pluginSystem-5MM7PDLU.js");
69223
69281
  this.pluginSystem = new PluginSystem(this);
69224
69282
  await this.pluginSystem.initialize();
69225
69283
  }
@@ -73798,10 +73856,14 @@ var DelegateInvocation = class extends BaseToolInvocation {
73798
73856
  return `Delegate to agent "${this.params.agentName}"`;
73799
73857
  }
73800
73858
  async execute() {
73801
- const message = `Delegated to agent "${this.params.agentName}" with input: ${this.params.input}`;
73859
+ const message = "The delegate_to_agent tool is not implemented yet. Configure and use subagents instead.";
73802
73860
  return {
73803
73861
  llmContent: [{ text: message }],
73804
- returnDisplay: message
73862
+ returnDisplay: message,
73863
+ error: {
73864
+ message,
73865
+ type: ToolErrorType.EXECUTION_FAILED
73866
+ }
73805
73867
  };
73806
73868
  }
73807
73869
  };
@@ -73840,10 +73902,14 @@ var SubagentInvocation = class extends BaseToolInvocation {
73840
73902
  return `Invoke subagent "${this.params.name}"`;
73841
73903
  }
73842
73904
  async execute() {
73843
- const message = `Subagent "${this.params.name}" invoked${this.params.input ? ` with input: ${this.params.input}` : ""}.`;
73905
+ const message = "The subagent_tool_wrapper tool is not implemented yet. Use configured subagents through the main orchestration flow.";
73844
73906
  return {
73845
73907
  llmContent: [{ text: message }],
73846
- returnDisplay: message
73908
+ returnDisplay: message,
73909
+ error: {
73910
+ message,
73911
+ type: ToolErrorType.EXECUTION_FAILED
73912
+ }
73847
73913
  };
73848
73914
  }
73849
73915
  };
@@ -1,9 +1,26 @@
1
1
  // Force strict mode and setup for ESM
2
2
  "use strict";
3
+ const __papertOriginalEmitWarning = process.emitWarning.bind(process);
4
+ process.emitWarning = function patchedEmitWarning(warning, ...args) {
5
+ if (!process.env.PAPERT_SHOW_NODE_DEPRECATIONS) {
6
+ const warningCode =
7
+ (warning && typeof warning === 'object' && 'code' in warning && warning.code) ||
8
+ (args.length > 1 && typeof args[1] === 'string' && args[1]) ||
9
+ (args.length > 0 &&
10
+ args[0] &&
11
+ typeof args[0] === 'object' &&
12
+ 'code' in args[0] &&
13
+ args[0].code);
14
+ if (warningCode === 'DEP0040' || warningCode === 'DEP0169') {
15
+ return;
16
+ }
17
+ }
18
+ return __papertOriginalEmitWarning(warning, ...args);
19
+ };
3
20
  import {
4
21
  __name,
5
22
  init_esbuild_shims
6
- } from "./chunk-4HTLIVVR.js";
23
+ } from "./chunk-NCFEMX7E.js";
7
24
 
8
25
  // packages/core/dist/src/plugins/pluginSystem.js
9
26
  init_esbuild_shims();
@@ -0,0 +1,52 @@
1
+ // Force strict mode and setup for ESM
2
+ "use strict";
3
+ const __papertOriginalEmitWarning = process.emitWarning.bind(process);
4
+ process.emitWarning = function patchedEmitWarning(warning, ...args) {
5
+ if (!process.env.PAPERT_SHOW_NODE_DEPRECATIONS) {
6
+ const warningCode =
7
+ (warning && typeof warning === 'object' && 'code' in warning && warning.code) ||
8
+ (args.length > 1 && typeof args[1] === 'string' && args[1]) ||
9
+ (args.length > 0 &&
10
+ args[0] &&
11
+ typeof args[0] === 'object' &&
12
+ 'code' in args[0] &&
13
+ args[0].code);
14
+ if (warningCode === 'DEP0040' || warningCode === 'DEP0169') {
15
+ return;
16
+ }
17
+ }
18
+ return __papertOriginalEmitWarning(warning, ...args);
19
+ };
20
+ import {
21
+ __esm,
22
+ __export,
23
+ init_esbuild_shims
24
+ } from "./chunk-NCFEMX7E.js";
25
+
26
+ // packages/cli/src/patches/node-fetch.ts
27
+ var node_fetch_exports = {};
28
+ __export(node_fetch_exports, {
29
+ default: () => node_fetch_default
30
+ });
31
+ var fetchImpl, node_fetch_default;
32
+ var init_node_fetch = __esm({
33
+ "packages/cli/src/patches/node-fetch.ts"() {
34
+ init_esbuild_shims();
35
+ fetchImpl = globalThis.fetch;
36
+ if (!fetchImpl) {
37
+ throw new Error("Global fetch is unavailable in this Node runtime.");
38
+ }
39
+ node_fetch_default = fetchImpl;
40
+ }
41
+ });
42
+
43
+ export {
44
+ node_fetch_default,
45
+ node_fetch_exports,
46
+ init_node_fetch
47
+ };
48
+ /**
49
+ * @license
50
+ * * Copyright 2026 Papert-code
51
+ * SPDX-License-Identifier: Apache-2.0
52
+ */
@@ -1,12 +1,29 @@
1
1
  // Force strict mode and setup for ESM
2
2
  "use strict";
3
+ const __papertOriginalEmitWarning = process.emitWarning.bind(process);
4
+ process.emitWarning = function patchedEmitWarning(warning, ...args) {
5
+ if (!process.env.PAPERT_SHOW_NODE_DEPRECATIONS) {
6
+ const warningCode =
7
+ (warning && typeof warning === 'object' && 'code' in warning && warning.code) ||
8
+ (args.length > 1 && typeof args[1] === 'string' && args[1]) ||
9
+ (args.length > 0 &&
10
+ args[0] &&
11
+ typeof args[0] === 'object' &&
12
+ 'code' in args[0] &&
13
+ args[0].code);
14
+ if (warningCode === 'DEP0040' || warningCode === 'DEP0169') {
15
+ return;
16
+ }
17
+ }
18
+ return __papertOriginalEmitWarning(warning, ...args);
19
+ };
3
20
  import {
4
21
  __commonJS,
5
22
  __name,
6
23
  __require,
7
24
  __toESM,
8
25
  init_esbuild_shims
9
- } from "./chunk-4HTLIVVR.js";
26
+ } from "./chunk-NCFEMX7E.js";
10
27
 
11
28
  // node_modules/ws/lib/constants.js
12
29
  var require_constants = __commonJS({
@@ -1,9 +1,26 @@
1
1
  // Force strict mode and setup for ESM
2
2
  "use strict";
3
+ const __papertOriginalEmitWarning = process.emitWarning.bind(process);
4
+ process.emitWarning = function patchedEmitWarning(warning, ...args) {
5
+ if (!process.env.PAPERT_SHOW_NODE_DEPRECATIONS) {
6
+ const warningCode =
7
+ (warning && typeof warning === 'object' && 'code' in warning && warning.code) ||
8
+ (args.length > 1 && typeof args[1] === 'string' && args[1]) ||
9
+ (args.length > 0 &&
10
+ args[0] &&
11
+ typeof args[0] === 'object' &&
12
+ 'code' in args[0] &&
13
+ args[0].code);
14
+ if (warningCode === 'DEP0040' || warningCode === 'DEP0169') {
15
+ return;
16
+ }
17
+ }
18
+ return __papertOriginalEmitWarning(warning, ...args);
19
+ };
3
20
  import {
4
21
  __name,
5
22
  init_esbuild_shims
6
- } from "./chunk-4HTLIVVR.js";
23
+ } from "./chunk-NCFEMX7E.js";
7
24
 
8
25
  // packages/core/dist/src/mcp/token-storage/base-token-storage.js
9
26
  init_esbuild_shims();
@@ -1,15 +1,84 @@
1
1
  // Force strict mode and setup for ESM
2
2
  "use strict";
3
+ const __papertOriginalEmitWarning = process.emitWarning.bind(process);
4
+ process.emitWarning = function patchedEmitWarning(warning, ...args) {
5
+ if (!process.env.PAPERT_SHOW_NODE_DEPRECATIONS) {
6
+ const warningCode =
7
+ (warning && typeof warning === 'object' && 'code' in warning && warning.code) ||
8
+ (args.length > 1 && typeof args[1] === 'string' && args[1]) ||
9
+ (args.length > 0 &&
10
+ args[0] &&
11
+ typeof args[0] === 'object' &&
12
+ 'code' in args[0] &&
13
+ args[0].code);
14
+ if (warningCode === 'DEP0040' || warningCode === 'DEP0169') {
15
+ return;
16
+ }
17
+ }
18
+ return __papertOriginalEmitWarning(warning, ...args);
19
+ };
3
20
  import {
4
21
  __name,
5
22
  init_esbuild_shims
6
- } from "./chunk-4HTLIVVR.js";
23
+ } from "./chunk-NCFEMX7E.js";
7
24
 
8
25
  // packages/cli/src/commands/server.ts
9
26
  init_esbuild_shims();
10
27
  import { spawn } from "node:child_process";
11
28
  import * as fs from "node:fs";
12
29
  import * as path from "node:path";
30
+ import { fileURLToPath } from "node:url";
31
+ import { createRequire } from "node:module";
32
+ function resolveA2aServerEntrypoint() {
33
+ const candidates = [];
34
+ const commandFile = fileURLToPath(import.meta.url);
35
+ const commandDir = path.dirname(commandFile);
36
+ const papertEntrypoint = process.argv[1];
37
+ candidates.push(
38
+ path.resolve(process.cwd(), "packages/a2a-server/dist/src/http/server.js")
39
+ );
40
+ candidates.push(
41
+ path.resolve(
42
+ commandDir,
43
+ "../../../../packages/a2a-server/dist/src/http/server.js"
44
+ )
45
+ );
46
+ candidates.push(
47
+ path.resolve(
48
+ commandDir,
49
+ "../../../../../packages/a2a-server/dist/src/http/server.js"
50
+ )
51
+ );
52
+ if (papertEntrypoint) {
53
+ candidates.push(
54
+ path.resolve(
55
+ path.dirname(papertEntrypoint),
56
+ "../packages/a2a-server/dist/src/http/server.js"
57
+ )
58
+ );
59
+ candidates.push(
60
+ path.resolve(
61
+ path.dirname(papertEntrypoint),
62
+ "../../packages/a2a-server/dist/src/http/server.js"
63
+ )
64
+ );
65
+ }
66
+ try {
67
+ const require2 = createRequire(import.meta.url);
68
+ const resolved = require2.resolve(
69
+ "@papert-code/papert-code-a2a-server/dist/src/http/server.js"
70
+ );
71
+ candidates.push(resolved);
72
+ } catch {
73
+ }
74
+ for (const candidate of candidates) {
75
+ if (fs.existsSync(candidate)) {
76
+ return candidate;
77
+ }
78
+ }
79
+ return void 0;
80
+ }
81
+ __name(resolveA2aServerEntrypoint, "resolveA2aServerEntrypoint");
13
82
  var serverCommand = {
14
83
  command: "server",
15
84
  describe: "Run Papert Code daemon (remote driving server).",
@@ -52,11 +121,8 @@ var serverCommand = {
52
121
  token: ${env.PAPERT_REMOTE_SERVER_TOKEN}
53
122
  cmd: papert-a2a-server`
54
123
  );
55
- const localServerEntrypoint = path.resolve(
56
- process.cwd(),
57
- "packages/a2a-server/dist/src/http/server.js"
58
- );
59
- const spawnCommand = fs.existsSync(localServerEntrypoint) ? {
124
+ const localServerEntrypoint = resolveA2aServerEntrypoint();
125
+ const spawnCommand = localServerEntrypoint ? {
60
126
  command: process.execPath,
61
127
  args: [localServerEntrypoint],
62
128
  display: `${process.execPath} ${localServerEntrypoint}`
@@ -1,13 +1,30 @@
1
1
  // Force strict mode and setup for ESM
2
2
  "use strict";
3
+ const __papertOriginalEmitWarning = process.emitWarning.bind(process);
4
+ process.emitWarning = function patchedEmitWarning(warning, ...args) {
5
+ if (!process.env.PAPERT_SHOW_NODE_DEPRECATIONS) {
6
+ const warningCode =
7
+ (warning && typeof warning === 'object' && 'code' in warning && warning.code) ||
8
+ (args.length > 1 && typeof args[1] === 'string' && args[1]) ||
9
+ (args.length > 0 &&
10
+ args[0] &&
11
+ typeof args[0] === 'object' &&
12
+ 'code' in args[0] &&
13
+ args[0].code);
14
+ if (warningCode === 'DEP0040' || warningCode === 'DEP0169') {
15
+ return;
16
+ }
17
+ }
18
+ return __papertOriginalEmitWarning(warning, ...args);
19
+ };
3
20
  import {
4
21
  isNodeError,
5
22
  open_default
6
- } from "./chunk-OVTXUA3U.js";
23
+ } from "./chunk-4YLWLT76.js";
7
24
  import {
8
25
  __name,
9
26
  init_esbuild_shims
10
- } from "./chunk-4HTLIVVR.js";
27
+ } from "./chunk-NCFEMX7E.js";
11
28
 
12
29
  // packages/core/dist/src/papert/papertOAuth2.js
13
30
  init_esbuild_shims();
@@ -1,10 +1,27 @@
1
1
  // Force strict mode and setup for ESM
2
2
  "use strict";
3
+ const __papertOriginalEmitWarning = process.emitWarning.bind(process);
4
+ process.emitWarning = function patchedEmitWarning(warning, ...args) {
5
+ if (!process.env.PAPERT_SHOW_NODE_DEPRECATIONS) {
6
+ const warningCode =
7
+ (warning && typeof warning === 'object' && 'code' in warning && warning.code) ||
8
+ (args.length > 1 && typeof args[1] === 'string' && args[1]) ||
9
+ (args.length > 0 &&
10
+ args[0] &&
11
+ typeof args[0] === 'object' &&
12
+ 'code' in args[0] &&
13
+ args[0].code);
14
+ if (warningCode === 'DEP0040' || warningCode === 'DEP0169') {
15
+ return;
16
+ }
17
+ }
18
+ return __papertOriginalEmitWarning(warning, ...args);
19
+ };
3
20
  import {
4
21
  __commonJS,
5
22
  __require,
6
23
  init_esbuild_shims
7
- } from "./chunk-4HTLIVVR.js";
24
+ } from "./chunk-NCFEMX7E.js";
8
25
 
9
26
  // node_modules/@opentelemetry/resources/build/src/detectors/platform/node/machine-id/execAsync.js
10
27
  var require_execAsync = __commonJS({
@@ -1,11 +1,28 @@
1
1
  // Force strict mode and setup for ESM
2
2
  "use strict";
3
+ const __papertOriginalEmitWarning = process.emitWarning.bind(process);
4
+ process.emitWarning = function patchedEmitWarning(warning, ...args) {
5
+ if (!process.env.PAPERT_SHOW_NODE_DEPRECATIONS) {
6
+ const warningCode =
7
+ (warning && typeof warning === 'object' && 'code' in warning && warning.code) ||
8
+ (args.length > 1 && typeof args[1] === 'string' && args[1]) ||
9
+ (args.length > 0 &&
10
+ args[0] &&
11
+ typeof args[0] === 'object' &&
12
+ 'code' in args[0] &&
13
+ args[0].code);
14
+ if (warningCode === 'DEP0040' || warningCode === 'DEP0169') {
15
+ return;
16
+ }
17
+ }
18
+ return __papertOriginalEmitWarning(warning, ...args);
19
+ };
3
20
  import {
4
21
  __commonJS,
5
22
  __name,
6
23
  __require,
7
24
  init_esbuild_shims
8
- } from "./chunk-4HTLIVVR.js";
25
+ } from "./chunk-NCFEMX7E.js";
9
26
 
10
27
  // node_modules/ms/index.js
11
28
  var require_ms = __commonJS({
@@ -1,5 +1,22 @@
1
1
  // Force strict mode and setup for ESM
2
2
  "use strict";
3
+ const __papertOriginalEmitWarning = process.emitWarning.bind(process);
4
+ process.emitWarning = function patchedEmitWarning(warning, ...args) {
5
+ if (!process.env.PAPERT_SHOW_NODE_DEPRECATIONS) {
6
+ const warningCode =
7
+ (warning && typeof warning === 'object' && 'code' in warning && warning.code) ||
8
+ (args.length > 1 && typeof args[1] === 'string' && args[1]) ||
9
+ (args.length > 0 &&
10
+ args[0] &&
11
+ typeof args[0] === 'object' &&
12
+ 'code' in args[0] &&
13
+ args[0].code);
14
+ if (warningCode === 'DEP0040' || warningCode === 'DEP0169') {
15
+ return;
16
+ }
17
+ }
18
+ return __papertOriginalEmitWarning(warning, ...args);
19
+ };
3
20
  var __create = Object.create;
4
21
  var __defProp = Object.defineProperty;
5
22
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
@@ -1,5 +1,22 @@
1
1
  // Force strict mode and setup for ESM
2
2
  "use strict";
3
+ const __papertOriginalEmitWarning = process.emitWarning.bind(process);
4
+ process.emitWarning = function patchedEmitWarning(warning, ...args) {
5
+ if (!process.env.PAPERT_SHOW_NODE_DEPRECATIONS) {
6
+ const warningCode =
7
+ (warning && typeof warning === 'object' && 'code' in warning && warning.code) ||
8
+ (args.length > 1 && typeof args[1] === 'string' && args[1]) ||
9
+ (args.length > 0 &&
10
+ args[0] &&
11
+ typeof args[0] === 'object' &&
12
+ 'code' in args[0] &&
13
+ args[0].code);
14
+ if (warningCode === 'DEP0040' || warningCode === 'DEP0169') {
15
+ return;
16
+ }
17
+ }
18
+ return __papertOriginalEmitWarning(warning, ...args);
19
+ };
3
20
  import {
4
21
  ApiErrorEvent,
5
22
  ApiResponseEvent,
@@ -14,11 +31,11 @@ import {
14
31
  logApiError,
15
32
  logApiResponse,
16
33
  tokenLimit
17
- } from "./chunk-VTNP3O6A.js";
34
+ } from "./chunk-6ZOXSA5F.js";
18
35
  import {
19
36
  __name,
20
37
  init_esbuild_shims
21
- } from "./chunk-4HTLIVVR.js";
38
+ } from "./chunk-NCFEMX7E.js";
22
39
 
23
40
  // packages/core/dist/src/core/openaiContentGenerator/index.js
24
41
  init_esbuild_shims();
@@ -9907,8 +9924,7 @@ var DefaultRequestTokenizer = class {
9907
9924
  }
9908
9925
  }
9909
9926
  /**
9910
- * Calculate tokens for audio contents
9911
- * TODO: Implement proper audio token calculation
9927
+ * Calculate tokens for audio contents using a conservative data-size heuristic.
9912
9928
  */
9913
9929
  async calculateAudioTokens(audioContents) {
9914
9930
  if (audioContents.length === 0)
@@ -9917,7 +9933,10 @@ var DefaultRequestTokenizer = class {
9917
9933
  for (const audioContent of audioContents) {
9918
9934
  try {
9919
9935
  const dataSize = Math.floor(audioContent.data.length * 0.75);
9920
- totalTokens += Math.max(Math.ceil(dataSize / 100), 10);
9936
+ const mimeType = audioContent.mimeType.toLowerCase();
9937
+ const bytesPerToken = mimeType.includes("wav") || mimeType.includes("wave") ? 80 : 120;
9938
+ const estimatedTokens = Math.ceil(dataSize / bytesPerToken);
9939
+ totalTokens += Math.min(Math.max(estimatedTokens, 10), 16384);
9921
9940
  } catch (error) {
9922
9941
  console.warn("Error calculating audio tokens:", error);
9923
9942
  totalTokens += 10;