MCPcopy Create free account
hub / github.com/apache/maka / ptyControlOperation

Function ptyControlOperation

packages/runtime/src/shell-run-tool-result.ts:73–105  ·  view source on GitHub ↗
(
  input: ShellRunWriteInput,
  outcome: {
    inputQueued: boolean;
    resizeApplied: boolean;
    resizeChanged: boolean;
    failed?: boolean;
  },
)

Source from the content-addressed store, hash-verified

71}
72
73export function ptyControlOperation(
74 input: ShellRunWriteInput,
75 outcome: {
76 inputQueued: boolean;
77 resizeApplied: boolean;
78 resizeChanged: boolean;
79 failed?: boolean;
80 },
81): Extract<ShellRunOperation, { kind: 'pty_control' }> {
82 const terminalInput =
83 input.input !== undefined
84 ? Buffer.byteLength(input.input, 'utf8')
85 : input.actions
86 ? encodedTerminalInputActionsByteLength(input.actions)
87 : undefined;
88 return {
89 kind: 'pty_control',
90 failed: outcome.failed === true,
91 ...(terminalInput !== undefined
92 ? { input: { bytes: terminalInput, queued: outcome.inputQueued } }
93 : {}),
94 ...(input.size
95 ? {
96 resize: {
97 cols: input.size.cols,
98 rows: input.size.rows,
99 applied: outcome.resizeApplied,
100 changed: outcome.resizeChanged,
101 },
102 }
103 : {}),
104 };
105}
106
107function terminalResultStatus(status: ShellRunStatus): TerminalToolResult['status'] {
108 switch (status) {

Callers 2

writeStdinMethod · 0.85
writeStdinWithoutLiveMethod · 0.85

Tested by

no test coverage detected