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

Method startPipe

packages/runtime/src/shell-run-manager.ts:726–803  ·  view source on GitHub ↗
(
    input: ShellRunBashInput,
    shellRunId: string,
    timeoutMs: number | undefined,
    forwardLive: boolean,
    slotReservation: ShellRunSlotReservation,
    sessionEpoch: number,
    onLiveAdmission: ((live: LiveShellRun) => void) | undefined,
  )

Source from the content-addressed store, hash-verified

724 }
725
726 private async startPipe(
727 input: ShellRunBashInput,
728 shellRunId: string,
729 timeoutMs: number | undefined,
730 forwardLive: boolean,
731 slotReservation: ShellRunSlotReservation,
732 sessionEpoch: number,
733 onLiveAdmission: ((live: LiveShellRun) => void) | undefined,
734 ): Promise<LivePipeShellRun> {
735 const collector = new PipeTailCollector(this.maxRetainedChars);
736 const pending: Array<(live: LivePipeShellRun) => void> = [];
737 let live: LivePipeShellRun | undefined;
738 let startingRecord: ShellRunRecord | undefined;
739 let spawnAttempted = false;
740 const dispatch = (callback: (target: LivePipeShellRun) => void): void => {
741 if (live) callback(live);
742 else pending.push(callback);
743 };
744 try {
745 const plan = input.argv
746 ? {
747 file: requireProgram(input.argv),
748 args: [...input.argv.slice(1)],
749 useShellOption: false,
750 }
751 : buildShellSpawnPlan(
752 input.shell ?? defaultShellPlan(),
753 input.command,
754 input.env ?? process.env,
755 );
756 startingRecord = await this.createStartingRecord(
757 input,
758 shellRunId,
759 timeoutMs,
760 collector.snapshot(),
761 );
762 this.assertStartupAllowed(input.sessionId, sessionEpoch, input.abortSignal);
763 spawnAttempted = true;
764 const driver = new PipeProcessDriver({
765 plan,
766 cwd: input.cwd,
767 ...((plan.env ?? input.env) ? { env: plan.env ?? input.env } : {}),
768 ...(input.fdInputs ? { fdInputs: input.fdInputs } : {}),
769 outputDrainMs: this.pipeOutputDrainMs,
770 onData: (stream, data) => dispatch((target) => this.onPipeData(target, stream, data)),
771 onRootExit: () => dispatch((target) => this.onNativeRootExit(target)),
772 onExit: (exit) =>
773 dispatch((target) => this.onDriverExit(target, { mode: 'pipes', value: exit })),
774 onFailure: (error) => dispatch((target) => this.handleIntegrityFailure(target, error)),
775 });
776 live = {
777 ...this.createLiveBase(input, startingRecord, 'pipes', timeoutMs, slotReservation),
778 mode: 'pipes',
779 driver,
780 collector,
781 pendingFlushChars: 0,
782 forwardLive,
783 liveEmitted: { stdout: 0, stderr: 0 },

Callers 1

startMethod · 0.95

Calls 15

createStartingRecordMethod · 0.95
snapshotMethod · 0.95
assertStartupAllowedMethod · 0.95
onPipeDataMethod · 0.95
onNativeRootExitMethod · 0.95
onDriverExitMethod · 0.95
createLiveBaseMethod · 0.95
writeInputsMethod · 0.95
armTimeoutMethod · 0.95
markRunningMethod · 0.95

Tested by

no test coverage detected