Skip to content

Commit a6ce671

Browse files
committed
Preserve original chat execution admission and actor-scoped Stop intent
1 parent ae6ac39 commit a6ce671

51 files changed

Lines changed: 32851 additions & 252 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎apps/sim/app/api/copilot/api-keys/validate/route.ts‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,8 @@ export const POST = withRouteHandler((req: NextRequest) =>
391391
protocol !== COPILOT_BILLING_PROTOCOL.direct &&
392392
!localUnbilledCallback &&
393393
!workspaceId &&
394-
!organizationId
394+
!organizationId &&
395+
!req.headers.has('x-mothership-execution-stream-id')
395396
) {
396397
span.setAttribute(TraceAttr.CopilotValidateOutcome, CopilotValidateOutcome.InvalidBody)
397398
span.setAttribute(TraceAttr.HttpStatusCode, 400)
@@ -400,6 +401,7 @@ export const POST = withRouteHandler((req: NextRequest) =>
400401
/** Direct keys carry self-hosted scope IDs that do not name hosted Sim resources. */
401402
if (protocol !== COPILOT_BILLING_PROTOCOL.direct && !localUnbilledCallback) {
402403
await authorizeCopilotChatCallback({
404+
executionStreamId: req.headers.get('x-mothership-execution-stream-id') ?? undefined,
403405
userId,
404406
workspaceId,
405407
organizationId,

‎apps/sim/app/api/files/uploads/purposes.ts‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,11 @@ function requireSessionScope(value: string | null, label = 'scope'): string {
250250

251251
async function principalUserId(principal: Principal, workspaceId?: string): Promise<string> {
252252
switch (principal.kind) {
253+
case 'personal_chat_delegated':
254+
throw new UploadSessionError(
255+
'forbidden',
256+
'Personal chat delegation cannot create workspace uploads'
257+
)
253258
case 'resource_delegated':
254259
throw new UploadSessionError(
255260
'forbidden',

‎apps/sim/app/api/mothership/integrations/catalog/route.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import {
1313

1414
export const POST = defineInternalJsonRoute({
1515
contract: readIntegrationCatalogContract,
16-
auth: internalCopilotAuth(INTEGRATION_CATALOG_AUDIENCE, { organization: true }),
16+
auth: internalCopilotAuth(INTEGRATION_CATALOG_AUDIENCE, { organization: true, personal: true }),
1717
operation: readIntegrationCatalogOperation,
1818
rateLimit: internalRateLimits.none({
1919
reason: 'Private bounded catalog discovery rechecks current authorization on every request.',

‎apps/sim/app/api/mothership/memories/access/route.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import {
1313

1414
export const POST = defineInternalJsonRoute({
1515
contract: resolveMemoryNotesAccessContract,
16-
auth: internalCopilotAuth(MEMORY_NOTES_ACCESS_AUDIENCE, { organization: true }),
16+
auth: internalCopilotAuth(MEMORY_NOTES_ACCESS_AUDIENCE, { organization: true, personal: true }),
1717
operation: resolveMemoryNotesAccessOperation,
1818
rateLimit: internalRateLimits.none({
1919
reason:

‎apps/sim/app/api/mothership/memory/scope/route.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import {
1313

1414
export const POST = defineInternalJsonRoute({
1515
contract: readMemoryScopeContract,
16-
auth: internalCopilotAuth(MEMORY_SCOPE_AUDIENCE, { organization: true }),
16+
auth: internalCopilotAuth(MEMORY_SCOPE_AUDIENCE, { organization: true, personal: true }),
1717
operation: readMemoryScopeOperation,
1818
rateLimit: internalRateLimits.none({
1919
reason: 'Authenticated worker resolves its current private chat memory scope.',

‎apps/sim/app/api/mothership/runs/control/route.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import {
1313

1414
export const POST = defineInternalJsonRoute({
1515
contract: readRunControlContract,
16-
auth: internalCopilotAuth(RUN_CONTROL_AUDIENCE, { organization: true }),
16+
auth: internalCopilotAuth(RUN_CONTROL_AUDIENCE, { organization: true, personal: true }),
1717
operation: readRunControlOperation,
1818
rateLimit: internalRateLimits.none({
1919
reason: 'Worker reconciles durable cancellation for its own run.',

‎apps/sim/app/api/mothership/tasks/workflow-status/route.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { readWatchedWorkflowStatus } from '@/lib/mothership/tasks/application/re
1111

1212
export const POST = defineInternalJsonRoute({
1313
contract: workflowWatchStatusContract,
14-
auth: internalCopilotAuth(TASK_DELEGATION_AUDIENCE, { organization: true }),
14+
auth: internalCopilotAuth(TASK_DELEGATION_AUDIENCE, { organization: true, personal: true }),
1515
operation: taskOperations.readWorkflowStatus,
1616
rateLimit: internalRateLimits.none({
1717
reason: 'Authenticated worker reconciles its bounded task inbox.',

‎apps/sim/app/api/mothership/workspaces/context/route.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import { WORKSPACE_TARGET_AUDIENCE } from '@/lib/mothership/chat/application/wor
1313

1414
export const POST = defineInternalJsonRoute({
1515
contract: readWorkspaceContextContract,
16-
auth: internalCopilotAuth(WORKSPACE_TARGET_AUDIENCE, { organization: true }),
16+
auth: internalCopilotAuth(WORKSPACE_TARGET_AUDIENCE, { organization: true, personal: true }),
1717
operation: readWorkspaceContextOperation,
1818
rateLimit: internalRateLimits.none({
1919
reason:

‎apps/sim/lib/core/application/operation.ts‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,12 @@ export function assertOperationOAuthPolicy(
115115
*/
116116
export type PrincipalKind = Exclude<
117117
Principal['kind'],
118-
'credential_group_enrollment' | 'system' | 'scim_connection' | 'slack_installation' | 'slack_app'
118+
| 'credential_group_enrollment'
119+
| 'system'
120+
| 'scim_connection'
121+
| 'slack_installation'
122+
| 'slack_app'
123+
| 'personal_chat_delegated'
119124
>
120125

121126
/**

‎apps/sim/lib/core/application/workspace-authorization.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ export function capabilityGovernedPrincipalUserId(principal: Principal): string
5555
case 'slack_installation':
5656
case 'slack_app':
5757
return null
58+
case 'personal_chat_delegated':
5859
case 'resource_delegated':
5960
case 'organization_delegated':
6061
return principal.subjectUserId

0 commit comments

Comments
 (0)