MCPcopy Index your code
hub / github.com/google/adk-python / stream

Method stream

src/google/adk/cli/browser/main-3CUQG2IN.js:220–220  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

218`){let a=this.continueScalar(t+1);if(a===-1)break;t=Math.max(t,a-2)}}else{if(e&&r6.has(n))break;A=t}return!n&&!this.atEnd?this.setNext("plain-scalar"):(yield a6,yield*Ie(this.pushToIndex(A+1,!0)),e?"flow":"doc")}*pushCount(e){return e>0?(yield this.buffer.substr(this.pos,e),this.pos+=e,e):0}*pushToIndex(e,A){let t=this.buffer.slice(this.pos,e);return t?(yield t,this.pos+=t.length,t.length):(A&&(yield""),0)}*pushIndicators(){switch(this.charAt(0)){case"!":return(yield*Ie(this.pushTag()))+(yield*Ie(this.pushSpaces(!0)))+(yield*Ie(this.pushIndicators()));case"&":return(yield*Ie(this.pushUntil($7)))+(yield*Ie(this.pushSpaces(!0)))+(yield*Ie(this.pushIndicators()));case"-":case"?":case":":{let e=this.flowLevel>0,A=this.charAt(1);if(ec(A)||e&&r6.has(A))return e?this.flowKey&&(this.flowKey=!1):this.indentNext=this.indentValue+1,(yield*Ie(this.pushCount(1)))+(yield*Ie(this.pushSpaces(!0)))+(yield*Ie(this.pushIndicators()))}}return 0}*pushTag(){if(this.charAt(1)==="<"){let e=this.pos+2,A=this.buffer[e];for(;!ec(A)&&A!==">";)A=this.buffer[++e];return yield*Ie(this.pushToIndex(A===">"?e+1:e,!1))}else{let e=this.pos+1,A=this.buffer[e];for(;A;)if(CsA.has(A))A=this.buffer[++e];else if(A==="%"&&sO.has(this.buffer[e+1])&&sO.has(this.buffer[e+2]))A=this.buffer[e+=3];else break;return yield*Ie(this.pushToIndex(e,!1))}}*pushNewline(){let e=this.buffer[this.pos];return e===`
219`?yield*Ie(this.pushCount(1)):e==="\r"&&this.charAt(1)===`
220`?yield*Ie(this.pushCount(2)):0}*pushSpaces(e){let A=this.pos-1,t;do t=this.buffer[++A];while(t===" "||e&&t===" ");let n=A-this.pos;return n>0&&(yield this.buffer.substr(this.pos,n),this.pos=A),n}*pushUntil(e){let A=this.pos,t=this.buffer[A];for(;!e(t);)t=this.buffer[++A];return yield*Ie(this.pushToIndex(A,!1))}};var vu=class{constructor(){this.lineStarts=[],this.addNewLine=e=>this.lineStarts.push(e),this.linePos=e=>{let A=0,t=this.lineStarts.length;for(;A<t;){let o=A+t>>1;this.lineStarts[o]<e?A=o+1:t=o}if(this.lineStarts[A]===e)return{line:A+1,col:1};if(A===0)return{line:0,col:e};let n=this.lineStarts[A-1];return{line:A,col:e-n+1}}}};function E2(i,e){for(let A=0;A<i.length;++A)if(i[A].type===e)return!0;return!1}function lO(i){for(let e=0;e<i.length;++e)switch(i[e].type){case"space":case"comment":case"newline":break;default:return e}return-1}function cO(i){switch(i?.type){case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":case"flow-collection":return!0;default:return!1}}function s6(i){switch(i.type){case"document":return i.start;case"block-map":{let e=i.items[i.items.length-1];return e.sep??e.start}case"block-seq":return i.items[i.items.length-1].start;default:return[]}}function RB(i){if(i.length===0)return[];let e=i.length;A:for(;--e>=0;)switch(i[e].type){case"doc-start":case"explicit-key-ind":case"map-value-ind":case"seq-item-ind":case"newline":break A}for(;i[++e]?.type==="space";);return i.splice(e,i.length)}function gO(i){if(i.start.type==="flow-seq-start")for(let e of i.items)e.sep&&!e.value&&!E2(e.start,"explicit-key-ind")&&!E2(e.sep,"map-value-ind")&&(e.key&&(e.value=e.key),delete e.key,cO(e.value)?e.value.end?Array.prototype.push.apply(e.value.end,e.sep):e.value.end=e.sep:Array.prototype.push.apply(e.start,e.sep),delete e.sep)}var bu=class{constructor(e){this.atNewLine=!0,this.atScalar=!1,this.indent=0,this.offset=0,this.onKeyLine=!1,this.stack=[],this.source="",this.type="",this.lexer=new Du,this.onNewLine=e}*parse(e,A=!1){this.onNewLine&&this.offset===0&&this.onNewLine(0);for(let t of this.lexer.lex(e,A))yield*Ie(this.next(t));A||(yield*Ie(this.end()))}*next(e){if(this.source=e,this.atScalar){this.atScalar=!1,yield*Ie(this.step()),this.offset+=e.length;return}let A=rO(e);if(A)if(A==="scalar")this.atNewLine=!1,this.atScalar=!0,this.type="scalar";else{switch(this.type=A,yield*Ie(this.step()),A){case"newline":this.atNewLine=!0,this.indent=0,this.onNewLine&&this.onNewLine(this.offset+e.length);break;case"space":this.atNewLine&&e[0]===" "&&(this.indent+=e.length);break;case"explicit-key-ind":case"map-value-ind":case"seq-item-ind":this.atNewLine&&(this.indent+=e.length);break;case"doc-mode":case"flow-error-end":return;default:this.atNewLine=!1}this.offset+=e.length}else{let t=`Not a YAML token: ${e}`;yield*Ie(this.pop({type:"error",offset:this.offset,message:t,source:e})),this.offset+=e.length}}*end(){for(;this.stack.length>0;)yield*Ie(this.pop())}get sourceToken(){return{type:this.type,offset:this.offset,indent:this.indent,source:this.source}}*step(){let e=this.peek(1);if(this.type==="doc-end"&&e?.type!=="doc-end"){for(;this.stack.length>0;)yield*Ie(this.pop());this.stack.push({type:"doc-end",offset:this.offset,source:this.source});return}if(!e)return yield*Ie(this.stream());switch(e.type){case"document":return yield*Ie(this.document(e));case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return yield*Ie(this.scalar(e));case"block-scalar":return yield*Ie(this.blockScalar(e));case"block-map":return yield*Ie(this.blockMap(e));case"block-seq":return yield*Ie(this.blockSequence(e));case"flow-collection":return yield*Ie(this.flowCollection(e));case"doc-end":return yield*Ie(this.documentEnd(e))}yield*Ie(this.pop())}peek(e){return this.stack[this.stack.length-e]}*pop(e){let A=e??this.stack.pop();if(!A)yield{type:"error",offset:this.offset,source:"",message:"Tried to pop an empty stack"};else if(this.stack.length===0)yield A;else{let t=this.peek(1);switch(A.type==="block-scalar"?A.indent="indent"in t?t.indent:0:A.type==="flow-collection"&&t.type==="document"&&(A.indent=0),A.type==="flow-collection"&&gO(A),t.type){case"document":t.value=A;break;case"block-scalar":t.props.push(A);break;case"block-map":{let n=t.items[t.items.length-1];if(n.value){t.items.push({start:[],key:A,sep:[]}),this.onKeyLine=!0;return}else if(n.sep)n.value=A;else{Object.assign(n,{key:A,sep:[]}),this.onKeyLine=!n.explicitKey;return}break}case"block-seq":{let n=t.items[t.items.length-1];n.value?t.items.push({start:[],value:A}):n.value=A;break}case"flow-collection":{let n=t.items[t.items.length-1];!n||n.value?t.items.push({start:[],key:A,sep:[]}):n.sep?n.value=A:Object.assign(n,{key:A,sep:[]});return}default:yield*Ie(this.pop()),yield*Ie(this.pop(A))}if((t.type==="document"||t.type==="block-map"||t.type==="block-seq")&&(A.type==="block-map"||A.type==="block-seq")){let n=A.items[A.items.length-1];n&&!n.sep&&!n.value&&n.start.length>0&&lO(n.start)===-1&&(A.indent===0||n.start.every(o=>o.type!=="comment"||o.indent<A.indent))&&(t.type==="document"?t.end=n.start:t.items.push({start:n.start}),A.items.splice(-1,1))}}}*stream(){switch(this.type){case"directive-line":yield{type:"directive",offset:this.offset,source:this.source};return;case"byte-order-mark":case"space":case"comment":case"newline":yield this.sourceToken;return;case"doc-mode":case"doc-start":{let e={type:"document",offset:this.offset,start:[]};this.type==="doc-start"&&e.start.push(this.sourceToken),this.stack.push(e);return}}yield{type:"error",offset:this.offset,message:`Unexpected ${this.type} token in YAML stream`,source:this.source}}*document(e){if(e.value)return yield*Ie(this.lineEnd(e));switch(this.type){case"doc-start":{lO(e.start)!==-1?(yield*Ie(this.pop()),yield*Ie(this.step())):e.start.push(this.sourceToken);return}case"anchor":case"tag":case"space":case"comment":case"newline":e.start.push(this.sourceToken);return}let A=this.startBlockValue(e);A?this.stack.push(A):yield{type:"error",offset:this.offset,message:`Unexpected ${this.type} token in YAML document`,source:this.source}}*scalar(e){if(this.type==="map-value-ind"){let A=s6(this.peek(2)),t=RB(A),n;e.end?(n=e.end,n.push(this.sourceToken),delete e.end):n=[this.sourceToken];let o={type:"block-map",offset:e.offset,indent:e.indent,items:[{start:t,key:e,sep:n}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=o}else yield*Ie(this.lineEnd(e))}*blockScalar(e){switch(this.type){case"space":case"comment":case"newline":e.props.push(this.sourceToken);return;case"scalar":if(e.source=this.source,this.atNewLine=!0,this.indent=0,this.onNewLine){let A=this.source.indexOf(`
221`)+1;for(;A!==0;)this.onNewLine(this.offset+A),A=this.source.indexOf(`
222`,A)+1}yield*Ie(this.pop());break;default:yield*Ie(this.pop()),yield*Ie(this.step())}}*blockMap(e){let A=e.items[e.items.length-1];switch(this.type){case"newline":if(this.onKeyLine=!1,A.value){let t="end"in A.value?A.value.end:void 0;(Array.isArray(t)?t[t.length-1]:void 0)?.type==="comment"?t?.push(this.sourceToken):e.items.push({start:[this.sourceToken]})}else A.sep?A.sep.push(this.sourceToken):A.start.push(this.sourceToken);return;case"space":case"comment":if(A.value)e.items.push({start:[this.sourceToken]});else if(A.sep)A.sep.push(this.sourceToken);else{if(this.atIndentedComment(A.start,e.indent)){let n=e.items[e.items.length-2]?.value?.end;if(Array.isArray(n)){Array.prototype.push.apply(n,A.start),n.push(this.sourceToken),e.items.pop();return}}A.start.push(this.sourceToken)}return}if(this.indent>=e.indent){let t=!this.onKeyLine&&this.indent===e.indent,n=t&&(A.sep||A.explicitKey)&&this.type!=="seq-item-ind",o=[];if(n&&A.sep&&!A.value){let a=[];for(let r=0;r<A.sep.length;++r){let s=A.sep[r];switch(s.type){case"newline":a.push(r);break;case"space":break;case"comment":s.indent>e.indent&&(a.length=0);break;default:a.length=0}}a.length>=2&&(o=A.sep.splice(a[1]))}switch(this.type){case"anchor":case"tag":n||A.value?(o.push(this.sourceToken),e.items.push({start:o}),this.onKeyLine=!0):A.sep?A.sep.push(this.sourceToken):A.start.push(this.sourceToken);return;case"explicit-key-ind":!A.sep&&!A.explicitKey?(A.start.push(this.sourceToken),A.explicitKey=!0):n||A.value?(o.push(this.sourceToken),e.items.push({start:o,explicitKey:!0})):this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken],explicitKey:!0}]}),this.onKeyLine=!0;return;case"map-value-ind":if(A.explicitKey)if(A.sep)if(A.value)e.items.push({start:[],key:null,sep:[this.sourceToken]});else if(E2(A.sep,"map-value-ind"))this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:o,key:null,sep:[this.sourceToken]}]});else if(cO(A.key)&&!E2(A.sep,"newline")){let a=RB(A.start),r=A.key,s=A.sep;s.push(this.sourceToken),delete A.key,delete A.sep,this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:a,key:r,sep:s}]})}else o.length>0?A.sep=A.sep.concat(o,this.sourceToken):A.sep.push(this.sourceToken);else if(E2(A.start,"newline"))Object.assign(A,{key:null,sep:[this.sourceToken]});else{let a=RB(A.start);this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:a,key:null,sep:[this.sourceToken]}]})}else A.sep?A.value||n?e.items.push({start:o,key:null,sep:[this.sourceToken]}):E2(A.sep,"map-value-ind")?this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:[],key:null,sep:[this.sourceToken]}]}):A.sep.push(this.sourceToken):Object.assign(A,{key:null,sep:[this.sourceToken]});this.onKeyLine=!0;return;case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":{let a=this.flowScalar(this.type);n||A.value?(e.items.push({start:o,key:a,sep:[]}),this.onKeyLine=!0):A.sep?this.stack.push(a):(Object.assign(A,{key:a,sep:[]}),this.onKeyLine=!0);return}default:{let a=this.startBlockValue(e);if(a){if(a.type==="block-seq"){if(!A.explicitKey&&A.sep&&!E2(A.sep,"newline")){yield*Ie(this.pop({type:"error",offset:this.offset,message:"Unexpected block-seq-ind on same line with key",source:this.source}));return}}else t&&e.items.push({start:o});this.stack.push(a);return}}}}yield*Ie(this.pop()),yield*Ie(this.step())}*blockSequence(e){let A=e.items[e.items.length-1];switch(this.type){case"newline":if(A.value){let t="end"in A.value?A.value.end:void 0;(Array.isArray(t)?t[t.length-1]:void 0)?.type==="comment"?t?.push(this.sourceToken):e.items.push({start:[this.sourceToken]})}else A.start.push(this.sourceToken);return;case"space":case"comment":if(A.value)e.items.push({start:[this.sourceToken]});else{if(this.atIndentedComment(A.start,e.indent)){let n=e.items[e.items.length-2]?.value?.end;if(Array.isArray(n)){Array.prototype.push.apply(n,A.start),n.push(this.sourceToken),e.items.pop();return}}A.start.push(this.sourceToken)}return;case"anchor":case"tag":if(A.value||this.indent<=e.indent)break;A.start.push(this.sourceToken);return;case"seq-item-ind":if(this.indent!==e.indent)break;A.value||E2(A.start,"seq-item-ind")?e.items.push({start:[this.sourceToken]}):A.start.push(this.sourceToken);return}if(this.indent>e.indent){let t=this.startBlockValue(e);if(t){this.stack.push(t);return}}yield*Ie(this.pop()),yield*Ie(this.step())}*flowCollection(e){let A=e.items[e.items.length-1];if(this.type==="flow-error-end"){let t;do yield*Ie(this.pop()),t=this.peek(1);while(t?.type==="flow-collection")}else if(e.end.length===0){switch(this.type){case"comma":case"explicit-key-ind":!A||A.sep?e.items.push({start:[this.sourceToken]}):A.start.push(this.sourceToken);return;case"map-value-ind":!A||A.value?e.items.push({start:[],key:null,sep:[this.sourceToken]}):A.sep?A.sep.push(this.sourceToken):Object.assign(A,{key:null,sep:[this.sourceToken]});return;case"space":case"comment":case"newline":case"anchor":case"tag":!A||A.value?e.items.push({start:[this.sourceToken]}):A.sep?A.sep.push(this.sourceToken):A.start.push(this.sourceToken);return;case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":{let n=this.flowScalar(this.type);!A||A.value?e.items.push({start:[],key:n,sep:[]}):A.sep?this.stack.push(n):Object.assign(A,{key:n,sep:[]});return}case"flow-map-end":case"flow-seq-end":e.end.push(this.sourceToken);return}let t=this.startBlockValue(e);t?this.stack.push(t):(yield*Ie(this.pop()),yield*Ie(this.step()))}else{let t=this.peek(2);if(t.type==="block-map"&&(this.type==="map-value-ind"&&t.indent===e.indent||this.type==="newline"&&!t.items[t.items.length-1].sep))yield*Ie(this.pop()),yield*Ie(this.step());else if(this.type==="map-value-ind"&&t.type!=="flow-collection"){let n=s6(t),o=RB(n);gO(e);let a=e.end.splice(1,e.end.length);a.push(this.sourceToken);let r={type:"block-map",offset:e.offset,indent:e.indent,items:[{start:o,key:e,sep:a}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=r}else yield*Ie(this.lineEnd(e))}}flowScalar(e){if(this.onNewLine){let A=this.source.indexOf(`
223`)+1;for(;A!==0;)this.onNewLine(this.offset+A),A=this.source.indexOf(`

Callers 7

_watch_job_completionMethod · 0.80
stepMethod · 0.80
constructorMethod · 0.80
v1Function · 0.80
run_agentMethod · 0.80
delete_sessionMethod · 0.80
_handle_streamingMethod · 0.80

Calls 1

pushMethod · 0.45

Tested by

no test coverage detected