# CoworkDeployedRoutineContext

The context a DEPLOYED routine receives (`cowork deploy` — it runs on a server, not on this
 computer): a subset of [CoworkRoutineContext](/docs/reference/sdk/interfaces/coworkroutinecontext.md). There is no Cowork around it, so it has
 no sign-in, no account secrets, no data folder and no consent prompts — calling a member
 that is not here fails.

## Properties

### auth

```ts
auth: object;
```

Always signed out: `getState()` → `{ authenticated: false, user: null }`,
 `getIdToken()` → null.

#### getIdToken

```ts
getIdToken: () => Promise<string | null>;
```

The ID token to call an authenticated API with — null when signed out, or when the
 token is too close to expiring to be trusted.

##### Returns

`Promise`\<`string` \| `null`\>

#### getState

```ts
getState: () => Promise<{
  authenticated: boolean;
  user:   | {
     displayName: string | null;
     email: string | null;
     uid: string;
   }
     | null;
}>;
```

`authenticated` and the account (`user`), or `user: null` when nobody is signed in.

##### Returns

`Promise`\<\{
  `authenticated`: `boolean`;
  `user`:   \| \{
     `displayName`: `string` \| `null`;
     `email`: `string` \| `null`;
     `uid`: `string`;
   \}
     \| `null`;
\}\>

***

### db?

```ts
db?: (path) => object;
```

A SQLite database where the target has one: in a container, files under its data
 folder (`COWORK_DATA_DIR`, default /data) — synchronous; on a Cloudflare Worker deployed
 with a D1 database, that database whatever the path — `query`/`exec` return Promises
 (`await` them and the routine runs on both) and `transaction` throws. Absent elsewhere.

#### Parameters

| Parameter | Type |
| ------ | ------ |
| `path` | `string` |

#### Returns

`object`

##### exec

```ts
exec: (sql, params?) => 
  | CoworkDbExecResult
| Promise<CoworkDbExecResult>;
```

###### Parameters

| Parameter | Type |
| ------ | ------ |
| `sql` | `string` |
| `params?` | `unknown`[] |

###### Returns

  \| [`CoworkDbExecResult`](/docs/reference/sdk/interfaces/coworkdbexecresult.md)
  \| `Promise`\<[`CoworkDbExecResult`](/docs/reference/sdk/interfaces/coworkdbexecresult.md)\>

##### query

```ts
query: (sql, params?) => 
  | CoworkDbQueryResult
| Promise<CoworkDbQueryResult>;
```

###### Parameters

| Parameter | Type |
| ------ | ------ |
| `sql` | `string` |
| `params?` | `unknown`[] |

###### Returns

  \| [`CoworkDbQueryResult`](/docs/reference/sdk/interfaces/coworkdbqueryresult.md)
  \| `Promise`\<[`CoworkDbQueryResult`](/docs/reference/sdk/interfaces/coworkdbqueryresult.md)\>

##### transaction

```ts
transaction: <T>(fn) => T;
```

###### Type Parameters

| Type Parameter |
| ------ |
| `T` |

###### Parameters

| Parameter | Type |
| ------ | ------ |
| `fn` | () => `T` |

###### Returns

`T`

***

### identity

```ts
identity: CoworkIdentity;
```

An anonymous caller: `user` and `organization` null.

***

### log

```ts
log: (...parts) => void;
```

A line in the platform's log (stderr).

#### Parameters

| Parameter | Type |
| ------ | ------ |
| ...`parts` | `unknown`[] |

#### Returns

`void`

***

### secrets

```ts
secrets: Pick<CoworkRoutineContext["secrets"], "get" | "list">;
```

The deployment's environment: `get(name)` is the variable of that name (the secrets you
 deployed with are set there); `list()` the names of those secrets.

***

### unchanged

```ts
unchanged: () => void;
```

Does nothing: a deployed run keeps no run list to leave it out of.

#### Returns

`void`

***

### workspaceRoot

```ts
workspaceRoot: string;
```

The deployment's `COWORK_WORKSPACE_ROOT`, else "/" — a deployed routine has no workspace.
