-
Notifications
You must be signed in to change notification settings - Fork 128
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added Agent.build() and return
app
for use in serverless environmen…
…ts (#99)
- Loading branch information
Showing
8 changed files
with
1,905 additions
and
73 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import awsServerlessExpress from 'aws-serverless-express' | ||
import Agent, { | ||
type StepResult, | ||
type StepHandler, | ||
type TaskInput, | ||
type StepInput, | ||
} from 'agent-protocol' | ||
|
||
async function taskHandler(taskInput: TaskInput | null): Promise<StepHandler> { | ||
console.log(`task: ${taskInput}`) | ||
|
||
async function stepHandler(stepInput: StepInput | null): Promise<StepResult> { | ||
console.log(`step: ${stepInput}`) | ||
return { | ||
output: stepInput, | ||
} | ||
} | ||
|
||
return stepHandler | ||
} | ||
|
||
const app = Agent.handleTask(taskHandler, {}).build() | ||
const server = awsServerlessExpress.createServer(app) | ||
|
||
exports.handler = (event, context) => { | ||
awsServerlessExpress.proxy(server, event, context) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { onRequest } from 'firebase-functions/v2/https' | ||
import Agent, { | ||
type StepResult, | ||
type StepHandler, | ||
type TaskInput, | ||
type StepInput, | ||
} from 'agent-protocol' | ||
|
||
async function taskHandler(taskInput: TaskInput | null): Promise<StepHandler> { | ||
console.log(`task: ${taskInput}`) | ||
|
||
async function stepHandler(stepInput: StepInput | null): Promise<StepResult> { | ||
console.log(`step: ${stepInput}`) | ||
return { | ||
output: stepInput, | ||
} | ||
} | ||
|
||
return stepHandler | ||
} | ||
|
||
const app = Agent.handleTask(taskHandler, {}).build() | ||
|
||
export const agentprotocol = onRequest(app) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import functions from '@google-cloud/functions-framework' | ||
import Agent, { | ||
type StepResult, | ||
type StepHandler, | ||
type TaskInput, | ||
type StepInput, | ||
} from 'agent-protocol' | ||
|
||
async function taskHandler(taskInput: TaskInput | null): Promise<StepHandler> { | ||
console.log(`task: ${taskInput}`) | ||
|
||
async function stepHandler(stepInput: StepInput | null): Promise<StepResult> { | ||
console.log(`step: ${stepInput}`) | ||
return { | ||
output: stepInput, | ||
} | ||
} | ||
|
||
return stepHandler | ||
} | ||
|
||
const app = Agent.handleTask(taskHandler, {}).build() | ||
functions.http('agentprotocol', app) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters