lody 0.79.2 → 0.81.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.
@@ -2466,8 +2466,8 @@ class ConnectionBuilder {
2466
2466
  /**
2467
2467
  * Sets a diagnostic name used by handlers created from this builder.
2468
2468
  */
2469
- name(name2) {
2470
- this.connectionName = name2;
2469
+ name(name) {
2470
+ this.connectionName = name;
2471
2471
  return this;
2472
2472
  }
2473
2473
  /**
@@ -3633,6 +3633,37 @@ class ClientApp {
3633
3633
  };
3634
3634
  }
3635
3635
  }
3636
+ const legacyAgentRequestMethods = /* @__PURE__ */ new Set([
3637
+ AGENT_METHODS.initialize,
3638
+ AGENT_METHODS.authenticate,
3639
+ AGENT_METHODS.providers_list,
3640
+ AGENT_METHODS.providers_set,
3641
+ AGENT_METHODS.providers_disable,
3642
+ AGENT_METHODS.session_new,
3643
+ AGENT_METHODS.session_load,
3644
+ AGENT_METHODS.session_set_mode,
3645
+ AGENT_METHODS.session_set_config_option,
3646
+ AGENT_METHODS.session_prompt,
3647
+ AGENT_METHODS.session_list,
3648
+ AGENT_METHODS.session_delete,
3649
+ AGENT_METHODS.session_fork,
3650
+ AGENT_METHODS.session_resume,
3651
+ AGENT_METHODS.session_close,
3652
+ AGENT_METHODS.logout,
3653
+ AGENT_METHODS.nes_start,
3654
+ AGENT_METHODS.nes_suggest,
3655
+ AGENT_METHODS.nes_close
3656
+ ]);
3657
+ const legacyAgentNotificationMethods = /* @__PURE__ */ new Set([
3658
+ AGENT_METHODS.session_cancel,
3659
+ AGENT_METHODS.nes_accept,
3660
+ AGENT_METHODS.nes_reject,
3661
+ AGENT_METHODS.document_did_open,
3662
+ AGENT_METHODS.document_did_change,
3663
+ AGENT_METHODS.document_did_close,
3664
+ AGENT_METHODS.document_did_save,
3665
+ AGENT_METHODS.document_did_focus
3666
+ ]);
3636
3667
  const legacyClientRequestMethods = /* @__PURE__ */ new Set([
3637
3668
  CLIENT_METHODS.session_request_permission,
3638
3669
  CLIENT_METHODS.fs_write_text_file,
@@ -3648,6 +3679,100 @@ const legacyClientNotificationMethods = /* @__PURE__ */ new Set([
3648
3679
  CLIENT_METHODS.session_update,
3649
3680
  CLIENT_METHODS.elicitation_complete
3650
3681
  ]);
3682
+ function legacyAgentApp(implementation) {
3683
+ const app = agent().onRequest(AGENT_METHODS.initialize, (ctx) => implementation.initialize(ctx.params)).onRequest(AGENT_METHODS.session_new, (ctx) => implementation.newSession(ctx.params)).onRequest(AGENT_METHODS.authenticate, async (ctx) => await implementation.authenticate(ctx.params) ?? {}).onRequest(AGENT_METHODS.session_prompt, (ctx) => implementation.prompt(ctx.params)).onNotification(AGENT_METHODS.session_cancel, (ctx) => implementation.cancel(ctx.params));
3684
+ if (implementation.loadSession) {
3685
+ app.onRequest(AGENT_METHODS.session_load, (ctx) => implementation.loadSession(ctx.params));
3686
+ }
3687
+ if (implementation.listSessions) {
3688
+ app.onRequest(AGENT_METHODS.session_list, (ctx) => implementation.listSessions(ctx.params));
3689
+ }
3690
+ if (implementation.deleteSession) {
3691
+ app.onRequest(AGENT_METHODS.session_delete, async (ctx) => await implementation.deleteSession(ctx.params) ?? {});
3692
+ }
3693
+ if (implementation.unstable_forkSession) {
3694
+ app.onRequest(AGENT_METHODS.session_fork, (ctx) => implementation.unstable_forkSession(ctx.params));
3695
+ }
3696
+ if (implementation.resumeSession) {
3697
+ app.onRequest(AGENT_METHODS.session_resume, (ctx) => implementation.resumeSession(ctx.params));
3698
+ }
3699
+ if (implementation.closeSession) {
3700
+ app.onRequest(AGENT_METHODS.session_close, async (ctx) => await implementation.closeSession(ctx.params) ?? {});
3701
+ }
3702
+ if (implementation.setSessionMode) {
3703
+ app.onRequest(AGENT_METHODS.session_set_mode, async (ctx) => await implementation.setSessionMode(ctx.params) ?? {});
3704
+ }
3705
+ if (implementation.setSessionConfigOption) {
3706
+ app.onRequest(AGENT_METHODS.session_set_config_option, (ctx) => implementation.setSessionConfigOption(ctx.params));
3707
+ }
3708
+ if (implementation.unstable_listProviders) {
3709
+ app.onRequest(AGENT_METHODS.providers_list, (ctx) => implementation.unstable_listProviders(ctx.params));
3710
+ }
3711
+ if (implementation.unstable_setProvider) {
3712
+ app.onRequest(AGENT_METHODS.providers_set, async (ctx) => await implementation.unstable_setProvider(ctx.params) ?? {});
3713
+ }
3714
+ if (implementation.unstable_disableProvider) {
3715
+ app.onRequest(AGENT_METHODS.providers_disable, async (ctx) => await implementation.unstable_disableProvider(ctx.params) ?? {});
3716
+ }
3717
+ if (implementation.logout) {
3718
+ app.onRequest(AGENT_METHODS.logout, async (ctx) => await implementation.logout(ctx.params) ?? {});
3719
+ }
3720
+ if (implementation.unstable_startNes) {
3721
+ app.onRequest(AGENT_METHODS.nes_start, (ctx) => implementation.unstable_startNes(ctx.params));
3722
+ }
3723
+ if (implementation.unstable_suggestNes) {
3724
+ app.onRequest(AGENT_METHODS.nes_suggest, (ctx) => implementation.unstable_suggestNes(ctx.params));
3725
+ }
3726
+ if (implementation.unstable_closeNes) {
3727
+ app.onRequest(AGENT_METHODS.nes_close, async (ctx) => await implementation.unstable_closeNes(ctx.params) ?? {});
3728
+ }
3729
+ if (implementation.unstable_didOpenDocument) {
3730
+ app.onNotification(AGENT_METHODS.document_did_open, (ctx) => implementation.unstable_didOpenDocument(ctx.params));
3731
+ }
3732
+ if (implementation.unstable_didChangeDocument) {
3733
+ app.onNotification(AGENT_METHODS.document_did_change, (ctx) => implementation.unstable_didChangeDocument(ctx.params));
3734
+ }
3735
+ if (implementation.unstable_didCloseDocument) {
3736
+ app.onNotification(AGENT_METHODS.document_did_close, (ctx) => implementation.unstable_didCloseDocument(ctx.params));
3737
+ }
3738
+ if (implementation.unstable_didSaveDocument) {
3739
+ app.onNotification(AGENT_METHODS.document_did_save, (ctx) => implementation.unstable_didSaveDocument(ctx.params));
3740
+ }
3741
+ if (implementation.unstable_didFocusDocument) {
3742
+ app.onNotification(AGENT_METHODS.document_did_focus, (ctx) => implementation.unstable_didFocusDocument(ctx.params));
3743
+ }
3744
+ if (implementation.unstable_acceptNes) {
3745
+ app.onNotification(AGENT_METHODS.nes_accept, (ctx) => implementation.unstable_acceptNes(ctx.params));
3746
+ }
3747
+ if (implementation.unstable_rejectNes) {
3748
+ app.onNotification(AGENT_METHODS.nes_reject, (ctx) => implementation.unstable_rejectNes(ctx.params));
3749
+ }
3750
+ if (implementation.extMethod) {
3751
+ app[appBuilder]().withHandler({
3752
+ handleMessage: async (message) => {
3753
+ if (message.kind !== "request" || legacyAgentRequestMethods.has(message.method)) {
3754
+ return Handled.no(message);
3755
+ }
3756
+ await message.responder.respond(await implementation.extMethod(message.method, message.params));
3757
+ return Handled.yes();
3758
+ },
3759
+ describe: () => "legacy-agent-extension-request"
3760
+ });
3761
+ }
3762
+ if (implementation.extNotification) {
3763
+ app[appBuilder]().withHandler({
3764
+ handleMessage: async (message) => {
3765
+ if (message.kind !== "notification" || legacyAgentNotificationMethods.has(message.method)) {
3766
+ return Handled.no(message);
3767
+ }
3768
+ await implementation.extNotification(message.method, message.params);
3769
+ return Handled.yes();
3770
+ },
3771
+ describe: () => "legacy-agent-extension-notification"
3772
+ });
3773
+ }
3774
+ return app;
3775
+ }
3651
3776
  function legacyClientApp(implementation) {
3652
3777
  const app = client().onRequest(CLIENT_METHODS.session_request_permission, (ctx) => implementation.requestPermission(ctx.params)).onNotification(CLIENT_METHODS.session_update, (ctx) => implementation.sessionUpdate(ctx.params)).onRequest(CLIENT_METHODS.fs_write_text_file, async (ctx) => await implementation.writeTextFile?.(ctx.params) ?? {}).onRequest(CLIENT_METHODS.fs_read_text_file, async (ctx) => await implementation.readTextFile?.(ctx.params)).onRequest(CLIENT_METHODS.terminal_create, async (ctx) => await implementation.createTerminal?.(ctx.params)).onRequest(CLIENT_METHODS.terminal_output, async (ctx) => await implementation.terminalOutput?.(ctx.params)).onRequest(CLIENT_METHODS.terminal_release, async (ctx) => await implementation.releaseTerminal?.(ctx.params) ?? {}).onRequest(CLIENT_METHODS.terminal_wait_for_exit, async (ctx) => await implementation.waitForTerminalExit?.(ctx.params)).onRequest(CLIENT_METHODS.terminal_kill, async (ctx) => await implementation.killTerminal?.(ctx.params) ?? {});
3653
3778
  if (implementation.unstable_createElicitation) {
@@ -3682,6 +3807,265 @@ function legacyClientApp(implementation) {
3682
3807
  }
3683
3808
  return app;
3684
3809
  }
3810
+ class AgentSideConnection {
3811
+ connection;
3812
+ /**
3813
+ * Creates a new agent-side connection to a client.
3814
+ *
3815
+ * This establishes the communication channel from the agent's perspective
3816
+ * following the ACP specification.
3817
+ *
3818
+ * @param toAgent - A function that creates an Agent handler to process incoming client requests
3819
+ * @param stream - The bidirectional message stream for communication. Typically created using
3820
+ * {@link ndJsonStream} for stdio-based connections.
3821
+ *
3822
+ * See protocol docs: [Communication Model](https://agentclientprotocol.com/protocol/overview#communication-model)
3823
+ *
3824
+ * @deprecated Prefer `agent({ name }).connect(stream)`.
3825
+ */
3826
+ constructor(toAgent, stream) {
3827
+ this.connection = legacyAgentApp(toAgent(this))[appBuilder]().connect(stream, stableConnectionOptions);
3828
+ }
3829
+ /**
3830
+ * Handles session update notifications from the agent.
3831
+ *
3832
+ * This is a notification endpoint (no response expected) that sends
3833
+ * real-time updates about session progress, including message chunks,
3834
+ * tool calls, and execution plans.
3835
+ *
3836
+ * Note: Clients SHOULD continue accepting tool call updates even after
3837
+ * sending a `session/cancel` notification, as the agent may send final
3838
+ * updates before responding with the cancelled stop reason.
3839
+ *
3840
+ * See protocol docs: [Agent Reports Output](https://agentclientprotocol.com/protocol/prompt-turn#3-agent-reports-output)
3841
+ */
3842
+ sessionUpdate(params) {
3843
+ return this.connection.sendNotification(CLIENT_METHODS.session_update, params);
3844
+ }
3845
+ /**
3846
+ * Requests permission from the user for a tool call operation.
3847
+ *
3848
+ * Called by the agent when it needs user authorization before executing
3849
+ * a potentially sensitive operation. The client should present the options
3850
+ * to the user and return their decision.
3851
+ *
3852
+ * If the client cancels the prompt turn via `session/cancel`, it MUST
3853
+ * respond to this request with `RequestPermissionOutcome::Cancelled`.
3854
+ *
3855
+ * See protocol docs: [Requesting Permission](https://agentclientprotocol.com/protocol/tool-calls#requesting-permission)
3856
+ */
3857
+ requestPermission(params) {
3858
+ return this.connection.sendRequest(CLIENT_METHODS.session_request_permission, params);
3859
+ }
3860
+ /**
3861
+ * Reads content from a text file in the client's file system.
3862
+ *
3863
+ * Only available if the client advertises the `fs.readTextFile` capability.
3864
+ * Allows the agent to access file contents within the client's environment.
3865
+ *
3866
+ * See protocol docs: [Client](https://agentclientprotocol.com/protocol/overview#client)
3867
+ */
3868
+ readTextFile(params) {
3869
+ return this.connection.sendRequest(CLIENT_METHODS.fs_read_text_file, params);
3870
+ }
3871
+ /**
3872
+ * Writes content to a text file in the client's file system.
3873
+ *
3874
+ * Only available if the client advertises the `fs.writeTextFile` capability.
3875
+ * Allows the agent to create or modify files within the client's environment.
3876
+ *
3877
+ * See protocol docs: [Client](https://agentclientprotocol.com/protocol/overview#client)
3878
+ */
3879
+ writeTextFile(params) {
3880
+ return this.connection.sendRequest(CLIENT_METHODS.fs_write_text_file, params, emptyObjectResponse);
3881
+ }
3882
+ /**
3883
+ * Executes a command in a new terminal.
3884
+ *
3885
+ * Returns a `TerminalHandle` that can be used to get output, wait for exit,
3886
+ * kill the command, or release the terminal.
3887
+ *
3888
+ * The terminal can also be embedded in tool calls by using its ID in
3889
+ * `ToolCallContent` with type "terminal".
3890
+ *
3891
+ * @param params - The terminal creation parameters
3892
+ * @returns A handle to control and monitor the terminal
3893
+ */
3894
+ createTerminal(params) {
3895
+ return this.connection.sendRequest(CLIENT_METHODS.terminal_create, params, (response) => TerminalHandle.create(response.terminalId, params.sessionId, this.connection));
3896
+ }
3897
+ /**
3898
+ * **UNSTABLE**
3899
+ *
3900
+ * This capability is not part of the spec yet, and may be removed or changed at any point.
3901
+ *
3902
+ * Creates an elicitation to request input from the user.
3903
+ *
3904
+ * @experimental
3905
+ */
3906
+ unstable_createElicitation(params) {
3907
+ return this.connection.sendRequest(CLIENT_METHODS.elicitation_create, params);
3908
+ }
3909
+ /**
3910
+ * **UNSTABLE**
3911
+ *
3912
+ * This capability is not part of the spec yet, and may be removed or changed at any point.
3913
+ *
3914
+ * Notifies the client that a URL-based elicitation is complete.
3915
+ *
3916
+ * @experimental
3917
+ */
3918
+ unstable_completeElicitation(params) {
3919
+ return this.connection.sendNotification(CLIENT_METHODS.elicitation_complete, params);
3920
+ }
3921
+ request(method, params, options) {
3922
+ const spec = clientRequestSpecsByMethod[method];
3923
+ return this.connection.sendRequest(method, params, spec?.mapResponse, options);
3924
+ }
3925
+ notify(method, params) {
3926
+ return this.connection.sendNotification(method, params);
3927
+ }
3928
+ /**
3929
+ * Extension method.
3930
+ *
3931
+ * @deprecated Use {@link request}.
3932
+ */
3933
+ extMethod(method, params) {
3934
+ return this.request(method, params);
3935
+ }
3936
+ /**
3937
+ * Extension notification.
3938
+ *
3939
+ * @deprecated Use {@link notify}.
3940
+ */
3941
+ extNotification(method, params) {
3942
+ return this.notify(method, params);
3943
+ }
3944
+ /**
3945
+ * AbortSignal that aborts when the connection closes.
3946
+ *
3947
+ * This signal can be used to:
3948
+ * - Listen for connection closure: `connection.signal.addEventListener('abort', () => {...})`
3949
+ * - Check connection status synchronously: `if (connection.signal.aborted) {...}`
3950
+ * - Pass to other APIs (fetch, setTimeout) for automatic cancellation
3951
+ *
3952
+ * The connection closes when the underlying stream ends, either normally or due to an error.
3953
+ *
3954
+ * @example
3955
+ * ```typescript
3956
+ * const connection = new AgentSideConnection(agent, stream);
3957
+ *
3958
+ * // Listen for closure
3959
+ * connection.signal.addEventListener('abort', () => {
3960
+ * console.log('Connection closed - performing cleanup');
3961
+ * });
3962
+ *
3963
+ * // Check status
3964
+ * if (connection.signal.aborted) {
3965
+ * console.log('Connection is already closed');
3966
+ * }
3967
+ *
3968
+ * // Pass to other APIs
3969
+ * fetch(url, { signal: connection.signal });
3970
+ * ```
3971
+ */
3972
+ get signal() {
3973
+ return this.connection.signal;
3974
+ }
3975
+ /**
3976
+ * Promise that resolves when the connection closes.
3977
+ *
3978
+ * The connection closes when the underlying stream ends, either normally or due to an error.
3979
+ * Once closed, the connection cannot send or receive any more messages.
3980
+ *
3981
+ * This is useful for async/await style cleanup:
3982
+ *
3983
+ * @example
3984
+ * ```typescript
3985
+ * const connection = new AgentSideConnection(agent, stream);
3986
+ * await connection.closed;
3987
+ * console.log('Connection closed - performing cleanup');
3988
+ * ```
3989
+ */
3990
+ get closed() {
3991
+ return this.connection.closed;
3992
+ }
3993
+ }
3994
+ class TerminalHandle {
3995
+ /**
3996
+ * Terminal identifier returned by `terminal/create`.
3997
+ */
3998
+ id;
3999
+ sessionId;
4000
+ connection;
4001
+ constructor(id, sessionId, conn) {
4002
+ this.id = id;
4003
+ this.sessionId = sessionId;
4004
+ this.connection = conn;
4005
+ }
4006
+ /** @internal */
4007
+ static create(id, sessionId, conn) {
4008
+ return new TerminalHandle(id, sessionId, conn);
4009
+ }
4010
+ /**
4011
+ * Gets the current terminal output without waiting for the command to exit.
4012
+ */
4013
+ currentOutput() {
4014
+ return this.connection.sendRequest(CLIENT_METHODS.terminal_output, {
4015
+ sessionId: this.sessionId,
4016
+ terminalId: this.id
4017
+ });
4018
+ }
4019
+ /**
4020
+ * Waits for the terminal command to complete and returns its exit status.
4021
+ */
4022
+ waitForExit() {
4023
+ return this.connection.sendRequest(CLIENT_METHODS.terminal_wait_for_exit, {
4024
+ sessionId: this.sessionId,
4025
+ terminalId: this.id
4026
+ });
4027
+ }
4028
+ /**
4029
+ * Kills the terminal command without releasing the terminal.
4030
+ *
4031
+ * The terminal remains valid after killing, allowing you to:
4032
+ * - Get the final output with `currentOutput()`
4033
+ * - Check the exit status
4034
+ * - Release the terminal when done
4035
+ *
4036
+ * Useful for implementing timeouts or cancellation.
4037
+ */
4038
+ kill() {
4039
+ return this.connection.sendRequest(CLIENT_METHODS.terminal_kill, {
4040
+ sessionId: this.sessionId,
4041
+ terminalId: this.id
4042
+ }, emptyObjectResponse);
4043
+ }
4044
+ /**
4045
+ * Releases the terminal and frees all associated resources.
4046
+ *
4047
+ * If the command is still running, it will be killed.
4048
+ * After release, the terminal ID becomes invalid and cannot be used
4049
+ * with other terminal methods.
4050
+ *
4051
+ * Tool calls that already reference this terminal will continue to
4052
+ * display its output.
4053
+ *
4054
+ * **Important:** Always call this method when done with the terminal.
4055
+ */
4056
+ release() {
4057
+ return this.connection.sendRequest(CLIENT_METHODS.terminal_release, {
4058
+ sessionId: this.sessionId,
4059
+ terminalId: this.id
4060
+ }, emptyObjectResponse);
4061
+ }
4062
+ /**
4063
+ * Releases the terminal when used with `await using`.
4064
+ */
4065
+ async [Symbol.asyncDispose]() {
4066
+ await this.release();
4067
+ }
4068
+ }
3685
4069
  class ClientSideConnection {
3686
4070
  connection;
3687
4071
  /**
@@ -4113,21 +4497,13 @@ class ClientSideConnection {
4113
4497
  return this.connection.closed;
4114
4498
  }
4115
4499
  }
4116
- const name = "acp-extension-claude";
4117
- const version = "0.66.0";
4118
- const dependencies = { "@anthropic-ai/claude-agent-sdk": "0.3.220" };
4119
- const packageJson = {
4120
- name,
4121
- version,
4122
- dependencies
4123
- };
4124
4500
  export {
4501
+ AgentSideConnection as A,
4125
4502
  ClientSideConnection as C,
4126
4503
  PROTOCOL_VERSION as P,
4127
4504
  RequestError as R,
4128
4505
  CreateElicitationResponse as a,
4129
4506
  agent as b,
4130
4507
  methods as m,
4131
- ndJsonStream as n,
4132
- packageJson as p
4508
+ ndJsonStream as n
4133
4509
  };
@@ -20938,12 +20938,13 @@ var Logger = class {
20938
20938
  var logger = new Logger();
20939
20939
  function startCodexConnection(codexPath, env) {
20940
20940
  const spawnEnv = process.env;
20941
+ const spawnOptions = { env: spawnEnv, windowsHide: true };
20941
20942
  let codex;
20942
20943
  if (codexPath) {
20943
- codex = process.platform === "win32" ? spawn(`"${codexPath}" app-server`, { shell: true, env: spawnEnv }) : spawn(codexPath, ["app-server"], { env: spawnEnv });
20944
+ codex = process.platform === "win32" ? spawn(`"${codexPath}" app-server`, { ...spawnOptions, shell: true }) : spawn(codexPath, ["app-server"], spawnOptions);
20944
20945
  } else {
20945
20946
  const bundledCodexPath = createRequire$1(import.meta.url).resolve("@openai/codex/bin/codex.js");
20946
- codex = spawn(process.execPath, [bundledCodexPath, "app-server"], { env: spawnEnv });
20947
+ codex = spawn(process.execPath, [bundledCodexPath, "app-server"], spawnOptions);
20947
20948
  }
20948
20949
  attachLogs(codex);
20949
20950
  const reader = createJSONRPCReader(codex.stdout);
@@ -0,0 +1,11 @@
1
+ const name = "acp-extension-claude";
2
+ const version = "0.66.0";
3
+ const dependencies = { "@anthropic-ai/claude-agent-sdk": "0.3.220" };
4
+ const packageJson = {
5
+ name,
6
+ version,
7
+ dependencies
8
+ };
9
+ export {
10
+ packageJson as p
11
+ };