Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/agent/loop/AgentLoop.ts
Original file line number Diff line number Diff line change
Expand Up @@ -840,7 +840,10 @@ export class AgentLoop {
temperature: this.config.temperature,
thinking: this.config.thinking,
stream: true,
metadata: this.config.metadata,
metadata: {
...this.config.metadata,
pilotdeck_session: input.sessionId,
},
cacheBreakpoints: prepared.cacheBreakpoints,
};
}
Expand Down
53 changes: 49 additions & 4 deletions src/model/streaming/streamModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export async function complete(
const nonStreamingRequest = { ...request, stream: false };
const { provider } = validateModelRequest(nonStreamingRequest, config);
const body = buildModelRequest(nonStreamingRequest, config);
const response = await sendProviderRequest(provider, body, false, options.fetch ?? fetch, options.signal);
const response = await sendProviderRequest(provider, body, false, options.fetch ?? fetch, options.signal, request.metadata);

if (!response.ok) {
const raw = await safeReadJson(response);
Expand Down Expand Up @@ -74,7 +74,7 @@ export async function* streamModel(
}
let response: Response;
try {
response = await sendProviderRequest(provider, body, true, options.fetch ?? fetch, options.signal);
response = await sendProviderRequest(provider, body, true, options.fetch ?? fetch, options.signal, currentRequest.metadata);
} catch (error) {
if (attempt < MAX_STREAM_RETRIES && isRetryableStreamError(error)) {
await delay(1000 * (attempt + 1));
Expand Down Expand Up @@ -204,15 +204,17 @@ async function sendProviderRequest(
stream: boolean,
transport: ModelTransport,
signal?: AbortSignal,
metadata?: Record<string, unknown>,
): Promise<Response> {
const controller = new AbortController();
const detachAbort = signal ? forwardAbort(signal, controller) : undefined;
const timeout = provider.timeoutMs
? setTimeout(() => controller.abort(), provider.timeoutMs)
: undefined;

const finalBody = provider.extraBody
? { ...(body as Record<string, unknown>), ...provider.extraBody }
const resolvedExtraBody = resolveExtraBody(provider.extraBody, metadata);
const finalBody = resolvedExtraBody
? { ...(body as Record<string, unknown>), ...resolvedExtraBody }
: body;

try {
Expand Down Expand Up @@ -354,3 +356,46 @@ function isAbortError(error: unknown): boolean {
function joinUrl(base: string, path: string): string {
return `${base.replace(/\/+$/, "")}/${path.replace(/^\/+/, "")}`;
}

/**
* Resolve `${variable}` template strings in extraBody values against the
* provided metadata record. Supports dot-path lookups like
* `${pilotdeck_session}` or `${user.id}`.
*
* Values that are not strings, or strings without template expressions,
* are returned unchanged. Missing variables resolve to an empty string.
*/
function resolveExtraBody(
extraBody: Record<string, unknown> | undefined,
metadata: Record<string, unknown> | undefined,
): Record<string, unknown> | undefined {
if (!extraBody) return undefined;

const resolved: Record<string, unknown> = {};
for (const [key, value] of Object.entries(extraBody)) {
if (typeof value === "string") {
resolved[key] = value.replace(/\$\{([^}]+)\}/g, (_match, path: string) => {
const trimmed = path.trim();
const lookedUp = lookupMetadataPath(metadata, trimmed);
return lookedUp !== undefined ? String(lookedUp) : "";
});
} else {
resolved[key] = value;
}
}
return resolved;
}

function lookupMetadataPath(
metadata: Record<string, unknown> | undefined,
path: string,
): unknown {
if (!metadata) return undefined;
const segments = path.split(".");
let current: unknown = metadata;
for (const segment of segments) {
if (typeof current !== "object" || current === null) return undefined;
current = (current as Record<string, unknown>)[segment];
}
return current;
}
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
1 change: 1 addition & 0 deletions ui/dist.noauth.bak/assets/index-Bdue6VvE.css

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions ui/dist.noauth.bak/assets/index-Bz-nAIa4.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

617 changes: 617 additions & 0 deletions ui/dist.noauth.bak/assets/index-DMmLYClt.js

Large diffs are not rendered by default.

Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
33 changes: 33 additions & 0 deletions ui/dist.noauth.bak/assets/vendor-codemirror-Cyecodkc.js

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions ui/dist.noauth.bak/assets/vendor-react-QREEBBIX.js

Large diffs are not rendered by default.

72 changes: 72 additions & 0 deletions ui/dist.noauth.bak/assets/vendor-xterm-BgHoLdPP.js

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions ui/dist.noauth.bak/favicon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions ui/dist.noauth.bak/favicon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions ui/dist.noauth.bak/icons/icon-128x128.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions ui/dist.noauth.bak/icons/icon-144x144.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions ui/dist.noauth.bak/icons/icon-152x152.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions ui/dist.noauth.bak/icons/icon-192x192.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions ui/dist.noauth.bak/icons/icon-384x384.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions ui/dist.noauth.bak/icons/icon-512x512.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions ui/dist.noauth.bak/icons/icon-72x72.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions ui/dist.noauth.bak/icons/icon-96x96.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
52 changes: 52 additions & 0 deletions ui/dist.noauth.bak/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/favicon.svg?v=pd1" />
<link rel="icon" type="image/png" href="/favicon.png?v=pd1" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no, viewport-fit=cover" />
<title>PilotDeck</title>

<!-- PWA Manifest -->
<link rel="manifest" href="/manifest.json" crossorigin="use-credentials" />

<!-- iOS Safari PWA Meta Tags -->
<meta name="mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
<meta name="apple-mobile-web-app-title" content="PilotDeck" />

<!-- iOS Safari Icons -->
<link rel="apple-touch-icon" sizes="152x152" href="/icons/icon-152x152.png?v=pd1" />
<link rel="apple-touch-icon" sizes="180x180" href="/icons/icon-192x192.png?v=pd1" />

<!-- Theme Color -->
<meta name="theme-color" content="#ffffff" />
<meta name="msapplication-TileColor" content="#ffffff" />

<!-- Prevent zoom on iOS -->
<meta name="format-detection" content="telephone=no" />
<script type="module" crossorigin src="/assets/index-DMmLYClt.js"></script>
<link rel="modulepreload" crossorigin href="/assets/vendor-react-QREEBBIX.js">
<link rel="modulepreload" crossorigin href="/assets/vendor-codemirror-Cyecodkc.js">
<link rel="modulepreload" crossorigin href="/assets/vendor-xterm-BgHoLdPP.js">
<link rel="stylesheet" crossorigin href="/assets/index-Bdue6VvE.css">
</head>
<body>
<div id="root"></div>

<!-- Service Worker Registration -->
<script>
if ('serviceWorker' in navigator) {
window.addEventListener('load', () => {
navigator.serviceWorker.register('/sw.js')
.then(registration => {
console.log('SW registered: ', registration);
})
.catch(registrationError => {
console.log('SW registration failed: ', registrationError);
});
});
}
</script>
</body>
</html>
3 changes: 3 additions & 0 deletions ui/dist.noauth.bak/logo-128.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions ui/dist.noauth.bak/logo-256.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions ui/dist.noauth.bak/logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
61 changes: 61 additions & 0 deletions ui/dist.noauth.bak/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
{
"name": "PilotDeck",
"short_name": "PilotDeck",
"description": "PilotDeck — agent-driven development workspace",
"start_url": "/",
"display": "standalone",
"background_color": "#ffffff",
"theme_color": "#ffffff",
"orientation": "portrait-primary",
"scope": "/",
"icons": [
{
"src": "/icons/icon-72x72.png?v=pd1",
"sizes": "72x72",
"type": "image/png",
"purpose": "maskable any"
},
{
"src": "/icons/icon-96x96.png?v=pd1",
"sizes": "96x96",
"type": "image/png",
"purpose": "maskable any"
},
{
"src": "/icons/icon-128x128.png?v=pd1",
"sizes": "128x128",
"type": "image/png",
"purpose": "maskable any"
},
{
"src": "/icons/icon-144x144.png?v=pd1",
"sizes": "144x144",
"type": "image/png",
"purpose": "maskable any"
},
{
"src": "/icons/icon-152x152.png?v=pd1",
"sizes": "152x152",
"type": "image/png",
"purpose": "maskable any"
},
{
"src": "/icons/icon-192x192.png?v=pd1",
"sizes": "192x192",
"type": "image/png",
"purpose": "maskable any"
},
{
"src": "/icons/icon-384x384.png?v=pd1",
"sizes": "384x384",
"type": "image/png",
"purpose": "maskable any"
},
{
"src": "/icons/icon-512x512.png?v=pd1",
"sizes": "512x512",
"type": "image/png",
"purpose": "maskable any"
}
]
}
Loading