FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
browsercode/packages/opencode/src/cli/cmd/github.shared.ts at main · code2labgit/browsercode · GitHub
code2labgit
/
browsercode
Public
forked from
browser-use/browsercode
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
browsercode
/
packages
/
opencode
/
src
/
cli
/
cmd
/
github.shared.ts
Copy path
More file actions
More file actions
Latest commit
History
History
History
30 lines (25 loc) · 1.2 KB
Breadcrumbs
browsercode
/
packages
/
opencode
/
src
/
cli
/
cmd
/
github.shared.ts
Copy path
File metadata and controls
30 lines (25 loc) · 1.2 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import
type
{
SessionV1
}
from
"@opencode-ai/core/v1/session"
export
{
parseGitHubRemote
}
from
"@/util/repository"
/**
* Extracts displayable text from assistant response parts.
* Returns null for non-text responses (signals summary needed).
* Throws only for truly empty responses.
*/
export
function
extractResponseText
(
parts
:
SessionV1
.
Part
[
]
)
:
string
|
null
{
const
textPart
=
parts
.
findLast
(
(
p
)
=>
p
.
type
===
"text"
)
if
(
textPart
)
return
textPart
.
text
// Non-text parts (tools, reasoning, step-start/step-finish, etc.) - signal summary needed
if
(
parts
.
length
>
0
)
return
null
throw
new
Error
(
"Failed to parse response: no parts returned"
)
}
/**
* Formats a PROMPT_TOO_LARGE error message with details about files in the prompt.
* Content is base64 encoded, so we calculate original size by multiplying by 0.75.
*/
export
function
formatPromptTooLargeError
(
files
:
{
filename
:
string
;
content
:
string
}
[
]
)
:
string
{
const
fileDetails
=
files
.
length
>
0
?
`\n\nFiles in prompt:\n
${
files
.
map
(
(
f
)
=>
` -
${
f
.
filename
}
(
${
(
(
f
.
content
.
length
*
0.75
)
/
1024
)
.
toFixed
(
0
)
}
KB)`
)
.
join
(
"\n"
)
}
`
:
""
return
`PROMPT_TOO_LARGE: The prompt exceeds the model's context limit.
${
fileDetails
}
`
}
Back
|
FazBrowse Home
|
New Git URL